/* Tokens (light, html.dark), reset, typography and the shared components: buttons, icon buttons, icons, chips, tabs, segmented controls, inputs, cards, popovers and menus, bottom sheets, modals, toasts. Page files (shell, practice, notes, tests, exam, landing) build on these. */

/* Dark: neutral greys, not navy. (The light palette follows so that it can win back for the exam.) */
html.dark {
  --bg: #0f0f11;
  --surface: #17171a;
  --surface-2: #1e1e22;
  --border: #2a2a2f;
  --border-strong: #3a3a41;
  --text: #ececf1;
  --text-2: #c9c9d1;
  --text-3: #a1a1aa;
  --brand: #00A3FF;
  --brand-2: #38BDF8;
  --brand-soft: #0c1c2e;
  --brand-solid: #0091FF;
  --brand-solid-2: #0080e0;
  --brand-accent: #00E5FF;
  --on-brand: #ffffff;
  --good: #34d399;
  --good-soft: #11261f;
  --bad: #f87171;
  --bad-soft: #2c1719;
  --warn: #fbbf24;
  --warn-soft: #2a2211;
  --nat: #38bdf8;
  --mcq: #c084fc;
  --msq: #34d399;
  --src-cs: #a78bfa;
  --src-ec: #22d3ee;
  --src-ee: #2dd4bf;
  --src-in: #e879f9;
  --src-me: #fb7185;
  --src-ce: #fb923c;
  --src-net: #fbbf24;
  --src-practice: #2dd4bf;
  --shadow: none;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, .55);
  --overlay: rgba(0, 0, 0, .6);
  --control-on: #2e2e35;
  --tip-bg: #2a2a2f;
  --tip-text: #ececf1;
  color-scheme: dark;
}

/* Light by default; html.dark switches the palette (modules/account.js: light, dark or the device's).
   The GATE exam replica stays light in every theme: html.exam-mode, and .theme-light on its dialogs. */
:root, html.dark.exam-mode, html.dark .theme-light {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f3f4f6;             /* raised: hover, selected, wells */
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-2: #374151;                /* secondary */
  --text-3: #6b7280;                /* muted */
  --brand: #0284C7;                 /* the accent: links, focus, selected */
  --brand-2: #0369a1;               /* accent hover */
  --brand-soft: #e0f2fe;            /* accent tint behind selected things */
  --brand-solid: #0284C7;           /* filled buttons (white text) */
  --brand-solid-2: #0369a1;
  --brand-accent: #0091FF;
  --on-brand: #ffffff;
  --good: #059669;
  --good-soft: #ecfdf5;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --nat: #0284c7;
  --mcq: #9333ea;
  --msq: #059669;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .04);
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, .06);
  --shadow-pop: 0 10px 28px rgba(17, 24, 39, .12), 0 2px 6px rgba(17, 24, 39, .06);
  --overlay: rgba(17, 24, 39, .42);
  --control-on: #ffffff;            /* the chosen option in a segmented control */
  --ring: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
  --tip-bg: #111827;
  --tip-text: #f9fafb;
  --src-cs: #7c3aed;
  --src-ec: #0891b2;
  --src-ee: #0d9488;
  --src-in: #c026d3;
  --src-me: #e11d48;
  --src-ce: #ea580c;
  --src-net: #d97706;
  --src-practice: #0d9488;
  --sidebar-w: 232px;
  --rail-w: 64px;
  --topbar-h: 56px;
  --tabbar-h: 60px;
  --fs-ui: 14px;
  --fs-read: 16px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

.theme-light { color: var(--text); }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: var(--fs-ui);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-2); }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
::placeholder { color: var(--text-3); opacity: 1; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }
.spacer { flex: 1; }

/* ------------------------------------------------------------------ icons
   <svg class="i"><use href="#i-NAME"/></svg>: an outline icon from the sprite in index.html, in the
   text colour. .i.sm is 14px for icons inside a line of text. */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i {
  flex: none;
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -4px;
}
.i.sm { width: 14px; height: 14px; vertical-align: -2px; }
.i.lg { width: 22px; height: 22px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-3);
  cursor: pointer;
  text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.on, .icon-btn[aria-pressed="true"] { color: var(--brand); }

/* ------------------------------------------------------------------ buttons
   .btn (secondary, bordered) · .btn-primary (filled accent) · .btn-ghost (outline, no fill)
   · .btn-text (no border) · .btn-danger / .btn-danger-ghost · sizes .btn-sm .btn-xs · .btn-block */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 12px;
  font-size: 14px; font-weight: 500; line-height: 1;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color .12s, border-color .12s, color .12s;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: default; pointer-events: none; }
.btn-primary { background: var(--brand-solid); border-color: var(--brand-solid); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-solid-2); border-color: var(--brand-solid-2); color: var(--on-brand); }
.btn-ghost { background: transparent; }
.btn-text { background: transparent; border-color: transparent; color: var(--text-2); padding: 0 8px; }
.btn-text:hover { background: var(--surface-2); color: var(--text); }
.btn-danger-ghost { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.btn-danger-ghost:hover { color: var(--bad); border-color: var(--bad); background: var(--bad-soft); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 88%, #000); border-color: color-mix(in srgb, var(--bad) 88%, #000); color: #fff; }
html.dark .btn-danger { background: #dc2626; border-color: #dc2626; color: #fff; }
html.dark .btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12.5px; gap: 4px; }
.btn-block { display: flex; width: 100%; }
.link-btn { padding: 0; font-size: inherit; font-weight: 500; color: var(--brand); background: none; border: 0; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

.soon-pill {
  display: inline-flex; align-items: center; justify-content: center;
  height: 26px; padding: 0 10px;
  font-size: 12.5px; font-weight: 500;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.soon-pill.sm { height: 22px; padding: 0 8px; font-size: 12px; }

/* ------------------------------------------------------------------ page heads */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; font-weight: 600; letter-spacing: -.2px; }
.lede { margin: 4px 0 0; color: var(--text-3); }
.page-actions { display: flex; gap: 8px; }
.section-title { font-size: 15px; font-weight: 600; margin: 28px 0 10px; color: var(--text); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 7px;
  font-size: 12px; font-weight: 500;
  color: var(--text-2); background: var(--surface-2);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.badge.brand { color: var(--brand); background: var(--brand-soft); }

/* ------------------------------------------------------------------ chips
   .chip (single or multiple choice, .on when chosen) in a .chips row; .n is a count */
.chip-toggle[data-status="incorrect"].on { color: var(--bad); background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.chip-toggle[data-status="incorrect"].on .n { color: var(--bad); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px;
  font-size: 13px; font-weight: 500;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip .n { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.chip.on { color: var(--brand); background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.chip.on .n { color: var(--brand); }

/* Exam colours: GATE DA = brand, GATE CS/IT = violet, EC = cyan, EE = teal, IN = fuchsia, ME = rose, CE = orange, UGC-NET = amber, practice = grey */
.src-gate-da { --src-c: var(--brand); }
.src-gate-cs, .src-gate-it { --src-c: var(--src-cs); }
.src-gate-ec { --src-c: var(--src-ec); }
.src-gate-ee { --src-c: var(--src-ee); }
.src-gate-in { --src-c: var(--src-in); }
.src-gate-me { --src-c: var(--src-me); }
.src-gate-ce { --src-c: var(--src-ce); }
.src-ugc-net { --src-c: var(--src-net); }
.src-practice { --src-c: var(--src-practice); }
.sdot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--src-c, var(--text-3)); }

/* ------------------------------------------------------------------ segmented control and tabs
   .segmented: a small set of exclusive options (button.on). .tabs > .tab: page tabs, the chosen one
   .on or [aria-selected="true"]. .seg: a compact icon group (used by the theme choice). */
.segmented { flex: none; display: inline-flex; padding: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.segmented button {
  height: 28px; padding: 0 10px;
  font-size: 13px; font-weight: 500;
  color: var(--text-3);
  background: none; border: 0; border-radius: var(--radius-sm);
  cursor: pointer;
}
.segmented button:hover { color: var(--text); }
.segmented button.on { background: var(--control-on); color: var(--text); box-shadow: var(--shadow-sm); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tab {
  flex: none;
  height: 38px; padding: 0 10px; margin-bottom: -1px;
  font-size: 14px; font-weight: 500;
  color: var(--text-3);
  background: none; border: 0; border-bottom: 2px solid transparent;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.on, .tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }

.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--surface-2); border-radius: var(--radius); }
.seg button {
  display: inline-grid; place-items: center;
  width: 30px; height: 26px; padding: 0;
  color: var(--text-3); background: none; border: 0; border-radius: var(--radius-sm);
  cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button.on, .seg button[aria-checked="true"], .seg button[aria-pressed="true"] { background: var(--control-on); color: var(--text); box-shadow: var(--shadow-sm); }
.seg .i { width: 16px; height: 16px; }

.toggle { flex: none; display: inline-flex; align-items: center; gap: 8px; margin-left: auto; font-size: 13.5px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.toggle input { width: 16px; height: 16px; accent-color: var(--brand); }
.empty { padding: 36px; text-align: center; color: var(--text-2); }
.empty p { margin: 0 0 12px; }
.tag {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 7px;
  font-size: 12px; font-weight: 500;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.tag-NAT, .tag-MCQ, .tag-MSQ { color: var(--text-2); background: var(--surface-2); }
/* Source badge: coloured dot + exam, year, session; GATE DA (the target exam) is tinted */
.src {
  display: inline-flex; align-items: center; gap: 6px;
  height: 20px; padding: 0 8px 0 7px;
  font-size: 12px; font-weight: 500;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  white-space: nowrap;
}
a.src { text-decoration: none; cursor: pointer; transition: opacity .15s ease; }
a.src:hover { opacity: 0.85; }
.src::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--src-c, var(--text-3)); }
.src.src-gate-da { color: var(--brand); background: var(--brand-soft); border-color: transparent; }
.src.src-practice { color: var(--text-3); }

/* ------------------------------------------------------------------ inputs
   .input for text fields and selects; .field wraps a label and its input */
.input,
.field input[type="url"], .field input[type="text"], .field input[type="email"], .field input[type="number"], .field select, .field textarea {
  height: 36px; padding: 0 12px;
  font: inherit; font-size: 14px; font-weight: 400;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  transition: border-color .12s, box-shadow .12s;
}
textarea.input, .field textarea { height: auto; padding: 8px 12px; line-height: 1.5; }
.input:focus,
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.radios { display: flex; gap: 18px; font-weight: 400; color: var(--text); }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius); font-weight: 500; color: var(--text); cursor: pointer; text-align: center; }
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.current-file { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius); font-weight: 400; }
.current-file code { font: 12.5px var(--mono); overflow-wrap: anywhere; }
.status { margin: 0; font-size: 13.5px; color: var(--text-2); }

/* ------------------------------------------------------------------ popovers and menus
   .popover: a floating panel under its button (modules/popover.js places it and closes it).
   .menu-item rows (a or button, with an .i icon), .menu-sep lines, .menu-head for a title or the
   account, .menu-row for a label with a control on the right, .menu-hint for muted text on the right.
   .popover.sheet: the same panel as a bottom sheet on phones, over a .sheet-backdrop. */
.popover {
  position: fixed; z-index: 60;
  min-width: 220px; max-width: calc(100vw - 16px);
  max-height: min(70vh, 560px); overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  color: var(--text);
}
.menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 34px; padding: 0 10px;
  font-size: 14px; font-weight: 400; text-align: left;
  color: var(--text); background: none; border: 0; border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); color: var(--text); outline: none; }
.menu-item > .i { color: var(--text-3); }
.menu-item > span:not(.menu-hint) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.menu-item kbd, .menu-hint { margin-left: auto; }
.menu-hint { font-size: 12.5px; color: var(--text-3); }
.menu-item[aria-checked="true"]::after { content: ""; width: 5px; height: 9px; margin: -3px 3px 0 auto; border: solid var(--brand); border-width: 0 1.75px 1.75px 0; transform: rotate(45deg); }
.menu-sep { height: 1px; margin: 6px -6px; background: var(--border); }
.menu-head { padding: 8px 10px; }
.menu-head p { margin: 0 0 10px; font-size: 13px; }
.menu-label { padding: 6px 10px 2px; font-size: 12px; color: var(--text-3); }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 38px; padding: 0 4px 0 10px; }

.popover.sheet {
  left: 0 !important; right: 0; top: auto !important; bottom: 0;
  width: 100%; max-width: none; max-height: 85vh; max-height: 85dvh;
  padding: 18px 12px max(14px, env(safe-area-inset-bottom));
  border-width: 1px 0 0; border-radius: 16px 16px 0 0;
  z-index: 2100;
  animation: sheetIn .18s cubic-bezier(0.16, 1, 0.3, 1);
}
.popover.sheet::before { content: ""; position: absolute; top: 7px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 99px; background: var(--border-strong); }
.popover.sheet .menu-item { min-height: 44px; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 2090; background: var(--overlay); }
@keyframes sheetIn { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ------------------------------------------------------------------ modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--overlay);
}
.modal-card {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: modalIn .15s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.98) translateY(4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 12px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  flex: 1;
  min-width: 0;
}
.modal-head .icon-btn {
  margin-left: auto;
  flex-shrink: 0;
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-foot .spacer,
.modal-foot > .muted {
  margin-right: auto;
}

/* ------------------------------------------------------------------ toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 80;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 14px;
  font-size: 14px; font-weight: 500;
  color: var(--tip-text); background: var(--tip-bg);
  border: 1px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
}
html.dark .toast { border-color: var(--border-strong); }
.toast.ok::before, .toast.error::before, .toast.warn::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.toast.error::before { background: var(--bad); }
.toast.warn::before { background: var(--warn); }
.toast.warn { border-color: var(--warn); }
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* Phones and tablets, and phones held sideways */
@media (max-width: 900px), (pointer: coarse) and (max-height: 500px) {
  :root { --topbar-h: 52px; }
  .toast { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); }
  /* Filters scroll sideways instead of wrapping */
  .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 -14px;
    padding: 1px 14px;
    -webkit-overflow-scrolling: touch;
  }
  .chips::-webkit-scrollbar { display: none; }
  /* 16px stops iOS zooming into focused fields */
  .input,
  .field input[type="url"],
  .field input[type="text"], .field input[type="email"], .field input[type="number"], .field select, .field textarea { font-size: 16px; }
}

/* Phones held sideways: slimmer bars leave room for the problems */
@media (max-width: 900px) and (max-height: 500px), (pointer: coarse) and (max-height: 500px) {
  :root { --topbar-h: 48px; --tabbar-h: 46px; }
}

/* The confirm dialog (modules/ui.js showConfirmModal) */
#generic-confirm-modal {
  z-index: 2600;
}
.modal-confirm {
  width: min(420px, 92vw);
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  animation: modalIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-confirm .modal-head {
  border-bottom: 0;
  padding-bottom: 0;
}
.modal-confirm .modal-head h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.modal-confirm .modal-body {
  padding: 8px 18px 18px;
}
.modal-confirm .modal-body p {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-2);
  margin: 0;
  white-space: pre-line;
}
.modal-confirm .modal-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 0 18px 16px;
  border-top: 0;
}

@media (max-width: 640px) {
  .page-head { flex-direction: column; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
  .page-head h1 { font-size: 20px; }
  .page-actions { width: 100%; display: flex; gap: 8px; }
  .page-actions .btn { flex: 1 1 0; height: 36px; padding: 0 12px; font-size: 13px; justify-content: center; }
  .toggle { margin-left: 0; }
  /* Dialogs become bottom sheets */
  .modal { align-items: end; padding: 0; }
  .modal-card { width: 100%; max-height: 92vh; max-height: 92dvh; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .modal-confirm { width: 100%; border-radius: 16px 16px 0 0; margin: 0; }
  .modal-confirm .modal-foot { display: flex; gap: 10px; padding: 14px 18px max(14px, env(safe-area-inset-bottom)); }
  .modal-confirm .modal-foot .btn { flex: 1 1 0; height: 42px; font-size: 14px; justify-content: center; }
}

@media (pointer: coarse) {
  .segmented button { height: 36px; }
  .chip { height: 38px; }
  .page-actions .btn { height: 38px; }
  .toggle { min-height: 40px; }
  .toggle input { width: 20px; height: 20px; }
  .menu-item { min-height: 44px; }
}

@media (hover: none) {
  .chip:hover { color: var(--text-2); border-color: var(--border); }
  .chip.on:hover { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .modal-card, .modal-confirm, .popover.sheet { animation: none; }
}

/* Admin-only links (Studio) stay hidden for everyone else, whatever their display rule */
[data-admin-only][hidden] { display: none !important; }
