:root {
  --bg: #0b1424;
  --card: #141f2f;
  --card-dark: #101828;
  --accent: #1cc5b8;
  --accent-rgb: 28, 197, 184;
  --text: #f4f6fb;
  --muted: #91a3c6;
  --border: rgba(255, 255, 255, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 20% 20%, #1d2e47, transparent),
    radial-gradient(circle at 80% 0%, #0c1c31, transparent), var(--bg);
  color: var(--text);
}

.app-shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.25rem 1.6rem;
  border-radius: 1.5rem;
  border: 1px solid var(--border);
  background: rgba(17, 27, 43, 0.8);
  box-shadow: 0 30px 60px rgb(6 14 27 / 0.3);
}

.hero-icon {
  display: none;
}

.hero-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--accent);
  display: grid;
  place-items: center;
}

.hero-icon svg {
  width: 28px;
  height: 28px;
}

.hero h1 {
  font-size: clamp(1.5rem, 5vw, 2rem);
  margin: 0 0 0.15rem;
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.hero-brand img {
  width: 320px;
  max-width: 100%;
  height: auto;
  max-height: 160px;
  display: block;
  border-radius: 12px;
  margin: 0;
  padding: 0;
}

.card {
  background: var(--card);
  border-radius: 1.5rem;
  border: 1px solid var(--border);
  padding: 2rem;
  box-shadow: 0 20px 50px rgb(5 10 18 / 0.35);
}

.card + .card {
  margin-top: 2.5rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.field label {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
}

.field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.field-header label {
  margin: 0;
}

#char-remaining {
  color: var(--muted);
  font-size: 0.85rem;
}

#char-remaining.warning {
  color: #f0b429;
}

#char-remaining.limit {
  color: #f87171;
}

textarea {
  resize: vertical;
  font: inherit;
  color: var(--text);
  background: var(--card-dark);
  border: 1px solid transparent;
  border-radius: 1rem;
  padding: 1rem 1.2rem;
  min-height: 150px;
  outline: none;
  transition: border 0.2s, box-shadow 0.2s;
}

textarea:focus {
  border-color: rgba(var(--accent-rgb), 0.5);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.08);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.select-wrapper {
  position: relative;
}

.select-wrapper::after {
  content: "v";
  position: absolute;
  right: 1rem;
  top: 50%;
  translate: 0 -50%;
  color: var(--muted);
  pointer-events: none;
}

select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--card-dark);
  padding: 0.85rem 1.1rem;
  border-radius: 0.9rem;
  border: 1px solid transparent;
  appearance: none;
  outline: none;
}

select:focus {
  border-color: rgba(var(--accent-rgb), 0.6);
}

.pill-select select {
  border-radius: 1.5rem;
  border: 1px solid rgba(var(--accent-rgb), 0.15);
  padding-left: 1.2rem;
  padding-right: 2.4rem;
  transition: border 0.2s, box-shadow 0.2s;
}

.pill-select::after {
  right: 1.3rem;
}

.pill-select select:focus {
  border-color: rgba(var(--accent-rgb), 0.5);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}

.custom-dropdown {
  position: relative;
}

.custom-dropdown .dropdown-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.3rem;
  border-radius: 1.6rem;
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  background: var(--card-dark);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border 0.2s, box-shadow 0.2s;
}

.custom-dropdown .dropdown-trigger:focus-visible,
.custom-dropdown.open .dropdown-trigger {
  border-color: rgba(var(--accent-rgb), 0.6);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.16);
}

.custom-dropdown .dropdown-icon svg {
  width: 18px;
  height: 18px;
  transition: transform 0.2s;
}

.custom-dropdown.open .dropdown-icon svg {
  transform: rotate(180deg);
}

.dropdown-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  width: 100%;
  padding: 0.5rem;
  background: #0c1728;
  border-radius: 1.2rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 25px 45px rgba(3, 8, 20, 0.5);
  max-height: 220px;
  overflow-y: auto;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 10;
}

.custom-dropdown.open .dropdown-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.dropdown-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 0.6rem 0.8rem;
  border-radius: 0.9rem;
  cursor: pointer;
}

.dropdown-item:hover,
.dropdown-item.is-selected {
  background: rgba(var(--accent-rgb), 0.18);
  color: var(--text);
}

button {
  font: inherit;
  border: none;
  cursor: pointer;
}

#generate-btn {
  margin-top: 2rem;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding: 0.95rem 1.5rem;
  background: var(--accent);
  color: #04131f;
  font-weight: 600;
  border-radius: 0.9rem;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
}

#generate-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 20px 30px rgba(var(--accent-rgb), 0.25);
}

#generate-btn.loading .btn-text {
  opacity: 0.35;
}

.btn-icon svg {
  width: 22px;
  height: 22px;
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: currentColor;
  border-radius: 50%;
  display: none;
}

#generate-btn.loading .btn-spinner {
  display: inline-flex;
  animation: spin 0.9s linear infinite;
}

.error {
  margin-top: 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: 0.75rem;
  background: rgba(255, 86, 86, 0.12);
  border: 1px solid rgba(255, 86, 86, 0.35);
  color: #ff8a8a;
}

.audio-card {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.audio-card[data-ready="false"] {
  display: none;
}

.visualizer-shell {
  background: var(--card-dark);
  border-radius: 1.2rem;
  overflow: hidden;
  border: 1px solid var(--border);
  padding: 1rem;
}

canvas {
  width: 100%;
  height: 220px;
  display: block;
}

.timeline {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
}

.timeline input[type="range"] {
  flex: 1;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: -5px;
}

input[type="range"]::-moz-range-track {
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
}

.controls-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.pill {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--card-dark);
  color: var(--text);
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  font-size: 1.2rem;
  transition: border 0.2s, transform 0.2s;
}

.pill svg {
  width: 24px;
  height: 24px;
  display: block;
}

.pill:hover {
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

#play-btn [data-pause] {
  display: none;
}

#play-btn.playing [data-play] {
  display: none;
}

#play-btn.playing [data-pause] {
  display: inline;
}

.volume {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1rem;
  color: var(--muted);
}

.volume input[type="range"] {
  flex: 1;
}

.volume-button {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border 0.2s, background 0.2s;
}

.volume-button svg {
  width: 22px;
  height: 22px;
}

.volume-button:hover {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.05);
}

.volume-button .icon-volume-off {
  display: none;
}

.volume-button.muted .icon-volume-on {
  display: none;
}

.volume-button.muted .icon-volume-off {
  display: inline-flex;
}

.speed-row,
.options-row,
.vis-speed {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.options-row {
  flex-wrap: wrap;
}

.option-group > span {
  color: var(--muted);
  font-weight: 500;
}

.speed-row {
  flex-direction: column;
  align-items: stretch;
}

.speed-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
}

.speed-header span:last-child {
  color: var(--text);
  font-weight: 600;
}

#speed-slider {
  width: 100%;
}

.speed-buttons,
.chip-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.speed-buttons button,
.chip-group button {
  background: #0f1a2b;
  color: var(--muted);
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.9rem;
}

.speed-buttons button.active,
.chip-group button.active {
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--text);
  border-color: rgba(var(--accent-rgb), 0.3);
}

.color-group {
  display: flex;
  gap: 0.6rem;
}
.option-group--color {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 0.4rem;
}
.option-group--color .color-group {
  width: 100%;
  justify-content: flex-end;
}

.option-group--vis-speed {
  flex: 1 1 100%;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.option-group--vis-speed span {
  color: var(--muted);
  font-weight: 500;
}

.option-group--vis-speed .vis-speed {
  width: 100%;
}

.option-group--vis-speed input[type="range"] {
  width: 100%;
}
.color-group button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: currentColor;
  padding: 0;
}

.color-group button[data-color="#1cc5b8"] {
  color: #1cc5b8;
}

.color-group button[data-color="#a96bff"] {
  color: #a96bff;
}

.color-group button[data-color="#ff8b5e"] {
  color: #ff8b5e;
}

.color-group button[data-color="#f2d45c"] {
  color: #f2d45c;
}

.color-group button.active {
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 6px rgb(255 255 255 / 0.08);
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 1rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.footer-links a {
  color: var(--accent);
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}

.success {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 0.75rem;
  background: rgba(28, 197, 184, 0.12);
  border: 1px solid rgba(28, 197, 184, 0.35);
  color: var(--accent);
}

input[type="text"],
input[type="email"] {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--card-dark);
  border: 1px solid transparent;
  border-radius: 0.9rem;
  padding: 0.85rem 1rem;
  outline: none;
}

input[type="text"]:focus,
input[type="email"]:focus {
  border-color: rgba(var(--accent-rgb), 0.6);
}

.primary-btn {
  margin-top: 1.5rem;
  width: 100%;
  padding: 0.95rem 1.5rem;
  border-radius: 0.9rem;
  border: none;
  font-weight: 600;
  background: var(--accent);
  color: #04131f;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.primary-btn:hover:enabled {
  transform: translateY(-1px);
  box-shadow: 0 20px 30px rgba(var(--accent-rgb), 0.25);
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 560px) {
  .card {
    padding: 1.5rem;
  }

  .controls-row {
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
  }

  #play-btn {
    order: 1;
  }

  #download-btn {
    order: 2;
  }

  .volume {
    order: 3;
    width: 100%;
  }

  .speed-row,
  .options-row {
    flex-direction: column;
    align-items: flex-start;
  }

.vis-speed {
  width: 100%;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
}

.vis-speed label {
  color: var(--muted);
  font-weight: 500;
}

.vis-speed input[type="range"] {
  width: 100%;
}
}
