@import url('https://fonts.googleapis.com/css2?family=Cabinet+Grotesk:wght@400;500;700;800;900&family=Satoshi:wght@400;500;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:       #F5F3EE;
  --bg2:      #FFFFFF;
  --bg3:      #EFEDE7;
  --bg4:      #E8E5DD;
  --border:   rgba(0,0,0,0.08);
  --border2:  rgba(0,0,0,0.14);
  --text:     #1A1814;
  --text2:    #6B6760;
  --text3:    #9E9B96;
  --accent:   #2563EB;
  --accent-s: #1D4ED8;
  --ai:       #7C3AED;
  --ai-s:     #6D28D9;
  --green:    #059669;
  --amber:    #D97706;
  --coral:    #DC2626;
  --sidebar-w: 260px;
  --topbar-h:  60px;
  --font-d:   'Cabinet Grotesk', sans-serif;
  --font-b:   'Satoshi', sans-serif;
  --font-m:   'JetBrains Mono', monospace;
  --r:        12px;
  --r-sm:     8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-b);
  font-size: 15px;
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
}

/* ── LAYOUT ── */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 0 2rem;
  transition: transform 0.3s cubic-bezier(.4,0,.2,1);
  z-index: 300;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 1.2rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--bg2); z-index: 10;
}
.logo-mark {
  width: 32px; height: 32px;
  background: var(--text); color: var(--bg2);
  border-radius: 8px; display: flex;
  align-items: center; justify-content: center;
  font-family: var(--font-d); font-weight: 900;
  font-size: 1rem; letter-spacing: -0.05em;
}
.logo-text {
  font-family: var(--font-d); font-weight: 800;
  font-size: 1.1rem; color: var(--text); letter-spacing: -0.03em;
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.user-avatar {
  width: 36px; height: 36px;
  background: var(--bg3); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.9rem; color: var(--text2); flex-shrink: 0;
}
.user-name  { font-weight: 600; font-size: 0.9rem; color: var(--text); }
.user-class { font-size: 0.75rem; color: var(--text3); }

.sidebar-nav { padding: 0.75rem; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 0.6rem 0.75rem; border-radius: var(--r-sm);
  color: var(--text2); text-decoration: none;
  font-size: 0.88rem; font-weight: 500;
  transition: all 0.15s; position: relative;
}
.nav-item:hover  { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--text); color: #fff; }
.nav-item.active .nav-icon { color: #fff; }
.nav-item-ai       { color: var(--ai) !important; }
.nav-item-ai:hover { background: rgba(124,58,237,0.08) !important; }
.nav-icon  { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: var(--ai); color: #fff;
  font-size: 0.62rem; font-weight: 700; padding: 0.15rem 0.4rem;
  border-radius: 4px; letter-spacing: 0.05em;
}
.sidebar-boards {
  padding: 1rem 1.25rem; border-top: 1px solid var(--border); margin-top: auto;
}
.sidebar-section-label {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--text3); margin-bottom: 0.6rem;
}
.board-select {
  width: 100%; background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--r-sm); color: var(--text); font-family: var(--font-b);
  font-size: 0.82rem; padding: 0.55rem 0.75rem; cursor: pointer; outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%239E9B96' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.75rem center;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 299;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ── MAIN ── */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ── TOPBAR ── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.5rem; flex-shrink: 0;
  position: sticky; top: 0; z-index: 100;
}
/*.mobile-toggle { display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text); padding: 4px; }*/
.mobile-toggle { display: flex; align-items: center; background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text); padding: 4px; }
.topbar-search {
  flex: 1; max-width: 480px;
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--r-sm); padding: 0 0.75rem; height: 38px;
}
.search-icon  { color: var(--text3); font-size: 1.1rem; }
.search-input { flex: 1; background: none; border: none; outline: none; font-family: var(--font-b); font-size: 0.88rem; color: var(--text); }
.search-input::placeholder { color: var(--text3); }
.search-shortcut {
  font-family: var(--font-m); font-size: 0.7rem; color: var(--text3);
  background: var(--bg4); padding: 0.1rem 0.4rem;
  border-radius: 4px; border: 1px solid var(--border2);
}
.topbar-right { display: flex; align-items: center; gap: 0.75rem; margin-left: auto; }
.ai-btn {
  background: var(--ai); color: #fff; padding: 0.45rem 1rem;
  border-radius: var(--r-sm); font-size: 0.85rem; font-weight: 700;
  text-decoration: none; font-family: var(--font-d); transition: background 0.15s;
}
.ai-btn:hover { background: var(--ai-s); }
.streak-badge {
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--r-sm); padding: 0.4rem 0.8rem;
  font-size: 0.82rem; font-weight: 600; color: var(--text2);
}

/* ── CONTENT SCROLL ── */
.content-scroll { flex: 1; overflow-y: auto; padding: 1.5rem; }

/* ── DAILY GOAL ── */
.daily-goal-bar {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 1rem 1.25rem;
  display: flex; align-items: center; gap: 1.5rem; margin-bottom: 1.25rem;
}
.goal-left  { flex-shrink: 0; }
.goal-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text3); display: block; }
.goal-count { font-family: var(--font-d); font-weight: 800; font-size: 1rem; color: var(--text); }
.goal-count b { color: var(--accent); }
.goal-track { flex: 1; height: 8px; background: var(--bg3); border-radius: 99px; position: relative; }
.goal-fill  { height: 100%; background: linear-gradient(90deg, var(--accent), #60a5fa); border-radius: 99px; transition: width 0.5s ease; }
.goal-milestones { position: absolute; top: 0; left: 0; right: 0; height: 100%; }
.milestone { position: absolute; top: 14px; transform: translateX(-50%); font-size: 0.65rem; color: var(--text3); font-family: var(--font-m); }

/* ── QUICK BANNER ── */
.quick-banner {
  background: var(--text); border-radius: var(--r);
  padding: 1.75rem 2rem; display: flex; align-items: center;
  justify-content: space-between; gap: 2rem; margin-bottom: 1.5rem;
  position: relative; overflow: hidden;
}
.quick-banner::before {
  content: ''; position: absolute; top: -40px; right: -40px;
  width: 200px; height: 200px; background: rgba(255,255,255,0.03); border-radius: 50%;
}
.banner-tag {
  display: inline-block; background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.7);
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0.2rem 0.6rem; border-radius: 4px; margin-bottom: 0.6rem;
}
.banner-title { font-family: var(--font-d); font-size: 1.5rem; font-weight: 900; color: #fff; line-height: 1.15; letter-spacing: -0.03em; margin-bottom: 0.4rem; }
.banner-sub   { color: rgba(255,255,255,0.5); font-size: 0.85rem; margin-bottom: 1.1rem; }
.banner-cta {
  display: inline-block; background: #fff; color: var(--text);
  padding: 0.6rem 1.2rem; border-radius: var(--r-sm);
  font-family: var(--font-d); font-weight: 800; font-size: 0.9rem;
  text-decoration: none; transition: opacity 0.15s;
}
.banner-cta:hover { opacity: 0.88; }
.banner-stats { display: flex; gap: 1.5rem; flex-shrink: 0; }
.bstat        { text-align: center; }
.bstat-num    { font-family: var(--font-d); font-size: 1.4rem; font-weight: 900; color: #fff; letter-spacing: -0.03em; }
.bstat-label  { font-size: 0.72rem; color: rgba(255,255,255,0.45); text-transform: uppercase; letter-spacing: 0.08em; }

/* ── SECTIONS ── */
.content-section  { margin-bottom: 2rem; }
.section-header   { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.section-title    { font-family: var(--font-d); font-size: 1.05rem; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.view-all         { font-size: 0.82rem; font-weight: 600; color: var(--accent); text-decoration: none; }
.view-all:hover   { text-decoration: underline; }

/* ── SUBJECT CARDS ── */
.subject-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; }
.subject-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r);
  padding: 1.1rem; text-decoration: none; transition: all 0.18s; position: relative; overflow: hidden;
}
.subject-card:hover { transform: translateY(-2px); border-color: var(--border2); box-shadow: 0 4px 16px rgba(0,0,0,0.07); }
.subject-icon { font-size: 1.5rem; margin-bottom: 0.5rem; display: block; }
.subject-name { font-weight: 700; font-size: 0.88rem; color: var(--text); margin-bottom: 0.2rem; }
.subject-qs   { font-size: 0.75rem; color: var(--text3); font-family: var(--font-m); }

.subject-card--blue .subject-icon   { color: var(--accent); }
.subject-card--green .subject-icon  { color: var(--green); }
.subject-card--amber .subject-icon  { color: var(--amber); }
.subject-card--teal .subject-icon   { color: #0891b2; }
.subject-card--pink .subject-icon   { color: #db2777; }
.subject-card--purple .subject-icon { color: var(--ai); }
.subject-card--coral .subject-icon  { color: var(--coral); }
.subject-card--gray .subject-icon   { color: var(--text2); }

/* ── BOARD CARDS ── */
.board-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.75rem; }
.board-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r);
  padding: 1rem 1.1rem; display: flex; align-items: center; gap: 0.9rem;
  text-decoration: none; transition: all 0.18s;
}
.board-card:hover { border-color: var(--border2); transform: translateY(-1px); box-shadow: 0 3px 12px rgba(0,0,0,0.06); }
.board-card-icon { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.8rem; font-family: var(--font-d); flex-shrink: 0; }
.board-card-icon--blue   { background: #EFF6FF; color: var(--accent); }
.board-card-icon--purple { background: #F5F3FF; color: var(--ai); }
.board-card-icon--amber  { background: #FFFBEB; color: var(--amber); }
.board-card-icon--green  { background: #F0FDF4; color: var(--green); }
.board-card-icon--coral  { background: #FEF2F2; color: var(--coral); }
.board-card-icon--teal   { background: #F0FDFA; color: #0891b2; }
.board-card-name { font-weight: 700; font-size: 0.9rem; color: var(--text); }
.board-card-sub  { font-size: 0.78rem; color: var(--text3); }
.board-card-tag  { margin-left: auto; font-size: 0.68rem; font-weight: 700; color: var(--green); background: #F0FDF4; padding: 0.2rem 0.5rem; border-radius: 4px; white-space: nowrap; flex-shrink: 0; }

/* ── FEATURE ROW ── */
.feature-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; }
.feature-tile { border-radius: var(--r); padding: 1.25rem; text-decoration: none; position: relative; overflow: hidden; transition: all 0.18s; display: flex; flex-direction: column; gap: 0.3rem; }
.feature-tile:hover { transform: translateY(-2px); }
.feature-tile--accent { background: #EFF6FF; border: 1px solid #BFDBFE; }
.feature-tile--ai     { background: #F5F3FF; border: 1px solid #DDD6FE; }
.feature-tile--notes  { background: #FFFBEB; border: 1px solid #FDE68A; }
.feature-tile--rank   { background: #F0FDF4; border: 1px solid #BBF7D0; }
.ftile-icon  { font-size: 1.4rem; margin-bottom: 0.2rem; }
.ftile-name  { font-family: var(--font-d); font-weight: 800; font-size: 0.95rem; }
.ftile-sub   { font-size: 0.78rem; opacity: 0.65; }
.ftile-arrow { position: absolute; top: 1.1rem; right: 1.1rem; font-size: 0.9rem; opacity: 0.4; }
.feature-tile--accent .ftile-name { color: var(--accent); }
.feature-tile--ai     .ftile-name { color: var(--ai); }
.feature-tile--notes  .ftile-name { color: var(--amber); }
.feature-tile--rank   .ftile-name { color: var(--green); }

/* ── ALL BOARDS GRID ── */
.all-boards-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.board-pill { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 0.45rem 0.9rem; font-size: 0.82rem; font-weight: 500; color: var(--text2); text-decoration: none; transition: all 0.15s; }
.board-pill:hover { background: var(--text); color: #fff; border-color: var(--text); }

/* ── FOOTER ── */
.footer-minimal { background: var(--bg2); border-top: 1px solid var(--border); padding: 0.75rem 1.5rem; text-align: center; font-size: 0.78rem; color: var(--text3); flex-shrink: 0; }

/* ════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET (≤ 1024px)
════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 230px; }
  .banner-stats { gap: 1rem; }
  .bstat-num    { font-size: 1.2rem; }
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET SMALL (≤ 900px)
════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  /* Sidebar → slide-in drawer */
  .sidebar {
    position: fixed; left: 0; top: 0;
    transform: translateX(-110%);
    box-shadow: 4px 0 32px rgba(0,0,0,0.15);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-toggle { display: flex; align-items: center; }

  .banner-stats { display: none; }
  .quick-banner { padding: 1.25rem; }
  .banner-title { font-size: 1.2rem; }

  /* Body scrollable */
  body { overflow: auto; height: auto; }
  .app-layout { height: auto; min-height: 100vh; overflow: visible; }
  .main-content { overflow: visible; }
  .content-scroll { overflow: visible; }
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (≤ 640px)
════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {

  /* Topbar */
  .topbar { padding: 0 0.875rem; height: 52px; gap: 0.5rem; }
  .topbar-search { max-width: none; flex: 1; height: 34px; padding: 0 0.6rem; }
  .search-shortcut { display: none; }
  .topbar-right { gap: 0.4rem; }
  .ai-btn { padding: 0.38rem 0.7rem; font-size: 0.78rem; }
  .streak-badge { padding: 0.35rem 0.55rem; font-size: 0.74rem; }

  /* Content */
  .content-scroll { padding: 0.875rem; }

  /* Daily goal */
  .daily-goal-bar { flex-direction: column; align-items: flex-start; gap: 0.6rem; padding: 0.875rem; }
  .goal-track { width: 100%; }

  /* Banner */
  .quick-banner { padding: 1rem; flex-direction: column; gap: 0.875rem; margin-bottom: 1rem; }
  .quick-banner::before { display: none; }
  .banner-title { font-size: 1.1rem; }
  .banner-sub   { font-size: 0.8rem; margin-bottom: 0.75rem; }
  .banner-cta   { padding: 0.5rem 1rem; font-size: 0.85rem; }
  .banner-stats { display: none; }

  /* Section */
  .section-title    { font-size: 0.95rem; }
  .content-section  { margin-bottom: 1.25rem; }

  /* Subject cards — 3 col */
  .subject-cards { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
  .subject-card  { padding: 0.75rem 0.6rem; }
  .subject-icon  { font-size: 1.25rem; margin-bottom: 0.3rem; }
  .subject-name  { font-size: 0.78rem; }
  .subject-qs    { font-size: 0.68rem; }

  /* Board cards */
  .board-cards  { grid-template-columns: 1fr; gap: 0.5rem; }
  .board-card   { padding: 0.75rem; }

  /* Feature row */
  .feature-row  { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .feature-tile { padding: 0.9rem; }
  .ftile-name   { font-size: 0.85rem; }
  .ftile-sub    { font-size: 0.72rem; }

  /* Footer */
  .footer-minimal { padding: 0.6rem 1rem; font-size: 0.72rem; }
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE — SMALL MOBILE (≤ 400px)
════════════════════════════════════════════════════════════ */
@media (max-width: 400px) {
  .content-scroll  { padding: 0.625rem; }
  .subject-cards   { grid-template-columns: repeat(2, 1fr); }
  .feature-row     { grid-template-columns: 1fr 1fr; }
  .topbar          { padding: 0 0.625rem; }
  .ai-btn          { padding: 0.35rem 0.55rem; font-size: 0.72rem; }
  .banner-title    { font-size: 1rem; }
  .quick-banner    { padding: 0.875rem; }
}

/* ════════════════════════════════════════════════════════════
   SAFE AREA — iPhone notch / home bar
════════════════════════════════════════════════════════════ */
@supports (padding: env(safe-area-inset-top)) {
  .topbar {
    padding-left: max(0.875rem, env(safe-area-inset-left));
    padding-right: max(0.875rem, env(safe-area-inset-right));
  }
  .content-scroll {
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  }
}

/* ════════════════════════════════════════════════════════════
   SIDEBAR OVERLAY — mobile drawer background dim
════════════════════════════════════════════════════════════ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 299;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }