/* Shared dashboard/admin tokens start in dark mode and are overridden by the light palettes. */
:root {
  color-scheme: dark;
  --bg: #0d0f13;
  --bg-glow: #1a1d26;
  --bg-elev: #14171d;
  --bg-input: #0f1116;
  --card: #171a21;
  --card-hover: #1c2029;
  --surface-2: #20242d;
  --surface-3: #262a33;
  --border: #262a33;
  --border-strong: #343945;
  --border-hover: #3f4553;
  --text: #e6e8ee;
  --muted: #8b91a1;
  --faint: #6b7180;
  --footer: #5c6270;
  --accent: #f59e0b;
  --accent-hover: #fbb033;
  --accent-contrast: #1a1200;
  --accent-2: #38bdf8;
  --danger: #f87171;
  --danger-border: rgba(239, 68, 68, 0.5);
  --danger-bg: rgba(239, 68, 68, 0.12);
  --ok: #4ade80;
  --ok-bg: rgba(74, 222, 128, 0.12);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.14);
  --chip-bg: rgba(255, 255, 255, 0.02);
  --tabbar-bg: rgba(20, 23, 29, 0.8);
  --backdrop: rgba(0, 0, 0, 0.6);
  --toast-bg: #22262f;
  --login-story: #111821;
  --login-pane: #0d1015;
  --login-line: #344451;
  --login-route: #536575;
  --login-node: #1a2631;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  /* Expand the main content on wide screens while keeping it within the viewport. */
  --content-max: min(1760px, 94vw);
  --tabbar-max: min(1240px, 94vw);
  /* app.js sets this browser-local card scale; level 8 uses the original 1x dimensions. */
  --card-scale: 1;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", Roboto, sans-serif;
}

/* Select the light palette for system light mode unless the user explicitly chooses dark. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --light: 1; }
}
:root[data-theme="light"] { --light: 1; }

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f5f6f8;
    --bg-glow: #ffffff;
    --bg-elev: #ffffff;
    --bg-input: #ffffff;
    --card: #ffffff;
    --card-hover: #ffffff;
    --surface-2: #eceef2;
    --surface-3: #e4e7ec;
    --border: #e3e6eb;
    --border-strong: #d0d5dd;
    --border-hover: #b9c0cb;
    --text: #1b1f27;
    --muted: #5f6675;
    --faint: #7c8393;
    --footer: #9aa1ae;
    --accent: #e08a00;
    --accent-hover: #f29b0e;
    --accent-contrast: #ffffff;
    --accent-2: #0ea5e9;
    --danger: #dc2626;
    --danger-border: rgba(220, 38, 38, 0.45);
    --danger-bg: rgba(220, 38, 38, 0.08);
    --ok: #15803d;
    --ok-bg: rgba(21, 128, 61, 0.1);
    --warn: #b45309;
    --warn-bg: rgba(180, 83, 9, 0.1);
    --chip-bg: #f3f4f6;
    --tabbar-bg: rgba(255, 255, 255, 0.85);
    --backdrop: rgba(15, 18, 25, 0.35);
    --toast-bg: #1b1f27;
    --login-story: #e9eff4;
    --login-pane: #ffffff;
    --login-line: #c8d5df;
    --login-route: #9bafbf;
    --login-node: #f7fafc;
    --shadow: 0 10px 30px rgba(20, 24, 33, 0.12);
  }
  :root:not([data-theme="dark"]) .toast { color: #f5f6f8; }
}
/* Explicit light mode must apply the same palette even when the system prefers dark. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6f8;
  --bg-glow: #ffffff;
  --bg-elev: #ffffff;
  --bg-input: #ffffff;
  --card: #ffffff;
  --card-hover: #ffffff;
  --surface-2: #eceef2;
  --surface-3: #e4e7ec;
  --border: #e3e6eb;
  --border-strong: #d0d5dd;
  --border-hover: #b9c0cb;
  --text: #1b1f27;
  --muted: #5f6675;
  --faint: #7c8393;
  --footer: #9aa1ae;
  --accent: #e08a00;
  --accent-hover: #f29b0e;
  --accent-contrast: #ffffff;
  --accent-2: #0ea5e9;
  --danger: #dc2626;
  --danger-border: rgba(220, 38, 38, 0.45);
  --danger-bg: rgba(220, 38, 38, 0.08);
  --ok: #15803d;
  --ok-bg: rgba(21, 128, 61, 0.1);
  --warn: #b45309;
  --warn-bg: rgba(180, 83, 9, 0.1);
  --chip-bg: #f3f4f6;
  --tabbar-bg: rgba(255, 255, 255, 0.85);
  --backdrop: rgba(15, 18, 25, 0.35);
  --toast-bg: #1b1f27;
  --login-story: #e9eff4;
  --login-pane: #ffffff;
  --login-line: #c8d5df;
  --login-route: #9bafbf;
  --login-node: #f7fafc;
  --shadow: 0 10px 30px rgba(20, 24, 33, 0.12);
}
:root[data-theme="light"] .toast { color: #f5f6f8; }

/* Base typography, page background, and shared element defaults. */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 50% -10%, var(--bg-glow) 0%, var(--bg) 60%) fixed;
  transition: background-color 0.2s, color 0.2s;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.hidden { display: none !important; }

/* ---------- Brand and top toolbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: conic-gradient(from 200deg, var(--accent), var(--accent-2), var(--accent));
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}
.brand-text { font-size: 20px; letter-spacing: -0.3px; }
.brand-text b { color: var(--accent); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.who { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.who a { color: inherit; }
.who a:hover, .who a:focus-visible { color: var(--text); }

/* Shared action buttons used by the dashboard, dialogs, and administrator page. */
.btn {
  border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text);
  min-height: 36px; padding: 0 14px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 500; line-height: 1.2;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn:hover { background: var(--card-hover); border-color: var(--border-hover); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.sm { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.lg { min-height: 42px; padding: 0 20px; font-size: 15px; border-radius: 11px; }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn.danger-solid:hover { filter: brightness(1.08); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; border-color: var(--danger-border); color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); }

/* ---------- Theme switch with aria-pressed selection state ---------- */
.theme-switch {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--bg-elev);
}
.theme-switch button {
  width: 30px; height: 28px; border-radius: 7px; border: 0; background: transparent; color: var(--muted);
  cursor: pointer; display: grid; place-items: center;
}
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }
.theme-switch svg { width: 15px; height: 15px; }

/* ---------- Browser-local card-size slider and reset button ---------- */
.card-size {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 7px 3px 9px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--bg-elev);
  color: var(--muted);
}
.card-size:hover { color: var(--text); }
.card-size > svg { width: 15px; height: 15px; flex: none; }
.card-size input[type="range"] {
  width: 84px; height: 28px; margin: 0; padding: 0;
  background: transparent; accent-color: var(--accent); cursor: pointer;
}
.card-size-val {
  min-width: 17px; height: 28px; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); cursor: pointer;
  font: inherit; font-size: 12px; font-variant-numeric: tabular-nums;
}
.card-size-val:hover { background: var(--surface-3); color: var(--text); }

/* ---------- Dashboard top bar: brand, search, primary action, who is signed in ---------- */
.app-top {
  position: sticky; top: 0; z-index: 30; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 20px;
  height: 64px; padding: 0 28px; border-bottom: 1px solid var(--border); background: var(--tabbar-bg); backdrop-filter: blur(12px);
}
.app-top .brand-text { white-space: nowrap; }
.app-search {
  justify-self: center; width: 100%; max-width: 620px; height: 42px; display: flex; align-items: center; gap: 10px; padding: 0 12px 0 14px;
  border: 1px solid var(--border-strong); border-radius: 12px; background: var(--bg-input); color: var(--muted);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.app-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15); }
.app-search svg { flex: none; }
.app-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 14.5px; }
.app-search input::placeholder { color: var(--faint); }
.app-search input::-webkit-search-cancel-button { cursor: pointer; }
.search-key { flex: none; min-width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid var(--border-strong); border-radius: 6px;
  color: var(--faint); font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.app-search:focus-within .search-key { display: none; }
.app-top-actions { display: flex; align-items: center; gap: 10px; }
.app-top-actions .btn { min-height: 40px; }
.who-chip { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 4px 0 6px; max-width: 300px;
  border: 1px solid var(--border-strong); border-radius: 20px; background: var(--bg-elev); color: var(--muted); font-size: 13px; }
.avatar { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700;
  color: var(--accent-contrast); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.who-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-logout { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); }
.who-logout:hover, .who-logout:focus-visible { background: var(--surface-3); color: var(--text); outline: none; }

/* ---------- Section tabs on the left, view controls and tools on the right ---------- */
.app-toolbar {
  width: var(--content-max); max-width: 100%; margin: 18px auto 0; padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.tabs { display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  white-space: nowrap; min-height: 36px; padding: 0 16px; border-radius: 10px; font-size: 14px; color: var(--muted);
  border: 1px solid transparent; background: transparent; cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tab.active { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); font-weight: 600; }
.toolbar-tools { display: flex; align-items: center; gap: 8px; flex: none; }
.tool-sep { width: 1px; height: 24px; background: var(--border-strong); margin: 0 2px; }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--muted); transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { color: var(--text); background: var(--card-hover); border-color: var(--border-hover); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn svg { width: 18px; height: 18px; }
.toolbar-tools .card-size, .toolbar-tools .theme-switch { height: 38px; }
.toolbar-tools .theme-switch button { height: 30px; }

/* ---------- Link sections and cards ---------- */
.sections { width: var(--content-max); max-width: 100%; margin: 0 auto; padding: 20px 28px 60px; }
.section { margin-top: 36px; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.section-head h2 { font-size: 20px; margin: 0; letter-spacing: -0.3px; }
.section-head .count { color: var(--muted); font-size: 13px; }
/* Scale grid columns, card spacing, typography, icons, and controls together.
   Changing --card-scale affects layout, so smaller cards also fit in more columns.
   The original size is 1; app.js supplies the current browser's preference. */
.grid {
  display: grid; gap: calc(18px * var(--card-scale));
  grid-template-columns: repeat(auto-fill, minmax(calc(260px * var(--card-scale)), 1fr));
}

.card {
  position: relative; display: block;
  background: var(--card); border: 1px solid var(--border);
  border-radius: calc(var(--radius) * var(--card-scale));
  padding: calc(20px * var(--card-scale)) calc(20px * var(--card-scale)) calc(18px * var(--card-scale));
  min-height: calc(190px * var(--card-scale));
  transition: transform 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.card:hover {
  transform: translateY(-2px); border-color: var(--border-strong); background: var(--card-hover);
  box-shadow: var(--shadow);
}
/* Drag handlers in app.js toggle these classes on the source and current drop target. */
.card.dragging { opacity: 0.4; }
.card.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }
.card-icon {
  width: calc(48px * var(--card-scale)); height: calc(48px * var(--card-scale));
  border-radius: calc(12px * var(--card-scale)); display: grid; place-items: center;
  font-size: calc(26px * var(--card-scale)); overflow: hidden;
  margin-bottom: calc(18px * var(--card-scale));
}
.card-icon svg { width: 100%; height: 100%; display: block; }
.card-title {
  font-size: calc(17px * var(--card-scale)); font-weight: 600;
  margin: 0 0 calc(6px * var(--card-scale)); letter-spacing: -0.2px;
}
.card-desc { color: var(--muted); font-size: calc(13px * var(--card-scale)); margin: 0; line-height: 1.5; min-height: 1.5em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-url { color: var(--faint); font-size: calc(12px * var(--card-scale)); margin-top: calc(10px * var(--card-scale));
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.card-tags { display: flex; flex-wrap: wrap; gap: calc(6px * var(--card-scale)); margin-top: calc(10px * var(--card-scale)); }
.chip {
  font-size: calc(11px * var(--card-scale)); color: var(--muted); border: 1px solid var(--border);
  border-radius: 999px; padding: calc(2px * var(--card-scale)) calc(8px * var(--card-scale));
  background: var(--chip-bg);
}
.card-edit {
  position: absolute; top: calc(14px * var(--card-scale)); right: calc(14px * var(--card-scale));
  width: calc(30px * var(--card-scale)); height: calc(30px * var(--card-scale));
  border-radius: calc(8px * var(--card-scale));
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
  display: grid; place-items: center; opacity: 0; transition: opacity 0.15s, background 0.15s;
}
.card-edit svg { width: calc(15px * var(--card-scale)); height: calc(15px * var(--card-scale)); }
/* Reveal editing on mouse hover or keyboard focus; mobile rules keep it visible. */
.card:hover .card-edit, .card:focus-within .card-edit { opacity: 1; }
.card-edit:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }

/* ---------- Empty collection and search-result messages ---------- */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-icon {
  width: 72px; height: 72px; margin: 0 auto 18px; border-radius: 20px; border: 1px dashed var(--border-strong);
  background: linear-gradient(135deg, rgba(245,158,11,0.12), rgba(56,189,248,0.12));
}
.empty h2 { color: var(--text); font-size: 20px; margin: 0 0 8px; }
.empty p { margin: 0; }

.footer { text-align: center; color: var(--footer); font-size: 12px; padding: 20px 0 40px; }

/* ---------- Link editor dialog and shared form fields ---------- */
.modal {
  border: 1px solid var(--border-strong); border-radius: 18px; background: var(--bg-elev); color: var(--text);
  padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow);
}
.modal::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }
.modal form { padding: 26px 26px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal h2 { margin: 0 0 6px; font-size: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.field > span { color: var(--muted); }
.field em { color: var(--accent); font-style: normal; }
.field input {
  background: var(--bg-input); border: 1px solid var(--border-strong); border-radius: 10px; color: var(--text);
  padding: 10px 12px; font-size: 14px; outline: none;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15); }
.field small { color: var(--faint); }
.keyword-row { display: flex; align-items: stretch; }
.keyword-suffix {
  display: flex; align-items: center; padding: 0 10px; font-size: 12.5px; color: var(--faint);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 10px 10px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; max-width: 55%; overflow: hidden; text-overflow: ellipsis;
}
.keyword-suffix:empty { display: none; }
.keyword-row input { flex: 1; min-width: 0; }
.keyword-row input:has(+ .keyword-suffix:not(:empty)) { border-radius: 10px 0 0 10px !important; }
.field.check { flex-direction: row; align-items: flex-start; gap: 10px; }
.field.check input { width: 16px; height: 16px; margin-top: 1px; accent-color: var(--accent); }
.field.check span { color: var(--text); }
.field.check small { color: var(--faint); display: block; margin-top: 2px; }
/* Emphasize the public keyword URL while retaining the original target as secondary text. */
.card-proxy {
  display: inline-flex; align-items: center; gap: calc(4px * var(--card-scale));
  margin-top: calc(10px * var(--card-scale)); font-size: calc(12px * var(--card-scale)); color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.card-proxy svg { width: calc(12px * var(--card-scale)); height: calc(12px * var(--card-scale)); flex: none; }
.card-url.secondary { margin-top: calc(4px * var(--card-scale)); }
/* A shortcut shown only to groups: who sees it, on the card. */
.card-audience {
  display: inline-flex; align-items: center; gap: calc(5px * var(--card-scale)); max-width: 100%;
  margin-top: calc(8px * var(--card-scale)); padding: calc(2px * var(--card-scale)) calc(8px * var(--card-scale));
  border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: calc(11.5px * var(--card-scale));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-audience svg { width: calc(11px * var(--card-scale)); height: calc(11px * var(--card-scale)); flex: none; }
/* Preview of another person's view: a banner, notes on keywords they could not open, editing locked. */
.preview-bar {
  width: var(--content-max); max-width: calc(100% - 56px); margin: 14px auto 0; padding: 10px 12px 10px 16px;
  display: flex; align-items: center; gap: 12px; border: 1px solid color-mix(in srgb, var(--accent-2) 45%, transparent);
  border-radius: 12px; background: color-mix(in srgb, var(--accent-2) 10%, var(--bg-elev)); color: var(--text); font-size: 14px;
}
.preview-bar > svg { width: 20px; height: 20px; flex: none; color: var(--accent-2); }
.preview-text { flex: 1; min-width: 0; line-height: 1.5; }
.preview-text span { color: var(--muted); }
body.is-preview #btn-add, body.is-preview #btn-import { opacity: 0.45; pointer-events: none; }
.card-access { display: inline-flex; margin-top: calc(8px * var(--card-scale)); margin-left: calc(4px * var(--card-scale)); padding: calc(2px * var(--card-scale)) calc(8px * var(--card-scale));
  border-radius: 999px; font-size: calc(11.5px * var(--card-scale)); font-weight: 600; }
.card-access.login { color: var(--warn); background: var(--warn-bg); }
.card-access.group { color: var(--danger); background: var(--danger-bg); }
@media (max-width: 640px) { .preview-bar { max-width: calc(100% - 32px); flex-wrap: wrap; } }
/* Two-choice switch (radio group) in dialogs. */
.segmented { display: inline-flex; padding: 3px; gap: 3px; border-radius: 11px; border: 1px solid var(--border-strong); background: var(--bg-input); align-self: flex-start; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: inline-flex; align-items: center; min-height: 32px; padding: 0 14px; border-radius: 8px; font-size: 13.5px; color: var(--muted); }
.segmented input:checked + span { background: var(--surface-3); color: var(--text); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.segmented input:disabled + span { opacity: 0.55; }
#audience .picker { margin-top: 4px; }
.icon-row { display: grid; grid-template-columns: 110px 44px 1fr; gap: 10px; align-items: center; }
.icon-row small { line-height: 1.4; }
.icon-preview { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; font-size: 24px; overflow: hidden; }
.icon-preview svg { width: 100%; height: 100%; display: block; }
.form-error { color: var(--danger); font-size: 13px; margin: 0; min-height: 1em; }
.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.modal-actions .spacer { flex: 1; }

/* ---------- Scrollable CA installation dialog and fingerprint display ---------- */
.modal.modal-wide { width: min(640px, calc(100vw - 32px)); }
.ca-actions { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-input); }
.ca-fp { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ca-fp-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.ca-fp code { font-size: 11.5px; word-break: break-all; line-height: 1.5; flex: 1; min-width: 200px; }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
.ca-steps h3 { font-size: 15px; margin: 10px 0 4px; }
.ca-check { margin: 4px 0 0; padding-left: 20px; line-height: 1.6; }
.ca-check li { margin: 4px 0; }
.modal-body ul li b, .modal-body ol li b { color: var(--text); }
.modal-body { padding: 26px 26px 20px; display: flex; flex-direction: column; gap: 12px; font-size: 14px; max-height: 85vh; overflow: auto; }
.modal-body h2 { margin: 0; font-size: 20px; }
.modal-body .lead { margin: 0; color: var(--muted); line-height: 1.55; }
.modal-body .btn.primary { align-self: flex-start; }
.modal-body details { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; background: var(--bg-input); }
.modal-body summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.modal-body ol { margin: 8px 0 4px; padding-left: 20px; line-height: 1.6; color: var(--text); }
.modal-body li { margin: 2px 0; }
.modal-body .note { margin: 6px 0 2px; color: var(--faint); font-size: 12.5px; line-height: 1.5; }
.modal-body pre { margin: 8px 0; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); font-size: 12.5px; overflow: auto; }

/* ---------- Transient status toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--toast-bg); border: 1px solid var(--border-strong); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 13.5px; opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s; box-shadow: var(--shadow); z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Show keyboard focus without adding the same outline to ordinary pointer clicks. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app-search input:focus-visible { outline: none; }

/* The login entrance has its own layout while sharing the dashboard's palette and mark. */
body.login-page { background: var(--login-pane); }
.login-shell {
  display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(430px, 0.92fr);
  max-width: 1600px; min-height: 100vh; min-height: 100svh; margin: 0 auto;
  border-inline: 1px solid var(--border);
}
.login-story {
  position: relative; isolation: isolate; overflow: hidden;
  min-height: 760px; padding: clamp(32px, 4.2vw, 68px);
  display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(550px 420px at 16% 103%, rgba(56, 189, 248, 0.08), transparent 72%),
    radial-gradient(520px 420px at 90% 0%, rgba(245, 158, 11, 0.065), transparent 70%),
    var(--login-story);
  border-right: 1px solid var(--border-strong);
}
.login-story::before {
  content: ''; position: absolute; z-index: -1;
  width: 850px; aspect-ratio: 1; right: -530px; top: -300px;
  border: 1px solid var(--login-line); border-radius: 50%;
  box-shadow: 0 0 0 110px var(--login-story), 0 0 0 111px var(--login-line),
    0 0 0 225px var(--login-story), 0 0 0 226px var(--login-line);
  opacity: 0.5;
}
.login-brand {
  display: inline-flex; align-items: center; align-self: flex-start; gap: 11px;
  color: var(--text); font-size: 21px; font-weight: 700; letter-spacing: -0.55px;
}
.login-brand .brand-mark { width: 28px; height: 28px; }
.login-brand b { color: var(--accent); }
.login-story-copy { position: relative; max-width: 660px; margin: auto 0 26px; padding-top: 70px; }
.login-kicker, .login-story-foot, .login-panel-top {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; font-weight: 600; letter-spacing: 0.14em;
}
.login-kicker { margin: 0 0 24px; color: var(--accent); }
.login-story h1 {
  margin: 0; font-size: clamp(40px, 4.2vw, 66px); font-weight: 700;
  line-height: 1.18; letter-spacing: -0.065em; text-wrap: balance;
}
.login-story h1 span { color: var(--accent); }
.login-intro { margin: 24px 0 0; color: var(--muted); font-size: 16px; line-height: 1.65; }
.login-map { width: min(620px, 100%); margin: 0 auto 28px; }
.login-map svg { display: block; width: 100%; height: auto; overflow: visible; }
.login-map-route, .login-map-route-accent { fill: none; stroke: var(--login-route); stroke-width: 1.5; }
.login-map-route-accent { stroke: var(--accent); stroke-width: 2; }
.login-map-node rect { fill: var(--login-node); stroke: var(--login-line); }
.login-map-node circle { fill: var(--accent-2); opacity: 0.75; }
.login-map-node path { fill: none; stroke: var(--login-route); stroke-width: 2; stroke-linecap: round; }
.login-map-core { fill: var(--card); stroke: var(--border-strong); }
.login-map-core-mark { fill: var(--accent); }
.login-map-core-link { fill: none; stroke: var(--accent-contrast); stroke-width: 2.5; stroke-linecap: round; }
.login-map text { fill: var(--text); font-family: var(--font); font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.login-story-foot { position: relative; margin: 0; color: var(--faint); letter-spacing: 0.08em; }
.login-story-foot span { color: var(--accent); padding: 0 7px; }
.login-access {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 48px clamp(28px, 5vw, 80px); background: var(--login-pane);
}
.login-panel { width: min(440px, 100%); }
.login-panel-top { display: flex; align-items: center; gap: 12px; color: var(--faint); }
.login-panel-symbol {
  display: grid; place-items: center; width: 32px; height: 32px;
  border: 1px solid var(--border-strong); border-radius: 9px;
  color: var(--accent); font-family: var(--font); font-size: 19px; letter-spacing: 0;
}
.login-step { margin: 76px 0 12px; color: var(--accent); font-size: 13px; font-weight: 700; }
.login-panel h2 { margin: 0; font-size: clamp(34px, 3.2vw, 47px); line-height: 1.2; letter-spacing: -0.055em; }
.login-description { max-width: 360px; margin: 20px 0 0; color: var(--muted); font-size: 15px; line-height: 1.7; }
.login-google {
  display: grid; grid-template-columns: 22px 1fr 22px; align-items: center; gap: 12px;
  width: 100%; min-height: 56px; margin-top: 42px; padding: 12px 18px;
  border: 1px solid #e2e5e9; border-radius: 10px;
  background: #f8fafc; color: #171b23; font-size: 14px; font-weight: 700; text-align: center;
  transition: background 0.15s, box-shadow 0.15s, transform 0.05s;
}
.login-google:hover { background: #ffffff; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14); }
.login-google:active { transform: translateY(1px); }
.login-google svg { display: block; }
.login-google-arrow { color: #606a78; font-size: 21px; font-weight: 400; line-height: 1; }
.login-domain {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 34px; padding-top: 20px; border-top: 1px solid var(--border);
  color: var(--faint); font-size: 12px;
}
.login-domain strong { color: var(--muted); font-weight: 600; overflow-wrap: anywhere; text-align: right; }
.login-footer { width: min(440px, 100%); margin: 64px 0 0; color: var(--footer); font-size: 11px; }

/* Gateway-owned status page: the target service may be offline, so only the apex serves its assets. */
.service-error-page .topbar { width: min(1200px, 100%); margin: 0 auto; padding-block: 28px; }
.service-error-shell {
  width: min(1144px, calc(100% - 56px)); min-height: min(640px, calc(100svh - 120px));
  margin: 12px auto 48px; border: 1px solid var(--border-strong); border-radius: 20px;
  background: var(--bg-elev); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.service-error-rail, .service-error-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 22px 32px; color: var(--faint); font-size: 11px; font-weight: 650;
  letter-spacing: 0.12em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.service-error-rail { border-bottom: 1px solid var(--border); }
.service-error-rail span:last-child { color: var(--accent); }
.service-error-content {
  flex: 1; display: grid; grid-template-columns: minmax(250px, 0.8fr) minmax(0, 1.2fr);
  align-items: center; gap: clamp(24px, 5vw, 88px); padding: clamp(38px, 6vw, 84px);
}
.service-error-code {
  color: var(--text); font-size: clamp(112px, 16vw, 220px); font-weight: 750;
  line-height: 0.95; letter-spacing: -0.105em; font-variant-numeric: tabular-nums;
}
.service-error-code span { color: var(--accent); }
.service-error-kicker { margin: 0 0 18px; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; }
.service-error-copy h1 { margin: 0; font-size: clamp(28px, 3.5vw, 44px); line-height: 1.2; letter-spacing: -0.055em; text-wrap: balance; }
.service-error-copy > p:not(.service-error-kicker) { max-width: 460px; margin: 20px 0 0; color: var(--muted); font-size: 15px; line-height: 1.75; }
.service-error-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 36px; }
.service-error-actions .btn { min-height: 44px; justify-content: center; }
.service-error-foot { border-top: 1px solid var(--border); letter-spacing: 0.04em; }
.service-error-foot span:first-child { color: var(--muted); font-family: var(--font); font-size: 12px; letter-spacing: 0; overflow-wrap: anywhere; }

@media (max-width: 700px) {
  .service-error-shell { width: calc(100% - 32px); min-height: calc(100svh - 112px); margin-top: 0; border-radius: 16px; }
  .service-error-content { grid-template-columns: 1fr; align-content: center; gap: 22px; padding: 32px 28px 48px; }
  .service-error-code { font-size: clamp(104px, 26vw, 164px); }
  .service-error-rail, .service-error-foot { padding-inline: 24px; }
  .service-error-foot span:last-child { display: none; }
}

@media (max-width: 900px) {
  .login-shell { display: block; border: 0; }
  .login-story { min-height: 0; padding: 32px clamp(24px, 6vw, 52px) 42px; border-right: 0; border-bottom: 1px solid var(--border-strong); }
  .login-story-copy { margin: 68px 0 0; padding: 0; }
  .login-story h1 { font-size: clamp(38px, 6.2vw, 58px); }
  .login-map, .login-story-foot { display: none; }
  .login-access { padding: 56px 24px 44px; }
  .login-step { margin-top: 52px; }
  .login-footer { margin-top: 52px; }
}
@media (max-width: 480px) {
  .login-story { padding: 26px 24px 36px; }
  .login-story-copy { margin-top: 52px; }
  .login-story h1 { font-size: clamp(34px, 9vw, 42px); }
  .login-kicker { margin-bottom: 18px; font-size: 10px; }
  .login-intro { margin-top: 18px; font-size: 13px; }
  .login-access { padding: 42px 24px 30px; }
  .login-step { margin-top: 42px; }
  .login-panel h2 { font-size: 34px; }
  .login-google { margin-top: 32px; }
  .login-domain { align-items: flex-start; flex-direction: column; gap: 5px; }
  .login-domain strong { text-align: left; }
  .login-footer { margin-top: 42px; }
}

/* Medium screens: search takes its own row; small screens: tools wrap and the add button keeps its icon. */
@media (max-width: 900px) {
  .app-top { grid-template-columns: auto 1fr; grid-template-areas: "brand actions" "search search"; height: auto; row-gap: 10px; padding: 10px 16px 12px; }
  .app-top .brand { grid-area: brand; }
  .app-top-actions { grid-area: actions; justify-self: end; }
  .app-search { grid-area: search; max-width: none; }
  .app-toolbar { padding: 0 16px; flex-wrap: wrap; }
  .sections { padding: 10px 16px 40px; }
}
@media (max-width: 640px) {
  .btn-label, .who-email { display: none; }
  .who-chip { padding: 0 4px; }
  .toolbar-tools { width: 100%; justify-content: flex-end; flex-wrap: wrap; }
  /* Cards are one column on a phone: the size slider has nothing to change there. */
  .toolbar-tools .card-size { display: none; }
  .card-edit { opacity: 1; }
}

/* ---------- Administrator console (/admin) ---------- */
body.console { background: var(--bg); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.console-top {
  position: sticky; top: 0; z-index: 30; height: 60px; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border-bottom: 1px solid var(--border); background: var(--tabbar-bg); backdrop-filter: blur(12px);
}
.console-brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.console-crumb { padding-left: 14px; border-left: 1px solid var(--border-strong); color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; }
.console-top-actions { display: flex; align-items: center; gap: 8px; }
.console-shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: calc(100vh - 60px); }
.console-nav {
  position: sticky; top: 60px; align-self: start; height: calc(100vh - 60px);
  display: flex; flex-direction: column; gap: 2px; padding: 18px 12px; border-right: 1px solid var(--border);
}
.console-nav button {
  display: flex; align-items: center; gap: 11px; width: 100%; min-height: 42px; padding: 0 12px;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 14.5px; text-align: left; cursor: pointer;
}
.console-nav button:hover { background: var(--surface-2); color: var(--text); }
.console-nav button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.console-nav button[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.console-nav svg { width: 18px; height: 18px; flex: none; }
.nav-count {
  margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px;
  display: inline-grid; place-items: center; background: var(--accent); color: var(--accent-contrast); font-size: 12px; font-weight: 700;
}
.console-main { width: 100%; max-width: 1320px; padding: 28px 36px 72px; }
/* Locked (no menu yet): the unlock card uses the whole row. */
.console-nav.hidden + .console-main { grid-column: 1 / -1; margin: 0 auto; }
.console-status { margin: 0 0 14px; min-height: 1.4em; color: var(--muted); font-size: 13px; }
.console-status[role="alert"], .view-status[role="alert"] { color: var(--danger); }
.view-status { margin: 0 0 10px; min-height: 0; font-size: 13.5px; }
.view-status:empty { display: none; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.records-count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 18px; }
.view-head h1 { margin: 0; font-size: 24px; letter-spacing: -0.4px; }
.view-head p { margin: 8px 0 0; max-width: 760px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.panel { border: 1px solid var(--border); border-radius: 14px; background: var(--bg-elev); }
.panel + .panel, .panel + section.panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; font-size: 15px; letter-spacing: -0.1px; }
.panel-body { padding: 18px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
/* Tables: roomy rows, quiet headers, numbers aligned, horizontal scroll on narrow screens. */
.console .table-scroll { position: relative; overflow-x: auto; border: 0; border-radius: 14px; background: transparent; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.data-table th {
  padding: 11px 16px; text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap;
  border-bottom: 1px solid var(--border); background: var(--bg-elev);
}
.data-table th:first-child { border-top-left-radius: 14px; }
.data-table th:last-child { border-top-right-radius: 14px; }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table tr.is-pending td { background: color-mix(in srgb, var(--warn) 7%, transparent); }
.data-table tr.is-pending td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.records-table td { white-space: pre-wrap; overflow-wrap: anywhere; vertical-align: top; min-width: 140px; font-size: 13.5px; }
.cell-main { display: block; font-weight: 600; word-break: keep-all; overflow-wrap: anywhere; }
.data-table td:first-child { min-width: 230px; }
.cell-sub { display: block; margin-top: 3px; color: var(--faint); font-size: 12.5px; background: none; padding: 0; }
code.cell-sub { font-size: 12px; }
.empty-cell { padding: 36px 16px !important; text-align: center; color: var(--muted); }
.actions-cell { width: 1%; white-space: nowrap; }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: nowrap; }
.groups-cell { min-width: 190px; }
.time-cell { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.groups-cell .chips { display: inline-flex; margin-right: 8px; vertical-align: middle; }
.groups-cell .btn { vertical-align: middle; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); }
.pagination span { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
/* Status badges and group chips. */
.badge { display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 11px; border-radius: 13px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.off { color: var(--muted); background: var(--surface-2); }
.badge.admin { color: var(--accent); background: rgba(245, 158, 11, 0.13); }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 13px; border: 1px solid var(--border-strong); background: var(--chip-bg); font-size: 12.5px; }
.chip.muted { color: var(--faint); border-style: dashed; background: transparent; }
/* On/off switch on a checkbox (role="switch"). */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 40px; height: 24px; margin: 0; border-radius: 12px;
  border: 1px solid var(--border-strong); background: var(--surface-3); cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.switch input::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); transition: transform 0.15s;
}
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }
.switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled { opacity: 0.5; cursor: not-allowed; }
.switch small { display: block; margin-top: 2px; color: var(--faint); font-size: 12.5px; }
/* Pickers: one toggle chip per choice. */
.picker { display: flex; flex-wrap: wrap; gap: 8px; }
.pick { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 14px; border-radius: 17px;
  border: 1px solid var(--border-strong); background: var(--bg-input); font-size: 13.5px; cursor: pointer; user-select: none; }
.pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pick small { color: var(--faint); font-size: 11.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.pick:hover { border-color: var(--border-hover); }
.pick:has(input:checked) { border-color: var(--accent); background: rgba(245, 158, 11, 0.12); color: var(--text); font-weight: 600; }
.pick:has(input:checked)::before { content: '✓'; color: var(--accent); font-weight: 700; }
.pick:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.pick:has(input:disabled) { opacity: 0.55; cursor: not-allowed; }
.pick.missing span { text-decoration: line-through; color: var(--faint); }
.picker-list { max-height: 50vh; overflow: auto; padding: 2px; }
/* Forms in the console. */
.console .field { font-size: 13.5px; }
.console .field > span { color: var(--muted); font-weight: 600; }
.console .field input { min-height: 40px; }
.field input[aria-invalid="true"], .picker[aria-invalid="true"] { border-color: var(--danger); }
.unlock-card { max-width: 460px; margin: 8vh auto 0; }
.unlock-card h1 { margin: 0 0 6px; font-size: 22px; }
.unlock-card p { margin: 0 0 18px; line-height: 1.6; font-size: 13.5px; }
.add-panel { margin-bottom: 16px; }
.add-grid { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(220px, 1.4fr) auto auto; align-items: end; gap: 16px; }
.add-actions { display: flex; gap: 8px; }
.filter-bar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; padding: 16px 18px; margin-bottom: 16px; }
.filter-bar .field { flex: 1 1 170px; }
.filter-bar .btn { min-height: 40px; }
.settings-form { display: flex; flex-direction: column; gap: 16px; }
.settings-form fieldset { margin: 0; padding: 0; min-width: 0; }
.settings-form legend { width: 100%; padding: 14px 18px; float: left; }
.settings-form legend + .panel-body { clear: both; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px 20px; align-items: start; }
.settings-grid .wide { grid-column: 1 / -1; }
.settings-grid .switch { min-height: 40px; }
.settings-bar {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: flex-end; gap: 16px;
  padding: 14px 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--tabbar-bg); backdrop-filter: blur(12px);
}
.settings-bar p { margin: 0 auto 0 0; color: var(--muted); font-size: 13px; white-space: pre-line; }
#settings-status[role="alert"] { color: var(--danger); }
.modal.modal-sm { width: min(460px, calc(100vw - 32px)); }
.modal form.modal-body { gap: 14px; }
@media (max-width: 960px) {
  .console-shell { grid-template-columns: 1fr; }
  .console-nav { position: sticky; top: 60px; z-index: 20; height: auto; flex-direction: row; overflow-x: auto; padding: 8px 12px;
    border-right: 0; border-bottom: 1px solid var(--border); background: var(--bg); }
  .console-nav button { width: auto; flex: none; min-height: 38px; }
  .console-nav button[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--accent); }
  .console-main { padding: 20px 16px 64px; }
  .add-grid { grid-template-columns: 1fr; }
  .console-crumb { display: none; }
}

/* ---------- Server-rendered message pages (login outcomes, logout confirmation) ---------- */
.message-page { background: var(--bg); }
.message-shell { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 32px 16px; }
.message-card { width: min(520px, 100%); padding: 32px 32px 28px; border: 1px solid var(--border); border-radius: 18px; background: var(--bg-elev); box-shadow: var(--shadow); }
.message-card h1 { margin: 0 0 10px; font-size: 22px; letter-spacing: -0.3px; }
.message-card p { margin: 0 0 10px; color: var(--muted); font-size: 14.5px; line-height: 1.65; }
.message-card .message-detail { color: var(--faint); font-size: 13px; }
.message-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.message-actions form { margin: 0; }
.message-actions .btn { min-height: 40px; }
