*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--fg);
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

.device {
  width: 390px;
  height: 844px;
  background: var(--bg);
  border-radius: 48px;
  border: 3px solid #2a2a2a;
  box-shadow: 0 24px 80px rgba(0,0,0,.45), inset 0 0 0 1px rgba(255,255,255,.08);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.device::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 126px;
  height: 34px;
  background: #000;
  border-radius: 20px;
  z-index: 100;
}
.status-bar {
  height: var(--safe-top);
  padding: 14px 28px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 600;
  color: var(--fg-2);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}
.status-bar.light { color: var(--on-dark); }
/* Dark screens: bezel must be dark so the transparent status-bar/home-indicator
   safe areas don't leak the parchment device bg as white strips top/bottom. */
.device:has(.screen.dark) { background: var(--surface-dark); }
.status-icons { display: flex; gap: 6px; align-items: center; }
.status-icons svg { display: block; }

.screen {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}
.screen.dark { background: var(--surface-dark); color: var(--on-dark); }
.home-indicator {
  height: var(--safe-bottom);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.home-indicator::after {
  content: "";
  width: 134px;
  height: 5px;
  background: var(--fg-2);
  border-radius: 3px;
  opacity: .25;
}
.home-indicator.light::after { background: var(--on-dark); opacity: .35; }

.nav-bar {
  display: grid;
  grid-template-columns: var(--hit) 1fr var(--hit);
  align-items: center;
  padding: 8px 8px 12px;
  min-height: 44px;
  flex-shrink: 0;
}
.nav-bar h1 {
  grid-column: 1 / -1;
  grid-row: 1;
  text-align: center;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--fg-2);
  letter-spacing: -0.02em;
  pointer-events: none;
}
.nav-bar .back,
.nav-bar .action,
.nav-bar > button.back {
  position: relative;
  z-index: 1;
}
.nav-bar .action { justify-self: end; grid-column: 3; }
.nav-bar .back,
.nav-bar > button.back { justify-self: start; grid-column: 1; }
.nav-bar .badge { justify-self: end; grid-column: 3; z-index: 1; }
.nav-bar .back {
  min-width: var(--hit);
  min-height: var(--hit);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: -8px;
  color: var(--fg-2);
}
.nav-bar .action {
  min-width: var(--hit);
  min-height: var(--hit);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--accent);
}

.tab-bar {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--surface-card);
  padding-bottom: 8px;
  flex-shrink: 0;
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--tab-height);
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  padding-top: 6px;
}
.tab-item.active { color: var(--fg-2); }
.tab-item svg { width: 24px; height: 24px; }

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--hit);
  padding: 10px 20px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: var(--text-sm);
  font-weight: 700;
  border-radius: var(--radius-md);
  width: 100%;
}
.btn-primary:active { background: var(--primary-pressed); }
.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--hit);
  padding: 10px 20px;
  background: var(--surface-warm);
  color: var(--fg-2);
  font-size: var(--text-sm);
  font-weight: 700;
  border-radius: var(--radius-md);
  width: 100%;
}
.btn-dark {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--hit);
  padding: 10px 20px;
  background: var(--fg-2);
  color: var(--on-dark);
  font-size: var(--text-sm);
  font-weight: 700;
  border-radius: var(--radius-md);
  width: 100%;
}
.btn-ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--hit);
  padding: 10px 16px;
  color: var(--fg-2);
  font-size: var(--text-sm);
  font-weight: 600;
}

.card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-free { background: var(--info-soft); color: #1d4ed8; }
[data-theme="dark"] .badge-free { color: #93c5fd; }
.badge-premium { background: color-mix(in oklab, var(--warn), white 70%); color: #b17816; }
[data-theme="dark"] .badge-premium { background: color-mix(in oklab, var(--warn), black 55%); color: #f5d08a; }
.badge-connected { background: var(--success-soft); color: var(--success); }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--fg-2);
  margin-bottom: 6px;
}
.field input, .field textarea, .field select {
  width: 100%;
  min-height: var(--hit);
  padding: 10px 12px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: 2px solid rgba(59,130,246,.5);
  border-color: #3b82f6;
}
.field .hint {
  font-size: var(--text-xs);
  color: var(--muted);
  margin-top: 4px;
}

.host-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  min-height: 72px;
}
.host-row:active { background: var(--surface); }
.host-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--surface-warm);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-2);
  flex-shrink: 0;
}
.host-info { flex: 1; min-width: 0; }
.host-info h3 {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--fg-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.host-info p {
  font-size: var(--text-sm);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.connect-btn {
  min-width: 72px;
  min-height: 36px;
  padding: 8px 14px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 13px;
  font-weight: 700;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.search-bar {
  margin: 0 16px 12px;
  position: relative;
}
.search-bar input {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px 8px 36px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.search-bar svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--meta);
}

.banner {
  margin: 0 16px 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: 1.43;
}
.banner-info { background: var(--info-soft); color: var(--fg-2); }
.banner-warn { background: color-mix(in oklab, var(--warn), white 75%); color: var(--fg-2); }
.banner-danger { background: var(--danger-soft); color: var(--fg-2); }
.banner-success { background: var(--success-soft); color: var(--fg-2); }

.fab {
  position: absolute;
  right: 20px;
  bottom: calc(var(--tab-height) + var(--safe-bottom) + 12px);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(247,165,1,.35);
  z-index: 20;
}
.fab:active { background: var(--primary-pressed); }
.fab--no-tab {
  bottom: calc(var(--safe-bottom) + 20px);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  min-height: var(--hit);
}
.toggle {
  width: 51px;
  height: 31px;
  background: var(--border);
  border-radius: 16px;
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle.on { background: var(--success); }
.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .2s;
}
.toggle.on::after { transform: translateX(20px); }

.segmented {
  display: flex;
  background: var(--surface-warm);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}
.segmented button {
  flex: 1;
  min-height: 36px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--muted);
  border-radius: var(--radius-sm);
}
.segmented button.active {
  background: var(--surface-card);
  color: var(--fg-2);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

.loading-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px;
  text-align: center;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.terminal-out {
  flex: 1;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.terminal-out .prompt { color: var(--terminal-prompt); }
.terminal-out .cmd { color: var(--on-dark); }
.terminal-out .out { color: #a3a3a3; }
.terminal-out .err { color: #f87171; }
.terminal-bar {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  background: #1a1b1f;
  border-top: 1px solid #333;
  overflow: hidden;
  flex-shrink: 0;
}
.terminal-bar.shortcut-bar {
  justify-content: stretch;
}
.terminal-bar .shortcut-keys {
  display: flex;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.terminal-bar .shortcut-keys button {
  flex: 1;
  min-width: 0;
}
.terminal-bar button {
  min-height: 36px;
  min-width: 44px;
  padding: 6px 8px;
  background: #33342d;
  color: var(--on-dark);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.terminal-bar button.more-btn {
  flex: 0 0 44px;
  min-width: 44px;
  color: #a3a3a3;
  background: #2a2b2f;
}
.terminal-bar button.more-btn.active,
.terminal-bar button.modifier-active {
  color: var(--primary);
  background: color-mix(in oklab, var(--primary), #2a2b2f 82%);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--primary), transparent 55%);
}
.shortcut-expanded-grid button.modifier-active {
  color: var(--primary);
  background: color-mix(in oklab, var(--primary), #33342d 78%);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--primary), transparent 55%);
}
.shortcut-expanded {
  display: none;
  flex-direction: column;
  flex-shrink: 0;
  background: #14151a;
  border-top: 1px solid #333;
}
.shortcut-expanded.open {
  display: flex;
}
.shortcut-expanded-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  color: #737373;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.shortcut-expanded-head button {
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: #a3a3a3;
}
.shortcut-expanded-head button:active {
  background: #333;
  color: var(--on-dark);
}
.shortcut-expanded-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 4px 10px 10px;
}
.shortcut-expanded-grid button {
  min-height: 40px;
  padding: 8px 4px;
  background: #33342d;
  color: var(--on-dark);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
}
.shortcut-expanded-grid button:active {
  background: #44453d;
}
.shortcut-expanded-grid button.wide {
  grid-column: span 2;
}
.terminal-input-wrap.hidden {
  display: none;
}
.terminal-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #1a1b1f;
  border-top: 1px solid #333;
  flex-shrink: 0;
}
.terminal-input-wrap span {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--terminal-prompt);
}
.terminal-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--on-dark);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
  min-height: 36px;
}

.sheet-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 50;
  display: none;
  align-items: flex-end;
}
.sheet-overlay.open { display: flex; }
.sheet {
  width: 100%;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  padding: 12px 16px calc(var(--safe-bottom) + 8px);
  max-height: 70%;
  overflow-y: auto;
}
.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.sftp-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  min-height: 56px;
}
.sftp-row:active { background: var(--surface); }
.sftp-icon { font-size: 20px; flex-shrink: 0; }
.sftp-info { flex: 1; min-width: 0; }
.sftp-info h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--fg-2);
}
.sftp-info p { font-size: var(--text-xs); color: var(--muted); }

.px-16 { padding-left: 16px; padding-right: 16px; }
.py-12 { padding-top: 12px; padding-bottom: 12px; }
.gap-12 { gap: 12px; }
.flex-col { display: flex; flex-direction: column; }
.mt-auto { margin-top: auto; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.text-sm { font-size: var(--text-sm); }
.font-bold { font-weight: 700; }

/* ── Shared polish ── */
.limit-bar {
  margin: 0 16px 10px;
  padding: 10px 14px;
  background: var(--info-soft);
  border: 1px solid color-mix(in oklab, #1d4ed8, var(--border) 70%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-sm);
  line-height: 1.43;
}
.limit-bar a { color: #1d4ed8; font-weight: 700; font-size: var(--text-xs); }
[data-theme="dark"] .limit-bar a { color: #93c5fd; }
.section-label {
  padding: 10px 16px 6px;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.star { color: var(--warn); font-size: 14px; }

.host-icon.tone-a { background: color-mix(in oklab, var(--primary), white 82%); border-color: color-mix(in oklab, var(--primary), var(--border) 40%); }
.host-icon.tone-b { background: var(--info-soft); border-color: color-mix(in oklab, #1d4ed8, var(--border) 50%); color: #1d4ed8; }
[data-theme="dark"] .host-icon.tone-b { color: #93c5fd; }
.host-icon.tone-c { background: var(--success-soft); border-color: color-mix(in oklab, var(--success), var(--border) 40%); color: var(--success); }
.host-meta { font-size: 11px; color: var(--meta); margin-top: 2px; }

.state-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px 24px;
  text-align: center;
}
.state-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.state-icon.danger { background: var(--danger-soft); }
.state-icon.warn { background: color-mix(in oklab, var(--warn), white 75%); }
.state-icon.info { background: var(--info-soft); }
.state-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--fg-2);
  letter-spacing: -0.02em;
}
.state-desc { font-size: var(--text-sm); color: var(--muted); line-height: 1.5; max-width: 280px; }
.state-actions {
  width: 100%;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.step-progress {
  display: flex;
  gap: 6px;
  margin-top: 20px;
}
.step-progress span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background .3s, transform .3s;
}
.step-progress span.done { background: var(--success); }
.step-progress span.active { background: var(--primary); transform: scale(1.2); }

.key-block {
  margin: 0 16px;
  padding: 14px 16px;
  background: var(--surface-dark);
  color: var(--on-dark);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.55;
  word-break: break-all;
  border: 1px solid color-mix(in oklab, var(--on-dark), transparent 85%);
}
.key-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 16px 10px;
  font-size: var(--text-sm);
  color: var(--muted);
}
.key-meta .algo {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  background: var(--surface-warm);
  border-radius: var(--radius-full);
  color: var(--fg-2);
}

.snippet-card {
  margin: 0 16px 10px;
  padding: 14px 16px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color .15s;
}
.snippet-card:active { border-color: color-mix(in oklab, var(--fg-2), var(--border) 50%); }
.snippet-card h3 { font-size: 15px; font-weight: 600; color: var(--fg-2); margin-bottom: 2px; }
.snippet-card code {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-2);
  background: var(--surface);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
  border: 1px solid var(--border-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.snippet-actions { display: flex; gap: 6px; margin-top: 12px; }
.action-pill {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--surface-warm);
  color: var(--fg-2);
}
.action-pill.primary { background: color-mix(in oklab, var(--primary), white 70%); color: var(--on-primary); }
.action-pill.accent { background: var(--info-soft); color: #1d4ed8; }
[data-theme="dark"] .action-pill.accent { color: #93c5fd; }

.premium-card {
  margin: 0 16px 16px;
  padding: 16px;
  background: color-mix(in oklab, var(--warn), white 80%);
  border: 1px solid color-mix(in oklab, var(--warn), var(--border) 50%);
  border-radius: var(--radius-md);
}
[data-theme="dark"] .premium-card {
  background: color-mix(in oklab, var(--warn), black 72%);
  border-color: color-mix(in oklab, var(--warn), var(--border) 30%);
}

.plan-segment { margin: 0 24px 12px; }
.plan-segment .save-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--radius-full);
  background: var(--success-soft);
  color: var(--success);
  vertical-align: middle;
}
[data-theme="dark"] .plan-segment .save-tag { color: #6ee7b7; }

.settings-group { padding: 0 16px 20px; }
.settings-group h2 {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 4px;
  padding-top: 8px;
}
.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-soft);
  min-height: var(--hit);
  width: 100%;
  text-align: left;
}
.settings-row .left { flex: 1; min-width: 0; }
.settings-row .toggle,
.settings-row .chevron { margin-left: auto; flex-shrink: 0; }
.settings-row--toggle {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}
.settings-row--toggle:active { background: var(--surface-warm); }
.settings-row .toggle {
  position: relative;
  z-index: 2;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  /* expand hit area to 44px without changing switch size */
  padding: 7px 8px;
  margin: -7px -8px;
}
.settings-row .title { font-size: 15px; font-weight: 600; color: var(--fg-2); }
.settings-row .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.settings-row .row-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--surface-warm);
  border: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--fg-2);
}
.settings-row .chevron { color: var(--meta); font-size: 18px; font-weight: 300; }
.toggle:disabled { opacity: .45; cursor: not-allowed; }

.sheet-overlay.open .sheet {
  animation: sheet-up .28s cubic-bezier(.32, .72, 0, 1);
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sftp-icon-svg {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sftp-icon-svg.folder { background: color-mix(in oklab, var(--primary), white 78%); color: var(--on-primary); }
.sftp-icon-svg.file { background: var(--surface-warm); color: var(--fg-2); }

.form-body { padding: 0 16px 24px; flex: 1; overflow-y: auto; }
.form-footer {
  padding: 12px 16px 8px;
  border-top: 1px solid var(--border-soft);
  background: var(--bg);
  flex-shrink: 0;
}
.form-footer.col { display: flex; flex-direction: column; gap: 10px; }

.btn-primary, .btn-secondary, .btn-dark, .connect-btn {
  transition: transform .1s, filter .1s;
}
.btn-primary:active, .btn-secondary:active, .connect-btn:active {
  transform: scale(.98);
}

.host-row:last-of-type { border-bottom: none; }
.host-row .connect-btn:active { transform: scale(.96); }

.fab {
  transition: transform .15s, box-shadow .15s;
}
.fab:active { transform: scale(.94); }

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}
.terminal-cursor {
  display: inline-block;
  width: 8px;
  height: 14px;
  background: var(--terminal-green);
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}
.term-hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: 0;
  padding: 0;
  caret-color: transparent;
  pointer-events: none;
}
.terminal-out .term-typed { color: var(--on-dark); }

.onboard-slide { animation: fade-in .35s ease; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Action sheets & dialogs ── */
.sheet-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  margin-bottom: 4px;
}
.sheet-host-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--fg-2);
  text-align: center;
  margin-bottom: 16px;
  letter-spacing: -.02em;
}
.sheet-action {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 12px 4px;
  font-size: 16px;
  font-weight: 600;
  color: var(--fg-2);
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
}
.sheet-action:last-of-type { border-bottom: none; }
.sheet-action:active { background: var(--surface-warm); }
.sheet-action .icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--surface-warm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--fg-2);
}
.sheet-action.danger { color: #cd4239; }
.sheet-action.danger .icon { background: var(--danger-soft); color: #cd4239; }
.sheet-cancel {
  margin-top: 8px;
  width: 100%;
  min-height: 52px;
  font-size: 16px;
  font-weight: 600;
  color: var(--fg-2);
  background: var(--surface-warm);
  border-radius: var(--radius-md);
}

.dialog-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.dialog-overlay.open { display: flex; }
.dialog {
  width: 100%;
  max-width: 300px;
  background: var(--surface-card);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.dialog h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--fg-2);
  margin-bottom: 8px;
}
.dialog p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 20px;
}
.dialog-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dialog-actions .btn-danger {
  min-height: 44px;
  background: #cd4239;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius-md);
  width: 100%;
}

/* ── Empty states ── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  text-align: center;
  gap: 8px;
}
.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--surface-warm);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  color: var(--muted);
}
.empty-state h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--fg-2);
  letter-spacing: -.02em;
}
.empty-state p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  max-width: 260px;
}
.empty-state .btn-primary {
  margin-top: 16px;
  max-width: 220px;
}

.search-empty {
  padding: 32px 24px;
  text-align: center;
  display: none;
}
/* ── Connections tab ── */
.conn-segment-wrap {
  margin: 0 16px 12px;
}
.conn-segment .conn-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 4px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 11px;
  font-weight: 700;
  border-radius: 9px;
}
.conn-segment button:not(.active) .conn-count {
  background: var(--border);
  color: var(--muted);
}
.conn-panel { display: none; }
.conn-panel.active { display: block; }
.conn-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  min-height: 72px;
  color: inherit;
}
.conn-row:active { background: var(--surface); }
.conn-row.recent {
  gap: 0;
  padding: 0;
}
.conn-row-tap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0 14px 16px;
  min-height: 72px;
  border: none;
  background: none;
  text-align: left;
  color: inherit;
  min-width: 0;
}
.conn-row-tap:active { background: var(--surface); }
.conn-row.recent .connect-btn { margin-right: 16px; }
.conn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--surface-warm);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
}
.conn-icon.live {
  background: color-mix(in oklab, var(--terminal-green), white 88%);
  border-color: color-mix(in oklab, var(--terminal-green), white 60%);
  color: var(--fg-2);
}
.conn-icon.live.sftp {
  background: color-mix(in oklab, var(--accent), white 88%);
  border-color: color-mix(in oklab, var(--accent), white 60%);
}
.conn-info { flex: 1; min-width: 0; }
.conn-info h3 {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--fg-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conn-info p {
  font-size: var(--text-sm);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.conn-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.conn-badge.ssh { color: color-mix(in oklab, var(--terminal-green), var(--fg-2) 40%); }
.conn-badge.sftp { color: color-mix(in oklab, var(--accent), var(--fg-2) 40%); }
.conn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.conn-dot.live {
  background: var(--terminal-green);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--terminal-green), transparent 70%);
}
.conn-meta {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--meta);
}

.search-empty.visible { display: block; }
.search-empty p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}
.search-empty strong { color: var(--fg-2); }

.btn-danger-text {
  color: #cd4239;
  font-size: 15px;
  font-weight: 700;
  width: 100%;
  min-height: 44px;
}

/* ── Local network discovery ── */
.local-promo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 16px 12px;
  padding: 12px 14px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color .15s, background .15s;
}
.local-promo:active { background: var(--surface); border-color: var(--fg-2); }
.local-promo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--success-soft);
  border: 1px solid color-mix(in oklab, var(--success), var(--border) 40%);
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.local-promo-body { flex: 1; min-width: 0; }
.local-promo-body h3 {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--fg-2);
  margin-bottom: 2px;
}
.local-promo-body p {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.local-promo .chevron { color: var(--meta); font-size: 20px; flex-shrink: 0; }

.scan-status {
  margin: 0 16px 10px;
  padding: 10px 14px;
  background: var(--surface-warm);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--text-sm);
  color: var(--fg-2);
}
.scan-status.scanning { background: var(--info-soft); border-color: color-mix(in oklab, #1d4ed8, var(--border) 60%); }
.scan-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}
.scan-status.scanning .scan-status-dot {
  background: var(--primary);
  animation: scan-pulse 1.2s ease-in-out infinite;
}
@keyframes scan-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .5; transform: scale(.85); }
}
.scan-status-meta { margin-left: auto; font-size: 11px; color: var(--meta); font-weight: 600; }

.device-row {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
  border-bottom: 1px solid var(--border-soft);
}
.device-row-tap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0 14px 16px;
  min-height: 72px;
  border: none;
  background: none;
  text-align: left;
  color: inherit;
  min-width: 0;
}
.device-row-tap:active { background: var(--surface); }
.device-row .connect-btn { margin-right: 16px; }
.device-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--surface-warm);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--fg-2);
}
.device-icon.mac { background: var(--info-soft); border-color: color-mix(in oklab, #1d4ed8, var(--border) 50%); color: #1d4ed8; }
[data-theme="dark"] .device-icon.mac { color: #93c5fd; }
.device-icon.linux { background: var(--success-soft); border-color: color-mix(in oklab, var(--success), var(--border) 40%); color: var(--success); }
.device-icon.nas { background: color-mix(in oklab, var(--primary), white 82%); border-color: color-mix(in oklab, var(--primary), var(--border) 40%); color: var(--fg-2); }
.device-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--meta);
}
.device-badge .live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--success);
}

.section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 6px;
}
.section-label-row .section-label { padding: 0; }
.section-label-row a {
  font-size: var(--text-xs);
  font-weight: 700;
  color: #1d4ed8;
}
[data-theme="dark"] .section-label-row a { color: #93c5fd; }

.connect-sheet-field {
  padding: 0 16px 16px;
}
.connect-sheet-field label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: 6px;
}
.connect-sheet-field input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
}
.connect-sheet-meta {
  padding: 0 16px 12px;
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.43;
}
.connect-sheet-meta strong { color: var(--fg-2); font-weight: 600; }

/* Landing-page iframe preview (?embed=1) — no auto-scroll or focus steal */
html.embed,
html.embed body {
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
html.embed body {
  padding: 0;
  display: block;
}
html.embed .device {
  width: 100%;
  height: 100%;
  max-height: 100%;
  border-radius: 0;
  border: none;
  box-shadow: none;
}
html.embed .device::before { display: none; }
html.embed .screen {
  overflow: hidden;
}
html.embed .terminal-out {
  overflow: hidden;
}
html.embed .sheet-overlay,
html.embed .sheet {
  pointer-events: none;
}