:root {
  --bg: #101018;
  --surface: #1a1a25;
  --surface-2: #232331;
  --line: rgba(255, 255, 255, .06);
  --text: #f4f3f8;
  --muted: #9b99ad;
  --faint: #6c6a80;
  --accent: #b59cff;
  --accent-strong: #9d7dff;
  --accent-ink: #1b1530;
  --red: #ff6b6b;
  --amber: #f7b84b;
  --green: #4ade80;
  --blue: #5b9cff;
  --violet: #a78bfa;
  --radius: 22px;
  --radius-sm: 14px;
  --tabbar: 74px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 12px);
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.status { text-align: center; color: var(--muted); padding: 40px 16px; }
[hidden] { display: none !important; }

/* ---- hero ---------------------------------------------------------------------- */
.hero {
  position: relative;
  padding: calc(18px + env(safe-area-inset-top)) 20px 18px;
  background:
    radial-gradient(120% 80% at 85% 0%, rgba(255, 170, 150, .55), transparent 60%),
    radial-gradient(90% 70% at 10% 10%, rgba(140, 110, 220, .55), transparent 65%),
    radial-gradient(120% 90% at 50% 100%, rgba(30, 30, 52, 1), transparent 70%),
    linear-gradient(180deg, #5a4a78 0%, #2b2640 55%, var(--bg) 100%);
  border-radius: 0 0 28px 28px;
  overflow: hidden;
}
.hero::after { /* soft hills, like the reference */
  content: ""; position: absolute; left: -10%; right: -10%; bottom: 64px; height: 90px;
  background: radial-gradient(60% 100% at 30% 100%, rgba(20, 20, 34, .55), transparent 70%),
              radial-gradient(60% 100% at 80% 100%, rgba(20, 20, 34, .45), transparent 70%);
  pointer-events: none;
}
.hero-top { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.hello { color: rgba(255, 255, 255, .8); font-size: 17px; }
.name { font-size: 34px; font-weight: 800; letter-spacing: -.02em; margin: 2px 0 6px; }
.sub { color: rgba(255, 255, 255, .75); font-size: 15px; }
.avatar { width: 56px; height: 56px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: rgba(20, 20, 30, .55); font-weight: 700; font-size: 22px; overflow: hidden; backdrop-filter: blur(6px); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.strip { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 22px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 0 9px; border-radius: 14px; color: rgba(255, 255, 255, .72); }
.day .wd { font-size: 13px; }
.day .dn { font-size: 19px; font-weight: 600; color: var(--text); }
.day .pips { display: flex; gap: 3px; height: 5px; }
.day .pip { width: 5px; height: 5px; border-radius: 50%; }
.day.today { color: var(--text); }
.day.sel { background: var(--accent); color: var(--accent-ink); }
.day.sel .dn { color: var(--accent-ink); }
.day.sel .pip { outline: 1.5px solid var(--accent); }

/* ---- layout ---------------------------------------------------------------------- */
.pad { padding: 0 16px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 26px 4px 12px; }
.section-head h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.see { color: var(--accent); font-size: 15px; font-weight: 500; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card.pad-y { padding: 6px 0; }
.page-title { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: calc(20px + env(safe-area-inset-top)) 20px 4px; }
.page-sub { color: var(--muted); margin: 0 20px 6px; }
.empty { color: var(--muted); text-align: center; padding: 26px 16px; }

/* ---- stat tiles ------------------------------------------------------------------ */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.tile { display: flex; align-items: center; gap: 12px; padding: 16px 30px 16px 14px; border-radius: var(--radius); text-align: left;
  border: 1px solid var(--line); position: relative; }
.tile .ibox { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; flex: none; }
.tile .num { font-size: 26px; font-weight: 700; line-height: 1.05; }
.tile .lbl { color: rgba(255, 255, 255, .7); font-size: 13.5px; line-height: 1.2; }
.tile .chev { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: rgba(255, 255, 255, .55); }
.tile.blue { background: linear-gradient(135deg, #263a5e, #22283d); }
.tile.blue .ibox { background: var(--blue); }
.tile.red { background: linear-gradient(135deg, #5a2c36, #2a2230); }
.tile.red .ibox { background: var(--red); }
.tile.green { background: linear-gradient(135deg, #1f4b3b, #1f2b2a); }
.tile.green .ibox { background: var(--green); color: #0f2a1d; }
.tile.violet { background: linear-gradient(135deg, #3d3166, #262338); }
.tile.violet .ibox { background: var(--violet); }

/* ---- rows ------------------------------------------------------------------------ */
.row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; width: 100%; text-align: left; }
.row + .row { border-top: 1px solid var(--line); }
.ibadge { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex: none; color: #fff; }
.rmain { flex: 1; min-width: 0; }
.rname { font-size: 16px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.rsub { color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rside { color: var(--muted); font-size: 14.5px; white-space: nowrap; }
.rside.hot { color: var(--red); }
.rchev { color: var(--faint); flex: none; }

.check { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .8); flex: none; display: grid; place-items: center; }
.check.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.check.locked { opacity: .6; }
.done .rname { text-decoration: line-through; color: var(--muted); }
.done .rside { text-decoration: line-through; color: var(--faint); }

/* ---- grades ---------------------------------------------------------------------- */
.chips { display: flex; gap: 10px; overflow-x: auto; padding: 14px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; width: 124px; display: block; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); border-radius: 18px; padding: 14px; scroll-snap-align: start; text-align: left; }
.chip .cn { color: rgba(255, 255, 255, .85); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .cp { font-size: 22px; font-weight: 700; margin: 4px 0 10px; }
.meter { height: 7px; border-radius: 4px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 4px; }

.gcard { padding: 18px; margin-bottom: 12px; }
.ghead { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.gname { font-weight: 700; font-size: 17px; }
.gcode { color: var(--muted); font-size: 13px; }
.gpct { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.gbar { position: relative; height: 12px; border-radius: 6px; background: rgba(255, 255, 255, .07); margin: 16px 0 22px; }
.gbar .range { position: absolute; top: 0; bottom: 0; border-radius: 6px; background: rgba(181, 156, 255, .2); }
.gbar .fill { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 6px; }
.gbar .proj { position: absolute; top: -4px; width: 3px; height: 20px; border-radius: 2px; background: #fff; box-shadow: 0 0 0 2px var(--surface); }
.gbar .tick { position: absolute; top: 16px; transform: translateX(-50%); font-size: 11px; color: var(--faint); }
.gbar .tick::before { content: ""; position: absolute; left: 50%; top: -16px; width: 1px; height: 12px; background: rgba(255, 255, 255, .25); }
.gline { color: var(--muted); font-size: 14px; margin-top: 4px; }
.gline b { color: var(--text); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pill { font-size: 12.5px; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill.ok { color: var(--green); }
.pill.no { color: var(--red); }
.legend { color: var(--faint); font-size: 12.5px; margin: 4px 6px 14px; }

/* ---- this week ------------------------------------------------------------------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); padding: 14px 8px; }
.wcol { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 0 10px; border-radius: 16px; min-height: 120px; }
.wcol + .wcol { border-left: 1px solid var(--line); }
.wcol.today { background: var(--surface-2); border-left-color: transparent; }
.wcol .wd { color: var(--muted); font-size: 13px; }
.wcol .dn { font-size: 17px; font-weight: 600; }
.wbar { width: 22px; height: 7px; border-radius: 4px; }
.wdot { width: 8px; height: 8px; border-radius: 50%; }
.wmark.done { opacity: .35; }

/* ---- detail ---------------------------------------------------------------------- */
.dhead { display: flex; gap: 14px; align-items: center; margin: calc(20px + env(safe-area-inset-top)) 20px 14px; }
.dhead .ibadge { width: 56px; height: 56px; border-radius: 17px; }
.dtitle { font-size: 21px; font-weight: 700; line-height: 1.2; }
.dsub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 16px 16px; }
.btn { padding: 11px 16px; border-radius: 14px; background: var(--surface-2); font-weight: 600; font-size: 14.5px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: .5; }
.brief { padding: 18px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.brief b { color: #fff; }
.brief a { color: var(--accent); }
.brief pre { white-space: pre-wrap; background: var(--surface-2); padding: 12px; border-radius: 12px; }

/* ---- tab bar ---------------------------------------------------------------------- */
.tabbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 10;
  height: var(--tabbar); display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: rgba(30, 30, 42, .88); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line); border-radius: 26px; padding: 6px;
}
.tabbtn { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; border-radius: 20px; color: #c9c7d6; font-size: 11.5px; }
.tabbtn.active { background: rgba(181, 156, 255, .14); color: var(--accent); }
.dot-badge { position: absolute; top: 6px; right: calc(50% - 16px); width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px #1e1e2a; }
.ico svg { width: 24px; height: 24px; display: block; }
.ibadge svg, .ibox svg { width: 24px; height: 24px; }

.toast { position: fixed; left: 20px; right: 20px; bottom: calc(var(--tabbar) + 24px + env(safe-area-inset-bottom)); z-index: 20;
  background: #f4f3f8; color: #15141c; padding: 13px 16px; border-radius: 16px; font-size: 14.5px; text-align: center; font-weight: 500; }
.count { color: var(--muted); font-size: 14px; }
.avatar.blank { background: rgba(20, 20, 30, .35); }
.waitlist { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.wait { font-size: 12.5px; padding: 4px 9px; border-radius: 8px; background: rgba(91, 156, 255, .14); color: #a9c8ff;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wait.more { background: var(--surface-2); color: var(--muted); }
.tools-label { margin: 4px 20px 8px; color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; }
.btn.tool { background: rgba(181, 156, 255, .12); color: var(--accent); }

/* ---- month calendar ---------------------------------------------------------------- */
.cal-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; padding-right: 16px; }
.cal-title { margin-bottom: 4px; font-size: 26px; white-space: nowrap; }
.cal-nav { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.navbtn { width: 38px; height: 38px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; color: var(--text); }
.navbtn .ico svg { width: 20px; height: 20px; }
.flip { transform: scaleX(-1); }
.pillbtn { padding: 8px 12px; border-radius: 12px; background: rgba(181, 156, 255, .14); color: var(--accent); font-weight: 600; font-size: 14px; }
.cal-card { padding: 10px 8px 12px; margin-top: 8px; touch-action: pan-y; }
.cgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cwd { text-align: center; color: var(--muted); font-size: 12px; padding: 4px 0 6px; }
.cday { aspect-ratio: 1 / 1.18; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 5px; padding-top: 7px; min-width: 0; }
.cday .cnum { font-size: 15px; font-weight: 600; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; }
.cday.out { opacity: .35; }
.cday.has { background: rgba(255, 255, 255, .03); }
.cday.today .cnum { box-shadow: inset 0 0 0 2px var(--accent); }
.cday.sel { background: var(--accent); color: var(--accent-ink); }
.cday.sel .cnum { box-shadow: none; }
.cmarks { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; max-width: 34px; }
.cmark { width: 7px; height: 7px; border-radius: 50%; }
.cmark.done { opacity: .5; }
.cday.sel .cmark { box-shadow: 0 0 0 1.5px var(--accent); }
.cmore { font-size: 10px; font-weight: 700; color: var(--muted); line-height: 7px; }
.cday.sel .cmore { color: var(--accent-ink); }
.legend-row { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 12px 6px 0; }
.lg { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); max-width: 100%; }
.lg i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.homescreen { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 16px; margin-top: 22px; color: var(--text); }
.homescreen > .ico { color: var(--accent); }
.homescreen b { display: block; font-size: 16px; }
.hs-sub { color: var(--muted); font-size: 13px; }
