:root {
  --bg: #f5f4f8;
  --card: #ffffff;
  --text: #1b1a22;
  --muted: #66637a;
  --line: #e2dfea;
  --accent: #7048e8;
  --accent-2: #d6336c;
  --accent-soft: #efeafd;
  --on-accent: #ffffff;
  --error: #b3261e;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131217;
    --card: #1d1b24;
    --text: #ecebf2;
    --muted: #9c99ad;
    --line: #33303f;
    --accent: #a78bfa;
    --accent-2: #f472b6;
    --accent-soft: #2a2342;
    --on-accent: #120c22;
    --error: #ff8a80;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131217; --card: #1d1b24; --text: #ecebf2; --muted: #9c99ad; --line: #33303f;
  --accent: #a78bfa; --accent-2: #f472b6; --accent-soft: #2a2342; --on-accent: #120c22; --error: #ff8a80;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: 640px; margin: 0 auto; padding: 40px 16px 32px; }

header { margin-bottom: 20px; }
h1 { margin: 0; font-size: 2rem; letter-spacing: -0.02em; line-height: 1.1; }
h1 .a { color: var(--accent-2); }
h1 .b { color: var(--accent); }
.tagline { margin: 8px 0 0; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 2px rgb(0 0 0 / 4%), 0 8px 24px rgb(0 0 0 / 5%);
}

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }

/* source picker */
.pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .pick { grid-template-columns: 1fr; } }
.source {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 32px 16px;
  font: inherit; color: var(--text);
  background: transparent;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.source:hover, .source.over, .source:focus-within, .source:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.source input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.source svg { width: 36px; height: 36px; color: var(--accent); margin-bottom: 6px; }
.source strong { font-size: 1.1rem; }

.recording {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius);
}
.recording .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--error); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .recording .dot { animation: none; } }
.recording canvas { flex: 1; min-width: 80px; height: 32px; }
#rec-time { font-variant-numeric: tabular-nums; }

.file-info {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-bottom: 16px; border-bottom: 1px solid var(--line);
}
.file-name { font-weight: 600; overflow-wrap: anywhere; }
#player { width: 100%; margin-top: 14px; }

/* options */
fieldset { border: 0; margin: 0; padding: 18px 0 0; min-width: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: 8px; }
fieldset p { margin: 8px 0 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip, .seg label { position: relative; }
.chip input, .seg input { position: absolute; opacity: 0; pointer-events: none; }
.chip span, .seg span {
  display: inline-block;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  user-select: none;
  transition: background .12s, border-color .12s, color .12s;
}
.chip input:checked + span, .seg input:checked + span {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
}
.chip input:focus-visible + span, .seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.seg { display: flex; flex-wrap: wrap; gap: 8px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
@media (max-width: 520px) { .grid { grid-template-columns: 1fr; } }
.grid label { display: flex; flex-direction: column; gap: 4px; font-size: 0.875rem; color: var(--muted); }

select, input:not([type="radio"]):not([type="checkbox"]):not([type="file"]) {
  font: inherit; color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 18px; height: 18px; }
.error-text { color: var(--error); min-height: 1.3em; }
.error-text:empty { min-height: 0; margin: 0; }

/* buttons */
.actions { display: flex; gap: 10px; margin-top: 22px; }
.btn {
  font: inherit; font-weight: 600;
  border-radius: 10px;
  padding: 11px 22px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--muted); }
.btn.block { display: flex; width: 100%; margin-top: 12px; }
.actions .btn.primary { flex: 1; }

/* status */
.status { margin-top: 20px; }
.status p { margin: 0 0 8px; }
.status.error p { color: var(--error); }
.status.error progress { display: none; }
progress { width: 100%; height: 10px; appearance: none; border: 0; border-radius: 99px; background: var(--line); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--line); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 99px; transition: width .3s; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 99px; }

/* result */
.live { margin: 12px 0 0; color: var(--muted); white-space: pre-wrap; max-height: 160px; overflow: auto; }
.live:empty { display: none; }
.result-label { display: block; font-weight: 600; margin-bottom: 8px; }
textarea {
  font: inherit; color: var(--text); line-height: 1.6;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; width: 100%; resize: vertical; min-height: 160px;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.downloads { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.downloads .btn { padding: 9px 16px; }
.downloads .btn.primary { flex: 1; }
.seg small { opacity: .75; font-weight: 400; }

footer { margin-top: 18px; text-align: center; }

/* embedded in another page (see index.html) */
.embedded body { background: transparent; }
.embedded .wrap { max-width: none; padding: 0; }
.embedded header { display: none; }
.embedded footer { margin-bottom: 4px; }
