/*
 * WellSaid Design System
 * Refined technological minimalism — audio meets AI.
 */

/* ── Design Tokens ─────────────────────────────────────────────────────────── */

:root {
  /* Palette */
  --color-bg:           #fafbfc;
  --color-surface:      #ffffff;
  --color-surface-alt:  #f4f5f7;
  --color-border:       #e4e7ec;
  --color-border-light: #eff1f4;
  --color-text:         #1a1d23;
  --color-text-secondary: #5f6b7a;
  --color-text-muted:   #8b95a5;

  /* Brand */
  --color-primary:       #4f46e5;
  --color-primary-hover: #4338ca;
  --color-primary-light: #eef2ff;
  --color-primary-ghost: #f5f6ff;

  /* Accent — warm amber for voice/warmth cues */
  --color-accent:        #f59e0b;
  --color-accent-hover:  #d97706;
  --color-accent-light:  #fffbeb;

  /* Semantic */
  --color-success:       #10b981;
  --color-success-light: #ecfdf5;
  --color-error:         #ef4444;
  --color-error-light:   #fef2f2;
  --color-warning:       #f59e0b;
  --color-warning-light: #fffbeb;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", Menlo, Courier, monospace;

  --text-xs:   0.75rem;
  --text-sm:   0.8125rem;
  --text-base: 0.9375rem;
  --text-lg:   1.125rem;
  --text-xl:   1.375rem;
  --text-2xl:  1.75rem;
  --text-3xl:  2.25rem;
  --text-4xl:  3rem;

  --leading-tight:  1.15;
  --leading-normal: 1.5;
  --leading-relaxed: 1.7;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Spacing scale */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Radii */
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 2px 0 rgb(0 0 0 / 0.04);
  --shadow-md:  0 4px 12px -2px rgb(0 0 0 / 0.06), 0 2px 4px -2px rgb(0 0 0 / 0.03);
  --shadow-lg:  0 12px 32px -8px rgb(0 0 0 / 0.08), 0 4px 8px -4px rgb(0 0 0 / 0.03);
  --shadow-xl:  0 20px 48px -12px rgb(0 0 0 / 0.12), 0 8px 16px -8px rgb(0 0 0 / 0.04);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;

  /* Layout */
  --page-max-width: 1200px;
  --nav-height: 64px;
}

/* ── Reset & Base ──────────────────────────────────────────────────────────── */

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}
a:hover { color: var(--color-primary-hover); }

img, svg {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ── Typography ───────────────────────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  color: var(--color-text);
}

.text-muted  { color: var(--color-text-muted); }
.text-small  { font-size: var(--text-sm); }
.text-center { text-align: center; }
.text-right  { text-align: right; }

/* ── Container ─────────────────────────────────────────────────────────────── */

.container {
  width: 100%;
  max-width: var(--page-max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.container--narrow {
  max-width: 760px;
}

/* ── Navigation ────────────────────────────────────────────────────────────── */

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: rgb(255 255 255 / 0.82);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: var(--page-max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.nav__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-weight: var(--weight-bold);
  font-size: var(--text-lg);
  color: var(--color-text);
  letter-spacing: -0.02em;
}
.nav__brand:hover { color: var(--color-text); }

.nav__brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--color-primary), #818cf8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.85rem;
}

.nav__links {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.nav__link {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  transition: color var(--duration-fast), background var(--duration-fast);
}
.nav__link:hover {
  color: var(--color-text);
  background: var(--color-surface-alt);
}

.nav__link--primary {
  color: #fff;
  background: var(--color-primary);
  border-radius: var(--radius-full);
}
.nav__link--primary:hover {
  color: #fff;
  background: var(--color-primary-hover);
}

.nav__user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}

/* ── Horizontal Menu Tabs ──────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-border-light);
  background: var(--color-surface);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  overflow: hidden;
}

.tab-btn {
  padding: var(--space-4) var(--space-6);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  transition: all var(--duration-fast);
  position: relative;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--color-text);
  background: var(--color-surface-alt);
}

.tab-btn.active {
  color: var(--color-primary);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: var(--space-4);
  right: var(--space-4);
  height: 2px;
  background: var(--color-primary);
  border-radius: 2px;
}

/* Tab panel */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Tab panel body container */
.tab-panel-body {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding: var(--space-6);
  min-height: 400px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.65rem 1.5rem;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  border: 2px solid transparent;
  border-radius: var(--radius-full);
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
  line-height: 1.4;
  cursor: pointer;
  user-select: none;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* Variants */
.btn--primary {
  color: #fff;
  background: var(--color-primary);
  border-color: var(--color-primary);
}
.btn--primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn--accent {
  color: #fff;
  background: var(--color-accent);
  border-color: var(--color-accent);
}
.btn--accent:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

.btn--outline {
  color: var(--color-text);
  background: transparent;
  border-color: var(--color-border);
}
.btn--outline:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-text-muted);
}

.btn--ghost {
  color: var(--color-text-secondary);
  background: transparent;
}
.btn--ghost:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
}

.btn--danger {
  color: var(--color-error);
  background: transparent;
  border-color: transparent;
}
.btn--danger:hover {
  background: var(--color-error-light);
}

/* Sizes */
.btn--lg {
  padding: 0.85rem 2rem;
  font-size: var(--text-base);
}

.btn--sm {
  padding: 0.4rem 1rem;
  font-size: var(--text-xs);
}

.btn--block {
  width: 100%;
}

.btn--icon {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: var(--radius-full);
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-normal) var(--ease-out);
  overflow: hidden;
}

.card--hover:hover {
  box-shadow: var(--shadow-md);
}

.card--interactive {
  cursor: pointer;
}
.card--interactive:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  transition: all var(--duration-normal) var(--ease-out);
}

.card__body {
  padding: var(--space-6);
}

.card__header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--color-border-light);
}

.card__footer {
  padding: var(--space-6);
  border-top: 1px solid var(--color-border-light);
  background: var(--color-surface-alt);
}

/* ── Forms ─────────────────────────────────────────────────────────────────── */

.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.form-input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-surface-alt);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast), background var(--duration-fast);
  outline: none;
}
.form-input::placeholder { color: var(--color-text-muted); }
.form-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgb(79 70 229 / 0.12);
  background: var(--color-surface);
}
.form-input.error {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px rgb(239 68 68 / 0.1);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-error);
  margin-top: var(--space-1);
  display: none;
}
.form-error.visible { display: block; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin-top: var(--space-4); }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th {
  text-align: left; padding: var(--space-3) var(--space-4);
  font-weight: var(--weight-semibold); color: var(--color-text-muted);
  font-size: var(--text-xs); text-transform: uppercase;
  letter-spacing: 0.05em; border-bottom: 2px solid var(--color-border-light); white-space: nowrap;
}
td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border-light); white-space: nowrap; }
tr:hover td { background: var(--color-surface-alt); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-full);
  font-size: 11px; font-weight: var(--weight-semibold);
}
.badge--active   { background: var(--color-success-light); color: #065f46; }
.badge--disabled { background: var(--color-error-light); color: var(--color-error); }
.badge--paid     { background: var(--color-success-light); color: #065f46; }
.badge--pending  { background: var(--color-warning-light); color: #92400e; }
.badge--failed   { background: var(--color-error-light); color: var(--color-error); }
.badge--expired  { background: #f3f4f6; color: #6b7280; }
.badge--admin    { background: var(--color-primary-light); color: var(--color-primary); }
.badge--signup   { background: #f0fdf4; color: #065f46; }

/* ── Pagination ──────────────────────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: var(--space-2); margin-top: var(--space-6);
}
.pagination button {
  padding: var(--space-2) var(--space-3); font-size: var(--text-xs);
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  background: var(--color-surface); cursor: pointer;
}
.pagination button:disabled { opacity: 0.4; cursor: default; }
.pagination button.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ── Toolbar ──────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: var(--space-4);
  flex-wrap: wrap; margin-bottom: var(--space-6);
}
.toolbar .form-input { max-width: 300px; }


/* ── Messages ──────────────────────────────────────────────────────────────── */

.message {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: 1.5;
  display: none;
  margin-top: var(--space-4);
}

.message--error {
  display: block;
  background: var(--color-error-light);
  color: var(--color-error);
  border: 1px solid rgb(239 68 68 / 0.2);
}

.message--success {
  display: block;
  background: var(--color-success-light);
  color: #065f46;
  border: 1px solid rgb(16 185 129 / 0.2);
}

.message--info {
  display: block;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid rgb(79 70 229 / 0.15);
}

/* ── Grid System ───────────────────────────────────────────────────────────── */

.grid {
  display: grid;
  gap: var(--space-6);
}

.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--auto-fill { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ── Flex Helpers ──────────────────────────────────────────────────────────── */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* ── Spacing Utilities ─────────────────────────────────────────────────────── */

.mt-2  { margin-top: var(--space-2); }
.mt-4  { margin-top: var(--space-4); }
.mt-6  { margin-top: var(--space-6); }
.mt-8  { margin-top: var(--space-8); }
.mt-10 { margin-top: var(--space-10); }
.mt-12 { margin-top: var(--space-12); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-6  { margin-bottom: var(--space-6); }
.mb-8  { margin-bottom: var(--space-8); }
.p-4  { padding: var(--space-4); }
.p-6  { padding: var(--space-6); }
.p-8  { padding: var(--space-8); }

/* ── Hero Section ──────────────────────────────────────────────────────────── */

.hero {
  padding: var(--space-20) 0 var(--space-16);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 900px;
  background: radial-gradient(circle at 50% 0%, rgb(79 70 229 / 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.hero__title {
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: var(--color-text);
  margin-bottom: var(--space-6);
  position: relative;
}

.hero__title .accent {
  background: linear-gradient(135deg, var(--color-primary), #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero__subtitle {
  font-size: var(--text-xl);
  color: var(--color-text-secondary);
  max-width: 600px;
  margin: 0 auto var(--space-8);
  line-height: var(--leading-relaxed);
}

.hero__actions {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Section ───────────────────────────────────────────────────────────────── */

.section {
  padding: var(--space-20) 0;
}

.section__header {
  text-align: center;
  margin-bottom: var(--space-12);
}

.section__title {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  margin-bottom: var(--space-4);
}

.section__subtitle {
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  max-width: 560px;
  margin: 0 auto;
}

/* ── Footer ────────────────────────────────────────────────────────────────── */

.footer {
  border-top: 1px solid var(--color-border-light);
  padding: var(--space-12) 0 var(--space-8);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.footer__inner {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-8);
  align-items: flex-start;
}

.footer__brand {
  max-width: 260px;
}

.footer__links {
  display: flex;
  gap: var(--space-8);
  flex-wrap: wrap;
  justify-content: space-evenly;
}

.footer__col h4 {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.footer__col a {
  display: block;
  padding: var(--space-1) 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.footer__col a:hover { color: var(--color-text); }

.footer__bottom {
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border-light);
  text-align: center;
  font-size: var(--text-xs);
}

/* ── Features Grid ─────────────────────────────────────────────────────────── */

.feature-card {
  padding: var(--space-6);
  text-align: left;
}

.feature-card__icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
  font-size: 1.3rem;
}

.feature-card__icon--primary {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.feature-card__icon--accent {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.feature-card__icon--success {
  background: var(--color-success-light);
  color: var(--color-success);
}

.feature-card__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-2);
}

.feature-card__desc {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
}

/* ── Stat Badge ────────────────────────────────────────────────────────────── */

.stat {
  text-align: center;
  padding: var(--space-6);
}

.stat__value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  color: var(--color-primary);
}

.stat__label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
}

/* ── App Launch Overlay ────────────────────────────────────────────────────── */

.app-launch-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: overlayFadeIn var(--duration-slow) var(--ease-out);
}

.app-launch-dialog {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-10);
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-xl);
  animation: dialogScaleIn var(--duration-slow) var(--ease-out);
}

.app-launch-dialog__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-6);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--color-primary), #818cf8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: #fff;
}

.app-launch-dialog__title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-3);
}

.app-launch-dialog__desc {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
  line-height: var(--leading-relaxed);
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes dialogScaleIn {
  from { opacity: 0; transform: scale(0.92) translateY(16px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Staggered Reveal ──────────────────────────────────────────────────────── */

.reveal {
  opacity: 0;
  transform: translateY(20px);
  animation: revealUp 0.6s var(--ease-out) forwards;
}

.reveal--1 { animation-delay: 0.05s; }
.reveal--2 { animation-delay: 0.12s; }
.reveal--3 { animation-delay: 0.19s; }
.reveal--4 { animation-delay: 0.26s; }
.reveal--5 { animation-delay: 0.33s; }
.reveal--6 { animation-delay: 0.40s; }

@keyframes revealUp {
  to { opacity: 1; transform: translateY(0); }
}

/* ── Auth Pages (Centered Card Layout) ─────────────────────────────────────── */

.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 20% 50%, rgb(79 70 229 / 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgb(245 158 11 / 0.04) 0%, transparent 50%),
    var(--color-bg);
}

.auth-page__main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.auth-card {
  width: 100%;
  max-width: 440px;
}

.auth-card__header {
  text-align: center;
  padding: var(--space-8) var(--space-8) 0;
}

.auth-card__body {
  padding: var(--space-8);
}

.auth-card__logo {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-4);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-primary), #818cf8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
  font-weight: var(--weight-bold);
}

.auth-card__title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-2);
}

.auth-card__desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.auth-card__footer {
  text-align: center;
  padding: 0 var(--space-8) var(--space-8);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.auth-card__footer a {
  font-weight: var(--weight-medium);
}

/* ── Download Page ─────────────────────────────────────────────────────────── */

.download-hero {
  text-align: center;
  padding: var(--space-16) 0 var(--space-10);
}

.platform-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-6);
}

.platform-card {
  text-align: center;
  padding: var(--space-8);
  overflow: visible; /* allow dropdown menu to render outside card bounds */
}

.platform-card__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--space-5);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}

.platform-card__icon--mac    { background: #f0f0f5; color: #1a1a2e; }
.platform-card__icon--win    { background: #e8f4fd; color: #0078d4; }
.platform-card__icon--linux  { background: #fef4e8; color: #e95420; }

.platform-card__name {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-2);
}

.platform-card__version {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-5);
}

.platform-card__meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-4);
}

/* Highlighted card for user's detected platform */
.platform-card--highlight {
  border: 2px solid var(--color-primary);
  box-shadow: 0 0 0 3px rgb(79 70 229 / 0.15);
  position: relative;
}

.platform-card__badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: var(--weight-medium);
  background: var(--color-primary);
  color: #fff;
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-full, 999px);
  vertical-align: middle;
  margin-left: var(--space-2);
}

/* ── Download Split Button (macOS arch selection) ───────────────────────────── */

.download-split {
  position: relative;
  display: flex;
  width: 100%;
}

.download-split__main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: 1px solid rgb(255 255 255 / 0.2);
  /* override btn--block so the split layout works */
  width: auto;
}

/* Fix border-right for outline variant */
.btn--outline.download-split__main {
  border-right: 1px solid var(--color-border);
}

.download-split__toggle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-3);
  border-radius: var(--radius-full);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  cursor: pointer;
  transition: background var(--duration-fast);
  /* Inherit visual style from adjacent main button */
}

.download-split__toggle--primary {
  background: var(--color-primary);
  color: #fff;
  border: 1px solid var(--color-primary);
}

.download-split__toggle--primary:hover {
  background: var(--color-primary-dark, #4338ca);
}

.download-split__toggle--outline {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  border-left: 1px solid var(--color-primary);
}

.download-split__toggle--outline:hover {
  background: var(--color-primary);
  color: #fff;
}

.download-split__chevron {
  transition: transform var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}

.download-split__arch-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: var(--weight-medium);
  background: rgb(255 255 255 / 0.25);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full, 999px);
  line-height: 1.4;
}

/* Badge color for outline variant */
.btn--outline .download-split__arch-badge {
  background: var(--color-primary);
  color: #fff;
}

.download-split__menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: none;
  overflow: hidden;
}

.download-split__menu--open {
  display: block;
  animation: dropdownFadeIn 0.15s var(--ease-out);
}

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

.download-split__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: none;
  background: none;
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--color-text);
  text-align: left;
  transition: background var(--duration-fast);
}

.download-split__item:hover {
  background: var(--color-surface-alt);
}

.download-split__item + .download-split__item {
  border-top: 1px solid var(--color-border-light);
}

.download-split__item--recommended {
  background: rgb(79 70 229 / 0.04);
}

.download-split__item-size {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.download-split__item-tag {
  font-size: 0.65rem;
  font-weight: var(--weight-medium);
  background: var(--color-primary);
  color: #fff;
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-full, 999px);
}

/* ── Auth Required Modal ─────────────────────────────────────────────────────── */

.auth-required-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: overlayFadeIn var(--duration-slow) var(--ease-out);
}

.auth-required-dialog {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-10);
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: var(--shadow-xl);
  animation: dialogScaleIn var(--duration-slow) var(--ease-out);
  position: relative;
}

@keyframes dialogScaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

.auth-required-dialog__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--space-5);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), #818cf8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.auth-required-dialog__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-3);
}

.auth-required-dialog__desc {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
  line-height: var(--leading-relaxed);
}

.auth-required-dialog__actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
}

.auth-required-dialog__close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 1.3rem;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.auth-required-dialog__close:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
}

/* ── Download loading & error states ─────────────────────────────────────────── */

.download-loading .spinner {
  display: block;
}

/* ── Installation Steps ────────────────────────────────────────────────────── */

.steps {
  counter-reset: step;
  list-style: none;
}

.step {
  display: flex;
  gap: var(--space-5);
  padding: var(--space-5) 0;
  counter-increment: step;
}

.step__number {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
}

.step__content h4 {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-1);
}

.step__content p {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

/* ── User Center ───────────────────────────────────────────────────────────── */

.user-header {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-8);
  margin-bottom: var(--space-8);
}

.user-avatar {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary), #818cf8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.8rem;
  font-weight: var(--weight-bold);
  flex-shrink: 0;
}

.user-meta h2 {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-1);
}

.user-meta p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
}

.balance-display {
  padding: var(--space-6);
  text-align: center;
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary-ghost));
  border: 1px solid rgb(79 70 229 / 0.12);
}

.balance-display__value {
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  color: var(--color-primary);
  letter-spacing: -0.03em;
}

.balance-display__label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-2);
}

/* ── Usage Bar Chart ─────────────────────────────────────────────────────── */

.chart-card {
  overflow: visible;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-5);
}

.chart-header__title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
}

.chart-header__subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.chart-body {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 160px;
  padding: 0 var(--space-1);
  position: relative;
}

/* Horizontal grid lines */
.chart-body::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      to top,
      transparent,
      transparent calc(25% - 1px),
      var(--color-border-light) calc(25% - 1px),
      var(--color-border-light) 25%
    );
  pointer-events: none;
}

.chart-bar-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.chart-bar-value {
  font-size: 9px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
  min-height: 12px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
}

.chart-bar-wrapper:hover .chart-bar-value {
  opacity: 1;
}

.chart-bar {
  width: 100%;
  max-width: 32px;
  min-height: 2px;
  background: linear-gradient(to top, var(--color-primary), #818cf8);
  border-radius: 4px 4px 0 0;
  transition: height 0.6s var(--ease-out), opacity 0.4s var(--ease-out);
  position: relative;
}

.chart-bar--zero {
  background: var(--color-border-light);
  min-height: 1px;
  opacity: 0.5;
}

.chart-bar-label {
  font-size: 9px;
  color: var(--color-text-muted);
  margin-top: 6px;
  white-space: nowrap;
  text-align: center;
}

/* ── User layout (side-by-side cards) ────────────────────────────────────── */

.user-top-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
}

.user-card--compact {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
}

.user-card--compact .user-avatar {
  width: 52px;
  height: 52px;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.user-card--compact .user-meta h2 {
  font-size: var(--text-lg);
  margin-bottom: var(--space-1);
}

.user-card--compact .user-meta p {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.balance-card--side {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  padding: var(--space-5);
}

.balance-card__digits {
  text-align: center;
}

.balance-card__value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--color-primary);
  letter-spacing: -0.03em;
  line-height: 1;
}

.balance-card__unit {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ── Totals Row ──────────────────────────────────────────────────────────── */

.totals-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

.total-stat {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
}

.total-stat__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
}

.total-stat__icon--words  { background: var(--color-primary-light); color: var(--color-primary); }
.total-stat__icon--time   { background: var(--color-accent-light);  color: var(--color-accent); }
.total-stat__icon--calls  { background: var(--color-success-light); color: var(--color-success); }

.total-stat__meta .total-stat__value {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  line-height: 1.1;
}

.total-stat__meta .total-stat__label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

@media (max-width: 768px) {
  .user-top-row {
    grid-template-columns: 1fr;
  }

  .chart-body {
    height: 120px;
  }

  .chart-bar {
    max-width: 24px;
  }

  .chart-bar-label {
    font-size: 8px;
  }

  .totals-row {
    grid-template-columns: 1fr;
  }
}

/* ── Legal Pages ───────────────────────────────────────────────────────────── */

.legal-content {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--space-12) 0;
}

.legal-content h1 {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-8);
}

.legal-content h2 {
  font-size: var(--text-xl);
  margin-top: var(--space-8);
  margin-bottom: var(--space-4);
}

.legal-content h3 {
  font-size: var(--text-lg);
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
}

.legal-content p {
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-4);
}

.legal-content ul, .legal-content ol {
  margin-bottom: var(--space-4);
  padding-left: var(--space-6);
}

.legal-content li {
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.legal-content .last-updated {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--color-border-light);
}

/* ── Pagination Dot / Loading Spinner ──────────────────────────────────────── */

.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

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

.skeleton {
  background: linear-gradient(90deg, var(--color-surface-alt) 25%, #eef0f4 50%, var(--color-surface-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Toast Notifications ───────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: #fff;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastSlideIn 0.35s var(--ease-out);
  max-width: 360px;
}

.toast--success { background: #059669; }
.toast--error   { background: #dc2626; }
.toast--info    { background: var(--color-primary); }

.toast--dismiss {
  animation: toastSlideOut 0.25s var(--ease-in-out) forwards;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(40px); }
}

/* ── Responsive ────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  :root {
    --nav-height: 56px;
  }

  .hero__title { font-size: var(--text-3xl); }
  .hero__subtitle { font-size: var(--text-lg); }
  .section__title { font-size: var(--text-2xl); }

  .grid--2,
  .grid--3,
  .grid--4 {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .nav__links {
    gap: 0;
  }

  .nav__link {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
  }

  .footer__inner {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }

  .hero__actions {
    flex-direction: column;
    align-items: center;
  }

  .platform-cards {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .user-header {
    flex-direction: column;
    text-align: center;
  }

  .steps {
    padding-left: 0;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 var(--space-4);
  }

  .card__body,
  .card__header,
  .card__footer {
    padding: var(--space-5);
  }

  .auth-card__body {
    padding: var(--space-5);
  }

  .auth-card__header {
    padding: var(--space-6) var(--space-5) 0;
  }
}

/* ── Print Styles ──────────────────────────────────────────────────────────── */

@media print {
  .nav,
  .footer,
  .toast-container {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}
