:root {
  color-scheme: light dark;
  --bg: #fff;
  --paper: #fff;
  --text: #161616;
  --muted: #646464;
  --border: #e4e4e4;
  --surface: #f7f7f7;
  --strong-surface: #eee;
  --invert: #111;
  --invert-text: #fff;
  --accent: #315fd4;
  --danger: #a92128;
  --danger-bg: #fff1f1;
  --success: #246846;
  --radius: 8px;
  --sidebar: 210px;
  font-family: Inter, "Helvetica Neue", Arial, sans-serif;
}
html[data-theme="dark"] {
  --bg: #141414;
  --paper: #1b1b1b;
  --text: #f1f1f1;
  --muted: #b5b5b5;
  --border: #393939;
  --surface: #242424;
  --strong-surface: #303030;
  --invert: #f4f4f4;
  --invert-text: #171717;
  --accent: #92aaff;
  --danger: #ff9c9f;
  --danger-bg: #402224;
  --success: #91d7b0;
  color-scheme: dark;
}
html:not([data-theme="dark"]) { color-scheme: light; }
* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--bg); font-size: 14px; line-height: 1.5; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button, .button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(36px, 5vw, 57px); line-height: 1; font-weight: 550; letter-spacing: -.065em; }
h2 { font-size: 24px; font-weight: 580; letter-spacing: -.035em; line-height: 1.16; }
h3 { font-size: 17px; font-weight: 640; letter-spacing: -.018em; }
.muted { color: var(--muted); }
.eyebrow { text-transform: uppercase; color: var(--muted); font-size: 11px; letter-spacing: .11em; font-weight: 650; }
.brand { font-size: 18px; font-weight: 350; letter-spacing: -.095em; white-space: nowrap; text-decoration: none; line-height: 1; }
.brand strong { font-weight: 900; }
.brand b { font-size: .82em; font-weight: 650; }
.row { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.spread { justify-content: space-between; }
.stack { display: grid; gap: 15px; align-content: start; min-width: 0; }
.button, button {
  display: inline-flex; min-height: 36px; padding: 7px 12px; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border); border-radius: 7px; background: var(--paper); color: var(--text);
  text-decoration: none; font-weight: 620; font-size: 13px; line-height: 1.35;
}
.button:hover, button:hover { background: var(--surface); }
.primary, .active-pill { color: var(--invert-text); background: var(--invert); border-color: var(--invert); }
.primary:hover, .active-pill:hover { background: var(--text); }
.quiet { border-color: transparent; background: transparent; }
.icon { min-width: 35px; padding-inline: 7px; }
.danger { color: var(--danger); }
label { display: grid; gap: 5px; font-weight: 600; font-size: 13px; }
input:not([type="checkbox"]), textarea, select {
  width: 100%; min-width: 0; border: 1px solid var(--border); border-radius: 7px;
  background: var(--paper); padding: 9px 11px; font-weight: 450;
}
input[type="file"] { padding: 8px; }
textarea { min-height: 75px; resize: vertical; line-height: 1.46; }
textarea[readonly], input[readonly] { background: var(--surface); }
label small { font-weight: 450; color: var(--muted); }
.tag { display: inline-flex; align-items: center; width: fit-content; font-size: 11px; font-weight: 680; border-radius: 5px; padding: 3px 7px; background: var(--strong-surface); line-height: 1.3; }
.tag.black { color: var(--invert-text); background: var(--invert); }
.tag.conflict { color: var(--danger); background: var(--danger-bg); }
.tag.good { color: var(--success); }
.error { color: var(--danger); font-size: 13px; overflow-wrap: anywhere; }
.notice { position: fixed; z-index: 9; right: 20px; bottom: 20px; max-width: min(520px, calc(100vw - 40px)); padding: 11px 15px; border-radius: 8px; background: var(--invert); color: var(--invert-text); box-shadow: 0 5px 22px #0002; }
.loading { padding: 34px; color: var(--muted); }
.login { display: grid; min-height: 100dvh; grid-template-columns: 1fr 1fr; }
.login-cover { background: #080808; color: #fff; padding: clamp(28px, 5vw, 65px); display: flex; flex-direction: column; justify-content: space-between; gap: 34px; }
.login-cover .brand { font-size: clamp(19px, 2.35vw, 33px); }
.login-cover .eyebrow, .login-cover footer { color: #b0b0b0; }
.login-cover h1 { margin-top: 18px; font-size: clamp(54px, 6vw, 94px); font-weight: 500; letter-spacing: -.085em; }
.login-cover footer { font-size: 12px; }
.login-main { padding: 32px; display: grid; place-items: center; }
.login-main form { width: 100%; max-width: 370px; gap: 17px; }
.login-main h2 { font-size: 31px; }
.login-main .primary { min-height: 43px; }
.password-field { display: grid; gap: 5px; }
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 78px; }
.password-wrap button { position: absolute; right: 4px; top: 4px; min-height: 29px; padding: 3px 6px; }
.topbar { height: 58px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 15px; padding: 0 19px; position: sticky; top: 0; z-index: 3; background: var(--bg); }
.topbar .mark { font-weight: 730; padding-left: 15px; border-left: 1px solid var(--border); }
.topbar .crumb { color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.top-actions { margin-left: auto; flex-wrap: nowrap; }
.user-chip { display: flex; align-items: center; gap: 7px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 7px; white-space: nowrap; font-size: 12px; }
.avatar { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--invert); color: var(--invert-text); font-size: 10px; font-weight: 680; }
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: calc(100dvh - 58px); }
.sidebar { border-right: 1px solid var(--border); padding: 19px 12px; }
.sidebar nav { display: grid; gap: 3px; position: sticky; top: 76px; }
.sidebar .eyebrow { padding: 3px 8px; margin-top: 13px; overflow-wrap: anywhere; }
.sidebar .eyebrow:first-child { margin-top: 0; }
.sidebar a { padding: 8px; border-radius: 5px; text-decoration: none; display: block; font-size: 13px; font-weight: 570; }
.sidebar a:hover { background: var(--surface); }
.sidebar a[aria-current="page"] { color: var(--invert-text); background: var(--invert); }
.workspace { max-width: 1600px; width: 100%; padding: 32px clamp(22px, 3.5vw, 49px) 50px; margin: 0 auto; }
.page-head { display: grid; gap: 12px; margin: 0 0 24px; }
.page-head .spread { align-items: end; gap: 14px; }
.page-head .muted { font-size: 13px; }
.section { border: 1px solid var(--border); border-radius: var(--radius); background: var(--paper); padding: 18px; }
.empty { padding: 34px 18px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted); display: grid; gap: 10px; justify-items: center; overflow-wrap: anywhere; }
.project-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.project-card { display: grid; gap: 11px; text-decoration: none; padding: 17px; min-height: 139px; }
.project-card:hover { border-color: var(--muted); }
.project-card footer { padding-top: 10px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.project-card h2, .project-card p, .workspace h1, .section h2, .section h3 { overflow-wrap: anywhere; }
.project-search { width: min(390px, 100%); }
.tabs { display: flex; flex-wrap: wrap; gap: 5px; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 18px; }
.tabs a { padding: 7px 11px; border-radius: 6px; font-weight: 620; text-decoration: none; font-size: 13px; }
.tabs a:hover { background: var(--surface); }
.tabs a[aria-current="page"] { background: var(--invert); color: var(--invert-text); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.full { grid-column: 1 / -1; }
.passport { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.details { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.details dt { color: var(--muted); font-size: 12px; }
.details dd { margin: 2px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 11px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.member-form { display: grid; grid-template-columns: 1fr minmax(130px, .8fr) auto; gap: 7px; align-items: end; }
.scene-header { display: grid; grid-template-columns: 1.25fr .85fr 1fr 1fr; gap: 12px; }
.scene-header input { min-height: 39px; }
.scene-table { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.scene-grid { display: grid; grid-template-columns: 64px minmax(0, 1.65fr) minmax(0, 1.35fr) minmax(0, .9fr) minmax(0, 1.15fr); }
.column-head { background: var(--surface); color: var(--muted); font-weight: 650; font-size: 11px; }
.column-head > *, .cells > * { padding: 9px; min-width: 0; }
.cells > * + * { border-left: 1px solid var(--border); }
.cells { border-top: 1px solid var(--border); }
.cells:focus-within { background: var(--surface); }
.num { display: flex; flex-wrap: wrap; gap: 3px; align-content: flex-start; align-items: start; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); }
.num .icon { min-width: 24px; min-height: 24px; padding: 1px 3px; }
.cells textarea { min-height: 86px; background: transparent; border-color: transparent; padding: 4px 6px; width: 100%; }
.cells textarea:hover, .cells textarea:focus { background: var(--paper); border-color: var(--border); }
.mobile-cell-label { display: none; }
.read-cell { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 54px; font-size: 13px; }
.block-head { padding: 8px 10px; border-top: 1px solid var(--border); background: var(--strong-surface); gap: 8px; }
.block-head button { min-height: 29px; padding: 3px 8px; }
.block-head .block-name { flex: 1 1 200px; }
.block-head input { padding: 5px 7px; background: var(--surface); }
.block-add { padding: 7px 10px; border-top: 1px solid var(--border); }
.block-count { font-size: 12px; color: var(--muted); }
.comparison-card { display: grid; gap: 12px; }
.comparison-card.is-conflict { border-color: var(--danger); }
.comparison-values { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.comparison-values > div, .proposal { background: var(--surface); border-radius: 6px; padding: 10px; }
.comparison-values p, .proposal p { margin-top: 5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.merge-step { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.merge-step > div { padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 12px; font-weight: 620; }
.merge-step .current { background: var(--invert); color: var(--invert-text); }
.merge-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.toolbar-actions { margin-left: auto; }
.alert { padding: 13px; border: 1px solid var(--danger); border-radius: var(--radius); background: var(--danger-bg); }
.alert pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }
dialog { width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); background: var(--paper); color: var(--text); border: 1px solid var(--border); border-radius: 11px; padding: 22px; box-shadow: 0 16px 60px #0003; }
dialog::backdrop { background: #0006; }
.mobile-only { display: none; }
@media (max-width: 1050px) {
  :root { --sidebar: 174px; }
  .workspace { padding-inline: 22px; }
  .passport { grid-template-columns: 1fr; }
}
@media (max-width: 740px) {
  .mobile-only { display: inline-flex; }
  .desktop-only { display: none !important; }
  .login { grid-template-columns: 1fr; align-content: start; }
  .login-cover { gap: 26px; min-height: 238px; padding: 25px 23px 29px; }
  .login-cover footer { display: none; }
  .login-cover h1 { margin-top: 8px; font-size: 50px; }
  .login-main { padding: 29px 22px; }
  .topbar { height: 53px; gap: 8px; padding-inline: 10px; }
  .topbar .brand { font-size: 15px; }
  .topbar .mark { display: none; }
  .user-chip { border: 0; padding: 0; }
  .top-actions { gap: 4px; }
  .shell { display: block; min-height: calc(100dvh - 53px); }
  .sidebar { display: none; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar.open { display: block; }
  .workspace { padding: 22px 13px 90px; }
  h1 { font-size: 43px; }
  .page-head { margin-bottom: 17px; }
  .page-head .spread { align-items: start; }
  .page-head .row.spread { flex-direction: column; }
  .tabs { margin-bottom: 13px; }
  .tabs a { padding-inline: 8px; }
  .project-cards, .form-grid { grid-template-columns: 1fr; }
  .scene-header { grid-template-columns: 1fr 1fr; gap: 8px; }
  .section { padding: 12px; }
  .member-form { grid-template-columns: 1fr; }
  .column-head { display: none; }
  .scene-grid.cells { grid-template-columns: minmax(0, 1fr); }
  .cells > * + * { border-left: 0; }
  .cells > * { padding: 4px 9px; }
  .cells > *:last-child { padding-bottom: 10px; }
  .cells textarea { min-height: 56px; border-color: var(--border); background: var(--paper); }
  .cells .num { padding-top: 9px; }
  .mobile-cell-label { display: block; color: var(--muted); font-size: 11px; font-weight: 650; }
  .read-cell { min-height: 0; padding-block: 4px; }
  .read-cell .mobile-cell-label { margin-bottom: 2px; }
  .block-head .block-name { flex-basis: 100%; }
  .comparison-values { grid-template-columns: 1fr; }
  .merge-step { gap: 4px; }
  .merge-step > div { padding: 7px; font-size: 11px; }
  .notice { right: 13px; bottom: 13px; }
}

.project-stages { margin-top: 16px; }
.stage-grid, .shoot-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stage-link { display: grid; gap: 4px; padding: 11px; border: 1px solid var(--border); border-radius: 7px; text-decoration: none; }
.stage-link:hover { background: var(--surface); }
.production-grid { display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.naked { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
.naked:disabled select, .naked:disabled input, .naked:disabled textarea { opacity: 1; color: var(--text); background: var(--surface); }
.work-table { border: 1px solid var(--border); border-radius: 7px; }
.work-table:empty { display: none; }
.module-row, .check-line { display: grid; gap: 9px; padding: 11px; }
.module-row + .module-row, .check-line + .check-line { border-top: 1px solid var(--border); }
.script-grid { grid-template-columns: 1.2fr 1fr 1fr; }
.shot-grid { grid-template-columns: .6fr 1.5fr repeat(3, 1fr); }
.check-line { grid-template-columns: minmax(150px, 1.3fr) minmax(104px, 1fr) repeat(3, minmax(70px, auto)); align-items: center; }
.check-line .button { justify-self: start; }
.check { display: inline-flex; align-items: center; gap: 6px; }
.source-row { display: grid; grid-template-columns: 1fr 1.25fr auto auto; align-items: end; gap: 9px; }
.shoot-stats strong { display: block; font-size: clamp(21px, 3.1vw, 34px); letter-spacing: -.04em; }
.multiline { white-space: pre-wrap; overflow-wrap: anywhere; }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; }
.asset-grid img { width: 100%; height: 110px; object-fit: cover; border-radius: 6px; }
.attach { align-items: end; }
.mobile-phasebar { display: none; }
#dialog:has([data-form="confirm-generation"]) { width: min(1020px, calc(100vw - 24px)); }
@media (max-width: 880px) {
  .shot-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 740px) {
  .stage-grid, .shoot-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .production-grid, .script-grid { grid-template-columns: minmax(0, 1fr); }
  .shot-grid, .source-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .check-line { grid-template-columns: 1fr auto; }
  .check-line > a:first-child { grid-column: 1 / -1; }
  .mobile-phasebar { position: fixed; bottom: 0; z-index: 4; display: flex; justify-content: space-around;
    gap: 3px; align-items: center; background: var(--paper); border-top: 1px solid var(--border);
    width: 100%; padding: 5px 4px max(5px, env(safe-area-inset-bottom)); }
  .mobile-phasebar a { padding: 7px 4px; text-decoration: none; font-weight: 630; font-size: 12px; }
  .mobile-phasebar a[aria-current="page"] { text-decoration: underline; text-underline-offset: 4px; }
  .notice { bottom: 62px; }
}
