/* Casting Radar. Tokens first, components through tokens only. */
:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #ecebe5;
  --ink: #16181d;
  --ink-2: #4b4f58;
  --ink-3: #7c808a;
  --line: #dcdad3;
  --side-bg: #151b2b;
  --side-ink: #c9cfdc;
  --side-ink-dim: #7f8799;
  --side-active: #222b40;
  --accent: #c8102e;
  --accent-ink: #ffffff;
  --st-dev: #b7791f;
  --st-order: #6f42c1;
  --st-pre: #2f5fd6;
  --st-cast: #1d7f6d;
  --st-prod: #4b4f58;
  --st-done: #9a9ea8;
  --p1: #c8102e;
  --p2: #2f5fd6;
  --p3: #9a9ea8;
  --shadow: 0 1px 2px rgba(20, 24, 33, .06), 0 6px 18px rgba(20, 24, 33, .05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101319; --surface: #181c25; --surface-2: #1f2430; --ink: #eceef2; --ink-2: #b7bcc8; --ink-3: #7f8799;
    --line: #2a303d; --side-bg: #0b0e15; --side-ink: #c9cfdc; --side-ink-dim: #6f7789; --side-active: #1a2030;
    --st-dev: #d9a441; --st-order: #a07be6; --st-pre: #6b8ff0; --st-cast: #3fae98; --st-prod: #a9aeb9; --st-done: #6f7789;
    --p1: #ff4d63; --p2: #6b8ff0; --p3: #6f7789; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #101319; --surface: #181c25; --surface-2: #1f2430; --ink: #eceef2; --ink-2: #b7bcc8; --ink-3: #7f8799;
  --line: #2a303d; --side-bg: #0b0e15; --side-ink: #c9cfdc; --side-ink-dim: #6f7789; --side-active: #1a2030;
  --st-dev: #d9a441; --st-order: #a07be6; --st-pre: #6b8ff0; --st-cast: #3fae98; --st-prod: #a9aeb9; --st-done: #6f7789;
  --p1: #ff4d63; --p2: #6b8ff0; --p3: #6f7789; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif; font-size: 14px; line-height: 1.5;
}
a { color: inherit; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--st-pre); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

/* Sidebar */
.side { background: var(--side-bg); color: var(--side-ink); padding: 22px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.wordmark { font-family: "Barlow Condensed", "Arial Narrow", sans-serif; font-weight: 800; font-size: 18px; letter-spacing: .14em; color: #fff; text-transform: uppercase; }
.wordmark small { display: block; font-family: "IBM Plex Sans", sans-serif; font-weight: 500; font-size: 11px; letter-spacing: .08em; color: var(--side-ink-dim); margin-top: 2px; }
.nav-group { margin-top: 26px; }
.nav-group h4 { margin: 0 0 6px 10px; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--side-ink-dim); font-weight: 600; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 6px; text-decoration: none; color: var(--side-ink); font-weight: 500; }
.nav a:hover { background: var(--side-active); }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav .count { font-size: 11px; color: var(--side-ink-dim); font-variant-numeric: tabular-nums; }
.side-foot { margin-top: 30px; font-size: 11px; color: var(--side-ink-dim); line-height: 1.6; }

/* Main */
.main { padding: 26px 32px 60px; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.page-title { font-family: "Barlow Condensed", "Arial Narrow", sans-serif; font-weight: 800; font-size: 34px; letter-spacing: .01em; line-height: 1; margin: 0; text-transform: uppercase; }
.page-sub { color: var(--ink-3); font-size: 13px; }

.summary { display: flex; gap: 14px; align-items: flex-start; background: var(--surface); border-left: 4px solid var(--accent); box-shadow: var(--shadow); padding: 14px 18px; margin-bottom: 18px; border-radius: 0 6px 6px 0; }
.summary p { margin: 0; max-width: 70ch; }
.summary .k { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; white-space: nowrap; padding-top: 3px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--surface); box-shadow: var(--shadow); border-radius: 6px; padding: 12px 14px; border-left: 4px solid var(--p2); }
.tile .n { font-family: "Barlow Condensed", "Arial Narrow", sans-serif; font-size: 34px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.tile .l { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; margin-top: 4px; }
.tile.hot { border-left-color: var(--p1); }
.tile.cast { border-left-color: var(--st-cast); }
.tile.dev { border-left-color: var(--st-dev); }
.tile.muted { border-left-color: var(--line); }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; align-items: center; }
.toolbar input[type=search], .toolbar select {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; font: inherit; font-size: 13px;
}
.toolbar input[type=search] { min-width: 240px; flex: 1 1 240px; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: 4px 11px; font-size: 12px; cursor: pointer; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.toolbar .spacer { flex: 1; }
.toolbar .meta { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }

/* Section headers */
.sec { margin: 26px 0 10px; display: flex; align-items: baseline; gap: 10px; }
.sec h2 { margin: 0; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); font-weight: 700; }
.sec .n { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }

/* Project cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); box-shadow: var(--shadow); border-radius: 0 6px 6px 0; border-left: 4px solid var(--p2);
  padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; transition: transform .12s ease;
}
.card:hover { transform: translateY(-1px); }
.card.p1 { border-left-color: var(--p1); }
.card.p3 { border-left-color: var(--p3); }
.card-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.card h3 { margin: 0; font-family: "Barlow Condensed", "Arial Narrow", sans-serif; font-weight: 700; font-size: 20px; letter-spacing: .02em; text-transform: uppercase; line-height: 1.1; text-wrap: balance; }
.card .studio { color: var(--ink-2); font-size: 13px; }
.pills { display: flex; flex-wrap: wrap; gap: 5px; }
.pill { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; padding: 2px 7px; border-radius: 3px; color: #fff; white-space: nowrap; }
.pill.fmt { background: transparent; color: var(--ink-2); border: 1px solid var(--line); }
.pill.new { background: var(--accent); }
.pill.upd { background: var(--st-pre); }
.st-dev { background: var(--st-dev); } .st-order { background: var(--st-order); } .st-pre { background: var(--st-pre); }
.st-cast { background: var(--st-cast); } .st-prod { background: var(--st-prod); } .st-done { background: var(--st-done); }
.signal { color: var(--ink-2); font-size: 13px; border-left: 2px solid var(--line); padding-left: 10px; margin: 2px 0; }
.kv { display: grid; grid-template-columns: 78px 1fr; gap: 3px 10px; font-size: 12.5px; }
.kv .k { color: var(--ink-3); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; font-weight: 600; padding-top: 2px; }
.kv .v a { text-decoration: none; border-bottom: 1px dotted var(--ink-3); }
.kv .v a:hover { border-bottom-style: solid; }
.card-foot { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.card-foot .src a { color: var(--ink-3); text-decoration: none; margin-right: 8px; }
.card-foot .src a:hover { color: var(--ink); }

/* Detail drawer */
.drawer-bg { position: fixed; inset: 0; background: rgba(10, 12, 18, .45); display: none; z-index: 20; }
.drawer-bg.open { display: block; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(640px, 100vw); background: var(--surface); box-shadow: -8px 0 30px rgba(0,0,0,.2); z-index: 21; overflow-y: auto; transform: translateX(100%); transition: transform .18s ease; }
.drawer.open { transform: none; }
.drawer-in { padding: 24px 28px 40px; }
.drawer h2.title { font-family: "Barlow Condensed", "Arial Narrow", sans-serif; font-weight: 800; font-size: 30px; text-transform: uppercase; margin: 6px 0 4px; line-height: 1.05; }
.drawer .close { float: right; background: none; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; color: var(--ink-2); }
.drawer .logline { margin: 10px 0 14px; max-width: 65ch; }
.dl { display: grid; grid-template-columns: 120px 1fr; gap: 6px 14px; font-size: 13px; margin: 0 0 16px; }
.dl dt { color: var(--ink-3); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; font-weight: 600; padding-top: 3px; margin: 0; }
.dl dd { margin: 0; }
.people-list { display: grid; gap: 6px; }
.person { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: baseline; padding: 7px 10px; background: var(--surface-2); border-radius: 5px; }
.person .nm { font-weight: 600; }
.person .rl { color: var(--ink-3); font-size: 12px; margin-left: 6px; }
.person .dt { display: block; color: var(--ink-2); font-size: 12px; }
.links a { font-size: 11.5px; text-decoration: none; color: var(--ink-2); border: 1px solid var(--line); padding: 2px 7px; border-radius: 4px; margin-left: 4px; white-space: nowrap; }
.links a:hover { border-color: var(--ink-2); }
.events { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: 12.5px; }
.events li { display: grid; grid-template-columns: 82px 1fr; gap: 10px; }
.events time { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 20px; }
.btn { background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); border-radius: 6px; padding: 6px 12px; cursor: pointer; font-size: 12.5px; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.on { box-shadow: inset 0 0 0 2px var(--accent); }
textarea.notes { width: 100%; min-height: 70px; border: 1px solid var(--line); border-radius: 6px; padding: 8px; font: inherit; background: var(--surface); color: var(--ink); }

/* Tables (people, companies, sources) */
.table-wrap { overflow-x: auto; background: var(--surface); box-shadow: var(--shadow); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; }
tr:last-child td { border-bottom: none; }
td.num { font-variant-numeric: tabular-nums; text-align: right; }
.proj-link { background: none; border: none; padding: 0; color: var(--ink); cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.proj-link:hover { text-decoration-style: solid; }
.roles { color: var(--ink-3); font-size: 12px; }
.ok { color: var(--st-cast); font-weight: 600; } .err { color: var(--accent); font-weight: 600; } .dim { color: var(--ink-3); }

.empty { color: var(--ink-3); padding: 24px; text-align: center; background: var(--surface); border-radius: 6px; }
.banner { background: var(--surface-2); border: 1px dashed var(--line); border-radius: 6px; padding: 8px 12px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 16px; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 14px 16px; }
  .nav-group { margin-top: 12px; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .main { padding: 18px 16px 40px; }
  .cards { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; }
}

/* Sign-in */
.signin { display: grid; place-items: center; min-height: 60vh; }
.signin-card { max-width: 440px; width: 100%; cursor: default; }
.signin-card:hover { transform: none; }
.signin-card h3 { font-family: "Barlow Condensed", "Arial Narrow", sans-serif; font-weight: 800; font-size: 26px; text-transform: uppercase; margin: 0; }
.signin-card p { margin: 6px 0 12px; }
.signin-card form { display: flex; gap: 8px; flex-wrap: wrap; }
.signin-card input { flex: 1 1 220px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font: inherit; }
#signin-msg { min-height: 1.4em; margin-top: 8px; }
.linklike { background: none; border: none; padding: 0; color: var(--side-ink); text-decoration: underline; cursor: pointer; font-size: 11px; margin-left: 6px; }
