@font-face { font-family: Inter; src: url("/assets/inter-400.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: Inter; src: url("/assets/inter-500.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: Inter; src: url("/assets/inter-600.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: Outfit; src: url("/assets/outfit-500.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: Outfit; src: url("/assets/outfit-700.ttf") format("truetype"); font-weight: 700; font-display: swap; }

*, *::before, *::after { box-sizing: border-box; }
:root {
  --bg-deep: #0f172a;
  --bg-elevated: #1e293b;
  --surface: rgba(30, 41, 59, 0.72);
  --surface-hover: rgba(51, 65, 85, 0.88);
  --stroke: rgba(148, 163, 184, 0.14);
  --stroke-strong: rgba(159, 134, 214, 0.42);
  --text: #e0f2fe;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-from: #9f86d6;
  --accent-to: #4ebfcf;
  --accent-mid: #bbb0ea;
  --btn-primary: #7549d4;
  --btn-primary-hover: #663cc4;
  --btn-primary-shadow: rgba(117, 73, 212, 0.4);
  --ok: #35b890;
  --danger: #ef6f85;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --brand-gradient: linear-gradient(135deg, var(--accent-from) 0%, var(--accent-to) 100%);
  --cta-gradient: linear-gradient(135deg, var(--btn-primary) 0%, var(--accent-to) 100%);
  --shadow-glow: 0 0 80px rgba(159, 134, 214, 0.17);
  --font-display: "Outfit", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
}

html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(187, 176, 234, 0.82) rgba(15, 23, 42, 0.28);
}
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.28);
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.08);
}
*::-webkit-scrollbar-thumb {
  border: 2px solid rgba(15, 23, 42, 0.38);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(187, 176, 234, 0.94), rgba(78, 191, 207, 0.86)),
    rgba(159, 134, 214, 0.78);
}
*::-webkit-scrollbar-thumb:hover {
  background:
    linear-gradient(180deg, rgba(224, 242, 254, 0.95), rgba(78, 191, 207, 0.98)),
    rgba(187, 176, 234, 0.95);
}

.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(159, 134, 214, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(78, 191, 207, 0.08), transparent),
    radial-gradient(ellipse 50% 35% at 0% 80%, rgba(159, 134, 214, 0.07), transparent);
}
.bg-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cg fill='none' stroke='%2394a3b8' stroke-opacity='0.06'%3E%3Cpath d='M0 24h48M24 0v48'/%3E%3C/g%3E%3C/svg%3E");
}

.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: max(clamp(20px, 4vw, 40px), env(safe-area-inset-top, 0px)) max(clamp(18px, 4vw, 36px), env(safe-area-inset-right, 0px)) 36px max(clamp(18px, 4vw, 36px), env(safe-area-inset-left, 0px));
}
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}
.logo-img {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  box-shadow: 0 0 32px rgba(159, 134, 214, 0.26);
}
.brand-text {
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: 0;
}
.header-nav {
  display: flex;
  align-items: center;
  gap: clamp(14px, 3vw, 28px);
  flex-wrap: wrap;
}
.header-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 160ms ease;
}
.header-nav a:hover { color: var(--text); }

.voice-app { display: grid; gap: 18px; }
.landing-app {
  min-height: min(640px, calc(100dvh - 140px));
  display: grid;
  align-content: center;
  gap: 24px;
}
.landing-head {
  display: grid;
  gap: 8px;
  max-width: 760px;
}
.engine-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.engine-card {
  min-height: 260px;
  display: grid;
  align-content: end;
  gap: 13px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  padding: clamp(22px, 4vw, 32px);
  color: var(--text);
  text-decoration: none;
  background:
    linear-gradient(180deg, rgba(30, 41, 59, 0.76), rgba(15, 23, 42, 0.68)),
    radial-gradient(circle at 10% 0%, rgba(159, 134, 214, 0.18), transparent 42%),
    radial-gradient(circle at 92% 92%, rgba(78, 191, 207, 0.14), transparent 38%);
  box-shadow: var(--shadow-glow);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.engine-card:hover {
  transform: translateY(-2px);
  border-color: rgba(78, 191, 207, 0.4);
  box-shadow: 0 0 90px rgba(78, 191, 207, 0.14), var(--shadow-glow);
}
.engine-card strong {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1;
}
.engine-card span:last-child {
  max-width: 42rem;
  color: var(--text-muted);
  font-weight: 500;
}
.engine-kicker {
  color: var(--accent-mid);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.app-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}
.hero-eyebrow {
  margin: 0 0 7px;
  color: var(--accent-mid);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
h1, h2 { font-family: var(--font-display); letter-spacing: 0; line-height: 1.1; margin: 0; }
h1 { font-size: clamp(1.9rem, 4vw, 3.2rem); }
h2 { font-size: 1rem; }
.status-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.status-strip span, .run-meta {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  color: var(--text-muted);
  background: rgba(15, 23, 42, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.run-meta:empty { display: none; }

.workspace {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  align-items: start;
  gap: 18px;
}
.voice-rail, .tool-panel, .player-panel {
  min-width: 0;
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.78), rgba(15, 23, 42, 0.62));
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-glow);
}
.voice-rail, .tool-panel { border-radius: var(--radius-lg); }
.voice-rail {
  height: var(--voice-rail-max-height, 520px);
  max-height: var(--voice-rail-max-height, 520px);
  min-height: 360px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  padding: 16px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.voice-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 6px 2px 0;
  margin-right: -6px;
}
.voice-item {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  align-content: center;
  text-align: left;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--text);
  background: rgba(15, 23, 42, 0.42);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.voice-item:hover {
  border-color: rgba(78, 191, 207, 0.34);
  background: rgba(30, 41, 59, 0.66);
  transform: translateY(-1px);
}
.voice-item.active {
  border-color: var(--stroke-strong);
  background: rgba(117, 73, 212, 0.18);
  box-shadow: 0 0 34px rgba(117, 73, 212, 0.16);
}
.voice-item.system-voice {
  border-style: dashed;
}
.voice-item strong {
  display: block;
  min-width: 0;
  font-size: 0.92rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.voice-item span {
  display: block;
  min-width: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-panel {
  position: relative;
  z-index: 40;
  overflow: visible;
}
.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin: 14px 14px 0;
  padding: 4px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(30, 41, 59, 0.46), rgba(15, 23, 42, 0.36)),
    radial-gradient(circle at 12% 0%, rgba(159, 134, 214, 0.12), transparent 40%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.tab {
  min-height: 52px;
  border: 0;
  border-radius: 23px;
  color: var(--text-muted);
  background: transparent;
  font: 600 0.92rem var(--font-body);
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}
.tab:hover { color: var(--text); background: rgba(159, 134, 214, 0.08); }
.tab.active {
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(159, 134, 214, 0.28), rgba(78, 191, 207, 0.1)),
    rgba(15, 23, 42, 0.34);
  box-shadow: inset 0 -1px 0 rgba(78, 191, 207, 0.28), 0 12px 28px rgba(78, 191, 207, 0.08);
}
.tab-pane { display: none; padding: 18px; gap: 14px; }
form.tab-pane.active, .tab-pane.active { display: grid; }
.field-grid, .control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.control-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.control-grid.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.control-grid.two-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.parameter-panel {
  display: grid;
  gap: 12px;
}
.control-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
}
.parameter-mode-toggle[aria-pressed="true"] {
  color: var(--text);
  border-color: rgba(78, 191, 207, 0.44);
  background: rgba(78, 191, 207, 0.12);
}
.developer-controls { display: none; }
.parameter-panel.developer-mode .friendly-controls { display: none; }
.parameter-panel.developer-mode .developer-controls { display: grid; }
.seg-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
}
#segToggle[aria-pressed="true"] {
  border-color: rgba(78, 191, 207, 0.45);
  color: var(--text);
  background: rgba(78, 191, 207, 0.16);
}
#ttsSingleBlock, #ttsSegmentsBlock { display: grid; gap: 14px; }
#ttsSingleBlock[hidden], #ttsSegmentsBlock[hidden] { display: none; }
.seg-hint { color: var(--text-muted); font-size: 0.8rem; }
#ttsSegments { display: grid; gap: 10px; }
.seg-row {
  --seg-control-height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}
.seg-row .seg-text,
.seg-row .seg-instruct { min-height: var(--seg-control-height); }
.seg-row .seg-text {
  height: var(--seg-control-height);
  overflow: hidden;
  resize: none;
}
.seg-row .seg-del {
  min-width: 40px;
  padding: 9px 12px;
  color: var(--text-muted);
}
.seg-row .seg-del:hover { color: var(--text); }
label { display: grid; gap: 7px; color: var(--text-muted); font-size: 0.82rem; font-weight: 600; }
label[hidden] { display: none; }
.sample-reference {
  display: grid;
  gap: 7px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
}
.sample-reference p {
  margin: 0;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  color: var(--text);
  background: rgba(15, 23, 42, 0.38);
  font: 500 0.94rem/1.65 var(--font-body);
  overflow-wrap: anywhere;
}
input, select, textarea {
  width: 100%;
  border: 1px solid rgba(159, 134, 214, 0.3);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.82), rgba(15, 23, 42, 0.66)),
    rgba(15, 23, 42, 0.72);
  outline: none;
  font: 500 0.94rem var(--font-body);
  color-scheme: dark;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
textarea { resize: vertical; min-height: 86px; }
input::placeholder, textarea::placeholder { color: rgba(148, 163, 184, 0.76); }
select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent-mid) 50%),
    linear-gradient(135deg, var(--accent-mid) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 38px;
}
select option,
select optgroup {
  color: var(--text);
  background: #0f172a;
}
select.native-select-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.custom-select {
  position: relative;
  width: 100%;
}
.custom-select-trigger {
  position: relative;
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  overflow: hidden;
  border: 1px solid rgba(159, 134, 214, 0.3);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.72), rgba(15, 23, 42, 0.58)),
    radial-gradient(circle at 12% 0%, rgba(159, 134, 214, 0.12), transparent 34%);
  outline: none;
  font: 600 0.94rem var(--font-body);
  text-align: left;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}
.custom-select-trigger::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: calc(var(--radius-sm) - 1px);
  pointer-events: none;
  background: linear-gradient(135deg, rgba(159, 134, 214, 0.1), transparent 36%, rgba(78, 191, 207, 0.06));
  opacity: 0;
  transition: opacity 160ms ease;
}
.custom-select-value {
  position: relative;
  z-index: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.custom-select-arrow {
  position: relative;
  z-index: 1;
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-right: 2px solid var(--accent-mid);
  border-bottom: 2px solid var(--accent-mid);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 160ms ease;
}
.custom-select.open .custom-select-trigger,
.custom-select-trigger:focus-visible {
  border-color: var(--stroke-strong);
  box-shadow: 0 0 0 3px rgba(159, 134, 214, 0.14), 0 0 28px rgba(78, 191, 207, 0.08);
}
.custom-select.open .custom-select-trigger::before,
.custom-select-trigger:hover::before {
  opacity: 1;
}
.custom-select.open .custom-select-arrow {
  transform: rotate(225deg) translate(-2px, -1px);
}
.custom-select-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  z-index: 120;
  max-height: 250px;
  overflow: auto;
  padding: 7px;
  border: 1px solid rgba(159, 134, 214, 0.34);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(23, 32, 52, 0.98), rgba(12, 18, 32, 0.98)),
    radial-gradient(circle at 12% 0%, rgba(159, 134, 214, 0.18), transparent 38%);
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.42), 0 0 42px rgba(78, 191, 207, 0.1);
  backdrop-filter: blur(18px);
  transform-origin: top;
  transform: translateY(-4px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}
.custom-select.open .custom-select-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.custom-select-option {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  border: 0;
  border-radius: 11px;
  padding: 9px 11px;
  color: var(--text-muted);
  background: transparent;
  font: 600 0.92rem var(--font-body);
  text-align: left;
  cursor: pointer;
}
.custom-select-option:hover,
.custom-select-option:focus-visible {
  color: var(--text);
  background: rgba(78, 191, 207, 0.1);
  transform: none;
}
.custom-select-option.selected {
  color: var(--text);
  background: linear-gradient(135deg, rgba(117, 73, 212, 0.42), rgba(78, 191, 207, 0.2));
  box-shadow: inset 0 0 0 1px rgba(159, 134, 214, 0.22);
}
input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
  padding-right: 40px;
  font-variant-numeric: tabular-nums;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
  display: none;
}
.number-stepper {
  position: relative;
  width: 100%;
}
.number-stepper input[type="number"] {
  padding-right: 44px;
}
.number-stepper-controls {
  position: absolute;
  top: 50%;
  right: 12px;
  width: 14px;
  height: 30px;
  display: grid;
  grid-template-rows: 1fr 1fr;
  transform: translateY(-50%);
  pointer-events: none;
}
.number-stepper-btn {
  width: 14px;
  height: 15px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  cursor: pointer;
  pointer-events: auto;
}
.number-stepper-btn::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  margin: auto;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  opacity: 0.62;
  transition: opacity 140ms ease, border-color 140ms ease;
}
.number-stepper-btn.up::before {
  border-bottom: 6px solid var(--text-muted);
}
.number-stepper-btn.down::before {
  border-top: 6px solid var(--text-muted);
}
.number-stepper-btn:hover::before,
.number-stepper-btn:focus-visible::before {
  opacity: 1;
}
.number-stepper-btn.up:hover::before,
.number-stepper-btn.up:focus-visible::before {
  border-bottom-color: var(--accent-mid);
}
.number-stepper-btn.down:hover::before,
.number-stepper-btn.down:focus-visible::before {
  border-top-color: var(--accent-mid);
}
input[type="file"] {
  padding: 8px 10px;
  cursor: pointer;
}
input[type="file"]::file-selector-button {
  min-height: 32px;
  margin-right: 12px;
  border: 1px solid rgba(159, 134, 214, 0.34);
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--text);
  background: linear-gradient(135deg, rgba(117, 73, 212, 0.82), rgba(78, 191, 207, 0.72));
  font: 700 0.82rem var(--font-body);
  cursor: pointer;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--stroke-strong);
  box-shadow: 0 0 0 3px rgba(159, 134, 214, 0.14), 0 0 28px rgba(78, 191, 207, 0.08);
}

.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
button, .download-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  padding: 9px 15px;
  font: 700 0.9rem var(--font-body);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}
.busy-button {
  gap: 9px;
}
.busy-button:disabled {
  opacity: 1;
  cursor: progress;
}
.busy-button::after {
  display: none;
}
.button-label,
.button-spinner {
  position: relative;
  z-index: 1;
}
.button-spinner {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  border: 2px solid rgba(255, 255, 255, 0.36);
  border-top-color: #ffffff;
  border-radius: 999px;
  animation: button-spin 760ms linear infinite;
  box-shadow: 0 0 14px rgba(78, 191, 207, 0.34);
}
.secondary-btn .button-spinner,
.ghost-btn .button-spinner {
  border-color: rgba(224, 242, 254, 0.26);
  border-top-color: var(--accent-to);
}
@keyframes button-spin {
  to { transform: rotate(360deg); }
}
.primary-btn {
  border: 0;
  color: white;
  background: var(--cta-gradient);
  box-shadow: 0 12px 32px var(--btn-primary-shadow);
}
.primary-btn::after, .secondary-btn::after, .ghost-btn::after, .download-link::after, .player-btn::after, .mobile-effect-toggle::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.18) 45%, transparent 70%);
  transform: translateX(-140%);
  transition: transform 520ms ease;
}
.primary-btn:hover, .secondary-btn:hover, .ghost-btn:hover, .download-link:hover, .player-btn:hover, .mobile-effect-toggle:hover {
  transform: translateY(-1px);
}
.primary-btn:hover {
  box-shadow: 0 16px 42px rgba(117, 73, 212, 0.48), 0 0 28px rgba(78, 191, 207, 0.18);
}
.primary-btn:hover::after, .secondary-btn:hover::after, .ghost-btn:hover::after, .download-link:hover::after, .player-btn:hover::after, .mobile-effect-toggle:hover::after {
  transform: translateX(140%);
}
.secondary-btn, .ghost-btn, .download-link, .mobile-effect-toggle {
  border: 1px solid var(--stroke);
  color: var(--text);
  background: rgba(15, 23, 42, 0.42);
}
.secondary-btn:hover, .ghost-btn:hover, .download-link:hover, .mobile-effect-toggle:hover {
  border-color: rgba(78, 191, 207, 0.38);
  background: rgba(30, 41, 59, 0.68);
}
.ghost-btn { min-height: 34px; padding: 6px 12px; color: var(--text-muted); }
button:disabled { opacity: 0.55; cursor: wait; }

.player-panel {
  position: relative;
  z-index: 10;
  border-radius: var(--radius-lg);
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(150px, 0.62fr) minmax(280px, 2fr) auto auto;
  align-items: center;
  gap: 16px;
}
.voice-player {
  min-width: 0;
  min-height: 64px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 999px;
  padding: 8px 12px 8px 9px;
  background:
    linear-gradient(180deg, rgba(30, 41, 59, 0.78), rgba(15, 23, 42, 0.82)),
    radial-gradient(circle at 10% 50%, rgba(159, 134, 214, 0.18), transparent 30%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 18px 54px rgba(0, 0, 0, 0.22);
}
.player-btn {
  width: 42px;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 999px;
  color: white;
  background: rgba(15, 23, 42, 0.62);
  padding: 0;
}
.play-btn {
  width: 46px;
  min-width: 46px;
  height: 46px;
  min-height: 46px;
  border: 0;
  background: linear-gradient(135deg, #7549d4, #4ebfcf);
  box-shadow: 0 0 34px rgba(78, 191, 207, 0.26), 0 10px 30px rgba(117, 73, 212, 0.32);
}
.play-icon {
  width: 0;
  height: 0;
  margin-left: 3px;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 12px solid currentColor;
}
.play-btn.playing .play-icon {
  width: 13px;
  height: 16px;
  margin-left: 0;
  border: 0;
  background: linear-gradient(90deg, currentColor 0 35%, transparent 35% 65%, currentColor 65% 100%);
}
.player-panel > .mobile-effect-toggle,
.player-panel > .download-link {
  width: 156px;
  min-height: 48px;
  padding: 9px 13px;
  flex: 0 0 156px;
  font-size: 0.9rem;
}
.mobile-effect-toggle {
  color: var(--text-muted);
  white-space: nowrap;
}
.mobile-effect-toggle.active,
.mobile-effect-toggle[aria-pressed="true"] {
  border-color: rgba(78, 191, 207, 0.55);
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(117, 73, 212, 0.28), rgba(78, 191, 207, 0.22)),
    rgba(15, 23, 42, 0.58);
  box-shadow: 0 0 28px rgba(78, 191, 207, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.timeline { min-width: 0; display: grid; gap: 6px; }
.time-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
}
.range-control {
  --progress: 0%;
  --progress-edge: max(0px, calc(var(--progress) - 11px));
  appearance: none;
  height: 8px;
  min-height: 8px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  background: linear-gradient(90deg, var(--accent-from) 0%, var(--accent-to) var(--progress-edge), rgba(148, 163, 184, 0.18) var(--progress-edge), rgba(148, 163, 184, 0.18) 100%);
  box-shadow: none;
  cursor: pointer;
}
.range-control::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 4px solid #172033;
  border-radius: 999px;
  background: #e0f2fe;
  box-shadow: 0 0 24px rgba(78, 191, 207, 0.38);
}
.range-control::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 4px solid #172033;
  border-radius: 999px;
  background: #e0f2fe;
  box-shadow: 0 0 24px rgba(78, 191, 207, 0.38);
}
audio { display: none; }
.download-link.disabled { pointer-events: none; opacity: 0.45; }

.library-pane { min-height: 360px; }
.library-pane.active {
  grid-template-rows: auto minmax(0, 1fr);
  max-height: min(72dvh, 640px);
}
.voice-table {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 6px;
  margin-right: -6px;
}
.voice-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-md);
  padding: 12px;
  background: rgba(15, 23, 42, 0.42);
}
.voice-row.locked {
  grid-template-columns: minmax(220px, 1fr) auto auto;
}
.voice-row strong { overflow-wrap: anywhere; }
.voice-row small { display: block; color: var(--text-muted); margin-top: 3px; }
.voice-title-static {
  display: block;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.voice-name-input {
  min-height: 42px;
  font-size: 0.9rem;
}
.voice-title-button {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text);
  background: transparent;
  font: 700 1rem var(--font-body);
  text-align: left;
  overflow-wrap: anywhere;
}
.voice-title-button:hover,
.voice-row.editing .voice-title-button {
  border-color: rgba(78, 191, 207, 0.28);
  background: rgba(15, 23, 42, 0.42);
}
.voice-row .voice-name-input {
  display: none;
  width: 100%;
}
.voice-row.editing .voice-title-button {
  display: none;
}
.voice-row.editing .voice-name-input {
  display: inline-flex;
}
.locked-badge {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--text-muted);
  background: rgba(15, 23, 42, 0.42);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.danger-btn {
  border: 1px solid rgba(239, 111, 133, 0.28);
  color: #ffd2da;
  background: rgba(127, 29, 45, 0.22);
}
.danger-btn:hover {
  border-color: rgba(239, 111, 133, 0.52);
  background: rgba(127, 29, 45, 0.36);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(20px);
  z-index: 20;
  max-width: min(680px, calc(100vw - 32px));
  padding: 11px 15px;
  border: 1px solid var(--stroke-strong);
  border-radius: 18px;
  color: var(--text);
  background: rgba(15, 23, 42, 0.88);
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  overflow-wrap: anywhere;
  text-align: center;
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error-text { text-align: left; }
.error-text { color: var(--danger); }

@media (max-width: 860px) {
  .shell {
    padding: max(16px, env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) 28px max(14px, env(safe-area-inset-left, 0px));
  }
  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
  }
  .header-nav {
    width: 100%;
    gap: 10px;
    font-size: 0.84rem;
  }
  .header-nav a {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--stroke);
    border-radius: 999px;
    padding: 6px 10px;
    background: rgba(15, 23, 42, 0.34);
  }
  .app-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }
  .landing-app {
    min-height: auto;
    align-content: start;
  }
  .engine-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .engine-card {
    min-height: 210px;
  }
  h1 {
    max-width: 100%;
    font-size: clamp(2.1rem, 12vw, 3.1rem);
    line-height: 1.02;
    overflow-wrap: anywhere;
  }
  .status-strip {
    width: 100%;
    justify-content: flex-start;
  }
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
  .voice-rail {
    height: min(var(--voice-rail-max-height, 420px), 42dvh);
    max-height: min(var(--voice-rail-max-height, 420px), 42dvh);
    min-height: 260px;
    padding: 14px;
  }
  .tool-panel {
    border-radius: 22px;
  }
  .tabs {
    margin: 10px 10px 0;
  }
  .tab-pane {
    padding: 14px;
  }
  .player-panel {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
  }
  .voice-player {
    border-radius: 24px;
    grid-template-columns: 44px minmax(0, 1fr);
  }
  .player-panel > .mobile-effect-toggle {
    width: 100%;
    min-width: 0;
    flex-basis: auto;
  }
  .player-panel > .download-link {
    width: 100%;
    flex-basis: auto;
  }
}
@media (max-width: 620px) {
  body {
    font-size: 14px;
  }
  .brand-text {
    font-size: 1rem;
  }
  .logo-img {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }
  .hero-eyebrow {
    font-size: 0.7rem;
  }
  h1 {
    font-size: clamp(2rem, 13vw, 2.7rem);
  }
  .tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-radius: 22px;
    gap: 3px;
    padding: 3px;
  }
  .tab {
    min-height: 46px;
    border-radius: 18px;
    font-size: 0.88rem;
  }
  .field-grid, .control-grid, .control-grid.compact, .control-grid.two-controls { grid-template-columns: 1fr; }
  .seg-row {
    --seg-control-height: 46px;
    grid-template-columns: 1fr;
  }
  .control-mode-bar {
    align-items: flex-start;
  }
  .actions {
    align-items: stretch;
  }
  .actions > button,
  .actions > .download-link {
    width: 100%;
  }
  .mobile-effect-toggle {
    min-height: 46px;
  }
  .voice-row {
    grid-template-columns: 1fr;
    padding: 14px;
  }
  .voice-row button,
  .voice-row .download-link {
    width: 100%;
  }
  .voice-list {
    padding: 2px 4px 2px 0;
    margin-right: -4px;
  }
  input:not([type="range"]), select, textarea,
  .custom-select-trigger {
    min-height: 46px;
  }
  .range-control {
    height: 8px;
    min-height: 8px;
  }
  textarea {
    min-height: 112px;
  }
  .toast {
    bottom: max(14px, env(safe-area-inset-bottom, 0px));
    border-radius: 18px;
  }
}
@media (max-width: 420px) {
  .shell {
    padding-left: max(10px, env(safe-area-inset-left, 0px));
    padding-right: max(10px, env(safe-area-inset-right, 0px));
  }
  .voice-rail,
  .tool-panel,
  .player-panel {
    border-radius: 20px;
  }
  .tabs {
    margin: 8px 8px 0;
  }
  .tab-pane {
    padding: 12px;
  }
  button, .download-link {
    min-height: 44px;
  }
}
