@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  --bg:        #0b0f1a;
  --nav:       #0d1221;
  --card:      #111827;
  --border:    #1e2940;
  --text:      #f8fafc;
  --muted:     #94a3b8;
  --primary:   #3b82f6;
  --primary-h: #60a5fa;
  --danger:    #f87171;
  --success:   #4ade80;
  --radius:    12px;
  --shadow:    0 4px 24px rgba(0,0,0,.5), 0 1px 4px rgba(0,0,0,.4);
}

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

/* ── Nav bar ──────────────────────────────────────────────────────────────── */

header {
  width: 100%;
  background: var(--nav);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-h);
  letter-spacing: -.01em;
}
header p { display: none; }

/* ── Main content area ────────────────────────────────────────────────────── */

.main-wrap {
  width: 100%;
  max-width: 760px;
  padding: 2.5rem 1.5rem;
  flex: 1;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  padding: 2rem;
}

/* ── Label & textarea ─────────────────────────────────────────────────────── */

label {
  display: block;
  font-weight: 500;
  font-size: .85rem;
  margin-bottom: .5rem;
  color: var(--muted);
  letter-spacing: .01em;
}

textarea {
  width: 100%;
  min-height: 240px;
  padding: .875rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: .95rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  resize: vertical;
  transition: border-color .15s;
  outline: none;
}
textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
textarea::placeholder { color: var(--muted); }

.char-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: .4rem;
  font-size: .8rem;
  color: var(--muted);
}
.char-row.warn { color: #fbbf24; }
.char-row.over { color: var(--danger); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .7rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-h));
  color: #fff;
  width: 100%;
  margin-top: 1.1rem;
  letter-spacing: .01em;
}
.btn-primary:hover:not(:disabled) { opacity: .9; transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: transparent;
  color: var(--primary-h);
  border: 1px solid var(--border);
  padding: .5rem 1.1rem;
  font-size: .875rem;
  font-weight: 500;
  width: 100%;
}
.btn-secondary:hover { background: rgba(255,255,255,.04); }

.btn-text {
  background: none;
  border: none;
  color: var(--primary-h);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0;
}
.btn-text:hover { text-decoration: underline; }

/* ── Login form ───────────────────────────────────────────────────────────── */

.card-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .35rem;
}
.card-subtitle {
  font-size: .9rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.field {
  margin-bottom: 1rem;
}
.field label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: .4rem;
  letter-spacing: .01em;
}
.field input {
  width: 100%;
  padding: .7rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: .95rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.field input::placeholder { color: #475569; }

/* ── User info bar ────────────────────────────────────────────────────────── */

#user-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--muted);
}

/* ── Status / spinner ─────────────────────────────────────────────────────── */

.status-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 600;
  font-size: .95rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Progress bar ─────────────────────────────────────────────────────────── */

.progress-track {
  background: var(--border);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
  margin-bottom: 0.4rem;
}
.progress-fill {
  background: linear-gradient(90deg, var(--primary), var(--primary-h));
  height: 100%;
  border-radius: 999px;
  width: 0%;
  transition: width 0.5s ease;
}
.progress-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: right;
}

/* ── Done / audio ─────────────────────────────────────────────────────────── */

.done-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 600;
  font-size: 1rem;
  color: var(--success);
  margin-bottom: 1.25rem;
}
.done-icon { font-size: 1.1rem; }

.audio-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ── Error ────────────────────────────────────────────────────────────────── */

.error-box {
  background: rgba(248, 113, 113, .08);
  border: 1px solid rgba(248, 113, 113, .3);
  border-radius: 8px;
  padding: .875rem 1rem;
  color: var(--danger);
  font-size: .875rem;
  line-height: 1.5;
  margin-bottom: .75rem;
}

/* ── Login section ────────────────────────────────────────────────────────── */

#login-section {
  text-align: center;
  padding: 1rem 0;
}
#login-section p {
  color: var(--muted);
  margin-bottom: 1.5rem;
  font-size: .9rem;
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin: -2rem -2rem 1.75rem;
  padding: 0 2rem;
}
.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 500;
  padding: .85rem 1.25rem;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--primary-h);
  border-bottom-color: var(--primary-h);
}

/* ── Voice tab ────────────────────────────────────────────────────────────── */

.voice-status-banner {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border-radius: 8px;
  font-size: .9rem;
  margin-bottom: 1.25rem;
}
.voice-active  { background: rgba(74,222,128,.08); border: 1px solid rgba(74,222,128,.25); color: var(--success); }
.voice-pending { background: rgba(59,130,246,.08); border: 1px solid rgba(59,130,246,.25); color: var(--primary-h); }

.btn-text.danger { color: var(--danger); }

.voice-prompt-label {
  font-size: .8rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: .01em;
  margin-bottom: .6rem;
}
.voice-prompt-text {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .9rem 1rem;
  font-size: .95rem;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 1.25rem;
  font-style: italic;
}

.recorder-controls {
  display: flex;
  gap: .75rem;
  align-items: center;
}
.recorder-controls .btn,
.recorder-controls .btn-mic,
#voice-upload-row .btn {
  flex-shrink: 0;
  width: auto;
}
#voice-upload-row {
  display: flex;
  gap: .75rem;
}
.btn-mic {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .6rem 1.25rem;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-mic:hover { opacity: .85; }
.btn-mic.recording {
  background: linear-gradient(135deg, #dc2626, #991b1b);
  animation: pulse-rec 1.2s ease-in-out infinite;
}
@keyframes pulse-rec {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.5); }
  50%       { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

.recording-indicator {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  color: var(--danger);
  margin-top: .75rem;
  font-weight: 500;
}
.rec-dot {
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  animation: blink-dot .9s step-start infinite;
}
@keyframes blink-dot { 50% { opacity: 0; } }

.voice-section-label {
  font-size: .8rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: .01em;
  margin-bottom: .75rem;
}

.voice-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
  margin-bottom: 1.25rem;
}

.voice-card {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .65rem .85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  user-select: none;
}
.voice-card:hover { border-color: var(--primary); }
.voice-card.selected {
  border-color: var(--primary);
  background: rgba(59,130,246,.07);
}

.voice-card-radio {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  transition: border-color .15s, background .15s;
  box-shadow: inset 0 0 0 3px var(--bg);
}
.voice-card.selected .voice-card-radio {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: inset 0 0 0 2px var(--bg);
}

.voice-card-info {
  flex: 1;
  min-width: 0;
}
.voice-card-name {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.voice-card-desc {
  display: block;
  font-size: .72rem;
  color: var(--muted);
  margin-top: .1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-preview {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--primary-h);
  border-radius: 6px;
  padding: .2rem .55rem;
  font-size: .75rem;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1.6;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-preview:hover { background: rgba(255,255,255,.05); }
.btn-preview.playing { color: var(--success); border-color: var(--success); }

.or-divider {
  text-align: center;
  color: var(--muted);
  font-size: .8rem;
  margin: 1rem 0 .75rem;
  position: relative;
}
.or-divider::before, .or-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 44%;
  height: 1px;
  background: var(--border);
}
.or-divider::before { left: 0; }
.or-divider::after  { right: 0; }

.file-upload-label {
  display: block;
  text-align: center;
  cursor: pointer;
  width: 100%;
}
.upload-hint {
  font-size: .75rem;
  color: var(--muted);
  text-align: center;
  margin-top: .4rem;
}

.auth-switch {
  text-align: center;
  font-size: .875rem;
  color: var(--muted);
  margin-top: 1rem;
}
.auth-switch a {
  color: var(--primary);
  text-decoration: none;
}
.auth-switch a:hover {
  text-decoration: underline;
}
