:root {
  --red:#E8192C; --red-dark:#C0141F; --red-light:#FF4D5A;
  --red-soft:#FFF0F1; --red-mid:#FFD6D9;
  --bg:#F8F7F5; --surface:#FFFFFF; --surface2:#F2F1EF;
  --text:#1A1917; --text-2:#5C5A57; --text-3:#9B9894;
  --border:#E8E6E3;
  --shadow:0 2px 16px rgba(0,0,0,.07);
  --shadow-lg:0 8px 40px rgba(0,0,0,.12);
  --radius:16px; --radius-sm:10px;
  --font-display:'Syne',sans-serif; --font-body:'DM Sans',sans-serif;
}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
body{font-family:var(--font-body);background:var(--bg);color:var(--text);font-size:15px;line-height:1.6}
#authScreen ~ * , #appScreen { height:100vh; overflow:hidden; }
#appScreen.active { display:block; }
::-webkit-scrollbar{width:5px;height:5px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--border);border-radius:99px}

/* ===== AUTH SCREEN ===== */
/* ===== LANDING PAGE ===== */
#authScreen {
  min-height:100vh; background:#0a0a0f; color:#fff;
  font-family:'DM Sans',sans-serif; overflow-x:hidden;
}

/* NAV */
.land-nav {
  position:fixed; top:0; left:0; right:0; z-index:100;
  display:flex; align-items:center; justify-content:space-between;
  padding:18px 48px;
  background:rgba(10,10,15,.8); backdrop-filter:blur(16px);
  border-bottom:1px solid rgba(255,255,255,.06);
}
.land-nav-logo { display:flex; align-items:center; gap:10px; }
.land-nav-logo-mark {
  width:36px; height:36px; background:#E8192C; border-radius:10px;
  display:flex; align-items:center; justify-content:center;
  font-weight:800; font-size:16px; color:#fff; font-family:'Clash Display',sans-serif;
}
.land-nav-logo-text { font-weight:800; font-size:20px; font-family:'DM Sans',sans-serif; }
.land-nav-logo-text span { color:#E8192C; }
.land-nav-links { display:flex; gap:32px; }
.land-nav-links a { color:rgba(255,255,255,.6); font-size:14px; text-decoration:none; transition:color .2s; cursor:pointer; }
.land-nav-links a:hover { color:#fff; }
.land-nav-cta { display:flex; gap:12px; align-items:center; }
.btn-land-ghost {
  padding:9px 20px; border:1px solid rgba(255,255,255,.2); border-radius:10px;
  background:transparent; color:#fff; font-size:14px; font-weight:600; cursor:pointer; transition:all .2s;
}
.btn-land-ghost:hover { border-color:rgba(255,255,255,.5); background:rgba(255,255,255,.05); }
.btn-land-red {
  padding:9px 20px; background:#E8192C; border:none; border-radius:10px;
  color:#fff; font-size:14px; font-weight:700; cursor:pointer; transition:all .2s;
}
.btn-land-red:hover { background:#c8111f; transform:translateY(-1px); }

/* HERO */
.land-hero {
  min-height:100vh; display:flex; align-items:center; justify-content:center;
  text-align:center; padding:120px 24px 80px; position:relative; overflow:hidden;
}
.land-hero-bg {
  position:absolute; inset:0; pointer-events:none;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(232,25,44,.18) 0%, transparent 70%),
    radial-gradient(ellipse 40% 40% at 20% 80%, rgba(232,25,44,.08) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 80% 80%, rgba(120,60,255,.06) 0%, transparent 60%);
}
.land-hero-grid {
  position:absolute; inset:0; pointer-events:none;
  background-image:linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size:60px 60px;
  mask-image:radial-gradient(ellipse 80% 80% at 50% 50%, black 0%, transparent 100%);
}
.land-hero-badge {
  display:inline-flex; align-items:center; gap:8px;
  padding:6px 16px; border:1px solid rgba(232,25,44,.4);
  border-radius:99px; background:rgba(232,25,44,.08);
  font-size:12px; font-weight:600; color:#E8192C; letter-spacing:.06em;
  text-transform:uppercase; margin-bottom:28px;
}
.land-hero-badge span { width:6px; height:6px; border-radius:50%; background:#E8192C; animation:pulse-dot 2s infinite; }
@keyframes pulse-dot { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.5;transform:scale(1.3)} }
.land-hero h1 {
  font-size:clamp(40px, 7vw, 80px); font-weight:800; line-height:1.08;
  letter-spacing:-.03em; margin-bottom:24px;
  font-family:'DM Sans',sans-serif;
}
.land-hero h1 em { font-style:normal; color:#E8192C; }
.land-hero-sub {
  font-size:clamp(16px,2vw,20px); color:rgba(255,255,255,.55);
  max-width:580px; margin:0 auto 44px; line-height:1.6; font-weight:400;
}
.land-hero-actions { display:flex; gap:16px; justify-content:center; flex-wrap:wrap; }
.btn-hero-primary {
  display:flex; align-items:center; gap:10px;
  padding:15px 32px; background:#E8192C; border:none; border-radius:14px;
  color:#fff; font-size:16px; font-weight:700; cursor:pointer;
  transition:all .25s; box-shadow:0 0 40px rgba(232,25,44,.35);
}
.btn-hero-primary:hover { background:#c8111f; transform:translateY(-2px); box-shadow:0 0 60px rgba(232,25,44,.5); }
.btn-hero-secondary {
  display:flex; align-items:center; gap:10px;
  padding:15px 32px; background:rgba(255,255,255,.06); border:1px solid rgba(255,255,255,.12);
  border-radius:14px; color:#fff; font-size:16px; font-weight:600; cursor:pointer; transition:all .25s;
}
.btn-hero-secondary:hover { background:rgba(255,255,255,.1); transform:translateY(-2px); }
.land-hero-stats {
  display:flex; gap:48px; justify-content:center; flex-wrap:wrap;
  margin-top:64px; padding-top:48px; border-top:1px solid rgba(255,255,255,.08);
}
.land-stat-val { font-size:32px; font-weight:800; color:#fff; }
.land-stat-val span { color:#E8192C; }
.land-stat-label { font-size:13px; color:rgba(255,255,255,.4); margin-top:2px; }

/* FEATURES */
.land-section { padding:100px 48px; max-width:1200px; margin:0 auto; }
.land-section-tag {
  font-size:11px; font-weight:700; letter-spacing:.12em; text-transform:uppercase;
  color:#E8192C; margin-bottom:14px;
}
.land-section-title {
  font-size:clamp(28px,4vw,48px); font-weight:800; line-height:1.1;
  letter-spacing:-.02em; margin-bottom:16px;
}
.land-section-sub { font-size:16px; color:rgba(255,255,255,.5); max-width:540px; line-height:1.6; margin-bottom:56px; }
.features-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(300px,1fr)); gap:20px; }
.feature-card {
  background:rgba(255,255,255,.03); border:1px solid rgba(255,255,255,.07);
  border-radius:20px; padding:28px; transition:all .25s; cursor:default;
}
.feature-card:hover { background:rgba(255,255,255,.06); border-color:rgba(232,25,44,.3); transform:translateY(-4px); }
.feature-icon {
  width:48px; height:48px; border-radius:14px;
  background:rgba(232,25,44,.12); display:flex; align-items:center; justify-content:center;
  font-size:22px; margin-bottom:18px;
}
.feature-title { font-size:17px; font-weight:700; margin-bottom:8px; }
.feature-desc { font-size:14px; color:rgba(255,255,255,.5); line-height:1.6; }
.feature-pills { display:flex; flex-wrap:wrap; gap:6px; margin-top:14px; }
.feature-pill {
  padding:3px 10px; border-radius:99px; font-size:11px; font-weight:600;
  background:rgba(232,25,44,.1); color:#E8192C; border:1px solid rgba(232,25,44,.2);
}

/* PRICING */
.land-pricing { padding:100px 24px; background:rgba(255,255,255,.015); }
.land-pricing-inner { max-width:1100px; margin:0 auto; text-align:center; }
.pricing-toggle {
  display:inline-flex; align-items:center; gap:14px;
  background:rgba(255,255,255,.06); border:1px solid rgba(255,255,255,.1);
  border-radius:99px; padding:6px 20px; margin-bottom:56px;
  font-size:14px; font-weight:600;
}
.pricing-toggle-btn {
  padding:8px 20px; border-radius:99px; cursor:pointer; transition:all .2s;
  background:transparent; border:none; color:rgba(255,255,255,.5); font-size:14px; font-weight:600;
}
.pricing-toggle-btn.active { background:#E8192C; color:#fff; }
.pricing-badge-annual {
  background:rgba(34,197,94,.15); border:1px solid rgba(34,197,94,.3);
  color:#22c55e; font-size:11px; padding:2px 8px; border-radius:99px; font-weight:700;
}
.pricing-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:20px; text-align:left; }
.pricing-card {
  background:rgba(255,255,255,.04); border:1px solid rgba(255,255,255,.08);
  border-radius:24px; padding:32px 28px; position:relative; transition:all .3s;
}
.pricing-card.popular {
  background:rgba(232,25,44,.06); border:2px solid #E8192C;
  transform:scale(1.03);
  box-shadow:0 0 60px rgba(232,25,44,.15);
}
.pricing-card-badge {
  position:absolute; top:-14px; left:50%; transform:translateX(-50%);
  background:#E8192C; color:#fff; font-size:11px; font-weight:800;
  padding:4px 16px; border-radius:99px; white-space:nowrap; letter-spacing:.06em;
}
.pricing-plan-name { font-size:14px; font-weight:700; color:rgba(255,255,255,.5); text-transform:uppercase; letter-spacing:.08em; margin-bottom:10px; }
.pricing-price { font-size:48px; font-weight:800; letter-spacing:-.03em; line-height:1; }
.pricing-price sub { font-size:18px; font-weight:500; color:rgba(255,255,255,.4); vertical-align:super; font-style:normal; }
.pricing-price-period { font-size:13px; color:rgba(255,255,255,.4); margin:4px 0 20px; }
.pricing-divider { border:none; border-top:1px solid rgba(255,255,255,.08); margin:20px 0; }
.pricing-feature { display:flex; align-items:flex-start; gap:10px; margin:10px 0; font-size:14px; color:rgba(255,255,255,.75); }
.pricing-feature .check { color:#E8192C; font-weight:700; flex-shrink:0; margin-top:1px; }
.pricing-feature .cross { color:rgba(255,255,255,.2); flex-shrink:0; margin-top:1px; }
.pricing-feature b { color:#fff; }
.pricing-cta {
  width:100%; padding:14px; border-radius:12px; margin-top:24px;
  font-size:15px; font-weight:700; cursor:pointer; transition:all .2s; border:none;
}
.pricing-cta.free { background:rgba(255,255,255,.08); color:#fff; }
.pricing-cta.free:hover { background:rgba(255,255,255,.14); }
.pricing-cta.paid { background:#E8192C; color:#fff; box-shadow:0 4px 24px rgba(232,25,44,.3); }
.pricing-cta.paid:hover { background:#c8111f; transform:translateY(-1px); }
.pricing-cta.premium { background:linear-gradient(135deg,#7c3aed,#E8192C); color:#fff; }
.pricing-cta.premium:hover { opacity:.9; transform:translateY(-1px); }

/* FOOTER */
.land-footer {
  padding:48px; text-align:center; border-top:1px solid rgba(255,255,255,.06);
  color:rgba(255,255,255,.25); font-size:13px;
}
.land-footer a { color:rgba(255,255,255,.4); text-decoration:none; }

/* LEGAL MODAL */
.legal-modal-overlay {
  position:fixed; inset:0; z-index:2000; background:rgba(0,0,0,.8);
  backdrop-filter:blur(8px); display:flex; align-items:center; justify-content:center;
  padding:24px; animation:fadeIn .2s;
}
.legal-modal-card {
  background:#12121a; border:1px solid rgba(255,255,255,.12); border-radius:20px;
  max-width:680px; width:100%; max-height:80vh; display:flex; flex-direction:column;
  box-shadow:0 32px 80px rgba(0,0,0,.6);
}
.legal-modal-header {
  padding:24px 28px 16px; border-bottom:1px solid rgba(255,255,255,.08);
  display:flex; align-items:center; justify-content:space-between; flex-shrink:0;
}
.legal-modal-title { font-size:18px; font-weight:800; color:#fff; }
.legal-modal-close {
  width:32px; height:32px; background:rgba(255,255,255,.08); border:none;
  border-radius:50%; color:#fff; font-size:16px; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
}
.legal-modal-body {
  padding:24px 28px; overflow-y:auto; flex:1;
  font-size:14px; line-height:1.8; color:rgba(255,255,255,.65);
}
.legal-modal-body h2 { font-size:15px; font-weight:700; color:#fff; margin:20px 0 8px; }
.legal-modal-body h2:first-child { margin-top:0; }
.legal-modal-body p { margin:0 0 12px; }
.legal-modal-body ul { padding-left:20px; margin:0 0 12px; }
.legal-modal-body li { margin:4px 0; }
.legal-modal-body a { color:#E8192C; }

.login-modal-overlay {
  position:fixed; inset:0; z-index:1000; background:rgba(0,0,0,.7);
  backdrop-filter:blur(8px); display:flex; align-items:center; justify-content:center;
  padding:24px; animation:fadeIn .2s;
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
.login-modal-card {
  background:#12121a; border:1px solid rgba(255,255,255,.12); border-radius:24px;
  padding:48px 40px; max-width:420px; width:100%; text-align:center;
  box-shadow:0 32px 80px rgba(0,0,0,.6); animation:slideUp .3s ease;
}
@keyframes slideUp { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }
.login-modal-logo { display:flex; align-items:center; justify-content:center; gap:10px; margin-bottom:28px; }
.login-modal-logo-mark {
  width:44px; height:44px; background:#E8192C; border-radius:13px;
  display:flex; align-items:center; justify-content:center; font-weight:800; font-size:20px; color:#fff;
}
.login-modal-logo-text { font-size:24px; font-weight:800; color:#fff; }
.login-modal-logo-text span { color:#E8192C; }
.login-modal-title { font-size:22px; font-weight:800; color:#fff; margin-bottom:8px; }
.login-modal-sub { font-size:14px; color:rgba(255,255,255,.45); margin-bottom:32px; line-height:1.5; }
.btn-google-dark {
  display:flex; align-items:center; justify-content:center; gap:12px;
  width:100%; padding:14px 20px;
  background:rgba(255,255,255,.06); border:1px solid rgba(255,255,255,.15); border-radius:12px;
  color:#fff; font-size:15px; font-weight:600; cursor:pointer; transition:all .2s;
}
.btn-google-dark:hover { background:rgba(255,255,255,.1); border-color:rgba(255,255,255,.3); }
.login-modal-footer { margin-top:20px; font-size:12px; color:rgba(255,255,255,.25); }
.login-modal-close {
  position:absolute; top:16px; right:16px; width:32px; height:32px;
  background:rgba(255,255,255,.08); border:none; border-radius:50%; color:#fff;
  font-size:16px; cursor:pointer; display:flex; align-items:center; justify-content:center;
}

@media(max-width:768px) {
  .land-nav { padding:16px 20px; }
  .land-nav-links { display:none; }
  .land-hero { padding:100px 20px 60px; }
  .land-section { padding:60px 20px; }
  .pricing-grid { grid-template-columns:1fr; }
  .pricing-card.popular { transform:none; }
  .land-pricing { padding:60px 16px; }
  .land-hero-stats { gap:28px; }
  .study-profile-card { padding:22px; }
  .study-profile-strip { align-items:flex-start; flex-direction:column; }
}

/* ===== APP LAYOUT ===== */
#appScreen { display:none; }
.app { display:flex; height:100vh; overflow:hidden; }

/* ===== SIDEBAR ===== */
.sidebar {
  width:240px; flex-shrink:0; background:var(--surface);
  border-right:1px solid var(--border);
  display:flex; flex-direction:column; overflow-y:auto;
}
.sidebar-logo { padding:22px 20px 16px; display:flex; align-items:center; gap:10px; }
.logo-mark {
  width:34px; height:34px; background:var(--red); border-radius:10px;
  display:flex; align-items:center; justify-content:center;
  font-family:var(--font-display); font-weight:800; color:#fff; font-size:16px; flex-shrink:0;
}
.logo-text { font-family:var(--font-display); font-weight:700; font-size:17px; }
.logo-text span { color:var(--red); }
.sidebar-section { padding:6px 12px 4px; font-size:10px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--text-3); margin-top:8px; }
.nav-item {
  display:flex; align-items:center; gap:10px;
  padding:9px 12px; margin:1px 8px; border-radius:var(--radius-sm);
  cursor:pointer; font-size:14px; font-weight:500; color:var(--text-2); transition:all .15s;
}
.nav-item:hover { background:var(--bg); color:var(--text); }
.nav-item.active { background:var(--red-soft); color:var(--red); }
.nav-icon { width:28px; height:28px; display:flex; align-items:center; justify-content:center; font-size:16px; flex-shrink:0; }

/* ===== USER PANEL ===== */
.user-panel {
  margin-top:auto; padding:12px; border-top:1px solid var(--border);
}
.user-card {
  background:var(--bg); border-radius:12px; padding:10px 12px;
  display:flex; align-items:center; gap:10px;
}
.user-avatar {
  width:34px; height:34px; border-radius:50%; background:var(--red-soft);
  overflow:hidden; flex-shrink:0; display:flex; align-items:center; justify-content:center;
  font-size:15px; font-weight:700; color:var(--red);
}
.user-avatar img { width:100%; height:100%; object-fit:cover; }
.user-info { flex:1; min-width:0; }
.user-name { font-size:13px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.user-email { font-size:11px; color:var(--text-3); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sign-out-btn {
  background:none; border:none; cursor:pointer; color:var(--text-3);
  font-size:16px; padding:4px; border-radius:6px; transition:all .15s;
}
.sign-out-btn:hover { color:var(--red); background:var(--red-soft); }

/* ===== MAIN ===== */
.main { flex:1; overflow-y:auto; display:flex; flex-direction:column; }
.page-header { padding:28px 32px 0; }
.page-title { font-family:var(--font-display); font-size:28px; font-weight:800; color:var(--red); line-height:1.1; }
.page-subtitle { color:var(--text-3); font-size:14px; margin-top:4px; }
.page-content { padding:20px 32px 32px; flex:1; }

/* ===== CARDS ===== */
.card-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:14px; }
.subject-card {
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
  padding:18px; cursor:pointer; transition:all .2s; box-shadow:var(--shadow);
}
.subject-card:hover { transform:translateY(-2px); box-shadow:var(--shadow-lg); border-color:var(--red-mid); }
.subject-card-icon { width:38px; height:38px; background:var(--red); border-radius:10px; display:flex; align-items:center; justify-content:center; font-size:18px; margin-bottom:10px; color:#fff; }
.subject-card-title { font-family:var(--font-display); font-size:14px; font-weight:700; margin-bottom:3px; }
.subject-card-sub { font-size:12px; color:var(--text-3); line-height:1.4; }

/* ===== CHAPTER LIST ===== */
.chapter-item {
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-sm);
  padding:14px 16px; display:flex; align-items:center; gap:12px;
  cursor:pointer; transition:all .15s; margin-bottom:8px;
}
.chapter-item:hover { border-color:var(--red); background:var(--red-soft); }
.chapter-badge { font-size:10px; font-weight:700; background:var(--red-soft); color:var(--red); padding:2px 7px; border-radius:20px; flex-shrink:0; }
.chapter-title { font-weight:600; font-size:14px; flex:1; }
.chapter-subs { font-size:11px; color:var(--text-3); margin-top:2px; }
.chevron { color:var(--text-3); font-size:12px; }

/* ===== NOTION ITEM ===== */
.notion-item {
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-sm);
  padding:12px 16px; display:flex; align-items:center; gap:10px;
  cursor:pointer; transition:all .15s; margin-bottom:6px;
}
.notion-item:hover { border-color:var(--red); }

/* ===== CONTENT AREA ===== */
.content-area {
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius); padding:24px; box-shadow:var(--shadow); min-height:200px;
}
.loading-pulse { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; padding:48px; color:var(--text-3); }
.spinner { width:32px; height:32px; border:3px solid var(--border); border-top-color:var(--red); border-radius:50%; animation:spin .7s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }

/* ===== MARKDOWN ===== */
.md-content h1,.md-content h2 { font-family:var(--font-display); color:var(--red); margin:20px 0 10px; }
.md-content h3,.md-content h4 { font-family:var(--font-display); color:var(--text); margin:16px 0 8px; }
.md-content p { margin:8px 0; line-height:1.7; }
.md-content ul,.md-content ol { padding-left:20px; margin:8px 0; }
.md-content li { margin:4px 0; }
.md-content strong { color:var(--red-dark); }
.md-content code { background:var(--surface2); border-radius:5px; padding:1px 6px; font-size:13px; }
.md-content pre { background:var(--surface2); border-radius:10px; padding:14px; overflow-x:auto; margin:10px 0; }
.md-content blockquote { border-left:3px solid var(--red); padding-left:14px; color:var(--text-2); margin:10px 0; }
.md-content table { border-collapse:collapse; width:100%; margin:12px 0; font-size:13px; }
.md-content th,.md-content td { border:1px solid var(--border); padding:8px 12px; }
.md-content th { background:var(--red-soft); color:var(--red-dark); font-weight:700; }
.katex { font-size:1.05em; }
.katex-display { margin:14px 0; overflow-x:auto; }

/* ===== CHAT ===== */
.chat-wrap { display:flex; flex-direction:column; height:calc(100vh - 100px); }
.chat-messages { flex:1; overflow-y:auto; padding:16px; display:flex; flex-direction:column; gap:12px; }
.chat-msg { display:flex; gap:10px; animation:fadeUp .2s ease; }
@keyframes fadeUp { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
.chat-msg.user { flex-direction:row-reverse; }
.chat-avatar { width:30px; height:30px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:13px; flex-shrink:0; overflow:hidden; }
.chat-avatar.ai { background:var(--red); color:#fff; font-weight:700; font-family:var(--font-display); }
.chat-avatar.user { background:var(--surface2); color:var(--text-2); }
.chat-avatar img { width:100%; height:100%; object-fit:cover; }
.chat-bubble { max-width:78%; padding:10px 14px; border-radius:14px; font-size:14px; line-height:1.6; }
.chat-bubble.ai { background:var(--surface); border:1px solid var(--border); border-radius:14px 14px 14px 4px; }
.chat-bubble.user { background:var(--red); color:#fff; border-radius:14px 14px 4px 14px; }
.chat-input-area { padding:12px 16px 16px; border-top:1px solid var(--border); display:flex; gap:10px; align-items:flex-end; }
.chat-input { flex:1; background:var(--surface); border:1px solid var(--border); border-radius:12px; padding:10px 14px; font-family:var(--font-body); font-size:14px; color:var(--text); outline:none; resize:none; min-height:44px; max-height:120px; transition:border-color .2s; }
.chat-input:focus { border-color:var(--red); }
.chat-send { width:40px; height:40px; background:var(--red); border:none; border-radius:10px; cursor:pointer; display:flex; align-items:center; justify-content:center; color:#fff; font-size:16px; flex-shrink:0; transition:background .15s; }
.chat-send:hover { background:var(--red-dark); }
.chat-send:disabled { background:var(--border); cursor:not-allowed; }
.context-badge { background:var(--red-soft); border:1px solid var(--red-mid); border-radius:20px; padding:4px 12px; font-size:12px; color:var(--red); font-weight:600; display:inline-flex; align-items:center; gap:5px; margin-bottom:8px; }

/* ===== SEARCH ===== */
.search-bar { display:flex; align-items:center; gap:10px; background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:10px 16px; margin-bottom:20px; box-shadow:var(--shadow); }
.search-bar input { flex:1; border:none; outline:none; font-family:var(--font-body); font-size:14px; color:var(--text); background:transparent; }
.search-bar input::placeholder { color:var(--text-3); }

/* ===== TABS ===== */
.tab-bar { display:flex; gap:4px; background:var(--surface2); border-radius:10px; padding:3px; margin-bottom:20px; }
.tab-item { flex:1; padding:7px; text-align:center; border-radius:8px; cursor:pointer; font-size:13px; font-weight:600; color:var(--text-3); transition:all .15s; }
.tab-item.active { background:var(--surface); color:var(--red); box-shadow:0 1px 4px rgba(0,0,0,.08); }

/* ===== FORMS ===== */
.form-group { margin-bottom:16px; }
.form-label { display:block; font-size:12px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--text-3); margin-bottom:6px; }
.form-select,.form-input,.form-textarea { width:100%; background:var(--surface); border:1px solid var(--border); border-radius:10px; padding:9px 12px; font-family:var(--font-body); font-size:14px; color:var(--text); outline:none; transition:border-color .2s; appearance:none; }
.form-select { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239B9894' stroke-width='1.5' fill='none'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 12px center; padding-right:32px; }
.form-select:focus,.form-input:focus,.form-textarea:focus { border-color:var(--red); }
.form-textarea { resize:vertical; min-height:120px; }
.form-row { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.stepper { display:flex; align-items:center; gap:10px; }
.stepper-btn { width:32px; height:32px; background:var(--surface2); border:1px solid var(--border); border-radius:8px; cursor:pointer; font-size:18px; display:flex; align-items:center; justify-content:center; color:var(--text-2); transition:all .15s; line-height:1; }
.stepper-btn:hover { background:var(--red-soft); border-color:var(--red); color:var(--red); }
.stepper-val { font-weight:700; font-size:16px; min-width:28px; text-align:center; }

/* ===== BUTTONS ===== */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:8px; padding:10px 20px; border-radius:10px; font-family:var(--font-body); font-size:14px; font-weight:600; cursor:pointer; border:none; transition:all .15s; }
.btn-primary { background:var(--red); color:#fff; }
.btn-primary:hover { background:var(--red-dark); }
.btn-primary:disabled { background:var(--border); color:var(--text-3); cursor:not-allowed; }
.btn-secondary { background:var(--surface2); color:var(--text-2); border:1px solid var(--border); }
.btn-secondary:hover { background:var(--red-soft); color:var(--red); border-color:var(--red); }
.btn-block { width:100%; }
.btn-save { background:var(--red-soft); color:var(--red); border:1px solid var(--red-mid); }
.btn-save:hover { background:var(--red); color:#fff; }

/* ===== STUDENT PROFILE ===== */
.study-profile-modal {
  position:fixed; inset:0; z-index:2100; background:rgba(10,10,15,.72);
  backdrop-filter:blur(10px); display:flex; align-items:center; justify-content:center;
  padding:24px; animation:fadeIn .2s;
}
.study-profile-card {
  width:min(640px,100%); max-height:88vh; overflow:auto;
  background:var(--surface); border:1px solid var(--border); border-radius:16px;
  box-shadow:0 32px 80px rgba(0,0,0,.24); padding:28px; position:relative;
}
.study-profile-close {
  position:absolute; top:14px; right:14px; width:32px; height:32px;
  border:none; border-radius:10px; background:var(--surface2); color:var(--text-2);
  cursor:pointer; font-size:14px;
}
.study-profile-kicker,.study-profile-strip-kicker {
  font-size:11px; font-weight:800; letter-spacing:.08em; text-transform:uppercase;
  color:var(--red); margin-bottom:6px;
}
.study-profile-title {
  font-family:var(--font-display); font-size:26px; font-weight:800; line-height:1.1;
  margin-bottom:8px;
}
.study-profile-sub {
  color:var(--text-2); font-size:14px; line-height:1.55; margin-bottom:22px;
}
.study-profile-preview {
  background:var(--bg); border:1px solid var(--border); border-radius:12px;
  padding:14px; margin-bottom:16px; min-height:88px;
}
.study-profile-empty { color:var(--text-3); font-size:14px; text-align:center; padding:20px; }
.study-profile-source { font-size:12px; color:var(--text-3); margin-bottom:8px; }
.study-profile-source a { color:var(--red); font-weight:700; text-decoration:none; }
.study-profile-preview-title { font-weight:800; margin-bottom:10px; }
.study-profile-unit {
  background:var(--surface); border:1px solid var(--border); border-radius:10px;
  padding:10px 12px; margin-bottom:8px;
}
.study-profile-unit div { font-weight:700; font-size:14px; }
.study-profile-unit span { display:block; color:var(--text-3); font-size:12px; line-height:1.45; margin-top:2px; }
.study-profile-tags { display:flex; flex-wrap:wrap; gap:7px; }
.study-profile-tags span {
  display:inline-flex; align-items:center; border:1px solid var(--red-mid);
  background:var(--red-soft); color:var(--red); border-radius:999px;
  padding:4px 10px; font-size:12px; font-weight:700;
}
.study-profile-strip {
  background:var(--surface); border:1px solid var(--border); border-radius:14px;
  padding:14px 16px; margin-bottom:20px; box-shadow:var(--shadow);
  display:flex; align-items:center; justify-content:space-between; gap:14px;
}
.study-profile-strip-title { font-weight:800; font-size:15px; line-height:1.35; }

/* ===== HOMEPAGE WELCOME ===== */
.welcome-card { background:linear-gradient(135deg,var(--red) 0%,#C0141F 100%); border-radius:var(--radius); padding:24px; color:#fff; position:relative; overflow:hidden; margin-bottom:24px; }
.welcome-card::after { content:''; position:absolute; right:-20px; top:-20px; width:140px; height:140px; border-radius:50%; background:rgba(255,255,255,.08); }
.welcome-card-title { font-family:var(--font-display); font-size:22px; font-weight:800; margin-bottom:4px; }
.welcome-card-sub { font-size:13px; opacity:.8; }
.progress-bar-wrap { background:rgba(255,255,255,.2); border-radius:99px; height:6px; margin-top:14px; }
.progress-bar-fill { height:6px; border-radius:99px; background:#fff; transition:width .6s ease; }
.progress-label { font-size:12px; opacity:.8; margin-top:5px; display:flex; justify-content:space-between; }

/* ===== SAVED ITEMS ===== */
.saved-item {
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-sm);
  padding:14px 16px; display:flex; align-items:center; gap:12px;
  cursor:pointer; transition:all .15s; margin-bottom:8px;
}
.saved-item:hover { border-color:var(--red); }
.saved-item-info { flex:1; min-width:0; }
.saved-item-title { font-weight:600; font-size:14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.saved-item-meta { font-size:11px; color:var(--text-3); margin-top:2px; }
.saved-item-del { background:none; border:none; cursor:pointer; color:var(--text-3); font-size:16px; padding:4px 6px; border-radius:6px; transition:all .15s; flex-shrink:0; }
.saved-item-del:hover { color:var(--red); background:var(--red-soft); }

/* ===== BACK BUTTON ===== */
.back-btn { display:inline-flex; align-items:center; gap:6px; color:var(--text-3); cursor:pointer; font-size:13px; font-weight:500; margin-bottom:16px; padding:4px 0; transition:color .15s; }
.back-btn:hover { color:var(--red); }

/* ===== TOAST ===== */
.toast { position:fixed; bottom:24px; right:24px; background:var(--text); color:#fff; padding:10px 18px; border-radius:10px; font-size:13px; font-weight:500; z-index:9999; animation:toastIn .3s ease; box-shadow:var(--shadow-lg); }
@keyframes toastIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

/* ===== CONFIG BANNER ===== */
.config-banner {
  background:#fffbeb; border:1px solid #fde68a; border-radius:12px;
  padding:14px 18px; margin-bottom:20px; font-size:13px; color:#92400e;
  display:none;
}
.config-banner.show { display:block; }
.config-banner code { background:#fef3c7; padding:2px 6px; border-radius:4px; font-size:12px; }

/* ===== FILE UPLOAD IN CHAT ===== */
.chat-input-area { position:relative; }
.chat-attach-bar {
  display:flex; gap:6px; padding:8px 16px 0;
  flex-wrap:wrap;
}
.attach-btn {
  display:inline-flex; align-items:center; gap:5px;
  background:var(--surface2); border:1px solid var(--border);
  border-radius:8px; padding:5px 10px; font-size:12px; font-weight:600;
  color:var(--text-2); cursor:pointer; transition:all .15s;
}
.attach-btn:hover { background:var(--red-soft); color:var(--red); border-color:var(--red); }
.attach-preview {
  display:flex; flex-wrap:wrap; gap:8px;
  padding:8px 16px 0;
}
.attach-preview-item {
  position:relative; background:var(--surface2);
  border:1px solid var(--border); border-radius:10px;
  padding:6px 10px; font-size:12px; display:flex; align-items:center; gap:6px;
  max-width:200px;
}
.attach-preview-item img {
  width:40px; height:40px; object-fit:cover; border-radius:6px;
}
.attach-preview-item .attach-name {
  flex:1; min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.attach-remove {
  background:none; border:none; cursor:pointer; color:var(--text-3);
  font-size:14px; padding:0; line-height:1; flex-shrink:0;
}
.attach-remove:hover { color:var(--red); }
.chat-msg-img { max-width:200px; border-radius:10px; margin-top:6px; display:block; }
.chat-msg-file {
  display:inline-flex; align-items:center; gap:6px;
  background:rgba(255,255,255,.15); border-radius:8px;
  padding:4px 10px; font-size:12px; margin-top:4px;
}

@media(max-width:768px){
  .page-content{padding:12px 14px 100px}
  .page-header{padding:14px 14px 0}
  .page-title{font-size:22px}
  .card-grid{grid-template-columns:1fr 1fr}
  .form-row{grid-template-columns:1fr}
  .content-area{padding:16px}
  .chapter-subs{display:none}

  /* Hide sidebar on mobile */
  .sidebar{
    position:fixed; left:0; top:0; bottom:0; z-index:1000;
    transform:translateX(-100%);
    transition:transform .3s cubic-bezier(.4,0,.2,1);
    width:280px;
    box-shadow:var(--shadow-lg);
  }
  .sidebar.open{transform:translateX(0)}

  /* Mobile top header */
  #mobileHeader{display:flex}

  /* Main takes full width, add top padding for header */
  .main{padding-top:0}

  /* Bottom nav */
  #mobileBottomNav{display:flex}

  /* TD layout fix */
  #tdLayout{grid-template-columns:1fr !important; gap:14px}
  #tdPanelWrap{grid-template-columns:1fr !important}
  /* Agenda: stack columns on mobile */
  #agendaLayout { flex-direction: column !important; }
  #agendaLayout > div:first-child { flex: unset !important; width: 100% !important; min-width: unset !important; }

  /* Chat input area */
  .chat-form{padding:8px 12px 8px}

  /* Tour card full width on mobile */
  #tourCard{max-width:calc(100vw - 32px) !important; left:16px !important; right:16px !important; top:auto !important; bottom:90px !important; transform:none !important;}
  #tourArrow{display:none !important}
  #tourHighlight{display:none !important}
}

@media(min-width:769px){
  #mobileHeader{display:none !important}
  #mobileBottomNav{display:none !important}
  #sidebarOverlay{display:none !important}
}

/* ===== FLOATING HAMBURGER (mobile fallback) ===== */
#floatingMenuBtn {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 9999;
  width: 40px;
  height: 40px;
  background: #111;
  border: none;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .2s, transform .2s;
}
#floatingMenuBtn.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.85);
}
@media(max-width:768px) {
  #floatingMenuBtn { display: flex; }
  .app { padding-top: 0 !important; }
  .main { padding-top: 60px !important; padding-bottom: 80px !important; }
  #sidebarCloseBtn { display: flex !important; }
}
#mobileHeader {
  display:none;
  position:fixed; top:0; left:0; right:0; z-index:900;
  height:54px; background:var(--surface);
  border-bottom:1px solid var(--border);
  align-items:center; padding:0 14px; gap:12px;
  box-shadow:0 1px 8px rgba(0,0,0,.06);
}
#mobileMenuBtn {
  width:36px; height:36px; display:flex; align-items:center; justify-content:center;
  background:none; border:none; cursor:pointer; color:var(--text); border-radius:8px;
  font-size:20px;
}
#mobileMenuBtn:active{background:var(--surface2)}
#mobileHeaderTitle {
  flex:1; font-family:var(--font-display); font-weight:700; font-size:16px;
}
#mobileHeaderAvatar {
  width:32px; height:32px; border-radius:50%; background:var(--red-soft);
  color:var(--red); font-weight:700; font-size:14px;
  display:flex; align-items:center; justify-content:center; overflow:hidden; cursor:pointer;
}
#mobileHeaderAvatar img{width:100%;height:100%;object-fit:cover}

/* ===== MOBILE BOTTOM NAV ===== */
#mobileBottomNav {
  display:none;
  position:fixed; bottom:0; left:0; right:0; z-index:900;
  height:64px; background:var(--surface);
  border-top:1px solid var(--border);
  align-items:center; justify-content:space-around;
  padding:0 4px;
  padding-bottom:env(safe-area-inset-bottom, 0px);
  box-shadow:0 -2px 16px rgba(0,0,0,.10);
}
.mob-nav-item {
  display:flex; flex-direction:column; align-items:center; gap:2px;
  padding:6px 8px; border-radius:10px; cursor:pointer;
  color:var(--text-3); transition:all .15s; flex:1; max-width:72px;
  -webkit-tap-highlight-color: transparent;
}
.mob-nav-item.active{ color:var(--red) }
.mob-nav-item.active span:first-child{ transform:scale(1.15) }
.mob-nav-item span:first-child{ font-size:22px; line-height:1; transition:transform .15s }
.mob-nav-label{ font-size:10px; font-weight:600; white-space:nowrap }

/* ===== SIDEBAR OVERLAY ===== */
#sidebarOverlay {
  display:none; position:fixed; inset:0; z-index:999;
  background:rgba(0,0,0,.4);
}

/* Mobile: add top padding to main to account for header */
@media(max-width:768px){
  .app{ padding-top:54px }
  .main{ overflow-y:auto; padding-bottom:80px !important; }
  .page-content{ padding-bottom:20px }
}

/* ===== ONBOARDING TOUR ===== */
#tourOverlay {
  position:fixed; inset:0; z-index:10000; pointer-events:none;
}
#tourBackdrop {
  position:fixed; inset:0; background:rgba(0,0,0,.55); z-index:10001;
  transition: opacity .3s;
}
#tourHighlight {
  position:fixed; z-index:10002; border-radius:12px;
  box-shadow: 0 0 0 4px var(--red), 0 0 0 9999px rgba(0,0,0,.55);
  pointer-events:none;
  transition: all .4s cubic-bezier(.4,0,.2,1);
}
#tourCard {
  position:fixed; z-index:10003; background:#fff; border-radius:16px;
  padding:22px 24px; max-width:320px; min-width:260px;
  box-shadow:0 8px 40px rgba(0,0,0,.22);
  pointer-events:all;
  transition: all .35s cubic-bezier(.4,0,.2,1);
}
#tourCard .tour-step-label {
  font-size:11px; font-weight:700; color:var(--red); letter-spacing:.08em;
  text-transform:uppercase; margin-bottom:6px;
}
#tourCard .tour-title {
  font-family:var(--font-display); font-size:17px; font-weight:800;
  color:var(--text); margin-bottom:8px; line-height:1.3;
}
#tourCard .tour-desc {
  font-size:13px; color:var(--text-2); line-height:1.6; margin-bottom:18px;
}
#tourCard .tour-actions {
  display:flex; align-items:center; justify-content:space-between; gap:10px;
}
#tourCard .tour-dots {
  display:flex; gap:5px; align-items:center;
}
#tourCard .tour-dot {
  width:7px; height:7px; border-radius:50%; background:var(--border);
  transition: background .2s, transform .2s;
}
#tourCard .tour-dot.active {
  background:var(--red); transform:scale(1.25);
}
#tourCard .tour-btn-skip {
  background:none; border:none; font-size:12px; color:var(--text-3);
  cursor:pointer; padding:4px 8px; border-radius:6px;
}
#tourCard .tour-btn-skip:hover { color:var(--red); }
#tourCard .tour-btn-next {
  background:var(--red); color:#fff; border:none; border-radius:10px;
  padding:9px 20px; font-size:13px; font-weight:700; cursor:pointer;
  transition: background .15s;
}
#tourCard .tour-btn-next:hover { background:var(--red-dark); }
#tourArrow {
  position:fixed; z-index:10003; width:14px; height:14px;
  background:#fff; transform:rotate(45deg);
  pointer-events:none;
  transition: all .35s cubic-bezier(.4,0,.2,1);
}
/* ===== PDF EXPORT RENDER AREA ===== */
#tdPrintArea {
  position: fixed; left: -9999px; top: 0;
  width: 794px; /* A4 at 96dpi */
  background: #ffffff;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px; line-height: 1.7; color: #1A1917;
  padding: 48px 56px;
  box-sizing: border-box;
}
#tdPrintArea h1 { font-size: 22px; font-weight: 800; color: #E8192C; margin: 0 0 6px; }
#tdPrintArea h2 { font-size: 16px; font-weight: 700; color: #E8192C; margin: 22px 0 8px; padding-bottom: 5px; border-bottom: 1px solid #f0e0e0; }
#tdPrintArea h3 { font-size: 14px; font-weight: 700; margin: 14px 0 6px; color: #333; }
#tdPrintArea p  { margin: 6px 0; }
#tdPrintArea ul, #tdPrintArea ol { padding-left: 20px; margin: 6px 0; }
#tdPrintArea li { margin: 3px 0; }
#tdPrintArea strong { font-weight: 700; }
#tdPrintArea .katex { font-size: 1em; }
#tdPrintArea .katex-display { margin: 12px 0; overflow: visible; }
#tdPrintArea .pdf-header { margin-bottom: 28px; padding-bottom: 16px; border-bottom: 3px solid #E8192C; }
#tdPrintArea .pdf-logo { font-size: 20px; font-weight: 800; color: #E8192C; margin-bottom: 4px; }
#tdPrintArea .pdf-logo span { color: #1A1917; }
#tdPrintArea .pdf-meta { font-size: 11px; color: #888; }
#tdPrintArea .pdf-section-title { font-size: 13px; font-weight: 700; color: #E8192C; text-transform: uppercase; letter-spacing: .05em; margin: 24px 0 12px; padding: 6px 10px; background: #fff5f5; border-radius: 6px; }
#tdPrintArea .pdf-correction-sep { margin: 32px 0; border: none; border-top: 2px dashed #E8192C; }

/* ===== SUBSCRIPTION / PAYWALL ===== */
.plan-card {
  background:var(--surface); border:2px solid var(--border);
  border-radius:var(--radius); padding:24px; text-align:center;
  transition:all .2s; position:relative;
}
.plan-card.popular { border-color:var(--red); }
.plan-card.popular::before {
  content:'⭐ Populaire'; position:absolute; top:-12px; left:50%; transform:translateX(-50%);
  background:var(--red); color:#fff; font-size:11px; font-weight:700;
  padding:3px 12px; border-radius:20px;
}
.plan-card.current { background:var(--red-soft); border-color:var(--red); }
.plan-name { font-family:var(--font-display); font-size:18px; font-weight:800; margin-bottom:4px; }
.plan-price { font-size:32px; font-weight:800; color:var(--red); margin:12px 0 4px; }
.plan-price span { font-size:14px; font-weight:400; color:var(--text-3); }
.plan-tokens { font-size:13px; color:var(--text-2); margin-bottom:16px; }
.plan-features { text-align:left; font-size:13px; margin-bottom:20px; }
.plan-features li { padding:4px 0; list-style:none; padding-left:20px; position:relative; color:var(--text-2); }
.plan-features li::before { content:'✓'; position:absolute; left:0; color:var(--red); font-weight:700; }

/* Token usage bar */
.token-bar-wrap { background:var(--surface2); border-radius:99px; height:8px; margin:8px 0; overflow:hidden; }
.token-bar-fill { height:100%; border-radius:99px; background:var(--red); transition:width .6s ease; }
.token-bar-fill.warning { background:#f59e0b; }
.token-bar-fill.danger  { background:#ef4444; }
.nav-lock { margin-left:auto; font-size:10px; opacity:.4; }
.nav-lock.unlocked { display:none; }

/* Paywall modal */
.paywall-modal {
  position:fixed; inset:0; z-index:20000; display:flex;
  align-items:center; justify-content:center; padding:16px;
  background:rgba(0,0,0,.6);
}
.paywall-card {
  background:#fff; border-radius:20px; padding:32px 28px;
  max-width:460px; width:100%; box-shadow:var(--shadow-lg); text-align:center;
}
.paywall-icon { font-size:48px; margin-bottom:12px; }
.paywall-title { font-family:var(--font-display); font-size:22px; font-weight:800; margin-bottom:8px; }
.paywall-desc { color:var(--text-2); font-size:14px; margin-bottom:24px; line-height:1.6; }
.paywall-plans { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-bottom:20px; }
.paywall-plan-btn {
  border:2px solid var(--border); border-radius:12px; padding:14px 10px;
  cursor:pointer; transition:all .15s; background:#fff;
}
.paywall-plan-btn:hover, .paywall-plan-btn.selected {
  border-color:var(--red); background:var(--red-soft);
}
.paywall-plan-name { font-weight:700; font-size:14px; }
.paywall-plan-price { font-size:20px; font-weight:800; color:var(--red); }
.paywall-plan-tokens { font-size:11px; color:var(--text-3); }  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(232,25,44,.18) 0%, transparent 70%),
    radial-gradient(ellipse 40% 40% at 20% 80%, rgba(232,25,44,.08) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 80% 80%, rgba(120,60,255,.06) 0%, transparent 60%);
}
.land-hero-grid {
  position:absolute; inset:0; pointer-events:none;
  background-image:linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size:60px 60px;
  mask-image:radial-gradient(ellipse 80% 80% at 50% 50%, black 0%, transparent 100%);
}
.land-hero-badge {
  display:inline-flex; align-items:center; gap:8px;
  padding:6px 16px; border:1px solid rgba(232,25,44,.4);
  border-radius:99px; background:rgba(232,25,44,.08);
  font-size:12px; font-weight:600; color:#E8192C; letter-spacing:.06em;
  text-transform:uppercase; margin-bottom:28px;
}
.land-hero-badge span { width:6px; height:6px; border-radius:50%; background:#E8192C; animation:pulse-dot 2s infinite; }
@keyframes pulse-dot { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.5;transform:scale(1.3)} }
.land-hero h1 {
  font-size:clamp(40px, 7vw, 80px); font-weight:800; line-height:1.08;
  letter-spacing:-.03em; margin-bottom:24px;
  font-family:'DM Sans',sans-serif;
}
.land-hero h1 em { font-style:normal; color:#E8192C; }
.land-hero-sub {
  font-size:clamp(16px,2vw,20px); color:rgba(255,255,255,.55);
  max-width:580px; margin:0 auto 44px; line-height:1.6; font-weight:400;
}
.land-hero-actions { display:flex; gap:16px; justify-content:center; flex-wrap:wrap; }
.btn-hero-primary {
  display:flex; align-items:center; gap:10px;
  padding:15px 32px; background:#E8192C; border:none; border-radius:14px;
  color:#fff; font-size:16px; font-weight:700; cursor:pointer;
  transition:all .25s; box-shadow:0 0 40px rgba(232,25,44,.35);
}
.btn-hero-primary:hover { background:#c8111f; transform:translateY(-2px); box-shadow:0 0 60px rgba(232,25,44,.5); }
.btn-hero-secondary {
  display:flex; align-items:center; gap:10px;
  padding:15px 32px; background:rgba(255,255,255,.06); border:1px solid rgba(255,255,255,.12);
  border-radius:14px; color:#fff; font-size:16px; font-weight:600; cursor:pointer; transition:all .25s;
}
.btn-hero-secondary:hover { background:rgba(255,255,255,.1); transform:translateY(-2px); }
.land-hero-stats {
  display:flex; gap:48px; justify-content:center; flex-wrap:wrap;
  margin-top:64px; padding-top:48px; border-top:1px solid rgba(255,255,255,.08);
}
.land-stat-val { font-size:32px; font-weight:800; color:#fff; }
.land-stat-val span { color:#E8192C; }
.land-stat-label { font-size:13px; color:rgba(255,255,255,.4); margin-top:2px; }

/* FEATURES */
.land-section { padding:100px 48px; max-width:1200px; margin:0 auto; }
.land-section-tag {
  font-size:11px; font-weight:700; letter-spacing:.12em; text-transform:uppercase;
  color:#E8192C; margin-bottom:14px;
}
.land-section-title {
  font-size:clamp(28px,4vw,48px); font-weight:800; line-height:1.1;
  letter-spacing:-.02em; margin-bottom:16px;
}
.land-section-sub { font-size:16px; color:rgba(255,255,255,.5); max-width:540px; line-height:1.6; margin-bottom:56px; }
.features-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(300px,1fr)); gap:20px; }
.feature-card {
  background:rgba(255,255,255,.03); border:1px solid rgba(255,255,255,.07);
  border-radius:20px; padding:28px; transition:all .25s; cursor:default;
}
.feature-card:hover { background:rgba(255,255,255,.06); border-color:rgba(232,25,44,.3); transform:translateY(-4px); }
.feature-icon {
  width:48px; height:48px; border-radius:14px;
  background:rgba(232,25,44,.12); display:flex; align-items:center; justify-content:center;
  font-size:22px; margin-bottom:18px;
}
.feature-title { font-size:17px; font-weight:700; margin-bottom:8px; }
.feature-desc { font-size:14px; color:rgba(255,255,255,.5); line-height:1.6; }
.feature-pills { display:flex; flex-wrap:wrap; gap:6px; margin-top:14px; }
.feature-pill {
  padding:3px 10px; border-radius:99px; font-size:11px; font-weight:600;
  background:rgba(232,25,44,.1); color:#E8192C; border:1px solid rgba(232,25,44,.2);
}

/* PRICING */
.land-pricing { padding:100px 24px; background:rgba(255,255,255,.015); }
.land-pricing-inner { max-width:1100px; margin:0 auto; text-align:center; }
.pricing-toggle {
  display:inline-flex; align-items:center; gap:14px;
  background:rgba(255,255,255,.06); border:1px solid rgba(255,255,255,.1);
  border-radius:99px; padding:6px 20px; margin-bottom:56px;
  font-size:14px; font-weight:600;
}
.pricing-toggle-btn {
  padding:8px 20px; border-radius:99px; cursor:pointer; transition:all .2s;
  background:transparent; border:none; color:rgba(255,255,255,.5); font-size:14px; font-weight:600;
}
.pricing-toggle-btn.active { background:#E8192C; color:#fff; }
.pricing-badge-annual {
  background:rgba(34,197,94,.15); border:1px solid rgba(34,197,94,.3);
  color:#22c55e; font-size:11px; padding:2px 8px; border-radius:99px; font-weight:700;
}
.pricing-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:20px; text-align:left; }
.pricing-card {
  background:rgba(255,255,255,.04); border:1px solid rgba(255,255,255,.08);
  border-radius:24px; padding:32px 28px; position:relative; transition:all .3s;
}
.pricing-card.popular {
  background:rgba(232,25,44,.06); border:2px solid #E8192C;
  transform:scale(1.03);
  box-shadow:0 0 60px rgba(232,25,44,.15);
}
.pricing-card-badge {
  position:absolute; top:-14px; left:50%; transform:translateX(-50%);
  background:#E8192C; color:#fff; font-size:11px; font-weight:800;
  padding:4px 16px; border-radius:99px; white-space:nowrap; letter-spacing:.06em;
}
.pricing-plan-name { font-size:14px; font-weight:700; color:rgba(255,255,255,.5); text-transform:uppercase; letter-spacing:.08em; margin-bottom:10px; }
.pricing-price { font-size:48px; font-weight:800; letter-spacing:-.03em; line-height:1; }
.pricing-price sub { font-size:18px; font-weight:500; color:rgba(255,255,255,.4); vertical-align:super; font-style:normal; }
.pricing-price-period { font-size:13px; color:rgba(255,255,255,.4); margin:4px 0 20px; }
.pricing-divider { border:none; border-top:1px solid rgba(255,255,255,.08); margin:20px 0; }
.pricing-feature { display:flex; align-items:flex-start; gap:10px; margin:10px 0; font-size:14px; color:rgba(255,255,255,.75); }
.pricing-feature .check { color:#E8192C; font-weight:700; flex-shrink:0; margin-top:1px; }
.pricing-feature .cross { color:rgba(255,255,255,.2); flex-shrink:0; margin-top:1px; }
.pricing-feature b { color:#fff; }
.pricing-cta {
  width:100%; padding:14px; border-radius:12px; margin-top:24px;
  font-size:15px; font-weight:700; cursor:pointer; transition:all .2s; border:none;
}
.pricing-cta.free { background:rgba(255,255,255,.08); color:#fff; }
.pricing-cta.free:hover { background:rgba(255,255,255,.14); }
.pricing-cta.paid { background:#E8192C; color:#fff; box-shadow:0 4px 24px rgba(232,25,44,.3); }
.pricing-cta.paid:hover { background:#c8111f; transform:translateY(-1px); }
.pricing-cta.premium { background:linear-gradient(135deg,#7c3aed,#E8192C); color:#fff; }
.pricing-cta.premium:hover { opacity:.9; transform:translateY(-1px); }

/* FOOTER */
.land-footer {
  padding:48px; text-align:center; border-top:1px solid rgba(255,255,255,.06);
  color:rgba(255,255,255,.25); font-size:13px;
}
.land-footer a { color:rgba(255,255,255,.4); text-decoration:none; }

/* LEGAL MODAL */
.legal-modal-overlay {
  position:fixed; inset:0; z-index:2000; background:rgba(0,0,0,.8);
  backdrop-filter:blur(8px); display:flex; align-items:center; justify-content:center;
  padding:24px; animation:fadeIn .2s;
}
.legal-modal-card {
  background:#12121a; border:1px solid rgba(255,255,255,.12); border-radius:20px;
  max-width:680px; width:100%; max-height:80vh; display:flex; flex-direction:column;
  box-shadow:0 32px 80px rgba(0,0,0,.6);
}
.legal-modal-header {
  padding:24px 28px 16px; border-bottom:1px solid rgba(255,255,255,.08);
  display:flex; align-items:center; justify-content:space-between; flex-shrink:0;
}
.legal-modal-title { font-size:18px; font-weight:800; color:#fff; }
.legal-modal-close {
  width:32px; height:32px; background:rgba(255,255,255,.08); border:none;
  border-radius:50%; color:#fff; font-size:16px; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
}
.legal-modal-body {
  padding:24px 28px; overflow-y:auto; flex:1;
  font-size:14px; line-height:1.8; color:rgba(255,255,255,.65);
}
.legal-modal-body h2 { font-size:15px; font-weight:700; color:#fff; margin:20px 0 8px; }
.legal-modal-body h2:first-child { margin-top:0; }
.legal-modal-body p { margin:0 0 12px; }
.legal-modal-body ul { padding-left:20px; margin:0 0 12px; }
.legal-modal-body li { margin:4px 0; }
.legal-modal-body a { color:#E8192C; }

.login-modal-overlay {
  position:fixed; inset:0; z-index:1000; background:rgba(0,0,0,.7);
  backdrop-filter:blur(8px); display:flex; align-items:center; justify-content:center;
  padding:24px; animation:fadeIn .2s;
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
.login-modal-card {
  background:#12121a; border:1px solid rgba(255,255,255,.12); border-radius:24px;
  padding:48px 40px; max-width:420px; width:100%; text-align:center;
  box-shadow:0 32px 80px rgba(0,0,0,.6); animation:slideUp .3s ease;
}
@keyframes slideUp { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }
.login-modal-logo { display:flex; align-items:center; justify-content:center; gap:10px; margin-bottom:28px; }
.login-modal-logo-mark {
  width:44px; height:44px; background:#E8192C; border-radius:13px;
  display:flex; align-items:center; justify-content:center; font-weight:800; font-size:20px; color:#fff;
}
.login-modal-logo-text { font-size:24px; font-weight:800; color:#fff; }
.login-modal-logo-text span { color:#E8192C; }
.login-modal-title { font-size:22px; font-weight:800; color:#fff; margin-bottom:8px; }
.login-modal-sub { font-size:14px; color:rgba(255,255,255,.45); margin-bottom:32px; line-height:1.5; }
.btn-google-dark {
  display:flex; align-items:center; justify-content:center; gap:12px;
  width:100%; padding:14px 20px;
  background:rgba(255,255,255,.06); border:1px solid rgba(255,255,255,.15); border-radius:12px;
  color:#fff; font-size:15px; font-weight:600; cursor:pointer; transition:all .2s;
}
.btn-google-dark:hover { background:rgba(255,255,255,.1); border-color:rgba(255,255,255,.3); }
.login-modal-footer { margin-top:20px; font-size:12px; color:rgba(255,255,255,.25); }
.login-modal-close {
  position:absolute; top:16px; right:16px; width:32px; height:32px;
  background:rgba(255,255,255,.08); border:none; border-radius:50%; color:#fff;
  font-size:16px; cursor:pointer; display:flex; align-items:center; justify-content:center;
}

@media(max-width:768px) {
  .land-nav { padding:16px 20px; }
  .land-nav-links { display:none; }
  .land-hero { padding:100px 20px 60px; }
  .land-section { padding:60px 20px; }
  .pricing-grid { grid-template-columns:1fr; }
  .pricing-card.popular { transform:none; }
  .land-pricing { padding:60px 16px; }
  .land-hero-stats { gap:28px; }
}

/* ===== APP LAYOUT ===== */
#appScreen { display:none; }
.app { display:flex; height:100vh; overflow:hidden; }

/* ===== SIDEBAR ===== */
.sidebar {
  width:240px; flex-shrink:0; background:var(--surface);
  border-right:1px solid var(--border);
  display:flex; flex-direction:column; overflow-y:auto;
}
.sidebar-logo { padding:22px 20px 16px; display:flex; align-items:center; gap:10px; }
.logo-mark {
  width:34px; height:34px; background:var(--red); border-radius:10px;
  display:flex; align-items:center; justify-content:center;
  font-family:var(--font-display); font-weight:800; color:#fff; font-size:16px; flex-shrink:0;
}
.logo-text { font-family:var(--font-display); font-weight:700; font-size:17px; }
.logo-text span { color:var(--red); }
.sidebar-section { padding:6px 12px 4px; font-size:10px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--text-3); margin-top:8px; }
.nav-item {
  display:flex; align-items:center; gap:10px;
  padding:9px 12px; margin:1px 8px; border-radius:var(--radius-sm);
  cursor:pointer; font-size:14px; font-weight:500; color:var(--text-2); transition:all .15s;
}
.nav-item:hover { background:var(--bg); color:var(--text); }
.nav-item.active { background:var(--red-soft); color:var(--red); }
.nav-icon { width:28px; height:28px; display:flex; align-items:center; justify-content:center; font-size:16px; flex-shrink:0; }

/* ===== USER PANEL ===== */
.user-panel {
  margin-top:auto; padding:12px; border-top:1px solid var(--border);
}
.user-card {
  background:var(--bg); border-radius:12px; padding:10px 12px;
  display:flex; align-items:center; gap:10px;
}
.user-avatar {
  width:34px; height:34px; border-radius:50%; background:var(--red-soft);
  overflow:hidden; flex-shrink:0; display:flex; align-items:center; justify-content:center;
  font-size:15px; font-weight:700; color:var(--red);
}
.user-avatar img { width:100%; height:100%; object-fit:cover; }
.user-info { flex:1; min-width:0; }
.user-name { font-size:13px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.user-email { font-size:11px; color:var(--text-3); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sign-out-btn {
  background:none; border:none; cursor:pointer; color:var(--text-3);
  font-size:16px; padding:4px; border-radius:6px; transition:all .15s;
}
.sign-out-btn:hover { color:var(--red); background:var(--red-soft); }

/* ===== MAIN ===== */
.main { flex:1; overflow-y:auto; display:flex; flex-direction:column; }
.page-header { padding:28px 32px 0; }
.page-title { font-family:var(--font-display); font-size:28px; font-weight:800; color:var(--red); line-height:1.1; }
.page-subtitle { color:var(--text-3); font-size:14px; margin-top:4px; }
.page-content { padding:20px 32px 32px; flex:1; }

/* ===== CARDS ===== */
.card-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:14px; }
.subject-card {
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
  padding:18px; cursor:pointer; transition:all .2s; box-shadow:var(--shadow);
}
.subject-card:hover { transform:translateY(-2px); box-shadow:var(--shadow-lg); border-color:var(--red-mid); }
.subject-card-icon { width:38px; height:38px; background:var(--red); border-radius:10px; display:flex; align-items:center; justify-content:center; font-size:18px; margin-bottom:10px; color:#fff; }
.subject-card-title { font-family:var(--font-display); font-size:14px; font-weight:700; margin-bottom:3px; }
.subject-card-sub { font-size:12px; color:var(--text-3); line-height:1.4; }

/* ===== CHAPTER LIST ===== */
.chapter-item {
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-sm);
  padding:14px 16px; display:flex; align-items:center; gap:12px;
  cursor:pointer; transition:all .15s; margin-bottom:8px;
}
.chapter-item:hover { border-color:var(--red); background:var(--red-soft); }
.chapter-badge { font-size:10px; font-weight:700; background:var(--red-soft); color:var(--red); padding:2px 7px; border-radius:20px; flex-shrink:0; }
.chapter-title { font-weight:600; font-size:14px; flex:1; }
.chapter-subs { font-size:11px; color:var(--text-3); margin-top:2px; }
.chevron { color:var(--text-3); font-size:12px; }

/* ===== NOTION ITEM ===== */
.notion-item {
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-sm);
  padding:12px 16px; display:flex; align-items:center; gap:10px;
  cursor:pointer; transition:all .15s; margin-bottom:6px;
}
.notion-item:hover { border-color:var(--red); }

/* ===== CONTENT AREA ===== */
.content-area {
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius); padding:24px; box-shadow:var(--shadow); min-height:200px;
}
.loading-pulse { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; padding:48px; color:var(--text-3); }
.spinner { width:32px; height:32px; border:3px solid var(--border); border-top-color:var(--red); border-radius:50%; animation:spin .7s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }

/* ===== MARKDOWN ===== */
.md-content h1,.md-content h2 { font-family:var(--font-display); color:var(--red); margin:20px 0 10px; }
.md-content h3,.md-content h4 { font-family:var(--font-display); color:var(--text); margin:16px 0 8px; }
.md-content p { margin:8px 0; line-height:1.7; }
.md-content ul,.md-content ol { padding-left:20px; margin:8px 0; }
.md-content li { margin:4px 0; }
.md-content strong { color:var(--red-dark); }
.md-content code { background:var(--surface2); border-radius:5px; padding:1px 6px; font-size:13px; }
.md-content pre { background:var(--surface2); border-radius:10px; padding:14px; overflow-x:auto; margin:10px 0; }
.md-content blockquote { border-left:3px solid var(--red); padding-left:14px; color:var(--text-2); margin:10px 0; }
.md-content table { border-collapse:collapse; width:100%; margin:12px 0; font-size:13px; }
.md-content th,.md-content td { border:1px solid var(--border); padding:8px 12px; }
.md-content th { background:var(--red-soft); color:var(--red-dark); font-weight:700; }
.katex { font-size:1.05em; }
.katex-display { margin:14px 0; overflow-x:auto; }

/* ===== CHAT ===== */
.chat-wrap { display:flex; flex-direction:column; height:calc(100vh - 100px); }
.chat-messages { flex:1; overflow-y:auto; padding:16px; display:flex; flex-direction:column; gap:12px; }
.chat-msg { display:flex; gap:10px; animation:fadeUp .2s ease; }
@keyframes fadeUp { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
.chat-msg.user { flex-direction:row-reverse; }
.chat-avatar { width:30px; height:30px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:13px; flex-shrink:0; overflow:hidden; }
.chat-avatar.ai { background:var(--red); color:#fff; font-weight:700; font-family:var(--font-display); }
.chat-avatar.user { background:var(--surface2); color:var(--text-2); }
.chat-avatar img { width:100%; height:100%; object-fit:cover; }
.chat-bubble { max-width:78%; padding:10px 14px; border-radius:14px; font-size:14px; line-height:1.6; }
.chat-bubble.ai { background:var(--surface); border:1px solid var(--border); border-radius:14px 14px 14px 4px; }
.chat-bubble.user { background:var(--red); color:#fff; border-radius:14px 14px 4px 14px; }
.chat-input-area { padding:12px 16px 16px; border-top:1px solid var(--border); display:flex; gap:10px; align-items:flex-end; }
.chat-input { flex:1; background:var(--surface); border:1px solid var(--border); border-radius:12px; padding:10px 14px; font-family:var(--font-body); font-size:14px; color:var(--text); outline:none; resize:none; min-height:44px; max-height:120px; transition:border-color .2s; }
.chat-input:focus { border-color:var(--red); }
.chat-send { width:40px; height:40px; background:var(--red); border:none; border-radius:10px; cursor:pointer; display:flex; align-items:center; justify-content:center; color:#fff; font-size:16px; flex-shrink:0; transition:background .15s; }
.chat-send:hover { background:var(--red-dark); }
.chat-send:disabled { background:var(--border); cursor:not-allowed; }
.context-badge { background:var(--red-soft); border:1px solid var(--red-mid); border-radius:20px; padding:4px 12px; font-size:12px; color:var(--red); font-weight:600; display:inline-flex; align-items:center; gap:5px; margin-bottom:8px; }

/* ===== SEARCH ===== */
.search-bar { display:flex; align-items:center; gap:10px; background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:10px 16px; margin-bottom:20px; box-shadow:var(--shadow); }
.search-bar input { flex:1; border:none; outline:none; font-family:var(--font-body); font-size:14px; color:var(--text); background:transparent; }
.search-bar input::placeholder { color:var(--text-3); }

/* ===== TABS ===== */
.tab-bar { display:flex; gap:4px; background:var(--surface2); border-radius:10px; padding:3px; margin-bottom:20px; }
.tab-item { flex:1; padding:7px; text-align:center; border-radius:8px; cursor:pointer; font-size:13px; font-weight:600; color:var(--text-3); transition:all .15s; }
.tab-item.active { background:var(--surface); color:var(--red); box-shadow:0 1px 4px rgba(0,0,0,.08); }

/* ===== FORMS ===== */
.form-group { margin-bottom:16px; }
.form-label { display:block; font-size:12px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--text-3); margin-bottom:6px; }
.form-select,.form-input,.form-textarea { width:100%; background:var(--surface); border:1px solid var(--border); border-radius:10px; padding:9px 12px; font-family:var(--font-body); font-size:14px; color:var(--text); outline:none; transition:border-color .2s; appearance:none; }
.form-select { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239B9894' stroke-width='1.5' fill='none'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 12px center; padding-right:32px; }
.form-select:focus,.form-input:focus,.form-textarea:focus { border-color:var(--red); }
.form-textarea { resize:vertical; min-height:120px; }
.form-row { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.stepper { display:flex; align-items:center; gap:10px; }
.stepper-btn { width:32px; height:32px; background:var(--surface2); border:1px solid var(--border); border-radius:8px; cursor:pointer; font-size:18px; display:flex; align-items:center; justify-content:center; color:var(--text-2); transition:all .15s; line-height:1; }
.stepper-btn:hover { background:var(--red-soft); border-color:var(--red); color:var(--red); }
.stepper-val { font-weight:700; font-size:16px; min-width:28px; text-align:center; }

/* ===== BUTTONS ===== */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:8px; padding:10px 20px; border-radius:10px; font-family:var(--font-body); font-size:14px; font-weight:600; cursor:pointer; border:none; transition:all .15s; }
.btn-primary { background:var(--red); color:#fff; }
.btn-primary:hover { background:var(--red-dark); }
.btn-primary:disabled { background:var(--border); color:var(--text-3); cursor:not-allowed; }
.btn-secondary { background:var(--surface2); color:var(--text-2); border:1px solid var(--border); }
.btn-secondary:hover { background:var(--red-soft); color:var(--red); border-color:var(--red); }
.btn-block { width:100%; }
.btn-save { background:var(--red-soft); color:var(--red); border:1px solid var(--red-mid); }
.btn-save:hover { background:var(--red); color:#fff; }

/* ===== HOMEPAGE WELCOME ===== */
.welcome-card { background:linear-gradient(135deg,var(--red) 0%,#C0141F 100%); border-radius:var(--radius); padding:24px; color:#fff; position:relative; overflow:hidden; margin-bottom:24px; }
.welcome-card::after { content:''; position:absolute; right:-20px; top:-20px; width:140px; height:140px; border-radius:50%; background:rgba(255,255,255,.08); }
.welcome-card-title { font-family:var(--font-display); font-size:22px; font-weight:800; margin-bottom:4px; }
.welcome-card-sub { font-size:13px; opacity:.8; }
.progress-bar-wrap { background:rgba(255,255,255,.2); border-radius:99px; height:6px; margin-top:14px; }
.progress-bar-fill { height:6px; border-radius:99px; background:#fff; transition:width .6s ease; }
.progress-label { font-size:12px; opacity:.8; margin-top:5px; display:flex; justify-content:space-between; }

/* ===== SAVED ITEMS ===== */
.saved-item {
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-sm);
  padding:14px 16px; display:flex; align-items:center; gap:12px;
  cursor:pointer; transition:all .15s; margin-bottom:8px;
}
.saved-item:hover { border-color:var(--red); }
.saved-item-info { flex:1; min-width:0; }
.saved-item-title { font-weight:600; font-size:14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.saved-item-meta { font-size:11px; color:var(--text-3); margin-top:2px; }
.saved-item-del { background:none; border:none; cursor:pointer; color:var(--text-3); font-size:16px; padding:4px 6px; border-radius:6px; transition:all .15s; flex-shrink:0; }
.saved-item-del:hover { color:var(--red); background:var(--red-soft); }

/* ===== BACK BUTTON ===== */
.back-btn { display:inline-flex; align-items:center; gap:6px; color:var(--text-3); cursor:pointer; font-size:13px; font-weight:500; margin-bottom:16px; padding:4px 0; transition:color .15s; }
.back-btn:hover { color:var(--red); }

/* ===== TOAST ===== */
.toast { position:fixed; bottom:24px; right:24px; background:var(--text); color:#fff; padding:10px 18px; border-radius:10px; font-size:13px; font-weight:500; z-index:9999; animation:toastIn .3s ease; box-shadow:var(--shadow-lg); }
@keyframes toastIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

/* ===== CONFIG BANNER ===== */
.config-banner {
  background:#fffbeb; border:1px solid #fde68a; border-radius:12px;
  padding:14px 18px; margin-bottom:20px; font-size:13px; color:#92400e;
  display:none;
}
.config-banner.show { display:block; }
.config-banner code { background:#fef3c7; padding:2px 6px; border-radius:4px; font-size:12px; }

/* ===== FILE UPLOAD IN CHAT ===== */
.chat-input-area { position:relative; }
.chat-attach-bar {
  display:flex; gap:6px; padding:8px 16px 0;
  flex-wrap:wrap;
}
.attach-btn {
  display:inline-flex; align-items:center; gap:5px;
  background:var(--surface2); border:1px solid var(--border);
  border-radius:8px; padding:5px 10px; font-size:12px; font-weight:600;
  color:var(--text-2); cursor:pointer; transition:all .15s;
}
.attach-btn:hover { background:var(--red-soft); color:var(--red); border-color:var(--red); }
.attach-preview {
  display:flex; flex-wrap:wrap; gap:8px;
  padding:8px 16px 0;
}
.attach-preview-item {
  position:relative; background:var(--surface2);
  border:1px solid var(--border); border-radius:10px;
  padding:6px 10px; font-size:12px; display:flex; align-items:center; gap:6px;
  max-width:200px;
}
.attach-preview-item img {
  width:40px; height:40px; object-fit:cover; border-radius:6px;
}
.attach-preview-item .attach-name {
  flex:1; min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.attach-remove {
  background:none; border:none; cursor:pointer; color:var(--text-3);
  font-size:14px; padding:0; line-height:1; flex-shrink:0;
}
.attach-remove:hover { color:var(--red); }
.chat-msg-img { max-width:200px; border-radius:10px; margin-top:6px; display:block; }
.chat-msg-file {
  display:inline-flex; align-items:center; gap:6px;
  background:rgba(255,255,255,.15); border-radius:8px;
  padding:4px 10px; font-size:12px; margin-top:4px;
}

@media(max-width:768px){
  .page-content{padding:12px 14px 100px}
  .page-header{padding:14px 14px 0}
  .page-title{font-size:22px}
  .card-grid{grid-template-columns:1fr 1fr}
  .form-row{grid-template-columns:1fr}
  .content-area{padding:16px}
  .chapter-subs{display:none}

  /* Hide sidebar on mobile */
  .sidebar{
    position:fixed; left:0; top:0; bottom:0; z-index:1000;
    transform:translateX(-100%);
    transition:transform .3s cubic-bezier(.4,0,.2,1);
    width:280px;
    box-shadow:var(--shadow-lg);
  }
  .sidebar.open{transform:translateX(0)}

  /* Mobile top header */
  #mobileHeader{display:flex}

  /* Main takes full width, add top padding for header */
  .main{padding-top:0}

  /* Bottom nav */
  #mobileBottomNav{display:flex}

  /* TD layout fix */
  #tdLayout{grid-template-columns:1fr !important; gap:14px}
  #tdPanelWrap{grid-template-columns:1fr !important}
  /* Agenda: stack columns on mobile */
  #agendaLayout { flex-direction: column !important; }
  #agendaLayout > div:first-child { flex: unset !important; width: 100% !important; min-width: unset !important; }

  /* Chat input area */
  .chat-form{padding:8px 12px 8px}

  /* Tour card full width on mobile */
  #tourCard{max-width:calc(100vw - 32px) !important; left:16px !important; right:16px !important; top:auto !important; bottom:90px !important; transform:none !important;}
  #tourArrow{display:none !important}
  #tourHighlight{display:none !important}
}

@media(min-width:769px){
  #mobileHeader{display:none !important}
  #mobileBottomNav{display:none !important}
  #sidebarOverlay{display:none !important}
}

/* ===== FLOATING HAMBURGER (mobile fallback) ===== */
#floatingMenuBtn {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 9999;
  width: 40px;
  height: 40px;
  background: #111;
  border: none;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .2s, transform .2s;
}
#floatingMenuBtn.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.85);
}
@media(max-width:768px) {
  #floatingMenuBtn { display: flex; }
  .app { padding-top: 0 !important; }
  .main { padding-top: 60px !important; padding-bottom: 80px !important; }
  #sidebarCloseBtn { display: flex !important; }
}
#mobileHeader {
  display:none;
  position:fixed; top:0; left:0; right:0; z-index:900;
  height:54px; background:var(--surface);
  border-bottom:1px solid var(--border);
  align-items:center; padding:0 14px; gap:12px;
  box-shadow:0 1px 8px rgba(0,0,0,.06);
}
#mobileMenuBtn {
  width:36px; height:36px; display:flex; align-items:center; justify-content:center;
  background:none; border:none; cursor:pointer; color:var(--text); border-radius:8px;
  font-size:20px;
}
#mobileMenuBtn:active{background:var(--surface2)}
#mobileHeaderTitle {
  flex:1; font-family:var(--font-display); font-weight:700; font-size:16px;
}
#mobileHeaderAvatar {
  width:32px; height:32px; border-radius:50%; background:var(--red-soft);
  color:var(--red); font-weight:700; font-size:14px;
  display:flex; align-items:center; justify-content:center; overflow:hidden; cursor:pointer;
}
#mobileHeaderAvatar img{width:100%;height:100%;object-fit:cover}

/* ===== MOBILE BOTTOM NAV ===== */
#mobileBottomNav {
  display:none;
  position:fixed; bottom:0; left:0; right:0; z-index:900;
  height:64px; background:var(--surface);
  border-top:1px solid var(--border);
  align-items:center; justify-content:space-around;
  padding:0 4px;
  padding-bottom:env(safe-area-inset-bottom, 0px);
  box-shadow:0 -2px 16px rgba(0,0,0,.10);
}
.mob-nav-item {
  display:flex; flex-direction:column; align-items:center; gap:2px;
  padding:6px 8px; border-radius:10px; cursor:pointer;
  color:var(--text-3); transition:all .15s; flex:1; max-width:72px;
  -webkit-tap-highlight-color: transparent;
}
.mob-nav-item.active{ color:var(--red) }
.mob-nav-item.active span:first-child{ transform:scale(1.15) }
.mob-nav-item span:first-child{ font-size:22px; line-height:1; transition:transform .15s }
.mob-nav-label{ font-size:10px; font-weight:600; white-space:nowrap }

/* ===== SIDEBAR OVERLAY ===== */
#sidebarOverlay {
  display:none; position:fixed; inset:0; z-index:999;
  background:rgba(0,0,0,.4);
}

/* Mobile: add top padding to main to account for header */
@media(max-width:768px){
  .app{ padding-top:54px }
  .main{ overflow-y:auto; padding-bottom:80px !important; }
  .page-content{ padding-bottom:20px }
}

/* ===== ONBOARDING TOUR ===== */
#tourOverlay {
  position:fixed; inset:0; z-index:10000; pointer-events:none;
}
#tourBackdrop {
  position:fixed; inset:0; background:rgba(0,0,0,.55); z-index:10001;
  transition: opacity .3s;
}
#tourHighlight {
  position:fixed; z-index:10002; border-radius:12px;
  box-shadow: 0 0 0 4px var(--red), 0 0 0 9999px rgba(0,0,0,.55);
  pointer-events:none;
  transition: all .4s cubic-bezier(.4,0,.2,1);
}
#tourCard {
  position:fixed; z-index:10003; background:#fff; border-radius:16px;
  padding:22px 24px; max-width:320px; min-width:260px;
  box-shadow:0 8px 40px rgba(0,0,0,.22);
  pointer-events:all;
  transition: all .35s cubic-bezier(.4,0,.2,1);
}
#tourCard .tour-step-label {
  font-size:11px; font-weight:700; color:var(--red); letter-spacing:.08em;
  text-transform:uppercase; margin-bottom:6px;
}
#tourCard .tour-title {
  font-family:var(--font-display); font-size:17px; font-weight:800;
  color:var(--text); margin-bottom:8px; line-height:1.3;
}
#tourCard .tour-desc {
  font-size:13px; color:var(--text-2); line-height:1.6; margin-bottom:18px;
}
#tourCard .tour-actions {
  display:flex; align-items:center; justify-content:space-between; gap:10px;
}
#tourCard .tour-dots {
  display:flex; gap:5px; align-items:center;
}
#tourCard .tour-dot {
  width:7px; height:7px; border-radius:50%; background:var(--border);
  transition: background .2s, transform .2s;
}
#tourCard .tour-dot.active {
  background:var(--red); transform:scale(1.25);
}
#tourCard .tour-btn-skip {
  background:none; border:none; font-size:12px; color:var(--text-3);
  cursor:pointer; padding:4px 8px; border-radius:6px;
}
#tourCard .tour-btn-skip:hover { color:var(--red); }
#tourCard .tour-btn-next {
  background:var(--red); color:#fff; border:none; border-radius:10px;
  padding:9px 20px; font-size:13px; font-weight:700; cursor:pointer;
  transition: background .15s;
}
#tourCard .tour-btn-next:hover { background:var(--red-dark); }
#tourArrow {
  position:fixed; z-index:10003; width:14px; height:14px;
  background:#fff; transform:rotate(45deg);
  pointer-events:none;
  transition: all .35s cubic-bezier(.4,0,.2,1);
}
/* ===== PDF EXPORT RENDER AREA ===== */
#tdPrintArea {
  position: fixed; left: -9999px; top: 0;
  width: 794px; /* A4 at 96dpi */
  background: #ffffff;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px; line-height: 1.7; color: #1A1917;
  padding: 48px 56px;
  box-sizing: border-box;
}
#tdPrintArea h1 { font-size: 22px; font-weight: 800; color: #E8192C; margin: 0 0 6px; }
#tdPrintArea h2 { font-size: 16px; font-weight: 700; color: #E8192C; margin: 22px 0 8px; padding-bottom: 5px; border-bottom: 1px solid #f0e0e0; }
#tdPrintArea h3 { font-size: 14px; font-weight: 700; margin: 14px 0 6px; color: #333; }
#tdPrintArea p  { margin: 6px 0; }
#tdPrintArea ul, #tdPrintArea ol { padding-left: 20px; margin: 6px 0; }
#tdPrintArea li { margin: 3px 0; }
#tdPrintArea strong { font-weight: 700; }
#tdPrintArea .katex { font-size: 1em; }
#tdPrintArea .katex-display { margin: 12px 0; overflow: visible; }
#tdPrintArea .pdf-header { margin-bottom: 28px; padding-bottom: 16px; border-bottom: 3px solid #E8192C; }
#tdPrintArea .pdf-logo { font-size: 20px; font-weight: 800; color: #E8192C; margin-bottom: 4px; }
#tdPrintArea .pdf-logo span { color: #1A1917; }
#tdPrintArea .pdf-meta { font-size: 11px; color: #888; }
#tdPrintArea .pdf-section-title { font-size: 13px; font-weight: 700; color: #E8192C; text-transform: uppercase; letter-spacing: .05em; margin: 24px 0 12px; padding: 6px 10px; background: #fff5f5; border-radius: 6px; }
#tdPrintArea .pdf-correction-sep { margin: 32px 0; border: none; border-top: 2px dashed #E8192C; }

/* ===== SUBSCRIPTION / PAYWALL ===== */
.plan-card {
  background:var(--surface); border:2px solid var(--border);
  border-radius:var(--radius); padding:24px; text-align:center;
  transition:all .2s; position:relative;
}
.plan-card.popular { border-color:var(--red); }
.plan-card.popular::before {
  content:'⭐ Populaire'; position:absolute; top:-12px; left:50%; transform:translateX(-50%);
  background:var(--red); color:#fff; font-size:11px; font-weight:700;
  padding:3px 12px; border-radius:20px;
}
.plan-card.current { background:var(--red-soft); border-color:var(--red); }
.plan-name { font-family:var(--font-display); font-size:18px; font-weight:800; margin-bottom:4px; }
.plan-price { font-size:32px; font-weight:800; color:var(--red); margin:12px 0 4px; }
.plan-price span { font-size:14px; font-weight:400; color:var(--text-3); }
.plan-tokens { font-size:13px; color:var(--text-2); margin-bottom:16px; }
.plan-features { text-align:left; font-size:13px; margin-bottom:20px; }
.plan-features li { padding:4px 0; list-style:none; padding-left:20px; position:relative; color:var(--text-2); }
.plan-features li::before { content:'✓'; position:absolute; left:0; color:var(--red); font-weight:700; }

/* Token usage bar */
.token-bar-wrap { background:var(--surface2); border-radius:99px; height:8px; margin:8px 0; overflow:hidden; }
.token-bar-fill { height:100%; border-radius:99px; background:var(--red); transition:width .6s ease; }
.token-bar-fill.warning { background:#f59e0b; }
.token-bar-fill.danger  { background:#ef4444; }
.nav-lock { margin-left:auto; font-size:10px; opacity:.4; }
.nav-lock.unlocked { display:none; }

/* Paywall modal */
.paywall-modal {
  position:fixed; inset:0; z-index:20000; display:flex;
  align-items:center; justify-content:center; padding:16px;
  background:rgba(0,0,0,.6);
}
.paywall-card {
  background:#fff; border-radius:20px; padding:32px 28px;
  max-width:460px; width:100%; box-shadow:var(--shadow-lg); text-align:center;
}
.paywall-icon { font-size:48px; margin-bottom:12px; }
.paywall-title { font-family:var(--font-display); font-size:22px; font-weight:800; margin-bottom:8px; }
.paywall-desc { color:var(--text-2); font-size:14px; margin-bottom:24px; line-height:1.6; }
.paywall-plans { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-bottom:20px; }
.paywall-plan-btn {
  border:2px solid var(--border); border-radius:12px; padding:14px 10px;
  cursor:pointer; transition:all .15s; background:#fff;
}
.paywall-plan-btn:hover, .paywall-plan-btn.selected {
  border-color:var(--red); background:var(--red-soft);
}
.paywall-plan-name { font-weight:700; font-size:14px; }
.paywall-plan-price { font-size:20px; font-weight:800; color:var(--red); }
.paywall-plan-tokens { font-size:11px; color:var(--text-3); }

/* ===== STUDY WORKSPACE ===== */
:root {
  --red:#2867F0;
  --red-dark:#1E4FC5;
  --red-light:#5D8EFF;
  --red-soft:#EDF3FF;
  --red-mid:#CFE0FF;
  --bg:#F6F7FB;
  --surface:#FFFFFF;
  --surface2:#F0F2F7;
  --text:#171B24;
  --text-2:#4C5565;
  --text-3:#7B8494;
  --border:#E2E6EE;
  --shadow:0 8px 24px rgba(30,42,65,.06);
  --shadow-lg:0 18px 42px rgba(30,42,65,.12);
  --radius:8px;
  --radius-sm:6px;
}

body { background:var(--bg); }
.app { background:var(--bg); }
.sidebar {
  width:264px;
  padding:10px 10px 12px;
  background:#FFFFFF;
  border-right:1px solid var(--border);
  transition:width .2s ease, padding .2s ease;
}
.sidebar-logo { padding:10px 8px 22px; min-height:56px; }
.logo-mark {
  width:32px;
  height:32px;
  border-radius:8px;
  background:var(--red);
  box-shadow:none;
}
.logo-text { font-size:18px; letter-spacing:0; }
.sidebar-collapse-btn {
  width:28px;
  height:28px;
  margin-left:auto;
  border:1px solid var(--border);
  border-radius:6px;
  color:var(--text-2);
  background:var(--surface);
  cursor:pointer;
  line-height:1;
  font-size:15px;
}
.sidebar-collapse-btn:hover { background:var(--red-soft); color:var(--red); border-color:var(--red-mid); }
.sidebar-section { padding:12px 10px 5px; margin-top:4px; letter-spacing:0; color:var(--text-3); }
.nav-item {
  min-height:42px;
  padding:7px 10px;
  margin:2px 0;
  border-radius:6px;
  color:var(--text-2);
  font-size:13px;
}
.nav-item:hover { background:#F4F6FA; color:var(--text); }
.nav-item.active { background:var(--red-soft); color:var(--red); font-weight:700; }
.nav-icon { width:24px; height:24px; font-size:15px; }
.user-panel { padding:12px 2px 0; border-top:1px solid var(--border); }
.user-card { background:#F4F6FA; border-radius:8px; }
.token-bar-wrap { background:#E7EBF2; }
.token-bar-fill { background:var(--red); }

@media (min-width:769px) {
  .sidebar-collapsed .sidebar { width:72px; padding-left:10px; padding-right:10px; overflow:hidden; }
  .sidebar-collapsed .sidebar-logo { justify-content:center; padding-left:0; padding-right:0; }
  .sidebar-collapsed .logo-text,
  .sidebar-collapsed .sidebar-section,
  .sidebar-collapsed .user-info,
  .sidebar-collapsed .user-panel > div:first-child,
  .sidebar-collapsed .nav-lock { display:none; }
  .sidebar-collapsed .sidebar-collapse-btn { margin-left:0; }
  .sidebar-collapsed .nav-item { justify-content:center; padding:8px; font-size:0; }
  .sidebar-collapsed .nav-icon { width:26px; height:26px; font-size:16px; }
  .sidebar-collapsed .user-card { justify-content:center; padding:9px; }
  .sidebar-collapsed .sign-out-btn { display:none; }
}

.main { background:var(--bg); }
.page-header { padding:32px 40px 0; }
.page-title { color:var(--text); letter-spacing:0; }
.page-content { padding:22px 40px 40px; }

.study-page {
  width:min(1360px,100%);
  margin:0 auto;
  padding:36px 40px 48px;
}
.study-page-heading {
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:20px;
  margin-bottom:28px;
}
.study-eyebrow {
  margin-bottom:7px;
  color:var(--text-3);
  font-size:11px;
  font-weight:800;
  letter-spacing:0;
  line-height:1.2;
}
.study-page-heading h1,
.study-section-heading h2,
.study-panel-heading h2,
.study-tutor-card h2 {
  margin:0;
  color:var(--text);
  font-family:var(--font-display);
  font-weight:800;
  letter-spacing:0;
  line-height:1.15;
}
.study-page-heading h1 { font-size:30px; }
.study-page-heading p { margin:8px 0 0; color:var(--text-2); font-size:14px; }
.study-heading-actions { display:flex; align-items:center; gap:10px; flex-shrink:0; }
.study-primary-btn,
.study-quiet-btn,
.study-text-btn,
.study-profile-line button,
.study-subject-tile,
.study-tutor-prompts button {
  font-family:var(--font-body);
  letter-spacing:0;
}
.study-primary-btn,
.study-quiet-btn {
  min-height:38px;
  padding:8px 13px;
  border-radius:6px;
  border:1px solid transparent;
  cursor:pointer;
  font-size:13px;
  font-weight:700;
  transition:background .15s ease, border-color .15s ease, transform .15s ease;
}
.study-primary-btn { background:var(--red); color:#fff; }
.study-primary-btn:hover { background:var(--red-dark); transform:translateY(-1px); }
.study-quiet-btn { background:#fff; border-color:var(--border); color:var(--text-2); }
.study-quiet-btn:hover { background:var(--surface2); color:var(--text); }
.study-text-btn {
  padding:0;
  border:0;
  background:transparent;
  color:var(--red);
  font-size:13px;
  font-weight:700;
  cursor:pointer;
  text-align:left;
}
.study-text-btn:hover { color:var(--red-dark); }
.study-profile-line {
  display:flex;
  align-items:center;
  gap:8px;
  width:fit-content;
  max-width:100%;
  margin:-14px 0 20px;
  color:var(--text-3);
  font-size:12px;
}
.study-profile-line strong { color:var(--text-2); font-weight:700; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.study-profile-line button { padding:0; border:0; background:transparent; color:var(--red); font-size:12px; font-weight:700; cursor:pointer; }

.study-focus-grid { display:grid; grid-template-columns:minmax(0,1.55fr) minmax(260px,.75fr); gap:16px; margin-bottom:16px; }
.study-resume-card,
.study-goal-card,
.study-metric,
.study-panel,
.study-subject-tile,
.study-score-card {
  border:1px solid var(--border);
  border-radius:8px;
  background:var(--surface);
  box-shadow:var(--shadow);
}
.study-resume-card { padding:24px; }
.study-card-kicker { color:var(--text-3); font-size:11px; font-weight:800; letter-spacing:0; }
.study-resume-main { display:flex; align-items:flex-start; gap:15px; margin-top:18px; }
.study-resume-icon,
.study-subject-icon {
  display:grid;
  place-items:center;
  flex-shrink:0;
  width:42px;
  height:42px;
  border-radius:8px;
  background:var(--red-soft);
  color:var(--red);
  font-size:20px;
}
.study-resume-subject { color:var(--red); font-size:12px; font-weight:800; }
.study-resume-card h2 { margin:2px 0 5px; color:var(--text); font-family:var(--font-display); font-size:21px; line-height:1.2; letter-spacing:0; }
.study-resume-card p { margin:0; color:var(--text-2); font-size:13px; }
.study-resume-footer { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:22px; }
.study-time-pill { color:var(--text-2); font-size:12px; font-weight:700; }
.study-goal-card { padding:24px; background:#EAF1FF; border-color:#D5E3FF; }
.study-goal-count { display:flex; align-items:baseline; gap:5px; margin:18px 0 10px; }
.study-goal-count strong { color:var(--text); font-family:var(--font-display); font-size:34px; line-height:1; }
.study-goal-count span { color:var(--text-2); font-size:13px; }
.study-goal-track,
.study-inline-progress,
.study-row-progress { overflow:hidden; background:#DAE3F3; border-radius:99px; }
.study-goal-track { height:7px; }
.study-goal-track div { height:100%; background:var(--red); border-radius:99px; transition:width .45s ease; }
.study-goal-card p { min-height:39px; margin:13px 0 8px; color:var(--text-2); font-size:12px; line-height:1.55; }

.study-metrics { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; margin-bottom:32px; }
.study-metric { min-height:132px; padding:19px 20px; display:flex; flex-direction:column; align-items:flex-start; }
.study-metric > span { color:var(--text-3); font-size:12px; font-weight:700; }
.study-metric > strong { margin:7px 0 3px; color:var(--text); font-family:var(--font-display); font-size:25px; line-height:1; letter-spacing:0; }
.study-metric > small { color:var(--text-2); font-size:12px; }
.study-inline-progress { width:100%; height:6px; margin-top:12px; background:var(--surface2); }
.study-inline-progress span { display:block; height:100%; border-radius:99px; background:var(--red); transition:width .45s ease; }
.study-metric-action { justify-content:space-between; background:#FFF7E5; border-color:#F2E2B8; }
.study-metric-action strong { margin-bottom:auto; }

.study-content-grid { display:grid; grid-template-columns:minmax(0,1fr) minmax(280px,.38fr); align-items:start; gap:30px; }
.study-section-heading,
.study-panel-heading { display:flex; align-items:flex-end; justify-content:space-between; gap:16px; margin-bottom:15px; }
.study-section-heading h2,
.study-panel-heading h2 { font-size:19px; }
.study-subject-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.study-subject-tile {
  display:grid;
  grid-template-columns:42px minmax(0,1fr) auto;
  align-items:center;
  gap:12px;
  min-height:82px;
  padding:13px;
  color:var(--text);
  cursor:pointer;
  text-align:left;
  transition:border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.study-subject-tile:hover { border-color:var(--red-mid); box-shadow:var(--shadow-lg); transform:translateY(-1px); }
.study-subject-copy { min-width:0; display:flex; flex-direction:column; gap:3px; }
.study-subject-copy strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:13px; }
.study-subject-copy small { overflow:hidden; color:var(--text-3); font-size:11px; text-overflow:ellipsis; white-space:nowrap; }
.study-subject-arrow { color:var(--text-3); font-size:16px; }
.study-tutor-card { padding:23px; border-radius:8px; background:#153D45; color:#fff; }
.study-tutor-topline { display:flex; align-items:center; gap:8px; color:#CDE5E7; font-size:11px; font-weight:800; letter-spacing:0; }
.study-ai-mark { display:grid; place-items:center; width:26px; height:26px; border-radius:6px; background:#C4F04B; color:#153D45; font-size:10px; }
.study-tutor-card h2 { margin:18px 0 10px; color:#fff; font-size:21px; }
.study-tutor-card p { margin:0; color:#D0E2E5; font-size:13px; line-height:1.6; }
.study-tutor-prompts { display:flex; flex-direction:column; align-items:stretch; gap:8px; margin:20px 0; }
.study-tutor-prompts button { padding:9px 10px; border:1px solid rgba(255,255,255,.2); border-radius:6px; background:rgba(255,255,255,.08); color:#fff; cursor:pointer; font-size:12px; text-align:left; }
.study-tutor-prompts button:hover { background:rgba(255,255,255,.14); }
.study-tutor-cta { width:100%; }

.study-dashboard .study-page-heading { margin-bottom:26px; }
.study-dashboard-metrics { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; margin-bottom:16px; }
.study-stat-card { min-height:130px; padding:18px; border:1px solid var(--border); border-radius:8px; background:var(--surface); box-shadow:var(--shadow); }
.study-stat-card > span { display:block; color:var(--text-3); font-size:12px; font-weight:700; }
.study-stat-card > strong { display:block; margin:15px 0 8px; color:var(--text); font-family:var(--font-display); font-size:29px; line-height:1; letter-spacing:0; }
.study-stat-card > small { display:block; color:var(--text-2); font-size:11px; line-height:1.35; }
.study-stat-card-accent { background:#FFF7E5; border-color:#F2E2B8; }
.study-dashboard-grid { display:grid; grid-template-columns:minmax(0,1.2fr) minmax(300px,.8fr); gap:16px; margin-bottom:30px; }
.study-panel { padding:22px; min-height:310px; }
.study-progress-list { display:flex; flex-direction:column; gap:19px; margin-top:26px; }
.study-progress-row { display:grid; grid-template-columns:minmax(110px,.8fr) minmax(100px,1.5fr) 38px; align-items:center; gap:12px; }
.study-progress-copy { display:flex; flex-direction:column; min-width:0; gap:2px; }
.study-progress-copy strong { overflow:hidden; font-size:13px; text-overflow:ellipsis; white-space:nowrap; }
.study-progress-copy span { color:var(--text-3); font-size:11px; }
.study-row-progress { height:7px; background:var(--surface2); }
.study-row-progress span { display:block; height:100%; border-radius:99px; transition:width .45s ease; }
.study-progress-row > b { color:var(--text-2); font-size:12px; text-align:right; }
.study-activity-list { display:flex; flex-direction:column; margin-top:8px; }
.study-activity-item { display:flex; align-items:center; gap:10px; min-height:47px; padding:9px 0; border-bottom:1px solid var(--border); }
.study-activity-item:last-child { border-bottom:0; }
.study-activity-kind { flex-shrink:0; min-width:53px; padding:3px 6px; border-radius:4px; background:var(--red-soft); color:var(--red); font-size:10px; font-weight:800; text-align:center; }
.study-activity-item div { display:flex; flex:1; align-items:baseline; justify-content:space-between; gap:8px; min-width:0; }
.study-activity-item strong { overflow:hidden; font-size:12px; text-overflow:ellipsis; white-space:nowrap; }
.study-activity-item div span { flex-shrink:0; color:var(--text-3); font-size:11px; }
.study-score-section { margin-top:4px; }
.study-score-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; }
.study-score-card { min-height:116px; padding:17px; display:flex; flex-direction:column; }
.study-score-card > strong { font-family:var(--font-display); font-size:26px; letter-spacing:0; line-height:1; }
.study-score-card > span { margin:9px 0 2px; color:var(--text-2); font-size:12px; font-weight:700; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.study-score-card > small { color:var(--text-3); font-size:11px; }
.study-score-card.score-high > strong { color:#008B6E; }
.study-score-card.score-mid > strong { color:#B87900; }
.study-score-card.score-low > strong { color:#D84B5A; }
.study-empty-state { display:grid; place-items:center; min-height:176px; padding:24px; color:var(--text-3); font-size:13px; line-height:1.6; text-align:center; }
.study-empty-state-wide { min-height:116px; border:1px dashed var(--border); border-radius:8px; background:rgba(255,255,255,.55); }
.share-source-note { margin-top:6px; color:var(--text-3); font-size:11px; line-height:1.45; }

@media (max-width:1100px) {
  .study-content-grid { grid-template-columns:1fr; gap:28px; }
  .study-tutor-card { max-width:none; }
  .study-dashboard-metrics { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .study-score-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
}
@media (max-width:768px) {
  .sidebar { width:264px; padding:10px; }
  .sidebar-collapse-btn { display:none; }
  .study-page { padding:24px 18px 92px; }
  .study-page-heading { align-items:flex-start; flex-direction:column; margin-bottom:24px; }
  .study-page-heading h1 { font-size:27px; }
  .study-heading-actions { width:100%; }
  .study-heading-actions button { flex:1; }
  .study-profile-line { align-items:flex-start; flex-wrap:wrap; margin-top:-8px; }
  .study-focus-grid,
  .study-dashboard-grid { grid-template-columns:1fr; }
  .study-metrics { grid-template-columns:1fr; }
  .study-metric { min-height:112px; }
  .study-subject-grid { grid-template-columns:1fr; }
  .study-dashboard-metrics { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .study-stat-card { min-height:116px; padding:15px; }
  .study-stat-card > strong { font-size:25px; }
  .study-panel { min-height:auto; padding:18px; }
  .study-panel-heading,
  .study-section-heading { align-items:flex-start; flex-direction:column; gap:8px; }
  .study-progress-row { grid-template-columns:minmax(94px,.8fr) minmax(72px,1.2fr) 34px; gap:8px; }
  .study-score-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}

/* ===== UNIFIED PUBLIC PALETTE ===== */
/* The public entry points share the workspace blue, surfaces, and contrast levels. */
#authScreen {
  background:var(--bg);
  color:var(--text);
}
.land-nav {
  background:rgba(255,255,255,.94);
  border-bottom-color:var(--border);
}
.land-nav-logo-mark,
.btn-land-red,
.btn-hero-primary,
.pricing-toggle-btn.active,
.pricing-card-badge,
.pricing-cta.paid,
.login-modal-logo-mark {
  background:var(--red);
}
.land-nav-logo-text span,
.land-hero h1 em,
.land-section-tag,
.feature-pill,
.pricing-feature .check,
.login-modal-logo-text span,
.legal-modal-body a {
  color:var(--red);
}
.land-nav-links a { color:var(--text-2); }
.land-nav-links a:hover { color:var(--red); }
.btn-land-ghost {
  border-color:var(--border);
  background:var(--surface);
  color:var(--text-2);
}
.btn-land-ghost:hover {
  border-color:var(--red-mid);
  background:var(--red-soft);
  color:var(--red);
}
.btn-land-red:hover,
.btn-hero-primary:hover,
.pricing-cta.paid:hover { background:var(--red-dark); }

.land-hero {
  min-height:calc(100vh - 1px);
  background:var(--bg);
  border-bottom:1px solid var(--border);
}
.land-hero-bg,
.land-hero-grid { display:none; }
.land-hero-badge {
  border-color:var(--red-mid);
  background:var(--red-soft);
  color:var(--red);
}
.land-hero-badge span { background:var(--red); }
.land-hero h1,
.land-stat-val { color:var(--text); }
.land-hero-sub,
.land-section-sub { color:var(--text-2); }
.btn-hero-primary { box-shadow:0 8px 22px rgba(40,103,240,.2); }
.btn-hero-primary:hover { box-shadow:0 10px 26px rgba(40,103,240,.28); }
.btn-hero-secondary {
  background:var(--surface);
  border-color:var(--border);
  color:var(--text-2);
}
.btn-hero-secondary:hover { background:var(--surface2); color:var(--text); }
.land-hero-stats { border-top-color:var(--border); }
.land-stat-val span { color:var(--red); }
.land-stat-label { color:var(--text-3); }

.feature-card,
.pricing-card {
  background:var(--surface);
  border-color:var(--border);
  box-shadow:var(--shadow);
}
.feature-card:hover {
  background:var(--surface);
  border-color:var(--red-mid);
}
.feature-icon,
.feature-pill {
  background:var(--red-soft);
  border-color:var(--red-mid);
}
.feature-title,
.pricing-price { color:var(--text); }
.feature-desc,
.pricing-plan-name,
.pricing-price sub,
.pricing-price-period,
.pricing-feature { color:var(--text-2); }
.pricing-feature b { color:var(--text); }
.land-pricing { background:var(--surface2); }
.pricing-toggle {
  background:var(--surface);
  border-color:var(--border);
}
.pricing-toggle-btn { color:var(--text-2); }
.pricing-card.popular {
  background:var(--surface);
  border-color:var(--red);
  box-shadow:0 12px 30px rgba(40,103,240,.14);
}
.pricing-divider { border-top-color:var(--border); }
.pricing-cta.free {
  background:var(--surface2);
  color:var(--text-2);
}
.pricing-cta.free:hover { background:var(--red-soft); color:var(--red); }
.pricing-cta.premium,
.pricing-cta.premium:hover { background:var(--red-dark); }
.land-pricing-note { color:var(--text-3); }

.land-footer {
  background:var(--surface);
  border-top-color:var(--border);
  color:var(--text-3);
}
.land-footer a { color:var(--text-2); }
.land-footer a:hover { color:var(--red); }
.land-footer-brand { color:var(--text-2); }
.land-footer-brand span { color:var(--red); }

.login-modal-overlay,
.legal-modal-overlay { background:rgba(23,27,36,.42); }
.login-modal-card,
.legal-modal-card {
  background:var(--surface);
  border-color:var(--border);
  box-shadow:var(--shadow-lg);
}
.login-modal-title,
.login-modal-logo-text,
.legal-modal-title,
.legal-modal-body h2 { color:var(--text); }
.login-modal-sub,
.legal-modal-body,
.login-modal-footer { color:var(--text-2); }
.btn-google-dark {
  background:var(--surface2);
  border-color:var(--border);
  color:var(--text);
}
.btn-google-dark:hover { background:var(--red-soft); border-color:var(--red-mid); }
.login-modal-close,
.legal-modal-close {
  background:var(--surface2);
  color:var(--text-2);
}
.login-modal-footer a { color:var(--text-2) !important; }

#tdPrintArea h1,
#tdPrintArea h2,
#tdPrintArea .pdf-logo { color:var(--red); }
#tdPrintArea .pdf-header { border-bottom-color:var(--red); }
#tdPrintArea .pdf-section-title {
  background:var(--red-soft);
  color:var(--red);
}
#tdPrintArea .pdf-correction-sep { border-top-color:var(--red); }
