:root {
  --bg: #0d1117;
  --bg-panel: #161c26;
  --bg-card: #1c2432;
  --bg-hover: #232d3f;
  --border: #2b3648;
  --text: #e6ebf3;
  --text-dim: #93a1b5;
  --accent: #35c96b;
  --accent-dim: #1f7a43;
  --amber: #f2b338;
  --red: #ef5b5b;
  --blue: #4da3ff;
  --radius: 12px;
  font-size: 15px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  min-height: 100vh;
}

.layout { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; }
.brand-icon { font-size: 28px; }
.brand-name { font-weight: 800; letter-spacing: 0.3px; }
.brand-sub { font-size: 11px; color: var(--text-dim); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

nav { display: flex; flex-direction: column; gap: 4px; }

.nav-btn {
  text-align: left;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.nav-btn:hover { background: var(--bg-hover); color: var(--text); }
.nav-btn.active { background: var(--accent-dim); color: #fff; }

.sidebar-foot { margin-top: auto; padding: 10px 12px; font-size: 12px; color: var(--text-dim); }

/* ---- Content ---- */
.content { flex: 1; padding: 28px 34px; max-width: 1180px; }

h1 { font-size: 24px; margin-bottom: 4px; }
h2 { font-size: 16px; margin: 22px 0 10px; color: var(--text); }
.subtitle { color: var(--text-dim); font-size: 13px; margin-bottom: 20px; }

.loading, .empty { color: var(--text-dim); padding: 40px 0; text-align: center; }

.error-banner {
  background: rgba(239, 91, 91, 0.12);
  border: 1px solid rgba(239, 91, 91, 0.4);
  color: #ffb4b4;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 14px;
}

/* ---- Cards & grids ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 8px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.card .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 6px; }
.card .value { font-size: 22px; font-weight: 800; }
.card .hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.card .value.good { color: var(--accent); }
.card .value.warn { color: var(--amber); }
.card .value.bad { color: var(--red); }

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid rgba(43, 54, 72, 0.55); white-space: nowrap; }
tr:hover td { background: rgba(35, 45, 63, 0.5); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.pos-badge {
  display: inline-block;
  min-width: 38px;
  text-align: center;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-hover);
  color: var(--text-dim);
}
.pos-QB { color: #d98cff; } .pos-RB { color: #5fd98a; } .pos-WR { color: #5fb8ff; }
.pos-TE { color: #ffb46b; } .pos-K { color: #c8d1de; } .pos-DST { color: #ff8a8a; }
/* IDP — one hue family so defenders read as a group at a glance. */
.pos-LB { color: #ff9ecb; } .pos-DE { color: #7fd6c8; } .pos-DT { color: #6fc0b4; }
.pos-CB { color: #b3a4ff; } .pos-S { color: #9d8cf5; } .pos-DL { color: #7fd6c8; }
.pos-DB { color: #b3a4ff; } .pos-P { color: #c8d1de; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.tag.green { background: rgba(53, 201, 107, 0.15); color: var(--accent); }
.tag.amber { background: rgba(242, 179, 56, 0.15); color: var(--amber); }
.tag.red { background: rgba(239, 91, 91, 0.15); color: var(--red); }
.tag.blue { background: rgba(77, 163, 255, 0.15); color: var(--blue); }

.injury { color: var(--red); font-size: 11px; font-weight: 700; margin-left: 6px; }
.delta-pos { color: var(--accent); font-weight: 700; }
.delta-neg { color: var(--red); font-weight: 700; }

/* ---- Trade cards ---- */
.trade-card {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  gap: 14px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
}
.trade-side .side-label { font-size: 11px; text-transform: uppercase; color: var(--text-dim); margin-bottom: 6px; }
.trade-arrow { font-size: 20px; color: var(--text-dim); }
.trade-meta { text-align: right; font-size: 13px; }
.trade-player { font-weight: 700; }
.trade-player .sub { font-weight: 400; color: var(--text-dim); font-size: 12px; }

/* ---- Live draft board ---- */
.draft-grid { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
/* Grid items default to min-width:auto, so a wide table would push the draft
   plan off-screen instead of scrolling inside its own wrapper. */
.draft-grid > * { min-width: 0; }

.draft-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.draft-toolbar input[type="search"] {
  flex: 1;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
}
.draft-toolbar input[type="search"]:focus { outline: none; border-color: var(--accent-dim); }
.pos-filters { display: flex; gap: 4px; flex-wrap: wrap; }
.pos-filters .topic-chip { padding: 6px 10px; font-size: 12px; }

/* The fit explanation wraps, but needs a floor or it collapses to one word
   per line and the rows grow to four times their height. */
.draft-why {
  white-space: normal;
  min-width: 124px;
  max-width: 180px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-dim);
}

#draft-table td, #draft-table th { padding-left: 7px; padding-right: 7px; }
/* Mine/Taken are the whole point of this screen — keep them reachable when
   the table has to scroll sideways on a narrow window. */
#draft-table td:last-child, #draft-table th:last-child {
  position: sticky;
  right: 0;
  background: var(--bg-card);
  box-shadow: -9px 0 12px -8px rgba(0, 0, 0, 0.65);
}
#draft-table tr:hover td:last-child { background: #212b3a; }

/* ---- ESPN draft sync ---- */
.sync-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.sync-bar .btn { padding: 8px 14px; font-size: 13px; }
.sync-auto {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
}
.sync-status { font-size: 12px; color: var(--text-dim); flex: 1; min-width: 160px; }
.sync-status.bad { color: var(--red); }

/* ---- Actions: the app changing your ESPN team ---- */
.act-panel { margin-top: 18px; padding: 14px 16px; background: var(--bg-card); border: 1px solid var(--accent-dim); border-radius: var(--radius); }
.act-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.act-head .hint, .apply-bar .hint { color: var(--text-dim); font-size: 12.5px; }
.plan-narrative { font-size: 13.5px; line-height: 1.6; margin-bottom: 8px; }
.plan-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.plan-item {
  display: grid; grid-template-columns: auto auto auto 1fr; gap: 10px; align-items: center;
  padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
}
.plan-item.invalid { opacity: .6; cursor: not-allowed; }
.plan-type { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); font-weight: 700; }
.plan-summary { font-size: 13.5px; }
.plan-why, .plan-problems { grid-column: 1 / -1; font-size: 12px; color: var(--text-dim); }
.plan-problems { color: var(--amber); }
.risk { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 2px 7px; border-radius: 999px; }
.risk-low { background: rgba(53, 201, 107, .15); color: var(--accent); }
.risk-medium { background: rgba(242, 179, 56, .15); color: var(--amber); }
.risk-high { background: rgba(239, 91, 91, .15); color: var(--red); }
.plan-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.act-result { padding: 8px 12px; border-radius: 8px; margin-top: 8px; font-size: 13px; background: var(--bg); border: 1px solid var(--border); }
.act-result.ok { border-color: var(--accent-dim); }
.act-result.bad { border-color: rgba(239, 91, 91, .5); }
.act-result pre { white-space: pre-wrap; font-size: 11px; color: var(--text-dim); margin-top: 6px; max-height: 220px; overflow: auto; }
.apply-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; background: var(--bg-card); border: 1px solid var(--accent-dim); border-radius: 10px; margin: 18px 0 10px;
}
.apply-bar > div { flex: 1; min-width: 220px; }
.trade-rank { font-size: 11px; font-weight: 800; color: var(--text-dim); }
.trade-reason { grid-column: 1 / -1; font-size: 12px; color: var(--text-dim); }
.threeway { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; background: var(--bg-card); }
.threeway-legs { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: 13px; margin: 8px 0; }
.threeway-leg { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }

/* ---- Import picks from the draft room ---- */
.import-bar {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: 10px;
}
.import-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--text-dim); margin-bottom: 8px; }
.import-head strong { color: var(--text); }
.bookmarklet-btn {
  display: inline-block; background: var(--accent-dim); color: #fff;
  padding: 4px 10px; border-radius: 6px; font-weight: 700; font-size: 12px;
  text-decoration: none; white-space: nowrap; cursor: grab;
}
.import-row { display: flex; gap: 8px; align-items: stretch; }
.import-row textarea {
  flex: 1; min-height: 44px; resize: vertical;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 8px 10px; font-size: 12.5px; font-family: inherit;
}
.import-row textarea:focus { outline: none; border-color: var(--accent-dim); }
.import-row .btn { padding: 8px 14px; font-size: 13px; white-space: nowrap; }

.mini-btn {
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.mini-btn:hover { filter: brightness(1.2); }
.mini-btn.mine { border-color: var(--accent-dim); color: var(--accent); }
.mini-btn.taken { border-color: rgba(239, 91, 91, 0.45); color: var(--red); }

.my-pick { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid rgba(43, 54, 72, 0.55); }
.my-pick:last-child { border-bottom: none; }

.plan-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(43, 54, 72, 0.55); font-size: 13.5px; }
.plan-row:last-child { border-bottom: none; }
.plan-row.done { opacity: 0.55; }
.plan-round { flex-shrink: 0; min-width: 52px; font-weight: 800; color: var(--accent); font-size: 12.5px; padding-top: 2px; }
/* Space is tight in the sidebar — a smaller thumbnail keeps each pick on one line. */
.plan-row .avatar, .my-pick .avatar { width: 22px; height: 22px; font-size: 8px; }
/* Let the badge size to its text instead of holding a 38px column — the
   sidebar needs those pixels for the name. */
.plan-row .pos-badge { min-width: 0; padding: 2px 5px; }
/* Each pick already leads with its assigned-slot tag, so the position badge
   beside it is a duplicate chip eating the width the name needs. */
.my-pick .pos-badge { display: none; }
.plan-round .plan-overall { color: var(--text-dim); font-weight: 600; font-size: 11px; }
.plan-alts { font-size: 11.5px; color: var(--text-dim); margin-top: 3px; line-height: 1.5; }

/* Mark a recommendation without hunting for it in the table. In the sidebar
   the ✓/✗ stack under the round label — that column already spans the row's
   two lines and only uses one, so the name line keeps its full width and a
   long name still fits. Full labels in the banner, where there's room. */
.plan-round { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.plan-actions { display: inline-flex; gap: 3px; }
.plan-actions .mini-btn { padding: 1px 6px; font-size: 11px; line-height: 1.5; }
.rec-actions { display: inline-flex; gap: 6px; }
.rec-actions .mini-btn { padding: 6px 12px; font-size: 13px; }

@media (max-width: 1000px) {
  .draft-grid { grid-template-columns: 1fr; }
}

/* ---- Forms ---- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--text-dim); margin-bottom: 6px; }
.field input, .field select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}
.field input:focus, textarea:focus { outline: none; border-color: var(--accent-dim); }
.field .help { font-size: 11.5px; color: var(--text-dim); margin-top: 5px; line-height: 1.45; }

.btn {
  display: inline-block;
  background: var(--accent-dim);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.12s;
  text-decoration: none; /* links dressed as buttons take no underline */
}
.btn:hover { filter: brightness(1.15); }
.btn.secondary { background: var(--bg-hover); color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn-row { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---- AI view ---- */
.ai-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 18px; align-items: start; }
.thread-list { position: sticky; top: 18px; display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 36px); }
.thread-new { width: 100%; }
.thread-items { overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding-right: 2px; }
.thread-item {
  display: flex; flex-direction: column; gap: 3px; text-align: left; width: 100%;
  padding: 9px 11px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--text); cursor: pointer; font: inherit;
}
.thread-item:hover { background: var(--bg-hover); }
.thread-item.active { background: var(--bg-card); border-color: var(--accent-dim); }
.thread-item-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-item-meta { font-size: 11px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-empty { font-size: 12.5px; color: var(--text-dim); padding: 10px 6px; line-height: 1.5; }
.thread-pane { min-width: 0; }
.thread-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.thread-head h2 { margin: 0; font-size: 17px; }
.thread-meta { display: block; font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.thread-tools { display: flex; gap: 6px; flex-shrink: 0; }
.thread-messages {
  display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px;
  max-height: 62vh; overflow-y: auto; padding: 2px;
}
.thread-messages:empty { display: none; }
.thread-empty-pane { padding: 28px 8px; text-align: center; font-size: 13.5px; }
.msg { max-width: 100%; }
.msg-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--text-dim); margin-bottom: 5px; display: flex; gap: 8px; align-items: center; }
.msg-when { font-weight: 500; text-transform: none; letter-spacing: 0; }
.msg-user { align-self: flex-end; width: min(100%, 720px); }
.msg-user .msg-label { justify-content: flex-end; }
.msg-user .msg-text {
  background: rgba(53, 201, 107, 0.09); border: 1px solid var(--accent-dim); border-radius: var(--radius);
  padding: 12px 16px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.msg-ai .msg-body { margin: 0; }
.msg-ai .ai-output { min-height: 0; }
.msg-pre { white-space: pre-wrap; font-size: 12.5px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.msg-ctx { font-weight: 500; text-transform: none; letter-spacing: 0; margin-left: auto; opacity: .8; }
.thread-messages .plan-item { cursor: default; }
.plan-mark { width: 13px; text-align: center; color: var(--text-dim); }
.plan-executed .plan-mark { color: var(--accent); }
.plan-failed .plan-mark, .plan-item.invalid .plan-mark { color: var(--red); }
.plan-dismissed, .plan-superseded { opacity: .55; }
.plan-dismissed .plan-summary, .plan-superseded .plan-summary { text-decoration: line-through; }
.plan-status { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin-left: 6px; color: var(--text-dim); }
.plan-status-executed { color: var(--accent); }
.plan-status-failed { color: var(--red); text-transform: none; letter-spacing: 0; }
.plan-item-tools { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
.plan-item-tools .mini-btn { padding: 2px 8px; font-size: 11px; }
.plan-revise { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.plan-revise .revise-text {
  flex: 1; min-width: 0; padding: 8px 10px; font: inherit; font-size: 13px; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
.plan-revise .revise-text:focus { outline: none; border-color: var(--accent-dim); }
.plan-revise .mini-btn { padding: 7px 12px; font-size: 12.5px; white-space: nowrap; }
.act-results:empty { display: none; }

/* ---- Rivals: sticky comparison beside scrolling rivals ---- */
.rivals-layout { display: grid; grid-template-columns: minmax(340px, 420px) minmax(0, 1fr); gap: 20px; align-items: start; }
.compare-panel { position: sticky; top: 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 16px 12px; min-width: 0; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.compare-panel .compare-head { position: sticky; top: 0; z-index: 2; background: var(--bg-card); padding: 14px 0 8px; margin-bottom: 0; }
.compare-tabs { display: flex; gap: 6px; margin-top: 10px; }
.compare-tabs .mini-btn { flex: 1; text-align: center; padding: 5px 8px; font-size: 12px; }
/* The two column layout depends on the space the grid actually has, not the window. */
.content { container-type: inline-size; }
@container (max-width: 860px) {
  .rivals-layout { grid-template-columns: 1fr; }
  .compare-panel { position: static; max-height: none; overflow: visible; }
}
.compare-panel.pinned { border-color: var(--accent-dim); }
.compare-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.compare-head .vs { color: var(--text-dim); font-size: 13px; }
.compare-head select { flex: 1; min-width: 140px; padding: 6px 8px; font: inherit; font-size: 13px; font-weight: 700; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.compare-head .mini-btn { padding: 5px 9px; font-size: 12px; }
.compare-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); font-weight: 700; }
.compare-hero { display: flex; align-items: baseline; gap: 10px; margin: 2px 0 6px; }
.compare-hero .num { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.compare-hero .num.pos { color: var(--accent); } .compare-hero .num.neg { color: var(--red); }
.compare-hero .sub { font-size: 12.5px; color: var(--text-dim); }
.compare-section { margin-top: 10px; }
.compare-section h4 { margin: 0 0 2px; font-size: 12.5px; display: flex; justify-content: space-between; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; }
.compare-section h4 > span:first-child { white-space: nowrap; }
.compare-section h4 .hint { font-weight: 500; font-size: 11.5px; color: var(--text-dim); flex: 1 1 200px; text-align: right; }
.viz-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-dim); margin: 2px 0 4px; }
.viz-legend .k { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.viz-legend .k.tick { width: 3px; height: 11px; border-radius: 1px; }
.viz-legend .k.cell { border-radius: 2px; width: 11px; height: 11px; }
.viz-box { position: relative; overflow-x: auto; }
.viz-box svg { display: block; max-width: 100%; }
.viz-box.dimmed { opacity: .55; transition: opacity .2s; }
.viz-table { width: 100%; font-size: 12px; margin-top: 4px; }
.viz-table th, .viz-table td { padding: 4px 6px; }
.viz-tip { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; background: #0f1520; border: 1px solid var(--border); border-radius: 10px; padding: 8px 11px; font-size: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.45); max-width: 280px; }
.viz-tip-row { display: flex; align-items: baseline; gap: 7px; line-height: 1.5; color: var(--text-dim); }
.viz-tip-row strong { color: #fff; font-size: 13px; min-width: 44px; }
.viz-tip-row.head strong { min-width: 0; font-size: 12.5px; }
.viz-tip-row.head { border-bottom: 1px solid var(--border); padding-bottom: 3px; margin-bottom: 3px; }
.viz-tip-key { display: inline-block; width: 10px; height: 3px; border-radius: 2px; flex-shrink: 0; align-self: center; }
.rivals-main { min-width: 0; }
.rival-card { scroll-margin-top: 16px; transition: border-color .2s, box-shadow .2s; }
.rival-card.active { border-color: var(--accent-dim); box-shadow: 0 0 0 1px var(--accent-dim); }
.rival-card .card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.rival-card .card-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.rival-facts { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; font-size: 12.5px; }
.heat-legend { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-dim); margin-top: 4px; }
.heat-legend .ramp { width: 120px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #e66767, #2f3846, #3987e5); }
@media (max-width: 1000px) {
  .rivals-layout { grid-template-columns: 1fr; }
  .compare-panel { position: static; }
}

/* ---- Notes to other managers: editor modal + plan notes ---- */
.msg-modal { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 20px; }
.msg-scrim { position: absolute; inset: 0; background: rgba(5, 8, 14, .7); }
.msg-dialog { position: relative; width: min(680px, 100%); background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; box-shadow: 0 24px 60px rgba(0,0,0,.5); }
.msg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.msg-summary { font-size: 14px; font-weight: 700; margin-top: 3px; }
.msg-label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 12px; font-weight: 700; color: var(--text-dim); margin-bottom: 6px; }
.msg-label .hint { font-weight: 500; font-size: 11.5px; }
.msg-dialog textarea, .plan-note textarea { width: 100%; font: inherit; font-size: 14px; line-height: 1.55; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; resize: vertical; }
.msg-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; margin: 6px 0 10px; min-height: 20px; }
.msg-ok { color: var(--accent); } .msg-bad { color: var(--amber); font-weight: 700; }
.msg-count { margin-left: auto; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.msg-status .mini-btn { padding: 2px 8px; font-size: 11px; }
.msg-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.plan-note { grid-column: 1 / -1; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-top: 4px; }
.plan-note.static { padding: 8px 12px; }
.plan-note blockquote, .sent-note blockquote { margin: 6px 0; padding: 8px 12px; border-left: 3px solid var(--accent-dim); background: var(--bg); border-radius: 0 8px 8px 0; font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; }
.sent-note { margin-top: 8px; }
.sent-note .hint { font-size: 12px; color: var(--text-dim); }

.plan-legacy { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--amber); background: rgba(242, 179, 56, .08); border: 1px solid rgba(242, 179, 56, .3); border-radius: 8px; padding: 8px 12px; margin-top: 8px; }
.act-confirm { padding: 10px 12px; background: var(--bg); border: 1px solid var(--accent-dim); border-radius: 8px; margin-top: 8px; font-size: 13px; }
.act-confirm ul { margin: 6px 0 0 18px; }
.act-confirm li { margin: 3px 0; }

/* ---- Memory drawer ---- */
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin: 6px 0 4px; }
.drawer-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); font-weight: 700; }
.memory-add { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.memory-add input { flex: 1 1 260px; min-width: 0; padding: 9px 11px; font: inherit; font-size: 13px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.memory-add input:focus { outline: none; border-color: var(--accent-dim); }
.memory-add select { padding: 8px 10px; font: inherit; font-size: 13px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.memory-add .btn { padding: 8px 14px; font-size: 13px; }
.memory-list { display: flex; flex-direction: column; gap: 8px; }
.memory-item { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.memory-item.pinned { border-color: var(--accent-dim); }
.memory-top { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; flex-wrap: wrap; }
.memory-kind { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 2px 7px; border-radius: 999px; background: var(--bg-hover); color: var(--text-dim); }
.kind-preference .memory-kind { background: rgba(53, 201, 107, .15); color: var(--accent); }
.kind-decision .memory-kind { background: rgba(77, 163, 255, .15); color: var(--blue); }
.kind-outcome .memory-kind { background: rgba(242, 179, 56, .15); color: var(--amber); }
.memory-meta { font-size: 11.5px; color: var(--text-dim); }
.memory-tools { margin-left: auto; display: flex; gap: 4px; }
.memory-tools .mini-btn { padding: 2px 7px; font-size: 11px; }
.memory-text { font-size: 13.5px; line-height: 1.5; }
@media (max-width: 900px) {
  .ai-layout { grid-template-columns: 1fr; }
  .thread-list { position: static; max-height: none; }
  .thread-items { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; }
  .thread-item { min-width: 200px; max-width: 240px; }
  .thread-messages { max-height: 55vh; }
}

.ai-topics { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.topic-chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.topic-chip.active { border-color: var(--accent); color: var(--accent); background: rgba(53, 201, 107, 0.08); }

.ai-input-row { display: flex; gap: 10px; margin-bottom: 16px; }
.ai-input-row textarea { flex: 1; min-height: 64px; resize: vertical; }

.ai-output {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  line-height: 1.65;
  font-size: 14.5px;
  min-height: 120px;
}
/* ---- Rendered markdown (model answers, plan narratives, briefings, scouting) ---- */
.ai-output { --md-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; color: var(--text); font-size: 14.5px; line-height: 1.68; overflow-wrap: anywhere; }
.ai-output > :first-child { margin-top: 0 !important; }
.ai-output > :last-child { margin-bottom: 0 !important; }
.ai-output h1, .ai-output h2, .ai-output h3, .ai-output h4, .ai-output h5, .ai-output h6 { color: #fff; font-weight: 650; letter-spacing: -0.01em; line-height: 1.3; margin: 22px 0 8px; }
.ai-output h2 { font-size: 18px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.ai-output h3 { font-size: 15.5px; position: relative; padding-left: 12px; }
.ai-output h3::before { content: ""; position: absolute; left: 0; top: 4px; bottom: 4px; width: 3px; border-radius: 3px; background: var(--accent); }
.ai-output h4 { font-size: 14.5px; color: var(--text); }
.ai-output h5, .ai-output h6 { font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.ai-output p { margin: 10px 0; }
.ai-output strong { color: #fff; font-weight: 650; }
.ai-output em { color: #d6deea; }
.ai-output del { color: var(--text-dim); }
.ai-output a { color: var(--blue); text-decoration: none; border-bottom: 1px solid rgba(77, 163, 255, 0.35); }
.ai-output a:hover { border-bottom-color: var(--blue); }
.ai-output hr { border: 0; height: 1px; margin: 20px 0; background: linear-gradient(90deg, var(--border), transparent); }
.ai-output ul, .ai-output ol { margin: 8px 0 12px; padding-left: 24px; }
.ai-output li { margin: 5px 0; padding-left: 2px; }
.ai-output li > p { margin: 4px 0; }
.ai-output li::marker { color: var(--text-dim); }
.ai-output ul > li::marker { color: var(--accent); }
.ai-output ul ul, .ai-output ol ul, .ai-output ul ol, .ai-output ol ol { margin: 4px 0 4px; }
.ai-output ul.tasks { list-style: none; padding-left: 4px; }
.ai-output li.task { display: flex; gap: 10px; align-items: flex-start; }
.ai-output .task-box { flex: none; width: 17px; height: 17px; margin-top: 4px; border-radius: 5px; border: 1.5px solid var(--border); background: var(--bg); color: var(--accent); font-size: 12px; line-height: 14px; text-align: center; font-weight: 700; }
.ai-output li.task.done .task-box { border-color: var(--accent-dim); background: rgba(53, 201, 107, 0.12); }
.ai-output li.task.done .task-body { color: var(--text-dim); text-decoration: line-through; text-decoration-color: rgba(147, 161, 181, 0.5); }
.ai-output .task-body { flex: 1; min-width: 0; }
.ai-output blockquote { margin: 12px 0; padding: 8px 16px; border-left: 3px solid var(--accent); background: rgba(53, 201, 107, 0.06); border-radius: 0 10px 10px 0; color: #d6deea; }
.ai-output blockquote p { margin: 6px 0; }
.ai-output code { font-family: var(--md-mono); font-size: 12.5px; background: rgba(13, 17, 23, 0.9); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; color: #dbe6f5; }
.ai-output .md-code { position: relative; margin: 12px 0; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); overflow: hidden; }
.ai-output .md-code pre { margin: 0; padding: 14px 16px; overflow-x: auto; font-family: var(--md-mono); font-size: 12.5px; line-height: 1.55; }
.ai-output .md-code code { background: none; border: 0; padding: 0; font-size: inherit; color: #dbe6f5; }
.ai-output .md-lang { position: absolute; top: 6px; right: 10px; font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); }
.ai-output img { max-width: 100%; border-radius: 8px; }

/* Tables: rounded frame, soft header, zebra rows, numbers right aligned in tabular figures. */
.ai-output .md-table { margin: 14px 0; overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: rgba(13, 17, 23, 0.45); -webkit-overflow-scrolling: touch; }
.ai-output table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 320px; font-size: 13.5px; line-height: 1.45; }
.ai-output thead th { position: sticky; top: 0; z-index: 1; text-align: left; font-size: 11.5px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-dim); background: var(--bg-panel); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.ai-output tbody td { padding: 9px 14px; vertical-align: top; border-bottom: 1px solid rgba(43, 54, 72, 0.55); }
.ai-output tbody tr:last-child td { border-bottom: 0; }
.ai-output tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.022); }
.ai-output tbody tr:hover td { background: rgba(53, 201, 107, 0.06); }
.ai-output tbody td:first-child { color: #fff; font-weight: 600; }
.ai-output tbody td:first-child strong { font-weight: 650; }
.ai-output td.num, .ai-output th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; color: #f2f5f9; }
.ai-output tbody td.num { font-weight: 600; }
.ai-output .align-center { text-align: center; }
.ai-output .align-right { text-align: right; font-variant-numeric: tabular-nums; }
.ai-output .align-left { text-align: left; }
.ai-output table code { white-space: nowrap; }

.ai-output .cursor { display: inline-block; width: 8px; height: 16px; background: var(--accent); animation: blink 0.9s infinite; vertical-align: text-bottom; }
@keyframes blink { 50% { opacity: 0; } }

.notice {
  background: rgba(77, 163, 255, 0.08);
  border: 1px solid rgba(77, 163, 255, 0.3);
  color: #a9cfff;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ---- Brand link ---- */
.brand { text-decoration: none; color: inherit; border-radius: 8px; transition: background .12s; }
.brand:hover { background: var(--bg-hover); }
.brand:hover .brand-ext { opacity: 1; }
.brand-ext { font-size: 11px; opacity: 0; color: var(--accent); transition: opacity .12s; }

/* ---- Player avatars & clickable cells ---- */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-hover);
  vertical-align: middle;
  flex-shrink: 0;
}
.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--text-dim);
  letter-spacing: -0.02em;
}
/* Two boxes only: the avatar, and one text box. Keeping badge/name/team as
   ordinary inline content (rather than sibling flex items) is what lets them
   wrap together as a phrase in narrow columns. */
.player-cell {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 6px;
  padding: 1px 5px;
  margin: -1px -5px;
}
.player-cell:hover { background: rgba(77, 163, 255, 0.12); }
.player-cell:hover strong { color: var(--blue); }
.player-meta { min-width: 0; line-height: 1.5; }
.player-meta .pos-badge { margin-right: 2px; }
/* Sized in em so it stays proportional wherever the cell is scaled up, like
   the recommended-pick banner. */
.player-team { color: var(--text-dim); font-size: 0.86em; font-weight: 600; white-space: nowrap; }

/* Team names open the team dossier drawer. */
.team-cell {
  cursor: pointer;
  border-radius: 6px;
  padding: 1px 5px;
  margin: -1px -5px;
  font-weight: 600;
  border-bottom: 1px dotted rgba(147, 161, 181, 0.5);
}
.team-cell:hover { background: rgba(77, 163, 255, 0.12); color: var(--blue); border-bottom-color: transparent; }

/* ---- Slideout drawer (players and teams) ---- */
#app-drawer { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
#app-drawer.open { pointer-events: auto; }
.drawer-scrim {
  position: absolute; inset: 0;
  background: rgba(5, 8, 13, 0.6);
  opacity: 0; transition: opacity .18s;
}
#app-drawer.open .drawer-scrim { opacity: 1; }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(580px, 100%);
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  box-shadow: -18px 0 44px rgba(0,0,0,.45);
  transform: translateX(100%);
  transition: transform .22s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
}
#app-drawer.open .drawer-panel { transform: translateX(0); }
.drawer-body { padding: 22px 24px 40px; position: relative; }
.drawer-close {
  position: absolute; top: 14px; right: 16px;
  background: var(--bg-hover); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 8px; width: 30px; height: 30px; cursor: pointer; font-size: 14px; line-height: 1;
}
.drawer-close:hover { color: var(--text); }
.drawer-hero { display: flex; gap: 16px; align-items: flex-start; margin: 4px 0 18px; }
.drawer-headshot {
  width: 96px; height: 96px; border-radius: 12px; object-fit: cover;
  background: var(--bg-hover); flex-shrink: 0;
}
.drawer-headshot-fallback {
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 22px; color: var(--text-dim);
}
.drawer-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
.drawer-h { font-size: 14px; margin: 22px 0 4px; }
.drawer-note { font-size: 11.5px; color: var(--text-dim); margin: 0 0 10px; line-height: 1.5; }

/* ---- Team dossier drawer ---- */
.team-hero { display: flex; gap: 14px; align-items: center; margin: 4px 0 18px; }
.team-crest {
  width: 54px; height: 54px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-hover); border: 1px solid var(--border);
  font-weight: 800; font-size: 18px; color: var(--text-dim); letter-spacing: -0.02em;
}
.h2h-score {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px; margin-bottom: 12px;
}
.h2h-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); margin-bottom: 3px; }
.h2h-val { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; }
.h2h-score > div:last-child { text-align: right; }
.h2h-edge { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }

.mini-trade {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 13px; margin-bottom: 9px;
  font-size: 13px; display: flex; flex-direction: column; gap: 5px;
}
.mini-trade-dir { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); margin-right: 6px; }
.mini-trade-gain { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.mini-stat { background: var(--bg-card); border: 1px solid var(--border); border-radius: 9px; padding: 9px 10px; }
.mini-stat .label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); margin-bottom: 3px; }
.mini-stat .value { font-size: 17px; font-weight: 800; }

/* ---- Points by week (drawer): the season on one fixed track ---- */
.wk-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 20px 0 6px; }
.wk-head h3 { font-size: 14px; margin: 0; }
.wk-verdict { font-size: 12px; color: var(--text-dim); }
.wk-verdict strong.good { color: var(--accent); }
.wk-verdict strong.bad { color: var(--amber); }
.wk-svg { display: block; width: 100%; height: auto; background: rgba(13, 17, 23, 0.45); border: 1px solid var(--border); border-radius: 10px; padding: 6px 4px 2px; }
.wk-grid { stroke: var(--border); stroke-width: 1; }
.wk-axis { fill: var(--text-dim); font-size: 9px; font-variant-numeric: tabular-nums; }
.wk-week { fill: var(--text-dim); font-size: 9px; font-variant-numeric: tabular-nums; }
.wk-week.now { fill: var(--text); font-weight: 700; }
.wk-bar.beat { fill: var(--accent); }
.wk-bar.miss { fill: var(--amber); }
.wk-bar.hollow { fill: rgba(255, 255, 255, 0.04); stroke: var(--text-dim); stroke-width: 1; stroke-dasharray: 3 2; }
.wk-tick { stroke: #fff; stroke-width: 2; opacity: .9; }
.wk-stub { fill: var(--border); }
.wk-value { fill: var(--text); font-size: 9.5px; font-weight: 700; font-variant-numeric: tabular-nums; paint-order: stroke; stroke: #131a24; stroke-width: 3px; stroke-linejoin: round; }
.wk-value.dim { fill: var(--text-dim); font-weight: 600; }
.wk-avg { stroke: var(--blue); stroke-width: 1; stroke-dasharray: 4 3; opacity: .9; }
.wk-col:hover .wk-bar { filter: brightness(1.2); }
.wk-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 11px; color: var(--text-dim); }
.wk-legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.wk-legend .sw.beat { background: var(--accent); }
.wk-legend .sw.miss { background: var(--amber); }
.wk-legend .sw.tick { height: 2px; background: #fff; vertical-align: 3px; }
.wk-legend .sw.avg { height: 0; border-top: 1px dashed var(--blue); vertical-align: 3px; }

/* ---- Diverging bars (vs league average) ---- */
.div-chart, .rival-bars { display: flex; flex-direction: column; gap: 7px; }
.rival-bars { margin-top: 12px; }
.div-row, .rival-bar-row { display: grid; grid-template-columns: 44px 1fr 54px; gap: 10px; align-items: center; }
.div-pos, .rival-pos { font-size: 11.5px; font-weight: 700; color: var(--text-dim); }
.div-track, .rival-track {
  position: relative; height: 14px; background: var(--bg); border-radius: 4px; overflow: hidden;
}
.rival-track { height: 10px; }
.div-mid, .rival-mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--border); }
.div-fill, .rival-fill { position: absolute; top: 2px; bottom: 2px; border-radius: 3px; }
.div-fill.pos, .rival-fill.pos { background: #199e70; }
.div-fill.neg, .rival-fill.neg { background: #c98500; }
.div-val, .rival-delta { font-size: 12px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

.scout-output:empty { display: none; }

@media (max-width: 560px) {
  .drawer-stats { grid-template-columns: repeat(2, 1fr); }
  .drawer-panel { width: 100%; }
}


/* ---- AI Analyst: chat layout ---- */
.content.chat-view { max-width: none; padding: 0; height: 100vh; height: 100dvh; overflow: hidden; }
.chat { display: grid; grid-template-columns: 250px minmax(0, 1fr) auto; height: 100vh; height: 100dvh; min-height: 0; }
.chat-rail { display: flex; flex-direction: column; gap: 8px; padding: 16px 12px; border-right: 1px solid var(--border); background: var(--bg-panel); min-height: 0; }
.chat-rail .thread-new { width: 100%; }
.chat-rail .thread-items { overflow-y: auto; min-height: 0; }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 24px 12px; border-bottom: 1px solid var(--border); }
.chat-head h2 { margin: 0; font-size: 16px; cursor: text; }
.chat-head h2[role="button"]:hover { text-decoration: underline dotted; text-underline-offset: 3px; }
.chat-head .thread-meta { display: block; font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.chat-head-tools { display: flex; gap: 6px; flex-shrink: 0; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 18px 24px; display: flex; flex-direction: column; gap: 14px; min-height: 0; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.chat-scroll .msg-user { max-width: min(78%, 760px); }
.chat-scroll .msg-ai { max-width: 900px; }
.chat-empty { margin: auto; max-width: 620px; text-align: center; padding: 20px; }
.chat-empty-title { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.chat-empty-sub { color: var(--text-dim); font-size: 13.5px; line-height: 1.6; margin-bottom: 18px; }
.chat-examples { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.chat-examples .example { text-align: left; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); font: inherit; font-size: 13.5px; cursor: pointer; }
.chat-examples .example:hover { border-color: var(--accent-dim); background: var(--bg-hover); }
.chat-composer { border-top: 1px solid var(--border); padding: 10px 24px 14px; background: var(--bg); }
.chat-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.chat-chips .topic-chip { padding: 5px 11px; font-size: 12px; }
.composer-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px 8px; }
.composer-box:focus-within { border-color: var(--accent-dim); }
.composer-box textarea { width: 100%; background: transparent; border: none; color: var(--text); font: inherit; font-size: 14.5px; line-height: 1.5; resize: none; min-height: 24px; max-height: 220px; outline: none; }
.composer-actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.composer-status { flex: 1; font-size: 12px; color: var(--text-dim); }
.composer-actions .btn { padding: 7px 14px; font-size: 13px; }
.msg-tools { display: flex; gap: 6px; margin-top: 6px; }
/* the choices under an answer */
.options { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.options-q { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); }
.options-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.option { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--bg-hover); display: flex; flex-direction: column; gap: 6px; }
.option.recommended { border-color: var(--accent-dim); box-shadow: inset 0 0 0 1px var(--accent-dim); }
.option-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.option-head .risk { margin-left: auto; }
.option-detail { font-size: 13px; color: var(--text); }
.option-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--text-dim); }
.option-gain { color: var(--accent); font-weight: 700; }
.option .msg-tools { margin-top: auto; }
.options-why { font-size: 13px; color: var(--text-dim); border-left: 3px solid var(--accent-dim); padding-left: 10px; }
.msg-tools .mini-btn { padding: 3px 9px; font-size: 11.5px; }
details.msg-ctx { margin-left: auto; font-weight: 500; text-transform: none; letter-spacing: 0; }
details.msg-ctx summary { cursor: pointer; opacity: .8; list-style: none; }
details.msg-ctx summary::-webkit-details-marker { display: none; }
details.msg-ctx summary::after { content: ' ▾'; }
details.msg-ctx[open] summary::after { content: ' ▴'; }
.msg-recalled { margin: 6px 0 0; padding: 8px 10px; list-style: none; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; font-size: 12px; line-height: 1.5; color: var(--text); font-weight: 400; max-width: 720px; }
.msg-recalled li { margin: 3px 0; }
.msg-recalled .memory-kind { margin-right: 4px; }
.know-scrim { display: none; }
.know-rail { width: 340px; border-left: 1px solid var(--border); background: var(--bg-panel); overflow-y: auto; padding: 14px 14px 20px; min-height: 0; }
.know-head { display: flex; justify-content: space-between; align-items: center; }
.know-stats { font-size: 12.5px; font-weight: 700; margin-top: 6px; }
.know-search input { width: 100%; padding: 8px 10px; font: inherit; font-size: 13px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.know-search input:focus { outline: none; border-color: var(--accent-dim); }
.know-section { margin-top: 14px; }
.know-section h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); display: flex; justify-content: space-between; }
.know-section h4 .hint { text-transform: none; letter-spacing: 0; font-weight: 500; }
.know-section .memory-item { margin-bottom: 6px; padding: 8px 10px; }
.know-section .memory-text { font-size: 12.5px; }
.know-foot { margin-top: 14px; display: flex; justify-content: flex-end; }
.kind-profile .memory-kind { background: rgba(77, 163, 255, .15); color: var(--blue); }
.kind-insight .memory-kind { background: rgba(217, 140, 255, .15); color: #d98cff; }
.kind-event .memory-kind { background: rgba(242, 179, 56, .15); color: var(--amber); }
.kind-plan .memory-kind { background: rgba(242, 179, 56, .12); color: var(--amber); }
@media (max-width: 1100px) {
  .chat { grid-template-columns: 220px minmax(0, 1fr); }
  .know-rail { position: fixed; right: 0; top: 0; bottom: 0; z-index: 40; box-shadow: -12px 0 30px rgba(0,0,0,.5); }
}

/* ---- Live activity: what the analyst is doing ---- */
.activity { margin: 4px 0 8px; font-size: 12.5px; color: var(--text-dim); }
.act-steps { display: flex; flex-direction: column; gap: 3px; }
.act-step, .act-tool, .act-draft { display: flex; align-items: center; gap: 8px; }
.act-draft { margin-top: 3px; flex-wrap: wrap; }
.dot.fail { background: var(--red); }
/* The briefing being generated, and its record once it has landed */
.brief-live { padding: 14px 16px; }
.brief-live-title { font-weight: 700; margin-bottom: 8px; }
.brief-live-note { font-weight: 400; font-size: 12.5px; color: var(--text-dim); }
.brief-live .activity { margin: 0; }
.brief-live .think-text { max-height: 260px; }
details.activity.brief-run { margin: 0 0 14px; }
.brief-think { margin: 0 0 14px; }
.act-text { color: var(--text); }
.act-detail { color: var(--text-dim); }
.act-detail:not(:empty)::before { content: '· '; }
.act-ms { margin-left: auto; font-variant-numeric: tabular-nums; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.dot.spin { border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.dot.done { background: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }
.act-tools { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.act-tool { color: var(--text); }
.think { margin: 6px 0; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-card); }
.think summary { cursor: pointer; padding: 6px 12px; font-size: 12px; font-weight: 700; color: var(--text-dim); list-style: none; }
.think summary::-webkit-details-marker { display: none; }
.think summary::before { content: '▸ '; }
.think[open] summary::before { content: '▾ '; }
.think-text { padding: 0 12px 10px; font-size: 12.5px; line-height: 1.55; color: var(--text-dim); white-space: pre-wrap; max-height: 220px; overflow-y: auto; font-style: italic; }
details.activity.folded { border: none; background: transparent; margin: 2px 0 8px; }
details.activity.folded > summary.act-summary { cursor: pointer; font-size: 12px; color: var(--text-dim); list-style: none; }
details.activity.folded > summary.act-summary::-webkit-details-marker { display: none; }
details.activity.folded > summary.act-summary::before { content: '▸ '; }
details.activity.folded[open] > summary.act-summary::before { content: '▾ '; }
details.activity.folded[open] > .act-steps { margin-top: 6px; }

/* ---- Trade offers on the table ---- */
.nav-badge { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 8px; border-radius: 999px; background: var(--amber); color: #1a1200; font-size: 11px; font-weight: 800; line-height: 18px; text-align: center; vertical-align: middle; }
.notice.warn { background: rgba(242, 179, 56, 0.08); border-color: rgba(242, 179, 56, 0.35); color: #f5d38a; }
.notice.offer-banner { display: flex; align-items: center; justify-content: space-between; gap: 14px; background: rgba(242, 179, 56, 0.08); border-color: rgba(242, 179, 56, 0.4); color: #f5d38a; }
.notice.offer-banner strong { color: #fff; }
.notice.offer-banner .btn { flex: none; }
.trade-card.offer { grid-template-columns: 1fr auto 1fr auto; position: relative; }
.trade-card.offer.incoming { border-color: rgba(242, 179, 56, 0.45); box-shadow: 0 0 0 1px rgba(242, 179, 56, 0.12) inset; }
.trade-card.offer.answered { opacity: 0.85; border-color: var(--border); box-shadow: none; }
.trade-card.offer .offer-when { margin-top: 8px; font-size: 12px; color: var(--text-dim); }
.trade-card.offer .offer-when.soon { color: var(--amber); font-weight: 600; }
.trade-card.offer .offer-verdict { grid-column: 1 / -1; font-size: 13.5px; padding: 8px 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); }
.trade-card.offer .offer-verdict.good { border-color: var(--accent-dim); }
.trade-card.offer .offer-verdict.bad { border-color: rgba(239, 91, 91, 0.5); }
.trade-card.offer .offer-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.trade-card.offer .offer-actions .btn { padding: 7px 14px; font-size: 12.5px; text-decoration: none; }
.trade-card.offer .offer-result { grid-column: 1 / -1; }
.trade-card.offer .offer-result:empty { display: none; }
@media (max-width: 760px) { .trade-card.offer { grid-template-columns: 1fr; } .notice.offer-banner { flex-direction: column; align-items: flex-start; } }

/* ---- Structured briefing ---- */
.brief-hero { position: relative; padding: 22px 26px; border-radius: 14px; border: 1px solid var(--border); background: linear-gradient(135deg, rgba(53, 201, 107, 0.07), rgba(77, 163, 255, 0.05) 60%, transparent); margin-bottom: 16px; }
.brief-hero.mood-urgent { background: linear-gradient(135deg, rgba(242, 179, 56, 0.12), rgba(242, 179, 56, 0.03) 60%, transparent); border-color: rgba(242, 179, 56, 0.4); }
.brief-hero.mood-trouble { background: linear-gradient(135deg, rgba(239, 91, 91, 0.12), rgba(239, 91, 91, 0.03) 60%, transparent); border-color: rgba(239, 91, 91, 0.4); }
.brief-hero.mood-strong { border-color: rgba(53, 201, 107, 0.4); }
.brief-mood { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); margin-bottom: 10px; }
.brief-mood.good { color: var(--accent); border-color: var(--accent-dim); }
.brief-mood.warn { color: var(--amber); border-color: rgba(242, 179, 56, 0.5); }
.brief-mood.bad { color: var(--red); border-color: rgba(239, 91, 91, 0.5); }
.brief-headline { font-size: 24px; line-height: 1.25; letter-spacing: -0.015em; margin: 0 0 10px; color: #fff; font-weight: 750; max-width: 30ch; }
.ai-output.plain { background: none; border: 0; padding: 0; min-height: 0; }
.brief-situation { max-width: 72ch; color: #d6deea; }
.brief-tiles { margin-bottom: 14px; }
.viz-fig { margin: 14px 0 18px; padding: 14px 16px 10px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); }
.viz-fig figcaption { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
.viz-fig figcaption strong { color: #fff; font-size: 14px; }
.viz-fig .takeaway { font-size: 13px; color: var(--text-dim); }
.viz-fig .viz-twin { margin-top: 6px; font-size: 12px; }
.viz-fig .viz-twin summary { cursor: pointer; color: var(--text-dim); }
.brief-actions { display: flex; flex-direction: column; gap: 10px; }
.brief-action { display: grid; grid-template-columns: 40px 1fr; gap: 12px; padding: 14px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); border-left-width: 4px; }
.brief-action.urgency-today { border-left-color: var(--accent); }
.brief-action.urgency-this-week { border-left-color: var(--blue); }
.brief-action.urgency-watch { border-left-color: var(--border); }
.brief-action-n { font-size: 22px; font-weight: 800; color: var(--text-dim); line-height: 1; padding-top: 4px; text-align: center; }
.brief-action-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.brief-action-head .urgency { text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; font-size: 10.5px; }
.brief-action-title { font-size: 16px; font-weight: 700; color: #fff; margin-bottom: 4px; }
.brief-action-detail { font-size: 13.5px; color: #d6deea; }
.brief-action-detail p { margin: 4px 0; }
.brief-action-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.brief-action-foot .btn { padding: 6px 12px; font-size: 12.5px; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; background: var(--bg); border: 1px solid var(--border); }
.chip.up { color: var(--accent); border-color: var(--accent-dim); }
.chip.down { color: var(--red); border-color: rgba(239, 91, 91, 0.5); }
.brief-verdicts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; }
.brief-verdict { padding: 14px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); font-size: 13.5px; }
.brief-verdict.verdict-accept { border-color: var(--accent-dim); }
.brief-verdict.verdict-decline { border-color: rgba(239, 91, 91, 0.45); }
.brief-verdict.verdict-counter { border-color: rgba(242, 179, 56, 0.45); }
.brief-verdict-head { margin-bottom: 6px; }
.brief-counter { margin-top: 6px; padding: 6px 10px; background: var(--bg); border-radius: 8px; }
.brief-matchup .brief-outlook { margin-bottom: 8px; }
.brief-matchup-summary { font-size: 14px; color: #d6deea; }
.brief-keyslots { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.brief-twin { margin: 6px 0 14px; font-size: 12.5px; }
.brief-twin summary { cursor: pointer; color: var(--text-dim); }
.brief-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.brief-cols .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 8px; }
.brief-inj { padding: 6px 0; border-bottom: 1px solid rgba(43, 54, 72, 0.55); font-size: 13.5px; }
.brief-inj:last-child { border-bottom: 0; }
.brief-league { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.brief-note { padding: 12px 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); font-size: 13.5px; }
.brief-note div { margin-top: 4px; color: #d6deea; }
.brief-think { margin-top: 18px; }
@media (max-width: 700px) { .brief-headline { font-size: 20px; } .brief-action { grid-template-columns: 30px 1fr; padding: 12px; } }

/* ---- Intel: usage chips, sparklines, settings panel ---- */
.chip.usage { font-weight: 600; color: var(--text); background: rgba(77, 163, 255, 0.08); border-color: rgba(77, 163, 255, 0.3); white-space: nowrap; }
.chip.usage.hot { border-color: var(--accent-dim); background: rgba(53, 201, 107, 0.1); }
.chip.game { font-weight: 500; color: var(--text-dim); white-space: nowrap; }
.chip.game.good { color: var(--accent); border-color: var(--accent-dim); }
.chip.game.bad { color: var(--red); border-color: rgba(239, 91, 91, 0.5); }
.intel-cell { white-space: normal; }
.intel-cell .chip { margin: 1px 4px 1px 0; }
.tr { font-size: 9px; margin-left: 3px; vertical-align: 1px; }
.tr.up { color: var(--accent); } .tr.down { color: var(--red); } .tr.flat { color: var(--text-dim); }
.risk { margin-left: 5px; font-size: 11px; cursor: help; }
.risk.high { color: var(--red); } .risk.watch { color: var(--amber); }
.opp { font-weight: 700; font-variant-numeric: tabular-nums; } .opp.hot { color: var(--accent); } .opp.warm { color: var(--amber); }
.pulse { font-variant-numeric: tabular-nums; } .pulse.hot, .pulse.rising { color: var(--accent); } .pulse.falling { color: var(--red); }
tr.admitted td { background: rgba(53, 201, 107, 0.05); }
.intel-game { margin: 4px 0 8px; }
.intel-sparks { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 8px 0 10px; }
.intel-spark { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.intel-spark .label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin-bottom: 4px; }
.intel-spark .hint { font-size: 10.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spark { display: block; max-width: 100%; }
.intel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13.5px; }
.intel-table td, .intel-table th { font-size: 12.5px; }
.market-line { margin-top: 6px; font-size: 12.5px; color: var(--text-dim); }
.market-line strong { color: var(--text); font-variant-numeric: tabular-nums; }
.chip.ecr { font-weight: 600; color: var(--text); background: rgba(255, 184, 77, 0.08); border-color: rgba(255, 184, 77, 0.35); white-space: nowrap; }
.chip.ecr.top { color: var(--accent); border-color: var(--accent-dim); background: rgba(53, 201, 107, 0.1); }
.ecr-inline { color: var(--amber); font-weight: 600; cursor: help; }

/* ==== Live (game day) ==== */
.live-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: -6px 0 14px; }
.live-status { font-size: 12.5px; color: var(--text-dim); }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); margin-right: 6px; animation: blink 1.4s infinite; vertical-align: 1px; }
.live-dot.idle { background: var(--text-dim); animation: none; }
.live-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.live-grid > .panel { min-width: 0; }
.live-team { padding: 0; overflow: hidden; }
.live-team .table-wrap { margin: 0; }
.live-team th, .live-team td { padding-left: 9px; padding-right: 9px; }
.live-team .chip.game { white-space: normal; line-height: 1.3; }
/* Two lineups side by side would need about 1300 px and the content box caps at 1180, so they stack: every column stays readable, nothing scrolls sideways. */
.live-grid.lineups { grid-template-columns: 1fr; }
.live-team-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; padding: 12px 14px 8px; }
.live-team-head .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 4px; }
.live-team-head .pts { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.live-bench summary { padding: 8px 14px; font-size: 12.5px; color: var(--text-dim); cursor: pointer; }
.live-bar { height: 3px; background: var(--border); border-radius: 2px; margin-top: 3px; overflow: hidden; min-width: 40px; }
.live-bar span { display: block; height: 100%; background: var(--accent); transition: width .6s ease; }
.live-row.in .live-pts strong { color: var(--accent); }
.live-row.bump td { animation: bump 1.6s ease-out; }
@keyframes bump { 0% { background: rgba(53, 201, 107, 0.28); } 100% { background: transparent; } }
.chip.game.live { color: var(--accent); border-color: var(--accent-dim); }
.chip.game.live.rz { color: var(--red); border-color: rgba(239, 91, 91, 0.5); }
.chip.game.final { color: var(--text-dim); }
.live-feed { list-style: none; margin: 0; padding: 0; max-height: 380px; overflow-y: auto; }
.live-feed li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; line-height: 1.45; }
.live-feed li:last-child { border-bottom: 0; }
.live-feed .when { color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12px; min-width: 64px; padding-top: 1px; }
.live-feed li.me .who { color: var(--accent); font-weight: 600; }
.live-feed li.injury .who, .live-feed li.report .who { color: var(--amber); font-weight: 600; }
.live-feed li.game .who { color: var(--text-dim); }
.live-strip { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.live-strip strong { font-variant-numeric: tabular-nums; }

/* ==== Phones (kept last so these rules win the cascade) ==== */
/* Phones and small tablets: a top bar and an off canvas menu. */
.topbar { display: none; }
.nav-scrim { display: none; }
@media (max-width: 780px) {
  html, body { overflow-x: hidden; }
  body { min-height: 100dvh; }
  .layout { flex-direction: column; min-height: 100dvh; }
  .topbar { position: sticky; top: 0; z-index: 60; display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 12px; padding-top: env(safe-area-inset-top); background: var(--bg-panel); border-bottom: 1px solid var(--border); }
  .menu-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); font-size: 18px; line-height: 1; cursor: pointer; flex: none; }
  .topbar-title { flex: 1; font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-week { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 64; background: rgba(5, 8, 14, 0.6); }
  .nav-scrim[hidden] { display: none; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 65; width: min(300px, 84vw); height: 100dvh; padding: 18px 14px; padding-top: calc(18px + env(safe-area-inset-top)); transform: translateX(-102%); transition: transform .22s cubic-bezier(.4, 0, .2, 1); box-shadow: 18px 0 44px rgba(0, 0, 0, .45); overflow-y: auto; }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open { overflow: hidden; }
  nav { flex-direction: column; }
  .nav-btn { padding: 12px 14px; font-size: 15px; min-height: 44px; }
  .content { padding: 14px 14px 32px; max-width: 100%; min-width: 0; }
  h1 { font-size: 21px; }
  .trade-card, .trade-card.offer { grid-template-columns: 1fr; }
  .trade-meta { text-align: left; }
  .trade-arrow { display: none; }
  /* iOS zooms into any field under 16px */
  .field input, .field select, textarea, input[type="search"], .compare-head select, .know-search input, .composer-box textarea, .plan-revise .revise-text, .import-row textarea, .msg-dialog textarea, .plan-note textarea { font-size: 16px; }
  /* grids that must stack */
  .plan-item { grid-template-columns: 1fr; gap: 6px; }
  .h2h-score { grid-template-columns: 1fr; }
  .h2h-score > div:last-child { text-align: left; }
  .drawer-hero { gap: 12px; }
  .drawer-headshot, .drawer-headshot-fallback { width: 64px; height: 64px; }
  .drawer-stats { grid-template-columns: repeat(2, 1fr); }
  .drawer-body { padding: 18px 16px 40px; }
  .drawer-panel .drawer-close, .know-head .drawer-close { width: 38px; height: 38px; font-size: 16px; }
  .import-row, .ai-input-row { flex-wrap: wrap; }
  .apply-bar { flex-direction: column; align-items: stretch; }
  .apply-bar .btn { width: 100%; }
  .mini-btn { min-height: 36px; padding: 6px 12px; }
  .msg-tools .mini-btn, .plan-item-tools .mini-btn, .msg-status .mini-btn { min-height: 34px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 12px 14px; }
  .card .value { font-size: 19px; }
  .brief-tiles { grid-template-columns: 1fr 1fr; }
  .msg-modal { padding: 0; align-items: flex-end; }
  .msg-dialog { width: 100%; max-height: calc(100dvh - 24px); overflow-y: auto; border-radius: 14px 14px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .viz-fig { padding: 10px 10px 8px; }
  .compare-panel { position: static; max-height: none; }
  .heat-legend { flex-wrap: wrap; }
  table { font-size: 13px; }
  th, td { padding: 8px 8px; }
  /* first column stays put while the numbers scroll */
  .table-wrap table th:first-child, .table-wrap table td:first-child { position: sticky; left: 0; background: var(--bg-card); z-index: 1; }
  .table-wrap tbody tr:nth-child(even) td:first-child { background: var(--bg-card); }
  .ai-output .md-table table th:first-child, .ai-output .md-table table td:first-child { position: sticky; left: 0; background: var(--bg-panel); }
}

@media (max-width: 780px) {
  /* The chat fills the screen under the top bar; the composer stays put
     above the keyboard; the thread list is a horizontal strip. */
  .content.chat-view { position: fixed; top: calc(52px + env(safe-area-inset-top)); left: 0; right: 0; bottom: 0; height: auto; overflow: hidden; padding: 0; }
  /* The page must not scroll under the chat: on iOS a scrollable document
     steals the swipe from the message list. The chat is pinned to the
     content box's edges (no percentage heights, which WebKit resolves
     unreliably inside a fixed box), so the list is the only scroller. */
  body.chat-open { overflow: hidden; height: 100dvh; }
  .chat { position: absolute; inset: 0; height: auto; grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .chat-main { position: relative; overflow: hidden; }
  .chat-rail { border-right: none; border-bottom: 1px solid var(--border); padding: 10px 12px; flex-direction: row; align-items: center; gap: 8px; overflow: hidden; }
  .chat-rail .thread-new { width: auto; flex: none; padding: 8px 12px; font-size: 13px; }
  .chat-rail .thread-items { flex-direction: row; display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; flex: 1; min-width: 0; padding-bottom: 2px; }
  .chat-rail .thread-item { min-width: 170px; max-width: 200px; flex: none; padding: 7px 10px; }
  .chat-rail .thread-empty { white-space: nowrap; font-size: 12px; }
  .chat-head { padding: 10px 14px; }
  .chat-head h2 { font-size: 14px; }
  .chat-scroll { padding: 12px 14px; gap: 12px; }
  .chat-scroll .msg-user { max-width: 92%; }
  .chat-composer { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); }
  .chat-chips { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .chat-chips .topic-chip { flex: none; }
  .composer-actions .btn { padding: 9px 14px; min-height: 40px; }
  /* What I know: a bottom sheet with a scrim */
  .know-rail { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 82dvh; z-index: 66; border-left: none; border-top: 1px solid var(--border); border-radius: 16px 16px 0 0; box-shadow: 0 -12px 40px rgba(0, 0, 0, .5); padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .know-scrim { display: none; position: fixed; inset: 0; z-index: 65; background: rgba(5, 8, 14, .55); }
  body.know-open .know-scrim { display: block; }
  .know-head .drawer-close { width: 38px; height: 38px; }
}

/* Live view on phones: one column, the feed stays short, and each lineup
   row stacks (slot, player and points on the first line; the game, the
   projection and the projected final on the second) so nothing sits off
   the edge of the screen. */
@media (max-width: 780px) {
  .live-grid { grid-template-columns: 1fr; }
  .live-feed { max-height: 300px; }
  .live-head .btn-row { width: 100%; }
  .live-team table, .live-team tbody { display: block; width: 100%; }
  .live-team tr.live-hdr { display: none; }
  .live-team tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "slot player player pts" "game game proj final"; gap: 3px 8px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); }
  .live-team tr:last-child { border-bottom: 0; }
  .live-team td { display: block; padding: 0 !important; border: 0; min-width: 0; }
  .live-team td:nth-child(1) { grid-area: slot; }
  .live-team td:nth-child(2) { grid-area: player; }
  .live-team td:nth-child(3) { grid-area: game; }
  .live-team td:nth-child(3) .chip.game { display: inline-block; }
  .live-team td:nth-child(4) { grid-area: pts; text-align: right; font-size: 16px; }
  .live-team td:nth-child(4) .live-bar { margin-left: auto; width: 48px; }
  .live-team td:nth-child(5) { grid-area: proj; text-align: right; font-size: 12px; color: var(--text-dim); white-space: nowrap; }
  .live-team td:nth-child(5)::before { content: 'proj '; }
  .live-team td:nth-child(6) { grid-area: final; text-align: right; font-size: 12px; white-space: nowrap; }
  .live-team td:nth-child(6)::before { content: 'final '; color: var(--text-dim); font-weight: 400; }
  .live-team .table-wrap { overflow-x: hidden; }
}

/* ---- Dashboard: game day panel ---- */
.gameday { padding: 16px 18px; margin: 6px 0 20px; }
.gameday-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.gameday-head .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 4px; }
.gameday-title { font-size: 18px; font-weight: 800; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gameday-title .vs { color: var(--text-dim); font-weight: 600; font-size: 13px; }
.gameday-status { font-size: 12.5px; color: var(--text-dim); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gameday-score { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; margin: 14px 0 4px; padding: 12px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; }
.gd-side.them { text-align: right; }
.gd-name { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); }
.gd-pts { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.gd-pts.good { color: var(--accent); }
.gd-pts.bad { color: var(--red); }
.gd-counts { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.gd-mid { text-align: center; min-width: 90px; }
.gd-edge { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.gd-edge.good { color: var(--accent); }
.gd-edge.bad { color: var(--red); }
.gd-h { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin: 16px 0 8px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.gd-h .hint { text-transform: none; letter-spacing: 0; font-size: 12px; }
.watch-list { display: flex; flex-direction: column; gap: 8px; }
.watch-game { display: grid; grid-template-columns: 96px 1fr; gap: 6px 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.watch-game.in { border-color: rgba(239, 91, 91, 0.45); }
.watch-game.in.rz { box-shadow: inset 3px 0 0 var(--red); }
.watch-game.post { opacity: 0.72; }
.watch-when { font-size: 12.5px; color: var(--text-dim); }
.watch-when .w-time { font-size: 15px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.watch-when .w-day { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.watch-main { min-width: 0; }
.w-match { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.w-match .at { color: var(--text-dim); font-weight: 500; font-size: 12px; margin: 0 4px; }
.w-where { font-size: 12.5px; margin-top: 2px; }
.w-play { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.watch-players { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; }
.wp { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; border: 1px solid var(--border); background: var(--bg-card); cursor: pointer; }
.wp.mine { border-color: var(--accent-dim); }
.wp:hover { border-color: var(--blue); }
.wp .wp-side { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); }
.wp.mine .wp-side { color: var(--accent); }
.wp strong { font-variant-numeric: tabular-nums; }
.wp.bump { animation: bump 1.6s ease-out; }
.gd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.gd-grid > div { min-width: 0; }
.gd-group { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin: 10px 0 2px; }
.gd-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.gd-row:last-child { border-bottom: 0; }
.gd-when { font-size: 12px; color: var(--text-dim); text-align: right; white-space: nowrap; }
.gd-num { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; }
.gd-row.in .gd-num { color: var(--accent); }
.gd-row.bump { animation: bump 1.6s ease-out; }
.gameday .live-feed { max-height: 260px; }
.watch-done summary { font-size: 12.5px; color: var(--text-dim); cursor: pointer; padding: 6px 2px; }
.watch-done .watch-list { margin-top: 8px; }
@media (max-width: 780px) {
  .gameday { padding: 14px; }
  .gameday-score { grid-template-columns: 1fr 1fr; }
  .gd-mid { grid-column: 1 / -1; }
  .watch-game { grid-template-columns: 1fr; }
  .watch-when { display: flex; gap: 8px; align-items: baseline; }
  .watch-players { grid-column: 1; }
  .gd-grid { grid-template-columns: 1fr; gap: 10px; }
  .gd-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .gd-when { grid-column: 2; text-align: left; white-space: normal; }
}

/* ---- Account pages and the account foot ---- */
body.auth-mode .sidebar, body.auth-mode .topbar, body.auth-mode .nav-scrim { display: none; }
/* Before the sign-in check answers, only the mark: no chrome, no nav, no "Loading". */
body.auth-pending .topbar { display: none; }
body.auth-pending .layout { display: none; }
body.auth-pending .nav-scrim { display: none; }
#boot { position: fixed; inset: 0; display: grid; place-items: center; font-size: 44px; background: var(--bg); opacity: 0.85; }
body:not(.auth-pending) #boot { display: none; }
body.auth-mode .content { max-width: none; padding: 24px 16px; }
.auth-shell { max-width: 440px; margin: 6vh auto 0; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; margin-bottom: 16px; justify-content: center; }
.auth-card h1 { font-size: 22px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .field input, .auth-card textarea { width: 100%; box-sizing: border-box; font-size: 16px; }
.auth-card .btn-row { margin-top: 8px; }
.auth-card .btn-row .btn { width: 100%; }
.auth-card .error-banner { margin: 4px 0 10px; }
.auth-links { margin-top: 18px; font-size: 13px; color: var(--text-dim); line-height: 1.8; }
.auth-links a { color: var(--blue); }
.auth-request { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.auth-request h2 { font-size: 15px; margin-bottom: 12px; }
.account-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-bottom: 4px; }
.account-foot[hidden] { display: none; }
.account-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.link-btn { background: none; border: none; color: var(--blue); font-size: 12px; cursor: pointer; padding: 0; flex: none; }
.link-btn:hover { text-decoration: underline; }

/* ---- Connect ESPN ---- */
.connect-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .connect-grid { grid-template-columns: 1fr; } }
.connect-card h2 { font-size: 16px; margin-bottom: 12px; }
.connect-card h3 { font-size: 13px; margin: 16px 0 6px; }
.connect-card .field { margin-bottom: 12px; }
.connect-card .field input { width: 100%; box-sizing: border-box; font-size: 16px; }
.connect-card summary { cursor: pointer; font-weight: 700; }
.connect-other { margin-top: 10px; }
.bookmarklet { display: inline-block; background: var(--accent-dim); color: #fff; padding: 3px 10px; border-radius: 6px; font-weight: 700; font-size: 12px; text-decoration: none; }
.pick-row { display: flex; align-items: center; gap: 10px; padding: 10px 8px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; cursor: pointer; }
.pick-row:hover { background: var(--bg-hover); }
.pick-row input { flex: none; }
.pick-main { font-weight: 700; }
.pick-sub { color: var(--text-dim); font-size: 12px; margin-left: auto; }
.connect-status { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

/* ---- Admin ---- */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.admin-table td, .admin-table th { white-space: normal; vertical-align: top; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.disabled-row td { color: var(--text-dim); }
.admin-inline { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.admin-inline input { flex: 1; min-width: 200px; }
.copy-url { width: 100%; box-sizing: border-box; margin-top: 6px; font-family: ui-monospace, monospace; font-size: 12px; }

/* ---- Metrics ---- */
.metrics-table td.range-cell { min-width: 170px; }
.range-bar { position: relative; display: inline-block; width: 110px; height: 10px; background: var(--bg-hover); border-radius: 5px; vertical-align: middle; margin-right: 8px; }
.range-fill { position: absolute; top: 0; height: 100%; background: rgba(77, 163, 255, 0.45); border-radius: 5px; }
.range-mark { position: absolute; top: -2px; width: 3px; height: 14px; background: var(--accent); border-radius: 2px; margin-left: -1px; }
.metric-row { cursor: pointer; }
.why-row td { background: rgba(35, 45, 63, 0.35); white-space: normal; }
.why-list { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.55; color: var(--text); }
.why-list li { margin: 2px 0; }
td.num.good { color: var(--accent); } td.num.warn { color: var(--amber); }
.metrics-table .tag { margin-left: 6px; }

/* ---- Plays ---- */
.plays { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; margin-bottom: 8px; }
.play { margin-bottom: 0; display: flex; flex-direction: column; gap: 8px; }
.play-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.play-head .tag { white-space: nowrap; }
.play-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.play-pitch { font-size: 13px; color: var(--text-dim); border-left: 3px solid var(--accent-dim); padding-left: 10px; }
.play-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: auto; }
.plays-top { border-color: rgba(53, 201, 107, 0.35); }

/* ---- Plays in the briefing ---- */
.brief-sub { font-size: 14px; margin: 14px 0 8px; }
.brief-sub .hint { font-weight: 400; margin-left: 6px; }
.brief-play.take-run { border-color: rgba(53, 201, 107, 0.45); }
.brief-play.take-skip { opacity: .75; }
.brief-play-note { font-size: 13.5px; }
.brief-action .options { margin-top: 8px; }

/* ---- The record of plays taken ---- */
.record { margin-bottom: 12px; }
.record-head { margin-bottom: 8px; }
.record-tiles { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 8px; }
.record-tile .label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); }
.record-tile .value { font-size: 20px; font-weight: 800; }
.record-tile .value.good { color: var(--accent); } .record-tile .value.bad { color: var(--red); }
.record-lessons { margin: 6px 0; padding-left: 18px; font-size: 13.5px; }
.record-recent { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
