:root {
  --bg: #f3efe7;
  --ink: #241816;
  --muted: #6f625b;
  --wine: #7c2430;
  --wine-deep: #4c1219;
  --card: #fffdf9;
  --line: #e5d9ce;
  --ok: #1d6b45;
  --ok-bg: #e5f4eb;
  --bad: #9d2433;
  --bad-bg: #fde8ea;
  --wait: #8a6a32;
  --shadow: 0 10px 30px rgba(76, 18, 25, 0.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 400px at 50% -10%, rgba(124, 36, 48, 0.18), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.4;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
}
.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 28px 22px 22px;
  box-shadow: var(--shadow);
}
.mark {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--wine);
  color: #f6efe4;
  display: grid;
  place-items: center;
  font-family: Georgia, "Iowan Old Style", serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 16px;
}
h1 {
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 34px;
  line-height: 1;
  margin: 0 0 8px;
  font-weight: 700;
}
.lede { margin: 0 0 22px; color: var(--muted); }
label { display: block; font-size: 13px; font-weight: 650; margin: 14px 0 6px; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 14px 14px;
  outline: none;
}
input:focus, select:focus { border-color: var(--wine); box-shadow: 0 0 0 3px rgba(124, 36, 48, 0.12); }
.primary, .ghost {
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  font-weight: 700;
}
.primary { background: var(--wine); color: #fffaf6; width: 100%; margin-top: 18px; }
.primary:disabled { opacity: 0.6; }
.ghost { background: transparent; color: var(--wine-deep); }
.error {
  background: var(--bad-bg);
  color: var(--bad);
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 14px;
}
.hint {
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  background: #f7f1e8;
  border-radius: 14px;
  padding: 12px;
}

.shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + var(--safe-top)) 14px 12px;
  background: rgba(76, 18, 25, 0.96);
  color: #f6efe4;
  backdrop-filter: blur(10px);
}
.burger, .icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  display: grid;
  place-items: center;
}
.burger span, .burger span:before, .burger span:after {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  position: relative;
  border-radius: 2px;
}
.burger span:before, .burger span:after {
  content: "";
  position: absolute;
  left: 0;
}
.burger span:before { top: -6px; }
.burger span:after { top: 6px; }
.top-title { flex: 1; min-width: 0; }
.top-title strong { display: block; font-size: 16px; }
.top-title small { display: block; opacity: 0.75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week-nav { display: flex; gap: 6px; }

.drawer-back {
  position: fixed;
  inset: 0;
  background: rgba(28, 16, 14, 0.45);
  z-index: 20;
}
.drawer {
  position: fixed;
  z-index: 21;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(320px, 86vw);
  background: #fffdf9;
  padding: calc(18px + var(--safe-top)) 16px calc(18px + var(--safe-bottom));
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.drawer header { margin-bottom: 12px; }
.drawer header b { font-family: Georgia, serif; font-size: 28px; display: block; }
.drawer header span { color: var(--muted); font-size: 14px; }
.nav-btn {
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 14px;
  padding: 14px 12px;
  font-weight: 700;
}
.nav-btn.active { background: #f6e8e4; color: var(--wine); }
.drawer .logout { margin-top: auto; color: var(--bad); }

.content { padding: 16px 14px calc(24px + var(--safe-bottom)); max-width: 760px; margin: 0 auto; }
.hello { margin: 4px 0 14px; }
.hello h2 { font-family: Georgia, serif; font-size: 30px; margin: 0; }
.hello p { margin: 4px 0 0; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.next {
  background: linear-gradient(160deg, #7c2430, #4c1219);
  color: #f6efe4;
  border: 0;
}
.next .kicker { letter-spacing: 0.08em; text-transform: uppercase; font-size: 12px; opacity: 0.75; }
.next h3 { margin: 6px 0; font-size: 22px; font-family: Georgia, serif; }
.meta { color: var(--muted); font-size: 14px; }
.next .meta { color: rgba(246, 239, 228, 0.82); }
.row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.time { font-variant-numeric: tabular-nums; font-weight: 750; }
.day-title {
  margin: 18px 0 8px;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.day-title.today { color: var(--wine); }
.lesson h3 { margin: 0 0 4px; font-size: 17px; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
  background: #f3ece4;
}
.next .badge { background: rgba(255,255,255,0.12); }
.empty { color: var(--muted); padding: 12px 2px 4px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.stat b { display: block; font-size: 22px; font-family: Georgia, serif; }
.stat span { color: var(--muted); font-size: 12px; }
.pill { border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 750; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.score { font-family: Georgia, serif; font-size: 28px; }
.score small { font-size: 14px; color: var(--muted); font-family: "Avenir Next", sans-serif; }
.semester { margin: 8px 0 10px; }
.semester h3 { margin: 0; font-family: Georgia, serif; }
.course-name { font-weight: 700; }
.wait { color: var(--wait); font-size: 13px; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar select { flex: 1; }
.doc-cat { margin: 16px 0 8px; font-size: 13px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.doc {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  text-decoration: none;
}
.doc b { display: block; }
.doc span { color: var(--muted); font-size: 13px; }
.dl {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #f6e8e4;
  color: var(--wine);
  font-weight: 800;
}
.note { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.loading { padding: 24px 0; color: var(--muted); }

.content.is-edt {
  background: #eef2f7;
  max-width: 820px;
}
.edt-head {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.edt-head strong {
  display: block;
  text-align: center;
  font-size: 16px;
  text-transform: capitalize;
}
.edt-head span {
  display: block;
  text-align: center;
  color: #6b7785;
  font-size: 12px;
}
.edt-arrow, .edt-today {
  border: 0;
  background: #fff;
  color: #245ca8;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(20, 40, 70, 0.08);
}
.edt-arrow { height: 40px; font-size: 26px; line-height: 1; }
.edt-today {
  display: block;
  width: 100%;
  margin: 0 0 10px;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 14px;
}
.daystrip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  position: sticky;
  top: calc(66px + var(--safe-top));
  z-index: 4;
  background: #eef2f7;
  padding: 4px 0 8px;
}
.daychip {
  border: 0;
  background: transparent;
  border-radius: 14px;
  padding: 6px 0 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  color: #5d6b7a;
  min-height: 62px;
}
.daychip span { font-size: 11px; font-weight: 700; letter-spacing: 0.02em; }
.daychip strong { font-size: 16px; line-height: 1.1; }
.daychip i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: transparent;
  display: block;
}
.daychip i.has { background: #2f6fbf; }
.daychip i.done { background: #c5ccd3; }
.daychip.is-on {
  background: #2f6fbf;
  color: #fff;
}
.daychip.is-on i.has, .daychip.is-on i.done { background: rgba(255, 255, 255, 0.85); }
.daychip.is-today:not(.is-on) strong { color: #2f6fbf; }
.daychip.is-done:not(.is-on) { color: #9aa3ad; }
.edt-day {
  margin: 8px 2px 12px;
  font-size: 22px;
  font-family: Georgia, "Iowan Old Style", serif;
  text-transform: capitalize;
}
.timeline { display: flex; flex-direction: column; gap: 8px; }
.slot {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 8px;
  align-items: stretch;
}
.slot-time {
  text-align: right;
  padding-top: 10px;
  color: #6b7785;
  font-variant-numeric: tabular-nums;
}
.slot-time b { display: block; font-size: 14px; color: #243140; }
.slot-time span { font-size: 12px; }
.slot-card {
  background: var(--wash);
  border-radius: 14px;
  padding: 10px 12px 11px;
  border-left: 4px solid var(--ink);
  min-height: 64px;
}
.slot-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.slot-card h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
  color: #1d2a38;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.slot-card p { margin: 3px 0 0; color: #4d5c6b; font-size: 13px; }
.slot-card em {
  flex: none;
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 3px 7px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
}
.slot.is-past .slot-time b,
.slot.is-past .slot-card h3,
.slot.is-past .slot-card p { color: #8b939c; }
.slot.is-past .slot-card h3 { text-decoration: line-through; text-decoration-thickness: 1px; }
.slot.is-past .slot-card em { background: #e4e8ec; color: #6d7782; }
.slot.is-now .slot-card {
  box-shadow: 0 0 0 2px var(--ink);
}
.slot.is-optional .slot-card {
  background: #f7f9fb;
  border-left-style: dashed;
}
.slot.is-optional.is-past .slot-card { background: #eef1f4; border-left-style: solid; }
.edt-empty {
  margin: 12px 0;
  padding: 28px 16px;
  text-align: center;
  color: #6b7785;
  background: #fff;
  border-radius: 16px;
}
