:root {
  --bg: #0a0c11;
  --bg-elevated: #10131a;
  --panel: #141822;
  --panel-head: #191d29;
  --border: #242a3a;
  --border-soft: #1b2029;
  --text: #eef0f6;
  --text-dim: #8b93a9;
  --text-faint: #565e72;
  --accent-a: #6366f1;
  --accent-b: #22d3ee;
  --accent-gradient: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  --accent-solid: #7c8cff;
  --ok: #34d399;
  --err: #f87171;
  --suggestion-accent: #a78bfa;
  --radius: 10px;
  --radius-lg: 18px;
  --font-display: 'Sora', -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-body: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

body { display: flex; flex-direction: column; }

.hidden { display: none !important; }

.app-loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 999;
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent-solid);
  animation: spin 0.7s linear infinite;
}

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

/* ---------- Brand mark ---------- */

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark .logo-icon { flex-shrink: 0; }

.brand-mark .brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.brand-mark.small .brand-name { font-size: 17px; }

/* ---------- Buttons ---------- */

.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 9px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  transition: filter 0.15s, background 0.15s, transform 0.1s;
}

.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(0.98); }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: none;
  transform: none;
}

.btn-primary {
  background: var(--accent-gradient);
  border: none;
  color: #06070a;
  font-weight: 700;
  box-shadow: 0 4px 20px -6px rgba(99, 102, 241, 0.55);
}

.btn-primary.recording {
  background: var(--err);
  box-shadow: 0 4px 20px -6px rgba(248, 113, 113, 0.5);
}

.btn-block { width: 100%; padding: 11px 16px; font-size: 15px; }

.btn-ghost {
  background: transparent;
}

/* ================== AUTH SCREEN ================== */

.auth-screen {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
}

.auth-bg {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(40% 35% at 20% 20%, rgba(99, 102, 241, 0.28), transparent 70%),
    radial-gradient(35% 30% at 85% 75%, rgba(34, 211, 238, 0.22), transparent 70%);
  filter: blur(40px);
  pointer-events: none;
}

.auth-card {
  position: relative;
  width: min(400px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.6);
}

.auth-card .brand-mark { justify-content: center; margin-bottom: 2px; }

.auth-tagline {
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
  margin: 0 0 10px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 3px;
  margin-bottom: 4px;
}

.auth-tab {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.auth-tab.active {
  background: var(--panel-head);
  color: var(--text);
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-field label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}

.auth-field input {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}

.auth-field input:focus {
  outline: none;
  border-color: var(--accent-solid);
}

.auth-link {
  color: var(--accent-solid);
  font-size: 12.5px;
  text-decoration: none;
  align-self: flex-end;
}

.auth-link:hover { text-decoration: underline; }

.oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.oauth-btn:hover {
  background: var(--panel-head);
  border-color: var(--accent-solid);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-faint);
  font-size: 11.5px;
  margin: 2px 0;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-password-wrap {
  position: relative;
  display: flex;
}

.auth-password-wrap input { flex: 1; padding-right: 60px; }

.auth-password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 8px;
}

.auth-password-toggle:hover { color: var(--text); }

.auth-error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: #ffb4b4;
  font-size: 13px;
  line-height: 1.4;
  padding: 9px 11px;
  border-radius: var(--radius);
}

.auth-footnote {
  color: var(--text-faint);
  font-size: 11.5px;
  line-height: 1.5;
  text-align: center;
  margin: 4px 0 0;
}

/* ================== APP SHELL ================== */

#appContent {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.mode-switch {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 3px;
}

.mode-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.mode-btn.active {
  background: var(--accent-gradient);
  color: #06070a;
}

.lang-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-select-label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}

.lang-select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.lang-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-dim);
  font-size: 13px;
  padding: 6px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: background 0.2s;
  flex-shrink: 0;
}

.dot.listening {
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  animation: pulse 1.4s infinite;
}

.dot.error {
  background: var(--err);
  box-shadow: 0 0 8px var(--err);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---------- User menu ---------- */

.user-menu { position: relative; }

.user-menu-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: #06070a;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}

.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 220px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.6);
  z-index: 20;
}

.user-menu-email {
  padding: 8px 10px 2px;
  font-size: 12px;
  color: var(--text-faint);
  word-break: break-all;
}

.user-menu-plan {
  padding: 0 10px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-solid);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.user-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  padding: 9px 10px;
  border-radius: 7px;
  cursor: pointer;
}

.user-menu-item:hover { background: var(--panel); }
.user-menu-item.danger { color: #ffb4b4; }
.user-menu-item.danger:hover { background: rgba(248, 113, 113, 0.1); }

.user-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 5px 4px;
}

.profile-badge {
  background: var(--err);
  color: #2a0505;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
}

/* ================== PANELS ================== */

.panels {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  overflow: hidden;
}

.panels .suggestion-panel-section { display: none; }
.panels.interview-mode { grid-template-columns: 1fr 1fr 1fr; }
.panels.interview-mode .suggestion-panel-section { display: flex; }

@media (max-width: 760px) {
  .panels, .panels.interview-mode { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-head {
  padding: 10px 16px;
  background: var(--panel-head);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-head-sub {
  font-weight: 400;
  color: var(--text-faint);
  text-transform: lowercase;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.line {
  animation: fadein 0.25s ease-out;
  line-height: 1.5;
  font-size: 15px;
}

.line .time {
  color: var(--text-faint);
  font-size: 11px;
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}

.line.new { color: var(--text); }

.line.partial {
  color: var(--text-dim);
  font-style: italic;
}

.line.partial::after {
  content: '▍';
  display: inline-block;
  margin-left: 2px;
  animation: pulse 1s infinite;
}

@keyframes fadein {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.placeholder {
  color: var(--text-faint);
  font-size: 14px;
  font-style: italic;
}

/* ---------- Suggestion cards ---------- */

.suggestion-card {
  animation: fadein 0.25s ease-out;
  background: var(--panel-head);
  border: 1px solid var(--border);
  border-left: 3px solid var(--suggestion-accent);
  border-radius: 8px;
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.suggestion-question {
  color: var(--text-dim);
  font-size: 12px;
  font-style: italic;
}

.suggestion-answer {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}

.suggestion-answer-vi {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.4;
}

/* ================== MISC ================== */

.error-banner {
  background: #2a1414;
  color: #ffb4b4;
  padding: 10px 20px;
  font-size: 13px;
  border-top: 1px solid #4a1f1f;
}

.footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 10px 20px;
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.footer-step b {
  color: var(--text);
  font-weight: 700;
  margin-right: 3px;
}

.footer-step-sep { color: var(--text-faint); }

.footer-tech {
  margin-left: auto;
  color: var(--text-faint);
}

/* ---------- Profile dialog ---------- */

.profile-dialog {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: min(560px, 90vw);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.6);
}

.profile-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.profile-dialog h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 18px;
}

.profile-hint {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 12px;
}

.profile-dialog textarea {
  width: 100%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
}

.profile-dialog textarea:focus {
  outline: none;
  border-color: var(--accent-solid);
}

.profile-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

/* ================== ADMIN ================== */

.admin-page {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}

.admin-main {
  flex: 1;
  padding: 24px 20px 60px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.admin-gate {
  text-align: center;
  padding: 60px 0;
}

.admin-search {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.admin-search input {
  flex: 1;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}

.admin-search input:focus {
  outline: none;
  border-color: var(--accent-solid);
}

.admin-user-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-user-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}

.admin-user-item:hover {
  border-color: var(--accent-solid);
}

.admin-user-item-email {
  font-size: 13.5px;
  font-weight: 600;
}

.admin-user-item-meta {
  font-size: 12px;
  color: var(--text-dim);
}

.admin-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.admin-section-head h2 {
  font-family: var(--font-display);
  font-size: 16px;
  margin: 0;
}

.admin-section-head-spaced {
  margin-top: 30px;
}

.admin-subhead {
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 18px 0 10px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.payment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.payment-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.payment-item-amount {
  font-size: 13.5px;
  font-weight: 600;
}

.payment-item-meta {
  font-size: 12px;
  color: var(--text-dim);
}

.payment-item-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.payment-item-badge.status-succeeded {
  background: rgba(52, 211, 153, 0.15);
  color: var(--ok);
}

.payment-item-badge.status-failed {
  background: rgba(248, 113, 113, 0.15);
  color: #ffb4b4;
}

.payment-item-badge.status-refunded {
  background: rgba(251, 191, 36, 0.15);
  color: #fcd34d;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.history-item-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}

.history-item-main:hover .history-item-date {
  color: var(--accent-solid);
}

.history-item-date {
  font-size: 13.5px;
  font-weight: 600;
}

.history-item-meta {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.history-item-tag {
  background: var(--panel-head);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
}

.history-back-btn {
  margin-bottom: 12px;
}

.history-detail-meta {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 14px;
}

.history-detail-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-entry {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.history-entry-original {
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}

.history-entry-translated {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.4;
  margin-top: 4px;
}

.history-entry.suggestion {
  border-left: 3px solid var(--suggestion-accent);
}

/* ================== PRICING SCREEN ================== */

.pricing-screen {
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.pricing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.pricing-body {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 24px 64px;
  text-align: center;
}

.pricing-body h1 {
  font-family: var(--font-display);
  font-size: 30px;
  margin: 0 0 10px;
}

.pricing-sub {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0 auto 36px;
  max-width: 480px;
}

.pricing-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  text-align: left;
}

@media (max-width: 760px) {
  .pricing-cards { grid-template-columns: 1fr; }
}

.pricing-card {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pricing-card.featured {
  border-color: var(--accent-a);
  box-shadow: 0 0 0 1px var(--accent-a), 0 20px 40px -16px rgba(99, 102, 241, 0.4);
}

.pricing-card-badge {
  position: absolute;
  top: -11px;
  left: 20px;
  background: var(--accent-gradient);
  color: #06070a;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
}

.pricing-card-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
}

.pricing-card-price {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
}

.pricing-card-price span {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim);
}

.pricing-features {
  list-style: none;
  padding: 0;
  margin: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-dim);
}

.pricing-features li::before {
  content: '✓ ';
  color: var(--ok);
  font-weight: 700;
}

