:root {
  --bg: #f4f6f8; --card: #fff; --text: #1d2733; --muted: #5f6b78; --line: #d5dbe1;
  --brand: #0b4f8a; --brand-text: #fff; --rec: #c62828; --ok: #1b7f3b; --warn: #b45309; --err: #b42318;
  --font: "Noto Sans Thai", "Sarabun", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
}
/* Dark colours: follow the phone setting unless the user picked light/dark with the header button (theme.js sets data-theme). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #11161c; --card: #1a222b; --text: #e6ebf0; --muted: #9aa6b2; --line: #2e3a46; --brand: #4a9ee6; --brand-text: #0b1520; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #11161c; --card: #1a222b; --text: #e6ebf0; --muted: #9aa6b2; --line: #2e3a46; --brand: #4a9ee6; --brand-text: #0b1520; color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
.theme { background: none; border: 1px solid currentColor; border-radius: 999px; color: var(--brand-text); min-width: 2.4em; padding: 2px 10px; margin: 0; font-size: 16px; font-weight: 700; line-height: 1.4; cursor: pointer; }
tr.off td { color: var(--muted); }
button.danger { color: var(--err); border-color: var(--err); }
button.small { padding: 6px 12px; margin-top: 6px; font-size: 14px; }
details.fold { padding: 0; }
details.fold > summary { padding: 14px 16px; cursor: pointer; font-weight: 600; }
details.fold[open] > summary { border-bottom: 1px solid var(--line); }
details.fold > .card { border: 0; border-radius: 0; margin: 0; border-bottom: 1px solid var(--line); }
details.fold > .card:last-child { border-bottom: 0; }
td form.inline { margin-top: 6px; }
td button { white-space: nowrap; }
.header-right { display: flex; gap: 12px; align-items: center; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 var(--font); }
header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; background: var(--brand); color: var(--brand-text); flex-wrap: wrap; }
header a, header .link { color: var(--brand-text); }
.brand { font-weight: 700; text-decoration: none; }
nav { display: flex; gap: 12px; align-items: center; font-size: 14px; }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 8px 0 16px; }
h1 .sub { display: block; font-size: 14px; font-weight: 400; color: var(--muted); }
h2 { font-size: 18px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 16px 0 6px; }
small.ja { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; overflow-x: auto; }
label { display: block; margin: 12px 0 4px; font-weight: 600; }
[hidden] { display: none !important; }
input, textarea, select { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
textarea { line-height: 1.7; }
input[readonly], textarea[readonly] { opacity: .8; }
button, .button { display: inline-block; padding: 10px 18px; margin-top: 12px; font: inherit; font-weight: 600; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; text-decoration: none; text-align: center; }
button small.ja, .button small.ja { color: inherit; opacity: .8; }
.primary { background: var(--brand); color: var(--brand-text); border-color: var(--brand); }
.big { width: 100%; padding: 14px; font-size: 18px; }
button:disabled { opacity: .45; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; margin: 0; color: var(--brand); text-decoration: underline; font-weight: 400; }
.rec { width: 100%; padding: 22px; font-size: 22px; background: var(--rec); color: #fff; border: 0; border-radius: 14px; }
.rec.on { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.timer { display: block; text-align: center; font-size: 28px; font-variant-numeric: tabular-nums; margin-top: 6px; }
.hint { color: var(--muted); font-size: 14px; font-weight: 400; margin: 6px 0; }
.status { min-height: 1.4em; color: var(--muted); }
.status.err, .err { color: var(--err); }
.ok { color: var(--ok); font-weight: 600; }
.demo { background: #fff4d6; color: #6b4a00; border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.segments { padding-left: 20px; }
.segments li { margin-bottom: 12px; }
.segments audio { width: 100%; }
.tx { font-size: 14px; white-space: pre-wrap; }
.cardimg { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }
pre { white-space: pre-wrap; word-break: break-word; font: 14px/1.6 var(--font); background: var(--bg); padding: 8px; border-radius: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }
.reports { list-style: none; padding: 0; }
.reports li a { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 12px; margin-bottom: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-decoration: none; }
.reports .main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.reports .meta { color: var(--muted); font-size: 14px; }
.reports .due small.ja { display: inline; margin-left: 4px; }
.reports .badge { align-self: center; font-size: 13px; text-align: right; }
.reports .due, .reports .who { color: var(--muted); font-size: 13px; }
.reports li.overdue a { border-color: var(--err); }
.reports li.overdue .badge { color: var(--err); font-weight: 700; }
.reports li.submitted .badge { color: var(--ok); }
.reports li.translated .badge { color: var(--warn); }
.view dt { font-weight: 600; margin-top: 10px; }
.view dd { margin: 0; }
.view ul { margin: 2px 0 8px; padding-left: 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
form.inline { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
form.inline input { width: auto; min-width: 0; flex: 1 1 6em; margin: 0; }
form.inline button { margin: 0; }
body.busy { cursor: progress; }
body.busy button { pointer-events: none; opacity: .6; }
details { margin: 12px 0; }

/* 4-step bar, "next" box and the current section */
.steps { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 0; margin: 0 0 12px; }
.steps li { display: flex; flex-direction: column; align-items: center; text-align: center; font-size: 12px; line-height: 1.3; color: var(--muted); }
.steps .dot { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); font-weight: 700; margin-bottom: 4px; }
.steps .lbl small.ja { font-size: 11px; }
.steps li.done { color: var(--ok); }
.steps li.done .dot { border-color: var(--ok); background: var(--ok); color: #fff; }
.steps li.current { color: var(--text); font-weight: 700; }
.steps li.current .dot { border-color: var(--brand); background: var(--brand); color: var(--brand-text); }
.next { border: 2px solid var(--brand); border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; background: var(--card); }
.next p { margin: 4px 0 0; }
.next .button { margin-top: 10px; }
.card.current { border: 2px solid var(--brand); }
.here { display: inline-block; vertical-align: middle; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--brand); color: var(--brand-text); font-size: 12px; font-weight: 700; }
details.flow > summary { cursor: pointer; font-weight: 700; }
.flowlist { margin: 10px 0 0; padding-left: 22px; }
.flowlist li { margin-bottom: 10px; }
.flowlist li .hint { display: block; margin: 2px 0 0; }
.flowlist li.done { color: var(--muted); text-decoration: line-through; }
.card.guide { border: 2px solid var(--warn); }

.meter { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; margin: 8px 0 0; }
.meter span { display: block; height: 100%; width: 0; background: var(--ok); transition: width .12s linear; }
