/* Shared by the public magazine AND the dashboard. Every colour in the app comes from these tokens.
   All palettes pass WCAG AA (text 4.5:1). Add a theme = add a block here + one entry in theme.js. */
:root{--radius:16px;--shadow:0 14px 34px -16px rgba(20,24,40,.4);--alert:#c62828;--alert-ink:#ffffff;--display:"Iowan Old Style","Palatino Linotype",Palatino,"Book Antiqua",Georgia,serif}
:root,[data-theme="light"]{color-scheme:light;--bg:#ffffff;--surface:#f4f5f7;--ink:#15171a;--muted:#586070;--line:#dfe3e8;--accent:#0b5fcc;--accent-ink:#ffffff;--img-dim:1}
[data-theme="paper"]{color-scheme:light;--bg:#f8f4eb;--surface:#efe9da;--ink:#26221b;--muted:#605845;--line:#dcd3bd;--accent:#1a5a86;--accent-ink:#ffffff;--img-dim:1}
[data-theme="sepia"]{color-scheme:light;--bg:#f4ecd8;--surface:#eadfc3;--ink:#3f3120;--muted:#6b5a42;--line:#d6c7a3;--accent:#84440e;--accent-ink:#ffffff;--img-dim:.98}
[data-theme="sage"]{color-scheme:light;--bg:#e8efe4;--surface:#dbe6d5;--ink:#1d281d;--muted:#4b5c4b;--line:#c2d2ba;--accent:#25623a;--accent-ink:#ffffff;--img-dim:1}
[data-theme="dark"]{color-scheme:dark;--bg:#16181c;--surface:#1f2228;--ink:#e6e8eb;--muted:#a0a8b3;--line:#2f343c;--accent:#6cb2ff;--accent-ink:#06121f;--img-dim:.9}
[data-theme="slate"]{color-scheme:dark;--bg:#1e2633;--surface:#273244;--ink:#dfe6f2;--muted:#9dabc2;--line:#38465d;--accent:#7dd3fc;--accent-ink:#04121c;--img-dim:.9}
[data-theme="black"]{color-scheme:dark;--bg:#000000;--surface:#0e0e0e;--ink:#d9d9d9;--muted:#959595;--line:#2a2a2a;--accent:#5eead4;--accent-ink:#001311;--img-dim:.82}
[data-theme="dark"],[data-theme="slate"],[data-theme="black"]{--alert:#ff8a80;--alert-ink:#1a0000;--shadow:0 14px 34px -16px rgba(0,0,0,.85)}
/* "Auto": no data-theme attribute -> follow the OS setting */
@media (prefers-color-scheme:dark){:root:not([data-theme]){color-scheme:dark;--bg:#16181c;--surface:#1f2228;--ink:#e6e8eb;--muted:#a0a8b3;--line:#2f343c;--accent:#6cb2ff;--accent-ink:#06121f;--img-dim:.9;--alert:#ff8a80;--alert-ink:#1a0000;--shadow:0 14px 34px -16px rgba(0,0,0,.85)}}
@media print{:root,[data-theme]{--bg:#fff;--surface:#fff;--ink:#000;--muted:#333;--line:#999;--accent:#000;--img-dim:1}.tp,.subscribe,.ad,.share-bar{display:none!important}}

/* ---- Reading preferences (set by theme.js) ---- */
:root{--fs:18px;--body:Georgia,"Iowan Old Style","Times New Roman",serif;--ui:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
[data-size="s"]{--fs:16px}[data-size="l"]{--fs:20px}[data-size="xl"]{--fs:22px}
[data-font="sans"]{--body:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
/* Low-Data / Bandwidth Saver mode for mobile commuters */
[data-datasaver="1"] .srow-thumb{display:none!important}
[data-datasaver="1"] .srow{grid-template-columns:1fr!important}
[data-datasaver="1"] .hero-img img,[data-datasaver="1"] .story-hero,[data-datasaver="1"] .article-figure img{display:none!important}
html{background:var(--bg)}
::selection{background:var(--accent);color:var(--accent-ink)}
:focus-visible{outline:3px solid var(--accent);outline-offset:2px}
img{filter:brightness(var(--img-dim,1))}
@media (prefers-reduced-motion:no-preference){body{transition:background-color .2s,color .2s}}

/* ---- Theme switcher: bottom sheet on phones, dropdown on larger screens ---- */
.tp{font:14px var(--ui)}
.tp-btn{display:inline-flex;align-items:center;justify-content:center;background:var(--surface);color:var(--ink);border:1px solid var(--line);border-radius:999px;min-height:44px;min-width:48px;padding:0 14px;font:700 16px Georgia,serif;cursor:pointer}
.tp-back{position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:90}.tp-back[hidden]{display:none}
.tp-panel{position:fixed;left:0;right:0;bottom:0;z-index:100;max-width:480px;margin:0 auto;background:var(--bg);color:var(--ink);border:1px solid var(--line);border-bottom:0;border-radius:24px 24px 0 0;padding:8px 18px calc(18px + env(safe-area-inset-bottom,0px));box-shadow:0 -16px 48px rgba(0,0,0,.35);max-height:88vh;overflow:auto}
.tp-panel[hidden]{display:none}
.tp-grab{width:40px;height:4px;border-radius:4px;background:var(--line);margin:4px auto 6px}
.tp-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:4px}.tp-head b{font:700 17px var(--ui)}
.tp-x{background:var(--surface);color:var(--ink);border:0;border-radius:50%;width:44px;height:44px;font:20px var(--ui);cursor:pointer;padding:0}
.tp-panel h4{margin:14px 0 8px;font:600 12px var(--ui);text-transform:uppercase;letter-spacing:.07em;color:var(--muted)}
.tp-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}
.tp-sw{display:flex;flex-direction:column;align-items:center;gap:5px;background:var(--surface);border:2px solid transparent;border-radius:14px;padding:8px 2px;color:var(--ink);cursor:pointer;font:600 12px var(--ui);min-height:68px}
.tp-sw i{display:block;width:32px;height:32px;border-radius:50%;border:1px solid var(--line);font:700 15px/30px Georgia,serif;text-align:center;font-style:normal}
.tp-sw[aria-pressed="true"],.tp-row button[aria-pressed="true"]{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}
.tp-row{display:flex;gap:8px;align-items:center}
.tp-row button{flex:1;min-height:48px;background:var(--surface);color:var(--ink);border:2px solid transparent;border-radius:14px;font:700 16px var(--ui);cursor:pointer}
.tp-row output{min-width:40px;text-align:center;color:var(--muted);font:600 14px var(--ui)}
.tp-select{width:100%;min-height:42px;background:var(--surface);color:var(--ink);border:1px solid var(--line);border-radius:12px;padding:8px 12px;font:600 13px var(--ui);cursor:pointer}
@media(min-width:720px){.tp{position:relative}.tp-back{background:transparent}
 .tp-panel{position:absolute;left:auto;right:0;bottom:auto;top:calc(100% + 10px);width:360px;max-width:none;margin:0;border:1px solid var(--line);border-radius:18px;box-shadow:var(--shadow);padding:10px 16px 16px;max-height:85vh}.tp-grab{display:none}}
