:root {
  --paper: #eeedf3;
  --card: #f8f7fb;
  --ink: #1c1a22;
  --body: #47434f;
  --muted: #6c6875;
  --line: #d9d6e1;
  --night: #17151d;
  --night-2: #221f2b;
  --on-night: #ece9f3;
  --on-night-soft: #a29dae;
  --accent: #2f6d61;
  --mint: #a7e5d3;
  --peach: #f4c5a8;
  --lavender: #c8b8e0;
  --sky: #a8c8e8;
  --rose: #e8b8c4;
  --ui: "Manrope", ui-sans-serif, sans-serif;
  --display: "Newsreader", Georgia, serif;
  --gutter: clamp(1.25rem, 0.8rem + 2.6vw, 3.5rem);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--ui);
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px var(--gutter);
  max-width: 1280px; margin: 0 auto;
}
.mark {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; letter-spacing: -0.01em; color: var(--ink); text-decoration: none;
}
.mark svg { width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
.unlock-link {
  border: 0; background: none; cursor: pointer; padding: 6px 0;
  font-weight: 600; font-size: 14px; color: var(--accent);
  text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px;
}

main { max-width: 1280px; margin: 0 auto; padding: 0 var(--gutter) 64px; }

.intro { padding: clamp(16px, 4vw, 48px) 0 clamp(24px, 4vw, 44px); max-width: 760px; }
.intro h1 {
  font: 300 clamp(2.15rem, 1.5rem + 2.6vw, 3.6rem)/1.06 var(--display);
  letter-spacing: -0.025em; margin: 0 0 18px;
  text-wrap: balance;
}
.intro p { margin: 0; max-width: 58ch; color: var(--body); font-size: 17px; text-wrap: pretty; }

.work {
  display: grid; gap: clamp(20px, 3vw, 40px);
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}
@media (min-width: 960px) {
  .work { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); }
  .stage { position: sticky; top: 20px; order: 2; }
}

/* Controls */
.controls { display: grid; gap: 14px; min-width: 0; }
.step {
  margin: 0; min-width: 0;
  border: 0; border-radius: 14px;
  background: var(--card);
  box-shadow: 0 0 0 1px var(--line);
  padding: 20px 20px 22px;
  display: grid; gap: 18px;
}
.step legend {
  float: left; width: 100%;
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 15px; padding: 0;
}
.step legend + * { clear: both; }
.n {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--ink); color: var(--paper); font-size: 12px; font-weight: 700;
}

.drop {
  position: relative; display: grid; gap: 2px; place-items: center; text-align: center;
  padding: 22px 16px; border-radius: 10px;
  border: 1.5px dashed #bdb8c8; background: var(--paper);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: #e7f0ed; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.drop strong { font-weight: 600; }
.drop span { color: var(--muted); font-size: 14px; }

.row-buttons { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px;
  border: 0; cursor: pointer; text-decoration: none; font-weight: 600; font-size: 15px;
  transition: background .15s, transform .1s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover:not([disabled]) { background: #000; }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--line); color: var(--ink); }
.btn.ghost:hover { box-shadow: inset 0 0 0 1px #b4afc0; background: #fff; }
.btn.light { background: var(--on-night); color: var(--night); }
.btn.light:hover { background: #fff; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #c2413a; }
#recBtn.recording .dot { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.clips { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.clips:empty { display: none; }
.clips li {
  display: grid; grid-template-columns: 14px minmax(0, 1fr) auto auto; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; background: var(--paper); font-size: 14px;
}
.clips .sw { width: 14px; height: 14px; border-radius: 4px; }
.clips .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.clips .dur { color: var(--muted); font-variant-numeric: tabular-nums; }
.clips button {
  border: 0; background: none; cursor: pointer; color: var(--muted);
  width: 28px; height: 28px; border-radius: 6px; font-size: 18px; line-height: 1;
}
.clips button:hover { background: #fff; color: var(--ink); }

.field { display: grid; gap: 8px; min-width: 0; }
.field[hidden] { display: none; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.field label, .label { font-size: 14px; font-weight: 500; color: var(--body); }
output { font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
.hint[hidden] { display: none; }
.inline {
  border: 0; background: none; padding: 0; cursor: pointer;
  color: var(--accent); font-weight: 600; font-size: 13px;
  text-decoration: underline; text-underline-offset: 2px;
}

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; margin: 0;
  --fill: 50%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 4px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--line) var(--fill));
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 1.5px var(--accent), 0 1px 3px rgb(0 0 0 / .15);
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--accent); background: #fff;
}

select {
  width: 100%; min-height: 44px; padding: 0 36px 0 12px; border-radius: 8px;
  border: 0; box-shadow: inset 0 0 0 1px var(--line); background: #fff;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%236c6875' stroke-width='1.6'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}

.seg {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 3px; border-radius: 10px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line);
}
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span {
  display: grid; place-items: center; min-height: 38px; padding: 0 6px; border-radius: 7px;
  font-size: 14px; font-weight: 500; color: var(--body); text-align: center; line-height: 1.15;
}
.seg input:checked + span { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / .08); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }

.check { display: flex; gap: 10px; align-items: center; font-size: 14px; font-weight: 500; color: var(--body); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Stage: the stack itself */
.stage { min-width: 0; }
.panel {
  background: var(--night); color: var(--on-night);
  border-radius: 18px; padding: 20px; display: grid; gap: 16px;
  box-shadow: 0 30px 60px -30px rgb(23 21 29 / .45);
}
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.panel-head p { margin: 0; }
#summary { font: 300 22px/1.2 var(--display); letter-spacing: -0.01em; }
.time { font-size: 13px; color: var(--on-night-soft); font-variant-numeric: tabular-nums; }
#strata {
  display: block; width: 100%; height: 300px;
  border-radius: 10px; background: var(--night-2);
}
@media (min-width: 960px) { #strata { height: 420px; } }

.actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.actions .btn.primary { background: var(--on-night); color: var(--night); }
.actions .btn.primary:hover:not([disabled]) { background: #fff; }
.status { margin: 0; font-size: 14px; color: var(--on-night-soft); min-height: 1.5em; }
.status.err { color: #f2a7a0; }
.status.busy::before {
  content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; vertical-align: -1px;
  border-radius: 50%; border: 2px solid var(--on-night-soft); border-top-color: transparent;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result { display: grid; gap: 12px; }
.result[hidden] { display: none; }
.result audio { width: 100%; height: 44px; }
.result .btn { justify-self: start; }
.privacy { margin: 12px 4px 0; font-size: 13px; color: var(--muted); }
.foot { max-width: 1280px; margin: 0 auto; padding: 0 var(--gutter) 32px; font-size: 13px; color: var(--muted); }
.foot a { color: inherit; }

/* Unlock dialog */
dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(440px, calc(100vw - 32px));
  background: var(--card); color: var(--ink);
  box-shadow: 0 30px 80px -20px rgb(23 21 29 / .5);
}
dialog::backdrop { background: rgb(23 21 29 / .45); }
.dlg { position: relative; padding: 26px 24px 24px; }
.dlg h2 { font: 300 30px/1.1 var(--display); margin: 0 0 6px; letter-spacing: -0.02em; }
.dlg p { margin: 0 0 14px; color: var(--body); }
.dlg ul { margin: 0 0 22px; padding-left: 18px; display: grid; gap: 6px; color: var(--body); }
.dlg-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.close {
  position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 8px;
  border: 0; background: none; cursor: pointer; font-size: 22px; color: var(--muted);
}
.close:hover { background: var(--paper); color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
