/* ツギアサ — shared stylesheet (served from /static/app.css; CSP style-src 'self', no inline styles).
   Calm, premium SaaS look. System fonts only (no web fonts / CDN). Light and dark via prefers-color-scheme.
   Text colors are chosen for WCAG AA (4.5:1) against their backgrounds; tests/test_round20.py checks the pairs. */

:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --fg: #1b1a22;
  --mut: #57556a;
  --line: #e4e2dc;
  --line-strong: #cfccc3;
  --acc: #3a46b0;
  --acc-fg: #ffffff;
  --acc-soft: #eceefb;
  --ok: #1d6b3a;
  --ok-soft: #e7f4ec;
  --warn: #a3261c;
  --warn-soft: #fbecea;
  --caution: #7a5400;
  --caution-soft: #fdf3d8;
  --gold: #8a6d1f;
  --nav-bg: #16171f;
  --nav-fg: #ecebf2;
  --nav-mut: #b4b2c2;
  --nav-acc: #e3c77a;
  /* speaker palette (AI社員ごとの色。id % 8 で決まる。app/report.py SPEAKER_PALETTE と同じ値) */
  --sp0: #2f5bb7;
  --sp1: #0e6b63;
  --sp2: #7a3db8;
  --sp3: #a14a00;
  --sp4: #2b7a30;
  --sp5: #b0306a;
  --sp6: #6f5d00;
  --sp7: #0a6690;
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 4px 16px rgba(20, 20, 30, .05);
  --shadow-lg: 0 12px 40px rgba(10, 10, 20, .22);
  --radius: 14px;
  --radius-sm: 9px;
  --font: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0f14;
    --surface: #171821;
    --surface-2: #1c1d27;
    --fg: #ecebf2;
    --mut: #a9a7b8;
    --line: #2a2b37;
    --line-strong: #3a3b49;
    --acc: #a9b3ff;
    --acc-fg: #10111a;
    --acc-soft: #23264a;
    --ok: #7ad6a0;
    --ok-soft: #15301f;
    --warn: #ff9e92;
    --warn-soft: #3a1a18;
    --caution: #f0c75e;
    --caution-soft: #33280c;
    --gold: #e3c77a;
    --nav-bg: #0a0b10;
    --nav-fg: #ecebf2;
    --nav-mut: #a9a7b8;
    --nav-acc: #e3c77a;
    --sp0: #93b2ff;
    --sp1: #5fd3c4;
    --sp2: #cfa8ff;
    --sp3: #ffb072;
    --sp4: #8fd894;
    --sp5: #ff9ccb;
    --sp6: #e0cc6a;
    --sp7: #7fcbf2;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.75 var(--font); letter-spacing: .01em;
  -webkit-font-smoothing: antialiased; overflow-wrap: anywhere;
}
a { color: var(--acc); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 24px; line-height: 1.4; font-weight: 650; letter-spacing: .02em; margin: 4px 0 18px; }
h2 { font-size: 16px; line-height: 1.5; font-weight: 650; margin: 0 0 12px; }
h1 .tag, h2 .tag { vertical-align: middle; }
p { margin: 0 0 12px; }
ul { margin: 4px 0 12px; padding-left: 22px; }
li { margin: 2px 0; }
img, svg, video { max-width: 100%; height: auto; }

.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--surface); color: var(--fg);
  padding: 8px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.skip:focus { left: 12px; }

/* ---------- top bar + navigation ---------- */
.topbar { background: var(--nav-bg); color: var(--nav-fg); position: sticky; top: 0; z-index: 40; }
.topbar-in, .nav-in { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.topbar-in { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; min-height: 56px; padding-top: 8px; padding-bottom: 8px; }
.brand { color: var(--nav-fg); font-weight: 700; font-size: 17px; letter-spacing: .04em; display: inline-flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; color: #fff; }
.brand-mark { color: var(--nav-acc); flex: none; display: block; }  /* the dawn mark (inline SVG, currentColor) */
.topbar-link { color: var(--nav-mut); }
.topbar-link:hover { color: var(--nav-fg); }
.account { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.account a { color: var(--nav-fg); }
.account .mut { color: var(--nav-mut); }
.org-chip { border: 1px solid rgba(255, 255, 255, .16); border-radius: 99px; padding: 2px 12px; }
.org-chip:hover { border-color: var(--nav-acc); text-decoration: none; }
.role-chip { color: var(--nav-acc); border: 1px solid currentColor; border-radius: 99px; padding: 0 9px; font-size: 12px; }
.account button.sec { color: var(--nav-fg); border-color: rgba(255, 255, 255, .28); background: transparent; }
.account button.sec:hover { border-color: var(--nav-acc); color: var(--nav-acc); }
.nav { border-top: 1px solid rgba(255, 255, 255, .07); }
/* wraps instead of scrolling sideways: a scrolling box would clip the 「その他」 menu */
.nav-in { display: flex; flex-wrap: wrap; gap: 2px; align-items: stretch; }
.nav a, .nav-more > summary { color: var(--nav-mut); padding: 10px 12px; font-size: 14px; white-space: nowrap; border-bottom: 2px solid transparent; }
.nav a:hover, .nav-more > summary:hover { color: var(--nav-fg); text-decoration: none; }
.nav a[aria-current="page"], .nav-more > summary.here { color: var(--nav-fg); border-bottom-color: var(--nav-acc); font-weight: 600; }
.nav .badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 99px;
  background: #f0c75e; color: #1a1a1a; font-size: 12px; font-weight: 700; line-height: 18px; text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nav-more { position: relative; }
.nav-more > summary { cursor: pointer; list-style: none; display: block; }
.nav-more > summary::-webkit-details-marker { display: none; }
.nav-more > summary::after { content: " ▾"; font-size: 11px; }
.nav-more[open] > summary::after { content: " ▴"; }
.nav-menu { position: absolute; left: 0; top: 100%; z-index: 50; min-width: 180px; padding: 6px 0;
  background: var(--nav-bg); border: 1px solid rgba(255, 255, 255, .12); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.nav-menu a { display: block; border-bottom: 0; border-left: 2px solid transparent; }
.nav-menu a[aria-current="page"] { border-left-color: var(--nav-acc); }

/* ---------- layout ---------- */
main { max-width: 1120px; margin: 0 auto; padding: 28px 20px 64px; min-width: 0; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; margin: 0 0 18px; box-shadow: var(--shadow); min-width: 0; overflow-x: auto;
}
.card > :last-child { margin-bottom: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 18px; }
.grid .card { margin: 0; }
.stat { font-size: 30px; font-weight: 650; line-height: 1.3; letter-spacing: .01em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.stat a { color: inherit; }
.mut { color: var(--mut); font-size: 13px; }
.pre { white-space: pre-wrap; }
.err { color: var(--warn); }
.card.err { background: var(--warn-soft); border-color: var(--warn); }
.notice { background: var(--acc-soft); border-radius: var(--radius-sm); padding: 8px 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > form { display: inline-block; flex: 1 1 260px; }
form.inline { display: inline; }

/* ---------- page header, empty states, lists (main screens) ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin: 4px 0 20px; }
.page-title { min-width: 0; flex: 1 1 420px; }
.page-title h1 { margin: 0 0 4px; }
.lead { color: var(--mut); font-size: 14px; margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-actions form { display: inline-flex; }
.page-actions button { margin-top: 0; }
.mission-controls { display: flex; gap: 6px; }  /* H3: 一時停止・中止 at the right of the mission's heading */
.back { margin: -12px 0 16px; font-size: 13px; }
.btn {
  display: inline-flex; align-items: center; background: var(--acc); color: var(--acc-fg); border: 1px solid var(--acc);
  border-radius: var(--radius-sm); padding: 8px 18px; font-weight: 600; font-size: 14px; white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn.sec { background: transparent; color: var(--acc); }
.btn.sec:hover { background: var(--acc-soft); filter: none; }
.empty { text-align: center; padding: 28px 16px; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); }
.empty-title { font-weight: 650; font-size: 15px; margin-bottom: 4px; }
.empty .steps { display: inline-block; text-align: left; margin: 8px 0 0; }
.list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--line); margin: 0; }
.item:last-child { border-bottom: 0; }
.item-main { min-width: 0; flex: 1 1 320px; }
.item-main a { font-weight: 600; }
.item-main p { margin: 2px 0 0; }
.item-meta { display: flex; gap: 10px; align-items: baseline; white-space: nowrap; }
.more { margin: 12px 0 0; font-size: 14px; }
.stat-label { color: var(--mut); font-size: 13px; font-weight: 600; letter-spacing: .02em; }
.stat-card.attn { border-color: var(--gold); box-shadow: inset 4px 0 0 var(--gold), var(--shadow); }
/* dashboard: 「はじめかた」 and 「次にやること」 (round 30) */
.start-steps { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 12px; }
.step { display: flex; gap: 12px; align-items: flex-start; margin: 0; }
.step p { margin: 2px 0 0; }
.step-no { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; font-weight: 700; background: var(--acc-soft); color: var(--acc); }
.step.is-done .step-no { background: var(--ok-soft); color: var(--ok); }
.next-title { font-size: 20px; font-weight: 700; margin: 4px 0; }
.tagline { margin: -4px 0 14px; }
.section-title { font-size: 16px; margin: 24px 0 8px; }
.confirm .row { align-items: center; gap: 12px; }
.confirm .row form { display: inline-flex; }
.confirm .row button { margin-top: 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 18px; }
h3, .letter-item h4 { font-size: 14px; font-weight: 650; letter-spacing: .02em; margin: 16px 0 6px; }
.minutes .summary { font-size: 16px; line-height: 1.85; padding: 12px 16px; margin: 0 0 4px;
  background: var(--surface-2); border-left: 3px solid var(--gold); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.minutes ul { padding-left: 20px; }
/* meeting page (round 32): download menu, round headings, a stopped meeting's head */
.menu { position: relative; }
.menu > summary { cursor: pointer; list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: " ▾"; font-size: 11px; margin-left: 4px; }
.menu-list { position: absolute; right: 0; top: 100%; z-index: 40; min-width: 200px; margin-top: 4px; padding: 6px 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.menu-list a { display: block; padding: 8px 14px; white-space: nowrap; }
.menu-list a:hover { background: var(--acc-soft); text-decoration: none; }
.round-h { margin: 18px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--line); color: var(--mut); }
.round-h:first-child { margin-top: 4px; }
.failed-head h2 { margin-top: 0; }
.failed-head form { margin-top: 10px; }

/* ---------- remaining screens (approvals, knowledge, members, account, login, public profiles) ---------- */
.item-title { font-weight: 650; margin: 0 0 2px; }
.item .row.decide { margin-top: 4px; align-items: flex-start; }
.decide-more > summary { cursor: pointer; padding: 6px 4px; color: var(--mut); font-size: 14px; }
.decide-more[open] { flex-basis: 100%; }
.appr-group + .appr-group { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.appr-group h3 { margin: 0 0 2px; }
.item-meta .tag + .tag { margin-left: -4px; }
.card.attn { border-color: var(--gold); box-shadow: inset 4px 0 0 var(--gold), var(--shadow); }
.card.top-card { border-color: var(--acc); box-shadow: inset 4px 0 0 var(--acc), var(--shadow); }
.made li { margin-bottom: 6px; }
details.work-log { margin-top: 8px; }
details.work-log > summary { cursor: pointer; color: var(--mut); font-size: .92em; }
details.fine-limits { margin: 8px 0; }
details.fine-limits > summary { cursor: pointer; color: var(--mut); font-size: .92em; }
.recommend { margin: 6px 0; padding: 6px 10px; border-left: 3px solid var(--acc); }
/* PM-r120-2: the 月額 a decision protects (code-computed), audit r123 rec.4 */
.money { font-weight: 700; font-size: 1.05em; }
/* PM-r171-2: an おまかせ text's headings / lists / tables on screen */
.doc-text h2, .doc-text h3, .doc-text h4 { margin: 1.2em 0 .4em; }
.doc-text table.doc-table { margin: .6em 0 1em; }
/* PM-r471-3: a long text's chapter list, before the text */
.doc-toc ol { margin: .2em 0 .6em; padding-left: 1.4em; }
.doc-toc li { margin: .3em 0; }
details.card > summary { cursor: pointer; font-weight: 600; }
details.card > summary > h2 { display: inline; margin: 0; } /* PM-r315-2: a folded card keeps its heading */
details.plans-more > summary { cursor: pointer; color: var(--acc); margin: 8px 0; }
.row.tight { flex-wrap: nowrap; align-items: center; gap: 8px; }
.row.tight > form { flex: 0 0 auto; display: inline-flex; gap: 6px; align-items: center; }
.row.tight select { padding: 3px 8px; }
.row.tight button { margin: 0; padding: 3px 12px; font-size: 13px; }
.roles { margin: 14px 0 0; padding-left: 18px; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
dl.facts dt { color: var(--mut); font-size: 13px; font-weight: 600; }
dl.facts dd { margin: 0; }
.auth { max-width: 440px; margin: 24px auto 0; }
.auth .card { padding: 28px 30px; }
.auth h1 { margin: 2px 0 16px; }
.auth-brand { color: var(--fg); font-weight: 700; letter-spacing: .06em; font-size: 15px; margin: 0; display: flex; align-items: center; gap: 6px; }
.auth-brand .brand-mark { color: var(--acc); }
button.wide { width: 100%; justify-content: center; margin-top: 20px; }
.profiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.profiles .card { margin: 0; }
.profile-head { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.profile-head h1, .profile-head h2 { margin: 0; }
.avatar { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 18px; background: var(--acc-soft); color: var(--acc); }

/* ---------- forms ---------- */
label { display: block; margin: 12px 0 4px; font-size: 13px; font-weight: 600; color: var(--mut); }
input, textarea, select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--fg); font: inherit; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }
textarea { min-height: 96px; resize: vertical; }
select.auto { width: auto; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--acc); margin: 0 6px 0 0; vertical-align: middle; }
label.check { display: inline-flex; align-items: center; margin: 6px 16px 6px 0; font-weight: 500; color: var(--fg); }
fieldset.ask-team { border: 0; padding: 0; margin: 4px 0 8px; }
fieldset.ask-team legend { font-weight: 600; padding: 0; }
button {
  display: inline-flex; align-items: center; gap: 6px; background: var(--acc); color: var(--acc-fg);
  border: 1px solid var(--acc); border-radius: var(--radius-sm); padding: 8px 18px; margin-top: 14px;
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; transition: filter .15s, background .15s;
}
button:hover { filter: brightness(1.08); }
button.sec { background: transparent; color: var(--acc); }
button.sec:hover { background: var(--acc-soft); filter: none; }
button.ng { background: var(--warn); border-color: var(--warn); color: var(--surface); }
/* dangerous but not the page's main action (却下・外す・停止): outlined; the filled red is kept for the confirmation */
button.sec.ng { background: transparent; color: var(--warn); border-color: var(--warn); }
button.sec.ng:hover { background: var(--warn-soft); }
button.sm { padding: 3px 12px; margin: 0; font-size: 13px; }
/* PM-r570-2: 「自分で渡した」 - a small link next to a secondary button (a form: it changes something) */
form.inline { display: inline; }
button.sec.link { border: 0; padding: 0 0 0 8px; color: var(--mut); text-decoration: underline; font-weight: 400; }
button.sec.link:hover { background: transparent; }
td button, .msg button { margin-top: 6px; }
/* 「件名をコピー」「本文をコピー」: hidden until /static/copy.js shows them (no JS: select the field and copy) */
button[hidden] { display: none; }
button.copy-btn { margin: 4px 0 8px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { font-size: 12px; font-weight: 600; color: var(--mut); letter-spacing: .04em; background: var(--surface-2); }
td, th { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, table tr:hover td { background: var(--surface-2); }
/* column widths: the main text column takes the room, short values stay on one line */
th.c-main, td.c-main { min-width: 14em; }
th.c-nowrap, td.c-nowrap, th.c-act, td.c-act, th.c-num, td.c-num { white-space: nowrap; width: 1%; }
th.c-num, td.c-num { text-align: right; font-variant-numeric: tabular-nums; }
td.c-act form { display: inline; }
td.c-act button { margin-top: 0; }

/* ---------- messages / transcript ---------- */
.msg { padding: 12px 0; border-bottom: 1px solid var(--line); }
.msg:last-child { border-bottom: 0; }
.msg .who { font-weight: 650; }
.msg.facilitator .who { color: var(--mut); }
.msg.human .who { color: var(--warn); }
/* speaker colours: band + name + initial circle (--band). The name is always shown, so colour is never the
   only cue. Humans (割り込み) use the warning tone, the facilitator stays neutral with a dashed band. */
.msg { --band: var(--line-strong); }
#transcript .msg, .msg.agent, .msg.human, .msg.facilitator { padding-left: 14px; border-left: 3px solid var(--band); margin-bottom: 4px; }
.msg .av { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  border-radius: 50%; margin-right: 6px; font-size: 12px; font-weight: 700; vertical-align: middle;
  background: var(--surface-2); color: var(--mut); border: 1px solid var(--line-strong); }
.msg.human { --band: var(--warn); }
.msg.human .av { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
#transcript .msg.facilitator, .msg.facilitator { border-left-style: dashed; }
.msg.sp0 { --band: var(--sp0); } .msg.sp1 { --band: var(--sp1); } .msg.sp2 { --band: var(--sp2); } .msg.sp3 { --band: var(--sp3); }
.msg.sp4 { --band: var(--sp4); } .msg.sp5 { --band: var(--sp5); } .msg.sp6 { --band: var(--sp6); } .msg.sp7 { --band: var(--sp7); }
.msg.spk .who { color: var(--band); }
/* minutes (round 33): numbered decisions and check-style next actions; the owner's name uses the speaker colour */
.decisions { padding-left: 24px; margin: 0; }
.decisions li { padding: 4px 0; font-weight: 600; }
/* short minutes card (round 34): morning summary and dashboard */
.preview-lead { margin: 4px 0; }
.decisions.preview li { padding: 2px 0; font-weight: 500; }
.preview-actions { margin: 4px 0 0; }
.next-actions { list-style: none; padding: 0; margin: 0; }
.next-actions li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 8px 0;
  border-bottom: 1px solid var(--line); }
.next-actions li:last-child { border-bottom: 0; }
.next-actions .chk { color: var(--mut); }
.next-actions .task { flex: 1 1 14em; min-width: 0; overflow-wrap: anywhere; }
.owner { font-weight: 650; --band: var(--mut); color: var(--band); }
.owner.sp0 { --band: var(--sp0); } .owner.sp1 { --band: var(--sp1); } .owner.sp2 { --band: var(--sp2); } .owner.sp3 { --band: var(--sp3); }
.owner.sp4 { --band: var(--sp4); } .owner.sp5 { --band: var(--sp5); } .owner.sp6 { --band: var(--sp6); } .owner.sp7 { --band: var(--sp7); }
a.tag { text-decoration: none; }
.msg.spk .av { background: var(--band); border-color: var(--band); color: var(--surface); }

/* ---------- mission team editor (ROADMAP P2): pool on the left, the team on the right, one column on phones ---------- */
.team-ed { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 6px 0; }
.team-col { border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 8px 10px; min-height: 72px; }
.team-slot { border-style: solid; border-color: var(--acc); background: var(--acc-soft); }
.team-col.over { box-shadow: 0 0 0 3px var(--acc-soft); border-color: var(--acc); }
.team-h { margin: 0 0 6px; font-size: 13px; font-weight: 650; color: var(--mut); }
.team-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { --band: var(--line-strong); display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px;
  border: 1px solid var(--band); border-radius: 99px; background: var(--surface); cursor: grab; font-weight: 500; }
.chip input { margin: 0 0 0 4px; }
.chip .av { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%;
  font-size: 12px; font-weight: 700; background: var(--band); color: var(--surface); }
.chip .mut { font-size: 12px; }
.chip.dragging { opacity: .5; }
.chip.sp0 { --band: var(--sp0); } .chip.sp1 { --band: var(--sp1); } .chip.sp2 { --band: var(--sp2); } .chip.sp3 { --band: var(--sp3); }
.chip.sp4 { --band: var(--sp4); } .chip.sp5 { --band: var(--sp5); } .chip.sp6 { --band: var(--sp6); } .chip.sp7 { --band: var(--sp7); }
.team-scope ul { margin: 4px 0; }

/* ---------- status tags ---------- */
.tag { display: inline-block; font-size: 12px; font-weight: 600; line-height: 1.7; padding: 0 10px; border-radius: 99px;
  border: 1px solid var(--line-strong); color: var(--mut); background: var(--surface); }
.tag.done, .tag.approved { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.tag.failed, .tag.rejected { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.tag.running { color: var(--acc); border-color: var(--acc); background: var(--acc-soft); }
.tag.pending { color: var(--caution); border-color: var(--caution); background: var(--caution-soft); }
.tag.active { color: var(--acc); border-color: var(--acc); background: var(--acc-soft); }
.tag.needs_human { color: var(--caution); border-color: var(--caution); background: var(--caution-soft); }
.tag.blocked { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
/* .tag.open (未処理), todo, paused, skipped keep the neutral look. Every badge also carries its Japanese label (server.tag). */

/* mission roadmap (server.flow_node, ROADMAP P3): a workflow diagram drawn with HTML/CSS only. Wide screens: the
   nodes run left to right with arrows and wrap; an opened node takes the whole row so its details sit under it.
   Narrow screens: one column with arrows pointing down. Every state also has text (tag, 「いまここ」…). */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 14px 34px; align-items: flex-start; }
.timeline .node { position: relative; flex: 0 1 220px; min-width: 0; }
.timeline .node:has(details[open]) { flex-basis: 100%; }
.timeline .node + .node::before { content: ""; position: absolute; left: -28px; top: 22px; width: 18px; height: 2px;
  background: var(--line-strong); }
.timeline .node + .node::after { content: ""; position: absolute; left: -12px; top: 18px; border: 5px solid transparent;
  border-left: 7px solid var(--line-strong); }
.timeline .node > details { border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); }
.timeline .node > details > summary { cursor: pointer; display: grid; grid-template-columns: 32px 1fr; gap: 4px 10px; padding: 10px 12px;
  list-style: none; }
/* the letter previews in a step's 「送ってよいか」 (nested details): not the step's grid, with room inside */
.decide details { border: 1px solid var(--line-strong); border-radius: 8px; padding: 10px 14px; margin: 8px 0; }
.decide details > summary { cursor: pointer; font-weight: 600; }
.timeline .node > details > summary::-webkit-details-marker { display: none; }
.timeline .node > details > summary > :not(.shape) { grid-column: 2; }
.timeline .shape { grid-row: 1 / span 3; display: inline-flex; align-items: center; justify-content: center; width: 26px;
  height: 26px; margin: 2px; border-radius: 50%; border: 2px solid var(--line-strong); font-weight: 700; font-size: 13px;
  background: var(--surface); }
.timeline .human .shape { border-radius: 3px; transform: rotate(45deg); width: 22px; height: 22px; margin: 4px; }
.timeline .st-done .shape { border-color: var(--ok); background: var(--ok); color: var(--surface); }
.timeline .st-running .shape { border-color: var(--acc); background: var(--acc-soft); color: var(--acc); }
.timeline .st-needs_human .shape { border-color: var(--caution); background: var(--caution-soft); color: var(--caution); }
.timeline .st-blocked .shape { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.timeline .st-done > details { border-color: var(--ok); }
.timeline .now > details { border-width: 2px; border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }
.timeline .human.st-needs_human > details { border-color: var(--caution); border-width: 2px; }
.timeline .n-no { color: var(--mut); font-size: 12px; }
.timeline .n-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.timeline .flag { font-size: 12px; font-weight: 700; padding: 0 8px; border-radius: 99px; line-height: 1.7; }
.timeline .flag.here { color: var(--surface); background: var(--acc); }
.timeline .flag.turn { color: var(--surface); background: var(--caution); }
.timeline .flag.redo { color: var(--mut); border: 1px dashed var(--line-strong); }
.timeline .n-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--mut); }
.timeline .avs { display: inline-flex; }
.timeline .av { --band: var(--line-strong); display: inline-flex; align-items: center; justify-content: center; width: 20px;
  height: 20px; border-radius: 50%; font-size: 11px; font-weight: 700; background: var(--band); color: var(--surface);
  margin-right: -4px; border: 1px solid var(--surface); }
.timeline .av.you { background: var(--caution); }
.timeline .av.more { background: var(--mut); }
.timeline .av.sp0 { --band: var(--sp0); } .timeline .av.sp1 { --band: var(--sp1); } .timeline .av.sp2 { --band: var(--sp2); }
.timeline .av.sp3 { --band: var(--sp3); } .timeline .av.sp4 { --band: var(--sp4); } .timeline .av.sp5 { --band: var(--sp5); }
.timeline .av.sp6 { --band: var(--sp6); } .timeline .av.sp7 { --band: var(--sp7); }
.timeline .bubble { position: relative; margin-top: 6px; padding: 6px 10px; border-radius: 8px; font-size: 13px;
  color: var(--warn); background: var(--warn-soft); border: 1px solid var(--warn); }
.timeline .bubble::before { content: ""; position: absolute; top: -7px; left: 14px; border: 6px solid transparent;
  border-top: 0; border-bottom: 7px solid var(--warn); }
.timeline .n-body { padding: 0 12px 12px 54px; }
/* the one-column layout with downward arrows is in the small-screen block at the end */
/* home (ROADMAP G2): the progress board, one line per mission */
.board-list { list-style: none; margin: 0; padding: 0; }
/* G5①: the same fixed tracks in every row (no auto / content-sized track), so the bars line up as a table */
.board-row { display: grid; grid-template-columns: minmax(0, 16em) 10em 4.5em minmax(0, 1fr) 6em;
  align-items: center; gap: 10px; padding: 6px 0; color: inherit; text-decoration: none; }
.board-row:hover .board-title { text-decoration: underline; }
.board-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row progress { width: 100%; }
.board-count { font-variant-numeric: tabular-nums; }
.board-step { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.other > summary { cursor: pointer; color: var(--acc); }
details.other { margin: 24px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }
details.other > summary { font-weight: 600; margin-bottom: 12px; }
/* step 5 「送ってよいか」 (server.send_decision_html) */
.decide { margin-top: 8px; padding: 12px; border: 1px solid var(--line-strong); border-radius: 8px; }
.decide pre.letter { white-space: pre-wrap; font-family: inherit; margin: 4px 0 8px; }

/* technical error text, owner only, folded (server.error_box) */
.err-detail { margin-top: 8px; font-size: 13px; }
.err-detail summary { cursor: pointer; }
.err-detail pre { margin: 6px 0 0; overflow-wrap: anywhere; font-size: 12px; }

/* long text in a list: 2-line preview, whole text behind 「続きを読む」 (server.more_text, no JS) */
.more summary { cursor: pointer; list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere; }
.more-link, .less-link { color: var(--acc); font-size: 13px; text-decoration: underline; }
.more .less-link, .more[open] .clamp2, .more[open] .more-link { display: none; }
.more[open] .less-link { display: inline; }
.more .pre { overflow-wrap: anywhere; }
/* 「人間が必要なこと」 card: the full text and why a person is needed behind 「詳細」 (server.action_details, no JS) */
.action-more { margin-top: 4px; font-size: 13px; }
.action-more summary { cursor: pointer; color: var(--acc); }
.action-more p { margin: 4px 0; overflow-wrap: anywhere; }
.action-do { margin-top: 6px; gap: 8px; align-items: center; }
.action-do form { margin: 0; }
.action-pick { font-size: 13px; }

/* ---------- one-time messages (flash): CSS only, closable without JS ---------- */
.flash-x { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.flash-x:checked + .flash-box { display: none; }
.flash-box { white-space: pre-wrap; overflow-wrap: anywhere; }
.flash-box.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: min(440px, calc(100vw - 40px));
  background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-left: 4px solid var(--ok);
  border-radius: var(--radius); padding: 14px 46px 14px 16px; box-shadow: var(--shadow-lg);
  animation: flash-in .25s ease-out, flash-out .4s ease 8s forwards;
}
@keyframes flash-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes flash-out { to { opacity: 0; visibility: hidden; } }
.flash-box.modal { position: fixed; inset: 0; z-index: 60; background: rgba(8, 8, 14, .55); display: flex;
  align-items: center; justify-content: center; padding: 16px; }
.flash-panel { position: relative; background: var(--surface); color: var(--fg); border-radius: var(--radius);
  border-top: 4px solid var(--warn); max-width: 500px; width: 100%; padding: 22px 24px; box-shadow: var(--shadow-lg); }
.flash-box.warn .flash-panel { border-top-color: var(--gold); }
.flash-close { position: absolute; top: 6px; right: 14px; cursor: pointer; font-size: 22px; line-height: 1.4; color: var(--mut); margin: 0; font-weight: 400; }
.flash-btn { display: inline-block; margin: 16px 0 0; background: var(--acc); color: var(--acc-fg); border-radius: var(--radius-sm);
  padding: 7px 20px; cursor: pointer; font-size: 14px; font-weight: 600; }
.flash-x:focus-visible + .flash-box .flash-close { outline: 2px solid var(--acc); }
.flash-close:focus-visible, .flash-btn:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .flash-box.toast { animation: none; }
}

/* ---------- small screens: no page-level horizontal scroll ---------- */
@media (max-width: 640px) {
  .team-ed { grid-template-columns: 1fr; }  /* mission team editor: pool above the team */
  .board-row { grid-template-columns: minmax(0, 1fr) 4.5em; }  /* progress board: title + count, then bar, step */
  /* mission workflow diagram (server.flow_node): one column, arrows pointing down */
  .timeline { flex-direction: column; flex-wrap: nowrap; gap: 30px; }
  .timeline .node { flex-basis: auto; width: 100%; }
  .timeline .node + .node::before { left: 24px; top: -24px; width: 2px; height: 16px; }
  .timeline .node + .node::after { left: 20px; top: -10px; border: 5px solid transparent; border-top: 7px solid var(--line-strong); }
  .timeline .n-body { padding-left: 12px; }
  body { font-size: 14px; }
  h1 { font-size: 20px; }
  .topbar { position: static; }
  .topbar-in, .nav-in { padding-left: 14px; padding-right: 14px; }
  .nav a, .nav-more > summary { padding: 8px 9px; font-size: 13px; }
  .nav { position: relative; }
  .nav-more { position: static; }
  .nav-menu { left: 14px; right: 14px; }
  .account { margin-left: 0; width: 100%; }
  main { padding: 18px 12px 48px; }
  .card { padding: 16px; border-radius: 12px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { font-size: 24px; }
  table, tbody, tr, td { display: block; width: 100%; }
  tr:first-child:has(th) { display: none; }
  th { display: none; }
  tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
  td { border: 0; padding: 4px 0; }
  /* stacked rows: the header row is hidden, each value shows its column name (data-label) instead */
  thead { display: none; }
  th.c-main, td.c-main, th.c-nowrap, td.c-nowrap, th.c-act, td.c-act, th.c-num, td.c-num { min-width: 0; width: 100%; white-space: normal; text-align: left; }
  td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 600; color: var(--mut); letter-spacing: .02em; }
  .page-actions { width: 100%; }
  .cols { grid-template-columns: 1fr; }
  .row.tight { flex-wrap: wrap; }
  .auth { margin-top: 8px; }
  .auth .card { padding: 20px 18px; }
  dl.facts { grid-template-columns: 1fr; gap: 0; }
  dl.facts dd { margin-bottom: 8px; }
  .flash-box.toast { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}
/* ROADMAP U1: the night batch log (/night/log) wraps on narrow screens */
.night-log pre{white-space:pre-wrap;overflow-wrap:anywhere;font-size:.85em}
.night-now{margin:.25rem 0 .75rem;font-weight:600}
/* PM-r90-1: a CSV shown on screen; only the table scrolls sideways on a phone */
.csv-view{overflow-x:auto;max-width:100%;margin:8px 0}
.csv-view th,.csv-view td{vertical-align:top;min-width:4em}
/* G3: the material box under the ask field, opened by its link 「資料を添える」 (#material, no JS) */
fieldset.material{margin:8px 0}
fieldset.material[hidden]:target{display:block}
.material-link{margin:4px 0}
