/* 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. */
:root {
  --r: 14px; --r-lg: 18px; --r-sm: 10px; font-size: 15px;
  --head: 'Inter Display', 'Inter', 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', Arial, sans-serif; /* self-hosted, see /fonts/ */
  --body: 'Inter', 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', system-ui, Arial, sans-serif;
  --navy: #0F1A30; --on-navy: #F7F5EF; --on-navy-dim: #C9D3E3; --navy-line: #3A4766;
  /* dark (default): the site's navy */
  --bg: #0F1A30; --panel: #16223D; --panel2: #1C2A48; --field: #12203A; --line: #2E3D60; --text: #F7F5EF; --muted: #A9B5CB;
  --ok: #4CC08A; --ok-ink: #04150c; --ok-line: #2c5a43; --warn: #E8A45C; --bad: #F07C74; --bad-line: #8a3a3a; --info: #74AEEB;
  --notice-bg: #2A2618; --notice-info-bg: #18284A; --media-bg: #000;
  --accent: #E0B44C; --btn: #E0B44C; --btn-ink: #0F1A30; --btn-hover: #EBC56A; --top-accent: #E0B44C;
  color-scheme: dark;
}
html[data-mode="light"] {
  /* light: the site's warm ground and white cards */
  --bg: #F7F5EF; --panel: #FFFFFF; --panel2: #FBFAF6; --field: #FBFAF6; --line: #E3DED1; --text: #14213D; --muted: #4A5568;
  --ok: #1D7342; --ok-ink: #ffffff; --ok-line: #9fd0b3; --warn: #9A4F00; --bad: #B8322A; --bad-line: #e2a6a1; --info: #1F5FBF;
  --notice-bg: #FFF4E0; --notice-info-bg: #EAF1FB; --media-bg: #111;
  --accent: #8A6100; --btn: #E0B44C; --btn-ink: #0F1A30; --btn-hover: #EBC56A;
  color-scheme: light;
}
/* four colour schemes; gold is the site's own */
html[data-scheme="ocean"]  { --accent: #4FB3E8; --btn: #4FB3E8; --btn-ink: #04151f; --btn-hover: #73C4EE; --top-accent: #4FB3E8; }
html[data-mode="dark"][data-scheme="ocean"]  { --bg: #0B1622; --panel: #11202F; --panel2: #172A3B; --field: #0E1B28; --line: #263C52; }
html[data-scheme="sakura"] { --accent: #F08FB0; --btn: #F08FB0; --btn-ink: #2a0a16; --btn-hover: #F4A8C2; --top-accent: #F08FB0; }
html[data-mode="dark"][data-scheme="sakura"] { --bg: #171019; --panel: #201722; --panel2: #2A1E2C; --field: #1A121C; --line: #3D2C3F; }
html[data-scheme="forest"] { --accent: #6CC28A; --btn: #6CC28A; --btn-ink: #06180d; --btn-hover: #89CFA1; --top-accent: #6CC28A; }
html[data-mode="dark"][data-scheme="forest"] { --bg: #0D1612; --panel: #13201A; --panel2: #192A22; --field: #101B16; --line: #29402F; }
html[data-mode="light"][data-scheme="ocean"]  { --accent: #0B5F8A; --btn: #0B5F8A; --btn-ink: #ffffff; --btn-hover: #0E73A6; --bg: #F3F7FA; --panel2: #F6FAFC; --field: #F6FAFC; --line: #D3DFE8; }
html[data-mode="light"][data-scheme="sakura"] { --accent: #AD2757; --btn: #AD2757; --btn-ink: #ffffff; --btn-hover: #C2305F; --bg: #FAF5F7; --panel2: #FCF8FA; --field: #FCF8FA; --line: #E8D6DE; }
html[data-mode="light"][data-scheme="forest"] { --accent: #1F7044; --btn: #1F7044; --btn-ink: #ffffff; --btn-hover: #258452; --bg: #F4F8F5; --panel2: #F7FAF8; --field: #F7FAF8; --line: #D2E2D7; }

* { 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; }
