@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/manrope-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/manrope-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/manrope-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/manrope-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

/* Collegium Da Vinci look.

   The palette and shapes follow cdv.pl: graphite ink on white and cool grey,
   lavender and green as accents, square corners, hairline rules, flat surfaces
   and the triangle motif from the <>V mark. Manrope stands in for the brand
   grotesque (TT Hoves is a licensed face and is not bundled).

   Every colour below is a token; components reference tokens only, which is
   what keeps the light and dark themes in sync. */
:root {
  color-scheme: light;

  --bg: #edeff2;
  --surface: #ffffff;
  --surface-soft: #f6f7f9;

  --ink: #1e252d;
  --ink-soft: #5c6773;
  /* WCAG AA (>=4.5:1) on --surface. */
  --ink-faint: #66707b;
  --line: #e1e3e8;
  --line-strong: #cbcdd1;

  --accent: #a699fc;
  --accent-ink: #1e252d;
  --accent-soft: rgba(166, 153, 252, 0.2);
  --green: #66c981;
  --green-soft: #c5f0d0;

  --danger: #d90000;
  --danger-soft: #fff0f0;
  --danger-line: #ffbfbf;
  --red: #d90000;

  /* The app bar is graphite in both themes, so the status bar always matches. */
  --bar: #1e252d;
  --bar-ink: #ffffff;
  --bar-ink-soft: rgba(255, 255, 255, 0.64);
  --bar-line: rgba(255, 255, 255, 0.14);

  --btn-bg: #1e252d;
  --btn-ink: #ffffff;
  --btn-bg-hover: #2d3641;

  --press: rgba(30, 37, 45, 0.08);
  --scrim: rgba(18, 22, 27, 0.56);
  --skeleton-base: rgba(30, 37, 45, 0.08);
  --shimmer: rgba(255, 255, 255, 0.7);
  --focus-ring: 0 0 0 3px rgba(166, 153, 252, 0.7);

  /* Minimum touch target. */
  --tap-target: 44px;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  --font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --bar-height: 56px;
  --tab-height: 62px;
  --gutter: 16px;
  --content-width: 720px;
}

html.theme-dark {
  color-scheme: dark;

  --bg: #12161b;
  --surface: #1e252d;
  --surface-soft: #252d37;

  --ink: #ffffff;
  --ink-soft: #b7bfcb;
  --ink-faint: #9aa4b0;
  --line: #2d3641;
  --line-strong: #3d4855;

  --accent-soft: rgba(166, 153, 252, 0.22);
  --green-soft: rgba(102, 201, 129, 0.22);

  --danger: #ff7a7a;
  --danger-soft: rgba(217, 0, 0, 0.18);
  --danger-line: rgba(255, 122, 122, 0.4);
  --red: #ff5a5a;

  --btn-bg: #a699fc;
  --btn-ink: #1e252d;
  --btn-bg-hover: #b8adff;

  --press: rgba(255, 255, 255, 0.1);
  --scrim: rgba(0, 0, 0, 0.64);
  --skeleton-base: rgba(255, 255, 255, 0.08);
  --shimmer: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  /* pan-x/pan-y keeps scrolling and the swipe gesture while leaving pinch-zoom. */
  touch-action: pan-x pan-y;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* App-like: no browser pull-to-refresh / rubber band dragging the whole UI. */
  overscroll-behavior-y: none;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}

/* Controls behave like app chrome: no text selection, no long-press callout. */
button,
a,
.nav-bar,
.tab-bar {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

html:not(.is-app) .app-only {
  display: none !important;
}

.noscript-note {
  margin: 16px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  text-align: center;
  font-weight: 600;
}

/* --- App bar --------------------------------------------------------------- */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--bar);
  color: var(--bar-ink);
  padding-top: var(--safe-top);
}

.bar-row,
.period-row {
  width: min(var(--content-width), 100%);
  margin: 0 auto;
  display: flex;
  align-items: center;
  padding: 0 calc(var(--safe-right) + 6px) 0 calc(var(--safe-left) + var(--gutter));
}

.bar-row {
  min-height: var(--bar-height);
  justify-content: space-between;
  gap: 12px;
}

.bar-logo {
  height: 26px;
  width: auto;
  display: block;
}

.bar-actions {
  display: flex;
  align-items: center;
}

.period-row {
  min-height: 52px;
  gap: 4px;
  padding-left: calc(var(--safe-left) + 6px);
  border-top: 1px solid var(--bar-line);
}

.period-text {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.period-label {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.period-label::first-letter {
  text-transform: uppercase;
}

.updated-at {
  margin: 1px 0 0;
  font-size: 11px;
  color: var(--bar-ink-soft);
}

.updated-at:empty {
  display: none;
}

/* --- Icon buttons ---------------------------------------------------------- */
.icon-btn {
  width: var(--tap-target);
  height: var(--tap-target);
  min-width: var(--tap-target);
  border: 0;
  border-radius: 0;
  padding: 0;
  display: grid;
  place-items: center;
  color: inherit;
  background: transparent;
  text-decoration: none;
  transition: background-color 140ms ease, opacity 140ms ease;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

.icon-btn.is-pressed {
  background: var(--bar-line);
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover:not(:disabled) {
    background: var(--bar-line);
  }
}

/* The refresh icon spins for as long as a load is in flight. */
#refreshNow:disabled {
  opacity: 1;
}

#refreshNow:disabled .corner-icon {
  animation: spin 900ms linear infinite;
  opacity: 0.6;
}

/* --- Layout ---------------------------------------------------------------- */
.app-shell {
  width: min(var(--content-width), 100%);
  margin: 0 auto;
  padding:
    0
    calc(var(--safe-right) + var(--gutter))
    calc(var(--safe-bottom) + 32px)
    calc(var(--safe-left) + var(--gutter));
}

html.is-app .app-shell {
  padding-bottom: calc(var(--safe-bottom) + var(--tab-height) + 28px);
}

/* --- Typography ------------------------------------------------------------ */
.brand {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

h1 {
  margin: 4px 0 0;
  font-size: 32px;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.subtitle {
  margin: 0;
  color: var(--ink-soft);
  font-size: 16px;
}

/* --- Sign-in --------------------------------------------------------------- */
.auth-screen {
  max-width: 480px;
  margin: 0 auto;
  animation: fadeIn 320ms var(--ease-out);
}

/* A cdv.pl tile: graphite block with the triangle motif cut from the corner. */
.auth-hero {
  position: relative;
  overflow: hidden;
  margin: 0 calc(-1 * var(--gutter));
  padding: 116px var(--gutter) 28px;
  background: var(--bar);
  color: var(--bar-ink);
  border-top: 1px solid var(--bar-line);
}

.auth-hero::before,
.auth-hero::after {
  content: "";
  position: absolute;
  pointer-events: none;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.auth-hero::before {
  top: -22px;
  right: -34px;
  width: 150px;
  height: 132px;
  background: var(--accent);
}

.auth-hero::after {
  top: 18px;
  right: 124px;
  width: 60px;
  height: 52px;
  background: var(--green);
}

.auth-hero > * {
  position: relative;
  z-index: 1;
}

.auth-hero .brand {
  color: var(--bar-ink-soft);
}

.auth-hero h1 {
  color: var(--bar-ink);
  font-size: 38px;
}

.auth-hero .subtitle {
  margin-top: 8px;
  max-width: 300px;
  font-size: 15px;
  color: var(--bar-ink-soft);
}

.credentials-form {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

.field {
  display: grid;
  gap: 6px;
}

.field-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.field input {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  /* 16px minimum keeps iOS from zooming the page on focus. */
  font-size: 16px;
  outline: none;
  caret-color: var(--accent);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.field input::placeholder {
  color: var(--ink-faint);
}

.field input:focus {
  border-color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.field input.is-invalid {
  border-color: var(--danger);
}

.field-error:empty {
  display: none;
}

.field-error {
  font-size: 13px;
  color: var(--danger);
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 52px;
}

.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: var(--tap-target);
  height: var(--tap-target);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  display: grid;
  place-items: center;
}

.password-toggle svg {
  width: 21px;
  height: 21px;
}

.password-toggle.is-active {
  color: var(--ink);
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap-target);
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
}

.check {
  -webkit-appearance: none;
  appearance: none;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  margin: 0;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.check::before {
  content: "";
  width: 12px;
  height: 12px;
  background: var(--accent);
  transform: scale(0);
  transition: transform 140ms var(--ease-out);
}

.check:checked::before {
  transform: scale(1);
}

.hint {
  margin: -6px 0 0;
  min-height: 18px;
  font-size: 13px;
  color: var(--ink-soft);
}

.credentials-form.is-loading input,
.credentials-form.is-loading button {
  cursor: wait;
}

.brand-note {
  margin: 28px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* --- Buttons --------------------------------------------------------------- */
.btn {
  min-height: var(--tap-target);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  padding: 10px 20px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  background: transparent;
  transition: background-color 140ms ease, opacity 140ms ease, transform 140ms ease;
}

.btn.is-pressed {
  transform: scale(0.985);
  opacity: 0.85;
}

.btn-strong {
  background: var(--btn-bg);
  border-color: var(--btn-bg);
  color: var(--btn-ink);
}

@media (hover: hover) and (pointer: fine) {
  .btn-strong:hover:not(:disabled) {
    background: var(--btn-bg-hover);
    border-color: var(--btn-bg-hover);
  }
}

.btn-large {
  min-height: 54px;
  width: 100%;
}

/* cdv.pl call-to-action: label on the left, arrow on the right. */
.btn-arrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}

.btn-arrow::after {
  content: "";
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='square'%3E%3Cpath d='M4 12h15M13 5.5l6.5 6.5-6.5 6.5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='square'%3E%3Cpath d='M4 12h15M13 5.5l6.5 6.5-6.5 6.5'/%3E%3C/svg%3E") center / contain no-repeat;
}

.btn-pill {
  font-size: 15px;
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn[aria-busy="true"] {
  animation: busyPulse 1.1s ease-in-out infinite;
}

.retry-btn {
  margin-top: 12px;
  width: 100%;
}

/* One focus treatment for every interactive control. */
.btn:focus-visible,
.icon-btn:focus-visible,
.tab:focus-visible,
.mode-tab:focus-visible,
.lang-btn:focus-visible,
.sheet-row-btn:focus-visible,
.password-toggle:focus-visible,
.lesson-link:focus-visible,
.check:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* --- App screen ------------------------------------------------------------ */
.app-screen {
  animation: fadeIn 320ms var(--ease-out);
}

.page-head {
  padding-top: 20px;
}

/* The logo sits right above in the app bar; the eyebrow would repeat it. */
.page-head .brand {
  display: none;
}

/* The same underlined section switch cdv.pl uses for "Dla kandydatów / …". */
.mode-tabs {
  display: flex;
  gap: 22px;
  margin-top: 14px;
  border-bottom: 1px solid var(--line-strong);
}

.mode-tab {
  position: relative;
  min-height: var(--tap-target);
  border: 0;
  border-radius: 0;
  padding: 0 0 2px;
  background: transparent;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink-faint);
  transition: color 140ms ease, opacity 140ms ease;
}

.mode-tab::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 220ms var(--ease-out);
}

.mode-tab.is-active {
  color: var(--ink);
}

.mode-tab.is-active::after {
  transform: scaleX(1);
}

.mode-tab:disabled {
  cursor: wait;
}

.mode-tab.is-pressed {
  opacity: 0.6;
}

/* --- Status ---------------------------------------------------------------- */
.status {
  margin: 14px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--accent);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 14px;
}

.status.error {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--danger-line);
  border-left-color: var(--danger);
}

/* --- Schedule -------------------------------------------------------------- */
.schedule {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.schedule.is-loading {
  opacity: 0.6;
  transition: opacity 200ms ease;
}

.schedule.is-skeleton {
  opacity: 1;
}

/* No entry animation on purpose: every period change rebuilds these cards, and
   fading dozens of them in made switching weeks look like the list blinked. */
.day-group {
  background: var(--surface);
  border: 1px solid var(--line);
  /* Keep the day header below the sticky app bar when scrolled to. */
  scroll-margin-top: calc(var(--safe-top) + var(--bar-height) + 60px);
}

.day-title {
  margin: 0;
  padding: 14px 14px 12px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.day-title::first-letter {
  text-transform: uppercase;
}

/* Today: the cdv.pl "→ active item" marker, on a lavender header. */
.day-group.is-today .day-title {
  background: var(--accent);
  color: var(--accent-ink);
  border-bottom-color: var(--accent);
}

.day-group.is-today .day-title::before {
  content: "";
  display: inline-block;
  vertical-align: -3px;
  margin-right: 8px;
  width: 20px;
  height: 20px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='square'%3E%3Cpath d='M4 12h15M13 5.5l6.5 6.5-6.5 6.5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='square'%3E%3Cpath d='M4 12h15M13 5.5l6.5 6.5-6.5 6.5'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* --- Lessons: time column | subject colour rule | details ------------------ */
.lesson {
  --time-col: 50px;
  position: relative;
  display: grid;
  grid-template-columns: var(--time-col) minmax(0, 1fr);
  column-gap: 26px;
  padding: 13px 14px 14px;
  transition: background-color 280ms ease, box-shadow 280ms ease;
}

.lesson > * {
  grid-column: 2;
}

.lesson::before {
  content: "";
  position: absolute;
  left: calc(14px + var(--time-col) + 11px);
  top: 13px;
  bottom: 14px;
  width: 4px;
  background: var(--lesson-color, var(--accent));
}

.lesson + .lesson,
.now-line + .lesson {
  border-top: 1px solid var(--line);
}

.lesson-time {
  grid-column: 1;
  grid-row: 1 / span 6;
  display: grid;
  align-content: start;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}

.lesson-time-start {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.lesson-time-end {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-faint);
}

.lesson-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.lesson-room-badge {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  padding: 3px 7px;
  font-variant-numeric: tabular-nums;
}

.lesson-sub {
  margin-top: 4px;
  font-size: 14px;
  color: var(--ink-soft);
}

.lesson-meta {
  margin-top: 2px;
  display: grid;
  gap: 2px;
  font-size: 13px;
  color: var(--ink-faint);
}

/* "Now" / "Next" highlights use the lesson's own subject colour
   (--lesson-color and its rgba tints are set inline per lesson in JS). */
.lesson.is-now,
.lesson.is-next-target {
  background: var(--lesson-highlight-soft, var(--accent-soft));
  box-shadow: inset 0 0 0 2px var(--lesson-color, var(--accent));
}

.lesson.is-next-target {
  animation: nextPulse 700ms var(--ease-out);
}

.lesson.is-nearest {
  background: var(--surface-soft);
}

@keyframes nextPulse {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.015);
  }
  100% {
    transform: scale(1);
  }
}

/* Current-time indicator inside today's card. */
.now-line {
  display: flex;
  align-items: center;
  pointer-events: none;
}

.now-line::after {
  content: "";
  flex: 1;
  height: 2px;
  background: var(--red);
}

.now-line.is-hidden {
  display: none;
}

.now-line-label {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffffff;
  background: #d90000;
  padding: 5px 8px;
}

.lesson-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  width: fit-content;
  min-height: 38px;
  padding: 7px 14px;
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 140ms ease;
}

.lesson-link::before {
  content: "";
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 6h13v12H3Zm14 3.7L22 6v12l-5-3.7Z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 6h13v12H3Zm14 3.7L22 6v12l-5-3.7Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.lesson-link.is-pressed {
  opacity: 0.75;
}

/* --- Skeleton -------------------------------------------------------------- */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--skeleton-base);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--shimmer), transparent);
  animation: shimmer 1.4s infinite;
}

.skeleton-day {
  pointer-events: none;
}

.skeleton-title {
  height: 18px;
  width: 45%;
  margin: 16px 14px 14px;
}

.skeleton-lesson {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  border-top: 1px solid var(--line);
}

.skeleton-lesson > * {
  grid-column: 1;
}

.skeleton-lesson::before {
  display: none;
}

.skeleton-line {
  height: 12px;
}

.skeleton-line.short {
  width: 32%;
}

.skeleton-line.wide {
  width: 70%;
}

.skeleton-line.med {
  width: 55%;
}

/* --- Empty state ----------------------------------------------------------- */
.empty {
  position: relative;
  overflow: hidden;
  padding: 28px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 16px;
  display: grid;
  gap: 16px;
  justify-items: start;
}

.empty::before {
  content: "";
  width: 46px;
  height: 42px;
  background: var(--green);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.empty-text {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
}

/* --- Scroll to top --------------------------------------------------------- */
.scroll-top {
  position: fixed;
  right: calc(var(--safe-right) + var(--gutter));
  bottom: calc(var(--safe-bottom) + var(--tab-height) + 14px);
  z-index: 65;
  width: 48px;
  height: 48px;
  background: var(--btn-bg);
  color: var(--btn-ink);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 200ms ease, transform 260ms var(--ease-out);
}

html.is-scrolled .scroll-top {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.scroll-top.is-pressed,
.scroll-top:hover:not(:disabled) {
  background: var(--btn-bg-hover);
}

/* --- Bottom action bar ----------------------------------------------------- */
.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  background: var(--surface);
  border-top: 1px solid var(--line-strong);
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  animation: tabBarIn 360ms var(--ease-out) both;
}

.tab-bar-inner {
  width: min(var(--content-width), 100%);
  margin: 0 auto;
  display: flex;
}

.tab {
  flex: 1 1 0;
  min-width: 0;
  min-height: var(--tab-height);
  border: 0;
  border-radius: 0;
  padding: 8px 4px 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  text-decoration: none;
  transition: background-color 140ms ease, color 140ms ease, opacity 140ms ease;
}

.tab-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.tab-label {
  max-width: 100%;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* "Today" is the home action, so it carries the ink colour and accent rule. */
#today {
  color: var(--ink);
  box-shadow: inset 0 3px 0 var(--accent);
}

.tab.is-pressed,
.tab[aria-expanded="true"] {
  background: var(--press);
  color: var(--ink);
}

@media (hover: hover) and (pointer: fine) {
  .tab:hover:not(:disabled) {
    color: var(--ink);
  }
}

.tab:disabled,
.tab.is-disabled {
  opacity: 0.4;
  cursor: wait;
}

.account-avatar {
  display: block;
  object-fit: cover;
  object-position: center top;
  background: var(--line);
}

/* --- Bottom sheets --------------------------------------------------------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

body:has(.sheet:not(.hidden)) .sheet-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 110;
  width: min(var(--content-width), 100%);
  max-height: 88dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0 auto;
  padding:
    10px
    calc(var(--safe-right) + var(--gutter))
    calc(var(--safe-bottom) + 20px)
    calc(var(--safe-left) + var(--gutter));
  background: var(--surface);
  color: var(--ink);
  border-top: 4px solid var(--accent);
  animation: sheetIn 300ms var(--ease-out);
}

.sheet-title {
  margin: 12px 0 6px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.sheet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  border-bottom: 1px solid var(--line);
}

.sheet-row-btn {
  width: 100%;
  border-width: 0 0 1px;
  border-style: solid;
  border-color: var(--line);
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

.sheet-label {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

/* Language switch: three square cells, the active one filled. */
.lang-switch {
  display: flex;
  border: 1.5px solid var(--ink);
}

.lang-btn {
  min-width: 48px;
  height: 38px;
  border: 0;
  border-radius: 0;
  padding: 0 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: transparent;
  transition: background-color 140ms ease, color 140ms ease;
}

.lang-btn + .lang-btn {
  border-left: 1.5px solid var(--ink);
}

.lang-btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--surface);
}

/* Square switch driven by the toggle button's aria-pressed. */
.switch {
  position: relative;
  flex-shrink: 0;
  width: 50px;
  height: 28px;
  border: 1.5px solid var(--ink);
  background: transparent;
  transition: background-color 180ms ease;
}

.switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  background: var(--ink);
  transition: transform 220ms var(--ease-out);
}

[aria-pressed="true"] > .switch {
  background: var(--accent);
}

[aria-pressed="true"] > .switch::before {
  transform: translateX(22px);
  background: var(--accent-ink);
}

.install-block {
  display: grid;
  gap: 12px;
  padding-top: 18px;
}

.install-hint {
  margin: 0;
  padding: 12px 14px;
  border-left: 4px solid var(--green);
  background: var(--surface-soft);
  font-size: 14px;
  color: var(--ink-soft);
}

/* --- Account sheet --------------------------------------------------------- */
.account-head {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px 0 16px;
}

.account-head-text {
  min-width: 0;
}

.account-panel-avatar {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  object-fit: cover;
  object-position: center top;
  background: var(--line);
}

.account-name {
  margin: 0;
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.account-email {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.account-list {
  border-top: 1px solid var(--line-strong);
}

.account-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 14px 0;
  font-size: 15px;
  border-bottom: 1px solid var(--line);
}

.account-label {
  color: var(--ink-soft);
}

.account-value {
  text-align: right;
  max-width: 64%;
  font-weight: 600;
}

.account-logout {
  margin-top: 18px;
  width: 100%;
  min-height: 52px;
  color: var(--danger);
  border-color: var(--danger);
}

/* --- Toast ----------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + var(--tab-height) + 14px);
  transform: translate(-50%, 12px);
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  background: var(--btn-bg);
  color: var(--btn-ink);
  border-left: 4px solid var(--accent);
  font-weight: 600;
  font-size: 14px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  z-index: 200;
  transition: opacity 200ms ease, transform 280ms var(--ease-out);
}

html.theme-dark .toast {
  border-left-color: var(--accent-ink);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* --- Motion ---------------------------------------------------------------- */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sheetIn {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes tabBarIn {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes busyPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

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

/* Tablet / desktop: a little more air, and the sheet becomes a centred panel. */
@media (min-width: 700px) {
  :root {
    --gutter: 24px;
  }

  h1 {
    font-size: 40px;
  }

  .auth-screen {
    padding-top: 32px;
  }

  .auth-hero {
    margin: 0;
    border-top: 0;
  }

  .tab-bar-inner {
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }
}

/* Narrow phones (iPhone SE / mini). */
@media (max-width: 380px) {
  .lesson {
    --time-col: 46px;
    column-gap: 22px;
  }

  .lesson::before {
    left: calc(14px + var(--time-col) + 9px);
  }

  .mode-tabs {
    gap: 16px;
  }

  .auth-hero h1 {
    font-size: 32px;
  }
}
