:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #ecebe6;
  --text: #1c1c1a;
  --muted: #64625b;
  --border: #d9d7cf;
  --accent: #1f6f5c;
  --accent-text: #ffffff;
  --warn: #9a4a12;
  --term-bg: #0b0c0a;
  --term-glow: rgba(85, 255, 170, 0.08);
  --radius: 10px;
  --mono: "Cascadia Mono", "Consolas", "DejaVu Sans Mono", "Menlo", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121311;
    --surface: #1b1c19;
    --surface-2: #24261f;
    --text: #e8e6df;
    --muted: #a19e94;
    --border: #34362f;
    --accent: #4fc29f;
    --accent-text: #0c1a15;
    --warn: #e59a5c;
  }
}
:root[data-theme="dark"] {
  --bg: #121311; --surface: #1b1c19; --surface-2: #24261f; --text: #e8e6df; --muted: #a19e94;
  --border: #34362f; --accent: #4fc29f; --accent-text: #0c1a15; --warn: #e59a5c;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: 0.02em; }
.logo { font-family: var(--mono); color: var(--accent); }
.status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pill { padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 600; font-size: 13px; }
.pill.connected { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.metric { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; padding: 20px; max-width: 1400px; margin: 0 auto; }
@media (max-width: 1000px) { .layout { grid-template-columns: 1fr; padding: 16px; } }

.terminal-wrap { min-width: 0; }
.screen {
  margin: 0; padding: 14px 16px; background: var(--term-bg); color: #aaa; border-radius: var(--radius);
  font: 15px/1.2 var(--mono); white-space: pre; overflow: auto; outline: none;
  box-shadow: inset 0 0 60px var(--term-glow), 0 1px 2px rgba(0,0,0,.2);
  border: 1px solid #000; min-height: calc(25 * 1.2em + 28px);
}
.screen:focus-visible { box-shadow: inset 0 0 60px var(--term-glow), 0 0 0 2px var(--accent); }
.screen .cursor { background: #aaa; color: #000; animation: blink 1s steps(1) infinite; }
.screen .blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
@media (max-width: 760px) { .screen { font-size: 2.1vw; } }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 2px 0; }

.transfer { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; margin-top: 10px;
  padding: 10px 12px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); }
.transfer-label { grid-column: 1; font-variant-numeric: tabular-nums; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { grid-column: 1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
#cancelXfer { grid-column: 2; grid-row: 1 / span 2; }

.panel { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.card h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 10px; }
.field { display: grid; gap: 4px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.field select, .field input:not([type="range"]) {
  font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 7px; padding: 7px 9px; width: 100%; min-width: 0;
}
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg label { display: flex; align-items: center; gap: 6px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; cursor: pointer; background: var(--surface-2); }
.seg label:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.note { font-size: 12.5px; color: var(--muted); margin: 0 0 8px; }
.note.warn { color: var(--warn); margin-top: 8px; }
.folder { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.folder-name { font-family: var(--mono); font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.folder-name.set { color: var(--text); }

button {
  font: inherit; font-weight: 600; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 7px; padding: 8px 12px; cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
button.ghost { background: transparent; }
button.small { padding: 5px 9px; font-size: 12.5px; margin-top: 10px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions h2 { display: none; }

.log { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow: auto; font: 12px/1.45 var(--mono); color: var(--muted); }
.log li { padding: 2px 0; border-bottom: 1px dashed var(--border); overflow-wrap: anywhere; }
.log li.state { color: var(--text); }
.log li.ok { color: var(--accent); }
.log li.err { color: var(--warn); }

dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 18px; width: min(480px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { margin: 0 0 12px; font-size: 16px; }
.file-list { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow: auto; display: grid; gap: 6px; }
.file-list button { width: 100%; display: flex; justify-content: space-between; gap: 12px; text-align: left; font-weight: 500; }
.file-list .size { color: var(--muted); font-variant-numeric: tabular-nums; }
dialog menu { display: flex; justify-content: flex-end; margin: 14px 0 0; padding: 0; }
