:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --line: #e3e6eb;
  --text: #1b2330;
  --muted: #687385;
  --accent: #d9480f;
  --accent-soft: #fff1ea;
  --ok: #2f855a;
  --ok-soft: #e8f5ee;
  --warn: #b7791f;
  --warn-soft: #fff7e0;
  --info: #2b6cb0;
  --info-soft: #e8f1fb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 12px;
  --sidebar: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 22px; }
h3 { font-size: 16px; }
p { margin: .5em 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; color: var(--text); }
.center { text-align: center; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
.clamp { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }

.demo-banner { background: #1b2330; color: #e7eaf0; font-size: 13px; text-align: center; padding: 6px 16px; }
.demo-banner a { color: #ffb08a; margin-left: 6px; }

/* layout */
.app { display: flex; min-height: calc(100vh - 30px); }
.sidebar { width: var(--sidebar); flex: none; background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; height: calc(100vh - 30px); }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 6px; }
.logo { width: 34px; height: 34px; }
.logo .flame { fill: var(--accent); }
.logo .handle { fill: #3a4556; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
#nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); font-weight: 500; }
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item .badge { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; border-radius: 10px; padding: 1px 7px; }
.sidebar-foot { display: flex; flex-direction: column; gap: 12px; }
.me { display: flex; gap: 10px; align-items: center; padding: 8px 6px 0; border-top: 1px solid var(--line); }
.me-name { font-weight: 600; font-size: 14px; }

.main { flex: 1; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 28px 6px; }
.page-actions { display: flex; gap: 8px; align-items: center; }
#view { padding: 12px 28px 120px; display: flex; flex-direction: column; gap: 16px; max-width: 1280px; }

/* icons */
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.xs { width: 14px; height: 14px; vertical-align: -2px; }
.icon.lg { width: 36px; height: 36px; fill: #fff; stroke: none; }

/* controls */
.btn { display: inline-flex; align-items: center; gap: 6px; justify-content: center; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(.95); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.icon-btn { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 6px; font: inherit; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; flex: 1; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
select, input, textarea { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: var(--surface); color: var(--text); }
select.warn { border-color: var(--warn); background: var(--warn-soft); }
textarea { width: 100%; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; margin-bottom: 12px; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h3 { margin-right: auto; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.card-head + .row { border-top: 0; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-actions.end { justify-content: flex-end; margin-top: 12px; }
.empty { color: var(--muted); padding: 14px 0; text-align: center; }
.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; }
.dot.warn { background: var(--warn); }
.dot.info { background: var(--info); }
.tag { display: inline-block; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; font-size: 12px; color: var(--text); margin: 2px 4px 2px 0; }
.tags { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #3a4556; color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
.avatar.xs { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 56px; height: 56px; font-size: 18px; background: var(--accent); }
.ai-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: #6b46c1; background: #f1ebff; border-radius: 999px; padding: 2px 8px; }
.banner { border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 10px; }
.banner.warn { background: var(--warn-soft); color: #7a4f0e; }

/* today */
.brief { border-left: 4px solid #6b46c1; }
.brief-list { margin: 0 0 8px; padding-left: 20px; }
.brief-list li { margin: 4px 0; }

/* board */
.needs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.need-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.bar { height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; display: flex; }
.bar.tall { height: 14px; margin: 10px 0 8px; }
.bar-commit { background: var(--ok); }
.bar-offer { background: #f6ad55; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px 8px 6px 12px; box-shadow: var(--shadow); }
.search input { flex: 1; border: 0; outline: none; padding: 8px 4px; min-width: 0; }
.search-icon { color: #6b46c1; }
.chips { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: -6px; }
.chip { background: #f1ebff; color: #553c9a; border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 500; }
.kanban { display: grid; grid-template-columns: repeat(4, minmax(200px, 1fr)); gap: 12px; overflow-x: auto; }
.col { background: #eceef2; border-radius: var(--radius); padding: 10px; min-height: 260px; display: flex; flex-direction: column; gap: 8px; transition: background .15s; }
.col.over { background: var(--accent-soft); outline: 2px dashed var(--accent); }
.col-head { display: flex; justify-content: space-between; font-weight: 600; padding: 2px 4px 4px; }
.rcard { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); box-shadow: var(--shadow); cursor: grab; }
.rcard:hover { text-decoration: none; border-color: #c9ced6; }
.rcard.dragging { opacity: .5; }
.rcard-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rcard-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.ofp { font-weight: 700; font-size: 13px; background: var(--accent-soft); color: var(--accent); border-radius: 6px; padding: 1px 7px; }
.ofp.big { font-size: 28px; padding: 6px 14px; display: flex; flex-direction: column; align-items: center; line-height: 1.1; }

/* player */
.player-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.player-id { display: flex; gap: 14px; align-items: center; }
.player-id .tags { margin-top: 6px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.synopsis { font-size: 16px; }
.synopsis sup a { font-size: 11px; background: #f1ebff; color: #553c9a; border-radius: 4px; padding: 0 4px; margin-left: 1px; }
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.metric { background: var(--surface-2); border-radius: 8px; padding: 10px; }
.metric-v { font-weight: 700; font-size: 17px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); align-items: center; }
.kv:first-of-type { border-top: 0; }
.kv span { color: var(--muted); font-size: 14px; }
.kv b { text-align: right; font-weight: 500; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 13px; color: var(--muted); font-weight: 600; border-top: 0; }
.table tr.flagged td { background: var(--warn-soft); }
.grade { font-weight: 700; }
.g2, .g3 { color: #a0aec0; } .g4 { color: #718096; } .g5 { color: var(--text); } .g6 { color: var(--ok); } .g7, .g8 { color: var(--accent); }
.mini { display: inline-block; width: 80px; height: 6px; background: var(--surface-2); border-radius: 9px; overflow: hidden; margin-right: 8px; vertical-align: middle; }
.mini span { display: block; height: 100%; background: var(--info); }
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.video-thumb { aspect-ratio: 16 / 9; background: linear-gradient(135deg, #3a4556, #1b2330); border-radius: 10px; display: grid; place-items: center; position: relative; margin-bottom: 6px; }
.video-len { position: absolute; right: 8px; bottom: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; border-radius: 4px; padding: 1px 5px; }
.note { padding: 10px 0; border-top: 1px solid var(--line); }
.card-head + .note { border-top: 0; }
.note.scanned { background: #fffdf5; border: 1px solid #f0e6c8; border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.hand { font-family: Caveat, cursive; font-size: 22px; line-height: 1.25; color: #1f3a8a; }
.draft { border: 1px solid #f6ad55; background: #fffdf8; }

/* scan */
.scan-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; align-items: start; }
.paper-wrap { position: relative; }
.paper { background: #fffef8; border: 1px solid #e7e0c7; border-radius: 6px; padding: 26px 26px 18px 52px; box-shadow: 0 10px 30px rgba(16,24,40,.12); transform: rotate(-1.2deg); position: relative;
  background-image: repeating-linear-gradient(transparent, transparent 37px, #cfe0f3 37px, #cfe0f3 38px); background-position: 0 26px; }
.paper::before { content: ""; position: absolute; left: 38px; top: 0; bottom: 0; width: 1px; background: #f2a7a7; }
.hand-line { font-family: Caveat, cursive; font-size: 25px; line-height: 38px; color: #1f3a8a; border-radius: 4px; padding: 0 4px; transition: background .15s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hand-line:first-of-type { font-weight: 700; }
.hand-line.hl { background: rgba(246, 173, 85, .45); }
.paper-foot { margin-top: 10px; }
.scanline { position: absolute; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, transparent, var(--accent), transparent); box-shadow: 0 0 18px var(--accent); top: 0; animation: scan 1.4s ease-in-out infinite alternate; }
@keyframes scan { from { top: 2%; } to { top: 96%; } }
.checks { padding-left: 0; list-style: none; margin: 8px 0 14px; }
.checks li { padding-left: 24px; position: relative; margin: 6px 0; }
.checks li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 10px; height: 6px; border-left: 2px solid var(--ok); border-bottom: 2px solid var(--ok); transform: rotate(-45deg); }
.steps { padding-left: 0; list-style: none; margin: 8px 0; counter-reset: s; }
.steps li { position: relative; padding: 8px 0 8px 36px; color: var(--muted); counter-increment: s; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 8px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.steps li b { color: var(--muted); }
.steps li.running b, .steps li.done b { color: var(--text); }
.steps li.running::before { border-color: var(--accent); border-top-color: transparent; animation: spin .8s linear infinite; content: ""; }
.steps li.done::before { content: "\2713"; background: var(--ok); border-color: var(--ok); color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
.extract td { vertical-align: middle; }
.cell { width: 100%; border: 1px solid transparent; border-radius: 6px; background: transparent; padding: 4px 6px; outline: none; }
.cell:hover, .cell:focus { border-color: var(--line); background: var(--surface); }
.flag-note { color: #7a4f0e; padding: 2px 6px; }
.conf { font-weight: 700; font-size: 12px; border-radius: 6px; padding: 2px 6px; }
.conf.high { background: var(--ok-soft); color: var(--ok); }
.conf.mid { background: var(--info-soft); color: var(--info); }
.conf.low { background: var(--warn-soft); color: var(--warn); }

/* messages */
.msg-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.thread-list { padding: 6px; }
.thread-item { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); }
.thread-item:hover { background: var(--surface-2); text-decoration: none; }
.thread-item.active { background: var(--accent-soft); }
.bubbles { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; padding: 6px 2px 12px; }
.bubble { max-width: 75%; border-radius: 16px; padding: 9px 13px; }
.bubble.coach { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble.recruit { align-self: flex-start; background: #eceef2; border-bottom-left-radius: 4px; }
.bubble-meta { font-size: 11px; opacity: .8; margin-top: 3px; }
.composer { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; margin-bottom: 8px; }
.composer .row-actions { justify-content: flex-end; }

/* roster */
.big-num { font-size: 30px; font-weight: 700; }
.depth { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.depth-pos { background: var(--surface-2); border-radius: 10px; padding: 10px; }
.depth-label { font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.depth-name { font-size: 14px; padding: 3px 0; color: var(--muted); }
.depth-name.starter { color: var(--text); font-weight: 600; }

/* audit */
.ready-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.ready { display: flex; gap: 12px; align-items: center; }
.ring { --p: 0; width: 52px; height: 52px; border-radius: 50%; flex: none; display: grid; place-items: center; background: conic-gradient(var(--ok) calc(var(--p) * 1%), var(--line) 0); }
.ring span { width: 40px; height: 40px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.log td { white-space: nowrap; }
.log td:nth-child(4) { white-space: normal; }
.suggest { padding: 10px 0; border-top: 1px solid var(--line); }
.suggest:first-child { border-top: 0; }

/* settings */
.deploy { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.deploy-opt { border: 2px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
.deploy-opt input { display: none; }
.deploy-opt.active { border-color: var(--accent); background: var(--accent-soft); }
.pkg { margin-top: 10px; }
.pkg-name { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.mods { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.mod { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.switch { appearance: none; width: 40px; height: 22px; border-radius: 99px; background: #cbd2dc; position: relative; cursor: pointer; flex: none; border: 0; padding: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch:checked { background: var(--ok); }
.switch:checked::after { left: 21px; }

/* join */
.hero { background: linear-gradient(135deg, #1b2330, #2d3748); color: #fff; padding: 32px; }
.hero h2 { font-size: 28px; max-width: 720px; }
.hero p { color: #cbd2dc; max-width: 720px; font-size: 16px; }
.hero .btn { margin-top: 10px; }

/* overlays */
.tour { position: fixed; right: 24px; bottom: 24px; width: 360px; max-width: calc(100vw - 32px); background: #1b2330; color: #fff; border-radius: 14px; padding: 16px 18px; box-shadow: 0 20px 40px rgba(0,0,0,.25); display: none; z-index: 40; }
.tour.open { display: block; }
.tour h4 { font-size: 17px; margin: 4px 0; }
.tour p { color: #cbd2dc; font-size: 14px; }
.tour .muted { color: #a0aec0; }
.tour .btn { background: transparent; color: #fff; border-color: #4a5568; }
.tour .btn.primary { background: var(--accent); border-color: var(--accent); }
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; pointer-events: none; }
.toast { background: #1b2330; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 10px 25px rgba(0,0,0,.2); opacity: 0; transform: translateY(8px); transition: all .25s; max-width: 90vw; }
.toast.show { opacity: 1; transform: none; }
.modal-root { display: none; }
.modal-root.open { display: block; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 50; }
.modal { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 520px; max-width: calc(100vw - 32px); max-height: calc(100vh - 64px); overflow-y: auto; background: var(--surface); border-radius: 14px; z-index: 51; box-shadow: 0 30px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 6px; }
.modal-body { padding: 8px 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; }
.steps.static li { color: var(--text); }

/* responsive */
@media (max-width: 1024px) {
  :root { --sidebar: 210px; }
  .scan-layout, .msg-layout { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}
#view > * { min-width: 0; max-width: 100%; }
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar, .main { min-width: 0; max-width: 100vw; }
  #nav { max-width: 100%; }
  .topbar { flex-wrap: wrap; }
  .sidebar { position: static; width: 100%; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; gap: 10px; }
  #nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .nav-item { white-space: nowrap; padding: 7px 10px; }
  .nav-item .icon { display: none; }
  .sidebar-foot .me { display: none; }
  .topbar { padding: 14px 16px 4px; }
  #view { padding: 10px 16px 140px; }
  .grid-2, .deploy { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(4, 78vw); }
  .player-head { flex-direction: column; align-items: flex-start; }
  .tour { right: 16px; bottom: 16px; }
}
