:root {
  color-scheme: dark;
  --page: #07111b;
  --panel: rgba(13, 25, 38, 0.94);
  --panel-soft: rgba(20, 34, 50, 0.9);
  --line: rgba(131, 157, 185, 0.18);
  --line-strong: rgba(131, 157, 185, 0.34);
  --ink: #f2f7fb;
  --muted: #9caec2;
  --cyan: #66e6ff;
  --cyan-dark: #1a8aa0;
  --danger: #573242;
  --danger-border: rgba(255, 116, 151, 0.28);
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.35);
  font-family: Inter, "Noto Sans CJK SC", "Noto Sans SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(8, 26, 42, 0.92), rgba(9, 12, 28, 0.96)),
    radial-gradient(circle at 85% 12%, rgba(73, 88, 210, 0.22), transparent 34%),
    var(--page);
  color: var(--ink);
}

button,
select,
input {
  font: inherit;
}

button,
select {
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(49, 65, 84, 0.9), rgba(31, 43, 60, 0.92));
  color: var(--ink);
  padding: 0 20px;
}

button {
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

button:hover {
  border-color: rgba(102, 230, 255, 0.62);
  box-shadow: 0 10px 28px rgba(16, 216, 255, 0.14);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.54;
  transform: none;
}

button.danger,
.danger {
  border-color: var(--danger-border);
  background: linear-gradient(180deg, rgba(91, 54, 70, 0.94), rgba(59, 38, 51, 0.94));
}

audio {
  width: 100%;
  height: 38px;
  filter: invert(1) hue-rotate(180deg) saturate(0.7);
}

.demo-shell {
  display: grid;
  gap: 18px;
  width: min(1280px, calc(100vw - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 34px 0;
}

.hero-panel,
.prompt-panel,
.saved-panel,
.result-item {
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    linear-gradient(145deg, rgba(13, 25, 38, 0.96), rgba(12, 20, 35, 0.94)),
    var(--panel);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.hero-panel {
  position: relative;
  overflow: hidden;
  display: flex;
  min-height: 164px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 32px;
}

.hero-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0 18%, rgba(255, 255, 255, 0.025) 18% 18.2%, transparent 18.2% 36%, rgba(255, 255, 255, 0.022) 36% 36.2%, transparent 36.2%),
    radial-gradient(circle at 74% 40%, rgba(102, 230, 255, 0.12), transparent 22%);
}

.title-block,
.model-chip {
  position: relative;
  z-index: 1;
}

.title-block span,
.section-head span,
.saved-head span,
.preview-card > span,
.audio-cell > span,
.select-wrap span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.title-block h1 {
  margin: 12px 0 0;
  font-size: clamp(42px, 7vw, 82px);
  line-height: 0.94;
  letter-spacing: 0;
}

/* 英文标题更长，缩小字号保持与中文版相同的单行头部高度 */
html[lang="en"] .title-block h1 {
  font-size: clamp(32px, 4.4vw, 58px);
  white-space: nowrap;
}

.hero-tools {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  justify-items: end;
}

.tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.tool-row button {
  min-height: 38px;
  padding: 0 14px;
  font-size: 14px;
}

.tool-row .nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(49, 65, 84, 0.9), rgba(31, 43, 60, 0.92));
  color: var(--ink);
  padding: 0 14px;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.tool-row .nav-link:hover {
  border-color: rgba(102, 230, 255, 0.62);
  box-shadow: 0 10px 28px rgba(16, 216, 255, 0.14);
  transform: translateY(-1px);
}

#openGuide {
  width: 38px;
  padding: 0;
}

.model-chip {
  display: grid;
  gap: 6px;
  min-width: 210px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(7, 17, 27, 0.42);
  padding: 18px 20px;
}

.model-chip span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.model-chip strong {
  font-size: 24px;
}

.prompt-panel {
  display: grid;
  gap: 18px;
  padding: 26px;
}

.section-head,
.saved-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.section-head strong,
.saved-head strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.section-head p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  text-align: right;
}

.voice-stack {
  display: grid;
  gap: 16px;
}

.voice-block {
  display: grid;
  gap: 14px;
  border: 1px solid rgba(131, 157, 185, 0.16);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(26, 42, 60, 0.74), rgba(9, 18, 31, 0.72)),
    rgba(7, 17, 27, 0.5);
  padding: 18px;
}

.voice-block[data-role="prompt"] {
  border-color: rgba(102, 230, 255, 0.26);
  box-shadow: inset 3px 0 0 rgba(102, 230, 255, 0.72);
}

.voice-block[data-role="target"] {
  border-color: rgba(116, 241, 187, 0.22);
  box-shadow: inset 3px 0 0 rgba(116, 241, 187, 0.64);
}

.voice-controls {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) repeat(4, auto);
  gap: 12px;
  align-items: end;
}

.select-wrap {
  display: grid;
  gap: 9px;
}

.select-wrap select {
  width: 100%;
  border-radius: 8px;
  background: rgba(7, 17, 27, 0.64);
  padding: 0 14px;
}

.preview-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
  padding: 18px;
}

.preview-card small {
  color: var(--muted);
}

.generation-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
}

#startGenerate,
#refreshSaved {
  border-color: rgba(102, 230, 255, 0.62);
  background: linear-gradient(180deg, #79edff, #35cce7);
  color: #05131b;
  box-shadow: 0 0 34px rgba(53, 204, 231, 0.22);
}

.saved-panel {
  display: grid;
  gap: 18px;
  min-height: 460px;
  padding: 26px;
}

.saved-head {
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.saved-list {
  display: grid;
  gap: 14px;
}

.result-item {
  display: grid;
  gap: 14px;
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.result-item header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.result-name {
  display: block;
  overflow-wrap: anywhere;
  color: #d9e9f5;
  font-size: 17px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0;
}

.result-time {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.delete-result {
  min-height: 40px;
  padding: 0 18px;
}

.progress-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.progress-bar {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
}

.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #63eaff, #74f1bb);
  box-shadow: 0 0 18px rgba(99, 234, 255, 0.42);
}

.progress-label {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.output-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.audio-cell {
  display: grid;
  gap: 10px;
  min-width: 0;
  border: 1px solid rgba(131, 157, 185, 0.12);
  border-radius: 14px;
  background: rgba(7, 17, 27, 0.36);
  padding: 14px;
}

.feedback-box {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(131, 157, 185, 0.12);
  border-radius: 14px;
  background: rgba(7, 17, 27, 0.36);
  padding: 14px;
}

.feedback-box label {
  display: grid;
  gap: 8px;
}

.feedback-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.feedback-entry {
  border: 1px solid rgba(131, 157, 185, 0.16);
  border-radius: 10px;
  background: rgba(7, 17, 27, 0.5);
  padding: 10px 12px;
}

.feedback-entry header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.delete-feedback {
  border: 0;
  background: transparent;
  color: #ff9a9a;
  cursor: pointer;
  font: inherit;
  padding: 2px 0;
  white-space: nowrap;
}

.delete-feedback:hover {
  color: #ffd0d0;
}

.feedback-entry p {
  margin: 0;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.feedback-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.feedback-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.feedback-text {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(7, 17, 27, 0.64);
  color: var(--ink);
  padding: 10px 12px;
}

.save-feedback {
  justify-self: end;
}

.feedback-status {
  color: var(--muted);
}

dialog {
  width: min(460px, calc(100vw - 32px));
  border: 0;
  border-radius: 18px;
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.52);
}

.dialog-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #0f1d2b;
  color: var(--ink);
  padding: 20px;
  box-shadow: var(--shadow);
}

.dialog-card header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-card h3 {
  margin: 0;
}

.dialog-card label {
  display: grid;
  gap: 8px;
}

.dialog-card input {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(7, 17, 27, 0.64);
  color: var(--ink);
  padding: 0 12px;
}

#closeLogin,
#closeGuide {
  width: 36px;
  min-height: 36px;
  padding: 0;
}

.guide-card ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
  line-height: 1.55;
}

.logged-in-note {
  margin: 0;
  border: 1px solid rgba(102, 230, 255, 0.26);
  border-radius: 10px;
  background: rgba(7, 17, 27, 0.5);
  color: var(--muted);
  padding: 10px 12px;
  line-height: 1.5;
}

.login-status {
  min-height: 18px;
  color: var(--cyan);
  font-size: 13px;
}

.dialog-actions button[hidden] {
  display: none;
}

.empty-state {
  display: grid;
  min-height: 300px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

@media (max-width: 960px) {
  .demo-shell {
    width: min(100vw - 24px, 1280px);
    padding: 12px 0;
  }

  .hero-panel,
  .section-head,
  .saved-head,
  .preview-grid,
  .result-item header,
  .progress-wrap {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-panel,
  .section-head,
  .saved-head {
    display: grid;
  }

  .hero-tools {
    justify-items: stretch;
  }

  .tool-row {
    justify-content: stretch;
  }

  .tool-row button,
  .tool-row .nav-link {
    flex: 1 1 auto;
    justify-content: center;
  }

  .section-head p {
    max-width: none;
    text-align: left;
  }

  .voice-controls,
  .output-preview {
    grid-template-columns: 1fr;
  }

  .voice-controls button,
  .generation-actions button,
  .saved-head button,
  .save-feedback {
    width: 100%;
  }

  .generation-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
