:root {
  --paper: #e6e7de;
  --sheet: #eeeee5;
  --paper-deep: #dcdfd1;
  --ink: #1a1b17;
  --ink-soft: #55584c;
  --rule: #b8baa9;
  --rule-soft: rgba(26, 27, 23, 0.13);
  --red: #b23a2e;
  --red-deep: #8c2b21;
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: "Archivo", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding-left: 72px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.9;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

a {
  color: inherit;
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
}
a:hover { color: var(--red); text-decoration-color: var(--red); }

/* ---------------- spine ---------------- */

.spine {
  position: fixed;
  inset: 0 auto 0 0;
  width: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 0 26px;
  border-right: 1px solid var(--rule);
  background: var(--paper);
  z-index: 5;
}
.spine-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}
.spine-word {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.34em;
  margin-top: 20px;
}
.spine-line {
  flex: 1;
  width: 1px;
  background: var(--rule);
  margin: 20px 0;
}
.spine-note {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}

/* ---------------- shell ---------------- */

.masthead,
.desk,
.colophon {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 48px;
}

/* ---------------- masthead ---------------- */

.masthead { padding-top: 76px; }

.masthead h1 {
  margin: 0 0 22px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(38px, 5.2vw, 64px);
  line-height: 1.14;
  letter-spacing: 0.01em;
  opacity: 0;
  transform: translateY(12px);
  animation: rise 0.85s cubic-bezier(0.2, 0.7, 0.2, 1) 0.08s forwards;
}

.masthead .lede {
  margin: 0;
  max-width: 34em;
  font-size: 16.5px;
  line-height: 1.95;
  color: var(--ink-soft);
  opacity: 0;
  animation: fade 0.9s ease 0.4s forwards;
}

@keyframes rise {
  to { opacity: 1; transform: none; }
}
@keyframes fade {
  to { opacity: 1; }
}

/* ---------------- desk ---------------- */

.desk {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr);
  gap: 64px;
  margin-top: 56px;
  align-items: start;
}

/* ---------------- sheet ---------------- */

.sheet {
  position: relative;
  background: var(--sheet);
  border: 1px solid var(--rule);
}
.sheet::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 56px;
  width: 1px;
  background: var(--red);
  opacity: 0.78;
}
.sheet:focus-within {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.sheet-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px 13px 72px;
  border-bottom: 1px solid var(--rule);
}
.sheet-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.count {
  font-family: var(--sans);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

textarea {
  display: block;
  width: 100%;
  min-height: 336px;
  padding: 22px 32px 30px 72px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.98;
  resize: vertical;
  outline: none;
}
textarea::placeholder {
  color: var(--ink-soft);
  opacity: 0.72;
  font-style: italic;
}

.sheet-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px 12px 72px;
  border-top: 1px solid var(--rule);
}
.samples { display: flex; flex-wrap: wrap; gap: 2px 20px; }
.samples button,
.link {
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--ink-soft);
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
  cursor: pointer;
}
.samples button:hover,
.link:hover {
  color: var(--red);
  text-decoration-color: var(--red);
}

/* ---------------- take ---------------- */

.take {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.record {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  padding: 0 30px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--ink);
  color: var(--sheet);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.record:hover:not(:disabled) {
  background: var(--red);
  border-color: var(--red);
}
.record:disabled {
  background: transparent;
  border-color: var(--rule);
  color: var(--ink-soft);
  opacity: 1;
  cursor: not-allowed;
}
.record:disabled .rec-dot { background: var(--rule); }

.rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--red);
  transition: background 0.18s ease;
}
.record:hover:not(:disabled) .rec-dot,
.record.busy .rec-dot { background: var(--sheet); }
.record.busy .rec-dot { animation: pulse 1.4s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.cancel {
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--red);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.shortcut {
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--ink-soft);
}
kbd {
  font-family: var(--sans);
  font-size: 11px;
  border-bottom: 1px dotted var(--ink-soft);
  padding-bottom: 1px;
  margin: 0 1px;
}

/* ---------------- dials ---------------- */

.dials {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 30px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--rule-soft);
}
.dial { display: flex; align-items: center; gap: 10px; min-width: 0; }
.dial label {
  flex: none;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
}
.dial input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  min-width: 0;
  height: 16px;
  background: transparent;
  cursor: pointer;
}
.dial input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: var(--rule); }
.dial input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 9px;
  height: 9px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--ink);
}
.dial input[type="range"]::-moz-range-track { height: 1px; background: var(--rule); }
.dial input[type="range"]::-moz-range-thumb {
  width: 9px;
  height: 9px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
}
.dial input[type="range"]:focus-visible::-webkit-slider-thumb { background: var(--red); }
.dial output {
  flex: none;
  min-width: 46px;
  text-align: right;
  font-family: var(--sans);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* ---------------- status & progress ---------------- */

.status {
  min-height: 20px;
  margin-top: 18px;
  font-family: var(--sans);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink-soft);
}
.status.error { color: var(--red-deep); }
.status.ok { color: var(--ink); }

.progress {
  height: 2px;
  margin-top: 6px;
  background: var(--rule);
  overflow: hidden;
}
.progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--red);
  transition: width 0.3s ease;
}
.progress.indeterminate i {
  width: 30% !important;
  animation: sweep 1.3s ease-in-out infinite;
}
@keyframes sweep {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(360%); }
}

/* ---------------- player ---------------- */

.player {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
}
.play {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}
.play:hover { background: var(--ink); }
.play:hover svg { fill: var(--sheet); }
.play svg { width: 17px; height: 17px; fill: var(--ink); }
.play .icon-pause { display: none; }
.player.playing .icon-play { display: none; }
.player.playing .icon-pause { display: block; }

.track { flex: 1; min-width: 0; }
#seek {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  cursor: pointer;
}
#seek::-webkit-slider-runnable-track { height: 2px; background: var(--rule); }
#seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 10px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--red);
}
#seek::-moz-range-track { height: 2px; background: var(--rule); }
#seek::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 0;
  border-radius: 50%;
  background: var(--red);
}

.time {
  flex: none;
  font-family: var(--sans);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}
.download {
  flex: none;
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--red);
  text-decoration: underline;
  text-underline-offset: 3px;
}
audio { display: none; }
.voice-empty {
  margin: 0;
  padding: 26px 12px;
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--ink-soft);
}
.player-meta {
  margin: 10px 0 0;
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--ink-soft);
}

/* ---------------- catalog ---------------- */

.catalog {
  border-top: 2px solid var(--ink);
  padding-top: 14px;
  min-width: 0;
}
.catalog-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}
.catalog-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

#voice-search {
  width: 100%;
  margin-top: 16px;
  padding: 10px 0 9px;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  outline: none;
}
#voice-search::placeholder { color: var(--ink-soft); opacity: 0.7; }
#voice-search:focus { border-bottom-color: var(--red); }

.langs {
  display: flex;
  flex-wrap: wrap;
  gap: 0 20px;
  margin-top: 14px;
}
.langs button {
  padding: 3px 0 4px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
}
.langs button:hover { color: var(--ink); }
.langs button[aria-pressed="true"] {
  color: var(--ink);
  border-bottom-color: var(--red);
}

.chosen {
  margin: 14px 0 8px;
  min-height: 18px;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-soft);
}
.chosen strong {
  font-weight: 500;
  color: var(--ink);
}

.voice-list {
  max-height: 468px;
  overflow: auto;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  scrollbar-width: thin;
}
.voice-group {
  padding: 16px 0 6px;
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}
.voice {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 8px 8px 9px 12px;
  border-bottom: 1px solid var(--rule-soft);
  background: none;
  text-align: left;
  cursor: pointer;
}
.voice-body { min-width: 0; }
.preview {
  flex: none;
  min-width: 50px;
  padding: 4px 8px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: transparent;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.preview:hover { color: var(--red); border-color: var(--red); }
.preview[data-state="playing"] { color: var(--red); border-color: var(--red); }
.preview:disabled { opacity: 0.65; cursor: wait; }
.voice:last-child { border-bottom: 0; }
.voice:hover { background: rgba(26, 27, 23, 0.04); }
.voice[aria-selected="true"] { background: rgba(178, 58, 46, 0.07); }
.voice[aria-selected="true"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--red);
}
.voice b {
  display: block;
  font-family: var(--serif);
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
}
.voice span {
  display: block;
  margin-top: 1px;
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------- colophon ---------------- */

.colophon {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-top: 84px;
  padding-top: 18px;
  padding-bottom: 40px;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--ink-soft);
}

/* ---------------- responsive ---------------- */

@media (max-width: 1080px) {
  .desk { grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr); gap: 44px; }
  .masthead, .desk, .colophon { padding: 0 36px; }
}

@media (max-width: 900px) {
  body { padding-left: 0; }
  .spine { display: none; }
  .masthead { padding-top: 52px; }
  .desk {
    grid-template-columns: minmax(0, 1fr);
    gap: 48px;
    margin-top: 42px;
  }
  .catalog { border-top: 1px solid var(--ink); padding-top: 18px; }
  .voice-list { max-height: 380px; }
  .masthead, .desk, .colophon { padding: 0 28px; }
}

@media (max-width: 560px) {
  .masthead { padding-top: 40px; }
  .masthead, .desk, .colophon { padding: 0 18px; }
  .masthead h1 { font-size: 34px; }
  .masthead .lede { font-size: 15px; }
  textarea { min-height: 260px; padding: 18px 18px 24px 52px; font-size: 16.5px; }
  .sheet::before { left: 34px; }
  .sheet-head { padding: 14px 16px 11px 52px; }
  .sheet-foot { padding: 10px 16px 10px 52px; flex-wrap: wrap; }
  .record { width: 100%; justify-content: center; }
  .shortcut { display: none; }
  .player { flex-wrap: wrap; gap: 12px; }
  .dials { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .download { margin-left: auto; }
  .colophon { flex-direction: column; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .masthead h1, .masthead .lede { opacity: 1; transform: none; animation: none; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}
