:root {
  --bg: #f4f7f3;
  --surface: #ffffff;
  --ink: #22303c;
  --ink-soft: #5b6b74;
  --line: #e2e8e3;
  --shadow: 0 1px 2px rgba(34, 48, 60, 0.06), 0 6px 16px rgba(34, 48, 60, 0.05);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Lexend', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.topbar-titles h1 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 30px;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.week-range {
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
}

.week-nav {
  display: flex;
  gap: 8px;
}

.week-nav button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.week-nav button:hover { border-color: #b9c6bd; }
.week-nav button:active { transform: scale(0.97); }
.week-nav button:focus-visible { outline: 2px solid #5b8def; outline-offset: 2px; }

.week-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
}

@media (max-width: 860px) {
  .week-grid { grid-template-columns: 1fr; }
}

.day-col {
  background: transparent;
  min-width: 0;
}

.day-heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0 4px 10px;
  border-bottom: 2px solid var(--line);
  margin-bottom: 12px;
}

.day-heading .day-name {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 17px;
}

.day-heading .day-date {
  color: var(--ink-soft);
  font-size: 13px;
}

.day-heading.is-today { border-bottom-color: #5b8def; }
.day-heading.is-today .day-name { color: #2f5fc7; }

.lesson {
  display: grid;
  grid-template-columns: 3px 1fr;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 14px 10px 0;
  margin-bottom: 8px;
}

.lesson-bar { border-radius: 3px; }

.lesson-time {
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  margin-bottom: 2px;
}

.lesson-subject {
  font-size: 14.5px;
  line-height: 1.3;
}

.lesson-code {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--ink-soft);
  background: var(--bg);
  border-radius: 6px;
  padding: 1px 7px;
}

.status {
  grid-column: 1 / -1;
  color: var(--ink-soft);
  padding: 40px 4px;
  text-align: center;
}

.status.error {
  color: #b23a3a;
}

.empty-day {
  color: var(--ink-soft);
  font-size: 13px;
  padding: 8px 4px;
}

/* ---- generic controls ------------------------------------------------- */

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 18px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.btn:hover { border-color: #b9c6bd; }
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid #5b8def; outline-offset: 2px; }
.btn:disabled { opacity: 0.6; cursor: default; transform: none; }

.btn-primary {
  background: #2f5fc7;
  border-color: #2f5fc7;
  color: #fff;
  font-weight: 500;
}
.btn-primary:hover { background: #2751ab; border-color: #2751ab; }

.btn-ghost { background: transparent; }
.btn-small { padding: 6px 12px; font-size: 13px; }

/* ---- login ------------------------------------------------------------- */

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-title {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 30px;
  margin: 0;
  letter-spacing: -0.01em;
}

.login-sub {
  margin: -6px 0 6px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.45;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: var(--ink-soft);
}
.field span { font-weight: 500; color: var(--ink); }
.field small { font-size: 12px; }
.field code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; }

.field input {
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus {
  outline: none;
  border-color: #5b8def;
  box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.18);
}

.form-error {
  margin: 0;
  color: #b23a3a;
  background: #fbeeee;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
}

.login-card .btn-primary { margin-top: 4px; }

/* ---- topbar controls ---------------------------------------------------- */

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.person-picker select {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 32px 8px 14px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235b6b74' d='M2 4l4 4 4-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.person-picker select:focus-visible { outline: 2px solid #5b8def; outline-offset: 2px; }

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.user-label {
  color: var(--ink-soft);
  font-size: 13px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .user-menu { border-left: none; padding-left: 0; }
}

/* ---- "now" lesson --------------------------------------------------------- */

.lesson.is-now {
  box-shadow: var(--shadow), 0 0 0 2px #5b8def;
}

.now-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 999px;
  background: #2f5fc7;
  color: #fff;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  vertical-align: 1px;
}
