:root {
  --primary: #A78BFA;
  --primary-bright: #C4B5FD;
  --primary-dim: #7C3AED;
  --on-primary: #1A0536;
  --primary-container: rgba(167,139,250,0.15);
  --on-primary-container: #C4B5FD;
  --surface: #FAFAFA;
  --on-surface: #18181B;
  --surface-variant: #F0EDF5;
  --surface-glass: rgba(255,255,255,0.7);
  --on-surface-variant: #71717A;
  --outline: #D4D4D8;
  --outline-dim: rgba(0,0,0,0.06);
  --error: #DC2626;
  --error-container: #FEE2E2;
  --background: #F5F3FF;
  --on-background: #18181B;
  --study-red: #EF4444;
  --study-orange: #F59E0B;
  --study-green: #10B981;
  --glow: rgba(167,139,250,0.25);
  --radius: 20px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);
  --gradient-primary: linear-gradient(135deg, #7C3AED, #A78BFA, #818CF8);
  --gradient-green: linear-gradient(135deg, #059669, #10B981, #34D399);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #A78BFA;
    --primary-bright: #C4B5FD;
    --primary-dim: #7C3AED;
    --on-primary: #FFFFFF;
    --primary-container: rgba(167,139,250,0.12);
    --on-primary-container: #C4B5FD;
    --surface: #1E1B2E;
    --on-surface: #E4E4E7;
    --surface-variant: #2A2740;
    --surface-glass: rgba(30,27,46,0.75);
    --on-surface-variant: #A1A1AA;
    --outline: #3F3B54;
    --outline-dim: rgba(255,255,255,0.06);
    --error: #F87171;
    --error-container: rgba(239,68,68,0.15);
    --background: #13111C;
    --on-background: #E4E4E7;
    --glow: rgba(167,139,250,0.2);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
  }
}

:root[data-theme="dark"] {
  --primary: #A78BFA;
  --primary-bright: #C4B5FD;
  --primary-dim: #7C3AED;
  --on-primary: #FFFFFF;
  --primary-container: rgba(167,139,250,0.12);
  --on-primary-container: #C4B5FD;
  --surface: #1E1B2E;
  --on-surface: #E4E4E7;
  --surface-variant: #2A2740;
  --surface-glass: rgba(30,27,46,0.75);
  --on-surface-variant: #A1A1AA;
  --outline: #3F3B54;
  --outline-dim: rgba(255,255,255,0.06);
  --error: #F87171;
  --error-container: rgba(239,68,68,0.15);
  --background: #13111C;
  --on-background: #E4E4E7;
  --glow: rgba(167,139,250,0.2);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--background);
  color: var(--on-background);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

#screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Bottom Nav ─────────────────────────────────────────────────────── */
.bottom-nav {
  display: flex;
  background: var(--surface-glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--outline-dim);
  padding: 6px 8px env(safe-area-inset-bottom, 8px);
  position: sticky;
  bottom: 0;
  z-index: 50;
}

.bottom-nav.hidden { display: none; }

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border: none;
  background: none;
  color: var(--on-surface-variant);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: var(--radius-sm);
  position: relative;
}

.nav-item.active {
  color: var(--on-surface);
  background: var(--primary-container);
}

.nav-item:hover:not(.active) { background: var(--outline-dim); }
.nav-item svg { transition: transform 0.2s ease, color 0.2s ease; }
.nav-item.active svg { transform: scale(1.15); }

.nav-item:nth-child(1).active svg path { fill: var(--study-green) !important; }
.nav-item:nth-child(2).active svg path { fill: var(--study-red) !important; }
.nav-item:nth-child(3).active svg path { fill: #FACC15 !important; }
.nav-item:nth-child(4).active svg path { fill: var(--study-orange) !important; }

@media (min-width: 768px) {
  .bottom-nav {
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
  }
  .nav-item {
    flex: none;
    flex-direction: row;
    padding: 10px 20px;
    gap: 8px;
    font-size: 13px;
  }
}

/* ── Typography ─────────────────────────────────────────────────────── */
.heading-lg { font-size: 32px; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }
.heading-md { font-size: 24px; font-weight: 800; line-height: 1.2; letter-spacing: -0.01em; }
.heading-sm { font-size: 18px; font-weight: 700; line-height: 1.3; }
.title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.body { font-size: 14px; line-height: 1.6; }
.body-sm { font-size: 12px; line-height: 1.4; }
.label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }

/* ── Cards ──────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--outline-dim);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card-elevated {
  background: var(--surface);
  border: 1px solid var(--outline-dim);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-md);
}

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  letter-spacing: 0.02em;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0) scale(0.99); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; box-shadow: none; }

.btn-primary {
  background: var(--gradient-primary);
  color: #FFFFFF;
  box-shadow: 0 4px 16px var(--glow);
}
.btn-primary:hover { box-shadow: 0 6px 24px var(--glow); }

.btn-green {
  background: var(--gradient-green);
  color: #FFFFFF;
  box-shadow: 0 4px 16px rgba(16,185,129,0.25);
}
.btn-green:hover { box-shadow: 0 6px 24px rgba(16,185,129,0.35); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--outline);
}
.btn-outline:hover { border-color: var(--primary); background: var(--primary-container); }

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}
.btn-text:hover { background: var(--primary-container); }

.btn-sm { padding: 10px 20px; font-size: 13px; }

.btn-full-desktop { max-width: none !important; }

/* Desktop button row layout */
.btn-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (min-width: 768px) {
  .btn-row {
    flex-direction: row;
  }
  .btn-row .btn { flex: 1; }
}

/* ── Inputs ─────────────────────────────────────────────────────────── */
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-size: 13px; font-weight: 700; color: var(--on-surface); letter-spacing: -0.01em; }

.input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--outline);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--on-surface);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--glow);
}
.input::placeholder { color: var(--on-surface-variant); }

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23A1A1AA' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

textarea.input { resize: vertical; min-height: 60px; }

/* ── Stat Cards ─────────────────────────────────────────────────────── */
.stat-card {
  flex: 1;
  text-align: center;
  padding: 20px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--outline-dim);
  position: relative;
  overflow: hidden;
}

.stat-icon-wrap { display: flex; justify-content: center; margin-bottom: 6px; opacity: 0.7; }
.stat-card .value { font-size: 32px; font-weight: 800; letter-spacing: -0.02em; }
.stat-card .label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; opacity: 0.8; }

.stat-red { background: rgba(239,68,68,0.1); color: var(--study-red); border-color: rgba(239,68,68,0.15); }
.stat-orange { background: rgba(245,158,11,0.1); color: var(--study-orange); border-color: rgba(245,158,11,0.15); }
.stat-green { background: rgba(16,185,129,0.1); color: var(--study-green); border-color: rgba(16,185,129,0.15); }

@media (min-width: 768px) {
  .stat-card { padding: 28px 16px; }
  .stat-card .value { font-size: 40px; }
  .stat-card .label { font-size: 12px; }
}

/* ── Review Card ────────────────────────────────────────────────────── */
.review-card {
  display: flex;
  align-items: center;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--outline-dim);
  gap: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.review-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), var(--shadow-md);
  transform: translateY(-1px);
}

.review-cards-grid { display: flex; flex-direction: column; gap: 10px; }

@media (min-width: 768px) {
  .review-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 12px;
  }
}

.review-card.atrasada { border-left: 3px solid var(--study-red); }
.review-card .info { flex: 1; min-width: 0; }
.review-card .materia { font-size: 11px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: 0.06em; }
.review-card .assunto { font-size: 15px; font-weight: 700; margin-top: 2px; }
.review-card .meta { font-size: 12px; color: var(--on-surface-variant); margin-top: 4px; }
.review-card .progress { text-align: right; flex-shrink: 0; }
.review-card .progress .count { font-size: 18px; font-weight: 800; color: var(--primary); }
.review-card .progress .badge { font-size: 10px; font-weight: 700; color: var(--study-red); text-transform: uppercase; letter-spacing: 0.06em; }
.review-card.upcoming-card { border-left: 3px solid var(--outline); }
.review-card .countdown-timer { color: var(--on-surface-variant); display: flex; align-items: center; gap: 4px; }
.review-card .countdown-meta { color: var(--on-surface-variant); font-style: italic; }

/* ── Top bar ────────────────────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  padding: 16px 16px;
  gap: 12px;
  position: sticky;
  top: 0;
  background: var(--background);
  z-index: 10;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.top-bar h1 { font-size: 22px; font-weight: 800; flex: 1; letter-spacing: -0.02em; }

@media (min-width: 768px) {
  .top-bar { padding: 20px 40px; }
  .top-bar h1 { font-size: 26px; }
}

.icon-btn {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--on-surface);
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s;
}

.icon-btn:hover { background: var(--surface-variant); }

/* ── Sections ───────────────────────────────────────────────────────── */
.section {
  padding: 0 16px;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  box-sizing: border-box;
}
.section + .section { margin-top: 16px; }

@media (min-width: 768px) {
  .section { padding: 0 40px; }
}

.gap-8 { display: flex; flex-direction: column; gap: 8px; }
.gap-12 { display: flex; flex-direction: column; gap: 12px; }
.gap-16 { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 8px; }
.row.spread { justify-content: space-between; align-items: center; }

/* ── Progress bar ───────────────────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--surface-variant);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 3px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Chip ───────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--outline);
  background: transparent;
  color: var(--on-surface);
  transition: all 0.2s;
}

.chip.active {
  background: var(--primary-container);
  color: var(--on-primary-container);
  border-color: var(--primary);
}

.chip:hover:not(.active) { border-color: var(--on-surface-variant); }

/* ── Dialog ─────────────────────────────────────────────────────────── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}

.dialog {
  background: var(--surface);
  border-radius: 24px;
  padding: 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--outline-dim);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dialog h3 { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.dialog p { font-size: 14px; color: var(--on-surface-variant); margin-bottom: 24px; line-height: 1.5; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ── Toast ──────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--on-surface);
  color: var(--surface);
  padding: 12px 24px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 600;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ── Screen containers ──────────────────────────────────────────────── */
.scroll-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.screen-fixed {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.screen-fixed .fixed-top {
  flex-shrink: 0;
  background: var(--background);
  z-index: 5;
  border-bottom: 1px solid var(--outline-dim);
}

.screen-fixed .scrollable {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 24px;
}

@media (min-width: 768px) {
  .scroll-list { padding: 0 40px 16px; }
}

/* ── Search ─────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1.5px solid var(--outline);
  border-radius: var(--radius);
  transition: all 0.2s;
}

.search-bar:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--glow); }

.search-bar input {
  flex: 1;
  border: none;
  background: none;
  font-size: 15px;
  color: var(--on-surface);
  outline: none;
  font-family: inherit;
}

.search-bar input::placeholder { color: var(--on-surface-variant); }

/* ── Divider ────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--outline);
  opacity: 0.2;
  margin: 12px 0;
}

/* ── Text colors ────────────────────────────────────────────────────── */
.text-primary { color: var(--primary); }
.text-muted { color: var(--on-surface-variant); }
.text-error { color: var(--study-red); }
.text-green { color: var(--study-green); }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }

/* ── Auth screen ────────────────────────────────────────────────────── */
.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 32px 24px;
  gap: 40px;
}

.auth-container .logo {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: -0.03em;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-container .subtitle { color: var(--on-surface-variant); font-size: 15px; text-align: center; }

.auth-form {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.input-password-wrap { position: relative; display: flex; align-items: center; }
.input-password-wrap .input { flex: 1; padding-right: 44px; }
.pwd-toggle { position: absolute; right: 8px; background: none; border: none; color: var(--on-surface-variant); cursor: pointer; padding: 4px; display: flex; align-items: center; justify-content: center; }
.pwd-toggle:hover { color: var(--on-surface); }

.auth-toggle { font-size: 14px; text-align: center; color: var(--on-surface-variant); }
.auth-toggle a { color: var(--primary); font-weight: 700; cursor: pointer; text-decoration: none; }
.auth-toggle a:hover { text-decoration: underline; }
.error-msg { color: var(--study-red); font-size: 13px; text-align: center; font-weight: 600; }

@media (min-width: 768px) {
  .auth-form { max-width: 420px; }
  .auth-container { gap: 56px; }
  .auth-container .logo { font-size: 48px; }
  .auth-container .subtitle { font-size: 16px; }
}

/* ── Empty state ────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px 24px;
  text-align: center;
}

.empty-state .icon { font-size: 48px; opacity: 0.4; }
.empty-state .title { font-size: 16px; font-weight: 700; }
.empty-state .body { font-size: 14px; color: var(--on-surface-variant); line-height: 1.5; }

/* ── Loading ────────────────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--on-surface-variant);
  font-weight: 600;
}

/* ── Review mode ────────────────────────────────────────────────────── */
.review-mode {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding: 0;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.review-mode .content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.review-mode .actions {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--outline-dim);
}

.review-mode .nav-row { display: flex; gap: 10px; }
.review-mode .nav-row button { flex: 1; }

@media (min-width: 768px) {
  .review-mode .content { padding: 32px 40px; }
  .review-mode .actions { padding: 20px 40px; }
}

/* ── Afirmativa row ─────────────────────────────────────────────────── */
.afirmativa-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 4px 0;
}

.afirmativa-row .prefix { font-weight: 800; min-width: 24px; padding-top: 2px; color: var(--primary); }
.afirmativa-row .text { flex: 1; transition: filter 0.3s ease, color 0.3s ease; }
.af-text.blurred {
  filter: blur(6px) !important;
  color: transparent !important;
  text-shadow: 0 0 12px var(--on-surface);
  user-select: none;
  pointer-events: none;
}
.afirmativa-row .eye-toggle { width: 32px; height: 32px; flex-shrink: 0; }
.eye-toggle-all { width: 36px; height: 36px; flex-shrink: 0; }

/* ── Afirmativa input row ───────────────────────────────────────────── */
.afirmativa-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.afirmativa-input-row .prefix { font-weight: 800; padding-top: 16px; min-width: 24px; color: var(--primary); }
.afirmativa-input-row .input { flex: 1; }
.afirmativa-input-row .afirm-actions { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.afirmativa-input-row .move-btn {
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  background: var(--surface-variant); border: none; border-radius: 6px; cursor: pointer; color: var(--on-surface-variant);
}
.afirmativa-input-row .move-btn:hover { background: var(--primary-container); color: var(--primary); }
.afirmativa-input-row .del-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--study-red);
  cursor: pointer;
  border-radius: 6px;
  flex-shrink: 0;
  transition: background 0.2s;
}
.afirmativa-input-row .del-btn:hover { background: var(--error-container); }

/* ── Phase card ─────────────────────────────────────────────────────── */
.fase-card {
  background: var(--surface);
  border: 1px solid var(--outline-dim);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s;
}

.fase-card:hover { border-color: var(--outline); }

.fase-card .fase-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fase-card .fase-header .nome { font-weight: 700; }
.fase-card .fase-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fase-card select.input, .fase-card .input { padding: 10px 12px; font-size: 13px; }

@media (min-width: 768px) {
  .fase-card .fase-fields { grid-template-columns: repeat(3, 1fr); }
}

/* ── Detail page history row ────────────────────────────────────────── */
.hist-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--outline-dim);
}

.hist-row:last-child { border-bottom: none; }
.hist-row .date { color: var(--on-surface-variant); }

/* ── Stats ──────────────────────────────────────────────────────────── */
.stat-big {
  text-align: center;
  padding: 32px 20px;
}
.stat-big .value {
  font-size: 56px;
  font-weight: 900;
  letter-spacing: -0.03em;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-big .label { font-size: 14px; color: var(--on-surface-variant); margin-top: 8px; font-weight: 600; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stats-grid .stat-item {
  background: var(--surface);
  border: 1px solid var(--outline-dim);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}

.stats-grid .stat-item:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stats-grid .stat-item .value { font-size: 28px; font-weight: 800; color: var(--primary); letter-spacing: -0.02em; }
.stats-grid .stat-item .label { font-size: 11px; font-weight: 700; color: var(--on-surface-variant); margin-top: 6px; text-transform: uppercase; letter-spacing: 0.06em; }

@media (min-width: 768px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .stats-grid .stat-item { padding: 32px 20px; }
  .stats-grid .stat-item .value { font-size: 36px; }
}

/* ── Detail actions bar (fixed bottom) ─────────────────────────────── */
.detail-actions-bar {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--outline-dim);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .detail-actions-bar { padding: 16px 40px; }
}

/* ── Save button bar ────────────────────────────────────────────────── */
.save-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--outline-dim);
  display: flex;
  flex-direction: column;
  max-width: 1200px;
  margin: 0 auto;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .save-bar { padding: 16px 40px; flex-direction: row; gap: 12px; }
  .save-bar .btn { flex: 1; }
}

/* ── Help Screen ────────────────────────────────────────────────────── */
.help-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 16px;
  text-align: center;
}

.help-hero-icon {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-container);
  border-radius: 50%;
}

.help-section { display: flex; flex-direction: column; gap: 12px; }

.help-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.help-number {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-primary);
  color: #FFF;
  font-size: 14px;
  font-weight: 800;
  border-radius: 50%;
  flex-shrink: 0;
}

.help-item-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--on-surface);
  margin-bottom: 2px;
}

.help-phases-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 768px) {
  .help-phases-grid { grid-template-columns: repeat(3, 1fr); }
}

.help-phase-card {
  background: var(--surface);
  border: 1px solid var(--outline-dim);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.help-phase-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
}

.help-default-phases {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (min-width: 768px) {
  .help-default-phases {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
}

.help-status-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (min-width: 768px) {
  .help-status-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
}

.help-flow {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-left: 4px;
}

.help-flow-step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 8px 0;
}

.help-flow-number {
  width: 28px;
  height: 28px;
  min-width: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-container);
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  border-radius: 50%;
}

.help-flow-connector {
  width: 2px;
  height: 16px;
  background: var(--outline);
  margin-left: 13px;
  opacity: 0.3;
}

.help-list {
  list-style: none;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.help-list li {
  font-size: 14px;
  line-height: 1.5;
  padding-left: 16px;
  position: relative;
  color: var(--on-surface-variant);
}

.help-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 9px;
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
}

.help-list li strong {
  color: var(--on-surface);
}

/* ── Quote card ────────────────────────────────────────────────────── */
.quote-card {
  background: var(--primary-container);
  border-radius: var(--radius);
  padding: 20px 24px;
  text-align: center;
}
.quote-card .quote-icon { font-size: 28px; opacity: 0.3; font-family: Georgia, serif; line-height: 1; }
.quote-card .quote-text { font-size: 15px; font-style: italic; line-height: 1.6; color: var(--on-surface); }

/* ── Level badge ───────────────────────────────────────────────────── */
.level-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 700;
  background: var(--primary-container);
  color: var(--primary);
}

/* ── Chart ──────────────────────────────────────────────────────────── */
.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--outline-dim);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.chart-wrap .chart-title { font-size: 15px; font-weight: 700; margin-bottom: 8px; }

/* ── Period selector ───────────────────────────────────────────────── */
.period-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.period-chips::-webkit-scrollbar { display: none; }
.period-chip {
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--outline);
  background: transparent;
  color: var(--on-surface-variant);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.period-chip.active {
  background: var(--primary-container);
  color: var(--primary);
  border-color: var(--primary);
}

/* ── Stat mini grid ────────────────────────────────────────────────── */
.stat-mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (min-width: 768px) {
  .stat-mini-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1200px) {
  .stat-mini-grid { grid-template-columns: repeat(5, 1fr); }
}
.stat-mini {
  background: var(--surface);
  border: 1px solid var(--outline-dim);
  border-radius: var(--radius-sm);
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.stat-mini .stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-mini .value { font-size: 24px; font-weight: 800; }
.stat-mini .label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--on-surface-variant); }

/* ── Stats top row (Flashcards / Revisoes feitas) ──────────────────── */
.stats-top-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.stats-top-row .stat-item {
  background: var(--surface);
  border: 1px solid var(--outline-dim);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}
.stats-top-row .stat-item:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stats-top-row .stat-item .value { font-size: 28px; font-weight: 800; color: var(--primary); letter-spacing: -0.02em; }
.stats-top-row .stat-item .label { font-size: 11px; font-weight: 700; color: var(--on-surface-variant); margin-top: 6px; text-transform: uppercase; letter-spacing: 0.06em; }

@media (min-width: 768px) {
  .stats-top-row .stat-item { padding: 32px 20px; }
  .stats-top-row .stat-item .value { font-size: 36px; }
}

/* ── Stats desktop layout ──────────────────────────────────────────── */
.stats-desktop-row { display: flex; flex-direction: column; gap: 16px; }
.stats-left { display: flex; flex-direction: column; gap: 16px; }
.charts-row { display: flex; flex-direction: column; gap: 16px; }

@media (min-width: 768px) {
  .stats-desktop-row { flex-direction: row; }
  .stats-left { flex: 1; min-width: 0; }
  .stat-mini-grid { flex: 1; min-width: 0; }
  .charts-row { flex-direction: row; }
}

/* ── Desktop responsiveness enhancements ───────────────────────────── */
@media (min-width: 768px) {
  .review-mode .content { max-width: 900px; margin: 0 auto; width: 100%; }
  .review-mode .actions { max-width: 900px; margin: 0 auto; width: 100%; }

  .auth-container .logo { font-size: 52px; }

  .help-section .card { padding: 24px; }

  .fase-card { padding: 24px; }
}

@media (min-width: 1024px) {
  .stat-card .value { font-size: 36px; }

  .stats-top-row .stat-item { padding: 36px 24px; }
  .stats-top-row .stat-item .value { font-size: 42px; }

  .stat-mini .value { font-size: 28px; }

  .quote-card { padding: 24px 32px; }
  .quote-card .quote-text { font-size: 16px; }
}

/* ── Collapsible review columns ──────────────────────────────────── */
.review-columns {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (min-width: 768px) {
  .review-columns {
    flex-direction: row;
    align-items: flex-start;
  }
  .review-col { flex: 1; min-width: 0; }
}

.review-col {
  display: flex;
  flex-direction: column;
}

.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 4px;
  cursor: pointer;
  user-select: none;
}

.collapsible-header .title {
  font-size: 15px;
  font-weight: 700;
}

.collapse-toggle {
  transition: transform 0.3s ease;
}

.collapse-toggle.collapsed {
  transform: rotate(-90deg);
}

.collapsible-body {
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  max-height: 2000px;
  opacity: 1;
}

.collapsible-body.collapsed {
  max-height: 0;
  opacity: 0;
}

.review-cards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
