:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c1f24;
  --muted: #5f6672;
  --line: #dde1e7;
  --accent: #1f5fae;
  --accent-soft: #e6eef9;
  --danger: #b3261e;
  --past: #8a909a;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121418;
    --surface: #1b1e24;
    --text: #e8eaee;
    --muted: #a0a6b1;
    --line: #2e333b;
    --accent: #6ea3ea;
    --accent-soft: #1f2c3f;
    --danger: #f2867e;
    --past: #747b86;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.2rem; margin: 0; }
.muted { color: var(--muted); }

button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
textarea { resize: vertical; }
label { display: block; margin: 0 0 14px; font-weight: 600; font-size: 0.92rem; }
label input, label select, label textarea { margin-top: 5px; font-weight: 400; font-size: 1rem; }

button {
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
button.secondary { background: transparent; }
button.link { border: none; background: none; color: var(--accent); padding: 4px 6px; }
button.danger { color: var(--danger); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; width: 100%; max-width: 380px; }
.card h1 { margin-bottom: 4px; }
.card .primary { width: 100%; margin-top: 6px; }
.alert { background: #fdecea; color: #8c1d18; padding: 10px 12px; border-radius: 8px; }
@media (prefers-color-scheme: dark) { .alert { background: #3b1d1b; color: #f6b8b3; } }

/* layout */
.top { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.top div { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.page { max-width: 900px; margin: 0 auto; padding: 24px 16px 64px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }

/* recording list */
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.item.done { opacity: 0.75; }
.item-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.item-title { font-weight: 600; overflow-wrap: anywhere; }
.item-meta { font-size: 0.88rem; color: var(--muted); }
.item-actions { display: flex; gap: 4px; flex-shrink: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 10px; font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.chip.past { background: transparent; color: var(--past); border: 1px solid var(--line); text-decoration: line-through; }
.item audio { width: 100%; height: 36px; }
.item-text { font-size: 0.9rem; color: var(--muted); white-space: pre-wrap; margin: 8px 0 0; }

/* dialogs */
dialog { border: none; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 24px)); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(10, 14, 20, 0.45); }
.dlg { padding: 20px; max-height: calc(100vh - 40px); overflow-y: auto; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 10px; color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.row label { margin: 0; }
.grow { flex: 1 1 180px; }
.preview { background: var(--bg); border-radius: 8px; padding: 10px 12px; margin: 4px 0 14px; }
.preview p { margin: 0 0 6px; font-size: 0.9rem; }
.preview audio { width: 100%; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; }
legend { font-weight: 600; font-size: 0.92rem; padding: 0 4px; }
.times { display: grid; gap: 8px; margin-bottom: 4px; }
.time-row { display: flex; gap: 6px; align-items: center; }
.time-row input { flex: 1; }
.status { min-height: 1.4em; margin: 4px 0; font-size: 0.92rem; }
.status.error { color: var(--danger); }

@media (max-width: 560px) {
  .item-head { flex-direction: column; }
  .page-head h1 { font-size: 1.3rem; }
}
