/* Malibu Codebook — VFX overview web view. Dark first (the DesignKit's default theme), light on request
   of the system. No inline styles anywhere: the page is served under a strict Content-Security-Policy. */
:root {
  color-scheme: dark light;
  --bg: #0d0d0d;
  --panel: #151515;
  --panel-2: #1c1c1c;
  --line: #2a2a2a;
  --text: #ececec;
  --muted: #a0a2a8;
  --accent: #2f9be0;
  --accent-soft: rgba(47, 155, 224, 0.2);
  --good: #4cc38a;
  --warn: #e5b44a;
  --bad: #ef6f6c;
  --radius-s: 6px;
  --radius: 10px;
  --radius-l: 14px;
  --font: "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f5f6;
    --panel: #ffffff;
    --panel-2: #f0f0f2;
    --line: #dcdce0;
    --text: #1a1a1c;
    --muted: #6b717c;
    --accent: #0076b8;
    --accent-soft: rgba(0, 118, 184, 0.14);
    --good: #1c8f5a;
    --warn: #a87208;
    --bad: #c4382f;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.boot { padding: 24px; color: var(--muted); }
.hidden { display: none !important; }

/* ---- shell ---- */
.shell { display: flex; flex-direction: column; height: 100vh; }
.header { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.title { font-size: 16px; font-weight: 600; margin: 0; }
.asof { color: var(--muted); font-size: 12px; }
.spacer { flex: 1; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.main { flex: 1; min-height: 0; display: flex; }
.content { flex: 1; min-width: 0; overflow: auto; padding: 12px 16px 24px; }
.detail { width: 420px; max-width: 100%; border-left: 1px solid var(--line); background: var(--panel); overflow: auto; padding: 16px; }

/* ---- controls ---- */
.btn { border: 1px solid var(--line); background: var(--panel-2); border-radius: var(--radius-s); padding: 6px 12px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.small { padding: 3px 9px; font-size: 12px; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.chip { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 3px 11px; font-size: 12px; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip[disabled] { opacity: 0.4; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; }
.seg button { border: 0; border-right: 1px solid var(--line); background: transparent; padding: 5px 12px; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent-soft); color: var(--accent); }
.input, .select, .textarea { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 6px 10px; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.input.search { min-width: 220px; flex: 1; max-width: 360px; }
.textarea { width: 100%; min-height: 70px; resize: vertical; }
.menu { position: relative; }
.popover { position: absolute; left: 0; top: 34px; z-index: 20; min-width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3); }
.popover.end { left: auto; right: 0; }
.popover label { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: var(--radius-s); }
.popover label:hover { background: var(--panel-2); }
.popover .item { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 8px; border-radius: var(--radius-s); }
.popover .item:hover { background: var(--panel-2); }
.popover .head { color: var(--muted); font-size: 11px; padding: 4px 8px; text-transform: none; }

/* ---- priority and status ---- */
.prio { font-weight: 700; letter-spacing: 1px; font-size: 13px; }
.prio.p3 { color: var(--bad); }
.prio.p2 { color: var(--warn); }
.prio.p1 { color: var(--muted); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; white-space: nowrap; border: 1px solid var(--line); }
.pill.good { color: var(--good); border-color: var(--good); }
.pill.warn { color: var(--warn); border-color: var(--warn); }
.pill.bad { color: var(--bad); border-color: var(--bad); }
.pill.info { color: var(--accent); border-color: var(--accent); }
.pill.muted, .pill.neutral { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.count { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }

/* ---- thumbnails ---- */
.thumb { display: block; background: var(--panel-2); border-radius: var(--radius-s); object-fit: cover; }
.thumb.small { width: 64px; height: 36px; }
.thumb.card { width: 100%; aspect-ratio: 16 / 9; border-radius: 0; }
.thumb.large { width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius); }
.thumb.empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 11px; }

/* ---- table ---- */
.table { width: 100%; border-collapse: collapse; }
.table th { position: sticky; top: 0; background: var(--bg); text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr.row { cursor: pointer; }
.table tr.row:hover td { background: var(--panel); }
.table tr.row.selected td { background: var(--accent-soft); }

/* ---- cards ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.card { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); overflow: hidden; cursor: pointer; text-align: left; padding: 0; }
.card:hover { border-color: var(--muted); }
.card.selected { border-color: var(--accent); }
.card .body { padding: 10px 12px; display: grid; gap: 4px; }
.card .line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- list ---- */
.list { display: grid; }
.list .item { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 8px 10px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; border-radius: 0; }
.list .item:hover { background: var(--panel); }
.list .item.selected { background: var(--accent-soft); }

/* ---- detail ---- */
.detail h2 { font-size: 17px; margin: 10px 0 2px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 12px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; word-break: break-word; }
.section-title { font-size: 12px; color: var(--muted); margin: 18px 0 8px; }
.comment { border: 1px solid var(--line); background: var(--panel-2); border-radius: var(--radius); padding: 8px 10px; margin-bottom: 8px; }
.comment.staff { border-color: var(--accent); }
.comment .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.comment .text { white-space: pre-wrap; word-break: break-word; }
.comment .actions { display: flex; gap: 6px; margin-top: 6px; }
.badge { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 0 8px; font-size: 11px; }
.back { margin-bottom: 8px; }
.notice { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--muted); }
.notice.error { border-color: var(--bad); color: var(--bad); }
.empty-state { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---- login and dialog ---- */
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { width: 360px; max-width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 22px; display: grid; gap: 12px; }
.dialog h1, .dialog h2 { margin: 0; font-size: 18px; }
.field { display: grid; gap: 4px; }
.field label { color: var(--muted); font-size: 12px; }
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.form-error { color: var(--bad); font-size: 13px; min-height: 18px; }

/* ---- narrow screens: the detail replaces the list instead of sitting next to it ---- */
@media (max-width: 760px) {
  .detail { position: fixed; inset: 0; width: auto; z-index: 30; border-left: 0; }
  .input.search { max-width: none; }
}
