/*
 * Layout and components. No colour literal here: every colour is a variable
 * from theme.css (TD-SET-2, checked by test/theme.test.js). Shapes and sizes
 * follow the approved prototype (tools/design/prototype/).
 */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--sans); }
/* Safari draws its own chrome on a button unless told not to (WeatherBlocksFE). */
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-appearance: none; appearance: none; }
a { color: inherit; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Loading screen, removed by main.js as soon as the shell has drawn. */
#boot { position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; justify-items: center; gap: 12px; background: var(--bg); color: var(--ink-3); font-size: 14px; }
#boot img { border-radius: 22px; }

/* Top bar (TD-SHL-1) */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--bar);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  padding-top: env(safe-area-inset-top); border-bottom: 1px solid transparent; }
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar-inner { max-width: var(--col); margin: 0 auto; height: var(--bar-h); padding: 0 16px; display: flex; align-items: center; justify-content: space-between; }
.wordmark { font: 700 22px/1 var(--serif); letter-spacing: -0.01em; }
.topbar-actions { display: flex; gap: 4px; }

/* The two timelines' tabs (TD-TAB-1) */
.tabs { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--line); }
.tabs button { padding: 5px 13px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.tabs button[aria-selected='true'] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); }
.icon-btn:hover { background: var(--line); }

/* Notes under the top bar (TD-NET-7, TD-ACC-2) */
.note { max-width: var(--col); margin: 0 auto; padding: 6px 16px; font-size: 13px; color: var(--ink-3); text-align: center; pointer-events: none; }
.no-access { max-width: var(--col); margin: 8px auto 0; padding: 12px 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between;
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; }
.no-access button { font-weight: 700; color: var(--accent-text); white-space: nowrap; }

/* Timeline */
.timeline { max-width: var(--col); margin: 0 auto; padding: 4px 12px calc(96px + env(safe-area-inset-bottom)); }
.edition-section { contain: layout; }
.edition { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 28px 6px 12px; }
.edition h2 { margin: 0; font: 600 20px/1.2 var(--serif); }
.edition .meta { color: var(--ink-3); font-size: 13px; white-space: nowrap; }
.edition.empty { padding-bottom: 4px; }
.edition-empty-note { margin: 0 6px 8px; color: var(--ink-3); font-size: 14px; }

/* Also in the news, ending an edition (TD-TL-13 to TD-TL-15) */
.also { margin: 6px 6px 4px; }
.also-head { display: flex; align-items: center; gap: 6px; width: 100%; padding: 10px 0; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.also-head .icon { width: 16px; height: 16px; transform: rotate(-90deg); transition: transform 0.2s; }
.also-head[aria-expanded='true'] .icon { transform: none; }
.also-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.also-list a { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.also-title { font-size: 15px; line-height: 1.35; }
.also-src { flex: none; color: var(--ink-3); font-size: 13px; white-space: nowrap; }
.also-more { padding: 10px 0; font-size: 14px; font-weight: 600; color: var(--accent-text); }
.also-note { margin: 0 0 8px; color: var(--ink-3); font-size: 13px; }
.end { text-align: center; color: var(--ink-3); font-size: 13px; padding: 24px 0; }
.loading-more { text-align: center; color: var(--ink-3); font-size: 13px; padding: 16px 0; }

/* Cards (TD-TL-7 to TD-TL-12) */
.card { position: relative; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  margin: 0 0 14px; overflow: hidden; transition: opacity 0.4s, height 0.35s ease, margin 0.35s ease; }
/* The card's edge, drawn over its content rather than as a border, so it frames the
   picture too and no card changes size (the collapse, the masonry and the 900 px grid
   measure cards). Without it a dark-theme card has no edge at all (`--shadow: none`,
   and the surface is barely apart from the page), and a picture such as a site's logo
   card read as an advertisement between two stories (2026-10-19, TD-TL-18). */
.card::after { content: ''; position: absolute; inset: 0; border: 1px solid var(--card-edge); border-radius: inherit;
  pointer-events: none; z-index: 3; }
.card-media { display: block; aspect-ratio: 16 / 9; background: var(--image-wait); overflow: hidden; position: relative; }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: filter 0.4s; }
.play { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  background: var(--scrim); display: grid; place-items: center; color: var(--toast-ink); }
.play .icon { width: 24px; height: 24px; fill: currentColor; stroke: none; margin-left: 3px; }
.duration { position: absolute; right: 10px; bottom: 10px; background: var(--toast-bg); color: var(--toast-ink); font-size: 12px; font-weight: 600; padding: 2px 6px; border-radius: 5px; font-variant-numeric: tabular-nums; }
.card-body { padding: 12px 16px 6px; }
.card.no-image { background: var(--source-tint); }
.card.no-image .card-body { padding-top: 16px; }
.card.no-image .card-title { font-size: 23px; }

.card-meta { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); min-height: 22px; }
.mono { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; flex: none;
  font: 700 11px/1 var(--sans); color: var(--pill-ink); background: var(--source-mono); }
.src { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sep, .time, .reporters { color: var(--ink-3); white-space: nowrap; }
.chip { margin-left: auto; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; color: var(--accent-text);
  border: 1px solid var(--accent-text); border-radius: 999px; padding: 1px 8px; white-space: nowrap; opacity: 0.9; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; margin-left: auto; }
.chip + .unread-dot { margin-left: 0; }

.card-title { margin: 6px 0 4px; font: 600 20px/1.25 var(--serif); letter-spacing: -0.005em; text-wrap: pretty; }
.card-desc { margin: 0 0 6px; color: var(--ink-2); font-size: 15px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-desc.whole { display: block; overflow: visible; }

.card-foot { display: flex; align-items: center; justify-content: space-between; min-height: 40px; margin-top: 4px; }
.more-sources { font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 8px 0; display: inline-flex; align-items: center; gap: 4px; }
.more-sources .icon { width: 16px; height: 16px; transition: transform 0.2s; }
.more-sources[aria-expanded='true'] .icon { transform: rotate(180deg); }
.menu-btn { width: 40px; height: 40px; margin-right: -10px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-3); }
.menu-btn:hover { background: var(--line); color: var(--ink); }
.foot-spacer { flex: 1; }

.cluster { list-style: none; margin: 0 0 10px; padding: 4px 0 0; border-top: 1px solid var(--line); }
.cluster a { display: flex; align-items: center; gap: 10px; padding: 9px 0; text-decoration: none; font-size: 15px; }
.cluster .mono { width: 18px; height: 18px; font-size: 10px; }
.cluster .host { margin-left: auto; color: var(--ink-3); font-size: 13px; }
.cluster .icon { width: 16px; height: 16px; color: var(--ink-3); }

/* Read state (TD-RS-4) */
.card.seen .card-title { color: var(--ink-2); }
.card.read { opacity: 0.58; }
.card.read .card-media img { filter: saturate(0.45); }
.card.read:hover { opacity: 1; }

.card-hit { position: absolute; inset: 0; z-index: 1; }
.card-foot, .cluster { position: relative; z-index: 2; }

/* Collapsed by an action (TD-ACT-3) */
.strip { display: flex; align-items: center; gap: 12px; padding: 12px 16px; font-size: 14px; color: var(--ink-2); }
.strip strong { color: var(--ink); font-weight: 600; }
.strip .undo { margin-left: auto; font-weight: 700; color: var(--accent-text); padding: 4px 2px; }
.card.collapsing { background: transparent; box-shadow: none; }

/* Caught up (TD-RES-5) */
.caught-up { text-align: center; padding: 28px 0 18px; color: var(--ink-2); }
.caught-up .tick { width: 44px; height: 44px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.caught-up strong { display: block; font: 600 18px/1.3 var(--serif); color: var(--ink); }
.caught-up span { font-size: 13px; color: var(--ink-3); }

/* New-stories pill (TD-RES-4) */
.new-pill { position: fixed; z-index: 25; left: 50%; transform: translateX(-50%); top: calc(var(--bar-h) + 10px + env(safe-area-inset-top));
  background: var(--pill-bg); color: var(--pill-ink); font-weight: 600; font-size: 14px; padding: 8px 14px 8px 10px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px; box-shadow: 0 6px 20px var(--scrim); animation: pill-in 0.25s ease; }
.new-pill .icon { width: 18px; height: 18px; stroke-width: 2.2; }
@keyframes pill-in { from { opacity: 0; transform: translate(-50%, -8px); } }

/* Toasts (TD-ACT-4) */
.toast-host { position: fixed; z-index: 40; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom)); display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { pointer-events: auto; background: var(--toast-bg); color: var(--toast-ink); border-radius: 12px; padding: 11px 14px 11px 16px; font-size: 14px;
  display: flex; gap: 16px; align-items: center; max-width: 520px; width: 100%; box-shadow: 0 8px 28px var(--scrim); animation: toast-in 0.2s ease; }
.toast button { font-weight: 700; color: var(--accent); margin-left: auto; }
.toast.out { opacity: 0; transform: translateY(8px); transition: 0.2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Action sheet (TD-ACT-1, TD-ACT-2, TD-ACT-8) */
.scrim { position: fixed; inset: 0; z-index: 30; background: var(--scrim); animation: fade 0.2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: fixed; z-index: 31; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 520px; background: var(--surface);
  border-radius: 20px 20px 0 0; padding: 8px 8px calc(12px + env(safe-area-inset-bottom)); animation: sheet-in 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
  max-height: 90vh; overflow-y: auto; }
@media (min-width: 700px) { .sheet { bottom: 24px; border-radius: 20px; box-shadow: 0 12px 40px var(--scrim); } }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
.grabber { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 2px auto 10px; }
.sheet-head { padding: 0 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.sheet-head .t { font: 600 16px/1.3 var(--serif); margin: 0 0 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.why-box { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font-size: 13px; color: var(--ink-2); }
.why-box .line { color: var(--ink); margin-bottom: 6px; }
.factors { display: flex; flex-wrap: wrap; gap: 6px; }
.factor { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.factor.up { color: var(--accent-text); }
.factor.down { color: var(--warn-text); }
.sheet-action { width: 100%; display: flex; align-items: center; gap: 14px; padding: 13px 12px; border-radius: 12px; text-align: left; font-size: 16px; }
.sheet-action:hover, .sheet-action:focus-visible { background: var(--surface-2); }
.sheet-action .icon { color: var(--ink-2); }
.sheet-action small { display: block; color: var(--ink-3); font-size: 13px; }

/* Panels: full-screen over the timeline, which keeps its scroll underneath (TD-SHL-2). */
.panel { position: fixed; inset: 0; z-index: 35; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch; animation: panel-in 0.22s ease; }
@keyframes panel-in { from { transform: translateX(24px); opacity: 0; } }
.panel-inner { max-width: var(--col); margin: 0 auto; padding: calc(8px + env(safe-area-inset-top)) 16px calc(48px + env(safe-area-inset-bottom)); }
.panel-top { display: flex; align-items: center; gap: 8px; height: var(--bar-h); }
.panel-top h1 { font: 700 22px/1 var(--serif); margin: 0; }
.panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); margin: 26px 4px 8px; }
.panel .lead { color: var(--ink-3); font-size: 14px; margin: 6px 4px 0; }
.panel .status { color: var(--ink-3); font-size: 14px; padding: 12px 4px; }
.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.row:last-child { border-bottom: 0; }
.row .name { flex: 1; min-width: 0; }
.row .name small { display: block; color: var(--ink-3); font-size: 12px; }
.row .value { color: var(--ink-2); font-variant-numeric: tabular-nums; font-size: 14px; }
.weight { width: 110px; flex: none; height: 6px; background: var(--line); border-radius: 3px; position: relative; }
.weight i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.weight i.up { background: var(--accent); }
.weight i.down { background: var(--warn); }
.weight::after { content: ''; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--ink-3); }
.wnum { width: 46px; text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; color: var(--ink-2); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg + .seg { margin-top: 8px; }
.seg button:disabled { opacity: 0.4; cursor: default; }
.seg button { padding: 9px 0; border-radius: 9px; font-size: 15px; color: var(--ink-2); }
.seg button[aria-pressed='true'] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.row-link { color: var(--accent-text); font-weight: 600; }

/* Reader (TD-RD-1 to TD-RD-9): a full-screen layer with its own scroll. */
.reader { position: fixed; inset: 0; z-index: 33; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch; animation: panel-in 0.2s ease; }
.reader-top { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px; height: calc(var(--bar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0; background: var(--bar); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--line); }
.reader-source { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-inner { max-width: 680px; margin: 0 auto; padding: 0 20px calc(64px + env(safe-area-inset-bottom)); }
.reader-lead { display: block; width: calc(100% + 40px); margin: 0 -20px; aspect-ratio: 16 / 9; object-fit: cover; background: var(--image-wait); }
@media (min-width: 720px) { .reader-lead { width: 100%; margin: 20px 0 0; border-radius: var(--radius); } }
.reader-video { position: relative; margin: 0 -20px; aspect-ratio: 16 / 9; background: var(--toast-bg); }
.reader-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
@media (min-width: 720px) { .reader-video { margin: 20px 0 0; border-radius: var(--radius); overflow: hidden; } }
.reader-title { font: 700 28px/1.2 var(--serif); letter-spacing: -0.01em; margin: 20px 0 8px; text-wrap: pretty; }
.reader-byline { color: var(--ink-3); font-size: 14px; margin: 0 0 20px; }
.reader-short { margin: 0 0 24px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--card-edge); border-radius: 12px; }
.reader-short h2 { margin: 0 0 6px; font: 600 12px/1.3 var(--sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.reader-short p { margin: 0; font-size: 16px; line-height: 1.55; color: var(--ink); }
.reader-lede { font-size: 19px; line-height: 1.5; color: var(--ink-2); }
.reader-note { color: var(--ink-3); font-size: 15px; padding: 12px 14px; background: var(--surface-2); border-radius: 12px; }
.reader-text { font: 19px/1.62 var(--serif); }
.reader-text p { margin: 0 0 1em; }
.reader-text h2 { font: 700 22px/1.3 var(--serif); margin: 1.4em 0 0.5em; }
.reader-text h3 { font: 700 19px/1.3 var(--serif); margin: 1.2em 0 0.4em; }
.reader-text blockquote { margin: 1.2em 0; padding: 0 0 0 16px; border-left: 3px solid var(--accent); color: var(--ink-2); font-style: italic; }
.reader-text ul, .reader-text ol { margin: 0 0 1em; padding-left: 1.3em; }
.reader-text li { margin: 0.25em 0; }
.reader-text figure { margin: 1.4em 0; }
.reader-text figure img { display: block; width: 100%; border-radius: 10px; background: var(--image-wait); }
.reader-text figcaption { color: var(--ink-3); font: 14px/1.4 var(--sans); margin-top: 6px; }
/* A table wider than the text scrolls sideways on its own, its first column staying in view (TD-RD-10). */
.reader-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.reader-table table { border-collapse: separate; border-spacing: 0; min-width: 100%; font: 15px/1.35 var(--sans); font-variant-numeric: tabular-nums; }
.reader-table th, .reader-table td { min-width: 7em; padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.reader-table thead th { font-weight: 600; color: var(--ink-2); vertical-align: bottom; border-bottom-width: 2px; }
.reader-table tr > :first-child { position: sticky; left: 0; z-index: 1; min-width: 8em; padding-left: 0; background: var(--bg); }
.reader-table .figure { text-align: right; }
.reader-table td.figure { min-width: 0; white-space: nowrap; }
.reader-end { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); display: grid; gap: 12px; justify-items: start; }
.reader-site { padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line); font-weight: 600; font-size: 15px; background: var(--surface); }
.reader-also { color: var(--ink-3); font-size: 14px; margin: 0; }
.reader-also a { color: var(--ink-2); }

/* Insight (TD-INS-1 to TD-INS-6) and How feedback counts (TD-LRN-1 to TD-LRN-4) */
.insight-note { display: flex; gap: 12px; align-items: center; justify-content: space-between; background: var(--surface); border-radius: 12px;
  padding: 12px 14px; margin: 0 0 8px; font-size: 15px; box-shadow: var(--shadow); }
.insight-note.faded { border-left: 3px solid var(--warn); }
.insight-note.mostRead { border-left: 3px solid var(--accent); }
.spark { flex: none; overflow: visible; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linejoin: round; }
.spark-mid { stroke: var(--line); stroke-width: 1; }
.insight-head { display: flex; align-items: center; gap: 10px; margin: 12px 4px; }
.insight-head h2 { margin: 0; font: 700 22px/1.2 var(--serif); }
.insight-head small { color: var(--ink-3); }
.weight-control { display: flex; align-items: center; gap: 14px; background: var(--surface); border-radius: 12px; padding: 14px; box-shadow: var(--shadow); }
.weight-slider { flex: 1; accent-color: var(--accent); }
.wnum.big { font-size: 20px; width: 64px; color: var(--ink); }
.panel .vd-actions { margin-top: 12px; }
.learning-row .num { width: 76px; padding: 6px 8px; font: inherit; font-variant-numeric: tabular-nums; text-align: right;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--ink); }
.learning-row .row-link { width: 96px; text-align: right; font-size: 13px; }
.learning-row .row-link:disabled { color: var(--ink-3); font-weight: 400; cursor: default; }
.read-only { margin: 16px 4px 0; }
.panel select { font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.panel input[type='checkbox'] { width: 22px; height: 22px; accent-color: var(--accent); }

/* Version dialog (TD-UPD-1 to TD-UPD-5) */
.vd { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: var(--scrim); padding: 16px; }
.vd-panel { background: var(--surface); border-radius: 16px; padding: 20px; max-width: 360px; width: 100%; box-shadow: var(--shadow); }
.vd-message { margin: 0 0 6px; font-size: 16px; }
.vd-countdown { margin: 0 0 12px; color: var(--ink-3); font-size: 13px; }
.vd-actions { display: flex; gap: 8px; justify-content: flex-end; }
.pill { padding: 9px 16px; border-radius: 999px; font-weight: 600; font-size: 15px; }
.vd-primary { background: var(--pill-bg); color: var(--pill-ink); }
.vd-secondary { color: var(--ink-2); }

/* Columns, in masonry (TD-LAY-1 to TD-LAY-4). The column count is published on
   the root element by the timeline view; the page widens with it. */
:root[data-columns='2'] { --col: 860px; }
:root[data-columns='3'] { --col: 1240px; }
.cards.masonry { display: flex; gap: 14px; align-items: flex-start; }
.cards.masonry .col { flex: 1 1 0; min-width: 0; }
:root:not([data-columns='1']) .card-title { font-size: 18px; }
:root:not([data-columns='1']) .card.no-image .card-title { font-size: 20px; }
:root:not([data-columns='1']) .card-desc { font-size: 14px; }
/* A narrow column cannot hold source, age and tag on one line: let it wrap
   rather than squeeze the source's name to nothing. */
:root:not([data-columns='1']) .card-meta { flex-wrap: wrap; row-gap: 4px; }
:root:not([data-columns='1']) .card-meta .src { flex: 0 1 auto; min-width: 0; }

/* Desktop in one column: a wider column, the image beside the text (TD-SHL-3, TD-TL-7). */
@media (min-width: 900px) {
  :root { --col: 760px; }
  :root[data-columns='1'] .card:not(.no-image):not(.collapsing) { display: grid; grid-template-columns: 300px 1fr; align-items: stretch; }
  :root[data-columns='1'] .card:not(.no-image) .card-media { aspect-ratio: auto; height: 100%; min-height: 200px; }
  :root[data-columns='1'] .card-body { padding: 14px 18px 6px; }
  :root[data-columns='1'] .card-title { font-size: 21px; }
}

/* The Tree tab (SPEC §2.15, TD-TREE-2 to TD-TREE-6) */
/* One reading column whatever the timelines' column count, which widens --col. */
.tree { max-width: 760px; margin: 0 auto; padding: 4px 16px calc(96px + env(safe-area-inset-bottom)); }
.tree-title { margin: 14px 0 2px; font: 700 26px/1.2 var(--serif); }
.tree-sub { margin: 0 0 8px; color: var(--ink-3); font-size: 13px; }
.tree h2 { margin: 22px 0 8px; font: 700 19px/1.25 var(--serif); }
.tree .status { color: var(--ink-3); font-size: 14px; padding: 12px 0; }
.tree-rising { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.tree-rising button { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; max-width: 100%; padding: 8px 12px;
  border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); text-align: left; }
.tree-rising-name { font-weight: 600; font-size: 15px; color: var(--ink); }
.tree-rising-path { font-size: 12px; color: var(--ink-3); }
.tree-rising-path:empty { display: none; }
.tree-rising .tree-tag { margin-top: 3px; }
.tree-list { list-style: none; margin: 0; padding: 0; }
.tree-thread { border-top: 1px solid var(--line); }
.tree-list .tree-list { margin-left: 14px; }
.tree-list .tree-list .tree-thread:first-child { border-top: none; }
.tree-row { display: grid; grid-template-columns: minmax(0, 1fr) 64px 34px 56px; align-items: center; gap: 8px; width: 100%;
  padding: 11px 0; text-align: left; color: var(--ink); }
.depth-0 > .tree-row .tree-name { font-weight: 650; font-size: 16px; }
.tree-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 15px; min-width: 0; }
.tree-tag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--line); color: var(--ink-2); }
.tree-tag.new, .tree-tag.rising { background: var(--accent-soft); color: var(--accent-text); }
.tree-tag.fading { color: var(--ink-3); }
.tree-bar { display: block; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.tree-bar > span { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.tree-bar.thin { height: 4px; }
.tree-count { font-size: 13px; color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }
.tree-spark { width: 100%; overflow: hidden; }
.tree-spark path { vector-effect: non-scaling-stroke; }
.tree-body { padding: 0 0 12px; }
.tree-summary { margin: 0 0 8px; font: 16px/1.5 var(--serif); color: var(--ink); }
.tree-perspectives { margin: 0 0 10px; font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.tree-perspectives strong { color: var(--ink); font-weight: 600; }
.tree-regions { margin: 4px 0 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface); }
.tree-regions h3 { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.tree-region { display: grid; grid-template-columns: 104px minmax(0, 1fr) 72px; gap: 8px; align-items: center; font-size: 13px; padding: 2px 0; }
.tree-region-name { color: var(--ink-2); }
.tree-region-share { text-align: right; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tree-lean { margin: 6px 0 0; font-size: 13px; color: var(--ink-2); }
.tree-headlines { list-style: none; margin: 0 0 6px; padding: 0; }
.tree-headlines li { padding: 5px 0; display: flex; flex-direction: column; gap: 1px; }
.tree-headlines a { color: var(--ink); text-decoration: none; font-size: 15px; line-height: 1.35; }
.tree-headlines a:hover { text-decoration: underline; }
.tree-meta { font-size: 12px; color: var(--ink-3); }
.tree-foot { margin: 28px 0 0; font-size: 12px; line-height: 1.45; color: var(--ink-3); }
@media (max-width: 420px) {
  .tree-row { grid-template-columns: minmax(0, 1fr) 40px 30px 44px; gap: 6px; }
  .tree-region { grid-template-columns: 92px minmax(0, 1fr) 64px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
