/* ============================================================
   StudyFlow — Design System v2.0
   Fixed: Light/dark mode, duplicate vars removed, clean tokens
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700&family=DM+Mono:ital,wght@0,400;0,500&display=swap');

/* ========== DARK MODE (default) ========== */
:root {
  --bg:        #080C14;
  --surface:   #0E1520;
  --surface2:  #141C2E;
  --border:    rgba(255,255,255,0.07);
  --accent:    #4F8EF7;
  --accent2:   #7B5CF7;
  --accent3:   #F75C7E;
  --green:     #3ECFA0;
  --amber:     #F7A94F;
  --text:      #E8EDF5;
  --muted:     #6B7A99;
  --radius:    14px;
  --radius-lg: 22px;
  --slot-height: 48px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.5);
}

/* ========== LIGHT MODE ========== */
body.light,
:root.light {
  --bg:        #F0F4FC;
  --surface:   #FFFFFF;
  --surface2:  #F5F7FF;
  --border:    rgba(0,0,0,0.08);
  --accent:    #3B7EF0;
  --accent2:   #6B4EE8;
  --accent3:   #E8365D;
  --green:     #22B47E;
  --amber:     #E89B30;
  --text:      #111827;
  --muted:     #6B7A99;
  --shadow-sm: 0 2px 8px rgba(79,142,247,0.08);
  --shadow-md: 0 8px 24px rgba(79,142,247,0.12);
  --shadow-lg: 0 20px 60px rgba(79,142,247,0.15);
}

/* ========== BASE ========== */
*, *::before, *::after {
  margin: 0; padding: 0;
  box-sizing: border-box;
}
html { scroll-behavior: smooth; }

body {
  font-family: 'Sora', sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 60% 40% at 80% 10%, rgba(79,142,247,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 40% 50% at 10% 80%, rgba(123,92,247,0.06) 0%, transparent 60%);
  color: var(--text);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background 0.25s ease, color 0.25s ease;
}

body.light {
  background-image:
    radial-gradient(ellipse 60% 40% at 80% 10%, rgba(79,142,247,0.05) 0%, transparent 60%),
    radial-gradient(ellipse 40% 50% at 10% 80%, rgba(123,92,247,0.04) 0%, transparent 60%);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

main {
  width: 100%;
  max-width: 1100px;
  margin: 1.5rem auto;
  padding: 1rem;
  flex: 1;
}

footer {
  text-align: center;
  padding: 1rem;
  margin-top: auto;
  background: var(--bg);
  color: var(--muted);
  border-top: 1px solid var(--border);
  font-size: 13px;
}

/* ========== TYPOGRAPHY ========== */
h1,h2,h3,h4,h5,h6 { line-height: 1.2; font-weight: 600; }

h2.page-title {
  font-size: 24px; font-weight: 600;
  color: var(--text); letter-spacing: -0.3px;
  margin: 0.2rem 0 1rem;
}

label {
  font-size: 12px; font-weight: 500;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: 1px;
}

.muted { color: var(--muted); }
.meta  { color: var(--muted); font-size: 13px; margin: 0.3rem 0; }
.avg   { color: var(--text);  font-size: 13px; margin: 0.3rem 0; }
.hint  { display: block; font-size: 12px; color: var(--muted); margin-top: 0.4rem; }

/* ========== HEADER ========== */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  padding: 0.9rem 2rem;
  position: sticky; top: 0; z-index: 900;
  transition: background 0.25s, border-color 0.25s;
  box-shadow: var(--shadow-sm);
  justify-content: space-between;
}

.logo { display: flex; align-items: center; gap: 0.6rem; color: var(--text); order: 1; }
.logo h1 { margin: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: 0.3px; }
.brand-icon { color: var(--accent); width: 36px; height: 36px; display: block; }

/* Nav */
.main-nav { display: flex; align-items: center; gap: 0.15rem; order: 3; }
.main-nav a,
.nav-group-label {
  color: var(--muted); text-decoration: none;
  font-weight: 500; padding: 8px 14px;
  border-radius: 10px; transition: all 0.2s ease;
  font-size: 14px;
}
.nav-group-label {
  display: inline-flex; align-items: center; gap: 0.35rem;
  cursor: default; user-select: none;
}
.nav-group-label::after {
  content: "";
  width: 6px; height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
}
.nav-group-link::after { display: none; }
.main-nav a:hover,
.nav-group:hover .nav-group-label {
  color: var(--text); background: var(--surface2); text-decoration: none;
}
.main-nav a.active,
.nav-group.is-active > .nav-group-label {
  background: var(--accent); color: #fff;
  box-shadow: 0 4px 12px rgba(79,142,247,0.3);
}
.nav-group { position: relative; }
.nav-group-menu {
  position: absolute; top: calc(100% + 0.45rem); left: 0;
  min-width: 180px; padding: 0.45rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; gap: 0.25rem;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  z-index: 920;
}
.nav-group:hover .nav-group-menu,
.nav-group:focus-within .nav-group-menu {
  opacity: 1; visibility: visible; transform: translateY(0);
}
.nav-group-menu a { white-space: nowrap; }

/* Hamburger */
.nav-toggle {
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 5px;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
  border: 1px solid var(--border); border-radius: 12px;
  cursor: pointer; width: 42px; height: 42px; z-index: 1020;
  order: 4; position: relative;
  padding: 0; margin: 0;
  box-shadow: var(--shadow-sm);
}
.nav-toggle span {
  width: 20px; height: 2px;
  background: var(--text); border-radius: 2px;
  transition: all 0.3s ease; display: block;
}
.nav-toggle:hover {
  border-color: rgba(79,142,247,0.45);
  background: rgba(79,142,247,0.12);
}
.nav-backdrop {
  position: fixed; inset: 0;
  display: none;
  background: transparent;
  z-index: 980;
}
@media (max-width: 880px) {
  .site-header { gap: 0.75rem; }
  .nav-toggle { display: flex; }
  .main-nav {
    position: fixed; top: 0.85rem; right: 0.85rem;
    width: min(92vw, 380px); max-height: calc(100dvh - 1.7rem);
    height: auto;
    background:
      linear-gradient(180deg, rgba(79,142,247,0.12), transparent 34%),
      var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    flex-direction: column;
    align-items: stretch;
    padding: 4.75rem 0.85rem 0.95rem;
    gap: 0.35rem;
    opacity: 0; visibility: hidden; transform: translateX(18px) scale(0.98);
    transform-origin: top right;
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
    z-index: 1000; overflow-y: auto;
    pointer-events: none;
    box-shadow: var(--shadow-lg);
  }
  .main-nav::before {
    content: "";
    position: absolute;
    top: 1rem; left: 1rem;
    width: 46px; height: 46px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    box-shadow: 0 12px 30px rgba(79,142,247,0.28);
  }
  .main-nav::after {
    content: "StudyFlow";
    position: absolute;
    top: 1.45rem; left: 4.45rem;
    color: var(--text);
    font-size: 16px;
    font-weight: 700;
  }
  .main-nav.nav-open {
    opacity: 1; visibility: visible; transform: translateX(0) scale(1);
    pointer-events: auto;
  }
  .main-nav a,
  .nav-group-label {
    width: 100%;
    min-height: 48px;
    padding: 13px 14px; border-radius: 14px; font-weight: 650;
    color: var(--muted); text-decoration: none; display: flex;
    align-items: center;
    font-size: 15px; transition: all 0.2s ease;
  }
  .main-nav a:hover,
  .nav-group:hover .nav-group-label {
    color: var(--text); background: var(--surface2);
  }
  .main-nav a.active,
  .nav-group.is-active > .nav-group-label {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    box-shadow: 0 10px 22px rgba(79,142,247,0.26);
  }
  .nav-group { position: relative; width: 100%; }
  .nav-group + .nav-group { margin-top: 0.1rem; }
  .nav-group-label {
    display: flex; align-items: center; gap: 0.35rem;
    cursor: pointer; user-select: none;
  }
  .nav-group.is-open:not(.is-active) > .nav-group-label {
    color: var(--text);
    background: var(--surface2);
  }
  .nav-group-label::after {
    content: "";
    width: 6px; height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translateY(-1px);
    margin-left: auto;
    transition: transform 0.2s ease;
  }
  .nav-group.is-active > .nav-group-label::after,
  .nav-group.is-open > .nav-group-label::after {
    transform: rotate(225deg) translate(-1px,-1px);
  }
  .nav-group-link::after { display: none; }
  .nav-group-menu {
    position: static; min-width: 0; padding: 0.35rem 0 0.25rem 0.7rem;
    background: transparent; border: none; box-shadow: none;
    opacity: 1; visibility: visible; transform: none;
    display: none; margin-top: 0.2rem; gap: 0.25rem;
  }
  .nav-group.is-active .nav-group-menu,
  .nav-group.is-open .nav-group-menu {
    display: flex; flex-direction: column;
  }
  .nav-group-menu a {
    min-height: 42px;
    padding: 10px 14px; font-size: 14px;
    color: var(--muted); font-weight: 500;
    border-left: 2px solid var(--border);
    border-radius: 0 12px 12px 0;
  }
  .nav-group-menu a:hover {
    color: var(--text); background: var(--surface2);
    border-left-color: var(--accent);
  }
  body.nav-open { overflow: hidden; }
  .nav-backdrop:not([hidden]) { display: block; }
  .nav-toggle[aria-expanded="true"] {
    position: fixed;
    top: 1.85rem;
    right: 1.85rem;
    background: var(--surface2);
    z-index: 1020;
  }
  .nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: rotate(45deg) translate(5px,5px); }
  .nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: rotate(-45deg) translate(5px,-5px); }
}

/* ========== BUTTONS ========== */
button, .btn {
  font-family: 'Sora', sans-serif;
  transition: all 0.2s ease; cursor: pointer;
  border: none; line-height: 1.4;
}
.btn {
  display: inline-flex; align-items: center;
  justify-content: center; gap: 6px;
  text-decoration: none; min-height: 40px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #3a7ee8);
  color: #fff; border-radius: 10px; padding: 10px 20px;
  font-size: 13px; font-weight: 600; border: none;
  box-shadow: 0 4px 20px rgba(79,142,247,0.3);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(79,142,247,0.45); }
.btn-primary:active { transform: translateY(0); }

.sf-btn-outline {
  background: transparent; color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 18px; font-size: 13px; font-weight: 500;
}
.sf-btn-outline:hover { background: var(--surface2); border-color: rgba(255,255,255,0.15); }
body.light .sf-btn-outline:hover { border-color: rgba(0,0,0,0.15); }

.btn-danger {
  background: rgba(247,92,126,0.12); color: var(--accent3);
  border: 1px solid rgba(247,92,126,0.2);
  padding: 9px 18px; border-radius: 10px;
  font-size: 13px; font-weight: 500;
}
.btn-danger:hover { background: rgba(247,92,126,0.2); border-color: rgba(247,92,126,0.35); }

/* Icon buttons */
.icon-btn {
  width: 36px; height: 36px; min-height: 36px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text);
  display: grid; place-items: center;
  cursor: pointer; transition: all 0.2s; flex-shrink: 0;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { border-color: rgba(255,255,255,0.15); background: var(--surface); }
body.light .icon-btn:hover { border-color: rgba(0,0,0,0.15); }
.icon-btn.primary { border-color: rgba(79,142,247,0.4); color: var(--accent); }
.icon-btn.primary:hover { background: rgba(79,142,247,0.12); }
.icon-btn.danger { border-color: rgba(247,92,126,0.3); color: var(--accent3); }
.icon-btn.danger:hover { background: rgba(247,92,126,0.12); }
.icon-btn.info { border-color: var(--border); color: var(--muted); }
.icon-btn.info:hover { color: var(--text); }

/* ========== CARDS ========== */
.card, .sf-card, .gpa-card, .subject-block,
.tasks-card, .assistant-card, .mission-block, .home-hero-super {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  position: relative; overflow: hidden;
  transition: background 0.25s, border-color 0.25s;
}
.card::before, .sf-card::before, .gpa-card::before,
.subject-block::before, .tasks-card::before,
.assistant-card::before, .home-hero-super::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.1), transparent);
  pointer-events: none;
}
body.light .card::before, body.light .sf-card::before,
body.light .gpa-card::before, body.light .subject-block::before,
body.light .tasks-card::before, body.light .assistant-card::before,
body.light .home-hero-super::before {
  background: linear-gradient(to right, transparent, rgba(0,0,0,0.05), transparent);
}

.sf-card-pad { padding: 1.5rem; }

/* ========== INPUTS & FORMS ========== */
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px; color: var(--text);
  font-family: 'Sora', sans-serif;
  padding: 10px 14px; font-size: 14px;
  transition: all 0.2s ease; width: 100%;
}
input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,142,247,0.12);
  outline: none;
}
input::placeholder { color: var(--muted); }
textarea { resize: vertical; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.5rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field label { display: block; }
.form-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 0.3rem; }

/* ========== APP FEEDBACK ========== */
.toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: min(340px, calc(100vw - 2rem));
  pointer-events: none;
}
.app-toast {
  opacity: 0;
  transform: translateY(10px);
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 600;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.app-toast.is-visible { opacity: 1; transform: translateY(0); }
.app-toast.success { border-left: 3px solid var(--green); }
.app-toast.warning { border-left: 3px solid var(--amber); }
.app-toast.error { border-left: 3px solid var(--accent3); }

.app-confirm {
  position: fixed;
  inset: 0;
  z-index: 480;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.app-confirm[hidden] { display: none; }
.app-confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3,7,18,0.6);
  backdrop-filter: blur(8px);
}
.app-confirm-card {
  position: relative;
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-lg);
}
.app-confirm-card h3 { margin: 0 0 0.5rem; font-size: 18px; }
.app-confirm-card p { color: var(--muted); margin: 0; font-size: 14px; }
.app-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.2rem;
}
body.confirm-open { overflow: hidden; }

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 470;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.auth-modal[hidden] { display: none; }
.auth-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3,7,18,0.58);
  backdrop-filter: blur(8px);
}
.auth-card {
  position: relative;
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.25rem;
}
.auth-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.auth-card-head h3 {
  margin: 0 0 0.25rem;
  font-size: 18px;
}
.auth-card-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.auth-close {
  width: 32px;
  height: 32px;
  min-height: 32px;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 20px;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.auth-name-field {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.auth-name-field[hidden] { display: none; }
.auth-form label {
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
}
.auth-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  margin-top: 0.35rem;
}
.auth-link-btn {
  width: fit-content;
  min-height: unset;
  padding: 0;
  margin-top: 0.4rem;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}
.auth-signed-in {
  display: grid;
  gap: 0.7rem;
}
.auth-signed-in p {
  margin: 0;
  color: var(--text);
  font-weight: 700;
}
body.auth-open { overflow: hidden; }

.onboarding-modal {
  position: fixed;
  inset: 0;
  z-index: 490;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.onboarding-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3,7,18,0.6);
  backdrop-filter: blur(8px);
}
.onboarding-card {
  position: relative;
  width: min(460px, 100%);
  display: grid;
  gap: 0.8rem;
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.onboarding-card h3 { margin: 0; font-size: 20px; }
.onboarding-card p { margin: 0; color: var(--muted); font-size: 14px; }
.onboarding-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

/* ========== INFO BOX ========== */
.info-box {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 12px; padding: 1rem; margin-bottom: 1rem; font-size: 14px;
}
.status-guide { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.5rem; }
.status-line { padding: 0.35rem 0.6rem; border-radius: 8px; font-weight: 600; font-size: 13px; }
.status-line.safe    { background: rgba(62,207,160,0.15); color: var(--green); }
.status-line.warning { background: rgba(247,169,79,0.15);  color: var(--amber); }
.status-line.risk    { background: rgba(247,92,126,0.15);  color: var(--accent3); }

.grade-insights {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem; margin: 1rem 0;
}
.grade-insight-card {
  padding: 1rem; background: var(--surface);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 12px;
}
.grade-insight-card.safe { border-left-color: var(--green); }
.grade-insight-card.warning { border-left-color: var(--amber); }
.grade-insight-card.risk { border-left-color: var(--accent3); }
.grade-insight-label {
  display: block; font-size: 11px; font-weight: 700;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: 1px; margin-bottom: 0.3rem;
}
.grade-insight-card strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 0.15rem; }
.grade-insight-card span:last-child { font-family: 'DM Mono', monospace; color: var(--muted); font-size: 13px; }

/* ========== PAGE TITLE ROW ========== */
.page-title-row {
  display: flex; align-items: center;
  justify-content: space-between; gap: 0.6rem;
  flex-wrap: wrap; margin-bottom: 0.5rem;
}
.page-title-group { display: flex; align-items: center; gap: 8px; }

/* ========== HOME PAGE ========== */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.9rem;
}
.section-head h2 { margin: 0; font-size: 20px; }
.section-subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 13px;
}
.section-kicker {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.home-agenda-panel {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.today-view-list { min-width: 0; }
.today-agenda-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}
.today-agenda-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.today-agenda-head strong {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  border-radius: 999px;
  background: rgba(79,142,247,0.14);
  color: var(--accent);
  font-family: 'DM Mono', monospace;
}
.today-view-list {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.today-view-item {
  display: grid;
  grid-template-columns: 34px 78px minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem;
  border-radius: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.today-view-item:hover {
  transform: translateY(-1px);
  border-color: rgba(79,142,247,0.35);
  text-decoration: none;
}
.today-item-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: rgba(79,142,247,0.12);
  color: var(--accent);
  font-weight: 900;
}
.today-item-type,
.today-view-item em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}
.today-view-item.warning { border-left: 3px solid var(--amber); }
.today-view-item.risk { border-left: 3px solid var(--accent3); }
.home-side-status {
  display: grid;
  gap: 0.75rem;
}
.study-stats-card {
  padding: 0.95rem;
  border-radius: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.study-stats-card {
  background: var(--surface2);
}
.study-stats-card strong {
  display: block;
  font-family: 'DM Mono', monospace;
  color: var(--text);
  font-size: 24px;
  margin: 0.4rem 0 0.2rem;
}
.study-stats-card p { margin: 0; color: var(--muted); font-size: 13px; }
.home-dashboard {
  width: min(1180px, calc(100% - 2rem));
  margin: 1.25rem auto 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}
.home-hero-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1rem;
  align-items: start;
}
.home-hero-super {
  padding: 1.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
}
.hero-top { margin-bottom: 1.05rem; }
.hero-date-row {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 1.05rem;
}
.hero-date {
  font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1.5px; margin: 0;
}

/* Theme toggle */
.home-theme-toggle {
  display: flex; gap: 3px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 99px; padding: 3px;
}
.theme-chip {
  background: transparent; border: none;
  color: var(--muted); width: 28px; height: 28px;
  border-radius: 50%; display: grid; place-items: center;
  cursor: pointer; transition: all 0.2s ease;
}
.theme-chip.is-active { background: var(--accent); color: #fff; }
.theme-icon { width: 16px; height: 16px; }

/* Hero main */
.hero-main { display: flex; gap: 1rem; align-items: center; }
.avatar-btn {
  width: 58px; height: 58px;
  border: 2px solid var(--border); border-radius: 50%;
  background: var(--surface2); cursor: pointer;
  position: relative; overflow: hidden;
  flex-shrink: 0; transition: all 0.2s ease;
  min-height: unset; padding: 0;
}
.avatar-btn:hover { border-color: var(--accent); }
.avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar-btn.is-empty .avatar-img { display: none; }
.avatar-btn.is-empty .avatar-placeholder { display: block; }
.avatar-placeholder {
  display: none; width: 32px; height: 32px; color: var(--muted);
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
}
.hero-greeting { flex: 1; }
.home-title {
  font-size: 28px; font-weight: 800; color: var(--text);
  margin: 0 0 0.3rem; letter-spacing: 0;
}
.home-subtitle { font-size: 15px; color: var(--muted); margin: 0; }

/* Mission block */
.mission-block {
  padding-top: 1rem;
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  background: transparent;
  border-right: none;
  border-bottom: none;
  border-left: none;
  border-radius: 0;
  overflow: visible;
}
.mission-block::before { display: none; }
.mission-head { margin-bottom: 0.9rem; }
.mission-label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1.5px;
  display: block; margin-bottom: 0.5rem;
}
.mission-block h3 { font-size: 18px; font-weight: 800; color: var(--text); margin: 0.35rem 0 0.2rem; }
.mission-meta { font-size: 13px; color: var(--muted); margin: 0; }
.focus-meta-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem; margin-bottom: 0.85rem;
}
.focus-chip {
  padding: 0.75rem; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 12px;
}
.focus-chip-label {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: 1px; margin-bottom: 0.3rem;
}
.focus-chip-value { display: block; font-size: 15px; font-weight: 700; color: var(--text); }
.quick-actions {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
}
.quick-action {
  min-height: 38px; display: flex; align-items: center; justify-content: center;
  padding: 0.58rem 0.65rem; border: 1px solid var(--border);
  border-radius: 999px; background: transparent;
  color: var(--text); text-decoration: none; font-size: 12px; font-weight: 800;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.quick-action:hover {
  transform: translateY(-2px); border-color: rgba(79,142,247,0.45);
  background: rgba(79,142,247,0.12); text-decoration: none;
}
.home-sync-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
}
.home-sync-card:hover {
  border-color: rgba(79,142,247,0.35);
  text-decoration: none;
}
.home-sync-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 5px rgba(107,122,153,0.12);
  flex-shrink: 0;
}
.home-sync-dot.is-online {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(62,207,160,0.14);
}
.home-sync-card strong {
  display: block;
  font-size: 13px;
  color: var(--text);
}
.home-sync-card small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 0.1rem;
}
/* Assistant card */
.assistant-card {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  height: fit-content;
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
}
.assistant-card::before { display: none; }
.assistant-head { display: flex; justify-content: space-between; align-items: center; }
.assistant-title { font-size: 14px; font-weight: 600; color: var(--text); margin: 0; }
.home-notifications-card {
  padding: 1rem;
  border: 1px solid rgba(247,169,79,0.22);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(247,169,79,0.12), transparent 52%),
    var(--surface2);
}
.notification-count {
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  border-radius: 999px;
  background: rgba(247,169,79,0.16);
  color: var(--amber);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 800;
}
.home-notifications-list {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.75rem;
}
.home-notification-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
  padding: 0.68rem;
  border-radius: 10px;
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
body.light .home-notification-item { background: rgba(255,255,255,0.55); }
.home-notification-item:hover {
  transform: translateY(-1px);
  border-color: rgba(247,169,79,0.35);
  text-decoration: none;
}
.home-notification-item::before {
  content: "";
  width: 8px;
  height: 100%;
  min-height: 34px;
  border-radius: 999px;
  background: var(--green);
}
.home-notification-item.warning::before { background: var(--amber); }
.home-notification-item.risk::before { background: var(--accent3); }
.home-notification-item.safe::before { background: var(--green); }
.home-notification-item strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}
.home-notification-item span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 0.15rem;
}
.assistant-link {
  color: var(--accent); text-decoration: none;
  font-size: 12px; font-weight: 500; padding: 5px 10px;
  border: 1px solid var(--border); border-radius: 8px; transition: all 0.2s;
}
.assistant-link:hover { background: var(--surface2); text-decoration: none; }
.home-empty-state {
  padding: 1rem; border: 1px dashed var(--border); border-radius: 12px;
  background: var(--surface2); color: var(--muted); font-size: 13px; text-align: center;
}
.focus-timer {
  padding: 1rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
}
.focus-task-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.focus-timer-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.8rem; margin: 0.85rem 0 0.8rem;
}
.focus-timer-head span {
  font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px;
}
.focus-timer-head strong {
  font-family: 'DM Mono', monospace; font-size: 24px; color: var(--text);
}
.focus-timer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.focus-timer-actions .btn { width: 100%; }

/* Next step */
.next-step {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.next-step[hidden] {
  display: none;
}
.next-step[hidden] + .focus-timer-head {
  margin-top: 0;
}
.next-step-row {
  display: flex;
  gap: 0.7rem;
  align-items: center;
}
.next-step-check { display: flex; align-items: center; cursor: pointer; }
.next-step-check input { display: none; }
.check-mark {
  width: 24px; height: 24px; border: 2px solid var(--border);
  border-radius: 6px; display: flex; align-items: center;
  justify-content: center; transition: all 0.2s ease; flex-shrink: 0;
}
.next-step-check input:checked ~ .check-mark {
  background: var(--accent); border-color: var(--accent);
}
.next-step-check input:checked ~ .check-mark::after {
  content: '✓'; font-size: 13px; font-weight: bold; color: #fff;
}
.next-step-main {
  font-size: 13px;
  color: var(--text);
  margin: 0;
  flex: 1;
  line-height: 1.4;
}

.stat-mini-label {
  font-size: 11px; font-weight: 500; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 0.3rem;
}

/* Avatar picker */
.avatar-picker {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); z-index: 300;
  display: grid; place-items: center; padding: 1rem;
}
.avatar-picker[hidden] { display: none; }
.avatar-backdrop { position: absolute; inset: 0; cursor: pointer; }
.avatar-card {
  position: relative; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.5rem; max-width: 480px; width: 100%;
  max-height: 80vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); z-index: 1;
}
.avatar-card-head {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 1.2rem;
}
.avatar-card-head h3 { margin: 0; font-size: 17px; color: var(--text); }
.avatar-close {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 20px; width: 32px; height: 32px;
  min-height: 32px; border-radius: 8px; cursor: pointer;
  display: grid; place-items: center;
}
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px,1fr));
  gap: 0.8rem; margin-bottom: 1.2rem;
}
.avatar-option {
  width: 100%; aspect-ratio: 1; border-radius: 12px;
  border: 2px solid var(--border); background: var(--surface2);
  cursor: pointer; overflow: hidden; transition: all 0.2s ease;
  min-height: unset; padding: 0;
}
.avatar-option img { width: 100%; height: 100%; object-fit: cover; }
.avatar-option:hover { border-color: var(--accent); transform: scale(1.05); }
.avatar-option.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,142,247,0.25);
}
.avatar-actions { display: flex; gap: 0.8rem; }
.avatar-actions button { flex: 1; }

/* ========== SCHEDULE PAGE ========== */
.schedule-page { padding: 1rem; }
.schedule-controls { display: flex; gap: 0.8rem; margin-bottom: 1.5rem; align-items: center; }
.timetable-container {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.timetable-grid {
  display: grid;
  grid-template-columns: 80px repeat(5,1fr);
  gap: 6px; min-width: 700px; align-items: start;
}
.time-column, .day-column { display: flex; flex-direction: column; }
.day-header {
  background: var(--surface2); color: var(--text);
  border-radius: 10px; padding: 10px; text-align: center;
  font-weight: 600; font-size: 13px; border: 1px solid var(--border);
  height: 50px; display: flex; align-items: center;
  justify-content: center; margin-bottom: 4px;
}
.time-column .day-header { background: transparent; border: none; }
.time-slot {
  height: var(--slot-height); display: flex;
  align-items: center; justify-content: center;
  font-family: 'DM Mono', monospace; font-size: 11px;
  color: var(--muted); border-bottom: 1px solid rgba(255,255,255,0.03);
}
body.light .time-slot { border-bottom-color: rgba(0,0,0,0.04); }
.slots-container {
  position: relative; background: var(--surface2);
  border-radius: 10px; border: 1px solid var(--border);
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.03) 0px, rgba(255,255,255,0.03) 1px,
    transparent 1px, transparent var(--slot-height)
  );
}
body.light .slots-container {
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0.03) 0px, rgba(0,0,0,0.03) 1px,
    transparent 1px, transparent var(--slot-height)
  );
}
.class-block {
  position: absolute; left: 6px; right: 6px;
  border-radius: 12px; padding: 8px 10px 30px;
  color: #fff; box-shadow: var(--shadow-md);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer; overflow: hidden;
}
.class-block:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,0.4); }
.class-block.is-short { padding-bottom: 28px; }
.class-block.is-short .class-subject { font-size: 13px; }
.class-block.is-short .class-start  { font-size: 10px; }
.class-topline { display: flex; flex-direction: column; gap: 3px; padding-right: 20px; }
.class-start { font-size: 11px; font-weight: 700; opacity: 0.9; font-family: 'DM Mono', monospace; }
.class-subject { font-size: 14px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.class-bottomline {
  position: absolute; left: 10px; right: 10px; bottom: 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.class-end { font-size: 11px; font-weight: 700; opacity: 0.9; font-family: 'DM Mono', monospace; white-space: nowrap; }
.class-room { font-size: 11px; font-weight: 700; opacity: 0.9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; max-width: 55%; }
.class-delete-x {
  position: absolute; top: 6px; right: 8px;
  background: transparent; border: none;
  color: rgba(255,255,255,0.9); font-size: 16px; font-weight: 900;
  line-height: 1; cursor: pointer; padding: 0; z-index: 5;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3); min-height: unset;
}
.class-delete-x:hover { transform: scale(1.2); }

/* ========== SCHEDULE MODAL ========== */
.modal {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); z-index: 250;
  align-items: center; justify-content: center;
  padding: 1rem; backdrop-filter: blur(3px);
}
.modal-content {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 0;
  max-width: 480px; width: 100%; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.2rem 1.5rem; border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 17px; font-weight: 600; color: var(--text); }
.modal-close {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 20px;
  width: 32px; height: 32px; min-height: 32px;
  border-radius: 8px; cursor: pointer; display: grid; place-items: center;
}
.modal-close:hover { background: var(--surface); }
.schedule-form { display: flex; flex-direction: column; gap: 1.2rem; padding: 1.5rem; }
.days-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(72px,1fr));
  gap: 0.6rem; margin-top: 0.4rem;
}
.days-grid label {
  display: flex; align-items: center; gap: 0.5rem;
  cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--text); text-transform: none; letter-spacing: 0;
}
.days-grid input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.color-picker { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.4rem; }
.color-picker input[type="radio"] { display: none; }
.color-option { width: 36px; height: 36px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; transition: all 0.2s ease; }
.color-option:hover { transform: scale(1.1); }
.color-picker input[type="radio"]:checked + .color-option { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); transform: scale(1.1); }
.modal-actions { display: flex; gap: 0.8rem; padding-top: 0.5rem; }
.modal-actions button { flex: 1; }

/* ========== CALENDAR PAGE ========== */
.calendar-page-wrap { max-width: 1100px; margin: 1.5rem auto; padding: 0 1rem; }
.cal-grid { width: 100%; }
.cal-grid.cal-grid-single { grid-template-columns: 1fr; }
.sf-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.cal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.2rem 1.5rem; border-bottom: 1px solid var(--border);
}
.cal-title-wrap { flex: 1; }
#monthLabel { font-size: 24px; font-weight: 700; color: var(--text); margin: 0; }
#monthRange { font-size: 12px; color: var(--muted); margin-top: 0.2rem; }
.cal-nav { display: flex; gap: 0.5rem; }
.cal-nav button {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); width: 36px; height: 36px; min-height: 36px;
  border-radius: 10px; cursor: pointer; font-size: 16px;
  display: grid; place-items: center; transition: all 0.2s ease;
}
.cal-nav button:hover { background: var(--surface); border-color: rgba(255,255,255,0.15); }
body.light .cal-nav button:hover { border-color: rgba(0,0,0,0.15); }
.cal-form-row {
  display: flex; gap: 1rem; padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap; align-items: flex-end;
}
.cal-field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 140px; }
.cal-field label { display: block; }
.cal-input { padding: 10px 12px; font-size: 14px; }
.cal-actions { display: flex; align-items: flex-end; gap: 0.5rem; flex-shrink: 0; }
.cal-task-toggle {
  align-self: flex-end;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.cal-task-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}
.cal-task-toggle:hover {
  border-color: rgba(79,142,247,0.35);
  background: rgba(79,142,247,0.1);
}
.cal-add-btn {
  background: var(--accent); color: #fff; border: none;
  padding: 10px 18px; border-radius: 10px;
  font-weight: 600; font-size: 13px; cursor: pointer;
  transition: all 0.2s ease; white-space: nowrap; min-height: 40px;
}
.cal-add-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(79,142,247,0.3); }
.weekday-row {
  display: grid; grid-template-columns: repeat(7,1fr);
  padding: 0.8rem 1rem 0.4rem;
  font-weight: 600; font-size: 11px; color: var(--muted);
  text-align: center; text-transform: uppercase; letter-spacing: 1px;
  border-bottom: 1px solid var(--border);
}
#calendarGrid { display: grid; grid-template-columns: repeat(7,1fr); padding: 0.5rem; }
.month-day {
  background: var(--surface); border: 1px solid rgba(255,255,255,0.04);
  padding: 6px; min-height: 110px;
  display: flex; flex-direction: column;
  cursor: pointer; transition: all 0.2s ease;
  position: relative; overflow: hidden;
}
body.light .month-day { border-color: rgba(0,0,0,0.04); }
.month-day:hover { background: rgba(79,142,247,0.04); }
.month-day.is-today { outline: 2px solid var(--accent); outline-offset: -2px; background: rgba(79,142,247,0.06); }
.month-day.is-outside { opacity: 0.4; }
.day-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; padding: 0 2px; }
.day-num { font-size: 12px; font-weight: 700; color: var(--text); width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; }
.day-lens { font-size: 11px; opacity: 0.2; border: none; background: transparent; cursor: pointer; padding: 2px; min-height: unset; transition: opacity 0.2s; }
.month-day:hover .day-lens { opacity: 0.6; }
.day-events { display: flex; flex-direction: column; gap: 3px; flex: 1; overflow: hidden; }
.event-bar { display: flex; align-items: center; gap: 4px; padding: 0 3px 0 6px; border-radius: 4px; cursor: pointer; height: 18px; position: relative; overflow: hidden; }
.event-bar.completed {
  opacity: 0.68;
  text-decoration: line-through;
}
.event-text { font-weight: 700; font-size: 10px; line-height: 1; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: rgba(15,23,42,0.9); }
.event-time-icon { font-size: 10px; line-height: 1; flex-shrink: 0; margin-left: 2px; }
.event-x {
  width: 14px; height: 14px; border: none; background: transparent;
  cursor: pointer; font-size: 12px; font-weight: 900;
  display: grid; place-items: center; opacity: 0;
  transition: opacity 0.15s; color: rgba(15,23,42,0.8);
  min-height: unset; padding: 0; flex: 0 0 14px;
}
.event-bar:hover .event-x { opacity: 1; }
.more-link { font-size: 10px; font-weight: 700; color: var(--accent); cursor: pointer; padding: 2px 4px; user-select: none; }

/* Day Modal */
.day-modal { position: fixed; inset: 0; z-index: 300; }
.day-modal[hidden] { display: none; }
body.day-modal-open { overflow: hidden; }
.day-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); cursor: pointer; }
.day-modal-card {
  position: relative; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.2rem; max-width: 460px;
  width: calc(100% - 2rem); margin: 8vh auto 0;
  box-shadow: var(--shadow-lg); max-height: 80vh; overflow-y: auto;
}
.day-modal-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1rem; padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border);
}
.day-modal-title { font-size: 16px; font-weight: 600; color: var(--text); }
.day-modal-close {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 18px;
  width: 30px; height: 30px; min-height: 30px;
  border-radius: 8px; cursor: pointer; display: grid; place-items: center;
}
.day-modal-list { display: flex; flex-direction: column; gap: 0.6rem; }
.day-modal-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0.6rem; }
.day-modal-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; min-height: 36px; }
.day-modal-bar.completed {
  opacity: 0.7;
  text-decoration: line-through;
}
.day-modal-text { font-size: 13px; font-weight: 700; color: rgba(15,23,42,0.95); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-modal-time, .day-modal-countdown { font-size: 11px; font-weight: 600; color: rgba(15,23,42,0.6); white-space: nowrap; }
.day-modal-actions { display: inline-flex; gap: 5px; }
.day-modal-actions .icon-btn { width: 30px; height: 30px; min-height: 30px; }
.day-modal-empty { font-size: 13px; color: var(--muted); }
.calendar-tip {
  position: absolute; bottom: 12px; right: 12px;
  padding: 6px 10px; border-radius: 8px;
  background: rgba(79,142,247,0.15); color: var(--accent);
  font-size: 11px; font-weight: 600; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.calendar-tip.is-hidden { opacity: 0; transform: translateY(-4px); }

/* ========== TASKS PAGE ========== */
.tasks-page { max-width: 800px; margin: 1.5rem auto; padding: 0 1rem; }
.tasks-card { padding: 1.5rem; }
.tasks-input-row { display: grid; grid-template-columns: 1fr 145px 140px 125px auto; gap: 0.8rem; margin-bottom: 1rem; }
.tasks-input-row input,
.tasks-input-row select { min-width: 0; }
.tasks-input-row input[type="date"],
.todo-edit-grid input[type="date"] {
  min-height: 40px;
  padding: 10px 12px;
  font-size: 14px;
}
.tasks-input-row button { flex-shrink: 0; }
.tasks-filter-row {
  display: grid;
  grid-template-columns: 1fr 150px 150px auto;
  gap: 0.7rem;
  margin-bottom: 1.5rem;
  padding: 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.tasks-filter-row select { min-width: 0; }
.tasks-stats {
  display: grid; grid-template-columns: auto auto 1fr;
  gap: 1.5rem; margin-bottom: 1.5rem;
  padding-bottom: 1.5rem; border-bottom: 1px solid var(--border);
  align-items: center;
}
.tasks-stat { display: flex; flex-direction: column; gap: 3px; }
.tasks-stat-label { font-size: 11px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.tasks-stat-value { font-family: 'DM Mono', monospace; font-size: 20px; font-weight: 600; color: var(--accent); }
.tasks-progress { display: flex; align-items: center; gap: 0.8rem; }
.tasks-progress-bar { flex: 1; height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.tasks-progress-fill { height: 100%; background: linear-gradient(to right, var(--accent), var(--accent2)); border-radius: 3px; transition: width 0.4s ease; width: 0%; }
.tasks-progress-label { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--muted); white-space: nowrap; }
.tasks-empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.tasks-empty-icon { font-size: 44px; margin-bottom: 0.8rem; }
.tasks-empty-text { font-size: 14px; }
.tasks-list, #todoList { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; padding: 0; margin: 0; }
.todo-item {
  display: flex; flex-direction: column;
  background: var(--surface2); padding: 0.9rem 1rem;
  border-radius: 12px; border: 1px solid var(--border);
  transition: all 0.2s ease;
}
.todo-item:hover { border-color: rgba(255,255,255,0.12); }
body.light .todo-item:hover { border-color: rgba(0,0,0,0.12); }
.todo-item.completed { opacity: 0.6; }
.todo-item.completed .todo-text { text-decoration: line-through; color: var(--muted); }
.todo-item.overdue { border-left: 3px solid var(--accent3); }
.todo-item.is-editing { border-color: var(--accent); }
.todo-main { display: flex; align-items: center; gap: 0.8rem; }
.todo-checkbox { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.todo-text-wrap { flex: 1; min-width: 0; }
.todo-text { flex: 1; font-size: 14px; color: var(--text); word-break: break-word; margin: 0; }
.todo-meta { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; margin-top: 0.25rem; font-size: 11px; color: var(--muted); }
.todo-priority {
  padding: 0.12rem 0.42rem; border-radius: 999px;
  background: rgba(79,142,247,0.12); color: var(--accent);
  text-transform: capitalize; font-weight: 700;
}
.todo-priority.high { background: rgba(247,92,126,0.14); color: var(--accent3); }
.todo-priority.medium { background: rgba(247,169,79,0.14); color: var(--amber); }
.todo-priority.low { background: rgba(62,207,160,0.14); color: var(--green); }
.todo-overdue { color: var(--accent3); font-weight: 800; }
.todo-actions { display: flex; gap: 0.35rem; margin-left: auto; flex-shrink: 0; }
.todo-edit-wrap { width: 100%; }
.todo-edit-form { border-top: 1px solid var(--border); padding-top: 0.8rem; margin-top: 0.8rem; display: flex; flex-direction: column; gap: 0.5rem; }
.todo-edit-input { font-size: 14px; }
.todo-edit-grid { display: grid; grid-template-columns: 1fr 1fr 140px; gap: 0.5rem; }
.todo-edit-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

/* ========== GRADES PAGE ========== */
.subjects-page { padding: 0.5rem 0; }
.subject-form { display: flex; gap: 0.8rem; margin-bottom: 1.5rem; }
.subject-form input { flex: 1; }
.subject-form button { flex-shrink: 0; }
.subjects-list, #subjectsContainer { display: flex; flex-direction: column; gap: 1rem; }
.subject-block { padding: 1.2rem 1.4rem; }
.subject-block.green  { border-left: 3px solid var(--green); }
.subject-block.yellow { border-left: 3px solid var(--amber); }
.subject-block.red    { border-left: 3px solid var(--accent3); }
.subject-title { font-size: 17px; font-weight: 600; color: var(--text); margin: 0; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin-bottom: 0.8rem; }
.subject-title-wrap { display: flex; align-items: center; gap: 0.6rem; flex: 1; }
.subject-title-input { font-size: 15px; font-weight: 600; background: transparent; border: 1px solid rgba(255,255,255,0.1); padding: 5px 8px; border-radius: 8px; color: var(--text); min-width: 180px; width: auto; }
.subject-title-input:focus { border-color: var(--accent); outline: none; }
.header-actions { display: flex; gap: 0.5rem; }
.subject-dashboard-mini {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.75rem 0;
}
.subject-dashboard-mini span {
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  background: var(--surface2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}
.subject-dashboard-panel {
  margin: 0.8rem 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
  overflow: hidden;
}
.subject-dashboard-panel summary {
  cursor: pointer;
  padding: 0.8rem 1rem;
  color: var(--text);
  font-weight: 800;
  font-size: 13px;
}
.subject-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  padding: 0 1rem 1rem;
}
.subject-dash-card {
  min-width: 0;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
}
.subject-dash-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.subject-dash-card strong {
  display: block;
  margin-top: 0.35rem;
  color: var(--text);
  font-size: 18px;
}
.subject-dash-card p {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.subject-note-card { grid-column: 1 / -1; }
.subject-note-card textarea {
  min-height: 76px;
  margin: 0.55rem 0;
}
.subject-block table { width: 100%; margin-top: 0.8rem; border-collapse: collapse; }
.subject-block th { background: var(--surface2); color: var(--muted); padding: 9px 12px; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; border: 1px solid var(--border); }
.subject-block td { padding: 9px 12px; border: 1px solid var(--border); font-size: 14px; color: var(--text); }
.subject-block tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
body.light .subject-block tbody tr:nth-child(even) { background: rgba(0,0,0,0.02); }
.td-left { text-align: left; }
.grade-actions-cell { text-align: right; }
.grade-actions-wrap { display: inline-flex; gap: 5px; justify-content: flex-end; }
.grade-edit-row { background: transparent !important; }
.grade-edit-cell { padding: 0 !important; border: none !important; }
.grade-form { display: grid; grid-template-columns: 1fr 100px 100px auto; gap: 0.6rem; margin: 0.8rem 0; align-items: end; }
.grade-form input { padding: 8px 10px; }
.grade-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.grade-edit-form { padding: 0.8rem; background: var(--surface2); border-radius: 10px; border: 1px solid var(--border); margin: 0.5rem 0; display: grid; gap: 0.6rem; }

/* ========== GPA PAGE ========== */
.gpa-page { padding: 0.5rem 0; display: flex; flex-direction: column; gap: 1rem; }
.gpa-card { padding: 1.2rem 1.4rem; margin-bottom: 0; }
.gpa-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; padding-bottom: 0.8rem; border-bottom: 1px solid var(--border); }
.gpa-card-title { font-size: 15px; font-weight: 600; color: var(--text); margin: 0; }
.gpa-results-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.gpa-prev-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 1.5rem; }
.gpa-prev-left, .gpa-prev-right { display: flex; flex-direction: column; gap: 1.2rem; }
.gpa-scale-toggle { display: flex; background: var(--surface2); border: 1px solid var(--border); border-radius: 99px; padding: 4px; width: fit-content; }
.gpa-scale-btn { background: transparent; border: none; color: var(--muted); padding: 8px 20px; border-radius: 99px; cursor: pointer; font-weight: 600; font-size: 15px; font-family: 'Sora', sans-serif; transition: all 0.2s ease; min-height: unset; }
.gpa-scale-btn.is-active { background: var(--accent); color: #fff; }
.gpa-method-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.gpa-method-head { display: flex; gap: 0.8rem; cursor: pointer; padding: 0.9rem 1rem; align-items: flex-start; }
.gpa-method-head input[type="radio"] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; margin-top: 2px; }
.gpa-method-title { font-weight: 600; color: var(--text); margin-bottom: 0.2rem; font-size: 14px; }
.gpa-method-sub { font-size: 12px; color: var(--muted); }
.gpa-method-body { padding: 0.8rem 1rem; border-top: 1px solid var(--border); }
.gpa-input-row { display: flex; gap: 0.6rem; }
.gpa-input-row input { flex: 1; }
.gpa-input-row button { flex-shrink: 0; }
.gpa-table { width: 100%; border-collapse: collapse; margin-top: 0.6rem; }
.gpa-table th { background: var(--surface2); color: var(--muted); padding: 9px 12px; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; border: 1px solid var(--border); font-family: 'DM Mono', monospace; }
.gpa-table td { padding: 10px 12px; border: 1px solid var(--border); font-family: 'DM Mono', monospace; font-size: 14px; color: var(--text); }
.gpa-add-form { display: flex; flex-direction: column; gap: 1rem; }
.gpa-add-mini { display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.8rem; align-items: end; }
.gpa-add-mini .field:last-child { align-self: end; }
.gpa-courses-list { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.6rem; }
.gpa-course-card { background: var(--surface2); border: 1px solid var(--border); border-left: 3px solid var(--accent2); border-radius: 12px; padding: 0.9rem 1rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.gpa-course-title { font-weight: 600; color: var(--text); margin: 0 0 0.2rem; font-size: 14px; }
.gpa-course-meta  { font-size: 12px; color: var(--muted); margin: 0; }
.gpa-course-actions { display: flex; gap: 0.4rem; }
#gpaEmpty { color: var(--muted); font-size: 14px; margin: 0; }
#clearSemesterBtn { display: none; }

/* ========== SETTINGS PAGE ========== */
.settings-page { max-width: 580px; margin: 0 auto; display: flex; flex-direction: column; gap: 1.5rem; }
.settings-account-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.settings-profile-avatar {
  width: 76px;
  height: 76px;
  border-radius: 24px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid rgba(79,142,247,0.28);
  background: var(--surface2);
  box-shadow: var(--shadow-sm);
}
.settings-profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.settings-account-card h3 {
  margin: 0.15rem 0 0.25rem;
  color: var(--text);
  font-size: 18px;
}
.settings-account-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.settings-sync-note {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 12px;
}
.sync-state-pill {
  flex-shrink: 0;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  background: rgba(62,207,160,0.12);
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}
.settings-account-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
}
.settings-account-actions .btn {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 12px;
  white-space: nowrap;
}
.settings-card { overflow: hidden; }
.settings-form { display: flex; flex-direction: column; gap: 0; }
.settings-form .form-row { display: grid; grid-template-columns: 160px 1fr; gap: 1rem; align-items: center; padding: 1.2rem 1.5rem; border-bottom: 1px solid var(--border); }
.settings-form .form-row:last-child { border-bottom: none; }
.settings-form .form-row label { font-size: 13px; font-weight: 500; color: var(--muted); text-transform: none; letter-spacing: 0; }
.settings-form .field { gap: 0.3rem; }
.settings-data-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}
.settings-data-actions .hint { grid-column: 1 / -1; }
.settings-import-btn { cursor: pointer; }
.import-ready-box {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem;
  border: 1px solid rgba(62,207,160,0.28);
  border-radius: 12px;
  background: rgba(62,207,160,0.1);
}
.import-ready-box strong,
.import-ready-box span {
  display: block;
}
.import-ready-box strong {
  color: var(--text);
  font-size: 13px;
}
.import-ready-box span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 0.15rem;
}
.settings-about { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.2rem 1.5rem; text-align: center; }
.settings-about-text { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.6; }

/* ========== CHATBOT PAGE ========== */
.chatbot-main { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; padding: 1.5rem 1rem; }
.chat-container { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; height: 520px; overflow: hidden; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1.2rem; display: flex; flex-direction: column; gap: 1rem; }
.message { display: flex; gap: 0.8rem; align-items: flex-end; animation: slideIn 0.2s ease; }
.message-avatar { font-size: 18px; flex-shrink: 0; }
.message-content { display: flex; flex-direction: column; max-width: 75%; white-space: pre-wrap; }
.message-content div,
.message-content p { margin: 0; font-size: 14px; padding: 0.7rem 1rem; border-radius: 16px; word-wrap: break-word; line-height: 1.5; }
.bot-message .message-content div,
.bot-message .message-content p { background: var(--surface2); color: var(--text); border-radius: 16px 16px 16px 4px; }
.user-message { flex-direction: row-reverse; }
.user-message .message-content div,
.user-message .message-content p { background: var(--accent); color: #fff; border-radius: 16px 16px 4px 16px; }
.typing-dots { display: flex; gap: 4px; align-items: center; padding: 0.7rem 1rem; background: var(--surface2); border-radius: 16px 16px 16px 4px; width: fit-content; }
.typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: typingBounce 1.4s infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%,80%,100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-6px); }
}
.chat-input-container { display: flex; gap: 0.6rem; padding: 1rem; border-top: 1px solid var(--border); background: var(--surface); }
.chat-input-container input { flex: 1; }
.chat-input-container button { flex-shrink: 0; background: var(--accent); color: #fff; border: none; padding: 10px 16px; border-radius: 10px; font-weight: 600; cursor: pointer; transition: all 0.2s ease; min-height: 40px; }
.chat-input-container button:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(79,142,247,0.3); }
.chat-input-container button:last-child { background: transparent; border: 1px solid var(--border); color: var(--text); }
.chat-input-container button:last-child:hover { background: var(--surface2); box-shadow: none; transform: none; }

/* ========== ANIMATIONS ========== */
@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* ========== FIREWORKS ========== */
#gpaFireworks, #tasksFireworks, #gradesFireworks {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 9999; display: none;
}

/* ========== LINKS ========== */
a { color: var(--accent); text-decoration: none; transition: all 0.2s ease; }
a:hover { text-decoration: underline; }

/* ========== PROGRESS INSIGHTS ========== */
.achievements-section {
  margin-top: 2rem;
  padding: 1.35rem;
  background:
    linear-gradient(135deg, rgba(62,207,160,0.08), transparent 38%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.achievements-title {
  margin: 0 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.achievements-title h2 { margin: 0.15rem 0 0; font-size: 20px; }
.achievements-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}
.insight-card {
  padding: 1rem;
  border-radius: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
}
.insight-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.insight-card strong {
  display: block;
  margin: 0.45rem 0 0.2rem;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 24px;
}
.insight-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.insight-card.green,
.insight-card.safe { border-left-color: var(--green); }
.insight-card.purple { border-left-color: var(--accent2); }
.insight-card.warning { border-left-color: var(--amber); }
.insight-card.risk { border-left-color: var(--accent3); }

/* ========== ANIMATIONS ========== */
@keyframes slideInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes achievementPop {
  0% { transform: scale(0.5) rotate(-10deg); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 10px rgba(79,142,247,0.2); }
  50% { box-shadow: 0 0 20px rgba(79,142,247,0.4); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes shimmer {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}

.mission-block { animation: slideInRight 0.6s ease; }
.assistant-card { animation: slideInLeft 0.6s ease; }

/* ========== GLOBAL FOCUS TIMER ========== */
.global-timer-container {
  position: fixed;
  top: calc(74px + env(safe-area-inset-top));
  right: 1rem;
  z-index: 190;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  pointer-events: none;
}

.global-timer-container.hidden {
  display: none;
}

.timer-display {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background:
    linear-gradient(135deg, rgba(79,142,247,0.18), rgba(123,92,247,0.12)),
    color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid rgba(79,142,247,0.28);
  border-radius: 999px;
  padding: 0.45rem 0.85rem 0.45rem 0.5rem;
  font-weight: 700;
  font-size: 13px;
  font-family: 'DM Mono', monospace;
  color: var(--accent);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  pointer-events: auto;
  box-shadow: 0 14px 36px rgba(0,0,0,0.24);
  backdrop-filter: blur(14px);
}

.timer-display:hover {
  transform: translateY(-2px);
  background:
    linear-gradient(135deg, rgba(79,142,247,0.24), rgba(123,92,247,0.16)),
    var(--surface);
  border-color: rgba(79,142,247,0.45);
  box-shadow: 0 18px 44px rgba(0,0,0,0.3);
}

.timer-circle {
  width: 34px; height: 34px; position: relative;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(79,142,247,0.1);
}

.timer-circle svg {
  width: 100%; height: 100%;
  transform: rotate(-90deg);
}

.timer-circle-bg {
  fill: none;
  stroke: rgba(79,142,247,0.15);
  stroke-width: 2;
}

.timer-circle-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.1s linear;
}

.timer-time-text {
  position: absolute;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  font-family: 'DM Mono', monospace;
}

.timer-time-label::before {
  content: "Focus";
  display: block;
  font-family: 'Sora', sans-serif;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  line-height: 1;
  margin-bottom: 2px;
}

.timer-display.inactive {
  opacity: 0.5;
}

.timer-display.running {
  animation: timerGlow 1.8s ease-in-out infinite;
}

@keyframes timerGlow {
  0%, 100% { box-shadow: 0 14px 36px rgba(0,0,0,0.24), 0 0 0 rgba(79,142,247,0); }
  50% { box-shadow: 0 18px 44px rgba(0,0,0,0.3), 0 0 0 5px rgba(79,142,247,0.08); }
}

body.light .timer-display {
  background:
    linear-gradient(135deg, rgba(59,126,240,0.14), rgba(107,78,232,0.1)),
    rgba(255,255,255,0.9);
  border-color: rgba(59,126,240,0.2);
  box-shadow: 0 14px 34px rgba(79,142,247,0.16);
}

body.light .timer-display:hover {
  background:
    linear-gradient(135deg, rgba(59,126,240,0.2), rgba(107,78,232,0.13)),
    #fff;
  border-color: rgba(59,126,240,0.3);
}

body.light .timer-circle-bg {
  stroke: rgba(59,126,240,0.15);
}

/* ========== IMPROVED RESPONSIVE ========== */
@media (max-width: 768px) {
  .site-header { padding: 0.8rem 1rem; }
  main { padding: 0.5rem; margin: 0.5rem auto; }
  .home-hero-row { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .today-view-item {
    grid-template-columns: 34px 1fr auto;
  }
  .today-item-type {
    display: none;
  }
  .gpa-prev-grid { grid-template-columns: 1fr; }
  .gpa-results-grid { grid-template-columns: 1fr; }
  .gpa-add-mini { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .tasks-input-row { grid-template-columns: 1fr 1fr; }
  .tasks-input-row input:first-child { grid-column: 1 / -1; }
  .tasks-input-row button { grid-column: 1 / -1; }
  .tasks-input-row input[type="date"] {
    min-height: 40px;
    font-size: 14px;
  }
  .tasks-stats { grid-template-columns: 1fr; gap: 0.8rem; }
  .grade-form { grid-template-columns: 1fr 1fr; }
  .grade-actions { grid-column: 1/-1; justify-content: flex-end; }
  .settings-form .form-row { grid-template-columns: 1fr; }
  .schedule-controls,
  .cal-form-row,
  .modal-actions,
  .subject-form,
  .gpa-input-row,
  .chat-input-container {
    flex-direction: column;
    align-items: stretch;
  }
  .schedule-controls .btn,
  .subject-form .btn,
  .modal-actions .btn,
  .chat-input-container button { width: 100%; }
  .cal-field { min-width: unset; }
  .calendar-page-wrap { padding: 0 0.5rem; margin-top: 0.75rem; }
  .cal-header,
  .cal-form-row { padding: 1rem; }
  .cal-task-toggle {
    align-self: stretch;
    justify-content: center;
  }
  .cal-header { align-items: flex-start; gap: 0.8rem; }
  #monthLabel { font-size: 20px; }
  .weekday-row { font-size: 10px; padding-inline: 0.4rem; }
  #calendarGrid { padding: 0.25rem; }
  .month-day { min-height: 82px; padding: 4px; }
  .event-bar { height: 16px; }
  .event-text { font-size: 9px; }
  .timetable-container {
    padding: 0.55rem;
    overflow-x: hidden;
  }
  .timetable-grid {
    grid-template-columns: 44px repeat(5,minmax(0,1fr));
    min-width: 0;
    gap: 3px;
  }
  .day-header {
    height: 38px;
    padding: 6px 3px;
    border-radius: 8px;
    font-size: 11px;
  }
  .time-slot {
    font-size: 9px;
    line-height: 1.1;
    justify-content: flex-start;
    padding-left: 1px;
  }
  .slots-container {
    border-radius: 8px;
  }
  .class-block {
    left: 3px;
    right: 3px;
    border-radius: 8px;
    padding: 6px 5px 22px;
  }
  .class-topline {
    gap: 2px;
    padding-right: 12px;
  }
  .class-start,
  .class-end,
  .class-room {
    font-size: 8px;
  }
  .class-subject {
    display: -webkit-box;
    font-size: 9px;
    line-height: 1.15;
    white-space: normal;
    overflow: hidden;
    text-overflow: clip;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow-wrap: anywhere;
  }
  .class-block.is-short .class-subject {
    font-size: 9px;
  }
  .class-block.is-short .class-start {
    font-size: 8px;
  }
  .class-bottomline {
    left: 5px;
    right: 5px;
    bottom: 5px;
    gap: 3px;
  }
  .class-delete-x {
    top: 5px;
    right: 5px;
    font-size: 13px;
  }
  .modal-content { width: 95%; }
  .achievements-grid { grid-template-columns: repeat(2, 1fr); }
  .tasks-card,
  .subject-block,
  .gpa-card,
  .settings-about { padding: 1rem; }
  .todo-main { align-items: flex-start; }
  .todo-actions,
  .header-actions,
  .gpa-course-actions {
    margin-left: 0;
    align-self: flex-end;
  }
  .header-row,
  .gpa-card-head,
  .gpa-course-card {
    flex-direction: column;
    align-items: stretch;
  }
  .subject-block { overflow-x: visible; }
  .subject-block table {
    min-width: 0;
    table-layout: fixed;
  }
  .subject-block th,
  .subject-block td {
    padding: 8px 7px;
    font-size: 12px;
    overflow-wrap: anywhere;
  }
  .subject-block th {
    font-size: 9px;
    letter-spacing: 0.35px;
  }
  .subject-block th:last-child,
  .subject-block td:last-child {
    width: 74px;
  }
  .grade-actions-wrap {
    gap: 3px;
  }
  .grade-actions-wrap .icon-btn {
    width: 28px;
    height: 28px;
    min-height: 28px;
  }
  .gpa-table { min-width: 560px; }
  .settings-form .form-row {
    gap: 0.55rem;
    padding: 1rem;
  }
  .settings-account-card {
    flex-direction: column;
    align-items: stretch;
  }
  .settings-profile-avatar {
    width: 68px;
    height: 68px;
  }
  .settings-account-actions {
    width: 100%;
    justify-content: space-between;
  }
  .sync-state-pill {
    width: fit-content;
  }
  .settings-data-actions { grid-template-columns: 1fr; }
  .import-ready-box {
    align-items: stretch;
    flex-direction: column;
  }
  .chatbot-main { padding: 0.75rem 0.5rem; }
  .chat-container {
    height: calc(100dvh - 170px);
    min-height: 440px;
  }
  .message-content { max-width: 86%; }
  .global-timer-container {
    top: calc(68px + env(safe-area-inset-top));
    right: 0.75rem;
  }
}
@media (max-width: 480px) {
  .site-header { padding: 0.7rem 0.8rem; }
  .logo h1 { font-size: 1.1rem; }
  .achievements-grid { grid-template-columns: 1fr; }
  :root { --slot-height: 42px; }
  .schedule-page { padding: 0.55rem; }
  .schedule-controls { gap: 0.55rem; }
  .timetable-container { padding: 0.4rem; border-radius: 14px; }
  .timetable-grid { grid-template-columns: 34px repeat(5,minmax(0,1fr)); min-width: 0; gap: 2px; }
  .day-header { height: 34px; padding: 5px 2px; font-size: 10px; border-radius: 7px; }
  .time-slot { font-size: 7.5px; }
  .class-block {
    left: 2px;
    right: 2px;
    padding: 5px 4px 19px;
    border-radius: 7px;
  }
  .class-subject {
    font-size: 8px;
    line-height: 1.12;
  }
  .class-block.is-short .class-subject {
    font-size: 8px;
  }
  .class-block.is-short .class-start {
    font-size: 7px;
  }
  .class-start,
  .class-end,
  .class-room { font-size: 7px; }
  .class-room { display: none; }
  .class-delete-x { font-size: 12px; right: 4px; top: 4px; }
  .home-title { font-size: 22px; }
  .gpa-add-mini { grid-template-columns: 1fr; }
  .focus-meta-grid,
  .grade-insights,
  .quick-actions,
  .tasks-filter-row,
  .tasks-input-row,
  .subject-dashboard-grid,
  .todo-edit-grid { grid-template-columns: 1fr; }
  .tasks-input-row input:first-child,
  .tasks-input-row button { grid-column: auto; }
  .tasks-input-row input[type="date"],
  .todo-edit-grid input[type="date"] {
    min-height: 40px;
    font-size: 14px;
    padding: 10px 12px;
  }
  .subject-block th,
  .subject-block td {
    padding: 7px 5px;
    font-size: 11px;
  }
  .subject-block th {
    font-size: 8px;
    letter-spacing: 0.2px;
  }
  .subject-block th:last-child,
  .subject-block td:last-child {
    width: 62px;
  }
  .grade-actions-wrap .icon-btn {
    width: 24px;
    height: 24px;
    min-height: 24px;
  }
  .grade-actions-wrap svg {
    width: 13px;
    height: 13px;
  }
  .toast-stack {
    right: 0.75rem;
    bottom: 0.75rem;
    width: calc(100vw - 1.5rem);
  }
  .app-confirm-actions {
    flex-direction: column-reverse;
  }
  .app-confirm-actions .btn { width: 100%; }
  .auth-actions { grid-template-columns: 1fr; }
  .global-timer-container {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: calc(100vw - 1.5rem);
    justify-content: center;
  }
  .timer-display {
    width: min(260px, 100%);
    justify-content: center;
  }
}
