:root {
  color-scheme: light dark;
  --bg: #f7f7f8;
  --panel: #ffffff;
  --fg: #16181d;
  --muted: #5d636e;
  --line: #dcdee3;
  --accent: #2f6df6;
  --accent-fg: #ffffff;
  --ok: #157f3d;
  --bad: #c0362c;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171c;
    --panel: #1d2026;
    --fg: #e9eaee;
    --muted: #9aa1ad;
    --line: #31353e;
    --accent: #5b8cff;
    --accent-fg: #0d1016;
    --ok: #4ec97a;
    --bad: #ff6f61;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
}
main { max-width: 820px; margin: 0 auto; padding: 24px 16px 64px; }

header { margin-bottom: 20px; }
h1 { font-size: 1.6rem; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 0.95rem; margin: 0 0 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.sub { margin: 0; color: var(--muted); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 14px;
}
#unsupported { border-color: var(--bad); }
#unsupported h2 { color: var(--bad); }
/* The message includes a command to run, so keep its line breaks. */
#unsupported-why { white-space: pre-wrap; font-size: 0.9rem; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row + .field, .field + .row, .options + .row { margin-top: 12px; }

button {
  font: inherit;
  padding: 8px 14px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
#btn-generate, #btn-selftest {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: transparent;
  font-weight: 600;
}
#btn-record.recording { background: var(--bad); color: #fff; border-color: transparent; }

.field { display: block; margin-bottom: 10px; }
.field > span { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 4px; }
select,
input[type=text], input[type=number], textarea {
  font: inherit;
  width: 100%;
  padding: 8px 10px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
}
textarea { resize: vertical; font-family: inherit; }
.opts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 0.85rem; color: var(--muted); margin-top: 8px; }
.check input { margin-top: 3px; }

.options { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.options summary { cursor: pointer; font-size: 0.85rem; color: var(--muted); }
.options[open] summary { margin-bottom: 10px; }

.out {
  font-family: var(--mono);
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  max-height: 220px;
  overflow: auto;
}
.out.error { border-color: var(--bad); color: var(--bad); }
.out.ok { border-color: var(--ok); }

.bar { height: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.15s linear; }
.progress-text { display: flex; justify-content: space-between; font-size: 0.82rem; margin-top: 6px; color: var(--muted); }
.progress-detail { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); margin-top: 2px; min-height: 1.2em; word-break: break-all; }

.metrics { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.metrics th {
  text-align: left; font-weight: 500; color: var(--muted);
  padding: 5px 10px 5px 0; vertical-align: top; white-space: nowrap; width: 1%;
}
.metrics td { padding: 5px 0; font-family: var(--mono); word-break: break-word; }
.metrics tr + tr th, .metrics tr + tr td { border-top: 1px solid var(--line); }
.yes { color: var(--ok); }
.no { color: var(--bad); }

.hint { font-size: 0.8rem; color: var(--muted); margin: 8px 0 0; }
footer { margin-top: 24px; font-size: 0.8rem; color: var(--muted); }
code { font-family: var(--mono); font-size: 0.95em; }

@media (max-width: 420px) {
  .row > button { flex: 1 1 auto; }
}
