/* ===== TOKENS ===== */
:root {
  --ielts: #3b82f6; --hsk: #ef4444; --f8: #8b5cf6; --ptit: #14b8a6;
  --cfa: #f59e0b; --fsb: #ec4899; --msc: #6366f1; --waijyu: #f59e0b;
  --bg: #0f1117; --card: #1a1f2e; --card2: #141824;
  --line: #2a3347; --txt: #e2e8f4; --mut: #8899b4; --acc: #3b82f6;
  --good: #34d399; --warn: #f59e0b; --danger: #ef4444;
  --shadow: 0 2px 8px rgba(0,0,0,.25);
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #f5f6f8; --card: #ffffff; --card2: #f0f2f5;
  --line: #dde1ea; --txt: #111827; --mut: #6b7280; --acc: #2563eb;
  --good: #059669; --warn: #d97706; --danger: #dc2626;
  --shadow: 0 1px 4px rgba(0,0,0,.08);
  color-scheme: light;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; background: var(--bg); min-height: 100%; overflow-x: hidden; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--txt);
  display: flex; min-height: 100dvh; font-size: 15px; line-height: 1.55;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
button, input, textarea, select, a { touch-action: manipulation; }
button:focus-visible, input:focus-visible, textarea:focus-visible,
select:focus-visible, a:focus-visible {
  outline: 2px solid var(--acc); outline-offset: 2px;
}
.skip {
  position: fixed; left: 12px; top: -60px; z-index: 100;
  background: var(--acc); color: #fff; padding: 10px 14px;
  border-radius: 8px; transition: top .18s;
}
.skip:focus { top: 12px; }

/* ===== SIDEBAR ===== */
nav {
  width: 240px; background: var(--card2); border-right: 1px solid var(--line);
  padding: 16px 10px; position: sticky; top: 0; height: 100dvh;
  overflow-y: auto; flex: none;
}
.brand {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 8px; font-weight: 800; font-size: 16px; line-height: 1.2;
  padding: 4px 8px 14px; border-bottom: 1px solid var(--line); margin-bottom: 10px;
}
.brand-title { min-width: 0; }
.brand small { display: block; color: var(--mut); font-weight: 500; font-size: 11px; margin-top: 3px; }
.nav-i {
  display: flex; align-items: center; gap: 9px; min-height: 38px;
  padding: 8px 10px; border-radius: 8px; font-size: 14px; color: var(--mut);
  transition: background .15s, color .15s;
}
.nav-i:hover { background: var(--card); color: var(--txt); }
.nav-i.on { background: var(--acc); color: #fff; }
.nav-sec {
  font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--mut); padding: 14px 10px 4px; font-weight: 700;
}
.sdot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* ===== LAYOUT ===== */
main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 24px 28px 32px; min-width: 0; }
h2.title { font-size: clamp(22px, 3vw, 30px); line-height: 1.2; margin-bottom: 6px; }
h3 { font-size: 15px; line-height: 1.35; }
.muted { color: var(--mut); font-size: 13px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 12px; }
.stats-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* ===== TABS ===== */
.tabs { display: flex; gap: 6px; margin: 16px 0; overflow-x: auto; padding-bottom: 2px; }
.tab {
  background: var(--card2); border: 1px solid var(--line); color: var(--txt);
  min-height: 38px; padding: 7px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 600; white-space: nowrap; transition: background .15s;
}
.tab:hover { background: var(--card); }
.tab.on { background: var(--acc); border-color: var(--acc); color: #fff; }
.hide { display: none; }

/* ===== EVENTS ===== */
.ev {
  border-left: 3px solid var(--line); background: var(--card2);
  border-radius: 8px; padding: 9px 11px; font-size: 13px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 6px 0;
}
.ev .t { font-variant-numeric: tabular-nums; color: var(--mut); font-size: 13px; min-width: 96px; font-weight: 600; }
.ev .name { font-weight: 600; font-size: 14px; }
.ev .tag { font-size: 11px; color: var(--mut); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; }
.ev.exam { background: color-mix(in srgb, var(--warn) 12%, var(--card2)); border-left-color: var(--warn); }
.strat { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 5px; display: inline-flex; align-items: center; min-height: 20px; }
.s-split { background: #92400e; color: #fff; }
.s-dual  { background: #0f766e; color: #fff; }
.s-soft  { background: #475569; color: #fff; }
.s-exam  { background: #d97706; color: #fff; }

/* ===== WEEK / MONTH ===== */
.day { display: grid; grid-template-columns: 80px 1fr; border-bottom: 1px solid var(--line); }
.day:last-child { border: none; }
.dcol { padding: 12px 8px; text-align: center; border-right: 1px solid var(--line); background: var(--card2); }
.dname { font-size: 11px; color: var(--mut); }
.dnum  { font-size: 20px; font-weight: 700; }
.today .dnum { color: var(--acc); }
.ev-wrap { padding: 8px; }
.weekbox { background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin: 12px 0; overflow: hidden; }
.weekbox > h3 { font-size: 12px; padding: 10px 14px; background: var(--card2); border-bottom: 1px solid var(--line); }
.mgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.mhd { text-align: center; font-size: 11px; color: var(--mut); font-weight: 600; }
.mcell { background: var(--card2); border: 1px solid var(--line); border-radius: 8px; min-height: 90px; padding: 5px; }
.mcell.dim { opacity: .3; }
.mcell .n { font-size: 11px; font-weight: 700; color: var(--mut); }
.mcell.today { border-color: var(--acc); }
.mcell.today .n { color: var(--acc); }
.chip { font-size: 10px; color: #fff; border-radius: 4px; padding: 2px 4px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; font-weight: 600; }

/* ===== SUBJECTS ===== */
.subgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.subcard {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 15px; border-top: 3px solid var(--line);
  transition: border-color .15s;
}
.subcard:hover { border-top-color: var(--acc); }
.subcard h4 { font-size: 15px; line-height: 1.3; margin-bottom: 3px; }
.subcard .code { font-size: 12px; color: var(--mut); font-weight: 600; }
.subcard .prog { font-size: 12px; margin-top: 7px; color: var(--good); font-weight: 600; }
.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 5px; margin-top: 8px; color: #fff; font-weight: 700; }

/* ===== INPUTS ===== */
input, textarea, select {
  width: 100%; background: var(--card2); border: 1px solid var(--line);
  color: var(--txt); border-radius: 8px; padding: 9px 11px; font-size: 15px; font-family: inherit;
}
input:focus, textarea:focus, select:focus { border-color: var(--acc); outline: none; }
textarea { min-height: 120px; resize: vertical; line-height: 1.6; }

/* ===== BUTTONS ===== */
.btn {
  background: var(--acc); color: #fff; border: 1px solid var(--acc);
  min-height: 38px; padding: 8px 15px; border-radius: 8px;
  font-weight: 600; font-size: 13px; transition: opacity .15s;
}
.btn:hover { opacity: .88; }
.btn.ghost { background: var(--card2); border-color: var(--line); color: var(--txt); }
.btn.ghost:hover { background: var(--card); }
.btn.sm { min-height: 32px; padding: 5px 10px; font-size: 12px; }
.btn.icon { width: 40px; min-width: 40px; height: 40px; min-height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; }
.btn.danger { background: color-mix(in srgb, var(--danger) 15%, var(--card2)); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); color: var(--txt); }

/* ===== MISC ===== */
.field  { margin: 9px 0; }
.label  { font-size: 12px; color: var(--mut); margin-bottom: 4px; display: block; font-weight: 600; }
.item   { background: var(--card2); border: 1px solid var(--line); border-radius: 8px; padding: 11px; margin: 8px 0; display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.term   { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.term b { color: var(--warn); }
.fc     { background: var(--card); border: 1px solid var(--line); border-radius: 12px; min-height: 200px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 30px; font-size: 18px; cursor: pointer; position: relative; }
.fc small { position: absolute; top: 12px; left: 14px; color: var(--mut); font-size: 11px; }
.statline { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 6px; }
.stat   { font-size: 13px; color: var(--mut); }
.stat b { color: var(--txt); font-size: 17px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.tools  { display: flex; gap: 8px; }

/* ===== MOBILE MENU BTN ===== */
.menubtn  { display: none; position: fixed; top: 12px; right: 12px; z-index: 60; }
.themebtn { min-width: 40px; }

/* ===== MOBILE ===== */
@media (max-width: 760px) {
  body { display: block; font-size: 16px; }
  nav {
    position: fixed; left: -260px; z-index: 50;
    transition: left .22s ease; width: 250px;
    box-shadow: 4px 0 16px rgba(0,0,0,.2);
  }
  nav.open { left: 0; }
  main { padding: 16px 14px 28px; max-width: 100%; }
  .menubtn { display: inline-flex; align-items: center; justify-content: center; }
  .topbar { padding-right: 54px; }
  h2.title { font-size: 22px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr !important; }
  .day { grid-template-columns: 60px 1fr; }
  .ev { display: grid; grid-template-columns: 1fr; gap: 4px; }
  .ev .t { min-width: 0; }
  .mgrid { gap: 3px; }
  .mcell { min-height: 70px; padding: 4px; }
  .chip { font-size: 11px; padding: 2px 4px; }
  .subgrid { grid-template-columns: 1fr; }
  .item { display: grid; grid-template-columns: 1fr auto; gap: 7px; align-items: start; }
  .term { display: grid; grid-template-columns: 1fr; gap: 7px; }
  .btn { min-height: 44px; }
  .exam-del { min-height: 32px !important; padding: 4px 10px !important; align-self: start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
