/* ==========================================================================
   UNITRUST Investment Bank — design tokens & shared components
   Dark is the default theme (brand direction); light is a fully designed pair.
   ========================================================================== */

:root {
  --font-display: "Inter Tight", "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Brand */
  --brand: #0e844d;
  --brand-deep: #0a5e37;
  --brand-glow: #34d27f;

  /* Shape & motion */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --radius-xl: 32px;
  --pill: 999px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.55, 0, 1, 0.45);
  --dur-1: 120ms;
  --dur-2: 220ms;
  --dur-3: 420ms;

  /* Layout */
  --gutter: clamp(16px, 4vw, 40px);
  --maxw: 1280px;
  --header-h: 72px;
  --z-header: 40;
  --z-drawer: 60;
  --z-modal: 80;
  --z-toast: 100;
}

/* Theme: dark (default). Also applies to any nested [data-theme="dark"] region. */
:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg: #050807;
  --bg-2: #0a0f0d;
  --surface: #0e1512;
  --surface-2: #141d19;
  --surface-3: #1b2621;
  --border: #213029;
  --border-strong: #33463d;
  --text: #eef4f0;
  --text-2: #b2c2b9;
  --text-3: #8a9d93;
  --accent: #34d27f;
  --accent-hover: #4be091;
  --on-accent: #03140a;
  --accent-ink: #4ade8a;
  --accent-soft: rgba(52, 210, 127, 0.12);
  --inverse: #ffffff;
  --on-inverse: #050807;
  --danger: #ff8080;
  --danger-soft: rgba(255, 128, 128, 0.12);
  --warning: #f5c04a;
  --warning-soft: rgba(245, 192, 74, 0.12);
  --info: #8ea9ff;
  --info-soft: rgba(142, 169, 255, 0.12);
  --success: var(--accent-ink);
  --success-soft: var(--accent-soft);
  --chart-in: #1fa864;
  --chart-out: #7381e8;
  --chart-grid: #1d2924;
  --scrim: rgba(2, 5, 4, 0.72);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-2: 0 24px 60px -24px rgba(0, 0, 0, 0.8);
  --focus: #7cf0ae;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-2: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #f3f6f4;
  --surface-3: #e8eeea;
  --border: #e0e7e3;
  --border-strong: #c6d2cb;
  --text: #0a120e;
  --text-2: #3e4e46;
  --text-3: #5b6b63;
  --accent: #0e844d;
  --accent-hover: #0a6b3e;
  --on-accent: #ffffff;
  --accent-ink: #0a6b3e;
  --accent-soft: rgba(14, 132, 77, 0.09);
  --inverse: #0a120e;
  --on-inverse: #ffffff;
  --danger: #c2332b;
  --danger-soft: rgba(194, 51, 43, 0.08);
  --warning: #8f5f00;
  --warning-soft: rgba(196, 140, 20, 0.12);
  --info: #2c57c7;
  --info-soft: rgba(44, 87, 199, 0.08);
  --chart-in: #0e844d;
  --chart-out: #5b6cd9;
  --chart-grid: #e6ece8;
  --scrim: rgba(10, 18, 14, 0.5);
  --shadow-1: 0 1px 2px rgba(10, 18, 14, 0.06);
  --shadow-2: 0 24px 60px -28px rgba(10, 18, 14, 0.28);
  --focus: #0a6b3e;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-family: var(--font-display); font-weight: 500; letter-spacing: -0.025em; line-height: 1.08; text-wrap: balance; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
table { border-collapse: collapse; width: 100%; }
dialog { color: inherit; }
::selection { background: var(--accent); color: var(--on-accent); }
[hidden] { display: none !important; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 6px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* ---------- Utilities ---------- */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 16px; top: -60px; z-index: 1000; background: var(--inverse); color: var(--on-inverse); padding: 10px 16px; border-radius: var(--pill); font-weight: 600; text-decoration: none; transition: top var(--dur-2) var(--ease-out); }
.skip-link:focus { top: 16px; }
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.mono { font-family: var(--font-mono); font-size: 0.92em; letter-spacing: 0; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.accent { color: var(--accent-ink); }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; }
.stack > * + * { margin-top: var(--stack, 12px); }
.row { display: flex; align-items: center; gap: 12px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.spacer { flex: 1; }

/* ---------- Icons ---------- */
.i { display: inline-block; vertical-align: -0.22em; width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 16px; height: 16px; }
.i-lg { width: 24px; height: 24px; }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand__logo { height: 34px; width: auto; }
.brand__mark { height: 30px; width: auto; }
.logo-light, [data-theme="light"] .logo-dark { display: none; }
[data-theme="light"] .logo-light { display: block; }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: transparent;
  --btn-fg: var(--text);
  --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px;
  border: 1px solid var(--btn-bd); border-radius: var(--pill);
  background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 500; font-size: 0.95rem; line-height: 1.2; letter-spacing: -0.005em;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  touch-action: manipulation; user-select: none;
  transition: background-color var(--dur-1) ease, border-color var(--dur-1) ease, color var(--dur-1) ease, transform var(--dur-1) ease, opacity var(--dur-1) ease;
}
.btn:hover { --btn-bd: var(--text-2); background: color-mix(in srgb, var(--btn-bg) 92%, var(--text) 8%); }
.btn:active { transform: scale(0.98); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn--primary { --btn-bg: var(--accent); --btn-fg: var(--on-accent); --btn-bd: var(--accent); font-weight: 600; }
.btn--primary:hover { --btn-bd: var(--accent-hover); background: var(--accent-hover); }
.btn--inverse { --btn-bg: var(--inverse); --btn-fg: var(--on-inverse); --btn-bd: var(--inverse); font-weight: 600; }
.btn--inverse:hover { --btn-bd: var(--inverse); background: color-mix(in srgb, var(--inverse) 86%, var(--bg)); }
.btn--ghost { --btn-bd: transparent; }
.btn--ghost:hover { --btn-bd: transparent; background: var(--surface-2); }
.btn--danger { --btn-bg: transparent; --btn-fg: var(--danger); --btn-bd: color-mix(in srgb, var(--danger) 50%, transparent); }
.btn--danger:hover { --btn-bd: var(--danger); background: var(--danger-soft); }
.btn--danger-solid { --btn-bg: var(--danger); --btn-fg: #fff; --btn-bd: var(--danger); font-weight: 600; }
:root:not([data-theme="light"]) .btn--danger-solid { --btn-fg: #2a0505; }
.btn--sm { min-height: 36px; padding: 6px 14px; font-size: 0.875rem; }
.btn--lg { min-height: 52px; padding: 14px 28px; font-size: 1.02rem; }
.btn--block { width: 100%; }
.btn--icon { width: 44px; padding: 0; }
.btn--icon.btn--sm { width: 36px; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--btn-fg); border-right-color: transparent; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.link { color: var(--accent-ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.link:hover { text-decoration-thickness: 2px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; font-weight: 500; cursor: pointer; min-height: 24px; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > label, .label { font-size: 0.875rem; font-weight: 500; color: var(--text); }
.req { color: var(--danger); margin-left: 2px; }
.hint { font-size: 0.82rem; color: var(--text-3); line-height: 1.45; }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 12px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 12px;
  font-size: 1rem; line-height: 1.3;
  transition: border-color var(--dur-1) ease, box-shadow var(--dur-1) ease;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); border-radius: 12px; }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.input[readonly] { background: var(--surface-2); border-style: dashed; }
.textarea { min-height: 96px; resize: vertical; }
.select { height: 48px; padding-top: 0; padding-bottom: 0; appearance: none; padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat; }
.input--amount { font-size: 1.6rem; font-family: var(--font-display); font-weight: 500; letter-spacing: -0.02em; min-height: 64px; }
.input-group { position: relative; display: flex; }
.input-group .input { padding-right: 52px; }
.input-group__btn { position: absolute; right: 2px; top: 2px; bottom: 2px; width: 44px; display: grid; place-items: center; background: transparent; border: 0; color: var(--text-2); border-radius: 10px; }
.input-group__btn:hover { color: var(--text); background: var(--surface-2); }
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-2); font-family: var(--font-display); font-size: 1.4rem; pointer-events: none; }
.input-prefix .input { padding-left: 46px; }
.field-error { display: flex; gap: 6px; align-items: flex-start; font-size: 0.85rem; color: var(--danger); font-weight: 500; }
.field-error .i { width: 16px; height: 16px; margin-top: 2px; }
.fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.fieldset > legend { padding: 0; margin-bottom: 14px; font-family: var(--font-display); font-weight: 500; font-size: 1.15rem; letter-spacing: -0.015em; }
.form-grid { display: grid; gap: 18px 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid > .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }

.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-size: 0.95rem; line-height: 1.45; min-height: 24px; }
.check input { flex: none; appearance: none; width: 22px; height: 22px; margin: 1px 0 0; border: 1.5px solid var(--border-strong); border-radius: 6px; background: var(--surface); display: grid; place-items: center; cursor: pointer; transition: background var(--dur-1), border-color var(--dur-1); }
.check input[type="radio"] { border-radius: 50%; }
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { content: ""; width: 11px; height: 6px; border: 2px solid var(--on-accent); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.check input[type="radio"]:checked::after { width: 8px; height: 8px; border: 0; border-radius: 50%; background: var(--on-accent); transform: none; }
.check input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.check input[aria-invalid="true"] { border-color: var(--danger); }

.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; min-height: 44px; }
.switch input { appearance: none; position: relative; width: 46px; height: 28px; border-radius: var(--pill); background: var(--surface-3); border: 1px solid var(--border-strong); cursor: pointer; transition: background var(--dur-2) var(--ease-out); flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--text-2); transition: transform var(--dur-2) var(--ease-out), background var(--dur-2); }
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(18px); background: var(--on-accent); }

/* Choice cards (radio as large tiles) */
.choices { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.choice { position: relative; display: grid; gap: 4px; padding: 16px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); cursor: pointer; transition: border-color var(--dur-1), background var(--dur-1); }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice:hover { border-color: var(--text-3); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.choice:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.choice__title { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.choice__desc { font-size: 0.85rem; color: var(--text-2); }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: clamp(18px, 2.4vw, 28px); }
.card--flat { background: var(--surface-2); border-color: transparent; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.card__title { font-family: var(--font-display); font-size: 1.15rem; font-weight: 500; letter-spacing: -0.015em; }
.divider { height: 1px; background: var(--border); border: 0; margin: 18px 0; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: var(--pill); font-size: 0.78rem; font-weight: 600; line-height: 1.5; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge--plain::before { display: none; }
.badge--plain { padding-inline: 10px; }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--neutral { background: var(--surface-3); color: var(--text-2); }

/* ---------- Alerts / banners ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); font-size: 0.93rem; line-height: 1.5; }
.alert > .i { margin-top: 2px; }
.alert strong { font-weight: 600; }
.alert--info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.alert--info > .i { color: var(--info); }
.alert--warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.alert--warning > .i { color: var(--warning); }
.alert--danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.alert--danger > .i { color: var(--danger); }
.alert--success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.alert--success > .i { color: var(--success); }
.error-summary { padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--danger); background: var(--danger-soft); }
.error-summary h2 { font-size: 1rem; font-family: var(--font-body); font-weight: 600; letter-spacing: 0; margin-bottom: 6px; }
.error-summary ul { padding-left: 18px; display: grid; gap: 4px; }
.error-summary a { color: var(--danger); font-weight: 500; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table { font-size: 0.92rem; }
.table th { text-align: left; font-weight: 500; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--dur-1); }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr.is-clickable:hover { background: var(--surface-2); }
.table .t-right { text-align: right; }
.table .t-strong { font-weight: 500; color: var(--text); }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 500; }
.amount--in { color: var(--accent-ink); }
.amount--pending { color: var(--text-3); }

/* ---------- Dialogs ---------- */
.dialog { padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); box-shadow: var(--shadow-2); overflow: hidden; }
.dialog--wide { width: min(880px, calc(100vw - 32px)); }
.dialog::backdrop { background: var(--scrim); backdrop-filter: blur(4px); }
.dialog[open] { animation: dialog-in var(--dur-2) var(--ease-out); display: flex; flex-direction: column; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
.dialog__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 0; }
.dialog__title { font-size: 1.35rem; }
.dialog__body { padding: 18px 24px 24px; overflow-y: auto; }
.dialog__foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding: 16px 24px; border-top: 1px solid var(--border); background: var(--surface); }

/* Drawer (right sheet) */
.drawer { margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(560px, 100vw); border-radius: 0; border: 0; border-left: 1px solid var(--border); padding: 0; background: var(--surface); }
.drawer[open] { animation: drawer-in var(--dur-3) var(--ease-out); display: flex; flex-direction: column; }
.drawer::backdrop { background: var(--scrim); }
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } }
.drawer--xl { width: min(980px, 100vw); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: var(--z-toast); left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 10px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); background: var(--inverse); color: var(--on-inverse); box-shadow: var(--shadow-2); font-size: 0.93rem; animation: toast-in var(--dur-2) var(--ease-out); }
.toast.is-leaving { animation: toast-out 160ms var(--ease-in) forwards; }
.toast .i { margin-top: 1px; }
.toast--success .i { color: #1fa864; }
.toast--error .i { color: #e5484d; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------- Skeleton ---------- */
.skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s ease-in-out infinite; min-height: 16px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Empty state ---------- */
.empty { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 40px 20px; color: var(--text-2); }
.empty .i { width: 32px; height: 32px; color: var(--text-3); }
.empty h3 { font-size: 1.1rem; color: var(--text); }

/* ---------- Help widget (consistent position on every page) ---------- */
.help-fab { position: fixed; right: 20px; bottom: 20px; z-index: calc(var(--z-header) + 1); display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 10px 18px 10px 14px; border-radius: var(--pill); border: 1px solid var(--border-strong); background: var(--inverse); color: var(--on-inverse); font-weight: 600; box-shadow: var(--shadow-2); transition: transform var(--dur-1) ease; }
.help-fab:hover { transform: translateY(-1px); }
.help-panel { position: fixed; right: 20px; bottom: 80px; z-index: var(--z-modal); width: min(360px, calc(100vw - 40px)); padding: 20px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-2); animation: dialog-in var(--dur-2) var(--ease-out); }
.help-panel h2 { font-size: 1.2rem; margin-bottom: 4px; }
.help-panel ul { list-style: none; display: grid; gap: 8px; margin-top: 14px; }
.help-panel a, .help-panel button.help-item { display: flex; gap: 12px; align-items: center; width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 0; text-align: left; text-decoration: none; font-size: 0.93rem; }
.help-panel a:hover, .help-panel button.help-item:hover { background: var(--surface-3); }
.help-panel .help-item small { display: block; color: var(--text-2); font-size: 0.8rem; }
.help-panel .help-urgent { background: var(--danger-soft); }
.help-panel .help-urgent .i { color: var(--danger); }

/* ---------- Theme toggle ---------- */
.theme-toggle { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: var(--text); }
.theme-toggle .i { width: 28px; height: 28px; stroke-width: 1.5; transition: transform var(--dur-3) var(--ease-out); }
.theme-toggle:hover { background: var(--surface-2); }
[data-theme="light"] .theme-toggle .i { transform: rotate(180deg); }

/* ---------- Phones and tablets (iOS Safari, Android Chrome) ---------- */
/* With viewport-fit=cover the page runs under the notch, rounded corners and home indicator:
   fixed controls and content keep clear of them. */
.container { padding-left: max(var(--gutter), env(safe-area-inset-left)); padding-right: max(var(--gutter), env(safe-area-inset-right)); }
.help-fab { right: calc(20px + env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom)); }
.help-panel { right: calc(20px + env(safe-area-inset-right)); bottom: calc(80px + env(safe-area-inset-bottom)); max-height: calc(100dvh - 120px - env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }
.toasts { bottom: calc(24px + env(safe-area-inset-bottom)); }
/* Our own pressed states replace the grey tap flash. */
.btn, .pill, .help-fab, .choice, .acct-tile, .feed__item, .thread-link, .bottom-nav a, .segmented button, .segmented a, .theme-toggle { -webkit-tap-highlight-color: transparent; }
.help-fab:active { transform: scale(0.96); }
/* iOS centres the value of date fields and collapses them when empty. */
input[type="date"].input { -webkit-appearance: none; appearance: none; min-height: 48px; text-align: left; }
input[type="date"].input::-webkit-date-and-time-value { text-align: left; }
/* Hover effects would stay "stuck" after a tap on touch screens. */
@media (hover: none) { .help-fab:hover { transform: none; } }
@media (max-width: 640px) {
  .help-fab { width: 52px; height: 52px; min-height: 52px; padding: 0; justify-content: center; border-radius: 50%; right: calc(14px + env(safe-area-inset-right)); bottom: calc(14px + env(safe-area-inset-bottom)); }
  .help-fab .i { width: 22px; height: 22px; }
  .help-fab__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .help-panel { left: calc(12px + env(safe-area-inset-left)); right: calc(12px + env(safe-area-inset-right)); width: auto; bottom: calc(76px + env(safe-area-inset-bottom)); }
  /* Dialogs open as bottom sheets with full-width buttons within thumb reach. */
  .dialog, .dialog--wide { width: 100%; max-width: none; margin: auto 0 0; border-radius: 22px 22px 0 0; border-bottom: 0; max-height: calc(100dvh - 24px - env(safe-area-inset-top)); }
  .dialog[open] { animation: sheet-in var(--dur-3) var(--ease-out); }
  .dialog__head { padding: 18px 18px 0; }
  .dialog__body { padding: 14px 18px 18px; overscroll-behavior: contain; }
  .dialog__foot { flex-direction: column-reverse; align-items: stretch; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); }
  .dialog__foot > .btn { width: 100%; justify-content: center; }
  .drawer { padding-bottom: env(safe-area-inset-bottom); }
  .choices { grid-template-columns: minmax(0, 1fr); }
}
@keyframes sheet-in { from { transform: translateY(48px); opacity: 0; } }

/* ---------- Print ---------- */
@media print {
  .no-print, .help-fab, .help-panel, .toasts { display: none !important; }
  html, body { background: #fff !important; color: #000; }
}
