:root {
  --red: #c91b2b; --red-strong: #a31421; --red-soft: #fbe8ea;
  --ink: #16181d; --ink-2: #444a55; --ink-3: #6b7280;
  --bg: #f4f4f2; --card: #ffffff; --line: #e3e3df; --line-2: #d0d0ca;
  --field: #ffffff; --head: #111114; --head-ink: #ffffff;
  --blue: #2563c9; --blue-soft: #e7effb;
  --green: #18804a; --green-soft: #e3f4ea;
  --amber: #b26a00; --amber-soft: #fdf1dc;
  --risk: #c21d2f; --risk-soft: #fbe5e7;
  --gray-soft: #eeeeec;
  --bar: #c9ccd3; --acute: #c91b2b; --chronic: #2b2f38;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --red: #e04a5c; --red-strong: #f06274; --red-soft: #3a1a1f;
    --ink: #eceef2; --ink-2: #b7bcc6; --ink-3: #8b919c;
    --bg: #0f1114; --card: #181b20; --line: #2a2e35; --line-2: #3a3f48;
    --field: #12151a; --head: #08090b; --head-ink: #ffffff;
    --blue: #7fb0ff; --blue-soft: #18263d; --green: #5fd193; --green-soft: #13301f;
    --amber: #f2b44c; --amber-soft: #36280f; --risk: #ff7080; --risk-soft: #3d171c; --gray-soft: #23262c;
    --bar: #3d424c; --acute: #ff6a7c; --chronic: #d8dbe2;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --red: #e04a5c; --red-strong: #f06274; --red-soft: #3a1a1f;
  --ink: #eceef2; --ink-2: #b7bcc6; --ink-3: #8b919c;
  --bg: #0f1114; --card: #181b20; --line: #2a2e35; --line-2: #3a3f48;
  --field: #12151a; --head: #08090b; --head-ink: #ffffff;
  --blue: #7fb0ff; --blue-soft: #18263d; --green: #5fd193; --green-soft: #13301f;
  --amber: #f2b44c; --amber-soft: #36280f; --risk: #ff7080; --risk-soft: #3d171c; --gray-soft: #23262c;
  --bar: #3d424c; --acute: #ff6a7c; --chronic: #d8dbe2;
  --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: Oswald, Inter, sans-serif; letter-spacing: .01em; margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.6rem; text-transform: uppercase; }
h2 { font-size: 1.2rem; text-transform: uppercase; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--red); }
button, input, select, textarea { font: inherit; color: inherit; }

/* header */
.topbar { background: var(--head); color: var(--head-ink); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 4px solid var(--red); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand > div { min-width: 0; }
.brand-logo { height: 46px; width: auto; flex: none; display: block; }
.brand-team { font-family: Oswald, sans-serif; font-weight: 700; font-size: 1.05rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-app { font-size: .78rem; opacity: .75; text-transform: uppercase; letter-spacing: .08em; }
.topbar-right { display: flex; align-items: center; gap: 8px; font-size: .85rem; flex: none; }
.role { padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.12); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.role.coach { background: var(--red); }
.linkbtn { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; padding: 4px; opacity: .85; }

.tabs { display: flex; gap: 2px; overflow-x: auto; background: var(--card); border-bottom: 1px solid var(--line); padding: 0 8px; scrollbar-width: none; position: sticky; top: 0; z-index: 5; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; padding: 12px 12px 10px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: .88rem; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--red); border-bottom-color: var(--red); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 18px 16px 64px; }
.loading { padding: 48px 0; text-align: center; color: var(--ink-3); }
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 16px; margin-bottom: 14px; }
.pagehead p { color: var(--ink-2); margin: 0; max-width: 70ch; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.hint { font-size: .8rem; color: var(--ink-3); margin-top: 3px; }

/* fields */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: .75rem; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=password], select, textarea {
  background: var(--field); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; min-height: 40px; width: 100%; min-width: 0;
}
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--red); outline-offset: 0; border-color: transparent; }
input:disabled, select:disabled { opacity: .55; }
.fgrid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.fgrid .wide { grid-column: 1 / -1; }
fieldset { border: 1px dashed var(--line-2); border-radius: 8px; padding: 10px 12px 12px; margin: 12px 0 0; }
legend { font-weight: 700; font-size: .85rem; padding: 0 6px; }
details summary { cursor: pointer; font-weight: 600; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-2); background: var(--card); border-radius: 8px; padding: 8px 14px; min-height: 40px; cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-strong); }
.btn.sm { min-height: 30px; padding: 3px 9px; font-size: .82rem; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* stat tiles */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile .lbl { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; }
.tile .val { font-family: Oswald, sans-serif; font-size: 1.9rem; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: .8rem; color: var(--ink-2); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; background: var(--gray-soft); color: var(--ink-2); }
.z-Undertrained { background: var(--blue-soft); color: var(--blue); }
.z-Sweet { background: var(--green-soft); color: var(--green); }
.z-Caution { background: var(--amber-soft); color: var(--amber); }
.z-High { background: var(--risk-soft); color: var(--risk); }
.z-Incomplete { background: var(--amber-soft); color: var(--amber); }
.dtgrid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.dtex { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.dtex ol { margin: 8px 0 0; padding-left: 20px; }
.dtex li { margin: 6px 0; }
details.card > summary { cursor: pointer; }
.callout { border-left: 4px solid var(--line-2); background: var(--gray-soft); padding: 10px 12px; border-radius: 6px; margin: 0 0 12px; font-size: .92rem; }
.callout.ok { border-color: var(--green); background: var(--green-soft); }
.callout.warn { border-color: var(--amber); background: var(--amber-soft); }
.callout.bad { border-color: var(--risk); background: var(--risk-soft); }
.callout.info { border-color: var(--blue); background: var(--blue-soft); }

.dt-Low { background: var(--blue-soft); color: var(--blue); }
.dt-Medium { background: var(--green-soft); color: var(--green); }
.dt-High { background: var(--amber-soft); color: var(--amber); }
.dt-Game, .dt-Bullpen { background: var(--risk-soft); color: var(--risk); }
.dt-No { background: var(--gray-soft); color: var(--ink-3); }

/* tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; max-width: 100%; }
table { border-collapse: collapse; width: 100%; font-size: .86rem; }
th, td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--gray-soft); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); white-space: nowrap; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--gray-soft); }
tr.sel td { background: var(--red-soft); }
tr.today td { box-shadow: inset 0 2px 0 var(--red), inset 0 -2px 0 var(--red); }
tr.off td { color: var(--ink-3); }
tr.pen td { font-weight: 600; }
td input, td select { min-height: 32px; padding: 4px 6px; font-size: .84rem; }
td input[type=number] { width: 62px; }
.plan-text { min-width: 260px; }
.nowrap { white-space: nowrap; }
.settings td.nowrap { white-space: normal; }
.settings td input[type=number] { width: 76px; margin: 2px 0; }
.settings table { table-layout: auto; }

/* charts */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--ink-3); font-size: 11px; font-family: Inter, sans-serif; }
.chart .grid line { stroke: var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .8rem; color: var(--ink-2); margin-top: 6px; }
.legend i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

/* login */
.login { max-width: 420px; margin: 40px auto; }
.login .card { padding: 24px; }
.err { color: var(--risk); font-weight: 600; font-size: .9rem; margin-top: 8px; }

.toast { visibility: hidden; position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(120px); background: var(--head); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .9rem; display: flex; gap: 12px; align-items: center; transition: transform .2s; z-index: 50; max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.show { visibility: visible; transform: translateX(-50%) translateY(0); }
.toast button { background: none; border: 1px solid rgba(255,255,255,.4); color: #fff; border-radius: 6px; padding: 3px 9px; cursor: pointer; }
.toast.error { background: var(--risk); }

.guide h2 { margin-top: 1.4rem; }
.guide p, .guide li { max-width: 78ch; color: var(--ink-2); }
.guide .formula { font-family: Oswald, sans-serif; font-size: 1.15rem; color: var(--ink); background: var(--red-soft); padding: 10px 14px; border-radius: 8px; display: inline-block; }

@media (max-width: 640px) {
  .wrap { padding: 14px 16px 64px; }
  h1 { font-size: 1.3rem; }
  .tile .val { font-size: 1.5rem; }
  .brand-app { display: none; }
  .hide-sm { display: none; }
  .topbar { padding: 10px 12px; }
  .brand-team { font-size: .92rem; }
  .brand-logo { height: 38px; }
  .tbl-wrap:has(table.stack) { border: 0; overflow: visible; }
  table.stack thead { display: none; }
  table.stack, table.stack tbody { display: block; }
  table.stack tr { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
  table.stack td { display: block; border: 0; padding: 0; text-align: left; }
  table.stack td.full { flex-basis: 100%; }
  table.stack td[data-l] { display: inline-flex; align-items: center; gap: 4px; }
  table.stack td[data-l]::before { content: attr(data-l) " "; color: var(--ink-3); font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; }
  table.stack td:empty { display: none; }
  table.stack .plan-text { min-width: 0; }
  table.stack tr.today { box-shadow: inset 3px 0 0 var(--red); padding-left: 10px; }
  table.stack tr.today td { box-shadow: none; }
  table.stack td input[type=number] { width: 64px; }
}
@media print {
  .topbar, .tabs, .no-print, .toast { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* ---------- program / today ---------- */
.eyebrow { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--red); }
h2.sec { margin: 18px 0 10px; }
.login-logo { display: block; margin: 0 auto 10px; width: 160px; height: auto; }
.login h1 { text-align: center; }
.hero { display: flex; gap: 16px; align-items: center; justify-content: space-between; background: var(--head); color: #fff; border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; border-left: 6px solid var(--red); }
.hero p { color: rgba(255,255,255,.85); margin: 6px 0 0; max-width: 62ch; }
.hero a { color: #ff8a96; }
.hero img { width: 150px; height: auto; flex: none; }
.hero h1 { color: #fff; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; overflow: hidden; background: var(--card); }
.seg button { border: 0; background: none; padding: 7px 14px; font-weight: 600; font-size: .85rem; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--head); color: #fff; }
.daycard { background: var(--card); border: 1px solid var(--line); border-top: 5px solid var(--line-2); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.daycard h2 { font-size: 1.45rem; margin: 2px 0 0; }
.dc-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.dc-title { font-weight: 700; color: var(--ink-2); margin-top: 2px; }
.kind { padding: 4px 10px; border-radius: 999px; font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; background: var(--gray-soft); color: var(--ink-2); }
.dc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 14px 0; }
.dc-stats div { background: var(--gray-soft); border-radius: 8px; padding: 8px 12px; }
.dc-stats span { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 700; }
.dc-stats strong { font-family: Oswald, sans-serif; font-size: 1.15rem; font-weight: 600; }
.steps { margin: 4px 0 12px; padding-left: 20px; }
.steps li { margin: 3px 0; }
.note-p, .note-x { border-left: 4px solid var(--red); background: var(--red-soft); border-radius: 6px; padding: 9px 12px; margin: 8px 0; font-size: .92rem; }
.note-x { border-left-color: var(--ink-3); background: var(--gray-soft); }
.note-p strong, .note-x strong { margin-right: 6px; }
.note-x ul { margin: 6px 0 0; padding-left: 18px; }
details.proj { margin-top: 10px; }
details.proj summary { font-size: .85rem; color: var(--ink-2); }
table.mini { font-size: .84rem; }
table.mini td { padding: 4px 6px; }
.k-throw { border-top-color: var(--ink) !important; }
.kind.k-throw { background: var(--head); color: #fff; }
.k-pen { border-top-color: var(--red) !important; }
.kind.k-pen, .kind.k-live, .kind.k-game { background: var(--red); color: #fff; }
.k-live { border-top-color: var(--red-strong) !important; }
.k-game { border-top-color: var(--red) !important; }
.kind.k-holiday { background: var(--amber-soft); color: var(--amber); }
.k-holiday { border-top-color: var(--amber) !important; }
.weekchips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; scrollbar-width: thin; }
.weekchips button { flex: none; border: 1px solid var(--line-2); background: var(--card); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: .82rem; cursor: pointer; color: var(--ink-2); }
.weekchips button.bridge { border-style: dashed; border-color: var(--red); }
.weekchips button.on { background: var(--red); border-color: var(--red); color: #fff; }
.weekgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.wday { text-align: left; border: 1px solid var(--line); border-top: 4px solid var(--line-2); background: var(--card); border-radius: 8px; padding: 8px; cursor: pointer; min-height: 74px; display: flex; flex-direction: column; gap: 3px; color: var(--ink); font: inherit; }
.wday .wd { font-size: .72rem; font-weight: 700; color: var(--ink-3); text-transform: uppercase; }
.wday .wt { font-weight: 700; font-size: .84rem; line-height: 1.2; }
.wday .wk { font-size: .74rem; color: var(--ink-3); }
.wday.k-off { background: var(--gray-soft); color: var(--ink-3); }
.wday.k-holiday { background: var(--amber-soft); }
.wday.k-pen, .wday.k-live, .wday.k-game { background: var(--red-soft); }
.wday.sel { outline: 2px solid var(--red); outline-offset: 1px; }
.wday.is-today .wd::after { content: ' · today'; color: var(--red); }
.bridge-tag { color: var(--red); }
.legend i.lg { width: 12px; height: 12px; border-radius: 3px; border: 0; border-top: 4px solid; background: var(--gray-soft); }
.expert ol { padding-left: 20px; margin: 0; }
.expert li { margin: 0 0 10px; color: var(--ink-2); max-width: 90ch; }
.expert li strong { color: var(--ink); }
ul.rules { padding-left: 18px; margin: 0; }
ul.rules li { margin: 0 0 8px; color: var(--ink-2); }
ul.rules li strong { color: var(--ink); }
@media (max-width: 640px) {
  .weekgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { flex-direction: column-reverse; align-items: flex-start; }
  .hero img { width: 120px; }
  .daycard h2 { font-size: 1.2rem; }
  .seg button { padding: 6px 10px; font-size: .8rem; }
}

/* ---------- players ---------- */
.role.player { background: var(--red); }
.login-seg { display: flex; margin: 4px 0 14px; }
.login-seg button { flex: 1; }
.armpick { border: 0; padding: 0; margin: 14px 0 0; }
.armpick legend { padding: 0; margin-bottom: 6px; font-size: .75rem; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span { display: inline-block; padding: 9px 14px; border: 1px solid var(--line-2); border-radius: 999px; font-weight: 700; font-size: .9rem; background: var(--card); min-width: 64px; text-align: center; }
.chip input:focus-visible + span { outline: 2px solid var(--red); outline-offset: 1px; }
.chip.a-Great input:checked + span, .chip.a-Normal input:checked + span { background: var(--green); border-color: var(--green); color: #fff; }
.chip.a-Tight input:checked + span { background: var(--amber); border-color: var(--amber); color: #fff; }
.chip.a-Sore input:checked + span, .chip.a-Pain input:checked + span { background: var(--risk); border-color: var(--risk); color: #fff; }
.card.logged { border-left: 5px solid var(--green); }
table.mini input[type=number] { width: 72px; }
.armstrip { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 4px; margin-bottom: 4px; }
.as { text-align: center; border-radius: 6px; background: var(--gray-soft); padding: 4px 0; font-size: .7rem; color: var(--ink-3); }
.as b { display: block; font-size: .95rem; color: var(--ink); }
.as.a-Great, .as.a-Normal { background: var(--green-soft); }
.as.a-Tight { background: var(--amber-soft); }
.as.a-Sore, .as.a-Pain { background: var(--risk-soft); }
.as.a-Sore b, .as.a-Pain b { color: var(--risk); }
.as.nothrow { opacity: .55; }
code { font-family: ui-monospace, Menlo, monospace; font-weight: 700; }
.pincards { display: none; }
@media print {
  body.print-pins main > *:not(.pincards) { display: none !important; }
  body.print-pins .pincards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .pincard { display: flex; gap: 10px; align-items: center; border: 1px dashed #999; border-radius: 8px; padding: 10px; break-inside: avoid; font-size: 13px; color: #000; }
  .pincard b { font-size: 18px; letter-spacing: .1em; }
}
@media (max-width: 640px) {
  .armstrip { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .chip span { padding: 10px 12px; min-width: 0; }
}


/* ---------- ArmCare ---------- */
.armcare-card { border-top: 5px solid var(--red); }
.armcare-card details { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--gray-soft); }
.armcare-card details[open] summary { margin-bottom: 6px; }
.armcare-card .eyebrow { color: var(--red); }
@media (max-width: 640px) {
  .armcare-card .row { align-items: flex-start !important; }
}
