:root {
  color-scheme: light;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: #17202a;
  background: #f5f7f8;
  letter-spacing: 0;
}

* { box-sizing: border-box; }

body { margin: 0; min-height: 100vh; }

button, textarea { font: inherit; letter-spacing: 0; }

.topbar {
  min-height: 76px;
  padding: 14px clamp(18px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #fff;
  background: #18252b;
  border-bottom: 4px solid #22a06b;
}

.eyebrow { margin: 0 0 2px; color: #8ce0bd; font-size: 11px; font-weight: 700; }
h1 { margin: 0; font-size: 24px; line-height: 1.2; }
.account { color: #dbe4e8; font-size: 13px; text-align: right; overflow-wrap: anywhere; }

main { width: min(1600px, calc(100% - 32px)); margin: 16px auto 24px; }
.workspace { display: block; }
.files-view { grid-template-columns: minmax(0, 1fr) !important; }
.files-panel { min-width: 0; background: #fff; border: 1px solid #d8e0e4; border-radius: 6px; }
.files-actions, .files-location { display: flex; align-items: center; gap: 10px; }
.files-location { padding: 14px 18px; background: #f7f9fa; border-bottom: 1px solid #e3e8eb; }
.files-location code { overflow-wrap: anywhere; min-width: 0; }
.files-transfer { padding: 0 18px; }
.files-transfer p { color: #53656d; font-size: 13px; }
.files-transfer progress { width: 100%; height: 14px; accent-color: #1a8c63; }
.files-list { padding: 0 18px; min-height: 130px; }
.file-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px 76px; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid #edf0f2; }
.file-name { text-align: left; overflow-wrap: anywhere; min-width: 0; border-color: transparent !important; background: transparent !important; }
.file-meta { font-size: 12px; color: #667780; }
.files-help { padding: 8px 18px 16px; color: #667780; font-size: 12px; }
@media (max-width: 640px) {
  .files-panel .section-heading { align-items: flex-start; flex-direction: column; }
  .file-row { grid-template-columns: minmax(0, 1fr) 76px; gap: 6px; }
  .file-meta { grid-column: 1; grid-row: 2; padding-left: 8px; }
  .file-row > button:last-child { grid-column: 2; grid-row: 1 / 3; }
  .view-tabs { overflow-x: auto; }
  .view-tab { white-space: nowrap; }
}
.view-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, .8fr); gap: 20px; }
.view-tabs {
  margin-bottom: 12px;
  display: flex;
  gap: 4px;
  border-bottom: 1px solid #cbd5da;
}
.view-tab {
  min-height: 42px;
  padding: 8px 18px;
  color: #53656d;
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  cursor: pointer;
  font-weight: 700;
}
.view-tab.active { color: #145e46; border-bottom-color: #1a8c63; }
.task-editor, .result-panel, .history-panel, .terminal-panel, .notice {
  background: #fff;
  border: 1px solid #d8e0e4;
  border-radius: 6px;
}
.task-editor, .result-panel { min-height: 410px; }
.history-panel { grid-column: 1 / -1; }
.terminal-view { grid-template-columns: 1fr; }
.terminal-panel { min-width: 0; overflow: hidden; }
.section-heading {
  min-height: 72px;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid #e3e8eb;
}
h2 { margin: 0; font-size: 17px; }
.section-heading p { margin: 5px 0 0; color: #667780; font-size: 12px; }

.terminal-actions { display: flex; align-items: center; gap: 8px; }
.terminal-font-controls {
  height: 34px;
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  color: #24343b;
  background: #f7f9fa;
  border: 1px solid #b9c6cc;
  border-radius: 5px;
}
.terminal-font-controls .icon-button {
  width: 34px;
  height: 32px;
  min-width: 34px;
  padding: 0;
  color: #23353d;
  background: transparent;
  border: 0;
  border-radius: 0;
  font-size: 19px;
  line-height: 1;
}
.terminal-font-controls .icon-button:hover { background: #e7edef; }
#terminal-font-size { min-width: 42px; font-size: 12px; font-weight: 700; text-align: center; }
.connection-state {
  min-width: 62px;
  color: #667780;
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}
.connection-state[data-state="connected"] { color: #14734f; }
.connection-state[data-state="error"] { color: #a53b3b; }
#terminal {
  position: relative;
  width: 100%;
  height: max(300px, calc(100dvh - 360px));
  min-height: 300px;
  padding: 14px 12px;
  background: #0d1117;
  cursor: text;
}
#terminal .xterm { height: 100%; }
#terminal .xterm-screen { text-rendering: geometricPrecision; }
#terminal .xterm-viewport { scrollbar-color: #484f58 #0d1117; }
#terminal .xterm-helper-textarea {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
}
.terminal-command-bar {
  min-height: 62px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  background: #152126;
  border-top: 1px solid #2c3e45;
}
.terminal-command-bar input {
  width: 100%;
  height: 40px;
  min-width: 0;
  padding: 0 12px;
  color: #fff;
  background: #0d1117;
  border: 1px solid #43565e;
  border-radius: 5px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 15px;
}
.terminal-command-bar input:focus {
  outline: 2px solid #36a77c;
  outline-offset: 1px;
}
.terminal-key { min-width: 52px; color: #d7e1e5; background: #223138; border-color: #52646c; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid #b9c6cc; border-radius: 5px; overflow: hidden; }
.mode { min-width: 72px; height: 34px; border: 0; background: #fff; color: #43545c; cursor: pointer; }
.mode + .mode { border-left: 1px solid #b9c6cc; }
.mode.active { color: #fff; background: #276b57; }

form { padding: 18px; }
label { display: block; margin-bottom: 8px; color: #43545c; font-size: 13px; font-weight: 700; }
select {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  color: #26363d;
  background: #fff;
  border: 1px solid #b9c6cc;
  border-radius: 5px;
  font: inherit;
}
.field-row { margin-bottom: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
form textarea {
  width: 100%;
  min-height: 245px;
  resize: vertical;
  padding: 14px;
  color: #ecf2f4;
  background: #111b20;
  border: 1px solid #26383f;
  border-radius: 5px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
}
form textarea:focus { outline: 2px solid #36a77c; outline-offset: 2px; }
.form-actions { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
#task-status { min-height: 20px; color: #667780; font-size: 13px; }
button { border-radius: 5px; }
.primary, .secondary, .button-link {
  min-height: 38px;
  padding: 8px 16px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}
.primary, .button-link { color: #fff; background: #167653; }
.secondary { color: #314149; background: #fff; border-color: #bdc9ce; }
button:disabled { cursor: default; opacity: .55; }

#result, #agent-result {
  min-height: 306px;
  max-height: 520px;
  margin: 0;
  padding: 18px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #c8f7e2;
  background: #111b20;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
}
#result.failed, #agent-result.failed { color: #ffd0cc; }
.history-list { padding: 0 18px 18px; }
.history-row {
  width: 100%;
  min-height: 58px;
  padding: 10px 0;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 190px;
  align-items: center;
  gap: 14px;
  text-align: left;
  color: #26363d;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #e4e9ec;
  cursor: pointer;
}
.history-row code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-details { color: #708088; font-size: 12px; text-align: right; }
.state { width: 52px; padding: 4px 5px; border-radius: 4px; font-size: 11px; font-weight: 700; text-align: center; }
.state.success { color: #0c6545; background: #dff5ea; }
.state.failed { color: #9c2f2f; background: #fde8e7; }
.state.running { color: #805800; background: #fff0c8; }
.empty { padding: 18px 0 2px; color: #75858c; }
.notice { padding: 28px; display: flex; align-items: center; gap: 18px; }
.notice span { flex: 1; color: #5c6c74; }
.hidden { display: none !important; }

@media (max-width: 800px) {
  .topbar { align-items: flex-start; }
  .view-grid { grid-template-columns: 1fr; }
  .history-panel { grid-column: 1; }
  .task-editor, .result-panel { min-height: auto; }
  .history-row { grid-template-columns: 60px minmax(0, 1fr); }
  .history-details { grid-column: 2; text-align: left; }
  .notice { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 480px) {
  main { width: min(100% - 20px, 1180px); margin-top: 16px; }
  .topbar { padding-inline: 14px; }
  .account { max-width: 48%; }
  .section-heading { align-items: flex-start; }
  .segmented { margin-top: 1px; }
  .mode { min-width: 62px; }
  .field-row { grid-template-columns: 1fr; }
  .view-tab { flex: 1; padding-inline: 8px; }
  .terminal-actions { width: 100%; flex-wrap: wrap; }
  .connection-state { margin-right: auto; text-align: left; }
  #terminal { height: 58vh; min-height: 340px; padding: 10px 8px; }
  .terminal-command-bar { grid-template-columns: repeat(4, 1fr); }
  .terminal-command-bar input { grid-column: 1 / -1; }
  .terminal-key, #terminal-send { min-width: 0; padding-inline: 6px; }
}

.terminal-panel { border-color: #30363d; background: #0d1117; }
.terminal-panel .section-heading { color: #e6edf3; background: #161b22; border-color: #30363d; flex-wrap: wrap; }
.terminal-panel .section-heading p { color: #8b949e; }
.terminal-panel .secondary { background: #21262d; color: #d7dde5; border-color: #484f58; }
.terminal-panel .secondary:hover:not(:disabled) { background: #30363d; }
.terminal-panel .terminal-font-controls { color: #d7dde5; background: #21262d; border-color: #484f58; }
.terminal-panel .terminal-font-controls .icon-button { color: #d7dde5; }
.terminal-panel .connection-state[data-state="connected"] { color: #7ee787; }
.terminal-panel .connection-state[data-state="error"] { color: #ff7b72; }
.terminal-toolbar { padding: 10px 12px; background: #161b22; border-top: 1px solid #30363d; }
.terminal-keys { display: flex; gap: 6px; flex-wrap: wrap; }
.terminal-keys button { min-height: 32px; min-width: 38px; padding: 5px 10px; font-size: 12px; }
#terminal-notice { margin: 8px 0 0; color: #8b949e; font-size: 12px; line-height: 1.5; }
.terminal-command-details { color: #8b949e; background: #161b22; border-top: 1px solid #30363d; font-size: 12px; }
.terminal-command-details summary { padding: 8px 12px; cursor: pointer; }
.terminal-panel:fullscreen, .terminal-panel.expanded { width: 100%; height: 100dvh; display: flex; flex-direction: column; border-radius: 0; }
.terminal-panel.expanded { position: fixed; inset: 0; z-index: 100; }
.terminal-panel:fullscreen #terminal, .terminal-panel.expanded #terminal { flex: 1; height: auto; min-height: 0; }
@media (max-width: 800px) {
  .terminal-actions { flex-wrap: wrap; }
  .terminal-panel .section-heading { gap: 10px; padding: 12px; }
}
@media (max-width: 480px) {
  #terminal { height: max(260px, calc(100dvh - 450px)); min-height: 260px; }
  .terminal-command-bar { grid-template-columns: minmax(0, 1fr) auto; }
  .terminal-command-bar input { grid-column: auto; }
  .terminal-actions { gap: 6px; }
  .terminal-actions > button { padding-inline: 10px; min-height: 34px; font-size: 12px; }
}

/* Higher contrast for terminal text and supporting labels. */
#terminal, #terminal .xterm-viewport { background: #000; }
#terminal .xterm, #terminal .xterm-screen, #terminal .xterm-rows { color: #fff; }
#terminal .xterm-rows { font-weight: 600; }
#terminal .xterm-viewport { scrollbar-color: #b6c1cc #000; }
.terminal-panel .section-heading p, #terminal-notice,
.terminal-command-details { color: #d8e2ed; }
#agent-result { color: #ffffff; font-size: 15px; font-weight: 600; background: #000; }

.pc-onboarding { padding: 18px; background: #eef8f3; border-bottom: 1px solid #d8e0e4; }
.pc-onboarding p { color: #314149; font-size: 13px; line-height: 1.7; margin: 12px 0 8px; }
.pc-onboarding a { display: inline-block; font-size: 13px; }
.pc-pair-form { border-bottom: 1px solid #e3e8eb; }
.pc-pair-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.pc-device-row { display: flex; gap: 6px; }
.pc-device-row select { min-width: 0; flex: 1; }
.pc-device-row button { padding-inline: 10px; }
.pc-editor input { min-width: 0; width: 100%; height: 40px; padding: 8px 10px; font: inherit; border: 1px solid #b9c6cc; border-radius: 5px; }
.pc-device-info { font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; color: #43545c; }
.pc-command-label { margin-top: 16px; }
#pc-status { font-size: 12px; overflow-wrap: anywhere; }
#pc-output { min-height: 360px; max-height: 700px; margin: 0; padding: 18px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; background: #000; color: #fff; font: 600 16px/1.6 Consolas, "Microsoft YaHei", monospace; }
#pc-output.failed { color: #ffd0cc; }
.state.interrupted, .state.cancelled { color: #9c2f2f; background: #fde8e7; }
.view-tabs { flex-wrap: wrap; }

.pc-target { padding: 18px; border-bottom: 1px solid #d8e0e4; }
.pc-target label { display:block; margin-bottom:8px; font-weight:600; }
.pc-agent-heading { padding:0 0 16px; min-height:0; border:0; }
.pc-manual { border-top:1px solid #d8e0e4; }
.pc-manual summary { padding:18px; cursor:pointer; color:#335b48; font-weight:600; }
.pc-manual-output { grid-column:1 / -1; min-height:0; }
.pc-manual-output #pc-output { min-height:120px; max-height:340px; }
.pc-agent-panel { min-width:0; }
.pc-agent-actions { display:flex; gap:6px; flex-wrap:wrap; }
#pc-agent-chat { padding:18px; height:680px; overflow:auto; background:#f1f5f3; }
.pc-chat-empty { color:#52665a; line-height:1.8; }
.pc-chat-message { padding:14px; margin-bottom:14px; border:1px solid #d6dfd9; border-radius:8px; background:#fff; min-width:0; }
.pc-chat-message.user { background:#e3f3e8; border-color:#c3dec9; }
.pc-chat-role { display:block; color:#32533f; font-size:12px; margin-bottom:8px; }
.pc-chat-message pre { margin:0; white-space:pre-wrap; overflow-wrap:anywhere; color:#15231a; font:500 15px/1.7 Consolas,"Microsoft YaHei",monospace; }
.pc-chat-message.failed pre { color:#92291d; }
#pc-agent-prompt { min-height:170px; }
#pc-agent-status { font-size:12px; overflow-wrap:anywhere; }
@media(max-width:700px) { #pc-agent-chat { height:480px; padding:12px; } .pc-agent-panel .section-heading { flex-wrap:wrap; gap:12px; } }
#pc-agent-prompt::placeholder, #pc-command::placeholder { color:#a5b7ae; opacity:1; } .pc-agent-panel { align-self:start; }
