:root {
  --bg: #eceff4;
  --ink: #0e1116;
  --muted: #5b6270;
  --faint: #8a91a0;
  --rule: #cfd5de;
  --card: #f7f8fa;
  --grey: #dde1e8;
  --blue: #2b63e3;
  --blue-soft: #6f94f0;
  --on-dark: #ffffff;
  --on-dark-muted: rgba(255, 255, 255, 0.72);
  --radius: 22px;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d11;
    --ink: #f2f4f7;
    --muted: #9aa2b1;
    --faint: #6b7280;
    --rule: #262b33;
    --card: #15181e;
    --grey: #1d2129;
    --blue: #3a70ef;
    --blue-soft: #8aa9f5;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d11;
  --ink: #f2f4f7;
  --muted: #9aa2b1;
  --faint: #6b7280;
  --rule: #262b33;
  --card: #15181e;
  --grey: #1d2129;
  --blue: #3a70ef;
  --blue-soft: #8aa9f5;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: Manrope, -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  font-feature-settings: "tnum" 1, "lnum" 1;
  -webkit-font-smoothing: antialiased;
  line-height: 1.4;
}

.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) var(--gutter) calc(env(safe-area-inset-bottom) + 32px);
}

/* Masthead: brand, meta, pill, hairline — as on the deck. */
.masthead {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 16px;
  padding-bottom: 14px;
  border-bottom: 1.5px solid var(--rule);
}
.brand { font-weight: 700; letter-spacing: -0.02em; font-size: 17px; }
.meta { color: var(--muted); font-size: 14px; grid-column: 1 / -1; grid-row: 2; }
@media (min-width: 760px) {
  .masthead { grid-template-columns: auto 1fr auto; }
  .meta { grid-column: 2; grid-row: 1; padding-left: 24px; }
}
.pill {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  border: 0;
  border-radius: 999px;
  padding: 7px 14px;
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
  white-space: nowrap;
}

/* Lead: big tight headline + muted aside. */
.lead {
  display: grid;
  gap: 10px;
  padding: 26px 0 22px;
}
.lead h1 {
  margin: 0;
  font-size: clamp(34px, 9vw, 64px);
  line-height: 1.02;
  font-weight: 600;
  letter-spacing: -0.045em;
  text-wrap: balance;
}
.aside { color: var(--muted); font-size: 15px; margin: 0; }
@media (min-width: 760px) {
  .lead { grid-template-columns: 1.7fr 1fr; align-items: end; gap: 32px; }
  .lead .aside { text-align: right; font-size: 17px; }
}

/* Bento tiles. */
.bento {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 760px) { .bento { grid-template-columns: repeat(4, 1fr); } }

.tile {
  border-radius: var(--radius);
  padding: 16px 18px 18px;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--grey);
  overflow: hidden;
}
.tile .label { font-size: 14px; color: var(--muted); }
.tile .num {
  font-size: clamp(40px, 11vw, 56px);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-top: 18px;
}
.tile .num small { font-size: 0.42em; letter-spacing: -0.02em; margin-left: 2px; }
.tile .cap { font-size: 14px; margin-top: 6px; line-height: 1.3; }
.tile.blue { background: var(--blue); color: var(--on-dark); }
.tile.dark { background: #0e1116; color: var(--on-dark); }
.tile.light { background: var(--card); }
.tile.blue .label, .tile.dark .label { color: var(--on-dark-muted); }
.tile.wide { grid-column: span 2; }

/* Blocks. */
.block { margin-top: 36px; }
.block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.block-head h2 {
  margin: 0;
  font-size: clamp(24px, 6vw, 32px);
  font-weight: 600;
  letter-spacing: -0.035em;
}

/* Numbered rows with hairlines. */
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 4px 12px;
  align-items: baseline;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule);
}
.row:first-child { border-top: 1px solid var(--rule); }
.row .idx { color: var(--blue); font-weight: 600; font-size: 15px; }
.row .course { font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
.row .sub { grid-column: 2; color: var(--muted); font-size: 14px; }
.row .tag { grid-row: 1 / span 2; grid-column: 3; align-self: center; }
.row.done .course, .row.done .idx { color: var(--faint); }

.tag {
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  padding: 5px 11px;
  background: var(--grey);
  color: var(--muted);
  white-space: nowrap;
}
.tag.now { background: var(--blue); color: #fff; }
.tag.next { background: var(--ink); color: var(--bg); }
.tag.absent { background: transparent; color: #c23a2b; box-shadow: inset 0 0 0 1.5px currentColor; }

.empty {
  padding: 22px 20px;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--muted);
  font-size: 15px;
}

/* Leave cards. */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 10px;
}
@media (min-width: 760px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
}
.leave {
  border-radius: var(--radius);
  padding: 14px 14px 14px;
  background: var(--card);
  display: flex;
  flex-direction: column;
  min-height: 160px;
}
@media (min-width: 760px) { .leave { padding: 16px 18px 18px; min-height: 176px; } }
.leave .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.leave .name { font-weight: 600; font-size: 14px; hyphens: auto; line-height: 1.25; letter-spacing: -0.01em; }
.leave .cr { font-size: 13px; color: var(--blue); font-weight: 600; white-space: nowrap; }
.leave .big {
  margin-top: auto;
  padding-top: 16px;
  font-size: 46px;
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1;
}
.leave .big small { font-size: 14px; letter-spacing: 0; font-weight: 500; color: var(--muted); margin-left: 6px; }
.leave .foot {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 2px 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
  font-size: 12.5px;
  color: var(--muted);
}
.leave.zero { background: #0e1116; color: #fff; }
.leave.zero .big small, .leave.zero .foot { color: var(--on-dark-muted); }
.leave.zero .foot { border-color: rgba(255, 255, 255, 0.16); }
.leave.zero .cr { color: var(--blue-soft); }
.leave.focus { background: var(--blue); color: #fff; }
.leave.focus .cr { color: #fff; }
.leave.focus .big small, .leave.focus .foot { color: var(--on-dark-muted); }
.leave.focus .foot { border-color: rgba(255, 255, 255, 0.22); }

.stepper { display: inline-flex; gap: 6px; }
.stepper button {
  font: inherit;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 0;
  background: var(--grey);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.sources {
  margin-top: 40px;
  color: var(--faint);
  font-size: 13px;
  line-height: 1.6;
}
.sources button {
  font: inherit;
  color: var(--blue);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* Settings sheet. */
dialog {
  border: 0;
  padding: 0;
  border-radius: 26px;
  background: var(--bg);
  color: var(--ink);
  width: min(560px, calc(100vw - 2 * var(--gutter)));
  max-height: 86vh;
}
dialog::backdrop { background: rgba(14, 17, 22, 0.42); backdrop-filter: blur(6px); }
.sheet { padding: 22px; display: grid; gap: 16px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet h2 { margin: 0; font-size: 26px; letter-spacing: -0.035em; font-weight: 600; }
.sheet h3 { margin: 6px 0 0; font-size: 15px; color: var(--muted); font-weight: 600; }
.icon-btn { font: inherit; border: 0; background: var(--grey); color: var(--ink); width: 34px; height: 34px; border-radius: 999px; cursor: pointer; }
.pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pick label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
select {
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 10px;
  width: 100%;
}
.toggles { display: grid; gap: 2px; max-height: 40vh; overflow: auto; }
.toggles label {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 2px;
  border-bottom: 1px solid var(--rule);
  font-size: 15px;
}
.toggles input { accent-color: var(--blue); width: 18px; height: 18px; }
.sheet-actions { display: flex; justify-content: flex-end; }
.btn { font: inherit; font-weight: 600; border: 0; border-radius: 999px; padding: 11px 22px; cursor: pointer; }
.btn.primary { background: var(--blue); color: #fff; }

@media (prefers-reduced-motion: no-preference) {
  .tile, .leave { transition: transform 0.2s ease; }
}

/* ---------- Landing ---------- */
.hero-lead { padding: 12vh 0 8vh; display: grid; gap: 22px; justify-items: start; }
.hero-lead h1 {
  margin: 0;
  font-size: clamp(40px, 10vw, 76px);
  line-height: 1.02;
  font-weight: 600;
  letter-spacing: -0.045em;
  max-width: 14ch;
  text-wrap: balance;
}
.btn.big { padding: 16px 28px; font-size: 17px; }

/* ---------- Tabs (segmented) ---------- */
.tabs {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  margin-top: 16px;
  border-radius: 999px;
  background: var(--grey);
}
.tabs button {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  border: 0;
  border-radius: 999px;
  padding: 8px 18px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(14, 17, 22, 0.08); }
[data-view] { margin-top: 4px; }
.block-head.first { margin-top: 26px; }

/* ---------- Week view ---------- */
.week-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 26px; }
.week-head h2 { margin: 0; font-size: clamp(24px, 6vw, 32px); font-weight: 600; letter-spacing: -0.035em; }
.week-nav { display: flex; gap: 6px; align-items: center; }
.pill.ghost { background: var(--grey); color: var(--ink); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 14px 0 12px; }
.day {
  font: inherit;
  border: 0;
  border-radius: 16px;
  padding: 10px 0 8px;
  background: var(--card);
  color: var(--ink);
  display: grid;
  justify-items: center;
  gap: 2px;
  cursor: pointer;
}
.day .dow { font-size: 12px; color: var(--muted); }
.day .dnum { font-size: 20px; font-weight: 600; letter-spacing: -0.03em; }
.day .dots { font-size: 9px; line-height: 1; letter-spacing: 1px; color: var(--blue); min-height: 9px; }
.day.today .dnum { color: var(--blue); }
.day.off { background: transparent; box-shadow: inset 0 0 0 1px var(--rule); }
.day.sel { background: var(--ink); color: var(--bg); }
.day.sel .dow { color: inherit; opacity: 0.7; }
.day.sel .dots, .day.sel.today .dnum { color: inherit; }
.day-flag { margin: 0 0 10px; }

/* ---------- Settings extras ---------- */
.sheet-head .aside { font-size: 13px; margin-top: 4px; }
.sheet-actions { flex-wrap: wrap; gap: 8px; }
.btn.ghost-btn { background: var(--grey); color: var(--ink); }
.btn.danger { color: #c23a2b; }
.sheet-actions .btn.primary { margin-left: auto; }
.install-ios { margin: 0; font-size: 13px; }
@media (max-width: 480px) { .pick { grid-template-columns: 1fr 1fr 1fr; gap: 6px; } }

/* ---------- Remote sign-in ---------- */
.signin {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding-top: env(safe-area-inset-top);
}
.signin-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--rule);
}
.urlbar {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  height: 34px;
  border-radius: 12px;
  background: var(--grey);
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.lock {
  width: 10px;
  height: 12px;
  border-radius: 2px;
  background: var(--muted);
  position: relative;
  flex: none;
  margin-top: 3px;
}
.lock::before {
  content: "";
  position: absolute;
  left: 2px;
  top: -5px;
  width: 6px;
  height: 7px;
  border: 1.6px solid var(--muted);
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  box-sizing: border-box;
}
.stage { position: relative; flex: 1; overflow: hidden; background: #fff; padding-bottom: env(safe-area-inset-bottom); }
.stage canvas { display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
#signin-keys {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: 0;
  padding: 0;
  font-size: 16px;
  pointer-events: none;
  resize: none;
}
.stage-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: var(--bg);
  color: var(--muted);
  font-size: 15px;
  text-align: center;
  padding: 24px;
}
.stage-overlay[hidden] { display: none; }
.stage-overlay.error .spinner { display: none; }
.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--grey);
  border-top-color: var(--blue);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ---------- On-phone sign-in ---------- */
.linkin { padding: 6vh 0 4vh; }
.linkin h1 { margin: 0 0 18px; font-size: clamp(32px, 8vw, 52px); font-weight: 600; letter-spacing: -0.04em; line-height: 1.05; }
.steps { list-style: none; margin: 0; padding: 0; }
.steps li {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  padding: 18px 0;
  border-top: 1px solid var(--rule);
}
.steps li:last-child { border-bottom: 1px solid var(--rule); }
.steps .idx { color: var(--blue); font-weight: 600; font-size: 15px; padding-top: 2px; }
.step { display: grid; gap: 12px; justify-items: start; }
.step-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.35; }
.step-title q { font-weight: 500; color: var(--muted); }
a.btn { text-decoration: none; display: inline-block; }
a.btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.link-input {
  font: inherit;
  font-size: 16px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--ink);
}
.link-error { color: #c23a2b; font-size: 15px; margin: 14px 0 0; }
.link-foot { display: flex; justify-content: space-between; margin-top: 18px; }
.link-btn { font: inherit; font-size: 15px; color: var(--blue); background: none; border: 0; padding: 6px 0; cursor: pointer; }

/* ---------- Profile ---------- */
.mast-actions { display: flex; align-items: center; gap: 8px; }
@media (min-width: 760px) { .masthead { grid-template-columns: auto 1fr auto; } }
.avatar-btn { border: 0; padding: 0; background: none; cursor: pointer; border-radius: 999px; }
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: var(--blue) center / cover no-repeat;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  overflow: hidden;
}
.avatar.lg { width: 60px; height: 60px; font-size: 22px; flex: none; }
.profile-head { display: flex; align-items: center; gap: 14px; }
.profile-id { flex: 1; min-width: 0; }
.profile-id h2 { margin: 0; font-size: 22px; letter-spacing: -0.03em; font-weight: 600; overflow-wrap: anywhere; }
.profile-id .aside { font-size: 13px; margin-top: 3px; overflow-wrap: anywhere; }
.menu { display: grid; border-radius: 16px; overflow: hidden; background: var(--card); }
.menu-row {
  font: inherit;
  font-size: 15px;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  color: var(--ink);
  padding: 14px 16px;
  cursor: pointer;
}
.menu-row:last-child { border-bottom: 0; }
.menu-row.danger { color: #c23a2b; }
.menu-row.confirm { background: #c23a2b; color: #fff; }
.menu-note { margin: 0; padding: 12px 16px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--rule); }
