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

:root {
  --bg: #f5f5f7;
  --surface: #fff;
  --border: #e5e7eb;
  --text: #1a1a1a;
  --text2: #888;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --radius: 14px;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- HEADER ---- */
header {
  background: linear-gradient(135deg, #0a0a0a 0%, #171717 40%, #1a1a1a 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}
header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(255,255,255,.04) 0%, transparent 70%);
  border-radius: 50%;
}
header::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(255,255,255,.03) 0%, transparent 70%);
  border-radius: 50%;
}
.header-inner {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 32px 40px;
}
.header-text h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: 8px;
}
.header-text p {
  font-size: .9rem;
  color: rgba(255,255,255,.7);
  max-width: 500px;
  line-height: 1.6;
}
.header-tags {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.header-tags span {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .04em;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.6);
}
.header-wave {
  position: relative;
  z-index: 1;
  height: 32px;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  margin-top: -1px;
}

/* ---- SPEAKER CARDS ---- */
.speakers {
  padding: 32px 32px 0;
}
.speakers-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  max-width: 960px;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.06);
}
.card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

.card-img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--c);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  border: 3px solid var(--border);
}
.card.active .card-img {
  border-color: var(--accent);
}
.card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-img .fallback {
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: rgba(255,255,255,.7);
  width: 100%;
  height: 100%;
}
.card-img img[style*="display: none"] ~ .fallback,
.card-img:not(:has(img)) .fallback {
  display: flex;
}

.card-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
}

.card-body {
  flex: 1;
  min-width: 0;
}
.card-body h3 {
  font-size: .9rem;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-tag {
  font-size: .6rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

/* Sample button */
.btn-sample {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 12px;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: .72rem;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  transition: all .15s;
}
.btn-sample:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent);
  background: rgba(79,70,229,.05);
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* Bottom sheet */
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 12px 28px 32px;
  z-index: 100;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.32,.72,0,1);
  max-width: 540px;
  margin: 0 auto;
  box-shadow: 0 -4px 32px rgba(0,0,0,.12);
}
.bottom-sheet.open {
  transform: translateY(0);
}
.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
  cursor: pointer;
}
.sheet-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.sheet-header img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
}
.sheet-header h3 {
  font-size: 1rem;
  font-weight: 700;
}
.sheet-header p {
  font-size: .8rem;
  color: var(--text2);
}
.sheet-body .sample-label {
  font-size: .65rem;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
  display: block;
  margin-bottom: 8px;
}
.sheet-body audio {
  width: 100%;
  border-radius: 8px;
}
.sample-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.sample-num {
  font-size: .65rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.tag-g { background: #eef2ff; color: #6c5ce7; }
.tag-p { background: #e6fff8; color: #00b894; }

.card-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.card-stats span {
  font-size: .68rem;
  color: var(--text2);
  background: var(--bg);
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
}

/* ---- GENERATE BOX ---- */
.gen-section {
  padding: 24px 32px;
  flex: 1;
}
.gen-box {
  max-width: 960px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.gen-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.gen-speaker {
  font-weight: 700;
  font-size: .95rem;
}
.gen-type {
  font-size: .7rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 4px;
  background: #eef2ff;
  color: #6c5ce7;
}
.gen-type.phoneme {
  background: #e6fff8;
  color: #00b894;
}

textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  font-family: inherit;
  font-size: .9rem;
  resize: vertical;
  color: var(--text);
  transition: border-color .15s;
}
textarea:focus { outline: none; border-color: var(--accent); }

.gen-actions {
  margin-top: 12px;
}
.btn-gen {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-gen:hover { background: var(--accent-hover); }
.btn-gen.loading { opacity: .6; pointer-events: none; }

.result-area {
  margin-top: 16px;
  min-height: 0;
}
.result-area:empty { display: none; }
.result-placeholder {
  color: var(--text2);
  font-size: .85rem;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}
.audio-wrap { width: 100%; }
.audio-wrap audio { width: 100%; margin-top: 6px; }
.audio-wrap .meta {
  display: flex;
  justify-content: space-between;
  font-size: .75rem;
  color: var(--text2);
}
.audio-wrap a {
  color: var(--accent);
  font-size: .8rem;
  text-decoration: none;
  margin-top: 6px;
  display: inline-block;
}

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- FOOTER ---- */
footer {
  text-align: center;
  padding: 20px;
  font-size: .72rem;
  color: var(--text2);
  border-top: 1px solid var(--border);
}

/* ---- RESPONSIVE ---- */
@media (max-width: 700px) {
  .speakers-grid { grid-template-columns: 1fr; }
  .speakers, .gen-section { padding-left: 20px; padding-right: 20px; }
  .header-inner { padding: 36px 20px 32px; }
  .header-text h1 { font-size: 1.4rem; }
}
