/* Global theme. WS-D owns polish here. Original palette — no real brand assets. */
:root {
  --bg: #0b0e0c;
  --panel: #14181500;
  --panel-solid: #161b17;
  --panel-2: #1d241f;
  --line: #2a332c;
  --text: #e8f0ea;
  --muted: #8ba393;
  --accent: #53fc18;
  --accent-dim: #2f8f14;
  --good: #53fc18;
  --bad: #ff4d4d;
  --warn: #ffcc33;
  --gamble: #f5a623;
  --jackpot: #ffd23d;
  --heat: #ff7a45;
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  --sans: system-ui, "Segoe UI", sans-serif;

  /* Meter styling hooks — reusable safe→danger stops for any risk/heat/rep bar.
     Views can read these (e.g. background: var(--meter-danger)) or use the
     generic .meter / .meter-fill utility below. */
  --meter-track: #ffffff12;
  --meter-safe: #53fc18;
  --meter-warn: #ffcc33;
  --meter-danger: #ff4d4d;
  --meter-danger-glow: #ff4d4d66;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background:
    radial-gradient(1200px 600px at 70% -10%, #16351d33, transparent),
    radial-gradient(900px 500px at 10% 110%, #0f2a1633, transparent),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
}

/* Readability + interaction polish (global, non-layout) */
::selection { background: var(--accent); color: #07130a; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 999px;
  border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: #3a463c; }

#app {
  flex: 1;
  display: grid;
  grid-template-columns: 1.1fr 1fr 0.9fr;
  gap: 12px;
  padding: 12px;
  min-height: 0;
}
.pane {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.pane > h2 {
  margin: 0;
  padding: 10px 14px;
  font-size: 13px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.pane-body { overflow-y: auto; padding: 10px; }

/* HUD */
#hud {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
#hud .brand { font-weight: 800; color: var(--accent); letter-spacing: -.02em; }
#hud .brand small { color: var(--muted); font-weight: 500; display:block; font-size:10px; letter-spacing:.15em; }
.stat { font-family: var(--mono); font-size: 13px; }
.stat b { color: var(--text); }
.stat .lbl { color: var(--muted); text-transform: uppercase; font-size: 10px; letter-spacing: .1em; display:block; }
.hud-spacer { flex: 1; }
button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 6px 12px;
  transition: background .12s ease, border-color .12s ease, transform .06s ease, box-shadow .12s ease;
}
button:hover { border-color: var(--accent-dim); background: #212a23; }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); color: #07130a; border-color: var(--accent); font-weight: 700; }
button.primary:hover { background: #6bff35; box-shadow: 0 0 0 3px #53fc1826; }
button:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }

/* Generic meter utility (styling hook). Front-page uses its own .risk-meter;
   HUD/other bars can adopt these. Set --fill (0..1) and optionally --meter-color. */
.meter {
  height: 8px; border-radius: 999px; overflow: hidden;
  background: var(--meter-track);
}
.meter-fill {
  height: 100%;
  width: calc(var(--fill, 0) * 100%);
  background: var(--meter-color, var(--meter-safe));
  transition: width .2s linear, background .2s ease;
}
.meter-fill.warn { background: var(--meter-warn); }
.meter-fill.danger {
  background: var(--meter-danger);
  box-shadow: 0 0 8px var(--meter-danger-glow);
}

/* Toasts / event feed */
#toasts {
  position: fixed; right: 14px; bottom: 14px;
  display: flex; flex-direction: column; gap: 8px; z-index: 50;
  max-width: 360px;
}
.toast {
  position: relative;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px 10px 10px; border-radius: 8px; font-size: 13px; line-height: 1.35;
  border: 1px solid var(--line); background: var(--panel-solid);
  box-shadow: 0 6px 24px #0009; cursor: pointer;
  animation: toast-pop .2s cubic-bezier(.2, .9, .3, 1.3);
  transition: transform .18s ease, opacity .18s ease;
}
.toast:hover { transform: translateX(-2px); }
.toast__accent {
  flex: none; width: 4px; align-self: stretch; border-radius: 999px;
  background: var(--muted);
}
.toast__content { flex: 1; min-width: 0; display: grid; gap: 9px; }
.toast__msg { min-width: 0; overflow-wrap: anywhere; }

/* Stream-specific TOS replay: normal feed → two generated incident beats → cut. */
.toast.toast--tos_break { width: min(360px, calc(100vw - 28px)); }
.incident-replay {
  position: relative; overflow: hidden;
  width: 100%; aspect-ratio: 16 / 9;
  border: 1px solid #8d2d2d; border-radius: 6px;
  background: #080808;
  box-shadow: inset 0 0 30px #0008;
}
.incident-frame {
  position: absolute;
  width: 400%; height: 300%; max-width: none;
  left: calc(var(--incident-col) * -100%);
  top: calc(var(--incident-row) * -100%);
  object-fit: fill;
  user-select: none; pointer-events: none;
}
.incident-frame--standalone {
  width: 100%; height: 100%; left: 0; top: 0;
  object-fit: cover;
}
.incident-frame--beat1 {
  opacity: 0;
  animation: incident-beat1 5.4s steps(1, end) 1 both;
}
.incident-frame--beat2 {
  opacity: 0;
  animation: incident-beat2 5.4s steps(1, end) 1 both;
}
.incident-replay__eyebrow {
  position: absolute; top: 7px; left: 7px; z-index: 2;
  padding: 3px 6px; border-radius: 3px;
  background: #090909d9; color: #fff;
  font: 800 9px/1 var(--mono); letter-spacing: .11em;
}
.incident-cut {
  position: absolute; inset: 0; z-index: 3;
  display: grid; place-content: center; gap: 6px; text-align: center;
  opacity: 0;
  background:
    repeating-linear-gradient(0deg, #000b 0 2px, #210808cc 2px 4px),
    #100606c9;
  color: var(--bad);
  text-shadow: 0 0 16px #ff4d4dcc;
  animation: incident-cut-in 5.4s steps(1, end) 1 both;
}
.incident-cut b { font: 900 20px/1 var(--mono); letter-spacing: .08em; }
.incident-cut small { color: #fff; font: 800 10px/1 var(--mono); letter-spacing: .16em; }

@keyframes incident-beat1 {
  0%, 21.999% { opacity: 0; }
  22%, 47.999% { opacity: 1; filter: saturate(1.08) contrast(1.04); }
  48%, 100% { opacity: 0; }
}
@keyframes incident-beat2 {
  0%, 47.999% { opacity: 0; }
  48%, 100% { opacity: 1; filter: saturate(1.15) contrast(1.08); }
}
@keyframes incident-cut-in {
  0%, 73.999% { opacity: 0; }
  74%, 100% { opacity: 1; }
}

/* Tone: base color band via the accent + a tinted edge */
.toast.good    { border-color: #2f8f14; }
.toast.good    .toast__accent { background: var(--good); box-shadow: 0 0 8px #53fc1866; }
.toast.bad     { border-color: #7a2323; }
.toast.bad     .toast__accent { background: var(--bad); box-shadow: 0 0 8px #ff4d4d66; }
.toast.neutral .toast__accent { background: var(--muted); }

/* Type treatments use a doubled `.toast` prefix so they reliably win over the
   two-class tone selectors above (matching specificity, later in source). */

/* Type: celebration for jackpots/viral moments */
.toast.toast--celebrate {
  border-color: var(--jackpot);
  background:
    linear-gradient(100deg, #2a2410 0%, var(--panel-solid) 55%);
}
.toast.toast--celebrate .toast__accent {
  background: var(--jackpot); box-shadow: 0 0 12px #ffd23daa;
}
.toast.toast--celebrate .toast__msg {
  background: linear-gradient(90deg, var(--jackpot), #fff3b0, var(--jackpot));
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text;
  color: transparent; font-weight: 700;
  animation: toast-shimmer 1.4s linear infinite;
}

/* Type: alarm for TOS breaks / audits / sponsor warnings */
.toast.toast--alarm {
  border-color: var(--bad);
  background: linear-gradient(100deg, #2a1414 0%, var(--panel-solid) 60%);
  animation: toast-pop .2s cubic-bezier(.2, .9, .3, 1.3), toast-alarm 1.1s ease-in-out infinite;
}
.toast.toast--alarm .toast__accent { background: var(--bad); box-shadow: 0 0 12px #ff4d4daa; }
.toast.toast--alarm .toast__msg { font-weight: 600; }
/* audit reads as an authority action — cool red-orange edge */
.toast.toast--audit { border-color: var(--heat); }
.toast.toast--audit .toast__accent { background: var(--heat); box-shadow: 0 0 12px #ff7a45aa; }

/* Exit */
.toast--out { opacity: 0; transform: translateX(24px); }

@keyframes toast-pop { from { transform: translateY(10px); opacity: 0; } }
@keyframes toast-shimmer { to { background-position: 200% 0; } }
@keyframes toast-alarm {
  0%, 100% { box-shadow: 0 6px 24px #0009, 0 0 0 0 var(--meter-danger-glow); }
  50%      { box-shadow: 0 6px 24px #0009, 0 0 0 4px #ff4d4d22; }
}

/* Phase 2 shift briefing + performance review */
.shift-overlay[hidden] { display: none; }
.shift-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 28px;
  background:
    radial-gradient(900px 560px at 48% 38%, #143f224d, transparent 72%),
    repeating-linear-gradient(135deg, #ffffff03 0 1px, transparent 1px 9px),
    #030704f2;
  backdrop-filter: blur(10px);
}
.shift-card {
  position: relative; overflow: hidden;
  width: min(980px, 100%); max-height: calc(100vh - 56px); overflow-y: auto;
  padding: 28px 32px 32px;
  border: 1px solid #3f5545;
  border-radius: 16px;
  background:
    linear-gradient(165deg, #1a241d 0%, #101612 56%, #0b100d 100%),
    var(--panel-solid);
  box-shadow: 0 32px 90px #000e, inset 0 1px #ffffff10;
  animation: shift-card-in .28s cubic-bezier(.2, .9, .3, 1.1);
}
.shift-card::before {
  content: ''; position: absolute; inset: 0 0 auto; height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.memo-masthead {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 24px;
  padding-bottom: 18px; border-bottom: 1px solid #405047;
}
.memo-brand { display: flex; align-items: center; gap: 10px; }
.memo-brand > span {
  padding: 7px 9px 5px; border-radius: 2px;
  color: #071008; background: var(--accent);
  font: 950 22px/.8 var(--sans); letter-spacing: -.08em; transform: skew(-4deg);
}
.memo-brand small,
.memo-meta small,
.memo-meta strong {
  display: block; color: var(--muted); font: 700 9px/1.45 var(--mono);
  letter-spacing: .13em; text-transform: uppercase;
}
.memo-meta { text-align: right; }
.memo-meta strong { color: #d9e4dc; font-size: 10px; }
.memo-meta small { color: #738178; }
.eddie-message {
  display: grid; grid-template-columns: 54px 1fr; gap: 16px; align-items: start;
  margin-top: 24px;
}
.eddie-avatar {
  display: grid; place-items: center; width: 52px; height: 52px;
  border: 1px solid #66776b; border-radius: 50%; color: #061007;
  background: linear-gradient(145deg, #72ff46, #3dbb1b);
  box-shadow: 0 0 0 4px #53fc1812;
  font: 900 23px/1 var(--sans);
}
.shift-card__eyebrow,
.brief-metric > span,
.result-metric > span,
.result-score__copy > span,
.brief-directive > span,
.eddie-verdict > span {
  color: var(--muted); font: 700 10px/1.2 var(--mono);
  letter-spacing: .16em; text-transform: uppercase;
}
.shift-card h1 {
  margin: 7px 0 10px; max-width: 760px;
  font-size: clamp(30px, 5vw, 52px); line-height: .96; letter-spacing: -.05em;
}
.shift-card__lede { margin: 0; max-width: 780px; color: #b7c7bc; line-height: 1.58; }
.brief-grid,
.result-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px;
  margin-top: 26px;
}
.result-grid { grid-template-columns: repeat(4, 1fr); margin-top: 10px; }
.brief-metric,
.result-metric {
  min-width: 0; padding: 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #ffffff07;
}
.brief-metric strong,
.result-metric strong { display: block; margin: 6px 0 2px; font: 700 19px/1.1 var(--mono); overflow-wrap: anywhere; }
.brief-metric small,
.result-metric small { color: var(--muted); font-size: 10px; line-height: 1.3; }
.result-metric.good strong { color: var(--good); }
.result-metric.bad strong { color: var(--bad); }
.brief-priorities {
  display: grid; grid-template-columns: 1.25fr 1fr; gap: 10px; margin-top: 10px;
}
.brief-directive {
  display: grid; gap: 6px; padding: 16px;
  border: 1px solid #566258; border-radius: 10px;
  background: linear-gradient(110deg, #ffffff08, transparent);
}
.brief-directive--stake { border-color: #8a6727; background: linear-gradient(100deg, #f5a62317, transparent); }
.brief-directive--stake > span { color: var(--gamble); }
.brief-directive strong { color: #e4eee7; line-height: 1.35; }
.brief-directive--stake strong { color: #ffe1a5; }
.brief-directive small { color: var(--muted); }
.eddie-checklist {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  margin-top: 16px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px;
  background: var(--line);
}
.eddie-checklist__item {
  display: grid; grid-template-columns: auto 1fr; gap: 11px; min-width: 0;
  padding: 14px; background: #0d130f;
}
.eddie-checklist__item > b { color: var(--accent); font: 800 13px/1 var(--mono); }
.eddie-checklist__item strong { display: block; color: #dbe7de; font-size: 12px; }
.eddie-checklist__item small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.eddie-signoff {
  position: relative; display: grid; gap: 3px; max-width: 620px;
  margin: 20px 0 0 auto; padding: 0 12px 0 18px; border-left: 2px solid var(--accent);
  color: #aebdb3; font-size: 12px; font-style: italic; text-align: right;
}
.eddie-signoff strong { color: var(--accent); font: 800 19px/1.2 var(--sans); }
.eddie-signoff small { color: #657169; font-size: 9px; }
.shift-card__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.shift-action { min-width: 210px; padding: 11px 18px; }
.result-stamp {
  position: absolute; top: 88px; right: 30px;
  padding: 6px 9px; border: 2px solid currentColor; border-radius: 5px;
  color: var(--good); font: 800 11px/1 var(--mono); letter-spacing: .12em;
  transform: rotate(2deg);
}
.is-fired::before { background: linear-gradient(90deg, transparent, var(--bad), transparent); }
.is-fired .result-stamp { color: var(--bad); transform: rotate(-3deg); }
.result-score {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 20px;
  margin-top: 14px; padding: 18px;
  border: 1px solid var(--line); border-radius: 12px; background: #080b09aa;
}
.result-score__number { color: var(--accent); font: 800 42px/1 var(--mono); letter-spacing: -.07em; }
.is-fired .result-score__number { color: var(--bad); }
.result-score__copy strong { display: block; margin-top: 5px; font: 700 14px/1.2 var(--mono); }
.result-progress { height: 6px; margin-top: 9px; overflow: hidden; border-radius: 999px; background: var(--meter-track); }
.result-progress i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.is-fired .result-progress i { background: var(--bad); }
.eddie-verdict {
  display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: start;
  margin-top: 18px; padding: 14px 16px; border: 1px solid #54705c; border-radius: 10px;
  background: linear-gradient(100deg, #53fc1810, transparent);
}
.eddie-verdict > span { color: var(--accent); padding-top: 3px; }
.eddie-verdict p { margin: 0; color: #d2ded5; line-height: 1.5; }
.is-fired .eddie-verdict { border-color: #7b3d3d; background: linear-gradient(100deg, #ff4d4d10, transparent); }
.is-fired .eddie-verdict > span { color: var(--bad); }
.review-sections {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px;
}
.review-panel {
  min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 11px;
  background: #ffffff05;
}
.review-panel--sponsors { grid-column: 1 / -1; }
.review-panel__heading { display: flex; gap: 10px; align-items: center; margin-bottom: 11px; }
.review-panel__heading > span { color: var(--accent); font: 800 18px/1 var(--mono); }
.review-panel__heading strong,
.review-panel__heading small { display: block; }
.review-panel__heading strong { color: #dce8df; font: 800 11px/1.25 var(--mono); letter-spacing: .1em; }
.review-panel__heading small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.review-line {
  display: flex; justify-content: space-between; gap: 16px; padding: 7px 0;
  border-top: 1px solid #ffffff0b; font-size: 11px;
}
.review-line > span { color: var(--muted); }
.review-line > strong { color: #d6e1d9; font: 700 11px/1.3 var(--mono); text-align: right; }
.sponsor-review-list { display: grid; gap: 7px; }
.sponsor-review {
  display: grid; grid-template-columns: minmax(220px, 1fr) auto 58px 72px; gap: 12px; align-items: center;
  padding: 10px 12px; border-left: 2px solid var(--line); border-radius: 5px; background: #070b08aa;
}
.sponsor-review.good { border-left-color: var(--good); }
.sponsor-review.warn { border-left-color: var(--gamble); }
.sponsor-review.bad { border-left-color: var(--bad); }
.sponsor-review strong,
.sponsor-review small { display: block; }
.sponsor-review small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.sponsor-review > span { color: var(--muted); font: 700 9px/1 var(--mono); letter-spacing: .08em; }
.sponsor-review > b { color: #dbe6dd; font: 800 13px/1 var(--mono); text-align: right; }
.sponsor-review > em { color: var(--good); font: 700 12px/1 var(--mono); text-align: right; }
.review-empty { color: var(--muted); font-size: 11px; }

/* Keep the briefing's decision button above the fold at a 720px-tall viewport. */
.shift-card--briefing { padding-top: 24px; padding-bottom: 22px; }
.shift-card--briefing .memo-masthead { padding-bottom: 12px; }
.shift-card--briefing .eddie-message { margin-top: 16px; }
.shift-card--briefing .brief-grid { margin-top: 18px; }
.shift-card--briefing .brief-metric { padding: 12px; }
.shift-card--briefing .brief-directive { padding: 13px 15px; }
.shift-card--briefing .eddie-checklist { margin-top: 10px; }
.shift-card--briefing .eddie-checklist__item { padding: 10px 12px; }
.shift-card--briefing .eddie-signoff { margin-top: 12px; }
.shift-card--briefing .shift-card__actions { margin-top: 14px; }

@keyframes shift-card-in {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
}

@media (max-width: 720px) {
  .shift-overlay { padding: 12px; }
  .shift-card { max-height: calc(100vh - 24px); padding: 24px 20px; }
  .memo-masthead { align-items: flex-start; }
  .memo-brand small { display: none; }
  .memo-meta { max-width: 190px; }
  .eddie-message { grid-template-columns: 42px 1fr; gap: 12px; }
  .eddie-avatar { width: 40px; height: 40px; font-size: 18px; }
  .brief-grid, .result-grid { grid-template-columns: repeat(2, 1fr); }
  .brief-priorities, .review-sections { grid-template-columns: 1fr; }
  .eddie-checklist { grid-template-columns: 1fr; }
  .review-panel--sponsors { grid-column: auto; }
  .result-stamp { position: static; display: inline-block; margin-bottom: 18px; }
  .result-score { grid-template-columns: 1fr; gap: 8px; }
  .eddie-verdict { grid-template-columns: 1fr; gap: 6px; }
  .sponsor-review { grid-template-columns: 1fr auto auto; }
  .sponsor-review > div { grid-column: 1 / -1; }
  .eddie-signoff { text-align: left; margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .toast,
  .toast.toast--alarm,
  .toast.toast--celebrate .toast__msg,
  .shift-card { animation: none !important; }
  .incident-frame--normal,
  .incident-frame--beat1 { display: none; }
  .incident-frame--beat2 {
    animation: none;
    opacity: 1;
    filter: grayscale(.35) contrast(1.12) brightness(.65);
  }
  .incident-cut { animation: none; opacity: 1; background-color: #10060688; }
  .meter-fill, button { transition: none; }
}
