/* Dark theme only. Text colors meet WCAG 2.1 AA (≥ 4.5:1) on every surface;
   control borders and focus rings meet the 3:1 non-text contrast rule. */
:root {
  color-scheme: dark;
  --bg: #0d1117; --panel: #151b24; --panel-2: #1b2330; --line: #263142;
  --control-border: #6b7a90;           /* 3:1+ against panels (form controls) */
  --fg: #e8ecf2; --muted: #9aa5b6; --gold: #d4a63a; --gold-soft: #d4a63a22;
  --up: #2fbf71; --down: #f47370; --neutral: #e0b341;
  --focus: #ffd666;
  --radius: 14px; --gap: 1rem;
  --font: "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, sans-serif;
  --num: "IBM Plex Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html { font-size: 100%; }                 /* respects the reader's own font-size setting */
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 1rem; line-height: 1.6; }
p, h1, h2, h3 { margin: 0; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 3rem; display: flex; flex-direction: column; gap: var(--gap); }
main { display: flex; flex-direction: column; gap: var(--gap); outline: none; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.up { color: var(--up); } .down { color: var(--down); } .neutral { color: var(--neutral); }
.gold { color: var(--gold); letter-spacing: 1px; }

/* Screen-reader only, and skip link */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 1rem; top: -4rem; z-index: 10; background: var(--gold); color: #1d1606; font-weight: 600; padding: .6rem 1rem; border-radius: 8px; text-decoration: none; }
.skip:focus { top: 1rem; }

/* Visible keyboard focus everywhere */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

header.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; }
.brand { display: flex; align-items: center; gap: .75rem; }
.mark { width: 40px; height: 40px; flex: none; border-radius: 10px; background: linear-gradient(135deg, #f3d27a, var(--gold) 55%, #8a6410); box-shadow: inset 0 -3px 0 #0003; }
.brand h1 { font-size: 1.25rem; font-weight: 600; line-height: 1.35; }
.brand p { font-size: .875rem; color: var(--muted); }
.controls { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; font-size: .875rem; }
.controls label { color: var(--muted); }
select, button { font: inherit; font-size: .875rem; color: var(--fg); background: var(--panel); border: 1px solid var(--control-border); border-radius: 8px; padding: .5rem .75rem; min-height: 44px; cursor: pointer; }
.badge { font-size: .8125rem; padding: 2px 10px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; align-self: flex-start; }
.warn { background: #e0b34122; border: 1px solid var(--neutral); color: var(--fg); padding: .65rem .9rem; border-radius: 10px; font-size: .9375rem; }
.warn[hidden] { display: none; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; min-width: 0; }
.card h2 { font-size: 1rem; font-weight: 600; margin-bottom: .25rem; }
.card .note { font-size: .8125rem; color: var(--muted); margin-bottom: .85rem; }

.hero { display: grid; grid-template-columns: 1.2fr 1fr 1fr 1fr; gap: var(--gap); }
.hero h2.lbl { font-size: .8125rem; font-weight: 500; color: var(--muted); }
.hero .big { font-size: 1.875rem; font-weight: 600; margin: .25rem 0; line-height: 1.3; }
.hero .sub { font-size: .875rem; }
.hero .key { font-size: 1.375rem; font-weight: 600; margin-top: .3rem; }
.hero .key .muted { font-size: .875rem; font-weight: 400; }
.bias-card { background: radial-gradient(120% 140% at 0% 0%, var(--gold-soft), transparent 60%), var(--panel); border-color: var(--gold); }
.bias-card .big { font-size: 2rem; }

.grid2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: var(--gap); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }

.tabs { display: flex; gap: .4rem; margin-bottom: .6rem; }
.tabs [role="tab"][aria-selected="true"] { background: var(--gold); color: #1d1606; border-color: var(--gold); font-weight: 600; }
.chart { position: relative; width: 100%; height: 380px; border-radius: 8px; }
.chart svg { display: block; width: 100%; height: 100%; }
.tip { position: absolute; display: none; pointer-events: none; background: var(--panel-2); border: 1px solid var(--control-border); border-radius: 8px; padding: .4rem .65rem; font-size: .8125rem; box-shadow: 0 6px 20px #0005; white-space: nowrap; z-index: 2; }
#chart-help { margin: .6rem 0 0; }
details.data { margin-top: .75rem; font-size: .875rem; }
details.data summary { cursor: pointer; color: var(--gold); padding: .4rem 0; min-height: 44px; display: flex; align-items: center; }
.tscroll { overflow-x: auto; }
caption { text-align: left; color: var(--muted); font-size: .8125rem; padding-bottom: .4rem; }

.scen { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .9rem; }
.scen .top { display: flex; justify-content: space-between; font-size: .9375rem; }
.scen .bar { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; margin: .35rem 0; }
.scen .bar span { display: block; height: 100%; border-radius: 5px; }
.scen .meta { font-size: .8125rem; color: var(--muted); }
.chief { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--line); font-size: .9375rem; white-space: pre-line; }
.chief h3 { font-size: .9375rem; color: var(--gold); margin-bottom: .3rem; }

.team { display: grid; grid-template-columns: repeat(5, 1fr); gap: .75rem; }
.expert { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: .9rem; display: flex; flex-direction: column; gap: .5rem; }
.expert .who { display: flex; align-items: center; gap: .6rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .8125rem; background: var(--gold-soft); color: var(--gold); border: 1px solid var(--gold); flex: none; }
.expert h3 { font-size: .875rem; font-weight: 600; line-height: 1.35; }
.expert .focus { font-size: .75rem; color: var(--muted); }
.meter { position: relative; height: 6px; background: var(--line); border-radius: 3px; margin: .25rem 0; }
.meter i { position: absolute; top: -3px; width: 12px; height: 12px; border-radius: 50%; transform: translateX(-50%); }
.meter::after { content: ""; position: absolute; left: 50%; top: -2px; width: 1px; height: 10px; background: var(--muted); }
.expert ul { margin: 0; padding-left: 1rem; font-size: .8125rem; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: .4rem .5rem .4rem 0; border-bottom: 1px solid var(--line); }
tbody th { color: var(--fg); font-weight: 600; }
td { padding: .45rem .5rem .45rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td, tr:last-child th { border-bottom: 0; }
td.r, th.r { text-align: right; }

footer { font-size: .8125rem; color: var(--muted); line-height: 1.7; }
.skeleton { color: transparent !important; background: var(--line); border-radius: 6px; }

@media (prefers-reduced-motion: no-preference) {
  .skeleton { animation: pulse 1.2s infinite; }
  @keyframes pulse { 50% { opacity: .5; } }
}
@media (max-width: 1000px) {
  .hero { grid-template-columns: 1fr 1fr; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .team { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .hero, .team { grid-template-columns: 1fr; }
  .chart { height: 300px; }
  .hero .big { font-size: 1.625rem; }
}
/* Windows High Contrast / forced colors */
@media (forced-colors: active) {
  .card, .expert, select, button { border: 1px solid CanvasText; }
  .tabs [role="tab"][aria-selected="true"] { outline: 2px solid Highlight; }
}

/* Entry / exit plans */
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.plan-tf h3 { font-size: 1rem; margin-bottom: .2rem; }
.plan-tf .basis { font-size: .8125rem; color: var(--muted); margin-bottom: .6rem; }
.setups { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .75rem; }
.setup { background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--neutral); border-radius: 10px; padding: .8rem .9rem; }
.setup.long { border-left-color: var(--up); }
.setup.short { border-left-color: var(--down); }
.setup.weak { opacity: .8; border-style: dashed; }
.setup header { display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.setup h4 { margin: 0; font-size: .9375rem; }
.setup dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem .75rem; margin: 0 0 .5rem; }
.setup dt { font-size: .75rem; color: var(--muted); }
.setup dd { margin: 0; font-family: var(--num); font-variant-numeric: tabular-nums; font-size: .9375rem; }
.setup p { font-size: .8125rem; color: var(--muted); margin: .15rem 0 0; }
.setup .warn-line { color: var(--neutral); }
@media (max-width: 1000px) { .plans { grid-template-columns: 1fr; } }
