:root {
  --bg: #f5f6f8; --panel: #ffffff; --ink: #15181d; --muted: #5f6775; --line: #e2e5ea;
  --accent: #0b5fff; --accent-ink: #fff; --ok: #12805c; --ok-bg: #e6f6ef; --warn: #9a5b00; --warn-bg: #fff4e0;
  --bad: #b42318; --bad-bg: #fdecea; --chip: #eef1f5;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014; --panel: #161a20; --ink: #eceff3; --muted: #98a1b0; --line: #262b34;
    --accent: #5f8fff; --accent-ink: #0e1014; --ok: #4fd1a1; --ok-bg: #10291f; --warn: #f0b45a; --warn-bg: #2b2112;
    --bad: #ff7b72; --bad-bg: #2d1515; --chip: #1f242c;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 4px; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 28px 0 12px; }
h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 24px 0 8px; }
.muted { color: var(--muted); } .small { font-size: .85rem; }

.shell { display: grid; grid-template-columns: 270px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: block; font-weight: 800; font-size: 1.15rem; color: var(--ink); text-decoration: none; margin-bottom: 18px; }
#athlete-list a { display: block; padding: 9px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; margin-bottom: 2px; }
#athlete-list a:hover, #athlete-list a.active { background: var(--chip); }
#athlete-list .meta { display: block; font-size: .78rem; color: var(--muted); }
.ai-status { margin-top: 24px; padding: 10px; border-radius: 8px; background: var(--chip); color: var(--muted); }
main { padding: 28px 32px 80px; max-width: 1000px; width: 100%; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.sm { padding: 5px 10px; font-size: .82rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 14px; }
form .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); }
label .req { color: var(--bad); }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; font-weight: 400; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.wide { grid-column: 1 / -1; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; color: var(--ink); font-size: .92rem; }
.check input { width: auto; margin-top: 4px; }
fieldset { border: 0; padding: 0; margin: 0 0 22px; }
legend { font-weight: 700; font-size: 1rem; margin-bottom: 12px; }

.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--chip); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.badge.high { background: var(--bad-bg); color: var(--bad); }
.badge.medium { background: var(--warn-bg); color: var(--warn); }
.badge.done, .badge.completed { background: var(--ok-bg); color: var(--ok); }
.badge.ready { background: var(--warn-bg); color: var(--warn); }
.badge.pending_approval { background: var(--warn-bg); color: var(--warn); }
.badge.failed, .badge.declined { background: var(--bad-bg); color: var(--bad); }

.rec { display: grid; grid-template-columns: 28px 1fr; gap: 12px; cursor: pointer; }
.rec input { width: 18px; height: 18px; margin-top: 3px; }
.rec.off { opacity: .55; }
.rec h4 { margin: 0; font-size: 1rem; }
.rec p { margin: 6px 0 0; }
.why { font-size: .86rem; color: var(--muted); }

.action h4 { margin: 0; font-size: 1rem; }
.artifact { border: 1px solid var(--line); border-radius: 9px; margin-top: 10px; overflow: hidden; }
.artifact .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 12px; background: var(--chip); font-size: .84rem; font-weight: 600; }
.artifact pre { margin: 0; padding: 12px; white-space: pre-wrap; word-wrap: break-word; font: .88rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; max-height: 340px; overflow: auto; }
.next { margin-top: 10px; padding: 10px 12px; background: var(--warn-bg); color: var(--ink); border-radius: 8px; font-size: .88rem; }
details summary { cursor: pointer; font-weight: 600; }

.timeline .item { border-left: 3px solid var(--line); padding: 2px 0 14px 16px; position: relative; }
.timeline .item::before { content: ""; position: absolute; left: -8px; top: 6px; width: 13px; height: 13px; border-radius: 50%; background: var(--panel); border: 3px solid var(--accent); }
.empty { text-align: center; padding: 60px 20px; }
.stat { display: inline-block; margin-right: 22px; }
.stat b { display: block; font-size: 1.5rem; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 9px; font-weight: 600; z-index: 10; }
.loading { display: flex; gap: 12px; align-items: center; padding: 40px 0; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { background: var(--bad-bg); color: var(--bad); padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.sticky-bar { position: sticky; bottom: 0; background: var(--bg); padding: 14px 0; border-top: 1px solid var(--line); margin-top: 10px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  main { padding: 20px 16px 60px; }
}

/* profile data */
.bad { color: var(--bad); }
.source { border-top: 1px solid var(--line); padding: 12px 0; }
.source:first-child { border-top: 0; }
.source a.small { margin-left: 6px; word-break: break-all; }
.paste { margin-top: 10px; }
.paste textarea { min-height: 120px; margin-bottom: 8px; }
.add-source { display: grid; grid-template-columns: 180px 1fr auto; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.add-source select, .add-source input { margin-top: 0; }
.table-wrap { overflow-x: auto; }
table.stats { width: 100%; border-collapse: collapse; margin-top: 8px; }
table.stats td, table.stats th { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.stats th.season { background: var(--chip); font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
table.stats td.val { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.stats tr.conflict td { background: var(--bad-bg); }
table.stats select { margin: 0; padding: 4px 6px; width: auto; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-top: 10px; }
.media { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.media.off { opacity: .45; }
.media img, .media .ph { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: flex; align-items: center; justify-content: center; background: var(--chip); font-size: 1.6rem; color: var(--muted); }
.media .body { padding: 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; font-size: .9rem; }
.media .body a { font-weight: 600; word-break: break-word; }
@media (max-width: 760px) { .add-source { grid-template-columns: 1fr; } }
.source .row { flex-shrink: 0; }
@media (max-width: 1100px) {
  .source > .spread { flex-direction: column; }
  .source > .spread > .row { margin-top: 6px; }
}

/* uploaded photos */
#photos.drop, #videos.drop { outline: 2px dashed var(--accent); outline-offset: -6px; }
.upload { cursor: pointer; color: var(--accent-ink); margin: 0; }
.upload input { display: none; }
.upload.busy { opacity: .6; pointer-events: none; }
.drop-hint { margin: 12px 0 0; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-top: 12px; }
.photo { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.photo img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--chip); }
.photo .body { padding: 8px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.photo .body input { margin: 0; padding: 6px 8px; font-size: .85rem; }

/* uploaded videos */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 12px; }
.video { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.video video { width: 100%; aspect-ratio: 16/9; display: block; background: #000; }
.video .body { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.video .body input { margin: 0; padding: 6px 8px; font-size: .85rem; }
.video .body .row { display: flex; gap: 6px; align-items: center; }
.video .body .row .muted { margin-right: auto; }

/* sign-in page and account */
.auth-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.auth { width: 100%; max-width: 400px; padding: 24px 16px; }
.auth .brand { text-align: center; }
.auth form { display: flex; flex-direction: column; gap: 14px; }
.auth h1 { font-size: 1.3rem; }
.auth p { margin: 0; }
.auth > p { text-align: center; margin-top: 4px; }
.auth .error { margin: 0; }
.signed-in { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.signed-in a { color: var(--ink); text-decoration: none; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.signed-in a:hover { text-decoration: underline; }
.users .user { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.users .user:first-child { border-top: 0; }
.account form .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
