/* Alpha-War Studio app. Same look as the public site: navy and gold, Inter Display headings,
   Inter / Noto Sans JP text (all self-hosted, no third-party requests), rounded cards and pill buttons. Light and dark modes, four colour schemes: the tokens are in shared.css (also used by Avatar). */
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); line-height: 1.5; -webkit-font-smoothing: antialiased; }
:lang(ja) body, body:lang(ja) { line-height: 1.7; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--btn); outline-offset: 2px; }
h1, h2, h3 { margin: 0 0 .5rem; font-family: var(--head); font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 2rem; line-height: 1.15; }
h2 { font-size: 1.4rem; line-height: 1.2; }
/* small section labels: the site's eyebrow */
h3 { font-family: var(--body); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .16em; color: var(--accent); margin-top: 1.4rem; }
.panel > h3:first-child { margin-top: 0; }

/* header: always the site's navy bar */
.top { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .75rem 1.5rem; background: var(--navy); color: var(--on-navy);
  position: sticky; top: 0; z-index: 5; border-bottom: 1px solid #1C2A48; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-family: var(--head); font-weight: 700; font-size: 1.2rem; color: var(--on-navy); text-decoration: none; }
.brand span { color: var(--top-accent); }
.brand svg { color: var(--top-accent); flex: none; }
.month { display: flex; gap: .7rem; align-items: center; color: var(--on-navy-dim); font-size: .85rem; }
.top .who { color: var(--on-navy-dim); }
.top .btn { background: transparent; color: var(--on-navy); border-color: var(--navy-line); }
.top .btn:hover { border-color: var(--on-navy-dim); }
.top .chip { color: #F2C27A; border-color: #F2C27A; }
.top .theme select { background: #1C2A48; color: var(--on-navy); border-color: var(--navy-line); }
meter { width: 120px; height: .6rem; flex: none; }
.top, .phead .row { flex-wrap: wrap; }

/* layout */
.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: calc(100vh - 58px); }
.side { border-right: 1px solid var(--line); padding: 1.2rem 1rem; background: var(--panel); }
.side ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; }
.side li a { display: block; padding: .6rem .75rem; border-radius: 12px; color: var(--text); text-decoration: none; font-size: .92rem; font-weight: 600; border-left: 3px solid transparent; }
.side li a:hover { background: var(--panel2); }
.side li a.active { background: var(--panel2); border-left-color: var(--btn); }
.side li small { display: block; color: var(--muted); font-size: .75rem; font-weight: 400; }
main { padding: 1.8rem 2.2rem 4rem; max-width: 1320px; min-width: 0; }

/* buttons: the site's pills */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 40px; border: 1px solid var(--line); background: transparent; color: var(--text);
  padding: .5rem 1.1rem; border-radius: 999px; cursor: pointer; font: inherit; font-size: .9rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }
.btn.primary:hover { background: var(--btn-hover); border-color: var(--btn-hover); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: var(--ok-ink); }
.btn.small { min-height: 32px; padding: .3rem .8rem; font-size: .8rem; }
.btn.block { display: flex; width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.chip { display: inline-block; font-size: .72rem; font-weight: 600; padding: .15rem .6rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.approved { color: var(--ok); border-color: var(--ok); }
.chip.review, .chip.open { color: var(--accent); border-color: var(--accent); }
.chip.generating, .chip.waiting_operator, .chip.running, .chip.queued { color: var(--info); border-color: var(--info); }
.chip.stale, .chip.awaiting_spend { color: var(--warn); border-color: var(--warn); }
.chip.failed { color: var(--bad); border-color: var(--bad); }

/* forms */
form.intake { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.3rem; max-width: 940px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.6rem; }
form.intake .full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; font-weight: 600; color: var(--text); }
input, select, textarea { background: var(--field); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-sm); padding: .6rem .75rem; font: inherit; font-size: .92rem; font-weight: 400; min-height: 42px; }
input[type="checkbox"], input[type="radio"] { min-height: 0; width: 18px; height: 18px; accent-color: var(--btn); }
input:focus, select:focus, textarea:focus { border-color: var(--btn); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--btn) 30%, transparent); }
textarea { min-height: 5.5rem; resize: vertical; }
textarea.code { font-family: ui-monospace, Menlo, monospace; font-size: .8rem; min-height: 12rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.2rem; }
legend { color: var(--accent); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .16em; padding: 0 .4rem; }
.checks { flex-direction: row; gap: 1rem; color: var(--text); }
.checks label { flex-direction: row; align-items: center; font-weight: 400; color: var(--text); }

/* project */
.phead { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 1.2rem; }
.phead .row.muted { margin-top: .2rem; font-size: .9rem; }
.stepper { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .5rem; margin-bottom: 1.2rem; }
.step { flex: 1 0 132px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: .6rem; row-gap: .35rem; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: .7rem .75rem; cursor: pointer; text-align: left; color: var(--text); font: inherit; }
.step .n { grid-row: 1 / 3; width: 32px; height: 32px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--head); font-weight: 700; font-size: .9rem; background: var(--panel2); color: var(--muted); border: 1px solid var(--line); }
.step b { font-size: .84rem; line-height: 1.25; }
.step .chip { justify-self: start; }
.step.sel { border-color: var(--btn); box-shadow: 0 0 0 1px var(--btn) inset; }
.step.sel .n { background: var(--navy); color: var(--top-accent); border-color: var(--navy); }
html[data-mode="dark"] .step.sel .n { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }
.step.st-approved .n { background: var(--ok); color: var(--ok-ink); border-color: var(--ok); }
.step:disabled { opacity: .5; cursor: default; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.4rem 1.5rem; margin-bottom: 1.1rem; }
.notice { border-left: 4px solid var(--warn); background: var(--notice-bg); padding: .8rem 1rem; border-radius: 12px; margin: .7rem 0; }
.notice.info { border-color: var(--info); background: var(--notice-info-bg); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; display: flex; flex-direction: column; gap: .55rem; min-width: 0; }
.card.approved { border-color: var(--ok-line); }
.card.failed { border-color: var(--bad); }
.card header { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.card h4 { margin: 0; font-family: var(--head); font-size: 1rem; font-weight: 700; }
.card .media img, .card .media video { width: 100%; max-height: 360px; object-fit: contain; background: var(--media-bg); border-radius: var(--r-sm); display: block; }
.card audio { width: 100%; }
.card dl { margin: 0; font-size: .82rem; display: grid; grid-template-columns: auto 1fr; gap: .15rem .6rem; }
.card dt { color: var(--muted); }
.card dd { margin: 0; overflow-wrap: anywhere; }
.lines { font-size: .85rem; display: flex; flex-direction: column; gap: .4rem; }
.lines .who { color: var(--accent); font-weight: 600; }
.lines .ja { color: var(--muted); }
.actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: auto; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
.log { font-size: .8rem; color: var(--muted); max-height: 240px; overflow: auto; }
.log div { padding: .25rem 0; border-bottom: 1px dashed var(--line); }
.toast { position: fixed; bottom: 1.4rem; right: 1.4rem; background: var(--navy); color: var(--on-navy); border: 1px solid var(--navy-line); border-left: 4px solid var(--top-accent);
  padding: .8rem 1.1rem; border-radius: var(--r); max-width: 420px; z-index: 10; box-shadow: 0 8px 24px rgba(15, 26, 48, .25); }
.toast.err { border-left-color: #F07C74; }
code { font-family: ui-monospace, Menlo, monospace; font-size: .82em; background: var(--panel2); padding: .05rem .35rem; border-radius: 6px; }
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; } .side { border-right: 0; border-bottom: 1px solid var(--line); }
  form.intake { grid-template-columns: 1fr; padding: 1.1rem; } main { padding: 1.2rem 1rem 3rem; } .top { padding: .7rem 1rem; }
}

/* sign-in page */
main.login { display: flex; justify-content: center; padding: 10vh 1rem 2rem; }
main.login form { width: min(420px, 100%); display: flex; flex-direction: column; gap: .9rem; padding: 2rem; border-radius: 22px; }
main.login .eyebrow { margin: 0; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .16em; color: var(--accent); }
main.login h1 { font-size: 2rem; }
main.login .btn.primary { min-height: 48px; font-size: 1rem; }
.who { color: var(--muted); font-size: .85rem; }

/* budgets */
.side .btn.block + .btn.block { margin-top: .5rem; }
.budgetbox { display: grid; gap: .35rem; justify-items: end; }
.capedit input { width: 7rem; }
.budget-table td.num, .budget-table th:nth-child(n+5) { text-align: right; }
.budget-table td, .budget-table th { padding: .35rem .5rem; border-bottom: 1px solid var(--line); }
@media (max-width: 720px) { .budgetbox { justify-items: start; } }

/* sharing and administration */
.checks.wrap { flex-wrap: wrap; gap: .3rem 1rem; }
.panel.narrow { max-width: 460px; display: grid; gap: .8rem; }
.panel.narrow label { display: grid; gap: .3rem; }
.admin-table td { vertical-align: middle; }
.admin-table tr.off td { opacity: .55; }
.btn.danger { border-color: var(--bad-line); color: var(--bad); }
code.otp { font-size: 1rem; padding: .15rem .4rem; background: var(--panel2); border-radius: 6px; user-select: all; }
[hidden] { display: none !important; }
.panel > .row + .row { margin-top: .6rem; }

/* theme picker */
.theme { display: flex; gap: .35rem; align-items: center; }
.theme select { font: inherit; font-size: .8rem; min-height: 32px; padding: .2rem 1.6rem .2rem .7rem; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 999px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; align-items: start; }
.grid2 .panel.narrow { max-width: none; }
pre.codes { font-size: 1rem; line-height: 1.6; background: var(--panel2); padding: .6rem .8rem; border-radius: var(--r-sm); columns: 2; }
details summary { cursor: pointer; color: var(--muted); margin: .4rem 0; }

/* starter material */
textarea.script { min-height: 220px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }
.starter-list { display: grid; gap: .5rem; }
.starter-row { display: grid; grid-template-columns: 72px 1fr auto; gap: .8rem; align-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: .5rem; }
.starter-fields { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.starter-fields input:not([type]) { min-width: 14rem; }
img.thumb { width: 72px; height: 72px; object-fit: cover; border-radius: var(--r-sm); background: var(--media-bg); }
.starter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .8rem; margin: .6rem 0; }
.starter-card { display: grid; gap: .35rem; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: .5rem; }
.starter-card img.thumb { width: 100%; height: 140px; }
label.inline { display: inline-flex; flex-direction: row; gap: .4rem; align-items: center; }
pre.script-view { white-space: pre-wrap; max-height: 320px; overflow: auto; background: var(--panel2); padding: .6rem .8rem; border-radius: var(--r-sm); font-size: .85rem; }
.starter-card > select, .starter-card > input, .starter-card > button { width: 100%; min-width: 0; box-sizing: border-box; }
.starter-card { min-width: 0; overflow: hidden; }
.key-card { margin-top: .6rem; gap: .5rem; }
.key-card input { min-width: 14rem; flex: 1 1 14rem; }

/* jobs in progress: stop controls */
.jobs-box .row { align-items: center; gap: 10px; flex-wrap: wrap; }
.jobs-box .row .btn { margin-left: auto; }
.job-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.job-list li { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 4px 0; border-top: 1px solid var(--line, rgba(127,127,127,.2)); min-width: 0; }
.job-list li span { min-width: 0; overflow-wrap: anywhere; }

/* edit brief and screenplay */
.brief-edit .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1.2rem; margin: .8rem 0; }
.brief-edit .form-grid .full { grid-column: 1 / -1; }
.brief-edit label { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.brief-edit label.inline { flex-direction: row; align-items: center; margin: .4rem 0 .8rem; }
.brief-edit textarea { min-height: 4.5rem; }
.brief-edit textarea.script { min-height: 16rem; }
@media (max-width: 700px) { .brief-edit .form-grid { grid-template-columns: minmax(0, 1fr); } }
main.login #msg:empty { display: none; }

/* Audio timeline (Edit & mix) */
.timeline { margin: 1rem 0; padding: 1rem; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel2); }
.timeline .row { margin-bottom: .6rem; }
.tl-video { max-width: 640px; margin-bottom: .8rem; }
.tl-video video { width: 100%; max-height: 360px; object-fit: contain; background: var(--media-bg); border-radius: var(--r-sm); display: block; }
.tl { position: relative; display: grid; gap: 4px; }
.tl-lane { display: grid; grid-template-columns: 110px 1fr; gap: .6rem; align-items: center; }
.tl-name { font-size: .8rem; font-weight: 600; display: flex; flex-direction: column; }
.tl-name small { color: var(--muted); font-weight: 400; }
.tl-track { position: relative; height: 34px; background: var(--field); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; cursor: pointer; }
.tl-ruler .tl-track { height: 18px; background: none; border: 0; }
.tl-tick { position: absolute; top: 0; font-size: .68rem; color: var(--muted); border-left: 1px solid var(--line); padding-left: 3px; }
.tl-block { position: absolute; top: 3px; bottom: 3px; border-radius: 4px; padding: 0 5px; font-size: .7rem; line-height: 28px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--btn-ink); }
.tl-block.video { background: var(--info); }
.tl-block.take { background: var(--accent); }
.tl-block.line { background: var(--ok); color: var(--ok-ink); }
.tl-block.amb { background: var(--muted); }
.tl-block.music { background: var(--accent); opacity: .85; left: 0; }
.tl-block.sub { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.tl-block.ph { background: repeating-linear-gradient(45deg, var(--line) 0 6px, transparent 6px 12px); color: var(--muted); border: 1px dashed var(--muted); }
.tl-duck { position: absolute; top: 0; bottom: 0; background: var(--bg); opacity: .55; pointer-events: none; }
.tl-empty { font-size: .75rem; color: var(--muted); padding: 0 .5rem; line-height: 32px; }
.tl-heads { position: absolute; top: 0; bottom: 0; left: calc(110px + .6rem); right: 0; pointer-events: none; }
.tl-playhead { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; background: var(--bad); }
.tl-label { position: absolute; left: 6px; top: 0; line-height: 32px; font-size: .7rem; font-weight: 600; color: var(--btn-ink); pointer-events: none; text-shadow: 0 0 3px var(--accent); }

/* Idle sign-out warning */
.idle-warning { position: fixed; left: 50%; top: 1.2rem; transform: translateX(-50%); z-index: 50; display: flex; gap: .8rem; align-items: center; flex-wrap: wrap;
  max-width: min(40rem, calc(100vw - 2rem)); background: var(--navy); color: var(--on-navy); border: 1px solid var(--navy-line); border-left: 4px solid var(--top-accent);
  border-radius: 12px; padding: .8rem 1rem; box-shadow: 0 12px 32px rgba(0, 0, 0, .25); }
/* Camera by scene */
.camera-panel summary { cursor: pointer; list-style: revert; }
.camera-panel select { min-width: 9rem; }
/* Credits */
.credit-balance { font-size: 1.6rem; margin: .2rem 0 .4rem; }
.credit-banner { margin: 1rem 1.4rem 0; }
.receipt pre { white-space: pre-wrap; font-family: inherit; }
@media print { body > *:not(main), .credit-banner, .actions, .phead .row { display: none !important; } }
.tl-tools { flex-wrap: wrap; gap: .35rem; }
.tl-tools .spacer { flex: 1; }
.tl-help { margin: .3rem 0 .6rem; }
.tl-block.sel { outline: 2px solid var(--text); outline-offset: 1px; }
.tl-block.cue { opacity: .6; }
.tl.tool-move .tl-block:not(.sub):not(.ph), .tl.tool-fade .tl-block:not(.sub) { cursor: ew-resize; touch-action: none; }
.tl.tool-move .tl-block.line, .tl.tool-move .tl-block.music { cursor: grab; }
.tl-fade { position: absolute; top: 0; bottom: 0; pointer-events: none; background: linear-gradient(to right, rgba(0,0,0,.55), transparent); }
.tl-fade.in { left: 0; }
.tl-fade.out { right: 0; background: linear-gradient(to left, rgba(0,0,0,.55), transparent); }
.tl-vol { position: absolute; inset: 0; pointer-events: none; }
.tl-vol.on { pointer-events: auto; cursor: crosshair; touch-action: none; }
.tl-vol svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.tl-env { fill: none; stroke: var(--text); stroke-width: 2; vector-effect: non-scaling-stroke; opacity: .8; }
.tl-dot { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--text); border: 2px solid var(--bg); cursor: grab; }
.tl-key { position: absolute; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; transform: rotate(45deg); background: var(--warn); border: 1px solid var(--bg); cursor: grab; touch-action: none; }
.tl-insp { margin-top: .8rem; padding: .8rem; border: 1px solid var(--line); border-radius: var(--r-sm); display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .6rem 1rem; align-items: end; }
.tl-insp .full { grid-column: 1 / -1; }
.tl-insp label { display: flex; flex-direction: column; gap: .2rem; font-size: .8rem; }
.tl-track { touch-action: pan-y; }

/* Language switch (i18n.js), styled like the theme selects beside it */
#themeSlot { display: flex; gap: .35rem; align-items: center; }
.lang-switch { font: inherit; font-size: .8rem; min-height: 32px; padding: .2rem 1.6rem .2rem .7rem; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 999px; }
.top .lang-switch { background: #1C2A48; color: var(--on-navy); border-color: var(--navy-line); }

/* Two-factor setup QR code: always dark on white, with a quiet margin, so phones can scan it in dark mode */
.qr-box { display: block; width: fit-content; background: #ffffff; padding: 8px; border-radius: 12px; border: 1px solid var(--line); line-height: 0; }
.qr-box svg { display: block; width: 208px; height: 208px; }
.otp { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; }
