/* Maya Dashboard — modern, neutral, dense-but-clean */
:root {
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --bg-inset: #f7f7f8;
  --border: #ececef;
  --border-strong: #d9d9de;
  --text: #0a0a0a;
  --text-2: #52525b;
  --text-3: #a1a1aa;
  --accent: #111111;
  --accent-fg: #ffffff;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warn: #d97706;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.04);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }
a { color: inherit; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--bg-inset); padding: 1px 6px; border-radius: 4px; }
.muted { color: var(--text-2); }
.muted.small { color: var(--text-3); font-size: 12.5px; }
.center { text-align: center; }
.danger { color: var(--danger); }
.danger-border { border-color: var(--danger) !important; color: var(--danger) !important; }
.full { width: 100%; }
.grow { flex: 1; }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.hint { color: var(--text-3); font-weight: 400; font-size: 12px; margin-left: 6px; }

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: -2px;
}
.spinner.dark { color: var(--text-2); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Centered screens */
.centered-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.card.no-pad { padding: 0; overflow: hidden; }
.card.narrow { max-width: 440px; width: 100%; padding: 32px; box-shadow: var(--shadow); }

/* Brand */
.brand-row { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-fg);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
}
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.sidebar-brand { padding: 4px 10px 0; margin-bottom: 28px; }
.auth-title { font-size: 22px; margin: 16px 0 6px; font-weight: 600; letter-spacing: -0.01em; }
.auth-mount { margin-top: 18px; display: flex; justify-content: center; }

/* App shell */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 10px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--bg-inset); color: var(--text); }
.nav-item.active { background: var(--accent); color: var(--accent-fg); }
.nav-item.active .badge { background: rgba(255,255,255,.15); color: #fff; }
.nav-icon { display: inline-flex; }
.badge {
  margin-left: auto;
  background: var(--bg-inset);
  color: var(--text-2);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 500;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.user-row { display: flex; align-items: center; gap: 10px; }
.user-meta { min-width: 0; flex: 1; }
.user-email { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--bg-inset);
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--border);
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.signout-icon {
  background: transparent;
  border: 0;
  padding: 6px;
  border-radius: 6px;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s;
}
.signout-icon:hover { background: var(--bg-inset); color: var(--danger); }
.signout-icon:disabled { opacity: .5; cursor: not-allowed; }

/* Main */
.main { padding: 28px 36px 60px; max-width: 1280px; width: 100%; }
.view { display: none; }
.view.active { display: block; }
.view-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.view-head h2 { font-size: 22px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.015em; }
.view-head p { margin: 0; font-size: 13.5px; }
.filters { display: flex; gap: 10px; min-width: 320px; }
.filters .input { flex: 2; }
.filters .select { flex: 1; }

/* Grid */
.grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1100px) {
  .grid.two { grid-template-columns: 1fr; }
}

/* Form */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(0,0,0,.08);
}
.textarea { resize: vertical; min-height: 110px; line-height: 1.55; }

/* Sample text chips */
.samples { margin-top: 10px; }
.samples-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}
.sample-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sample-chip {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color .12s, color .12s, background .12s;
}
.sample-chip:hover { border-color: var(--text-2); color: var(--text); background: #fff; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 34px;
  cursor: pointer;
}

/* Combobox */
.combo { position: relative; }
.combo-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  max-height: 300px;
  overflow-y: auto;
  box-shadow: var(--shadow);
  z-index: 50;
  padding: 4px;
}
.combo-item {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--mono);
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.combo-item:hover, .combo-item.active { background: var(--bg-inset); color: var(--text); }
.combo-empty { padding: 12px; text-align: center; color: var(--text-3); font-size: 13px; }
.selected-voice {
  margin-top: 8px;
  font-size: 13px;
  font-family: var(--mono);
  color: var(--text-2);
  padding: 8px 10px;
  background: var(--bg-inset);
  border-radius: 6px;
}
.selected-voice.set { color: var(--text); }
.selected-voice strong { color: var(--text); font-weight: 600; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s, color .12s, border-color .12s, opacity .12s, transform .05s;
  text-decoration: none;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { background: #000; }
.btn.secondary { background: var(--bg-elev); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover:not(:disabled) { background: var(--bg-inset); }
.btn.ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn.ghost:hover:not(:disabled) { background: var(--bg-inset); color: var(--text); }
.btn.google-btn {
  background: #fff;
  color: #1f1f1f;
  border-color: var(--border-strong);
  height: 44px;
  font-weight: 600;
  font-size: 14px;
  margin-top: 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.btn.google-btn:hover:not(:disabled) {
  background: #f8f9fb;
  border-color: #c0c0c5;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.btn.recording { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.recording:hover:not(:disabled) { background: #b91c1c; }
.rec-dot {
  width: 8px; height: 8px;
  background: currentColor;
  border-radius: 50%;
  display: inline-block;
}
.btn.recording .rec-dot { animation: pulse 1s infinite; background: #fff; }
@keyframes pulse { 50% { opacity: 0.4; } }

.link { background: none; border: 0; color: var(--text-2); text-decoration: underline; cursor: pointer; font-size: 12.5px; padding: 0; }
.link:hover { color: var(--text); }

/* Result panel */
.result-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.result-head h3 { font-size: 14px; font-weight: 600; margin: 0; letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-2); }
.empty-state {
  text-align: center;
  padding: 40px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
}
.empty-state.pad { padding: 60px 20px; }
.empty-icon { color: var(--text-3); margin-bottom: 8px; }
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 12px;
}
.alert.error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }

audio { width: 100%; margin-top: 8px; }

.meta-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  margin: 14px 0;
  padding: 12px;
  background: var(--bg-inset);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}
.meta-grid dt { color: var(--text-3); font-weight: 500; }
.meta-grid dd { margin: 0; color: var(--text); font-family: var(--mono); }

/* History */
.history { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.history-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  margin-bottom: 10px;
}
.history-list { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; }
.history-item {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  align-items: center;
}
.history-item:hover { background: var(--bg-inset); }
.history-item .h-voice { font-family: var(--mono); color: var(--text); }
.history-item .h-time { color: var(--text-3); font-size: 11.5px; }
.history-item .h-text { grid-column: 1 / -1; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Tabs */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 18px; gap: 0; }
.tab {
  flex: 1;
  padding: 10px 14px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.pane { display: none; }
.pane.active { display: block; }

/* ASR specific */
.record-row { display: flex; gap: 10px; align-items: center; }
.timer {
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-2);
  min-width: 56px;
  text-align: center;
  font-family: var(--mono);
}
.timer.live { color: var(--danger); }
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  background: var(--bg-inset);
  color: var(--text-2);
  transition: border-color .12s, background .12s;
}
.dropzone:hover { border-color: var(--text-2); background: #efefef; }
.dropzone.drag { border-color: var(--primary); background: #eff6ff; }
.dropzone-icon { color: var(--text-3); margin-bottom: 8px; }
.file-preview {
  padding: 10px 12px;
  background: var(--bg-inset);
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
}
.file-name { font-size: 13px; font-weight: 500; }
.transcript {
  background: var(--bg-inset);
  border-left: 3px solid var(--accent);
  padding: 14px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 360px;
  overflow-y: auto;
}

/* Voices view */
.voices-head { align-items: center; }
.voices-actions { display: flex; gap: 10px; align-items: center; }
.voices-actions .input { width: 240px; }
.lang-strip-wrap {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  margin: 0 -36px;
  padding: 0 36px;
  border-bottom: 1px solid var(--border);
}
.lang-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 12px;
}
.lang-strip::-webkit-scrollbar { height: 4px; }
.lang-strip::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }
.lang-pill {
  flex-shrink: 0;
  padding: 8px 14px;
  background: var(--bg-elev);
  color: var(--text-2);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background .12s, color .12s, border-color .12s;
}
.lang-pill:hover { background: var(--bg-inset); color: var(--text); }
.lang-pill.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.lang-pill .count {
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.lang-pill.active .count { color: rgba(255,255,255,.7); }

.voices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  padding: 18px 0 40px;
}
.voice-card {
  padding: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color .12s, background .12s;
}
.voice-card:hover { border-color: var(--border-strong); }
.voice-card.playing { border-color: var(--accent); background: var(--bg-inset); }
.voice-card .voice-info { flex: 1; min-width: 0; }
.voice-name {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.voice-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.play-btn {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  border: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, transform .05s;
}
.play-btn:hover:not(:disabled) { background: #000; }
.play-btn:active { transform: scale(.95); }
.play-btn:disabled { opacity: .5; cursor: not-allowed; }
.play-btn svg { display: block; }

/* Clerk overrides */
.cl-rootBox, .cl-card { box-shadow: none !important; border: 0 !important; background: transparent !important; }
.cl-internal-1da4ipv { border: 0 !important; }
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  /* Grid item escape hatch — prevent intrinsic min-content from
     expanding the column above viewport when descendants are wide. */
  .sidebar, .main, .view, .voices-head, .lang-strip-wrap, .lang-strip,
  .voices-grid, .voice-card, .voice-info { min-width: 0; }

  /* Sidebar collapses into a compact horizontal top bar */
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 50;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    height: auto;
    padding: 10px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elev);
  }
  .sidebar-brand { margin: 0; padding: 0; }
  .brand-name { font-size: 17px; }
  .nav {
    flex: 1;
    flex-direction: row;
    gap: 4px;
    overflow-x: auto;
    margin: 0;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item {
    width: auto;
    white-space: nowrap;
    padding: 7px 10px;
    font-size: 13px;
    flex-shrink: 0;
  }
  .nav-item .badge { display: none; }
  .nav-item .nav-icon svg { width: 16px; height: 16px; }
  .sidebar-footer {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }
  .user-row .user-meta { display: none; }
  .user-row { gap: 4px; }
  .user-avatar { width: 28px; height: 28px; }

  .main { padding: 18px 16px 60px; }

  /* Headers stack on small screens */
  .view-head, .voices-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .view-head h2 { font-size: 19px; }
  .view-head p { font-size: 13px; }
  .voices-actions { flex-direction: row; gap: 8px; width: 100%; }
  .voices-actions .input { flex: 1 1 auto; width: auto; min-width: 0; }
  .voices-actions .btn { flex: 0 0 auto; padding: 10px 14px; }

  /* Lang strip flush with screen edges */
  .lang-strip-wrap { margin: 0 -16px; padding: 0 16px; }

  /* Voice grid: hard-locked to 2 cols on phone */
  .voices-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 14px 0 30px;
  }
  .voice-card { padding: 10px; gap: 8px; min-width: 0; }
  .voice-name { font-size: 12px; }
  .play-btn { width: 32px; height: 32px; }

  /* Auth / loading cards: less padding on tiny screens */
  .card.narrow { padding: 24px 20px; }
  .auth-title { font-size: 19px; }

  /* TTS form: tighter spacing */
  .field { margin-bottom: 14px; }
  .textarea { min-height: 90px; }
  .sample-chip { font-size: 12px; padding: 5px 10px; }

  /* ASR record row: timer below */
  .record-row { flex-wrap: wrap; }

  /* Result + meta tighter */
  .meta-grid { font-size: 12px; }
}

/* Very small phones — squeeze further */
@media (max-width: 380px) {
  .sidebar { padding: 8px 12px; gap: 8px; }
  .brand-name { font-size: 16px; }
  .main { padding: 14px 12px 50px; }
  .lang-strip-wrap { margin: 0 -12px; padding: 0 12px; }
  .lang-pill { padding: 7px 11px; font-size: 12.5px; }
  .nav-item span:not(.nav-icon) { display: none; }
  .nav-item { padding: 8px; }
  .voices-grid { grid-template-columns: 1fr 1fr; }
  .card { padding: 16px; }
}
