/* BRANDAO.US design system. All themes are the variable blocks below; no component hard-codes a theme color. */


:root {
  --font-ui: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-read: "Newsreader", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --radius: 14px; --radius-sm: 9px; --radius-xs: 6px;
  --sidebar-w: 224px; --sidebar-w-collapsed: 66px; --topbar-h: 60px;
  --gap: 18px; --card-pad: 18px;
  --reading-w: 1040px;
  --ease: cubic-bezier(.2,.7,.2,1);
}
html[data-density="compact"] { --gap: 10px; --card-pad: 12px; }
html[data-reading="narrow"] { --reading-w: 780px; }
html[data-reading="wide"] { --reading-w: 1320px; }

html[data-font="small"] { font-size: 14px; }
html[data-font="medium"] { font-size: 15.5px; }
html[data-font="large"] { font-size: 17.5px; }
html[data-font="xlarge"] { font-size: 19.5px; }

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f1f2f4; --surface: #ffffff; --surface-2: #f6f7f9; --surface-3: #eaecef; --border: #dee1e6; --border-strong: #c7cbd3;
  --text: #1d2026; --text-2: #4d525c; --muted: #676c77;
  --accent: #2f55d4; --accent-hover: #2546b4; --accent-soft: #e8edfd; --on-accent: #ffffff;
  --positive: #0d7a4d; --positive-soft: #dff3e9; --negative: #c02f33; --negative-soft: #fbe7e6; --warn: #985f00; --warn-soft: #fbf0d8; --on-negative: #ffffff;
  --shadow: 0 1px 2px rgba(29,32,38,.05), 0 6px 22px -14px rgba(29,32,38,.28); --shadow-lg: 0 18px 60px -14px rgba(29,32,38,.34);
  --ocean: #d9e2ec; --land: #f4f5f7; --land-stroke: #b3b8c1; --night: rgba(22,28,58,.46);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111317; --surface: #1a1d23; --surface-2: #20242b; --surface-3: #292e37; --border: #2c313a; --border-strong: #3e4551;
  --text: #eceef2; --text-2: #bdc2cc; --muted: #969cab;
  --accent: #7c9bff; --accent-hover: #98b1ff; --accent-soft: #232c49; --on-accent: #0e1324;
  --positive: #45c98d; --positive-soft: #15301f; --negative: #f47a78; --negative-soft: #3a1c1d; --warn: #e3b252; --warn-soft: #362a12; --on-negative: #1a1014;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -16px rgba(0,0,0,.7); --shadow-lg: 0 18px 60px -14px rgba(0,0,0,.8);
  --ocean: #182028; --land: #333a44; --land-stroke: #4d5562; --night: rgba(0,0,10,.55);
}
html[data-theme="dracula"] {
  color-scheme: dark;
  --bg: #1e1f29; --surface: #282a36; --surface-2: #313442; --surface-3: #3b3e4f; --border: #3b3e4f; --border-strong: #565a70;
  --text: #f8f8f2; --text-2: #d6d6e2; --muted: #aab0cf;
  --accent: #bd93f9; --accent-hover: #ccabfb; --accent-soft: #3a3257; --on-accent: #1e1f29;
  --positive: #50fa7b; --positive-soft: #24402f; --negative: #ff7a7a; --negative-soft: #4a2a33; --warn: #f1fa8c; --warn-soft: #43452e; --on-negative: #1a1014;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -16px rgba(0,0,0,.7); --shadow-lg: 0 18px 60px -14px rgba(0,0,0,.8);
  --ocean: #21222c; --land: #44475a; --land-stroke: #6272a4; --night: rgba(5,5,20,.55);
}
html[data-theme="catppuccin-latte"] {
  color-scheme: light;
  --bg: #e6e9ef; --surface: #eff1f5; --surface-2: #e9ecf2; --surface-3: #dce0e8; --border: #ccd0da; --border-strong: #bcc0cc;
  --text: #3a3d55; --text-2: #4c4f69; --muted: #5c5f77;
  --accent: #7428df; --accent-hover: #6020bd; --accent-soft: #e4dcf6; --on-accent: #ffffff;
  --positive: #2d7a1e; --positive-soft: #e4f1e1; --negative: #bf0d33; --negative-soft: #f4dbe0; --warn: #975a07; --warn-soft: #f6ecdc; --on-negative: #ffffff;
  --shadow: 0 1px 2px rgba(76,79,105,.06), 0 6px 22px -14px rgba(76,79,105,.3); --shadow-lg: 0 18px 60px -14px rgba(76,79,105,.36);
  --ocean: #d6deee; --land: #f2f3f7; --land-stroke: #acb0be; --night: rgba(30,30,60,.42);
}
html[data-theme="catppuccin-mocha"] {
  color-scheme: dark;
  --bg: #181825; --surface: #1e1e2e; --surface-2: #252536; --surface-3: #313244; --border: #313244; --border-strong: #45475a;
  --text: #cdd6f4; --text-2: #bac2de; --muted: #a6adc8;
  --accent: #cba6f7; --accent-hover: #d8bcf9; --accent-soft: #3a3150; --on-accent: #1e1e2e;
  --positive: #a6e3a1; --positive-soft: #26372f; --negative: #f38ba8; --negative-soft: #3f2838; --warn: #f9e2af; --warn-soft: #3b3530; --on-negative: #1e1e2e;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -16px rgba(0,0,0,.7); --shadow-lg: 0 18px 60px -14px rgba(0,0,0,.8);
  --ocean: #11111b; --land: #313244; --land-stroke: #585b70; --night: rgba(5,5,15,.55);
}
html[data-theme="tokyo-night"] {
  color-scheme: dark;
  --bg: #16161e; --surface: #1a1b26; --surface-2: #1f2335; --surface-3: #292e42; --border: #292e42; --border-strong: #414868;
  --text: #c0caf5; --text-2: #a9b1d6; --muted: #9099c0;
  --accent: #7aa2f7; --accent-hover: #94b4f9; --accent-soft: #283457; --on-accent: #16161e;
  --positive: #9ece6a; --positive-soft: #26332a; --negative: #f7768e; --negative-soft: #3c2232; --warn: #e0af68; --warn-soft: #3a3024; --on-negative: #16161e;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -16px rgba(0,0,0,.7); --shadow-lg: 0 18px 60px -14px rgba(0,0,0,.8);
  --ocean: #13131a; --land: #292e42; --land-stroke: #414868; --night: rgba(0,0,12,.55);
}
html[data-theme="dimmed-monokai"] {
  color-scheme: dark;
  --bg: #1b1b1b; --surface: #232323; --surface-2: #2a2a2a; --surface-3: #333333; --border: #363636; --border-strong: #4b4b4b;
  --text: #d4d6d4; --text-2: #b6b9b7; --muted: #959896;
  --accent: #e58a2e; --accent-hover: #f09f4c; --accent-soft: #3b2d1f; --on-accent: #1b1b1b;
  --positive: #a3b33f; --positive-soft: #2c3220; --negative: #e2766b; --negative-soft: #3d2523; --warn: #d9bd7e; --warn-soft: #3a3324; --on-negative: #1b1b1b;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -16px rgba(0,0,0,.7); --shadow-lg: 0 18px 60px -14px rgba(0,0,0,.8);
  --ocean: #161616; --land: #333333; --land-stroke: #505050; --night: rgba(0,0,0,.55);
}
html[data-theme="iceberg-light"] {
  color-scheme: light;
  --bg: #dcdfe7; --surface: #e8e9ec; --surface-2: #e2e4ea; --surface-3: #d4d7e0; --border: #cad0de; --border-strong: #a7adbd;
  --text: #33374c; --text-2: #474c63; --muted: #5a5f75;
  --accent: #2d539e; --accent-hover: #22437f; --accent-soft: #d3dbec; --on-accent: #ffffff;
  --positive: #45662a; --positive-soft: #d8e2cf; --negative: #a9335a; --negative-soft: #ecd5de; --warn: #8d4e1a; --warn-soft: #ecdccd; --on-negative: #ffffff;
  --shadow: 0 1px 2px rgba(51,55,76,.06), 0 6px 22px -14px rgba(51,55,76,.3); --shadow-lg: 0 18px 60px -14px rgba(51,55,76,.36);
  --ocean: #cdd5e3; --land: #eceef1; --land-stroke: #a2a8b8; --night: rgba(25,30,55,.42);
}
html[data-theme="pacific-mist"] {
  color-scheme: light;
  --bg: #e2eaee; --surface: #f5f8f9; --surface-2: #edf2f4; --surface-3: #dce5e9; --border: #d0dbe0; --border-strong: #b0bfc6;
  --text: #1c2b33; --text-2: #3c4f59; --muted: #576a74;
  --accent: #1d6c87; --accent-hover: #17576e; --accent-soft: #d6e8ef; --on-accent: #ffffff;
  --positive: #1d7656; --positive-soft: #d9efe6; --negative: #b5384a; --negative-soft: #f5dfe2; --warn: #8a6000; --warn-soft: #f1e8d0; --on-negative: #ffffff;
  --shadow: 0 1px 2px rgba(28,43,51,.06), 0 6px 22px -14px rgba(28,43,51,.3); --shadow-lg: 0 18px 60px -14px rgba(28,43,51,.36);
  --ocean: #cddfe7; --land: #f3f6f7; --land-stroke: #a7b6bd; --night: rgba(15,35,50,.42);
}
html[data-theme="morning-mist"] {
  color-scheme: light;
  --bg: #eeecf1; --surface: #fcfbfd; --surface-2: #f6f4f8; --surface-3: #e9e6ed; --border: #e0dce5; --border-strong: #c7c1ce;
  --text: #26222e; --text-2: #4f4859; --muted: #696273;
  --accent: #a2446a; --accent-hover: #863855; --accent-soft: #f5e3ea; --on-accent: #ffffff;
  --positive: #2b774c; --positive-soft: #e0f0e6; --negative: #b5353a; --negative-soft: #f8e1e1; --warn: #965f00; --warn-soft: #f6ecd6; --on-negative: #ffffff;
  --shadow: 0 1px 2px rgba(38,34,46,.05), 0 6px 22px -14px rgba(38,34,46,.28); --shadow-lg: 0 18px 60px -14px rgba(38,34,46,.34);
  --ocean: #dcdde9; --land: #f6f4f8; --land-stroke: #b8b1c1; --night: rgba(35,25,50,.42);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font-ui); line-height: 1.5; -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss03"; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.012em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
img { max-width: 100%; display: block; }
code { font-family: var(--font-mono); font-size: .9em; background: var(--surface-3); padding: .1em .35em; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
kbd { font-family: var(--font-ui); font-size: .72rem; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 5px; padding: 1px 6px; background: var(--surface); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.icon { width: 1.15em; height: 1.15em; flex: none; display: inline-block; vertical-align: -.2em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.xs { font-size: .76rem; }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; border-radius: var(--radius-xs); }
.skip-link:focus { left: 8px; }
.noscript { padding: 40px; text-align: center; }
[hidden] { display: none !important; }

/* Shell */
body:not(.auth-page) { display: flex; }
.sidebar { position: sticky; top: 0; align-self: flex-start; height: 100vh; width: var(--sidebar-w); flex: none; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 14px 10px; transition: width .2s var(--ease); z-index: 30; overflow: hidden; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-weight: 750; letter-spacing: .02em; white-space: nowrap; }
.brand:hover { color: inherit; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 9px; background: var(--accent); color: var(--on-accent); font-family: var(--font-read); font-size: 1.15rem; font-weight: 700; }
.brand-text em { font-style: normal; color: var(--accent); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar nav a, .sidebar-toggle { display: flex; align-items: center; gap: 12px; padding: 9px 11px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; white-space: nowrap; width: 100%; transition: background .12s, color .12s; }
.sidebar nav a:hover, .sidebar-toggle:hover { background: var(--surface-3); color: var(--text); }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar .icon { width: 1.25em; height: 1.25em; }
.nav-lock { margin-left: auto; opacity: .55; display: inline-flex; } .nav-lock .icon { width: .85em; height: .85em; }
.sidebar-toggle { margin-top: 6px; color: var(--muted); }
/* Money badge: a daily move limit is exceeded */
.nav-alert { margin-left: auto; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--negative); color: #fff; font-size: 11px; line-height: 19px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; animation: alert-blink 1.1s ease-in-out infinite; }
@keyframes alert-blink { 0%, 100% { opacity: 1; box-shadow: 0 0 0 0 color-mix(in srgb, var(--negative) 55%, transparent); } 50% { opacity: .35; box-shadow: 0 0 0 5px transparent; } }
.sidebar nav a, .bottom-nav a { position: relative; }
html[data-sidebar="collapsed"] .sidebar .nav-alert { position: absolute; top: 3px; right: 4px; min-width: 15px; height: 15px; line-height: 15px; font-size: 9px; padding: 0 3px; }
.bottom-nav .nav-alert { position: absolute; top: 3px; left: calc(50% + 6px); margin: 0; min-width: 15px; height: 15px; line-height: 15px; font-size: 9px; padding: 0 3px; }
.quote-tile.quote-alert { box-shadow: inset 0 0 0 2px var(--negative); }
.move-alert { display: flex; align-items: center; gap: 5px; font-size: .78rem; font-weight: 600; color: var(--negative); margin-top: 4px; }
.move-alert .icon { width: 13px; height: 13px; }
.field-row.threshold-row { grid-template-columns: minmax(140px, 1.6fr) repeat(3, minmax(70px, 1fr)) auto; }
@media (max-width: 640px) { .field-row.threshold-row { grid-template-columns: 1fr 1fr; } }
html[data-sidebar="collapsed"] .sidebar { width: var(--sidebar-w-collapsed); }
html[data-sidebar="collapsed"] .nav-label, html[data-sidebar="collapsed"] .sidebar .brand-text, html[data-sidebar="collapsed"] .nav-lock { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center; gap: 14px; padding: 0 22px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.brand-compact { display: none; padding: 0; }
.clock { font-variant-numeric: tabular-nums; font-size: .9rem; color: var(--text-2); white-space: nowrap; }
.clock b { font-weight: 650; color: var(--text); }
.search-trigger { margin-left: auto; display: flex; align-items: center; gap: 9px; height: 38px; padding: 0 10px 0 12px; min-width: 240px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; color: var(--muted); font-size: .9rem; }
.search-trigger:hover { border-color: var(--border-strong); }
.search-trigger span { flex: 1; text-align: left; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
#search-btn-small { display: none; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: var(--text-2); flex: none; transition: background .12s, color .12s; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:disabled { opacity: .45; cursor: default; }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 8px; font-size: .9rem; }
.icon-btn.on { color: var(--accent); background: var(--accent-soft); }
.menu-btn { display: none; }
.badge { position: absolute; top: 3px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--negative); color: #fff; font-size: 10px; line-height: 17px; font-weight: 700; text-align: center; }
.menu-wrap { position: relative; }
.popover { position: absolute; right: 0; top: calc(100% + 8px); width: 340px; max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px; z-index: 40; }
.popover-menu { width: 220px; }
.popover-title { padding: 6px 8px 8px; font-weight: 650; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; text-align: left; font-size: .93rem; }
.menu-item:hover { background: var(--surface-3); color: var(--text); }
.menu-item.active { color: var(--accent); font-weight: 600; }
.notif-item { padding: 9px 10px; border-radius: 8px; display: block; }
.notif-item:hover { background: var(--surface-3); color: inherit; }
.notif-item.unread { background: var(--accent-soft); }
.theme-swatch { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; }
#page { padding: 22px 24px 48px; flex: 1; outline: none; width: 100%; max-width: 1720px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 1.55rem; }
.page-head .sub { color: var(--muted); font-size: .88rem; }
.page-head .spacer { flex: 1; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bottom-nav { display: none; }
.drawer-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.42); z-index: 25; }

/* Primitives */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 13px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); font-size: .9rem; font-weight: 550; white-space: nowrap; transition: background .12s, border-color .12s, transform .06s; }
.btn:hover { background: var(--surface-3); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-danger { color: var(--negative); border-color: color-mix(in srgb, var(--negative) 45%, var(--border)); }
.btn-danger:hover { background: var(--negative-soft); color: var(--negative); }
.btn-solid-danger { background: var(--negative); border-color: var(--negative); color: var(--on-negative); }
.btn-solid-danger:hover { filter: brightness(1.08); background: var(--negative); color: inherit; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: .84rem; border-radius: 8px; }
.btn-block { width: 100%; }
.spin .icon, .icon.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.field > span, .field-label { font-size: .84rem; font-weight: 550; color: var(--text-2); }
.input, .field input:not([type=checkbox]):not([type=radio]):not([type=color]), .field select, .field textarea, .select { width: 100%; height: 38px; padding: 0 11px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); transition: border-color .12s, box-shadow .12s; }
.field textarea { height: auto; min-height: 88px; padding: 9px 11px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus, .select:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); }
.check { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; font-size: .92rem; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.hint { font-size: .8rem; color: var(--muted); margin: -6px 0 12px; }
.field .hint { margin: 0; }
.form-error { background: var(--negative-soft); color: var(--negative); font-size: .88rem; padding: 8px 11px; border-radius: 8px; margin-bottom: 12px; }
.field-error { color: var(--negative); font-size: .8rem; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; line-height: 1.6; }
.tag-live { background: var(--positive-soft); color: var(--positive); }
.tag-delayed { background: var(--accent-soft); color: var(--accent); }
.tag-closed { background: var(--surface-3); color: var(--text-2); }
.tag-stale { background: var(--warn-soft); color: var(--warn); }
.tag-unavailable { background: var(--surface-3); color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot-green { background: #22a565; } .dot-yellow { background: #e0a31a; } .dot-red { background: #d9443f; } .dot-gray { background: #9298a4; }
.banner { display: flex; gap: 11px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--text); font-size: .9rem; margin-bottom: 16px; }
.banner .icon { color: var(--warn); margin-top: 2px; }
.banner-info { background: var(--accent-soft); } .banner-info .icon { color: var(--accent); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty .icon { width: 30px; height: 30px; margin-bottom: 8px; opacity: .6; }
.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.page-loading { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--gap); }
.page-loading .skeleton { height: 180px; border-radius: var(--radius); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: var(--card-pad); }
.grid-stack-item-content.card { display: flex; flex-direction: column; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 9px; padding: 11px var(--card-pad); border-bottom: 1px solid var(--border); flex: none; min-height: 46px; }
.card-head h2, .card-head h3 { font-size: .95rem; font-weight: 650; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-head .icon-lead { color: var(--accent); }
.draggable .card-head { cursor: grab; }
.draggable .card-head:active { cursor: grabbing; }
.card-body { padding: 12px var(--card-pad); flex: 1; min-height: 0; overflow: auto; }
.card-foot { padding: 7px var(--card-pad); border-top: 1px solid var(--border); font-size: .78rem; color: var(--muted); flex: none; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-link { color: var(--accent); font-weight: 550; font-size: .84rem; white-space: nowrap; }
.grid-stack { margin: calc(var(--gap) / -2); }
.grid-stack > .grid-stack-item > .grid-stack-item-content { top: calc(var(--gap) / 2) !important; right: calc(var(--gap) / 2) !important; bottom: calc(var(--gap) / 2) !important; left: calc(var(--gap) / 2) !important; width: auto !important; height: auto !important; }
.grid-stack-placeholder > .placeholder-content { background: var(--accent-soft) !important; border: 2px dashed var(--accent) !important; border-radius: var(--radius); inset: calc(var(--gap) / 2) !important; }
.ui-draggable-dragging > .card { box-shadow: var(--shadow-lg); }

/* Story rows */
.story-row { display: grid; grid-template-columns: 72px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.story-row:last-child { border-bottom: 0; }
.story-row:first-child { padding-top: 0; }
.thumb { width: 72px; height: 54px; border-radius: 8px; object-fit: cover; background: var(--surface-3); display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.thumb .icon { opacity: .55; }
.story-title { font-weight: 600; font-size: .94rem; line-height: 1.32; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.story-meta { font-size: .76rem; color: var(--muted); margin-top: 3px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.story-excerpt { font-size: .83rem; color: var(--text-2); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.story-actions { margin-left: auto; margin-block: -4px; display: inline-flex; gap: 2px; }
.story-actions .icon-btn { color: var(--muted); }
.story-actions .story-like.on-up { color: var(--positive); }
.story-actions .story-read-more { height: 26px; padding: 0 9px; gap: 5px; font-size: .76rem; color: var(--text-2); }
.story-actions .story-read-more:hover { color: var(--accent); border-color: var(--accent); }
.story-actions .story-dismiss:hover { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
/* Alert key phrases */
.story-row.story-alert { background: var(--warn-soft); box-shadow: inset 3px 0 0 var(--warn); border-radius: var(--radius-xs); padding: 9px 8px 9px 11px; border-bottom-color: transparent; margin-bottom: 4px; }
mark.phrase { background: color-mix(in srgb, var(--warn) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.alert-tags { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; color: var(--warn); }
.alert-tags .icon { width: 13px; height: 13px; }
.tag-alert { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 35%, transparent); }
.alert-stories { margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.alert-head { display: flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--warn); margin-bottom: 7px; }
.alert-head .icon { width: 14px; height: 14px; }
.alert-head .card-link { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 550; }
.notif-item.alert { box-shadow: inset 3px 0 0 var(--warn); }
.notif-kind { display: flex; align-items: center; gap: 4px; color: var(--warn); font-weight: 650; margin-bottom: 1px; }
.notif-kind .icon { width: 12px; height: 12px; }
.phrase-list { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 10px; }
.phrase-row { display: flex; align-items: center; gap: 8px; }
.phrase-row > .icon { color: var(--warn); flex: none; }
.phrase-row .input { flex: 1; height: 34px; }
.phrase-add { display: flex; gap: 8px; }
.phrase-add .input { flex: 1; }
#phrase-hint { margin-top: 8px; }

.accent-bar { width: 4px; align-self: stretch; border-radius: 3px; flex: none; margin-block: 3px; }
.state-note { display: inline-flex; align-items: center; gap: 5px; }

/* Mini cards */
.quote-card { display: flex; flex-direction: column; justify-content: safe center; min-height: 100%; gap: 8px; }
.quote-card blockquote { margin: 0; font-family: var(--font-read); font-size: 1.22rem; line-height: 1.34; font-weight: 450; }
.quote-card cite { font-style: normal; color: var(--muted); font-size: .84rem; }
.mini-weather-now { display: flex; align-items: center; gap: 12px; }
.mini-weather-now .wx-icon { width: 46px; height: 46px; color: var(--accent); }
.mini-temp { font-size: 2.3rem; font-weight: 680; letter-spacing: -.03em; line-height: 1; }
.mini-forecast { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 12px; text-align: center; font-size: .78rem; }
.mini-forecast .icon { width: 18px; height: 18px; color: var(--text-2); }
.money-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 4px 18px; }
.money-cell { padding: 3px 0; min-width: 0; display: block; }
.money-cell:hover { color: inherit; }
.money-cell .name { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.money-cell .value { font-size: 1.2rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.chg { font-variant-numeric: tabular-nums; font-size: .84rem; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.chg-up { color: var(--positive); } .chg-down { color: var(--negative); } .chg-flat { color: var(--muted); }
.mini-cal-head { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.mini-cal-head b { flex: 1; font-weight: 650; font-size: .92rem; }
.mini-cal { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: .78rem; gap: 1px; font-variant-numeric: tabular-nums; }
.mini-cal .dow { color: var(--muted); font-weight: 600; font-size: .68rem; padding-bottom: 3px; }
.mini-cal .d { position: relative; padding: 4px 0 6px; border-radius: 7px; }
.mini-cal .d.other { color: var(--muted); opacity: .5; }
.mini-cal .d.today { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.mini-cal .d i { position: absolute; bottom: 2px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--dot, var(--accent)); }
.mini-agenda { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 7px; font-size: .8rem; display: grid; gap: 4px; }
.mini-agenda div { display: flex; gap: 7px; align-items: baseline; }
.mini-agenda .date { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; min-width: 44px; }
.mini-agenda .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Reading */
.reading-head { margin-bottom: 12px; }
.interests { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: .82rem; }
.carousel { --slide-h: max(440px, calc(100dvh - var(--topbar-h) - 290px)); position: relative; outline: none; }
.carousel-viewport { overflow: hidden; border-radius: var(--radius); box-shadow: var(--shadow); touch-action: pan-y; user-select: none; }
.carousel-viewport.receiving { animation: stage-receive .9s cubic-bezier(.22,.72,.16,1); }
@keyframes stage-receive { 0% { box-shadow: var(--shadow), 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent); } 45% { box-shadow: var(--shadow), 0 0 0 3px color-mix(in srgb, var(--accent) 55%, transparent), 0 0 46px 6px color-mix(in srgb, var(--accent) 28%, transparent); } 100% { box-shadow: var(--shadow), 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent); } }
.carousel-track { display: flex; height: var(--slide-h); transform: translate3d(calc(var(--i, 0) * -100% + var(--drag, 0px)), 0, 0); transition: transform .62s cubic-bezier(.22,.72,.16,1); will-change: transform; }
.carousel-track.dragging { transition: none; cursor: grabbing; }
.slide { position: relative; flex: 0 0 100%; min-width: 0; height: 100%; overflow: hidden; display: flex; align-items: flex-end; background: color-mix(in srgb, var(--story) 15%, var(--surface)); color: var(--text); transform: scale(.965); opacity: .35; transition: transform .62s cubic-bezier(.22,.72,.16,1), opacity .5s ease; }
.slide.active { transform: none; opacity: 1; }
.slide-backdrop, .slide-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.slide-backdrop { display: none; filter: blur(34px) saturate(1.15); transform: scale(1.15); }
.slide-photo { transform: scale(1.06); transition: transform 7s ease-out; }
.slide.active .slide-photo { transform: none; }
.slide-scrim { position: absolute; inset: 0; display: none; pointer-events: none; background: linear-gradient(to top, rgba(8,10,16,.93) 0%, rgba(8,10,16,.72) 34%, rgba(8,10,16,.12) 68%, rgba(8,10,16,.04) 100%); }
.slide.has-image { color: #fff; background: #12141a; }
.slide.has-image .slide-scrim { display: block; }
/* Images too small to fill the slot sit sharp beside the text, over a blurred copy of themselves. */
.slide.low-res .slide-backdrop { display: block; }
.slide.low-res .slide-photo { z-index: 1; inset: 50% 5% auto auto; width: min(38%, var(--photo-w, 480px)); height: auto; max-height: 78%; object-fit: contain; border-radius: 12px; box-shadow: 0 18px 50px rgba(0,0,0,.45); transform: translateY(-50%) !important; transition: none; }
.slide.low-res .slide-scrim { background: linear-gradient(to right, rgba(8,10,16,.85) 0%, rgba(8,10,16,.6) 55%, rgba(8,10,16,.25) 100%); }
.slide.low-res .slide-text { max-width: 54%; align-self: center; }
.slide-text { position: relative; z-index: 2; width: 100%; max-width: 980px; padding: clamp(20px, 4vw, 52px); display: flex; flex-direction: column; gap: 12px; opacity: 0; transform: translateY(16px); transition: opacity .45s ease .08s, transform .6s cubic-bezier(.22,.72,.16,1) .08s; }
.slide.active .slide-text { opacity: 1; transform: none; }
.slide:not(.has-image) .slide-text { align-self: center; margin-inline: auto; }
.slide-source { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .82rem; font-weight: 550; opacity: .92; }
.slide-source .dot { background: var(--story); }
.slide.has-image .slide-source .tag { background: rgba(255,255,255,.17); color: #fff; }
.slide-title { font-family: var(--font-read); font-weight: 540; font-size: clamp(1.75rem, 3.6vw, 3.25rem); line-height: 1.08; letter-spacing: -.016em; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.slide-excerpt { font-family: var(--font-read); font-size: clamp(1rem, 1.4vw, 1.24rem); line-height: 1.42; max-width: 62ch; opacity: .9; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.slide-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.slide-actions .btn-read { height: 42px; padding: 0 18px; font-size: .96rem; }
.slide.has-image .btn-read { background: #fff; border-color: #fff; color: #12141a; }
.slide.has-image .btn-read:hover { background: #e9ebf0; color: #12141a; }
.slide.has-image .icon-btn { color: #fff; }
.slide.has-image .icon-btn:hover { background: rgba(255,255,255,.18); color: #fff; }
.slide.has-image .vote.on-up { background: #1c9c63; color: #fff; }
.slide.has-image .vote.on-down { background: #cf4340; color: #fff; }
.slide-why { display: inline-flex; gap: 6px; align-items: center; font-size: .78rem; opacity: .85; margin-left: 6px; }
.vote.on-up { color: var(--positive); background: var(--positive-soft); }
.vote.on-down { color: var(--negative); background: var(--negative-soft); }
.carousel-arrow { position: absolute; top: calc(var(--slide-h) / 2); translate: 0 -50%; z-index: 3; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(12,14,20,.52); backdrop-filter: blur(6px); transition: background .15s, opacity .2s; }
.carousel-arrow:hover:not(:disabled) { background: rgba(12,14,20,.8); }
.carousel-arrow:disabled { opacity: 0; pointer-events: none; }
.carousel-arrow.prev { left: 14px; } .carousel-arrow.next { right: 14px; }
.carousel-arrow .icon { width: 22px; height: 22px; }
.carousel-foot { display: flex; align-items: center; gap: 14px; padding: 12px 2px 0; font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.carousel-progress { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.carousel-progress i { display: block; height: 100%; width: 100%; background: var(--accent); border-radius: 2px; transform-origin: left; transition: transform .62s cubic-bezier(.22,.72,.16,1); }

/* Up next feed: rows of 2 and 3 tiles that rise into the carousel as it advances (reading.js drawFeed). */
.feed { margin-top: 22px; --pull: 0; }
.feed-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.feed-head h2 { font-size: .8rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--text-2); }
.feed-count { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.feed-head::after { content: ""; flex: 1; height: 1px; background: linear-gradient(to right, var(--border), transparent); }
.feed-flow { position: relative; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); overflow: hidden; flex: none; }
.feed-flow .icon { position: absolute; left: 4px; width: 14px; height: 14px; animation: feed-flow 1.6s cubic-bezier(.45,.05,.35,1) infinite; }
.feed-flow .icon + .icon { animation-delay: -.8s; }
@keyframes feed-flow { 0% { transform: translateY(14px); opacity: 0; } 30% { opacity: 1; } 75% { opacity: 1; } 100% { transform: translateY(-12px); opacity: 0; } }
.feed-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.feed-tile { position: relative; grid-column: span 2; height: 178px; overflow: hidden; display: flex; align-items: flex-end; text-align: left; padding: 0; border: 0; border-radius: var(--radius-sm); color: var(--text); cursor: pointer; isolation: isolate;
  background: radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--story) 34%, transparent), transparent 70%), color-mix(in srgb, var(--story) 12%, var(--surface));
  box-shadow: var(--shadow); transition: box-shadow .25s ease, translate .35s cubic-bezier(.22,.72,.16,1); }
.feed-tile[data-size="lg"] { grid-column: span 3; height: 222px; }
.feed-tile:hover { box-shadow: var(--shadow-lg); }
.feed-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transform: scale(1.04); transition: opacity .6s ease, transform .9s cubic-bezier(.22,.72,.16,1); z-index: -1; }
.feed-tile.has-image { color: #fff; background: #12141a; }
.feed-tile.has-image .tile-photo { opacity: 1; transform: none; }
.feed-tile.has-image:hover .tile-photo { transform: scale(1.06); }
.tile-scrim { position: absolute; inset: 0; z-index: -1; display: none; background: linear-gradient(to top, rgba(8,10,16,.92) 0%, rgba(8,10,16,.62) 42%, rgba(8,10,16,.05) 100%); }
.feed-tile.has-image .tile-scrim { display: block; }
.tile-shine { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.28) 50%, transparent 65%); transform: translateX(-110%); }
.feed-tile:hover .tile-shine, .feed-tile.arrived .tile-shine { animation: tile-shine .9s ease; }
@keyframes tile-shine { to { transform: translateX(110%); } }
.tile-text { display: flex; flex-direction: column; gap: 6px; padding: 14px 15px; width: 100%; }
.tile-source { display: flex; align-items: center; gap: 6px; font-size: .72rem; font-weight: 550; opacity: .9; min-width: 0; white-space: nowrap; }
.tile-source b { overflow: hidden; text-overflow: ellipsis; }
.tile-source .dot { background: var(--story); flex: none; }
.tile-title { font-family: var(--font-read); font-weight: 540; font-size: 1.04rem; line-height: 1.18; letter-spacing: -.01em; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.feed-tile[data-size="lg"] .tile-title { font-size: 1.22rem; }
/* The next story: labelled, and pulled toward the stage while the carousel is dragged. */
.feed-tile[data-slot="0"] { translate: 0 calc(var(--pull) * -16px); box-shadow: var(--shadow), 0 0 0 calc(var(--pull) * 3px) color-mix(in srgb, var(--accent) 60%, transparent); }
.feed.pulling .feed-tile[data-slot="0"] { transition: none; }
.feed-tile[data-slot="0"]::before { content: "Next"; position: absolute; top: 10px; left: 10px; z-index: 1; padding: 2px 9px; border-radius: 99px; font: 700 .66rem/1.6 var(--font-ui); letter-spacing: .08em; text-transform: uppercase; background: var(--accent); color: var(--on-accent); box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--accent) 70%, transparent); }
.feed-tile.arrived::before { animation: next-pop .5s cubic-bezier(.3,1.6,.5,1) .35s backwards; }
@keyframes next-pop { from { transform: scale(.4); opacity: 0; } }
.feed-ghost { position: fixed; z-index: 30; margin: 0; pointer-events: none; transform-origin: 0 0; will-change: transform, opacity; }
.feed-ghost::before { display: none; }
.feed-end { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; padding: 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); color: var(--muted); font-size: .88rem; }
.feed-end[hidden] { display: none; }
@media (max-width: 1100px) { .feed-tile { height: 168px; } .feed-tile[data-size="lg"] { height: 200px; } }

/* Reading modal: expands from the carousel's rectangle via clip-path. */
.article-modal { position: fixed; inset: 0; z-index: 70; background: var(--bg); overflow-y: auto; overscroll-behavior: contain; clip-path: inset(var(--from, 0) round var(--radius)); transition: clip-path .52s cubic-bezier(.3,.75,.16,1); outline: none; }
.article-modal.open { clip-path: inset(0 round 0); }
.article-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 8px clamp(10px, 2vw, 20px); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.article-bar .where { flex: 1; min-width: 0; font-size: .86rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.reader-size { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 10px; }
.reader-size .icon-btn { width: 34px; height: 32px; border-radius: 9px; }
.size-a { font-family: var(--font-read); font-weight: 600; font-size: 1.22rem; line-height: 1; }
.size-a.small-a { font-size: .9rem; }
.reader-size-label { min-width: 46px; height: 32px; font-size: .78rem; font-variant-numeric: tabular-nums; color: var(--text-2); border-radius: 6px; }
.reader-size-label:hover { background: var(--surface-3); color: var(--text); }
.reader-scroll { display: inline-flex; align-items: center; gap: 9px; }
.reader-scroll .btn { min-width: 112px; }
.reader-scroll .btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.reader-scroll input[type=range] { width: 96px; accent-color: var(--accent); cursor: pointer; }
.reader-voice { display: inline-flex; align-items: center; gap: 6px; }
.reader-listen { min-width: 92px; }
.reader-rate { min-width: 52px; justify-content: center; font-variant-numeric: tabular-nums; }
.reader-listen.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.article-main .speaking { background: var(--accent-soft); box-shadow: 0 0 0 6px var(--accent-soft); border-radius: 4px; transition: background .2s, box-shadow .2s; }
.article-hero { position: relative; height: min(46vh, 480px); background: #12141a; overflow: hidden; }
.article-hero img { width: 100%; height: 100%; object-fit: cover; }
.article-hero img.low-res { object-fit: contain; }
.article-hero .blur { position: absolute; inset: 0; object-fit: cover; filter: blur(34px); transform: scale(1.15); }
.article-hero .sharp { position: relative; }
.article-main { --article-w: 740px; max-width: calc(var(--article-w) + 40px); margin: 0 auto; padding: clamp(22px, 4vw, 44px) 20px 72px; opacity: 0; transform: translateY(14px); transition: opacity .4s ease .2s, transform .5s cubic-bezier(.22,.72,.16,1) .2s; }
.article-modal.open .article-main { opacity: 1; transform: none; }
html[data-reading="narrow"] .article-main { --article-w: 620px; }
html[data-reading="wide"] .article-main { --article-w: 920px; }
.article-title { font-family: var(--font-read); font-size: calc(clamp(1.9rem, 4vw, 3rem) * (1 + (var(--article-scale, 1) - 1) * .5)); font-weight: 560; line-height: 1.1; letter-spacing: -.016em; margin: 10px 0 12px; }
.article-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: .84rem; color: var(--muted); padding-bottom: 18px; margin-bottom: 22px; border-bottom: 1px solid var(--border); }
.article-body { font-family: var(--font-read); font-size: calc(1.22rem * var(--article-scale, 1)); line-height: 1.62; overflow-wrap: anywhere; }
.article-body p { margin: 0 0 1.05em; }
.article-body h2, .article-body h3, .article-body h4 { font-family: var(--font-ui); margin: 1.5em 0 .5em; line-height: 1.25; }
.article-body h2 { font-size: 1.32rem; } .article-body h3 { font-size: 1.14rem; } .article-body h4 { font-size: 1rem; }
.article-body a:not(.btn) { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.article-body img { max-width: 100%; height: auto; border-radius: 8px; margin: 1.1em auto .5em; }
.article-body figure { margin: 1.4em 0; }
.article-body figcaption { font-family: var(--font-ui); font-size: .8rem; line-height: 1.4; color: var(--muted); }
.article-body ul, .article-body ol { padding-left: 1.4em; margin: 0 0 1.05em; }
.article-body blockquote { margin: 1.2em 0; padding-left: 16px; border-left: 3px solid var(--accent); color: var(--text-2); }
.article-body pre { background: #171a21; color: #dfe3ea; padding: 12px 14px; border-radius: 10px; overflow-x: auto; font-size: .82rem; line-height: 1.45; }
.article-body code { font-size: .86em; }
.article-body pre code { background: none; padding: 0; color: inherit; }
.article-body table { display: block; overflow-x: auto; border-collapse: collapse; font-family: var(--font-ui); font-size: .86rem; margin: 0 0 1.05em; }
.article-body th, .article-body td { border: 1px solid var(--border-strong); padding: 5px 9px; }
.article-loading { display: grid; gap: 12px; }
.article-loading .skeleton { height: 17px; }
.article-loading .skeleton:nth-child(3n) { width: 72%; }
.article-note { display: flex; gap: 11px; padding: 13px 15px; border-radius: var(--radius-sm); background: var(--accent-soft); font-family: var(--font-ui); font-size: .9rem; margin-bottom: 20px; line-height: 1.45; }
.article-note .icon { color: var(--accent); margin-top: 2px; }
.article-end { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 34px; padding-top: 22px; border-top: 1px solid var(--border); font-family: var(--font-ui); }

/* Money */
.money-section { margin-bottom: 24px; }
.money-section > h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 9px; font-weight: 650; }
.money-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: var(--gap); }
.quote-tile { padding: 14px var(--card-pad); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.quote-tile.unavailable { background: var(--surface-2); box-shadow: none; }
.quote-tile .top { display: flex; align-items: flex-start; gap: 8px; justify-content: space-between; }
.quote-tile .name { font-size: .88rem; font-weight: 600; color: var(--text-2); }
.quote-tile .value { font-size: 1.75rem; font-weight: 680; font-variant-numeric: tabular-nums; letter-spacing: -.022em; line-height: 1.2; }
.quote-tile .meta { font-size: .73rem; color: var(--muted); margin-top: 3px; }

/* Calendar */
.cal-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-title { font-size: 1.55rem; font-weight: 680; letter-spacing: -.015em; min-width: 11ch; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); overflow: hidden; }
.cal-dow { padding: 8px 10px; font-size: .75rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); }
.cal-day { min-height: 118px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); cursor: default; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.can-add { cursor: pointer; }
.cal-day.can-add:hover { background: var(--surface-2); }
.cal-day.other { background: var(--surface-2); }
.cal-day.other .num { color: var(--muted); opacity: .65; }
.cal-day .num { font-size: .84rem; font-weight: 600; width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; font-variant-numeric: tabular-nums; }
.cal-day.today .num { background: var(--accent); color: var(--on-accent); }
.cal-event { display: block; width: 100%; text-align: left; font-size: .75rem; line-height: 1.32; padding: 2px 6px; border-radius: 5px; background: color-mix(in srgb, var(--ev) 17%, var(--surface)); color: var(--text); border-left: 3px solid var(--ev); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event:hover { background: color-mix(in srgb, var(--ev) 28%, var(--surface)); }
.cal-event-gap { display: block; height: calc(.75rem * 1.32 + 4px); }
/* Multi-day bars: one button per day, stretched over the cell padding so they read as a single bar. */
.cal-event.span { width: calc(100% + 13px); margin-inline: -6px -7px; border-radius: 0; border-left: 0; overflow: visible; height: calc(.75rem * 1.32 + 4px); }
.cal-event.span.starts { width: calc(100% + 7px); margin-left: 0; border-left: 3px solid var(--ev); border-radius: 5px 0 0 5px; }
.cal-event.span.ends { width: calc(100% + 6px); margin-right: 0; border-radius: 0 5px 5px 0; }
.cal-event.span.starts.ends { width: 100%; margin-inline: 0; border-radius: 5px; }
.cal-event.span.lead { position: relative; z-index: 1; }
.cal-label { display: block; width: calc(var(--span) * 100%); overflow: hidden; text-overflow: ellipsis; }
.agenda-list { display: grid; }
.agenda-day { display: grid; grid-template-columns: 130px 1fr; gap: 16px; padding: 14px var(--card-pad); border-bottom: 1px solid var(--border); }
.agenda-day:last-child { border-bottom: 0; }
.agenda-date b { display: block; font-size: 1.05rem; }
.agenda-items { display: grid; gap: 7px; }
.agenda-item { text-align: left; display: grid; grid-template-columns: auto 1fr; gap: 11px; padding: 6px 10px; border-left: 3px solid var(--ev); border-radius: 0 7px 7px 0; background: color-mix(in srgb, var(--ev) 9%, var(--surface)); }
.agenda-item:hover { background: color-mix(in srgb, var(--ev) 18%, var(--surface)); }

/* Weather */
.weather-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: var(--gap); }
.wx-card { padding: var(--card-pad); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.wx-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.wx-city { font-size: 1.1rem; font-weight: 660; }
.wx-now { display: flex; align-items: center; gap: 14px; }
.wx-now .wx-icon { width: 58px; height: 58px; color: var(--accent); stroke-width: 1.5; flex: none; }
.wx-temp { font-size: 3rem; font-weight: 680; letter-spacing: -.035em; line-height: 1; }
.wx-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 8px; font-size: .84rem; padding: 10px 0; border-block: 1px solid var(--border); }
.wx-stats div span { display: block; font-size: .71rem; color: var(--muted); }
.wx-stats div b { font-weight: 600; font-variant-numeric: tabular-nums; }
.wx-hours { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 3px; }
.wx-hour { flex: 0 0 48px; text-align: center; font-size: .74rem; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; gap: 2px; align-items: center; }
.wx-hour .icon { color: var(--text-2); width: 18px; height: 18px; }
.wx-days { display: grid; gap: 3px; }
.wx-day { display: grid; grid-template-columns: 46px 22px 40px 1fr 40px; align-items: center; gap: 8px; font-size: .85rem; font-variant-numeric: tabular-nums; }
.wx-day .icon { color: var(--text-2); }
.temp-bar { height: 5px; border-radius: 3px; background: var(--surface-3); position: relative; }
.temp-bar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: linear-gradient(90deg, #5fa8e0, #e8a33d, #d9543f); }
.loc-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.loc-row .name { flex: 1; min-width: 0; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-list { border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 190px; overflow: auto; margin-bottom: 12px; }
.result-list button { display: block; width: 100%; text-align: left; padding: 8px 11px; font-size: .9rem; border-bottom: 1px solid var(--border); }
.result-list button:last-child { border-bottom: 0; }
.result-list button:hover { background: var(--surface-3); }

/* World time */
.map-card { overflow: hidden; margin-bottom: var(--gap); }
.world-map { display: block; width: 100%; height: auto; background: var(--ocean); }
.world-map .land { fill: var(--land); stroke: var(--land-stroke); stroke-width: .5; }
.world-map .night { fill: var(--night); }
.world-map .graticule { stroke: var(--land-stroke); stroke-width: .4; opacity: .32; fill: none; }
.world-map .city-dot { stroke: #fff; stroke-width: 1.4; }
.world-map .city-dot.day { fill: #f0a020; }
.world-map .city-dot.night { fill: #5469d4; }
.world-map text { font-family: var(--font-ui); font-size: 11.5px; font-weight: 600; fill: #fff; paint-order: stroke; stroke: rgba(14,18,32,.86); stroke-width: 3px; stroke-linejoin: round; }
.map-legend { display: flex; gap: 18px; flex-wrap: wrap; padding: 10px var(--card-pad); font-size: .8rem; color: var(--text-2); align-items: center; }
.map-legend i { display: inline-block; width: 13px; height: 13px; border-radius: 3px; margin-right: 6px; vertical-align: -2px; border: 1px solid var(--border-strong); }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; padding: 10px var(--card-pad); border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 10px var(--card-pad); border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }

/* Notes */
.note-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.note-toolbar .input { max-width: 260px; }
.note-toolbar .select { width: auto; }
.note-card { --note: transparent; background: color-mix(in srgb, var(--note) 24%, var(--surface)) !important; }
.note-head { padding: 7px 8px 7px 12px; gap: 3px; border-bottom-color: color-mix(in srgb, var(--note) 34%, var(--border)); flex-wrap: wrap; }
.note-title { flex: 1 1 110px; min-width: 70px; background: transparent; border: 0; font-weight: 650; font-size: .96rem; padding: 3px 4px; border-radius: 5px; outline: 0; }
.note-title:focus { background: color-mix(in srgb, var(--surface) 80%, transparent); box-shadow: inset 0 0 0 1px var(--border-strong); }
.note-tools { display: flex; gap: 0; flex-wrap: wrap; }
.note-body { flex: 1; min-height: 0; overflow: auto; padding: 10px 14px; font-size: .94rem; display: flex; flex-direction: column; }
.note-view { flex: 1; min-height: 28px; cursor: text; overflow-wrap: anywhere; }
.note-view:empty::before { content: "Empty note. Click to write."; color: var(--muted); }
.note-view h1, .note-view h2, .note-view h3 { margin: .3em 0; } .note-view h1 { font-size: 1.3rem; } .note-view h2 { font-size: 1.14rem; } .note-view h3 { font-size: 1.02rem; }
.note-view p { margin: 0 0 .35em; }
.note-view ul, .note-view ol { margin: .2em 0 .5em; padding-left: 1.5em; }
.note-view a { color: var(--accent); text-decoration: underline; }
.note-foot { font-size: .7rem; color: var(--muted); padding: 4px 28px 6px 14px; display: flex; justify-content: space-between; gap: 8px; flex: none; }
.note-color-pop { position: absolute; z-index: 50; top: 44px; right: 8px; display: grid; grid-template-columns: repeat(4, 26px); gap: 7px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; box-shadow: var(--shadow-lg); }
.note-color-pop button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border-strong); background: color-mix(in srgb, var(--swatch) 35%, var(--surface)); }
.note-color-pop button.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.note-body .ql-toolbar.ql-snow { border: 0; border-bottom: 1px solid var(--border); padding: 2px 0 5px; }
.note-body .ql-container.ql-snow { border: 0; font-family: var(--font-ui); font-size: .94rem; flex: 1; min-height: 0; }
.note-body .ql-editor { padding: 8px 0; min-height: 60px; }
.note-body .ql-editor.ql-blank::before { left: 0; color: var(--muted); font-style: normal; }
.ql-snow .ql-stroke { stroke: var(--text-2) !important; }
.ql-snow .ql-fill { fill: var(--text-2) !important; }
.ql-snow .ql-picker { color: var(--text-2) !important; }
.ql-snow .ql-picker-options { background: var(--surface) !important; border-color: var(--border) !important; }
.ql-snow .ql-tooltip { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; box-shadow: var(--shadow-lg) !important; z-index: 60; }
.ql-snow .ql-tooltip input { background: var(--surface-2) !important; color: var(--text); border-color: var(--border-strong) !important; }
.ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--accent) !important; }
.ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--accent) !important; }

/* AI */
.ai-layout { height: calc(100vh - var(--topbar-h) - 70px); min-height: 480px; }
.ai-main { height: 100%; }
.ai-picker { display: flex; align-items: center; gap: 7px; min-width: 0; }
.ai-usage { display: inline-flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; padding: 4px 9px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.ai-usage span { display: inline-flex; align-items: center; gap: 3px; }
.ai-usage .icon { width: .95em; height: .95em; color: var(--muted); }
.conv-list { max-height: 46vh; overflow: auto; margin: 0 -6px; }
.conv { display: flex; align-items: center; gap: 2px; border-radius: 8px; }
.conv:hover, .conv.active { background: var(--surface-3); }
.conv.active { font-weight: 600; }
.conv-open { flex: 1; min-width: 0; text-align: left; padding: 8px 9px; font-size: .9rem; display: flex; gap: 8px; align-items: baseline; }
.conv-open .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-open .when { flex: none; font-size: .74rem; color: var(--muted); font-weight: 400; }
.conv-open .icon { color: var(--warn); align-self: center; }
.opt-tabs { margin-bottom: 14px; }
.opt-section { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 650; color: var(--muted); margin: 14px 0 6px; }
.opt-section:first-of-type { margin-top: 0; }
.opt-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.conn-hint { font-size: .82rem; color: var(--muted); margin-bottom: 8px; }
.conn-row.off .info b, .conn-row.off .info span { opacity: .6; }
.conn-default { display: grid; place-items: center; width: 22px; flex: none; cursor: pointer; }
.conn-default input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.conn-actions { display: flex; align-items: center; gap: 4px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
.conn-switch { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; margin-right: 4px; cursor: pointer; color: var(--text-2); }
.conn-switch input { width: 16px; height: 16px; accent-color: var(--accent); }
.provider-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.provider-tile { text-align: left; padding: 13px 14px; border: 1px solid var(--border-strong); border-radius: 11px; display: grid; gap: 3px; transition: border-color .12s, background .12s; }
.provider-tile:hover { border-color: var(--accent); background: var(--accent-soft); color: inherit; }
.provider-tile b { font-size: .95rem; font-weight: 620; }
.provider-tile span { font-size: .78rem; color: var(--muted); line-height: 1.35; }
.conn-provider { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.conn-provider b { font-size: 1rem; font-weight: 640; }
.conn-provider a, .link-btn { color: var(--accent); font-size: .84rem; text-decoration: underline; text-underline-offset: 2px; }
.model-row { display: flex; gap: 8px; align-items: flex-start; }
.model-row > :first-child { flex: 1; min-width: 0; }
.conn-result { font-size: .84rem; margin: -4px 0 12px; }
.conn-result.good { color: var(--positive); } .conn-result.bad { color: var(--negative); }
.conn-advanced { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; }
.conn-advanced summary { cursor: pointer; font-size: .88rem; font-weight: 550; color: var(--text-2); margin-bottom: 10px; }
.ai-main { display: flex; flex-direction: column; overflow: hidden; min-height: 0; min-width: 0; }
.ai-top { display: flex; align-items: center; gap: 8px; padding: 9px 13px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ai-top .select { width: auto; max-width: 380px; height: 34px; }
.ai-title { font-weight: 620; font-size: .94rem; flex: 1; min-width: 80px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-messages { flex: 1; overflow-y: auto; padding: 20px 18px; display: flex; flex-direction: column; gap: 18px; min-height: 0; }
.msg { max-width: min(860px, 100%); width: 100%; margin: 0 auto; display: flex; gap: 12px; }
.msg-avatar { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-2); }
.msg-assistant .msg-avatar { background: var(--accent-soft); color: var(--accent); }
.msg-user { flex-direction: row-reverse; }
.msg-content { min-width: 0; overflow-wrap: anywhere; flex: 1; }
.msg-user .msg-content { flex: 0 1 auto; background: var(--accent); color: var(--on-accent); padding: 8px 13px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; }
.msg-body > :first-child { margin-top: 0; } .msg-body > :last-child { margin-bottom: 0; }
.msg-body p { margin: 0 0 .75em; } .msg-body ul, .msg-body ol { padding-left: 1.5em; margin: 0 0 .75em; } .msg-body h1, .msg-body h2, .msg-body h3 { margin: 1em 0 .4em; font-size: 1.08rem; }
.msg-body a { color: var(--accent); text-decoration: underline; }
.msg-body blockquote { margin: 0 0 .75em; padding-left: 12px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.msg-body table { border-collapse: collapse; margin-bottom: .75em; font-size: .9em; display: block; overflow-x: auto; }
.msg-body th, .msg-body td { border: 1px solid var(--border-strong); padding: 4px 9px; }
.msg-body pre { position: relative; margin: 0 0 .75em; background: #171a21; color: #dfe3ea; padding: 12px 13px; border-radius: 10px; overflow-x: auto; font-size: .85rem; line-height: 1.45; }
.msg-body pre code { background: none; padding: 0; color: inherit; font-size: inherit; }
.copy-code { position: absolute; top: 6px; right: 6px; font-family: var(--font-ui); font-size: .7rem; color: #b6bdc9; background: #2a2f3a; padding: 2px 8px; border-radius: 6px; }
.copy-code:hover { color: #fff; }
.hljs-keyword, .hljs-selector-tag, .hljs-built_in { color: #c792ea; } .hljs-string, .hljs-attr { color: #a5d6a0; } .hljs-number, .hljs-literal { color: #f6b26b; } .hljs-comment, .hljs-quote { color: #7b8496; font-style: italic; } .hljs-title, .hljs-section { color: #82aaff; } .hljs-type, .hljs-class { color: #ffcb6b; } .hljs-variable, .hljs-template-variable { color: #f28779; }
.msg-body .katex-display { margin: .2em 0 .9em; overflow-x: auto; overflow-y: hidden; padding: .3em 0; }
.msg-body div.math { max-width: 100%; }
.msg-body .katex { font-size: 1.12em; }
.msg-body ul:has(> li > input[type=checkbox]) { list-style: none; padding-left: .2em; }
.msg-body li > input[type=checkbox] { margin-right: .5em; accent-color: var(--accent); }
.msg-body img { max-width: 100%; height: auto; border-radius: 8px; }
.msg-body th { background: var(--surface-2); text-align: left; }
.msg-body hr { margin: 1em 0; }
.visual { margin: 0 0 .9em; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.visual-chart { position: relative; height: 320px; max-width: 100%; }
.visual-diagram { overflow-x: auto; text-align: center; }
.visual-diagram svg { max-width: 100%; height: auto; }
.visual-source { margin-top: 8px; font-size: .78rem; color: var(--muted); }
.visual-source summary { cursor: pointer; width: fit-content; }
.visual-source pre { margin-top: 6px; margin-bottom: 0; }
.visual-table { overflow-x: auto; margin-top: 6px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.msg-body .visual-table table { display: table; margin: 0; font-size: .95em; }
.render-note { font-size: .8rem; color: var(--muted); margin: -.3em 0 .9em !important; }
.msg-meta { font-size: .72rem; color: var(--muted); margin-top: 5px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.msg-error { color: var(--negative); background: var(--negative-soft); padding: 7px 11px; border-radius: 8px; font-size: .88rem; margin-top: 6px; }
.typing i { display: inline-block; width: 6px; height: 6px; margin-right: 3px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite both; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.ai-input { padding: 11px 13px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: flex-end; }
.ai-input textarea { flex: 1; resize: none; min-height: 42px; max-height: 200px; padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 11px; line-height: 1.4; }
.ai-input textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ai-input .btn { height: 42px; }
.ai-welcome { margin: auto; text-align: center; color: var(--muted); max-width: 440px; }
.ai-welcome .icon { width: 36px; height: 36px; color: var(--accent); margin-bottom: 10px; }
.ai-welcome h2 { color: var(--text); margin-bottom: 6px; font-size: 1.2rem; }
.conn-row { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); }
.conn-row .info { flex: 1; min-width: 0; }
.conn-row .info b { display: block; font-size: .93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn-row .info span { font-size: .77rem; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Settings */
.settings-layout { display: grid; grid-template-columns: 210px minmax(0, 760px); gap: 26px; align-items: flex-start; }
.settings-tabs { position: sticky; top: calc(var(--topbar-h) + 18px); display: grid; gap: 2px; }
.settings-tabs button { display: flex; gap: 10px; align-items: center; padding: 8px 11px; border-radius: 9px; text-align: left; font-size: .92rem; color: var(--text-2); font-weight: 500; }
.settings-tabs button:hover { background: var(--surface-3); color: var(--text); }
.settings-tabs button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.settings-panel > .card, .notif-panel > .card { padding: 20px var(--card-pad); margin-bottom: 16px; }
/* Notification settings: sub-tabs */
.settings-panel { min-width: 0; } /* lets the sub-tab strip scroll instead of widening the page */
.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtabs button { display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px 10px; margin-bottom: -1px; border-bottom: 2px solid transparent; border-radius: 8px 8px 0 0; font-size: .9rem; font-weight: 550; color: var(--text-2); white-space: nowrap; }
.subtabs button:hover { color: var(--text); background: var(--surface-3); }
.subtabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 650; }
.subtabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.subtab-meta { font-size: .7rem; font-weight: 650; line-height: 1.6; padding: 0 7px; border-radius: 99px; background: var(--positive-soft); color: var(--positive); }
.subtab-meta.off { background: var(--surface-3); color: var(--muted); }
.notif-panel:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: var(--radius); }
.notif-panel .banner { align-items: center; }
.notif-panel .banner > div { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1; }
.notif-panel .banner .btn { margin-left: auto; }
.settings-panel h2 { font-size: 1.08rem; margin-bottom: 4px; }
.settings-panel h2 + p { color: var(--muted); font-size: .88rem; margin-bottom: 15px; }
.danger-zone { border-color: color-mix(in srgb, var(--negative) 42%, var(--border)) !important; }
.action-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.action-row:last-child { border-bottom: 0; }
.action-row > div:first-child { min-width: 0; }
.action-row b { font-weight: 600; display: block; font-size: .94rem; }
.action-row span { font-size: .82rem; color: var(--muted); }
.theme-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; margin-bottom: 18px; }
.theme-card { border: 2px solid var(--border); border-radius: 11px; padding: 10px; text-align: left; font-size: .87rem; font-weight: 600; display: grid; gap: 8px; }
.theme-card.active { border-color: var(--accent); }
.theme-card .preview { height: 44px; border-radius: 7px; display: grid; grid-template-columns: 1fr 2.2fr; overflow: hidden; border: 1px solid rgba(128,128,128,.3); }
.segmented { display: inline-flex; align-self: flex-start; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; flex-wrap: wrap; }
.segmented button { padding: 6px 12px; font-size: .86rem; border-right: 1px solid var(--border-strong); }
.segmented button:last-child { border-right: 0; }
.segmented button.active { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 10px 16px; font-size: .88rem; }
.status-grid span { display: block; color: var(--muted); font-size: .74rem; }

/* Modal */
.modal-scrim { position: fixed; inset: 0; background: rgba(10,12,18,.52); z-index: 60; display: grid; place-items: center; padding: 18px; overflow: auto; animation: fade .14s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; max-height: calc(100vh - 36px); display: flex; flex-direction: column; animation: pop .17s var(--ease); }
.modal.wide { max-width: 760px; }
@keyframes pop { from { transform: translateY(8px) scale(.985); opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 13px 18px; border-bottom: 1px solid var(--border); flex: none; }
.modal-head h2 { flex: 1; font-size: 1.05rem; }
.modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); flex: none; flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; }
#toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 80; max-width: min(380px, calc(100vw - 36px)); }
.toast { background: var(--text); color: var(--surface); padding: 10px 15px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: .9rem; animation: pop .2s var(--ease); }
.toast.error { background: var(--negative); color: var(--on-negative); }

/* Sign-in dialog: the page stays visible, blurred, in its current theme. */
.modal-scrim.login-scrim { z-index: 75; padding: 18px; place-items: center; background: color-mix(in srgb, var(--bg) 88%, transparent); }
@supports (backdrop-filter: blur(1px)) {
  .modal-scrim.login-scrim { background: color-mix(in srgb, var(--bg) 38%, transparent); backdrop-filter: blur(14px) saturate(1.15); }
}
.modal.login-modal { max-width: 400px !important; border-radius: 18px; }
.login-modal .modal-body { padding: 26px 26px 20px; }
.login-form h2 { font-size: 1.32rem; margin-bottom: 5px; }
.login-form .muted { margin-bottom: 16px; }
.login-form .btn-ghost { margin-top: 6px; color: var(--muted); }
.login-form .auth-brand { margin-bottom: 18px; }

/* Search palette */
.palette { max-width: 600px; align-self: flex-start; margin-top: 8vh; }
.palette-input { display: flex; gap: 10px; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.palette-input input { flex: 1; border: 0; background: transparent; outline: 0; font-size: 1.05rem; }
.palette-results { max-height: 58vh; overflow: auto; padding: 8px; }
.palette-group { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; padding: 8px 10px 3px; }
.palette-item { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; width: 100%; text-align: left; font-size: .92rem; min-width: 0; }
.palette-item span:first-of-type { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item:hover, .palette-item.sel { background: var(--surface-3); color: inherit; }

/* Auth */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: var(--bg); }
.auth-card { background: var(--surface); border: 1px solid var(--border); padding: 28px; border-radius: 18px; box-shadow: var(--shadow-lg); width: 100%; max-width: 410px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 750; margin-bottom: 20px; }
.auth-card h1 { font-size: 1.35rem; margin-bottom: 6px; }
.auth-card .muted { margin-bottom: 18px; font-size: .92rem; }
.auth-back { display: block; text-align: center; font-size: .88rem; color: var(--muted); margin-top: 14px; }

/* Responsive */
/* Video */
.video-chips { display: flex; gap: 8px; overflow-x: auto; margin: -6px 0 16px; padding: 2px; scrollbar-width: none; }
.video-chips:empty { display: none; }
.video-chip { flex: none; padding: 5px 13px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface-3); color: var(--text); font: inherit; font-size: .84rem; font-weight: 550; cursor: pointer; white-space: nowrap; }
.video-chip:hover { border-color: var(--accent); }
.video-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: 22px 16px; }
.video-card { display: flex; flex-direction: column; min-width: 0; }
.video-media { position: relative; display: grid; place-items: center; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 10px; background: var(--surface-3); color: var(--muted); margin-bottom: 9px; }
.video-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.video-media:hover img { transform: scale(1.03); }
.video-duration { position: absolute; right: 6px; bottom: 6px; padding: 1px 5px; border-radius: 4px; background: rgb(0 0 0 / .8); color: #fff; font-size: .74rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.video-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: .95rem; font-weight: 600; line-height: 1.32; color: var(--text); }
.video-meta { display: flex; flex-direction: column; gap: 1px; margin-top: 4px; font-size: .82rem; color: var(--muted); min-width: 0; }
.video-meta a, .video-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-meta a { color: var(--text-2); }
.video-why { display: flex; align-items: center; gap: 5px; margin-top: 4px; font-size: .76rem; color: var(--muted); min-width: 0; }
.video-why .icon { flex: none; width: 13px; height: 13px; }
.video-why span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 1180px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-tabs { position: static; display: flex; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  .settings-tabs button { white-space: nowrap; }
  .search-trigger { min-width: 0; } .search-trigger kbd { display: none; }
}
@media (max-width: 860px) {
  :root { --topbar-h: 54px; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; height: 100%; width: 256px !important; transform: translateX(-102%); transition: transform .22s var(--ease); }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  html[data-sidebar="collapsed"] .nav-label, html[data-sidebar="collapsed"] .sidebar .brand-text, html[data-sidebar="collapsed"] .nav-lock { display: revert; }
  .sidebar-toggle { display: none; }
  .menu-btn { display: inline-grid; }
  .brand-compact { display: flex; }
  .topbar { padding: 0 10px; gap: 6px; padding-top: env(safe-area-inset-top); height: calc(var(--topbar-h) + env(safe-area-inset-top)); }
  .clock { display: none; }
  .search-trigger { display: none; }
  #search-btn-small { display: inline-grid; }
  .topbar-actions { margin-left: auto; }
  #page { padding: 14px 12px calc(84px + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 1.3rem; }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; gap: 1px; align-items: center; justify-content: center; padding: 7px 0 6px; font-size: .68rem; color: var(--muted); }
  .bottom-nav .icon { width: 1.3rem; height: 1.3rem; }
  .bottom-nav a.active { color: var(--accent); font-weight: 600; }
  .popover { position: fixed; left: 10px; right: 10px; top: calc(var(--topbar-h) + 6px); width: auto; }
  .carousel { --slide-h: max(420px, calc(100dvh - var(--topbar-h) - 232px - env(safe-area-inset-bottom))); }
  .carousel-arrow { width: 38px; height: 38px; }
  .carousel-arrow.prev { left: 8px; } .carousel-arrow.next { right: 8px; }
  .slide.low-res .slide-photo { inset: 16px 0 auto 50%; width: auto; max-width: 74%; max-height: 40%; transform: translateX(-50%) !important; }
  .slide.low-res .slide-scrim { background: linear-gradient(to top, rgba(8,10,16,.93) 0%, rgba(8,10,16,.78) 55%, rgba(8,10,16,.25) 100%); }
  .slide.low-res .slide-text { max-width: none; align-self: flex-end; }
  .slide-why { margin-left: 0; width: 100%; }
  .slide-excerpt { -webkit-line-clamp: 2; }
  .feed-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .feed-tile, .feed-tile[data-size="lg"] { grid-column: span 1; height: 158px; }
  .feed-tile[data-slot="0"] { grid-column: span 2; height: 190px; }
  .feed-tile .tile-title { font-size: .95rem; }
  .feed-tile[data-slot="0"] .tile-title { font-size: 1.15rem; }
  .feed-tile[data-slot="9"] { display: none; }
  .article-body { font-size: calc(1.14rem * var(--article-scale, 1)); }
  .article-bar { flex-wrap: wrap; row-gap: 6px; }
  .article-bar .where { flex: 1 1 0; }
  .reader-tools { order: 5; flex: 1 1 100%; justify-content: space-between; gap: 8px; }
  .reader-scroll { flex: 1; justify-content: flex-end; min-width: 0; }
  .reader-scroll .btn { min-width: 0; }
  .reader-scroll .btn span, .reader-listen span { display: none; }
  .reader-listen { min-width: 0; }
  .reader-scroll input[type=range] { flex: 1; width: auto; min-width: 60px; max-width: 150px; }
  .reader-original span { display: none; }
  .weather-grid { grid-template-columns: 1fr; }
  .cal-day { min-height: 62px; padding: 3px; }
  .cal-day .num { font-size: .76rem; width: 21px; height: 21px; }
  .cal-event, .cal-event.span { font-size: 0; height: 6px; padding: 0; border-left-width: 0; background: var(--ev); border-radius: 3px; }
  .cal-event.span { width: calc(100% + 7px); margin-inline: -3px -4px; border-radius: 0; }
  .cal-event.span.starts { width: calc(100% + 4px); margin-left: 0; border-left: 0; border-radius: 3px 0 0 3px; }
  .cal-event.span.ends { width: calc(100% + 3px); margin-right: 0; border-radius: 0 3px 3px 0; }
  .cal-event-gap { height: 6px; }
  .cal-dow { padding: 6px 2px; text-align: center; font-size: .66rem; }
  .agenda-day { grid-template-columns: 1fr; gap: 6px; }
  .ai-layout { height: calc(100vh - var(--topbar-h) - 130px); }
  .ai-title { display: none; }
  .ai-picker { flex: 1 1 100%; order: 3; }
  .conn-row { flex-wrap: wrap; }
  .conn-row .info { flex: 1 1 60%; }
  .conn-actions { flex: 1 1 100%; justify-content: flex-start; padding-left: 30px; }
  .ai-top .select { max-width: none; flex: 1; min-width: 0; }
  .modal-scrim { padding: 0; place-items: end stretch; }
  .modal { max-width: none !important; border-radius: 16px 16px 0 0; max-height: 92vh; }
  .palette { margin: 0; align-self: flex-start; border-radius: 0 0 16px 16px; }
  .action-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  #toasts { bottom: calc(70px + env(safe-area-inset-bottom)); left: 12px; right: 12px; max-width: none; }
  .note-toolbar .input { max-width: none; flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print { .sidebar, .topbar, .bottom-nav { display: none; } }
