/* ===========================================================================
   TermLite — macOS desktop chrome
   Built on PostHog tokens (css/tokens.css). Dark terminal islands sit on the
   warm cream app surface — the brand's signature dark-on-cream contrast.
   Desktop-only chrome: traffic-light titlebar, icon rail, source-list sidebar,
   tabbed + split terminals, dual-pane SFTP, preferences.
   =========================================================================== */

:root {
  /* Desktop-specific surfaces layered on top of the PostHog token set */
  --desk-1: #6b6f5f;          /* wallpaper deep */
  --desk-2: #9aa088;          /* wallpaper light */
  --titlebar: #e9eae3;        /* unified toolbar */
  --titlebar-line: #c7c9bd;
  --rail: #e5e7df;            /* icon rail */
  --sidebar: #f1f2ec;         /* source list */
  --win-radius: 12px;

  /* Terminal island palette */
  --term-bg: #16171b;
  --term-bg-2: #1b1c21;
  --term-chrome: #1f2128;
  --term-line: #34363f;
  --term-line-soft: #2a2c33;
  --term-dim: #6f7280;
  --term-fg: #d6d8d2;
  --term-green: #6ee7a8;
  --term-prompt: #86efac;
  --term-cyan: #67e8f9;
  --term-amber: #fbbf24;
  --term-cmd: #ffffff;
  --term-cursor: var(--term-green);
}

* , *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
  background:
    radial-gradient(120% 120% at 18% 8%, var(--desk-2) 0%, var(--desk-1) 62%, #4f5347 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
input, select, textarea { font: inherit; color: inherit; }

/* ───────────────────────── Window frame ───────────────────────── */
.mac-window {
  width: min(1320px, 100%);
  height: min(840px, 100%);
  background: var(--bg);
  border-radius: var(--win-radius);
  box-shadow:
    0 0 0 0.5px rgba(0,0,0,.35),
    0 32px 70px -20px rgba(0,0,0,.55),
    0 12px 28px -16px rgba(0,0,0,.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Titlebar / unified toolbar */
.titlebar {
  height: 52px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  background: var(--titlebar);
  border-bottom: 1px solid var(--titlebar-line);
  -webkit-user-select: none;
  user-select: none;
}
.titlebar.dark {
  background: var(--term-chrome);
  border-bottom-color: var(--term-line);
  color: var(--term-fg);
}

.traffic { display: flex; gap: 8px; flex-shrink: 0; }
.traffic span {
  width: 12px; height: 12px; border-radius: 50%;
  display: block; position: relative;
}
.traffic .tl-close { background: #ff5f57; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.2); }
.traffic .tl-min   { background: #febc2e; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.2); }
.traffic .tl-max   { background: #28c840; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.2); }
.traffic:hover .tl-close::after,
.traffic:hover .tl-min::after,
.traffic:hover .tl-max::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 7px; height: 7px;
}

.title-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.title-meta .t-name { font-size: 13px; font-weight: 700; color: var(--fg-2); }
.title-meta .t-sub  { font-size: 11px; color: var(--muted); }
.titlebar.dark .t-name { color: var(--term-fg); }
.titlebar.dark .t-sub  { color: var(--term-dim); }

.title-center {
  flex: 1; display: flex; align-items: center; justify-content: center;
  min-width: 0;
}
.title-spacer { flex: 1; }

/* Toolbar buttons */
.toolbar-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.tb-btn {
  min-width: 34px; height: 30px; padding: 0 9px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius-sm);
  color: var(--fg-2);
  font-size: 13px; font-weight: 600;
  border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.tb-btn:hover { background: var(--surface-warm); color: var(--accent); }
.tb-btn.solid { background: var(--primary); color: var(--on-primary); }
.tb-btn.solid:hover { background: var(--primary-pressed); color: var(--on-primary); }
.tb-btn svg { width: 16px; height: 16px; }
.titlebar.dark .tb-btn { color: var(--term-fg); }
.titlebar.dark .tb-btn:hover { background: rgba(255,255,255,.08); color: var(--term-amber); }

.tb-search {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 10px; min-width: 200px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--meta);
}
.tb-search svg { width: 14px; height: 14px; flex-shrink: 0; }
.tb-search input {
  border: none; outline: none; background: none; flex: 1;
  font-size: 13px; color: var(--fg-2); min-width: 0;
}
.tb-search input::placeholder { color: var(--meta); }

/* ───────────────────────── Body layout ───────────────────────── */
.mac-body { flex: 1; display: flex; min-height: 0; }

/* Slim icon rail */
.rail {
  width: 60px; flex-shrink: 0;
  background: var(--rail);
  border-right: 1px solid var(--titlebar-line);
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 0; gap: 4px;
}
.rail-btn {
  width: 42px; height: 42px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  position: relative;
  transition: background .15s, color .15s;
}
.rail-btn svg { width: 20px; height: 20px; }
.rail-btn:hover { background: var(--surface-warm); color: var(--fg-2); }
.rail-btn.active { background: var(--surface-dark); color: #fff; }
.rail-btn .rail-badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 15px; height: 15px; padding: 0 4px;
  background: var(--accent); color: #fff;
  font-size: 9px; font-weight: 700; line-height: 15px;
  border-radius: 999px; text-align: center;
}
.rail-spacer { flex: 1; }
.rail-tip {
  position: absolute; left: 52px; top: 50%; transform: translateY(-50%);
  background: var(--fg-2); color: #fff;
  font-size: 11px; font-weight: 600; padding: 4px 8px;
  border-radius: var(--radius-sm); white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 50;
}
.rail-btn:hover .rail-tip { opacity: 1; }

/* Source-list sidebar */
.sidebar {
  width: 270px; flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--titlebar-line);
  display: flex; flex-direction: column; min-height: 0;
}
.sidebar.wide { width: 300px; }
.sidebar-head {
  padding: 12px 14px 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-head h2 { font-size: 15px; font-weight: 800; color: var(--fg-2); letter-spacing: -.01em; }
.sidebar-search {
  margin: 0 12px 8px;
  display: flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 9px;
  background: var(--surface-card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--meta);
}
.sidebar-search svg { width: 14px; height: 14px; flex-shrink: 0; }
.sidebar-search input { border: none; outline: none; background: none; flex: 1; font-size: 13px; color: var(--fg-2); min-width: 0; }
.sidebar-search input::placeholder { color: var(--meta); }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }

.side-section {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--meta);
  padding: 12px 8px 5px;
  display: flex; align-items: center; justify-content: space-between;
}
.side-section a { font-size: 11px; color: #1d4ed8; text-transform: none; letter-spacing: 0; font-weight: 600; }
.side-section a:hover { color: var(--accent); }

/* Host / device row in sidebar */
.host-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px; border-radius: var(--radius-md);
  cursor: pointer; width: 100%; text-align: left;
  transition: background .12s;
}
.host-row:hover { background: var(--surface-warm); }
.host-row.active { background: var(--surface-dark); }
.host-row.active .hr-name,
.host-row.active .hr-sub { color: #fff; }
.host-row.active .hr-sub { color: rgba(255,255,255,.6); }
.host-avatar {
  width: 30px; height: 30px; border-radius: var(--radius-sm); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; letter-spacing: .02em;
}
.tone-a { background: #2c8c66; }
.tone-b { background: #2c84e0; }
.tone-c { background: #7c44a6; }
.tone-d { background: #cd7a39; }
.tone-mac { background: var(--surface-dark); }
.hr-body { flex: 1; min-width: 0; }
.hr-name { font-size: 13px; font-weight: 600; color: var(--fg-2); display: flex; align-items: center; gap: 5px; }
.hr-name .star { color: var(--primary); font-size: 11px; }
.hr-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hr-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--meta); }
.hr-dot.on { background: var(--success); }
.hr-status { font-size: 11px; color: var(--meta); flex-shrink: 0; }

/* Connect ghost button inside a row */
.hr-connect {
  font-size: 11px; font-weight: 700; padding: 4px 10px;
  border-radius: var(--radius-sm); background: var(--surface-warm);
  color: var(--fg-2); flex-shrink: 0; transition: background .12s, color .12s;
}
.hr-connect:hover { background: var(--primary); color: var(--on-primary); }

/* Sidebar footer (limit / upgrade) */
.sidebar-foot {
  border-top: 1px solid var(--titlebar-line);
  padding: 10px 12px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--muted);
}
.sidebar-foot strong { color: var(--fg-2); }
.sidebar-foot a { font-size: 12px; font-weight: 700; color: #1d4ed8; }
.sidebar-foot a:hover { color: var(--accent); }

/* Main content area */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.main.dark { background: var(--term-bg); }
.main-scroll { flex: 1; overflow-y: auto; }

/* ───────────────────────── Buttons / pills ───────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 16px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 700; border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s, filter .15s;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-pressed); }
.btn-secondary { background: var(--surface-warm); color: var(--fg-2); }
.btn-secondary:hover { color: var(--accent); }
.btn-ghost { background: transparent; color: var(--fg-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
}
.pill-info { background: var(--info-soft); color: #1d4ed8; }
.pill-ok { background: var(--success-soft); color: var(--success); }
.pill-warn { background: color-mix(in oklab, var(--primary), white 72%); color: var(--primary-active); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-dim { background: var(--surface-warm); color: var(--muted); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.eyebrow {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--meta);
}

/* ───────────────────────── Forms ───────────────────────── */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; height: 36px; padding: 0 11px;
  background: var(--surface-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px; color: var(--fg-2);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field textarea { height: auto; padding: 9px 11px; resize: vertical; font-family: var(--font-mono); line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.25);
}
.field input::placeholder, .field textarea::placeholder { color: var(--meta); }
.field-hint { font-size: 11px; color: var(--meta); margin-top: 5px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

/* Segmented control */
.segment { display: inline-flex; background: var(--surface-warm); border-radius: var(--radius-md); padding: 3px; gap: 2px; }
.segment button {
  padding: 6px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  color: var(--muted); transition: background .12s, color .12s;
}
.segment button.active { background: var(--surface-card); color: var(--fg-2); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ───────────────────────── Cards / detail ───────────────────────── */
.card {
  background: var(--surface-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 18px;
}
.detail-pad { padding: 24px 28px; }
.detail-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.detail-avatar {
  width: 54px; height: 54px; border-radius: var(--radius-md); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: #fff;
}
.detail-title h1 { font-size: 24px; font-weight: 800; color: var(--fg-2); letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; }
.detail-title .addr { font-family: var(--font-mono); font-size: 13px; color: var(--muted); margin-top: 3px; }
.detail-actions { margin-left: auto; display: flex; gap: 8px; }

.kv-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--border-soft); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.kv { background: var(--surface-card); padding: 12px 14px; }
.kv .k { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--meta); margin-bottom: 3px; }
.kv .v { font-size: 14px; color: var(--fg-2); font-weight: 500; }
.kv .v.mono { font-family: var(--font-mono); font-size: 13px; }

/* ───────────────────────── Terminal ───────────────────────── */
.term-tabs {
  display: flex; align-items: stretch;
  background: var(--term-bg-2); border-bottom: 1px solid var(--term-line);
  flex-shrink: 0; overflow-x: auto; scrollbar-width: none;
}
.term-tabs::-webkit-scrollbar { display: none; }
.term-tab {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; min-height: 38px; max-width: 200px;
  font-size: 12px; font-weight: 600; color: var(--term-dim);
  border-right: 1px solid var(--term-line-soft); flex-shrink: 0;
  transition: background .12s, color .12s;
}
.term-tab:hover { background: rgba(255,255,255,.03); color: var(--term-fg); }
.term-tab.active { color: var(--term-fg); background: var(--term-bg); box-shadow: inset 0 -2px 0 var(--primary); }
.term-tab .tdot { width: 7px; height: 7px; border-radius: 50%; background: var(--term-green); flex-shrink: 0; }
.term-tab .tdot.idle { background: var(--term-dim); }
.term-tab .tname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.term-tab .tclose {
  width: 18px; height: 18px; border-radius: var(--radius-sm); margin-right: -4px;
  display: flex; align-items: center; justify-content: center; color: var(--term-dim);
}
.term-tab .tclose:hover { background: rgba(255,255,255,.12); color: #fff; }
.term-tab-add {
  min-width: 38px; display: flex; align-items: center; justify-content: center;
  color: var(--term-dim); flex-shrink: 0;
}
.term-tab-add svg { width: 16px; height: 16px; }
.term-tab-add:hover { background: rgba(255,255,255,.05); color: #fff; }
.term-tabs .tabs-right { margin-left: auto; display: flex; align-items: center; gap: 2px; padding-right: 6px; }
.term-tabs .tabs-right .tb-icon {
  width: 30px; height: 30px; border-radius: var(--radius-sm); margin-top: 4px;
  display: flex; align-items: center; justify-content: center; color: var(--term-dim);
}
.term-tabs .tabs-right .tb-icon:hover { background: rgba(255,255,255,.08); color: var(--term-amber); }
.term-tabs .tabs-right .tb-icon svg { width: 16px; height: 16px; }

/* Tab "⋮" more button + context menu */
.term-tab .tmore {
  width: 18px; height: 18px; border-radius: var(--radius-sm); margin-right: -4px;
  display: flex; align-items: center; justify-content: center; color: var(--term-dim);
}
.term-tab .tmore:hover { background: rgba(255,255,255,.12); color: #fff; }
.term-tab .tmore svg { width: 15px; height: 15px; }
.tab-ctx-backdrop { position: absolute; inset: 0; z-index: 95; display: none; }
.tab-ctx-backdrop.open { display: block; }
.tab-ctx {
  position: absolute; z-index: 96; min-width: 196px;
  background: #2b2d33; border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px; padding: 5px;
  box-shadow: 0 16px 40px -8px rgba(0,0,0,.6);
  opacity: 0; transform: scale(.95); transform-origin: top left;
  transition: opacity .12s ease, transform .12s ease; pointer-events: none;
}
.tab-ctx.open { opacity: 1; transform: scale(1); pointer-events: auto; }
.tab-ctx-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 34px; padding: 0 10px; border-radius: 7px;
  color: #f3f4f2; font-size: 13px; font-weight: 500; text-align: left;
  font-family: var(--font-body);
}
.tab-ctx-item .ic { color: var(--term-dim); display: flex; flex-shrink: 0; }
.tab-ctx-item .ic svg { width: 15px; height: 15px; }
.tab-ctx-item:hover { background: var(--primary); color: #fff; }
.tab-ctx-item:hover .ic { color: #fff; }
.tab-ctx-item.danger { color: #ff6b66; }
.tab-ctx-item.danger .ic { color: #ff6b66; }
.tab-ctx-item.danger:hover { background: var(--danger); color: #fff; }
.tab-ctx-item.danger:hover .ic { color: #fff; }
.tab-ctx-sep { height: 1px; background: rgba(255,255,255,.1); margin: 4px 6px; }

/* Theme picker rows (mac modal) */
.theme-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 46px; padding: 7px 8px; text-align: left; border-radius: var(--radius-sm);
  color: var(--fg-2); font-size: 13px; font-weight: 600;
}
.theme-row:hover { background: var(--surface); }
.theme-row .tswatch {
  width: 40px; height: 30px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); flex-shrink: 0;
  display: flex; flex-direction: column; justify-content: center; gap: 3px;
  padding: 0 6px; overflow: hidden;
}
.theme-row .tswatch span { height: 3px; border-radius: 2px; display: block; }
.theme-row .tname { flex: 1; }
.theme-row .tcheck { color: var(--primary); flex-shrink: 0; display: flex; }

/* Split container */
.term-stage { flex: 1; display: flex; min-height: 0; background: var(--term-bg); }
.term-pane {
  flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0;
  border-right: 1px solid var(--term-line);
}
.term-pane:last-child { border-right: none; }
.term-pane.focused .pane-head { background: var(--term-chrome); }
.term-pane.focused .pane-head .ph-name { color: var(--term-fg); }
.pane-head {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; background: var(--term-bg-2);
  border-bottom: 1px solid var(--term-line-soft); flex-shrink: 0;
}
.pane-head .ph-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--term-green); }
.pane-head .ph-name { font-size: 11px; font-weight: 600; color: var(--term-dim); flex: 1; }
.pane-head .ph-act { width: 22px; height: 22px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--term-dim); }
.pane-head .ph-act:hover { background: rgba(255,255,255,.1); color: #fff; }
.pane-head .ph-act svg { width: 13px; height: 13px; }

.term-out {
  flex: 1; overflow-y: auto; padding: 12px 14px;
  font-family: var(--font-mono); font-size: var(--term-font, 13px); line-height: 1.55;
  color: var(--term-fg); white-space: pre-wrap; word-break: break-word;
}
.term-out::-webkit-scrollbar { width: 9px; }
.term-out::-webkit-scrollbar-thumb { background: #3a3c44; border-radius: 9px; border: 2px solid var(--term-bg); }
.term-out .out { color: var(--term-fg); }
.term-out .cmd { color: var(--term-cmd); }
.term-out .prompt { color: var(--term-prompt); }
.term-out .user { color: var(--term-cyan); }
.term-out .muted { color: var(--term-dim); }

.term-inputline {
  display: flex; align-items: center; gap: 8px; padding: 9px 14px;
  border-top: 1px solid var(--term-line-soft); flex-shrink: 0;
  font-family: var(--font-mono); font-size: var(--term-font, 13px);
}
.term-inputline .ps { color: var(--term-prompt); white-space: nowrap; }
.term-inputline input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--term-cmd); font-family: var(--font-mono); font-size: var(--term-font, 13px);
}
.term-caret { width: 8px; height: 16px; background: var(--term-cursor); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Terminal status bar */
.term-status {
  flex-shrink: 0; height: 28px;
  display: flex; align-items: center; gap: 16px; padding: 0 14px;
  background: var(--term-bg-2); border-top: 1px solid var(--term-line);
  font-family: var(--font-mono); font-size: 11px; color: var(--term-dim);
}
.term-status .st-item { display: flex; align-items: center; gap: 5px; }
.term-status .st-item.ok { color: var(--term-green); }
.term-status .st-spacer { flex: 1; }
.term-status kbd {
  font-family: var(--font-mono); font-size: 10px; padding: 1px 5px;
  background: rgba(255,255,255,.07); border: 1px solid var(--term-line);
  border-radius: 3px; color: var(--term-fg);
}

/* Premium hint banner inside terminal */
.term-premium {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
  padding: 7px 14px; font-size: 12px; font-weight: 600; color: var(--primary);
  background: color-mix(in oklab, var(--primary), var(--term-bg) 88%);
  border-bottom: 1px solid var(--term-line);
}
.term-premium svg { width: 13px; height: 13px; flex-shrink: 0; }
.term-premium a { margin-left: auto; color: var(--primary); font-weight: 700; }
.term-premium a:hover { color: #fff; }

/* ───────────────────────── SFTP dual pane ───────────────────────── */
.sftp-split { flex: 1; display: flex; min-height: 0; }
.sftp-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--border); }
.sftp-pane:last-child { border-right: none; }
.sftp-pane-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 14px;
  background: var(--surface); border-bottom: 1px solid var(--border-soft); flex-shrink: 0;
}
.sftp-pane-head .sp-label { font-size: 12px; font-weight: 700; color: var(--fg-2); text-transform: uppercase; letter-spacing: .05em; }
.sftp-pane-head .sp-host { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.sftp-crumb {
  padding: 7px 14px; font-family: var(--font-mono); font-size: 12px; color: var(--muted);
  background: var(--surface-card); border-bottom: 1px solid var(--border-soft);
  white-space: nowrap; overflow-x: auto; flex-shrink: 0; scrollbar-width: none;
}
.sftp-crumb::-webkit-scrollbar { display: none; }
.sftp-crumb .seg { color: var(--fg-2); }
.sftp-list { flex: 1; overflow-y: auto; }
.sftp-row {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 8px 14px; border-bottom: 1px solid var(--border-soft);
  transition: background .12s;
}
.sftp-row:hover { background: var(--surface); }
.sftp-row .si { width: 20px; height: 20px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.sftp-row .si.folder { color: var(--primary-active); }
.sftp-row .si.file { color: var(--meta); }
.sftp-row .si svg { width: 18px; height: 18px; }
.sftp-row .sf-body { flex: 1; min-width: 0; }
.sftp-row .sf-name { font-size: 13px; font-weight: 500; color: var(--fg-2); }
.sftp-row .sf-meta { font-family: var(--font-mono); font-size: 11px; color: var(--meta); }
.sftp-row .sf-size { font-family: var(--font-mono); font-size: 11px; color: var(--muted); flex-shrink: 0; }

/* Transfer queue */
.transfer-dock {
  flex-shrink: 0; border-top: 1px solid var(--border);
  background: var(--surface); max-height: 160px; overflow-y: auto;
}
.transfer-dock-head { padding: 8px 14px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--meta); }
.transfer-item { display: flex; align-items: center; gap: 10px; padding: 7px 14px; }
.transfer-item .ti-icon { color: var(--success); display: flex; }
.transfer-item .ti-icon svg { width: 15px; height: 15px; }
.transfer-item .ti-body { flex: 1; min-width: 0; }
.transfer-item .ti-name { font-size: 12px; font-weight: 600; color: var(--fg-2); }
.transfer-item .ti-bar { height: 4px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.transfer-item .ti-fill { height: 100%; background: var(--success); width: 0; transition: width .3s; }
.transfer-item .ti-pct { font-family: var(--font-mono); font-size: 11px; color: var(--muted); flex-shrink: 0; min-width: 34px; text-align: right; }
.transfer-item.done .ti-fill { background: var(--success); }
.transfer-item.err .ti-icon { color: var(--danger); }
.transfer-item.err .ti-fill { background: var(--danger); }

/* ───────────────────────── Settings / Preferences ───────────────────────── */
.prefs-body { flex: 1; display: flex; min-height: 0; }
.prefs-rail {
  width: 210px; flex-shrink: 0; background: var(--sidebar);
  border-right: 1px solid var(--titlebar-line); padding: 10px 8px; overflow-y: auto;
}
.prefs-cat {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: var(--radius-md); color: var(--fg);
  font-size: 13px; font-weight: 600; transition: background .12s, color .12s;
}
.prefs-cat svg { width: 17px; height: 17px; color: var(--muted); }
.prefs-cat:hover { background: var(--surface-warm); }
.prefs-cat.active { background: var(--surface-dark); color: #fff; }
.prefs-cat.active svg { color: #fff; }
.prefs-main { flex: 1; overflow-y: auto; padding: 24px 30px; }
.prefs-panel { display: none; max-width: 620px; }
.prefs-panel.active { display: block; }
.prefs-panel h2 { font-size: 20px; font-weight: 800; color: var(--fg-2); letter-spacing: -.01em; margin-bottom: 4px; }
.prefs-panel .panel-sub { font-size: 13px; color: var(--muted); margin-bottom: 18px; }

.set-group { background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; margin-bottom: 18px; }
.set-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 13px 16px; border-bottom: 1px solid var(--border-soft);
}
.set-group .set-row:last-child { border-bottom: none; }
.set-row:hover { background: var(--surface); }
.set-row .sr-icon { width: 30px; height: 30px; border-radius: var(--radius-sm); background: var(--surface-warm); display: flex; align-items: center; justify-content: center; color: var(--fg-2); flex-shrink: 0; }
.set-row .sr-icon svg { width: 16px; height: 16px; }
.set-row .sr-body { flex: 1; min-width: 0; }
.set-row .sr-title { font-size: 14px; font-weight: 600; color: var(--fg-2); }
.set-row .sr-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.set-row .chevron { color: var(--meta); font-size: 18px; }

/* Toggle */
.toggle {
  width: 40px; height: 24px; border-radius: 999px; background: var(--border);
  position: relative; flex-shrink: 0; transition: background .18s;
}
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .18s; }
.toggle.on { background: var(--success); }
.toggle.on::after { transform: translateX(16px); }
.toggle:disabled { opacity: .5; }

/* Premium upsell card */
.upsell {
  background: linear-gradient(135deg, color-mix(in oklab, var(--primary), white 70%), var(--surface-card));
  border: 1px solid color-mix(in oklab, var(--primary), var(--border) 50%);
  border-radius: var(--radius-md); padding: 18px; margin-bottom: 18px;
  display: flex; align-items: center; gap: 16px;
}
.upsell .us-body { flex: 1; }
.upsell h3 { font-size: 15px; font-weight: 800; color: var(--fg-2); margin-bottom: 3px; }
.upsell p { font-size: 13px; color: var(--muted); }

/* ───────────────────────── Modals / dialogs ───────────────────────── */
.overlay {
  position: absolute; inset: 0; background: rgba(35,37,29,.42);
  display: none; align-items: center; justify-content: center; z-index: 100;
  backdrop-filter: blur(2px);
}
.overlay.open { display: flex; }
.modal {
  width: min(520px, 92%); max-height: 86%; overflow-y: auto;
  background: var(--bg); border-radius: var(--radius-lg);
  box-shadow: 0 30px 60px -12px rgba(0,0,0,.4); padding: 22px 24px;
}
.modal.sm { width: min(400px, 92%); }
.modal h3 { font-size: 18px; font-weight: 800; color: var(--fg-2); margin-bottom: 4px; letter-spacing: -.01em; }
.modal .modal-sub { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Command palette / popover */
.popover {
  position: absolute; z-index: 90; width: 340px;
  background: var(--surface-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: 0 18px 40px -12px rgba(0,0,0,.35);
  overflow: hidden; display: none;
}
.popover.open { display: block; }
.popover-head { padding: 10px 14px 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--meta); }
.popover-item { display: flex; flex-direction: column; gap: 2px; padding: 9px 14px; border-top: 1px solid var(--border-soft); width: 100%; text-align: left; transition: background .12s; }
.popover-item:hover { background: var(--surface); }
.popover-item .pi-title { font-size: 13px; font-weight: 600; color: var(--fg-2); }
.popover-item .pi-cmd { font-family: var(--font-mono); font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Empty / centered states */
.empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px; gap: 4px;
}
.empty .empty-art { width: 64px; height: 64px; border-radius: var(--radius-lg); background: var(--surface); display: flex; align-items: center; justify-content: center; color: var(--meta); margin-bottom: 12px; }
.empty .empty-art svg { width: 30px; height: 30px; }
.empty h2 { font-size: 18px; font-weight: 800; color: var(--fg-2); }
.empty p { font-size: 14px; color: var(--muted); max-width: 360px; line-height: 1.5; margin-bottom: 12px; }

/* Toast */
.toast {
  position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(8px);
  background: var(--surface-dark); color: #fff; font-size: 13px; font-weight: 600;
  padding: 11px 18px; border-radius: var(--radius-md); z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity .22s, transform .22s;
  box-shadow: 0 12px 30px -8px rgba(0,0,0,.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Banner */
.banner { padding: 11px 14px; border-radius: var(--radius-md); font-size: 13px; line-height: 1.5; }
.banner-info { background: var(--info-soft); color: #1e3a8a; }
.banner-warn { background: color-mix(in oklab, var(--primary), white 74%); color: var(--primary-active); }

/* Scrollbars (light areas) */
.sidebar-scroll::-webkit-scrollbar, .main-scroll::-webkit-scrollbar,
.sftp-list::-webkit-scrollbar, .prefs-main::-webkit-scrollbar,
.prefs-rail::-webkit-scrollbar { width: 10px; }
.sidebar-scroll::-webkit-scrollbar-thumb, .main-scroll::-webkit-scrollbar-thumb,
.sftp-list::-webkit-scrollbar-thumb, .prefs-main::-webkit-scrollbar-thumb,
.prefs-rail::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }

/* Utility */
.mono { font-family: var(--font-mono); }
.text-muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.divider { height: 1px; background: var(--border-soft); margin: 16px 0; }

/* ── Embed mode (App Store screenshot frames) ── */
html.embed,
html.embed body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: transparent;
}

html.embed body {
  display: block;
}

html.embed .mac-window {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: none;
  max-height: none;
  border-radius: 0;
  box-shadow: none;
}

html.embed .overlay,
html.embed .toast,
html.embed .popover,
html.embed .tab-ctx,
html.embed .tab-ctx-backdrop,
html.embed .rail-tip {
  display: none !important;
}
