/* Termio — Modern true-AMOLED terminal theme. Mobile-first, plain CSS.
   Rounded, pill-shaped components. Fullscreen major interfaces.

   Table of contents:
     1. Tokens & base
        :root design tokens · global reset · base typography

     2. Layout & app shell
        - Fullscreen screens
        - Setup Wizard

     3. Reusable components
        - Form fields
        - Buttons
        - Badges

     4. App surface
        - App Layout & Topbar
        - Terminal Interface
        - Input Bar

     5. Fullscreen detail screens
        - Model Picker
        - Session History
        - Settings Body
        - Network Access
        - Changelog
        - Warning Screen
        - Toast

     6. Responsive & motion
        - Responsive

   Rules are kept in source order; no duplicate selectors. */


:root {
  --bg: #000000;
  --bg-1: #08080a;
  --bg-2: #101013;
  --bg-3: #16161b;
  --line: #1d1d23;
  --line-2: #2a2a32;
  --fg: #f3f3f7;
  --fg-2: #b9b9c4;
  --muted: #767684;
  --dim: #50505c;
  --accent: #e8e8ee;
  --accent-2: #9e9ea8;
  --ok: #74e08a;
  --warn: #f0b46a;
  --err: #ff6b6b;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", "Cascadia Code",
          "Source Code Pro", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 16px;
  --radius-sm: 12px;
  --pill: 999px;
  --tap: 42px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-x pan-y;
  overflow: hidden;
}

body { overscroll-behavior: none; }

button, input, select { font-family: var(--sans); }

[hidden] { display: none !important; }

::selection { background: #2a2a35; color: var(--fg); }


/* ==============================================================================
   Layout & app shell
   ============================================================================== */

/* ---------- Fullscreen screens (setup / picker / settings / history / changelog / network / warning) ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.fs-screen { animation: fsslide .22s var(--ease); }
@keyframes fsslide {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

#picker, #history-modal, #changelog, #network-access {
  z-index: 60;
}

#warning-screen {
  z-index: 100;
}

.fs-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  padding-top: calc(8px + var(--safe-top));
  min-height: calc(52px + var(--safe-top));
  border-bottom: 1px solid var(--line);
}
.fs-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.3px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fs-count {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}
.fs-spacer { flex: 0 0 auto; width: var(--tap); }

.fs-controls {
  flex: 0 0 auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

/* ---------- Setup Wizard: fullscreen multi-step ---------- */
.screen-setup {
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow-y: auto;
}

.setup-wizard {
  width: 100%;
  max-width: 520px;
  min-height: 100dvh;
  margin: auto;
  padding: 24px 20px;
  padding-top: calc(24px + var(--safe-top));
  padding-bottom: calc(28px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.wizard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.wizard-brand-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
}
.setup-glyph {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 20px;
  color: var(--fg);
}
.wizard-progress {
  display: flex;
  gap: 8px;
  align-items: center;
}
.wizard-step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-2);
  transition: background .2s var(--ease), transform .2s var(--ease);
}
.wizard-step-dot.active {
  background: var(--fg);
  transform: scale(1.2);
}

.wizard-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-bottom: 24px;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  animation: fadeInStep .24s var(--ease);
}
@keyframes fadeInStep {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.setup-title {
  margin: 0 0 10px;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.5px;
}
.setup-sub {
  margin: 0 0 24px;
  color: var(--fg-2);
  font-size: 14px;
  line-height: 1.55;
}

.setup-points {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: grid;
  gap: 12px;
}
.setup-points li {
  position: relative;
  padding-left: 18px;
  color: var(--fg-2);
  font-size: 13.5px;
  line-height: 1.55;
}
.setup-points li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 9px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--fg-2);
  opacity: 0.8;
}
.setup-points strong { color: var(--fg); font-weight: 600; }

.setup-form {
  display: grid;
  gap: 14px;
  width: 100%;
}

.setup-warning-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 4px;
}
.setup-warning-icon {
  color: var(--warn);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 2px;
}

.setup-warning-box, .setup-ready-box {
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--fg-2);
}
.setup-warning-box p, .setup-ready-box p { margin: 0; }
.setup-warning-box strong { color: var(--fg); }
.ready-text { font-size: 14px; color: var(--ok); font-weight: 500; }

.setup-network-box {
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.setup-network-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.setup-network-desc {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--fg-2);
}
.setup-network-desc code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--pill);
  padding: 1px 7px;
  color: var(--fg);
}
.setup-alpha-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  background: var(--bg-2);
  border: 1px solid #3a2c14;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.setup-alpha-note .badge { flex: 0 0 auto; margin-top: 1px; }

.wizard-nav {
  display: flex;
  gap: 12px;
  justify-content: space-between;
}
.wizard-nav button { flex: 1; }


/* ==============================================================================
   Reusable components
   ============================================================================== */

/* ---------- Form fields ---------- */
.field { display: grid; gap: 7px; width: 100%; }
.field-label { font-size: 12.5px; color: var(--fg-2); font-weight: 500; }
.field-hint { font-size: 11px; color: var(--muted); line-height: 1.4; }
.field-inline {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

input[type="text"],
input[type="password"],
input[type="search"],
select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--pill);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 14px;
  padding: 11px 16px;
  outline: none;
  min-height: 44px;
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
input::placeholder { color: var(--dim); }
input:focus, select:focus {
  border-color: var(--fg-2);
  background: var(--bg-3);
  box-shadow: none;
}

.key-row { display: flex; gap: 8px; width: 100%; }
.key-row input { flex: 1 1 auto; }
.key-status-row { display: flex; align-items: center; justify-content: space-between; width: 100%; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  color: var(--fg);
  border-radius: var(--pill);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  text-decoration: none;
  transition: background .16s var(--ease), border-color .16s var(--ease), transform .08s var(--ease);
}
.btn:hover { background: var(--bg-3); border-color: var(--fg-2); }
.btn:active { transform: scale(0.97); }
.btn-pill { border-radius: var(--pill); }
.btn-full { width: 100%; }
.btn-sm { min-height: 34px; padding: 6px 14px; font-size: 12.5px; }
.btn-primary {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
  font-weight: 600;
}
.btn-primary:hover { background: #dbdbe2; border-color: #dbdbe2; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--bg-2); border-color: var(--line-2); }
.btn-danger { color: var(--err); border-color: #3a1f22; background: #160a0c; }
.btn-danger:hover { background: #220d10; border-color: var(--err); }

.btn:disabled,
.btn[aria-disabled="true"] { opacity: 0.35; pointer-events: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-2);
  border-radius: var(--pill);
  cursor: pointer;
  flex: 0 0 auto;
  transition: color .16s var(--ease), background .16s var(--ease), transform .08s var(--ease);
}
.icon-btn:hover { color: var(--fg); background: var(--bg-2); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn:disabled { opacity: 0.35; pointer-events: none; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: var(--pill);
  border: 1px solid var(--line-2);
  color: var(--fg-2);
  background: var(--bg-2);
  line-height: 1.4;
}
.badge-ok { color: var(--ok); border-color: #1a3a20; background: #0c1a0e; }
.badge-none { color: var(--warn); border-color: #3a2c14; background: #18120a; }
.badge-warn { color: var(--warn); border-color: #3a2c14; background: #18120a; }
.badge-sm { font-size: 9.5px; padding: 2px 7px; }


/* ==============================================================================
   App surface
   ============================================================================== */

/* ---------- App Layout & Responsive Topbar ---------- */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  background: var(--bg);
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 10px;
  padding-top: calc(6px + var(--safe-top));
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  min-height: calc(48px + var(--safe-top));
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex: 0 0 auto;
  min-width: 0;
}
.topbar-right .icon-btn { flex: 0 0 auto; }
.brand-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
}
.mascot-prompt {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--fg);
  font-size: 15px;
  letter-spacing: -1px;
  flex-shrink: 0;
}
.app-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 0 1 auto;
}

.model-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 34vw;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  color: var(--fg);
  border-radius: var(--pill);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  min-height: 32px;
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
.model-pill:hover { background: var(--bg-3); border-color: var(--fg-2); }
.model-pill:disabled { opacity: 0.4; pointer-events: none; }
.model-pill-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-pill-wide { width: 100%; max-width: none; justify-content: space-between; }

/* ---------- Terminal Interface ---------- */
.term {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px 8px;
  font-size: 13.5px;
  line-height: 1.6;
  font-family: var(--mono);
  scroll-behavior: smooth;
}
.term-output { display: flex; flex-direction: column; gap: 2px; }

.term-welcome {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 0;
  color: var(--fg-2);
  font-family: var(--mono);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}
.term-welcome-line { color: var(--fg); font-weight: 600; }
.term-welcome-sub { color: var(--fg-2); font-size: 12.5px; }
.term-welcome-status { color: var(--ok); font-size: 12px; }

.term-block { display: flex; flex-direction: column; gap: 2px; }
.term-block + .term-block { margin-top: 12px; }
.term-block.is-new { animation: blockIn .22s var(--ease); }
/* Defense in depth: never let an empty block/bubble take up space. */
.term-block:empty { display: none; margin: 0; gap: 0; }
@keyframes blockIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.cmd-line {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: baseline;
  color: var(--fg);
  font-family: var(--mono);
}
.cmd-line .prompt-sym { color: var(--fg); font-weight: 700; }
.cmd-line .cmd-text { color: var(--fg); white-space: pre-wrap; word-break: break-word; }

.term-out {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  color: var(--fg-2);
  font-family: var(--mono);
}
.term-out.out-err { color: var(--err); }
.term-out.out-dim { color: var(--muted); }

.term-meta {
  font-size: 11px;
  color: var(--dim);
  font-family: var(--mono);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 2px;
}

.running-line {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
}
.dots { display: inline-flex; gap: 4px; }
.dots span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--fg-2);
  animation: blink 1.1s infinite ease-in-out both;
}
.dots span:nth-child(2) { animation-delay: .18s; }
.dots span:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* ---------- Input Bar (part of the terminal, not a chat box) ---------- */
.inputbar {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  background: var(--bg);
  border-top: 0;
  font-family: var(--mono);
  color: var(--fg);
}
.inputbar:focus-within {
  background: var(--bg);
}
.prompt {
  color: var(--fg);
  font-size: 14px;
  font-weight: 700;
  flex: 0 0 auto;
  font-family: var(--mono);
  line-height: 1.6;
  text-shadow: none;
}
.cmd-form {
  flex: 1 1 auto;
  display: flex;
  align-items: baseline;
}
.cmd-input {
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 0;
  outline: none;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  padding: 0;
  caret-color: var(--fg);
  letter-spacing: 0;
}
.cmd-input::placeholder { color: var(--dim); }
.cmd-input:disabled { opacity: 0.5; cursor: not-allowed; }

/* Stop button (terminal-styled, shown while running) */
.stop-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  background: var(--bg-2);
  border: 1px solid var(--err);
  color: var(--err);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  min-height: 28px;
  line-height: 1;
  letter-spacing: 0.3px;
  box-shadow: none;
  transition: background .14s var(--ease), border-color .14s var(--ease);
}
.stop-btn:hover { background: #220d10; border-color: var(--err); }
.stop-btn:active { transform: scale(0.96); }
.stop-btn-icon { font-size: 11px; line-height: 1; color: var(--err); }
.stop-btn-label { line-height: 1; font-family: var(--mono); }
@media (max-width: 420px) {
  .stop-btn-label { display: none; }
  .stop-btn { padding: 4px 8px; }
}


/* ==============================================================================
   Fullscreen detail screens
   ============================================================================== */

/* ---------- Model Picker controls & list ---------- */
.picker-filter-row { display: flex; gap: 8px; width: 100%; }
.picker-provider-select {
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  color: var(--fg);
  border-radius: var(--pill);
  padding: 8px 14px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.picker-cats {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.picker-cats::-webkit-scrollbar { display: none; }
.cat-btn {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--fg-2);
  border-radius: var(--pill);
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s var(--ease), border-color .16s var(--ease), color .16s var(--ease);
}
.cat-btn:hover { background: var(--bg-3); }
.cat-btn[aria-selected="true"] {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.picker-list {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.picker-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-1);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
.picker-item:hover, .picker-item:focus-visible { background: var(--bg-2); border-color: var(--line-2); }
.picker-item[aria-selected="true"] {
  background: var(--bg-3);
  border-color: var(--fg-2);
}
.picker-item-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.picker-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}
.picker-item-id {
  font-size: 11px;
  color: var(--dim);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 0 1 auto;
}
.picker-item-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 10.5px;
  color: var(--muted);
}
.picker-item-meta .tag {
  border: 1px solid var(--line);
  border-radius: var(--pill);
  padding: 2px 8px;
  font-variant-numeric: tabular-nums;
}
.tag-free { color: var(--ok); border-color: #1a3a20; background: #0c1a0e; }
.tag-cheap { color: var(--ok); border-color: #1a3a20; background: #0c1a0e; }
.tag-fast { color: var(--fg); border-color: var(--line-2); background: var(--bg-2); }
.tag-prem { color: var(--warn); border-color: #3a2c14; background: #18120a; }

/* ---------- Session History List ---------- */
.history-list {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-1);
  transition: background .16s var(--ease), border-color .16s var(--ease);
  cursor: pointer;
}
.history-item:hover { background: var(--bg-2); border-color: var(--line-2); }
.history-item.active { border-color: var(--fg-2); background: var(--bg-3); }
.history-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 auto; margin-right: 12px; }
.history-title { font-size: 14px; font-weight: 600; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-meta { display: flex; gap: 8px; align-items: center; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.history-actions { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; }

/* ---------- Settings Body ---------- */
.settings-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px 28px;
  padding-bottom: calc(28px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.settings-sec-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--fg-2);
}
.settings-sec-head svg { flex: 0 0 auto; }
.settings-h {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--fg-2);
  font-weight: 600;
}
.settings-section { display: flex; flex-direction: column; gap: 10px; }
.settings-note {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--fg-2);
}

.row-pill {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-1);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  cursor: pointer;
}
.row-pill:hover { background: var(--bg-2); }
.row-pill-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--fg);
  text-align: left;
}
.row-pill-main { display: flex; flex-direction: column; gap: 2px; }
.row-pill-title { font-size: 14px; font-weight: 500; color: var(--fg); }
.row-pill-sub { font-size: 12px; color: var(--muted); }
.row-pill-link svg { color: var(--muted); flex: 0 0 auto; }

/* Material-style Switch */
.switch {
  appearance: none;
  width: 44px;
  height: 24px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--pill);
  position: relative;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--fg-2);
  transition: transform .18s var(--ease), background .18s var(--ease);
}
.switch:checked { background: var(--fg); border-color: var(--fg); }
.switch:checked::after { transform: translateX(20px); background: var(--bg); }

/* ---------- Network Access Page ---------- */
.network-access-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 18px 28px;
}
.network-switch-row {
  margin-bottom: 6px;
  align-items: center;
}
.domain-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}
.domain-item {
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.domain-name {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--ok);
}
.domain-desc {
  font-size: 12.5px;
  color: var(--fg-2);
}

/* ---------- Changelog ---------- */
.changelog-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 18px 24px;
}
.changelog-version {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-1);
  margin-bottom: 18px;
  font-size: 13.5px;
  color: var(--fg-2);
}
.changelog-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--ok);
}
.changelog-num {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--fg);
}
.changelog-list { display: flex; flex-direction: column; gap: 14px; }
.changelog-entry {
  border-left: 2px solid var(--line-2);
  padding: 2px 0 2px 14px;
}
.changelog-entry .cl-ver {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 4px;
}
.changelog-entry .cl-items {
  margin: 0;
  padding-left: 16px;
  display: grid;
  gap: 4px;
  color: var(--fg-2);
  font-size: 12.5px;
  line-height: 1.55;
}

/* ---------- Custom Fullscreen Warning Screen ---------- */
.warning-screen {
  align-items: center;
  justify-content: center;
  background: #000000;
  padding: 24px 20px;
}
.warning-container {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  animation: fsslide .2s var(--ease);
}
.warning-icon {
  color: var(--err);
  display: flex;
  align-items: center;
  justify-content: center;
}
.warning-title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: var(--fg);
}
.warning-message {
  margin: 0;
  font-size: 14px;
  color: var(--fg-2);
  line-height: 1.55;
}
.warning-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 10px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  color: var(--fg);
  font-size: 13px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: var(--pill);
  z-index: 110;
  max-width: 90vw;
  text-align: center;
  animation: toastIn .2s var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }


/* ==============================================================================
   Responsive & motion
   ============================================================================== */

/* ---------- Responsive Adjustments ---------- */
@media (min-width: 760px) {
  .term { padding: 18px 24px 10px; max-width: 1000px; margin: 0 auto; width: 100%; }
  .inputbar { padding: 12px 24px; max-width: 1000px; margin: 0 auto; width: 100%; }
  .topbar { padding: 8px 18px; }
  .model-pill { max-width: 260px; }
  .setup-wizard { max-width: 560px; }
  .setup-title { font-size: 32px; }
  .fs-head { padding: 10px 18px; }
  .fs-controls { padding: 12px 22px; }
  .picker-list { padding: 12px 22px 22px; }
  .history-list { padding: 14px 22px 24px; }
  .settings-body { padding: 16px 22px 28px; }
  .warning-actions { flex-direction: row; }
}

@media (max-width: 380px) {
  .term { padding: 10px 12px 6px; font-size: 12.5px; }
  .inputbar { padding: 10px 12px; }
  .topbar { padding: 6px 8px; gap: 4px; }
  .model-pill { max-width: 42vw; font-size: 11.5px; padding: 5px 9px; min-height: 34px; }
  .app-title { display: none; }
  .mascot-prompt { font-size: 14px; }
  .icon-btn { width: 38px; height: 38px; }
  .setup-title { font-size: 24px; }
}

/* Very narrow screens: keep the brand glyph only; model pill and icons must
   never overlap or clip. Brand text hides first, model pill truncates. */
@media (max-width: 340px) {
  .app-title { display: none; }
  .model-pill { max-width: 38vw; }
  .topbar-right { gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
