/* Crisis Stability Calculator. Built on shared/css/tsm.css tokens only. */
.stage { position: relative; --sa: var(--c1); --sb: var(--c2); }
.panel { --sa: var(--c1); --sb: var(--c2); }
.card { padding: 12px 14px; }
.nbanner { margin: 0; font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.nbanner .notional { flex: none; }
.ca { color: var(--sa); } .cb { color: var(--sb); }

/* Headline card */
.headcard { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.head-l { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.prob { width: 100%; max-width: 220px; height: auto; display: block; }
.head-r { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.head-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; align-items: end; }
.head-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.idx { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.idx b { font-family: var(--display); font-size: 40px; line-height: 1; color: var(--ink); margin-right: 6px; }
.costwrap table { font-size: 13px; }
.costwrap td.num { text-align: right; font-size: 14px; }
.costwrap th.ca, .costwrap th.cb { text-align: right; }
.costwrap tr.ratio td, .costwrap tr.ratio th { font-weight: 600; border-bottom: 0; }
.pd-all { fill: color-mix(in srgb, var(--bad) 10%, transparent); stroke: var(--rule); }
.pd-a { fill: color-mix(in srgb, var(--good) 40%, transparent); stroke: var(--good); stroke-width: 1.5; }
.pd-la { stroke: var(--sa); stroke-width: 2; }
.pd-lb { stroke: var(--sb); stroke-width: 2; stroke-dasharray: 6 3; }
.pd-t { font: 600 13px var(--body); fill: var(--ink); }
.pd-ax { font: 500 11px var(--mono); }
.pd-ax-a { fill: var(--sa); } .pd-ax-b { fill: var(--sb); }
.pd-cap { font: 500 10px var(--body); fill: var(--muted); }

/* Charts */
.chartcard { display: flex; flex-direction: column; gap: 6px; }
.chart-h { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: space-between; align-items: center; }
.chart { width: 100%; height: auto; display: block; touch-action: pan-y; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 5px; }
.legend .sw { display: inline-block; width: 12px; height: 10px; border-radius: 2px; }
.legend .sa { background: var(--sa); } .legend .sb { background: var(--sb); }
.legend .ln { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--ink); }
.legend .la { border-top: 1.5px solid color-mix(in srgb, var(--sa) 70%, transparent); }
.legend .lb { border-top: 1.5px dashed color-mix(in srgb, var(--sb) 80%, transparent); }
.legend .dda { border-top: 3px solid var(--sa); } .legend .ddb { border-top: 3px solid var(--sb); }
.legend .sboth { border-top: 3px solid var(--ink); } .legend .sa2 { border-top: 2px solid var(--sa); }
.legend .sb2 { border-top: 2px dashed var(--sb); } .legend .scur { border-top: 2px solid var(--accent); }
.chart .plotbg { fill: var(--panel); }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .ax-t { font: var(--axis-font); fill: var(--axis-ink); }
.chart .ax-l { font: 500 11.5px var(--body); fill: var(--muted); }
.chart .cl { fill: none; stroke-width: 1.1; }
.chart .cl-a { stroke: color-mix(in srgb, var(--sa) 55%, transparent); }
.chart .cl-b { stroke: color-mix(in srgb, var(--sb) 65%, transparent); stroke-dasharray: 4 3; }
.chart .cl-one { stroke-width: 2; }
.chart .cl-t { font: 500 10.5px var(--mono); paint-order: stroke; stroke: var(--panel); stroke-width: 3px; }
.chart .cl-t-a { fill: var(--sa); } .chart .cl-t-b { fill: var(--sb); }
.chart .dd { fill: none; stroke-width: 3; stroke-linejoin: round; }
.chart .dd-a { stroke: var(--sa); } .chart .dd-b { stroke: var(--sb); }
.chart .invpt { fill: var(--ink); }
.chart .stop { stroke: var(--panel); stroke-width: 2.5; }
.chart .stop-a { fill: var(--sa); } .chart .stop-b { fill: var(--sb); }
.chart .stop-t { font: 600 12px var(--body); paint-order: stroke; stroke: var(--panel); stroke-width: 4px; }
.chart .stop-t-a { fill: var(--sa); } .chart .stop-t-b { fill: var(--sb); }
.chart .hov { fill: none; stroke-width: 2.5; }
.chart .hov-a { stroke: var(--sa); } .chart .hov-b { stroke: var(--sb); }
.chart .swl { fill: none; stroke-width: 2; }
.chart .swl.sw-both { stroke: var(--ink); stroke-width: 3; }
.chart .swl.sw-a { stroke: var(--sa); }
.chart .swl.sw-b { stroke: var(--sb); stroke-dasharray: 6 4; }
.chart .swd.sw-both { fill: var(--ink); } .chart .swd.sw-a { fill: var(--sa); } .chart .swd.sw-b { fill: var(--sb); }
.chart .cur { stroke: var(--accent); stroke-width: 2; }
.chart .cur-h { fill: var(--accent); stroke: var(--panel); stroke-width: 2; }
.hover { margin: 0; font-size: 12.5px; color: var(--muted); min-height: 2.8em; }
.hover b { color: var(--ink); font-weight: 600; }

/* Segmented buttons and tabs */
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button { font-size: 12px; padding: 5px 9px; border: 1px solid var(--rule); background: transparent; border-radius: 3px; cursor: pointer; font-weight: 500; }
.seg button:hover { border-color: var(--muted); }
.seg button[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-soft); }
.tabs button { flex: 1; font-size: 13px; font-weight: 600; padding: 7px 9px; }
.tabs .ta[aria-pressed="true"] { border-color: var(--sa); background: color-mix(in srgb, var(--sa) 14%, transparent); color: var(--ink); }
.tabs .tb[aria-pressed="true"] { border-color: var(--sb); background: color-mix(in srgb, var(--sb) 14%, transparent); color: var(--ink); }
.sliders { display: flex; flex-direction: column; gap: 10px; border-left: 3px solid var(--sa); padding-left: 10px; }
.sliders[data-side="B"] { border-left-color: var(--sb); }
.sliders .slider input { accent-color: var(--sa); }
.sliders[data-side="B"] .slider input { accent-color: var(--sb); }
.choices small { color: var(--muted); font-size: 11.5px; }
.choices b { font-weight: 600; }
.rule-h { margin: 0; font-weight: 600; font-size: 13px; }
.readout dd { text-align: right; }

/* Below */
.below h2.mt { margin-top: 22px; }
.lit p { font-size: 13.5px; }
.chartcard .tsm-export { margin-top: 4px; }

@media (max-width: 640px) {
  .headcard { grid-template-columns: minmax(0, 1fr); }
  .head-l { flex-direction: row; justify-content: center; gap: 12px; }
  .prob { max-width: 190px; }
  .head-l .legend { flex-direction: column; }
  .idx b { font-size: 32px; }
  .choices { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
.chart .curtick-a { fill: var(--sa); } .chart .curtick-b { fill: var(--sb); }
.chart .curtick-t { font: 600 11px var(--body); paint-order: stroke; stroke: var(--panel); stroke-width: 3px; }
.pnote { border-left: 3px solid var(--warn); padding-left: 8px; }

/* ---- Trailer graphics (Interactive Deterrence games only) ---- */
:root[data-skin="trailer"] {
  --c1: #7fb6d9; --c2: #ff8a3d; --c3: #2cc2ac; --c4: #d77ab0; --c5: #efc12f; --c6: #a68ef0; --c7: #63b3d6; --c8: #c8b48a;
}
/* Side A is blue, side B the threat red; amber stays for the player's current setting. */
:root[data-skin="trailer"] .stage, :root[data-skin="trailer"] .panel { --sa: #7fb6d9; --sb: #e8604a; }
:root[data-skin="trailer"] .idx b { font-family: var(--mono); font-weight: 400; color: var(--accent); text-shadow: 0 0 22px rgba(240, 169, 59, .35); }
:root[data-skin="trailer"] .chart .plotbg { fill: rgba(8, 18, 13, .55); }
:root[data-skin="trailer"] .chart .grid { stroke: #1c3326; }
:root[data-skin="trailer"] .chart .dd-a { filter: drop-shadow(0 0 5px rgba(127, 182, 217, .55)); }
:root[data-skin="trailer"] .chart .dd-b { filter: drop-shadow(0 0 5px rgba(232, 96, 74, .55)); }
:root[data-skin="trailer"] .chart .cur { filter: drop-shadow(0 0 4px rgba(240, 169, 59, .7)); }
:root[data-skin="trailer"] .pd-a { fill: rgba(111, 191, 139, .28); }
:root[data-skin="trailer"] .pd-all { fill: rgba(232, 96, 74, .1); }
:root[data-skin="trailer"] .status b { font-family: var(--display); font-style: italic; font-weight: 500; }
:root[data-skin="trailer"] .costwrap th, :root[data-skin="trailer"] .readout dd { letter-spacing: .02em; }
:root[data-skin="trailer"] .tabs .ta[aria-pressed="true"], :root[data-skin="trailer"] .tabs .tb[aria-pressed="true"] { box-shadow: 0 0 16px -6px var(--sa); }
:root[data-skin="trailer"] .choices button[aria-pressed="true"] { box-shadow: var(--glow); }

/* ---- Motion (both looks) ---- */
@keyframes fx-flash { from { background: color-mix(in srgb, var(--accent) 22%, transparent); } }
.fx-flash { animation: fx-flash .9s ease-out; }
.idx b, #costs td.num { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .fx-flash { animation: none; } }
/* Keep the status card's band colour in the trailer look (the shared trailer sheet paints every status amber). */
:root[data-skin="trailer"] .status[data-s="good"] { border-color: var(--good); background: color-mix(in srgb, var(--good) 8%, var(--panel)); }
:root[data-skin="trailer"] .status[data-s="bad"] { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--panel)); box-shadow: 0 0 24px -10px var(--bad); }
