:root {
  --bg: #0c0b0f;
  --panel: #16141b;
  --line: #2c2834;
  --text: #e9e4ee;
  --muted: #8f879b;
  --accent: #9b2335;
  --accent-text: #fff;
  --warn: #e0a24a;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

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

section, details {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

textarea, input[type=text], input[type=password], select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font: inherit;
}
textarea { resize: vertical; font-size: 1.15rem; min-height: 110px; }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.row input { flex: 1; min-width: 0; }

button {
  font: inherit;
  border-radius: 10px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  flex: 1;
  font-size: 1.1rem;
}
kbd { font-size: .7em; opacity: .7; margin-left: 6px; font-family: inherit; }

.status { min-height: 1.5em; margin: 8px 0 0; color: var(--accent); }
.hint { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }
.warn { color: var(--warn); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.chip button { border: 0; border-radius: 0; padding: 8px 12px; }
.chip button.x { padding: 8px 10px 8px 2px; color: var(--muted); }
.chip:hover { border-color: var(--accent); }

.history { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.history li button {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 10px 4px;
  overflow-wrap: anywhere;
}
.history li:last-child button { border-bottom: 0; }

summary { cursor: pointer; font-weight: 600; }
.settings { display: grid; gap: 14px; margin-top: 14px; }
.settings label { display: grid; gap: 6px; color: var(--muted); }
.settings label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.settings output { color: var(--text); }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

header h1 { font-family: Georgia, "Times New Roman", serif; letter-spacing: .02em; }
.sub { font-style: italic; }
.notice {
  border: 1px solid var(--warn);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--warn);
  margin: 0 0 16px;
}
fieldset {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px 14px;
  margin: 0;
  display: grid;
  gap: 14px;
}
legend { padding: 0 6px; color: var(--text); font-weight: 600; }
.row.tight { margin-top: 0; flex-wrap: nowrap; }
.row.tight select { flex: 1; min-width: 0; }
.settings textarea { font-size: .95rem; min-height: 0; }
.history li { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.history li:last-child { border-bottom: 0; }
.history li button { border-bottom: 0 !important; }
.history li button.save { width: auto; flex: none; color: var(--muted); font-size: .85rem; }
.status.error { color: var(--warn); }
.speaking textarea { border-color: var(--accent); }

[hidden] { display: none !important; }
.file-btn {
  display: inline-block !important;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 16px;
  color: var(--text) !important;
  cursor: pointer;
}
.file-btn:hover, .file-btn:focus-within { border-color: var(--accent); }
#caw-list li.caw-item { flex-wrap: wrap; }
#caw-list li.caw-item > button:first-child { flex: 1; width: auto; min-width: 0; }
.trim { flex-basis: 100%; display: grid; gap: 8px; padding: 4px 4px 12px; }
.trim canvas { width: 100%; height: 64px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.trim label { display: grid; gap: 4px; color: var(--muted); font-size: .85rem; }
#caw-list .trim button { width: auto; flex: none; border: 1px solid var(--line) !important; border-radius: 10px; padding: 8px 14px; text-align: center; }
.volume { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--muted); }
.volume input { flex: 1; }
.volume output { min-width: 3.5em; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
