:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --panel-2: #fafaf9;
  --line: #e5e3de;
  --text: #1c1c1a;
  --muted: #8a8880;
  --accent: #1c1c1a;
  --accent-dim: #44443f;
  --brand: #b98a1b;
  --danger: #b4443c;
  --ok: #3f7d54;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: 'Archivo', system-ui, sans-serif; font-size: 16px; -webkit-font-smoothing: antialiased; }
.boot { padding: 48px 20px; text-align: center; color: var(--muted); }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 15px; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; }
input:focus, textarea:focus, select:focus { outline: none; border-color: #b7b4ab; }
label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 12px 0 5px; font-weight: 700; }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 14px; padding: 0 22px; height: 52px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 800; font-size: 14px; letter-spacing: .14em; white-space: nowrap; text-transform: uppercase; }
.brand em { color: var(--brand); font-style: normal; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 12.5px; color: var(--muted); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Layout */
.wrap { max-width: 1060px; margin: 0 auto; padding: 26px 22px 80px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Buttons */
.btn { display: inline-block; background: var(--accent); color: #f6f6f4; font-weight: 700; border: none; border-radius: 8px; padding: 10px 16px; font-size: 14px; }
.btn:hover { background: var(--accent-dim); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.btn.ghost:hover { border-color: #b7b4ab; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid #e2c3bf; font-weight: 600; }
.btn.danger:hover { border-color: var(--danger); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 7px; }

/* Auth */
.auth { max-width: 380px; margin: 10vh auto 0; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 36px 30px; }
.auth h1 { margin: 0 0 4px; font-size: 22px; font-weight: 800; letter-spacing: .06em; }
.auth h1 em { color: var(--brand); font-style: normal; }
.auth .tag { color: var(--muted); margin-bottom: 26px; font-size: 14px; line-height: 1.5; }
.auth .oauth { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; background: #fff; color: #1f1f1f; border: 1px solid var(--line); border-radius: 8px; padding: 11px; font-size: 14.5px; font-weight: 600; }
.auth .oauth:hover { border-color: #b7b4ab; }
.auth .divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; margin: 18px 0 6px; text-transform: uppercase; letter-spacing: .1em; }
.auth .divider::before, .auth .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.auth .magic { display: flex; gap: 8px; }
.auth .magic input { flex: 1; }

/* Project list */
h1.page { font-size: 20px; margin: 4px 0 2px; font-weight: 800; letter-spacing: -.01em; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; cursor: pointer; transition: border-color .15s; }
.card:hover { border-color: #b7b4ab; }
.card h3 { margin: 0 0 6px; font-size: 15.5px; font-weight: 700; }
.card .meta { color: var(--muted); font-size: 12.5px; }
.card.new { display: flex; align-items: center; justify-content: center; min-height: 90px; color: var(--muted); font-weight: 600; border-style: dashed; }
.card.new:hover { color: var(--text); }

/* Project layout: sidebar */
.proj-layout { display: flex; min-height: calc(100vh - 52px); }
.sidebar { width: 208px; flex-shrink: 0; border-right: 1px solid var(--line); background: var(--panel-2); padding: 18px 12px; position: sticky; top: 52px; height: calc(100vh - 52px); }
.side-back { display: block; font-size: 12.5px; color: var(--muted); padding: 6px 10px; border-radius: 7px; margin-bottom: 14px; }
.side-back:hover { background: #f0efec; color: var(--text); }
.side-title { font-size: 14.5px; font-weight: 800; padding: 0 10px 14px; letter-spacing: -.01em; border-bottom: 1px solid var(--line); margin-bottom: 10px; overflow-wrap: break-word; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav button { background: none; border: none; text-align: left; color: var(--muted); font-size: 13.5px; font-weight: 600; padding: 8px 10px; border-radius: 7px; }
.side-nav button:hover { background: #f0efec; color: var(--text); }
.side-nav button.active { background: #eceae5; color: var(--text); }
.proj-main { flex: 1; min-width: 0; padding: 24px 30px 80px; }
@media (max-width: 760px) {
  .proj-layout { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--line); padding: 12px 14px; }
  .side-nav { flex-direction: row; overflow-x: auto; }
  .side-title { display: none; }
  .side-back { display: none; }
  .proj-main { padding: 18px 16px 60px; }
}

/* Generic rows / tables */
.section-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 2px 0 14px; }
.section-head h2 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.section-head .spacer { flex: 1; }
.rowlist { display: flex; flex-direction: column; gap: 10px; }
.item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.item .item-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.item .item-head strong { font-size: 14.5px; }
.chip { display: inline-block; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--muted); margin: 2px 3px 0 0; }
.chip.cast { color: #2f5f86; border-color: #c8d8e4; }
.chip.prop { color: #8a5426; border-color: #e4d4c8; }
.chip.ward { color: #68438a; border-color: #d8cce4; }
.chip.loc { color: #2f6b45; border-color: #cbe2d3; }
.empty { text-align: center; color: var(--muted); padding: 44px 20px; border: 1px dashed var(--line); border-radius: var(--radius); margin-top: 8px; font-size: 14px; }

/* Script editor (Celtx-style) */
.scr-wrap { background: transparent; padding: 0; }
.scr-toolbar { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; margin-bottom: 18px; position: sticky; top: 64px; z-index: 10; }
.scr-toolbar select { width: auto; background: #fff; color: #222; border: 1px solid var(--line); font-size: 13px; padding: 5px 8px; border-radius: 6px; }
.scr-toolbtn { background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 5px 10px; font-size: 13px; color: var(--text); font-weight: 600; }
.scr-toolbtn:hover { background: #f0efec; border-color: var(--line); }
.scr-sep { width: 1px; height: 20px; background: var(--line); margin: 0 5px; }
.scr-count { font-size: 12px; color: var(--muted); margin-right: 8px; white-space: nowrap; }
.script-save { font-size: 12px; color: var(--muted); white-space: nowrap; }
.script-save.saved { color: var(--ok); }
.scr-page { background: #fff; color: #111; max-width: 816px; margin: 0 auto; border: 1px solid var(--line); padding: 96px 96px 96px 144px; font-family: 'Courier Prime', 'Courier New', monospace; font-size: 12pt; line-height: 1.25; }
.el { white-space: pre-wrap; overflow-wrap: break-word; margin-top: 15px; min-height: 1.25em; outline: none; }
.el:first-child { margin-top: 0; }
.el:empty::before { content: attr(data-ph); color: #b5b3ac; }
.el-act { text-transform: uppercase; text-align: center; font-weight: 700; margin-top: 30px; }
.el-scene { text-transform: uppercase; font-weight: 700; }
.el-character { text-transform: uppercase; margin-left: 22ch; }
.el-dialogue { margin-left: 10ch; max-width: 33ch; }
.el-paren { margin-left: 16ch; max-width: 24ch; }
.el-transition { text-transform: uppercase; text-align: right; }
.el-shot { text-transform: uppercase; }
.el-text { font-style: italic; }
.scr-hint { font-size: 12px; color: var(--muted); margin: 14px 4px 0; }

/* Shot list table */
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table.tbl th { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl input, table.tbl select { padding: 5px 7px; font-size: 13.5px; background: transparent; border-color: transparent; }
table.tbl input:focus, table.tbl select:focus { background: #fff; border-color: #b7b4ab; }
table.tbl tr.done td { opacity: .45; }

/* Tasks */
.task { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 14px; }
.task.done .t-title { text-decoration: line-through; color: var(--muted); }
.task .t-date { font-size: 12px; color: var(--brand); font-weight: 700; white-space: nowrap; }
.task .t-date.overdue { color: var(--danger); }
.task-check { width: 18px; height: 18px; accent-color: var(--accent); }

/* Call sheet */
.csheet { background: #fff; color: #111; border: 1px solid var(--line); border-radius: 10px; padding: 26px 24px; }
.csheet h2 { margin: 0 0 2px; font-size: 21px; }
.csheet .cs-sub { color: #555; font-size: 13.5px; margin-bottom: 14px; }
.csheet table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.csheet th { text-align: left; background: #f4f3f0; padding: 6px 8px; border: 1px solid #ddd; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
.csheet td { padding: 6px 8px; border: 1px solid #ddd; }
@media print {
  body { background: #fff; }
  .topbar, .sidebar, .no-print, .wrap > .btn, .scr-toolbar, .scr-hint { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  .proj-layout { display: block; }
  .proj-main { padding: 0; }
  .csheet, .scr-page { border: none; }
}

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(28,28,26,.35); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 18px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: 100%; max-width: 460px; max-height: 86vh; overflow-y: auto; }
.modal h3 { margin: 0 0 4px; font-size: 17px; }
.modal .actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1c1c1a; color: #f6f6f4; border-radius: 999px; padding: 9px 18px; font-size: 13.5px; z-index: 60; }
