/* dse-alerts design tokens. Four themes; charts read these variables at render time.
   Palette: the validated reference set (categorical slots s1..s4, status up/down). */
:root, :root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f7; --surface: #fcfcfb; --surface-2: #f0efec; --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --line: #e1e0d9; --line-2: #c3c2b7; --accent: #2a78d6; --accent-ink: #ffffff;
  --up: #006300; --down: #d03b3b; --warn: #9a6700; --info: #4b5563;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --shadow: 0 1px 2px rgba(11,11,11,.06), 0 4px 16px rgba(11,11,11,.05);
  --radius: 10px; --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; --mono: var(--font);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #232322; --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --line: #2c2c2a; --line-2: #383835; --accent: #3987e5; --accent-ink: #ffffff;
  --up: #0ca30c; --down: #e66767; --warn: #c98500; --info: #9aa3ad;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
}
:root[data-theme="midnight"] {
  color-scheme: dark;
  --bg: #0b1220; --surface: #111a2e; --surface-2: #172238; --ink: #e8edf7; --ink-2: #b7c2d9; --muted: #8391ab;
  --line: #223052; --line-2: #2c3b63; --accent: #5aa0ff; --accent-ink: #0b1220;
  --up: #35c26b; --down: #ff6b6b; --warn: #e3b341; --info: #9fb0cc;
  --s1: #5aa0ff; --s2: #ff8a4c; --s3: #2ec4a0; --s4: #e3b341;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 8px 24px rgba(0,0,0,.45);
}
:root[data-theme="terminal"] {
  color-scheme: dark;
  --bg: #050806; --surface: #0b100c; --surface-2: #101812; --ink: #d7ffd9; --ink-2: #9fd8a5; --muted: #5f8f66;
  --line: #1d2a20; --line-2: #27392b; --accent: #39d353; --accent-ink: #050806;
  --up: #39d353; --down: #ff5c5c; --warn: #e3b341; --info: #7fb888;
  --s1: #39d353; --s2: #ffb454; --s3: #4cc9f0; --s4: #e879f9;
  --shadow: none; --radius: 4px; --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme]) {
  color-scheme: dark;
  --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #232322; --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --line: #2c2c2a; --line-2: #383835; --accent: #3987e5; --accent-ink: #ffffff;
  --up: #0ca30c; --down: #e66767; --warn: #c98500; --info: #9aa3ad;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
} }

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14.5px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
h1 { font-size: clamp(19px, 1.6vw + 12px, 22px); font-weight: 650; letter-spacing: -.01em; margin: 0 0 2px; }
h2 { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; }
h3 { font-size: 15px; font-weight: 650; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .error { color: var(--down); }
.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* layout */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px; padding: 10px 22px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.brand .logo { width: 22px; height: 22px; }
nav.main { display: flex; gap: 2px; flex: 1; }
nav.main a { padding: 6px 11px; border-radius: 7px; color: var(--ink-2); font-weight: 500; }
nav.main a:hover { background: var(--surface-2); text-decoration: none; } nav.main a.active { background: var(--surface-2); color: var(--ink); }
.top .right { display: flex; align-items: center; gap: 10px; }
.themes { display: flex; gap: 4px; padding: 3px; background: var(--surface-2); border-radius: 8px; }
.themes button { width: 22px; height: 22px; border-radius: 6px; border: 2px solid transparent; cursor: pointer; padding: 0; }
.themes button.active { border-color: var(--accent); }
.themes button[data-theme-pick="light"] { background: #fcfcfb; } .themes button[data-theme-pick="dark"] { background: #1a1a19; }
.themes button[data-theme-pick="midnight"] { background: #0b1220; } .themes button[data-theme-pick="terminal"] { background: #050806; box-shadow: inset 0 0 0 1px #39d353; }
main { max-width: 1240px; margin: 0 auto; padding: 22px max(22px, env(safe-area-inset-right)) 48px max(22px, env(safe-area-inset-left)); }
footer { max-width: 1240px; margin: 0 auto; padding: 0 22px max(32px, env(safe-area-inset-bottom)); color: var(--muted); font-size: 12px; }
@media (min-width: 1600px) { main, footer { max-width: 1400px; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .sub { color: var(--muted); font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); margin: 0 0 16px; }
.card.narrow { max-width: 440px; margin: 56px auto; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1.4fr 1fr; } .grid.cols-3 { grid-template-columns: repeat(3, 1fr); } .grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.even { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.even { grid-template-columns: 1fr; } main { padding: 14px 14px 40px; } .top { padding: 8px 14px; gap: 10px; } nav.main a { padding: 6px 8px; } }
/* up to small tablets the nine links do not fit beside the controls: the nav takes its own
   row and scrolls sideways if it must */
@media (max-width: 1000px) {
  .top { flex-wrap: wrap; row-gap: 6px; }
  nav.main { order: 3; flex: 1 1 100%; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  nav.main::-webkit-scrollbar { display: none; }
  .top .right { margin-left: auto; }
}

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.tile .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin: 4px 0 2px; }
.tile .value .unit { font-size: 16px; }
.tile .delta { font-size: 13px; font-weight: 600; } .tile .note { font-size: 12px; color: var(--muted); }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 11.5px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
table.compact th, table.compact td { padding: 6px 8px; font-size: 13px; }
table.kv td:first-child { color: var(--muted); width: 55%; } table.kv td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { max-height: 440px; overflow: auto; }
/* a table scrolls inside its card instead of stretching the page; low-priority columns drop
   out first on narrow screens (hide-md under 1100px, hide-sm under 760px) */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 1100px) { .hide-md { display: none; } }
@media (max-width: 760px) { .hide-sm { display: none; } }
.name { max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rowgroup td { background: var(--surface-2); font-weight: 650; }

/* badges, dots, bars */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 650; letter-spacing: .02em; border: 1px solid currentColor; line-height: 18px; white-space: nowrap; }
.badge.up { color: var(--up); } .badge.down { color: var(--down); } .badge.warn { color: var(--warn); } .badge.info { color: var(--info); }
.badge.owned { color: var(--s1); } .badge.target { color: var(--s2); } .badge.watch { color: var(--muted); }
.badge.cat-A { color: var(--up); } .badge.cat-B { color: var(--warn); } .badge.cat-Z { color: var(--down); } .badge.cat-N { color: var(--info); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--info); vertical-align: middle; }
.dot.high { background: var(--down); } .dot.notable { background: var(--warn); }
.bar { position: relative; height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.bar > span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--s1); border-radius: 5px; }
.range { position: relative; height: 6px; background: var(--surface-2); border-radius: 3px; margin: 6px 0 2px; }
.range > i { position: absolute; top: -4px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.hbar { display: grid; grid-template-columns: 130px 1fr 90px; align-items: center; gap: 10px; padding: 5px 0; font-size: 13px; }
.hbar .bar > span { background: var(--s1); }

/* alerts */
.alert { padding: 11px 14px; border-left: 4px solid var(--info); background: var(--surface-2); border-radius: 6px; margin: 8px 0; }
.alert.high { border-color: var(--down); } .alert.notable { border-color: var(--warn); }
.alert.info { border-left-style: dashed; background: transparent; border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.alert .head { font-weight: 650; } .detail { font-size: 13px; color: var(--ink-2); margin-top: 3px; white-space: pre-wrap; }
.alert.info .head { font-weight: 550; }
.sev { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; vertical-align: middle; margin-left: 4px; color: var(--info); border: 1px solid var(--line-2); background: var(--surface); line-height: 16px; }
.sev.notable { color: var(--warn); border-color: var(--warn); } .sev.high { color: var(--accent-ink); background: var(--down); border-color: var(--down); }
.alert .meta { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* forms & buttons */
label { display: block; margin: 10px 0; font-size: 12.5px; color: var(--muted); font-weight: 500; }
label.check { display: flex; align-items: center; gap: 8px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, input:not([type]) { width: 100%; padding: 8px 11px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--bg); color: var(--ink); font: inherit; }
input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
button, .btn { padding: 7px 14px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface); color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; }
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; font-weight: 500; } button.link.danger { color: var(--down); font-size: 12px; }
.inline { display: inline; } .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .row.between { justify-content: space-between; }
form.row input, form.row select { width: auto; } form.row { margin: 0; }
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 8px; }
.seg button { padding: 4px 10px; border: 0; background: transparent; border-radius: 6px; font-size: 12.5px; color: var(--ink-2); }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* charts */
.chart { position: relative; width: 100%; height: clamp(240px, 32vw, 320px); }
.chart.tall { height: clamp(300px, 40vw, 440px); } .chart.short { height: clamp(180px, 22vw, 220px); }
.chart.loading { opacity: .55; transition: opacity .2s; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); margin: 0 0 8px; min-height: 18px; }
.legend .key { display: inline-block; width: 14px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 6px; }
.legend .key.rect { height: 10px; border: 0; border-radius: 2px; }
.legend b { color: var(--ink); font-variant-numeric: tabular-nums; margin-left: 4px; }
.spark { width: 110px; height: 30px; color: var(--s1); display: block; }
.spark.up { color: var(--up); } .spark.down { color: var(--down); }

/* evidence */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.fact { padding: 10px 12px; background: var(--surface-2); border-radius: 8px; }
.fact .label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }
.fact .value { font-size: 17px; font-weight: 650; margin: 2px 0; } .fact .note { font-size: 12.5px; color: var(--ink-2); }

/* rules form */
.rules .rule { padding: 10px 0; border-bottom: 1px solid var(--line); }
.rules .rule-head { color: var(--ink); margin: 0; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.rules .params { display: flex; gap: 12px; flex-wrap: wrap; margin: 6px 0 0 26px; }
.rules .params label { margin: 0; width: 170px; } .rules .params input { padding: 5px 8px; }
.news { padding: 8px 0; border-bottom: 1px solid var(--line); }
.news .title { font-weight: 600; }

/* ---- language -------------------------------------------------------------------------
   Bangla uses fonts that ship with the OS (Nirmala UI on Windows, Noto Sans Bengali on
   Android/ChromeOS/Linux, common Bangladeshi installs); nothing is fetched from the web. */
:root[lang="bn"], :root[lang="bn"][data-theme] { --font: "Noto Sans Bengali", "Nirmala UI", "Hind Siliguri", "SolaimanLipi", "Kalpurush", "Vrinda", system-ui, "Segoe UI", sans-serif; }
:root[lang="bn"] body { line-height: 1.65; }
:root[lang="bn"] .num, :root[lang="bn"] code { font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
.lang { display: flex; background: var(--surface-2); border-radius: 8px; padding: 3px; }
.lang a { padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); text-decoration: none; line-height: 18px; }
.lang a.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---- demo mode and the AI summary -------------------------------------------------- */
.banner.demo { background: var(--surface-2); border-bottom: 1px solid var(--line); padding: 8px 22px; font-size: 13px; color: var(--ink-2); text-align: center; }
.demo-box { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
button.wide { width: 100%; }
a.button { display: inline-block; padding: 7px 12px; border: 1px solid var(--line-2); border-radius: 7px; }
.card.ai { border-left: 4px solid var(--accent); }
.ai-mark { color: var(--accent); }
.digest { white-space: pre-wrap; line-height: 1.6; font-size: 14.5px; }
.digest.small { font-size: 13px; }
.digest-row td { background: var(--surface-2); }

/* ---- market today: sector board, movers, record dates ------------------------------ */
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.board .cell { padding: 8px 9px; border-radius: 7px; background: var(--surface-2); color: var(--ink); min-height: 58px; display: flex; flex-direction: column; justify-content: space-between; }
.board .cell .sector { font-size: 12px; font-weight: 600; line-height: 1.25; }
.board .cell .move { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.board .cell .n { font-size: 11px; opacity: .75; }
.board .cell.up1 { background: color-mix(in srgb, var(--up) 14%, var(--surface-2)); } .board .cell.up2 { background: color-mix(in srgb, var(--up) 28%, var(--surface-2)); } .board .cell.up3 { background: color-mix(in srgb, var(--up) 45%, var(--surface-2)); }
.board .cell.dn1 { background: color-mix(in srgb, var(--down) 14%, var(--surface-2)); } .board .cell.dn2 { background: color-mix(in srgb, var(--down) 28%, var(--surface-2)); } .board .cell.dn3 { background: color-mix(in srgb, var(--down) 45%, var(--surface-2)); }
/* the shade follows the size of the move (--k is set per cell), so -0.2% and -2.9% differ */
.board .cell.up { background: color-mix(in srgb, var(--up) var(--k, 10%), var(--surface-2)); }
.board .cell.dn { background: color-mix(in srgb, var(--down) var(--k, 10%), var(--surface-2)); }
.movers { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .movers { grid-template-columns: 1fr; } }
.movers h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 6px; }
.help { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }
.help a { font-weight: 500; }
th[title] { cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
.ai-tag { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; padding: 1px 6px; border-radius: 4px; background: var(--accent); color: var(--accent-ink); vertical-align: middle; }

/* ---- stock finder ------------------------------------------------------------------ */
.presets { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.presets a { padding: 6px 12px; border: 1px solid var(--line-2); border-radius: 999px; font-size: 13px; color: var(--ink-2); background: var(--surface); }
.presets a:hover { background: var(--surface-2); text-decoration: none; } .presets a.active { border-color: var(--accent); color: var(--accent); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.filters label { margin: 0; } .filters input, .filters select { width: 100%; }
.filters .actions { display: flex; gap: 8px; }

/* ---- learn page -------------------------------------------------------------------- */
.learn { max-width: 820px; }
.learn h2 { font-size: 17px; text-transform: none; letter-spacing: 0; color: var(--ink); margin: 26px 0 8px; }
.learn h2:first-child { margin-top: 0; }
.learn p { margin: 0 0 10px; line-height: 1.65; }
.learn dl { margin: 0; } .learn dt { font-weight: 650; margin-top: 10px; } .learn dd { margin: 2px 0 0; color: var(--ink-2); line-height: 1.6; }
.learn .toc { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; margin-bottom: 8px; }
.meta > span:not(:first-child)::before { content: "/"; color: var(--muted); margin: 0 7px; }

/* ---- landing page for visitors ------------------------------------------------------ */
.hero { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; margin: 18px 0 20px; }
.hero h1 { font-size: 30px; line-height: 1.2; margin: 0 0 10px; }
.hero .lead { font-size: 16px; line-height: 1.6; color: var(--ink-2); margin: 0 0 16px; max-width: 640px; }
.hero .cta { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.hero .cta .btn, .hero .cta button { padding: 9px 16px; }
.hero .tile .note { margin-top: 2px; }
.steps .card h3 { margin-bottom: 6px; }
.steps .card p { margin: 0; color: var(--ink-2); line-height: 1.55; }
.features { margin: 0; padding-left: 20px; line-height: 1.65; }
.features li { margin-bottom: 4px; }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } .grid.cols-3 { grid-template-columns: 1fr; } .hero h1 { font-size: 24px; } }

/* ---- folded sections (the per-stock rules form) -------------------------------------- */
details.fold summary { cursor: pointer; font-weight: 650; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.fold summary::-webkit-details-marker { display: none; }
details.fold summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin: 0 6px 4px 0; }
details.fold[open] summary::after { transform: rotate(-135deg); margin: 4px 6px 0 0; }

/* ---- scorecard: the backtest as dots against the any-session line --------------------- */
.dots .dotrow { display: grid; grid-template-columns: minmax(150px, 230px) 1fr 56px; gap: 14px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.dots .dotrow.ticks { padding: 0 0 4px; border-bottom: 0; font-size: 11px; color: var(--muted); }
.dots .dotrow.ticks .track { height: 16px; }
.dots .dotrow.ticks .track span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.dots .dotrow.ticks .track span:first-child { transform: none; } .dots .dotrow.ticks .track span:last-child { transform: translateX(-100%); }
.dots .dotrow.ticks .track span.mid { color: var(--ink-2); font-weight: 600; }
.dots .track { position: relative; height: 24px; }
.dots .track::before { content: ""; position: absolute; left: 0; right: 0; top: 11px; height: 2px; background: var(--line-2); border-radius: 1px; }
.dots .base { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--muted); }
.dots .dot { position: absolute; top: 5px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--up); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-2); }
.dots .dot.down { background: var(--down); }
.dots .val { font-weight: 650; }
.sample .alert { margin: 6px 0; }
.sample .alert .head { font-size: 13.5px; }

/* ---- tablets: two columns stay, tables shed the optional columns (see hide-md) -------- */
@media (max-width: 1100px) { .grid.cols-2 { grid-template-columns: 1fr 1fr; } }

/* ---- touch: targets at least 40px tall -------------------------------------------------- */
@media (pointer: coarse) {
  button, .btn, a.button, .presets a { min-height: 40px; }
  nav.main a { padding-top: 9px; padding-bottom: 9px; }
  .seg button { min-height: 32px; }
  .themes button { width: 26px; height: 26px; }
}

/* ---- phones: nothing wider than the screen, headline tiles two by two ------------------ */
@media (max-width: 760px) {
  html, body { overflow-x: hidden; }
  .top { flex-wrap: wrap; row-gap: 6px; padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  nav.main { order: 3; flex: 1 1 100%; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  nav.main::-webkit-scrollbar { display: none; }
  .card { overflow-x: auto; }
  table { min-width: 0; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .hero .cta form, .hero .cta .btn { flex: 1 1 auto; text-align: center; }
  .board { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .name { max-width: 120px; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tile { padding: 10px 12px; overflow: hidden; }
  .tile .label { font-size: 11px; } .tile .value { font-size: 19px; } .tile .value .unit { font-size: 12px; } .tile .delta { font-size: 12px; } .tile .note { font-size: 11.5px; }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .dots .dotrow { grid-template-columns: 1fr 48px; gap: 6px 10px; }
  .dots .lbl { grid-column: 1 / -1; }
  .dots .dotrow.ticks { grid-template-columns: 1fr 48px; } .dots .dotrow.ticks > div:first-child { display: none; }
  .legend { gap: 10px; font-size: 12px; }
  .facts { grid-template-columns: 1fr 1fr; }
  .rules .params label { width: 100%; }
}
@media (max-width: 400px) { .facts { grid-template-columns: 1fr; } .tile .value { font-size: 17px; } }
tr.repeat td { color: var(--muted); }
