:root {
  --navy: #14213D;
  --teal: #14B8A6;
  --teal-dark: #0D9488;
  --amber: #F4B942;
  --bg: #F1F5F9;
  --surface: #FFFFFF;
  --slate: #64748B;
  --text: #0F172A;
  --border: #E2E8F0;
  --danger: #EF4444;
  --success: #10B981;
  --shadow: 0 4px 18px rgba(15, 23, 42, 0.05);
}
body.dark {
  --bg: #0B1120;
  --surface: #111827;
  --text: #F8FAFC;
  --slate: #94A3B8;
  --border: #1F2937;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: linear-gradient(90deg, #14213D 0%, #1B2E54 100%);
  color: #fff;
  height: 62px;
  padding: 0 18px;
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.16);
  display: flex;
  align-items: center;
}
.topbar-inner {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.brand {
  text-decoration: none;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #14B8A6, #2DD4BF);
  color: #0F172A;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: .88rem;
  box-shadow: 0 2px 8px rgba(20, 184, 166, 0.35);
}
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(45, 212, 191, 0.85);
  background: #fff;
  box-shadow: 0 2px 8px rgba(20, 184, 166, 0.35);
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; font-size: 1rem; letter-spacing: -.2px; white-space: nowrap; }
.brand-sub { font-size: .7rem; color: #94A3B8; font-weight: 500; }

.goal-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,.10);
  color: #F8FAFC;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  max-width: 260px;
  min-width: 0;
  transition: .15s;
}
.goal-pill:hover { background: rgba(20,184,166,.22); border-color: rgba(20,184,166,.5); }
.goal-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); flex-shrink: 0; }
.goal-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-caret { opacity: .75; flex-shrink: 0; }

.top-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.action-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
  color: #fff;
  font-weight: 600;
  font-size: .8rem;
  cursor: pointer;
  transition: .15s;
}
.action-pill:hover { background: rgba(255,255,255,.20); }
.logout-pill {
  background: linear-gradient(135deg, #EF4444, #DC2626);
  border: 1px solid rgba(255,255,255,.22);
  color: #FFFFFF;
  box-shadow: 0 3px 10px rgba(220, 38, 38, 0.30);
}
.logout-pill:hover { background: linear-gradient(135deg, #DC2626, #B91C1C); transform: translateY(-1px); }
.logout-side-btn {
  width: 100%;
  background: linear-gradient(135deg, #EF4444, #DC2626);
  color: #FFFFFF;
  border: none;
  border-radius: 11px;
  padding: 11px 14px;
  font-weight: 700;
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.24);
  transition: transform .15s ease, box-shadow .15s ease;
}
.logout-side-btn:hover { background: linear-gradient(135deg, #DC2626, #B91C1C); transform: translateY(-1px); }
.icon-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
  color: #fff;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  font-size: .95rem;
  position: relative;
  transition: .15s;
}
.icon-circle:hover { background: rgba(255,255,255,.22); }
.notif-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--amber);
  color: var(--navy);
  font-size: .68rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  border: 2px solid #14213D;
}

.app-shell { display: flex; flex: 1; max-width: 1280px; width: 100%; margin: 0 auto; }
.sidebar { width: 232px; padding: 18px 12px; border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; gap: 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 11px; border: none; background: transparent; color: var(--slate); font-weight: 600; cursor: pointer; text-align: left; font-size: .92rem; transition: .15s; }
.nav-item:hover { background: rgba(100,116,139,.08); }
.nav-item.active { background: rgba(20,184,166,.14); color: var(--teal-dark); }
body.dark .nav-item.active { color: var(--teal); }
.main { flex: 1; padding: 20px; padding-bottom: 90px; max-width: 100%; overflow-x: hidden; }

.bottom-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); z-index: 30; justify-content: space-around; padding: 6px 4px; box-shadow: 0 -2px 12px rgba(0,0,0,.06); }
.bottom-nav button { background: none; border: none; color: var(--slate); font-size: .72rem; font-weight: 600; padding: 5px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.bottom-nav button.active { color: var(--teal-dark); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.hero-banner { background: linear-gradient(135deg, var(--navy) 0%, #1D3557 100%); color: #fff; border-radius: 18px; padding: 22px; margin-bottom: 18px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(115px, 1fr)); gap: 12px; margin-bottom: 20px; }
.quick-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 10px; text-align: center; cursor: pointer; box-shadow: var(--shadow); transition: .15s; font-weight: 600; font-size: .83rem; color: var(--text); }
.quick-tile:hover { transform: translateY(-2px); border-color: var(--teal); }
.quick-tile .qt-icon { font-size: 1.5rem; display: block; margin-bottom: 6px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 15px; border-radius: 10px; font-weight: 600; cursor: pointer; border: none; font-size: .88rem; transition: .15s; }
.btn-primary { background: var(--teal); color: #042F2E; }
.btn-primary:hover { background: var(--teal-dark); color: #fff; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-amber { background: var(--amber); color: var(--navy); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: .8rem; border-radius: 8px; }

input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--slate); font-size: .86rem; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; background: rgba(20,184,166,.15); color: var(--teal-dark); }
body.dark .badge { color: #5EEAD4; }
.badge-amber { background: var(--amber); color: var(--navy); font-weight: 700; padding: 3px 9px; border-radius: 999px; font-size: .74rem; }
.badge-live { background: #FEE2E2; color: #DC2626; font-weight: 800; padding: 3px 9px; border-radius: 999px; font-size: .72rem; }
.progress-bar { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--teal), #2DD4BF); }
.chip { display: inline-block; padding: 5px 12px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--surface); color: var(--slate); cursor: pointer; border: 1px solid var(--border); }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.option-btn { width: 100%; text-align: left; padding: 12px 14px; border-radius: 11px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text); margin-bottom: 10px; cursor: pointer; font-weight: 500; }
.option-btn.selected { border-color: var(--teal); background: rgba(20,184,166,.12); }
.palette-btn { width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 700; cursor: pointer; }
.palette-btn.answered { background: var(--success); color: #fff; border-color: var(--success); }
.palette-btn.review { background: var(--amber); color: var(--navy); border-color: var(--amber); }
.palette-btn.current { outline: 2px solid var(--navy); }

.flashcard-box { background: linear-gradient(135deg, #F0FDFA, #FFFFFF); border: 2px solid var(--teal); border-radius: 18px; padding: 28px; text-align: center; cursor: pointer; min-height: 190px; display: flex; flex-direction: column; justify-content: center; gap: 10px; }
body.dark .flashcard-box { background: linear-gradient(135deg, #0F172A, #1E293B); }
.ebook-reader { border: 1px solid var(--border); border-radius: 12px; padding: 20px; line-height: 1.75; margin-top: 12px; }
.ebook-sepia { background: #FBF5E6; color: #3B2F2F; }
.ebook-night { background: #0F172A; color: #E2E8F0; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.65); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); color: var(--text); border-radius: 18px; max-width: 720px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 22px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.empty-state { text-align: center; padding: 36px 16px; color: var(--slate); }

@media (max-width: 820px) {
  .topbar { height: 58px; padding: 0 12px; }
  .brand-sub { display: none; }
  .brand-name { font-size: .95rem; }
  .goal-pill { display: none !important; }
  .hide-sm { display: none; }
  .sidebar { display: none; }
  .bottom-nav { display: flex; }
  .main { padding: 14px; padding-bottom: 88px; }
}
