:root {
  --bg: #101012;
  --surface: #1c1c1f;
  --surface-2: #252529;
  --input: #2e2e33;
  --cream: #f7f4ef;
  --mute: #a3a3a3;
  --faint: #6a6a72;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.15);
  --pink: #fd429c;
  --orange: #ff6a00;
  --ok: #4aab04;
  --warn: #f5d907;
  --bad: #f8441b;
  --aura: linear-gradient(100deg, #ffb300 0%, #ff6a00 46%, #fd429c 100%);
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 196px 1fr;
  color: var(--cream);
  background:
    radial-gradient(560px 320px at 12% -8%, rgba(255, 106, 0, 0.22), transparent 62%),
    radial-gradient(480px 280px at 78% -12%, rgba(253, 66, 156, 0.16), transparent 58%),
    var(--bg);
  font: 15px/1.6 var(--sans);
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 2px;
}
::placeholder { color: var(--faint); }

.sidebar {
  padding: 28px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: rgba(16, 16, 18, 0.72);
  backdrop-filter: blur(16px);
}

.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px; }
.brand strong {
  display: block;
  font-size: 18px;
  font-weight: 650;
}
.brand small { color: var(--mute); font-size: 12px; }
.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--aura);
  box-shadow: 0 0 16px rgba(255, 106, 0, 0.55);
  font-size: 0;
  color: transparent;
  flex: none;
}

nav { display: flex; flex-direction: column; gap: 2px; }
nav button, .ghost, .primary, .text-link { border: 0; text-decoration: none; }
nav button {
  display: flex;
  align-items: center;
  text-align: left;
  background: transparent;
  color: var(--mute);
  border-radius: 999px;
  padding: 8px 14px;
  border-left: 0;
}
nav button i { display: none; }
nav button:hover { color: var(--cream); }
nav button.active {
  background: var(--aura);
  color: #101012;
  font-weight: 650;
}
nav button.active:hover { color: #101012; filter: brightness(1.06); }
nav button[data-nav="generate"] { margin-bottom: 14px; }

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.45;
}

main {
  padding: 40px 48px 80px;
  max-width: 1080px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 28px;
}
h1 {
  margin: 0 0 8px;
  font-size: 40px;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
h2 {
  margin: 0 0 16px;
  font-size: 22px;
  font-weight: 650;
  line-height: 1.2;
}
.page-head p, .hint, small, .muted { color: var(--mute); }
.page-head p { max-width: 38em; }
p { margin: 0; }

.card, .take, .custom-item, .record, .settings-form, .clone-form {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}

.sheet {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px 22px 18px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.7fr);
  gap: 36px;
  align-items: start;
}

.field { display: flex; flex-direction: column; gap: 8px; }
.field > span { font-size: 13px; color: var(--mute); }

textarea,
input[type="text"],
input[type="search"],
input[type="url"],
input[type="password"],
select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--input);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  color: var(--cream);
}
textarea {
  resize: vertical;
  min-height: 220px;
  padding: 8px 4px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-size: 18px;
  line-height: 1.7;
}
textarea:focus,
input:focus,
select:focus {
  border-color: var(--line-strong);
  box-shadow: none;
}
textarea:focus { border-bottom-color: var(--cream); }
select option { background: var(--surface); color: var(--cream); }

.meta-row, .toolbar, .picker-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: 10px 0 12px;
}
#preset-panel .toolbar {
  flex-direction: column;
  align-items: stretch;
}
#preset-panel .chips { margin-bottom: 4px; }
.meta-row, .picker-head span { font-size: 13px; color: var(--mute); }
#voice-search, #preset-search, #custom-search { max-width: 280px; background: var(--input); }

.picked {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.picked strong { display: block; font-size: 18px; font-weight: 650; }
.picked small { color: var(--mute); }
.picked.is-empty strong { font-size: 15px; font-weight: 500; color: var(--mute); }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--cream);
  font-size: 13px;
}
.picked:not(.is-empty) .avatar,
.voice-option.selected .avatar,
.voice-card.selected .avatar {
  background: var(--aura);
  border-color: transparent;
  color: #101012;
}

.primary, .ghost { border-radius: 999px; padding: 10px 16px; }
.primary {
  width: auto;
  margin-top: 8px;
  background: var(--cream);
  color: #101012;
  font-weight: 650;
}
.primary:hover { background: #fff; }
.primary:disabled { opacity: 0.55; cursor: wait; }
#synth-btn {
  width: 100%;
  margin-top: 14px;
  background: var(--aura);
  color: #101012;
}
#synth-btn:hover { filter: brightness(1.06); }
#synth-btn:disabled { filter: none; animation: none; }
.ghost {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--cream);
}
.ghost:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.08); }
.ghost:disabled { opacity: 0.4; cursor: not-allowed; }

.voice-picker {
  border-top: 1px solid var(--line);
  max-height: 280px;
  overflow: auto;
  background: transparent;
  margin-bottom: 4px;
}
.voice-option, .voice-card {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--cream);
}
.voice-option {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  border-radius: 10px;
}
.voice-option small,
.voice-card small,
.voice-card em,
.custom-item small { display: block; color: var(--mute); font-style: normal; }
.voice-option.selected,
.voice-card.selected { background: rgba(253, 66, 156, 0.12); }
.voice-option:hover,
.voice-card:hover { background: rgba(255, 255, 255, 0.04); }
.voice-option.selected:hover,
.voice-card.selected:hover { background: rgba(253, 66, 156, 0.16); }
.voice-option:disabled { opacity: 0.45; cursor: not-allowed; }
.group-label {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--faint);
  font-size: 12px;
  padding: 8px 8px 4px;
}

.voice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  border: 0;
}
.voice-card {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 84px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.voice-card strong { display: block; font-size: 16px; font-weight: 650; }

.tabs, .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tabs button, .chips button {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
  padding: 6px 12px;
  margin-right: 0;
  color: var(--mute);
}
.tabs button.active, .chips button.active {
  background: var(--cream);
  color: #101012;
  border-color: var(--cream);
  font-weight: 650;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span-2 { grid-column: span 2; }
.check { display: flex; gap: 8px; align-items: center; align-self: end; }
input[type="checkbox"] { accent-color: var(--pink); }
.clone-form {
  margin-bottom: 28px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.clone-form h2 { margin-bottom: 16px; }
.stack { display: flex; flex-direction: column; }
.custom-item, .record {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.item-row, .record-top, .who { display: flex; gap: 12px; align-items: center; }
.item-row, .record-top { justify-content: space-between; align-items: flex-start; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 0;
  font-size: 12px;
  background: transparent;
  color: var(--mute);
  vertical-align: 1px;
}
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--bad); }
audio { width: 100%; margin: 12px 0 6px; }
.text-link { color: var(--pink); font-weight: 650; }
.text-link:hover { text-decoration: underline; }
.script {
  margin-top: 12px;
  font-size: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--cream);
}
.empty { color: var(--mute); padding: 12px 0 20px; }
.take .empty { padding-top: 4px; max-width: 22em; }
.notice {
  margin-bottom: 18px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(245, 217, 7, 0.35);
  color: var(--warn);
  background: rgba(245, 217, 7, 0.08);
}
.notice.bad {
  color: #ffb4a8;
  border-color: rgba(248, 68, 27, 0.4);
  background: rgba(248, 68, 27, 0.1);
}
.hidden { display: none !important; }
.settings-form { max-width: 520px; display: flex; flex-direction: column; gap: 16px; }
.settings-form .primary { align-self: flex-start; }
.take {
  position: sticky;
  top: 32px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
}
#result-title { font-size: 22px; font-weight: 650; }
.hint { margin: 8px 0 16px; font-size: 13px; max-width: 46em; }

@media (prefers-reduced-motion: reduce) {
  #synth-btn:hover { filter: none; }
}

@media (max-width: 980px) {
  body { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    gap: 16px;
  }
  nav { flex-direction: row; flex-wrap: wrap; align-items: center; }
  nav button { border-bottom: 0; }
  nav button[data-nav="generate"] { margin-bottom: 0; }
  .sidebar-foot { margin-top: 0; }
  main { padding: 24px 16px 56px; }
  .split, .form-grid, .page-head { display: flex; flex-direction: column; align-items: stretch; }
  .span-2 { grid-column: auto; }
  .take { position: static; }
  h1 { font-size: 32px; }
  .item-row, .record-top { flex-direction: column; }
}
