/* ═══════════════════════════════════════════════════════════════════════════
   pages/themes.css — Themes, the "Signal Board". Loaded by themes/index.php.
   Colours only through the gs2 tokens (light + dark). Prefix: th-
   ═══════════════════════════════════════════════════════════════════════════ */

.th { padding-bottom: var(--sp-7); }
.th :is(h1, h2, h3), .th a { overflow-wrap: break-word; }

/* ── Board header ────────────────────────────────────────────────────────── */
.th-head {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); align-items: end; gap: var(--sp-4) var(--sp-6);
  margin: var(--sp-6) 0 var(--sp-4); padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--rule-strong); box-shadow: 0 3px 0 -2px var(--bg), 0 4px 0 -2px var(--rule-strong);
}
.th-head .gs2-kicker { margin-bottom: 10px; }
.th-head__title { font: 700 var(--fs-4xl)/1.02 var(--font-serif); letter-spacing: -.02em; margin: 0 0 10px; }
.th-head__sub { margin: 0; max-width: 62ch; font: 400 var(--fs-md)/1.5 var(--font-sans); color: var(--ink-2); }
.th-balance { display: flex; flex-direction: column; gap: 8px; }
.th-balance__bar { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; background: var(--surface-2); }
.th-balance__seg { min-width: 0; }
.th-balance__seg--pos { background: var(--pos); } .th-balance__seg--neg { background: var(--neg); } .th-balance__seg--neu { background: var(--neu); opacity: .45; }
.th-balance__k { display: flex; justify-content: space-between; gap: 10px; font: 500 var(--fs-xs)/1.2 var(--font-sans); }
.th-balance__k b { font-size: var(--fs-md); margin-right: 3px; }

/* ── Tools: sector chips + sort ──────────────────────────────────────────── */
.th-tools { display: flex; align-items: flex-start; gap: var(--sp-3) var(--sp-5); margin: 0 0 var(--sp-5); }
.th-filter { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 auto; min-width: 0; }
.th-filter .gs2-chip--active .gs2-chip__count { opacity: .8; }
.th-sort { display: flex; align-items: center; gap: 8px; flex: none; }
.th-sort__l { font: 600 var(--fs-xs)/1 var(--font-sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.th-sort .gs2-select { min-height: 40px; width: auto; padding-right: 32px; font-size: var(--fs-sm); }

/* ── Theme cards ─────────────────────────────────────────────────────────── */
.th-grid { display: grid; gap: var(--sp-5); grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
.th-card { position: relative; display: flex; flex-direction: column; min-width: 0; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg); overflow: hidden; transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
.th-card[hidden] { display: none; }
.th-card:hover { border-color: var(--ink-2); box-shadow: var(--shadow-1); }
.th-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; z-index: 2; background: var(--neu); opacity: .5; }
.th-card--pos::before { background: var(--pos); opacity: 1; } .th-card--neg::before { background: var(--neg); opacity: 1; }
.th-card__img { border-radius: 0; aspect-ratio: 2 / 1; }
.th-moreall { display: flex; justify-content: center; margin-top: var(--sp-5); }
.th-moreall[hidden] { display: none; }
.th-card__rank { position: absolute; left: 10px; top: 12px; padding: 3px 7px; border-radius: 4px; background: rgba(10, 11, 14, .72); color: #fff; font-size: 11px; font-weight: 600; }
.th-card__body { display: flex; flex-direction: column; gap: 10px; padding: var(--sp-4); flex: 1 1 auto; }
.th-card__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.th-card__top .gs2-kicker { margin: 0; }
.th-card__upd { font: 500 var(--fs-xs)/1 var(--font-sans); color: var(--muted); }
.th-card__title { font: 650 var(--fs-xl)/1.2 var(--font-serif); margin: 0; letter-spacing: -.008em; text-wrap: pretty; }
.th-card__title a { color: var(--ink); text-decoration: none; }
.th-card__title a::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.th-card:hover .th-card__title a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .15em; }
.th-card__signal { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.th-card__spark { display: inline-flex; align-items: center; gap: 6px; }
.th-card__7d { font: 600 10px/1 var(--font-mono); color: var(--muted); }
.th-card__sum { margin: 0; font: 400 var(--fs-sm)/1.5 var(--font-sans); color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.th-card__heads { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.th-card__heads li { position: relative; z-index: 2; display: flex; flex-direction: column; gap: 2px; padding-left: 12px; border-left: 2px solid var(--rule); }
.th-card__heads a { font: 500 var(--fs-sm)/1.35 var(--font-serif); color: var(--ink); text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.th-card__heads a:hover { text-decoration: underline; }
.th-card__heads span { font: 600 10px/1.2 var(--font-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.th-card__foot { display: flex; align-items: center; gap: 14px; margin-top: auto; padding-top: 4px; font: 500 var(--fs-xs)/1 var(--font-sans); color: var(--muted); }
.th-card__foot b { color: var(--ink); font-size: var(--fs-sm); margin-right: 2px; }
.th-card__more { margin-left: auto; font-weight: 650; color: var(--ink); }
.th-none, .th-empty { margin-top: var(--sp-5); }

/* ── Theme page ──────────────────────────────────────────────────────────── */
.th-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: var(--sp-5) 0 var(--sp-3); font: 500 var(--fs-sm)/1.3 var(--font-sans); color: var(--muted); }
.th-crumbs a { color: var(--ink-2); text-decoration: none; min-height: 32px; display: inline-flex; align-items: center; }
.th-crumbs a:hover { color: var(--ink); text-decoration: underline; }
.th-hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--sp-6); align-items: center; padding-bottom: var(--sp-5); border-bottom: 1px solid var(--rule-strong); }
.th-hero .gs2-kicker { margin-bottom: 10px; }
.th-hero__title { font: 700 clamp(2rem, 1.3rem + 2.4vw, 3rem)/1.06 var(--font-serif); letter-spacing: -.02em; margin: 0 0 var(--sp-4); text-wrap: balance; }
.th-hero__meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; font: 500 var(--fs-sm)/1.4 var(--font-sans); color: var(--muted); }
.th-hero__meta strong { color: var(--ink); font-family: var(--font-mono); font-weight: 600; }
.th-cooled { color: var(--neg); font-weight: 600; }
.th-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--sp-4); }
.th-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--sp-4); }
.th-follow[aria-pressed=true] { border-color: var(--pos); background: var(--pos-bg); color: var(--pos); }
.th-hero__img { border-radius: var(--radius-lg); }

.th-top { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--sp-6); margin: var(--sp-6) 0; align-items: start; }

/* chart */
.th-chart { margin: 0; padding: var(--sp-4) var(--sp-4) var(--sp-3); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg); min-width: 0; }
.th-chart__cap { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px 16px; margin-bottom: var(--sp-4); }
.th-chart__h { font: 700 12px/1.2 var(--font-sans); letter-spacing: .09em; text-transform: uppercase; color: var(--ink); }
.th-chart__legend { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; font: 500 var(--fs-xs)/1.2 var(--font-sans); color: var(--muted); }
.th-key { display: inline-block; vertical-align: middle; }
.th-key--line { width: 18px; height: 2px; background: var(--ink); margin-right: 2px; }
.th-key--dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); opacity: .7; margin: 0 2px 0 10px; }
.th-chart__plot { position: relative; height: 240px; margin: 0 0 26px 40px; }
.th-chart__plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.th-band--pos { fill: var(--pos-bg); opacity: .55; } .th-band--neg { fill: var(--neg-bg); opacity: .55; }
.th-gl { stroke: var(--rule); stroke-width: 1; vector-effect: non-scaling-stroke; }
.th-gl--zero { stroke: var(--muted); stroke-dasharray: 3 4; }
.th-gl--day { stroke-dasharray: 1 5; }
.th-dot { stroke: var(--neu); stroke-width: 8; stroke-linecap: round; vector-effect: non-scaling-stroke; opacity: .5; fill: none; }
.th-dot--pos { stroke: var(--pos); } .th-dot--neg { stroke: var(--neg); }
.th-dot:hover { opacity: 1; }
.th-line { fill: none; stroke: var(--ink); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.th-pt { stroke: var(--ink); stroke-width: 9; stroke-linecap: round; vector-effect: non-scaling-stroke; fill: none; }
.th-chart__y { position: absolute; left: -40px; width: 34px; transform: translateY(-50%); text-align: right; font-size: 11px; color: var(--muted); }
.th-chart__x { position: absolute; bottom: -22px; transform: translateX(-50%); font: 500 11px/1 var(--font-sans); color: var(--muted); white-space: nowrap; }
.th-chart__band { position: absolute; left: 8px; font: 700 10px/1 var(--font-sans); letter-spacing: .1em; text-transform: uppercase; opacity: .8; }
.th-chart__band--pos { top: 8px; color: var(--pos); } .th-chart__band--neg { bottom: 8px; color: var(--neg); }

.th-about { min-width: 0; }
.th-about__h { font: 700 12px/1.2 var(--font-sans) !important; letter-spacing: .09em; text-transform: uppercase; margin: 0 0 10px !important; padding-top: 8px; border-top: 3px solid var(--rule-strong); }
.th-about__p { font: 400 1.1875rem/1.6 var(--font-serif); color: var(--ink); margin: 0 0 10px; }
.th-about__note { font-size: var(--fs-xs); color: var(--muted); margin: 0 0 var(--sp-4); }
.th-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0; background: var(--rule); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.th-stats > div { background: var(--surface); padding: 12px 14px; }
.th-stats dt { font: 600 11px/1.2 var(--font-sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.th-stats dd { margin: 6px 0 0; font-size: var(--fs-2xl); font-weight: 600; color: var(--ink); line-height: 1; }

/* stories: list + preview */
.th-stories { margin-top: var(--sp-6); }
.th-split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--sp-6); align-items: start; }
.th-rows { list-style: none; margin: 0; padding: 0; }
.th-row { position: relative; display: grid; grid-template-columns: 96px minmax(0, 1fr) 110px; gap: var(--sp-4); align-items: center; padding: 12px 10px; margin: 0 -10px; border-bottom: 1px solid var(--rule); border-radius: var(--radius); }
.th-row:hover { background: var(--hover); }
.th-row.is-selected { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.th-row__img { border-radius: 4px; }
.th-row__t { display: block; font: 600 var(--fs-md)/1.3 var(--font-serif); color: var(--ink); text-decoration: none; }
.th-row__t::after { content: ""; position: absolute; inset: 0; }
.th-row:hover .th-row__t { text-decoration: underline; text-underline-offset: .15em; }
.th-row__m { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 5px; font: 500 var(--fs-xs)/1.3 var(--font-sans); color: var(--muted); }
.th-row__s { font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; }
.th-row__score { display: flex; flex-direction: column; align-items: stretch; gap: 6px; text-align: right; }
.th-row__n { font-size: var(--fs-md); font-weight: 600; }
.th-row__ns { font-size: var(--fs-xs); color: var(--muted); font-style: italic; }
.th-preview { position: sticky; top: var(--sp-4); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg); overflow: hidden; }
.th-preview__img { border-radius: 0; }
.th-preview__body { display: flex; flex-direction: column; gap: 12px; padding: var(--sp-4); }
.th-preview__m { display: flex; gap: 10px; font: 500 var(--fs-xs)/1.3 var(--font-sans); color: var(--muted); }
.th-preview__s { font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; }
.th-preview__t { font: 650 var(--fs-xl)/1.2 var(--font-serif); margin: 0; }
.th-preview__d { margin: 0; font: 400 var(--fs-sm)/1.55 var(--font-sans); color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.th-preview__d:empty { display: none; }
.th-preview__score { display: flex; align-items: center; gap: 12px; }
.th-preview__score .gs2-scorebar { flex: 1 1 auto; }
.th-preview__tk { display: flex; flex-wrap: wrap; gap: 6px; }
.th-preview__tk:empty { display: none; }

/* related */
.th-more { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: var(--sp-6); margin-top: var(--sp-7); }
.th-more__col:only-child { grid-column: 1 / -1; }
.th-mini, .th-rel { list-style: none; margin: 0; padding: 0; }
.th-mini li { padding: 10px 0; border-top: 1px solid var(--rule); }
.th-mini li:first-child { border-top: 0; padding-top: 0; }
.th-mini a, .th-rel__t { display: block; font: 600 var(--fs-md)/1.3 var(--font-serif); color: var(--ink); text-decoration: none; }
.th-mini a:hover, .th-rel__t:hover { text-decoration: underline; }
.th-mini__m, .th-rel__m { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-top: 6px; font: 500 var(--fs-xs)/1.2 var(--font-sans); color: var(--muted); }
.th-rel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.th-rel__i { padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--radius-lg); background: var(--surface); }
.th-missing { max-width: 560px; margin: var(--sp-8) auto; text-align: center; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1100px) { .th-split { grid-template-columns: minmax(0, 1fr) 320px; } }
@media (max-width: 960px) {
  .th-hero, .th-top, .th-more { grid-template-columns: minmax(0, 1fr); }
  .th-hero__img { order: -1; }
  .th-split { grid-template-columns: minmax(0, 1fr); }
  .th-preview { display: none; }
  .th-row.is-selected { background: none; box-shadow: none; }
}
@media (max-width: 899px) {
  .th-head { grid-template-columns: minmax(0, 1fr); margin-top: var(--sp-5); }
  .th-tools { flex-direction: column; align-items: stretch; }
  .th-filter { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 2px var(--gutter); -webkit-mask-image: linear-gradient(90deg, #000 90%, transparent); mask-image: linear-gradient(90deg, #000 90%, transparent); }
  .th-filter::-webkit-scrollbar { display: none; }
  .th-sort .gs2-select { flex: 1 1 auto; }
}
@media (max-width: 600px) {
  .th-head__title { font-size: clamp(2rem, 1.4rem + 3vw, 2.6rem); }
  .th-row { grid-template-columns: 76px minmax(0, 1fr); gap: var(--sp-3); }
  .th-row__score { grid-column: 2; flex-direction: row; align-items: center; text-align: left; }
  .th-row__score .gs2-scorebar { flex: 1 1 auto; max-width: 140px; }
  .th-chart { padding: var(--sp-3); }
  .th-chart__plot { height: 190px; margin-left: 34px; }
  .th-chart__y { left: -34px; width: 28px; font-size: 10px; }
  .th-chart__x { font-size: 10px; }
  .th-chart__x:nth-of-type(even) { }
  .th-rel { grid-template-columns: minmax(0, 1fr); }
  .th-actions .gs2-btn { flex: 1 1 auto; }
}
@media (max-width: 600px) { .th-card__heads { display: none; } .th-card__sum { -webkit-line-clamp: 2; } }
@media (max-width: 420px) { .th-chart__x { font-size: 9.5px; letter-spacing: -.01em; } }
