/* ============================================================
   BSc R&AI — DEGREE
   Soleo's language: uppercase grotesque over a text serif,
   hairline rules, square corners, tabular numerals.
   Three skins: light · dark · beast (racing).
   ============================================================ */

:root {
  --ink:       #14110F;
  --paper:     #FFFFFF;
  --bone:      #F7F4F1;
  --sand:      #D0C8C5;
  --ink-70:    rgba(20, 17, 15, .74);
  --ink-45:    rgba(20, 17, 15, .62);
  --ink-soft:  rgba(20, 17, 15, .55);
  --line:      rgba(20, 17, 15, .16);
  --line-soft: rgba(20, 17, 15, .09);
  --scrim:     rgba(20, 17, 15, .40);

  --accent:    #8A6D1F;   /* earned */
  --live:      #2F5FA8;   /* in progress */
  --alert:     #9E4436;   /* failed */
  --ok:        #2F6B44;

  --sans: 'Inter Tight', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --display: var(--sans);
  --slant: 0deg;

  --ease: cubic-bezier(.2, .8, .3, 1);
  --pad: clamp(20px, 5.4vw, 28px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

:root[data-theme="dark"] {
  --ink:       #F5F1ED;
  --paper:     #121110;
  --bone:      #1C1A18;
  --sand:      #C6BBB6;
  --ink-70:    rgba(245, 241, 237, .74);
  --ink-45:    rgba(245, 241, 237, .58);
  --ink-soft:  rgba(245, 241, 237, .52);
  --line:      rgba(245, 241, 237, .18);
  --line-soft: rgba(245, 241, 237, .10);
  --scrim:     rgba(0, 0, 0, .6);
  --accent:    #C9A84C;
  --live:      #6E9BE8;
  --alert:     #D98878;
  --ok:        #6FBF8B;
}

/* ── beast: rosso corsa on graphite, gold numerals ── */
:root[data-theme="beast"] {
  --ink:       #F2EFEA;
  --paper:     #0B0B0C;
  --bone:      #17171A;
  --sand:      #3E3E44;
  --ink-70:    rgba(242, 239, 234, .76);
  --ink-45:    rgba(242, 239, 234, .56);
  --ink-soft:  rgba(242, 239, 234, .48);
  --line:      rgba(255, 40, 0, .26);
  --line-soft: rgba(242, 239, 234, .09);
  --scrim:     rgba(0, 0, 0, .72);
  --accent:    #E8B923;   /* gold */
  --live:      #FF2800;   /* rosso corsa */
  --alert:     #FF2800;
  --ok:        #E8B923;
  --slant: -6deg;         /* forward rake on the big numbers */
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; height: 100%; background: var(--paper); }

body {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.5;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

button, input, textarea, select {
  font: inherit; color: inherit; background: none;
  border: 0; margin: 0; border-radius: 0;
  -webkit-appearance: none; appearance: none;
}
button { cursor: pointer; -webkit-user-select: none; user-select: none; }
:where(button, textarea, input, select):focus-visible {
  outline: 2px solid var(--ink); outline-offset: 2px;
}
svg { fill: none; stroke: currentColor; stroke-width: 1.6; }
[hidden] { display: none !important; }

/* ── type ── */
.mark {
  font-family: var(--sans); font-weight: 700; font-size: 14px;
  letter-spacing: .28em; text-transform: uppercase;
}
.label {
  font-family: var(--sans); font-weight: 600; font-size: 11px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--ink-45);
}
.label.dim { color: var(--ink-soft); font-weight: 500; }
.serif { font-family: var(--serif); }
.num { font-variant-numeric: tabular-nums; font-family: var(--sans); font-weight: 600; }

/* ── shell ── */
.app { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--paper); }

.bar {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: calc(var(--safe-t) + 16px) var(--pad) 14px;
  border-bottom: 1px solid var(--line); background: var(--paper);
}
.bar-l { display: flex; align-items: center; gap: 10px; }
.conn { width: 7px; height: 7px; display: block; background: var(--sand); }
.conn.live { background: var(--ok); }
.conn.down { background: var(--alert); }
.conn.sync { background: var(--accent); animation: blink 1.1s steps(2, start) infinite; }
@keyframes blink { 50% { opacity: .25 } }

.gear {
  font-family: var(--sans); font-weight: 600; font-size: 11px;
  letter-spacing: .18em; text-transform: uppercase; color: var(--ink-70);
  min-height: 44px; padding: 0 2px 0 14px;
}

.scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; padding: 0 var(--pad) 28px; background: var(--paper);
}

/* ── tabs ── */
.tabs {
  flex: none; display: flex; border-top: 1px solid var(--line);
  background: var(--paper); padding-bottom: var(--safe-b);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; min-height: 58px; padding: 8px 2px;
  font-family: var(--sans); font-weight: 600; font-size: 9.5px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft);
}
.tab svg { width: 19px; height: 19px; }
.tab[aria-current="true"] { color: var(--ink); }
:root[data-theme="beast"] .tab[aria-current="true"] { color: var(--live); }
.tab[aria-current="true"] .tab-rule { background: var(--ink); }
:root[data-theme="beast"] .tab[aria-current="true"] .tab-rule { background: var(--live); }
.tab-rule { display: block; width: 18px; height: 2px; background: transparent; }

/* ── hero ── */
.hero { text-align: center; padding: clamp(16px, 3.4vh, 30px) 0 clamp(12px, 2.4vh, 20px); }
.count {
  display: block; font-family: var(--display); font-weight: 700;
  font-size: clamp(76px, 24vw, 118px); line-height: .9; letter-spacing: -.045em;
  font-variant-numeric: tabular-nums; transform: skewX(var(--slant));
}
:root[data-theme="beast"] .count { color: var(--accent); }
.count-sub {
  font-family: var(--sans); font-weight: 600; font-size: 12px;
  letter-spacing: .18em; text-transform: uppercase; color: var(--ink-45); margin-top: 10px;
}
.hero-title { font-size: 19px; margin: 14px 0 0; line-height: 1.3; }
.hero-sub { font-size: 15px; color: var(--ink-45); margin: 4px 0 0; }

/* the full-width progress rule under the hero */
.railway { margin-top: 20px; height: 3px; background: var(--line-soft); position: relative; }
.railway i { position: absolute; inset: 0 auto 0 0; background: var(--ink); transition: width 900ms var(--ease); }
:root[data-theme="beast"] .railway i { background: linear-gradient(90deg, var(--live), var(--accent)); }

/* ── section heads ── */
.head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 22px 0 10px; border-top: 1px solid var(--line); margin-top: 6px;
}
.head:first-child { border-top: 0; margin-top: 0; }
.head-a { font-family: var(--sans); font-weight: 600; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; }
.more { font-family: var(--sans); font-weight: 600; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-45); }

/* ── rows ── */
.row {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 15px 0; border-top: 1px solid var(--line-soft); text-align: left;
}
.row:first-of-type { border-top: 1px solid var(--line); }
.row:active { background: var(--bone); }
.row-main { flex: 1; min-width: 0; }
.row-t { font-size: 17px; line-height: 1.25; }
.row-s { font-family: var(--sans); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-45); margin-top: 4px; }
.row-n { font-family: var(--sans); font-weight: 600; font-size: 19px; font-variant-numeric: tabular-nums; flex: none; }
.row-n small { display: block; font-size: 9.5px; letter-spacing: .14em; color: var(--ink-soft); font-weight: 600; text-align: right; }

/* status stripe on the left of a course row */
.stripe { width: 3px; align-self: stretch; flex: none; background: transparent; }
.stripe.passed { background: var(--accent); }
.stripe.in_progress { background: var(--live); }
.stripe.failed { background: var(--alert); }

/* ── fach bars ── */
.fach { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line-soft); width: 100%; text-align: left; }
.fach:first-of-type { border-top: 1px solid var(--line); }
.fach-n { flex: 0 0 42%; font-size: 15px; }
.fach-bar { flex: 1; height: 2px; background: var(--line-soft); position: relative; }
.fach-bar i { position: absolute; inset: 0 auto 0 0; background: var(--ink); transition: width 900ms var(--ease); }
:root[data-theme="beast"] .fach-bar i { background: var(--live); }
.fach-bar.done i { background: var(--accent); }
.fach-v { flex: none; font-family: var(--sans); font-weight: 600; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ink-45); min-width: 62px; text-align: right; }

/* ── countdown ── */
.cd { display: flex; align-items: baseline; gap: 12px; padding: 20px 0 6px; }
.cd-n {
  font-family: var(--display); font-weight: 700; font-size: clamp(56px, 18vw, 86px);
  line-height: .85; letter-spacing: -.04em; font-variant-numeric: tabular-nums;
  transform: skewX(var(--slant));
}
.cd-n.soon { color: var(--alert); }
.cd-u { font-family: var(--sans); font-weight: 600; font-size: 13px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-45); }
.chip {
  display: inline-block; font-family: var(--sans); font-weight: 600; font-size: 10px;
  letter-spacing: .14em; text-transform: uppercase; padding: 4px 9px;
  border: 1px solid var(--line); color: var(--ink-70); margin: 0 6px 6px 0;
}
.chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
:root[data-theme="beast"] .chip.on { background: var(--live); border-color: var(--live); color: #fff; }
.chip.acc { color: var(--accent); border-color: var(--accent); }
.chip.bad { color: var(--alert); border-color: var(--alert); }

/* ── timeline ── */
.sem { padding: 20px 0; border-top: 1px solid var(--line); }
.sem-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sem-l { font-family: var(--sans); font-weight: 700; font-size: 15px; letter-spacing: .12em; text-transform: uppercase; }
.sem.now .sem-l { color: var(--live); }
.sem.grad .sem-l { color: var(--accent); }
.sem-line { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line-soft); }
.sem-line span:first-child { font-size: 16px; }
.sem-note { font-family: var(--sans); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); display: block; margin-top: 2px; }
.sem-e { font-family: var(--sans); font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; flex: none; }

/* ── sheet (modal) ── */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; }
.sheet-scrim { position: absolute; inset: 0; background: var(--scrim); }
.sheet {
  position: relative; width: 100%; max-width: 560px; margin: 0 auto;
  background: var(--paper); border-top: 2px solid var(--ink);
  max-height: 92vh; overflow-y: auto;
  padding: 22px var(--pad) calc(var(--safe-b) + 28px);
  animation: rise 260ms var(--ease);
}
:root[data-theme="beast"] .sheet { border-top-color: var(--live); }
@keyframes rise { from { transform: translateY(14px); opacity: .6 } }
.sheet-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.sheet-t { font-size: 22px; line-height: 1.2; }
.x { font-family: var(--sans); font-size: 22px; line-height: 1; min-height: 44px; min-width: 44px; color: var(--ink-45); }

.field { padding: 16px 0; border-top: 1px solid var(--line); }
.field > .label { display: block; margin-bottom: 11px; }
.opts { display: flex; flex-wrap: wrap; gap: 7px; }
.opt {
  flex: 1 1 auto; min-width: 74px; min-height: 46px; padding: 8px 12px;
  border: 1px solid var(--line); font-family: var(--sans); font-weight: 600;
  font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-70);
}
.opt small { display: block; font-size: 9px; letter-spacing: .06em; color: var(--ink-soft); margin-top: 3px; font-weight: 500; }
.opt.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.opt.on small { color: rgba(255,255,255,.7); }
:root[data-theme="beast"] .opt.on { background: var(--live); border-color: var(--live); color: #fff; }
.opt.on.passed { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.opt.on.failed { background: var(--alert); border-color: var(--alert); color: #fff; }

.inp {
  width: 100%; min-height: 48px; padding: 12px 14px;
  border: 1px solid var(--line); background: var(--bone);
  font-family: var(--sans); font-size: 15px;
}
textarea.inp { font-family: var(--sans); line-height: 1.6; resize: vertical; min-height: 130px; }

.step { display: flex; align-items: center; gap: 18px; }
.step button { width: 46px; height: 46px; border: 1px solid var(--line); font-family: var(--sans); font-size: 20px; font-weight: 600; }
.step span { font-family: var(--sans); font-weight: 600; font-size: 26px; font-variant-numeric: tabular-nums; min-width: 40px; text-align: center; }

.btn {
  display: block; width: 100%; min-height: 54px; margin-top: 18px;
  background: var(--ink); color: var(--paper);
  font-family: var(--sans); font-weight: 700; font-size: 12px;
  letter-spacing: .2em; text-transform: uppercase;
}
:root[data-theme="beast"] .btn { background: var(--live); color: #fff; }
.btn:disabled { opacity: .3; }
.btn.ghost { background: none; color: var(--ink-45); border: 1px solid var(--line); margin-top: 8px; }
.btn.danger { background: var(--alert); color: #fff; }

/* ── update / diff ── */
.diff { padding: 14px 0; border-top: 1px solid var(--line-soft); display: flex; gap: 13px; width: 100%; text-align: left; }
.box { width: 18px; height: 18px; flex: none; border: 1px solid var(--sand); margin-top: 2px; display: grid; place-items: center; }
.box.on { background: var(--ink); border-color: var(--ink); }
:root[data-theme="beast"] .box.on { background: var(--live); border-color: var(--live); }
.box.on::after { content: ""; width: 9px; height: 5px; border-left: 2px solid var(--paper); border-bottom: 2px solid var(--paper); transform: rotate(-45deg) translate(1px, -1px); }
:root[data-theme="beast"] .box.on::after { border-color: #fff; }
.diff-t { font-size: 16px; line-height: 1.3; }
.diff-d { font-family: var(--sans); font-size: 12px; color: var(--ink-70); margin-top: 4px; line-height: 1.5; }
.diff.bad .diff-t { color: var(--alert); }
.drop { border: 1px dashed var(--line); padding: 20px; text-align: center; margin-top: 12px; }
.drop.over { border-color: var(--ink); background: var(--bone); }

.note { font-size: 15px; color: var(--ink-45); margin: 10px 0 0; line-height: 1.5; }
.warn { border-left: 3px solid var(--alert); padding: 12px 0 12px 14px; margin: 14px 0; font-size: 15px; color: var(--ink-70); }

/* ── toast ── */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 74px); transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 13px 20px; z-index: 90;
  font-family: var(--sans); font-weight: 600; font-size: 11px;
  letter-spacing: .16em; text-transform: uppercase; white-space: nowrap;
}
:root[data-theme="beast"] .toast { background: var(--live); color: #fff; }

/* ── celebration ── */
.cheer { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--scrim); backdrop-filter: blur(6px); transition: opacity 400ms; }
.cheer-in { text-align: center; }
.cheer-m { font-family: var(--display); font-size: 46px; color: var(--accent); }
.cheer-t { font-family: var(--sans); font-weight: 700; font-size: 24px; letter-spacing: .1em; text-transform: uppercase; margin-top: 10px; }
.cheer-s { font-size: 16px; color: var(--ink-45); margin-top: 4px; }

/* ── beast backdrop (webgl shader, beast skin only) ── */
.backdrop { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: var(--paper); }
.backdrop canvas { display: block; width: 100%; height: 100%; }
/* keeps type legible over the moving gradient */
/* tuned against measured shader output (peak luma 143/255): keeps body text
   above 4.5:1 without flattening the gradient into a black rectangle */
.backdrop-scrim {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(130% 90% at 50% 8%, rgba(11,11,12,.42) 0%, rgba(11,11,12,.70) 58%, rgba(11,11,12,.84) 100%);
}
:root[data-theme="beast"] .app { background: transparent; z-index: 1; }
:root[data-theme="beast"] .scroll { background: transparent; }
:root[data-theme="beast"] .bar,
:root[data-theme="beast"] .tabs {
  background: rgba(11,11,12,.74);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
:root[data-theme="beast"] .row:active,
:root[data-theme="beast"] .fach:active,
:root[data-theme="beast"] .diff:active { background: rgba(255,255,255,.06); }

/* ── beast mode banner ── */
.redline {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-top: 2px solid var(--live); border-bottom: 1px solid var(--line);
  padding: 12px 0; margin-bottom: 4px;
}
.redline .label { color: var(--live); }

@media (min-width: 720px) {
  .scroll { padding-left: max(var(--pad), calc(50vw - 340px)); padding-right: max(var(--pad), calc(50vw - 340px)); }
  .bar { padding-left: max(var(--pad), calc(50vw - 340px)); padding-right: max(var(--pad), calc(50vw - 340px)); }
  .tabs { padding-left: max(0px, calc(50vw - 340px)); padding-right: max(0px, calc(50vw - 340px)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0ms !important; transition-duration: 0ms !important; }
}

/* ── icon inside a row ── */
.row-ic { flex: none; display: flex; color: var(--ink-45); }
.row-ic svg {
  width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6;
}

/* ── daily film line ── */
.daily {
  margin: 0; padding: 18px 0 16px; border-bottom: 1px solid var(--line-soft);
}
.daily-q {
  margin: 0; font-family: var(--serif); font-size: 16px; line-height: 1.45;
  color: var(--ink-70); font-style: italic;
}
.daily-f {
  margin-top: 8px; font-family: var(--sans); font-weight: 600; font-size: 10px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--ink-soft);
}
:root[data-theme="beast"] .daily-f { color: var(--accent); }

/* ── timetable ── */
:root                    { --pre: #8A6E12; --pre-bg: rgba(138, 110, 18, .07); }
:root[data-theme="dark"] { --pre: #E0B84A; --pre-bg: rgba(224, 184, 74, .10); }
:root[data-theme="beast"]{ --pre: #E8B923; --pre-bg: rgba(232, 185, 35, .09); }

.tt-day {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 26px 0 8px; border-top: 1px solid var(--line); margin-top: 8px;
}
.tt-d {
  font-family: var(--sans); font-weight: 700; font-size: 12px;
  letter-spacing: .18em; text-transform: uppercase;
}
.tt-h {
  font-family: var(--sans); font-weight: 600; font-size: 11px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-45);
  font-variant-numeric: tabular-nums;
}

.tt {
  display: flex; align-items: flex-start; gap: 13px; width: 100%;
  padding: 14px 0; border-top: 1px solid var(--line-soft);
}
.tt:first-of-type { border-top: 1px solid var(--line); }

.tt-time { flex: 0 0 46px; display: block; padding-top: 1px; }
.tt-s {
  display: block; font-family: var(--sans); font-weight: 700; font-size: 15px;
  font-variant-numeric: tabular-nums; line-height: 1.05; letter-spacing: -.01em;
}
.tt-e {
  display: block; font-family: var(--sans); font-weight: 500; font-size: 11px;
  font-variant-numeric: tabular-nums; color: var(--ink-soft); margin-top: 3px;
}

.tt-main { flex: 1; min-width: 0; }
.tt-n { font-family: var(--serif); font-size: 17px; line-height: 1.25; }
.tt-m {
  font-family: var(--sans); font-size: 10.5px; letter-spacing: .085em;
  text-transform: uppercase; color: var(--ink-45); margin-top: 5px; line-height: 1.55;
}
.tt-flag {
  display: inline-block; margin-top: 6px; color: var(--alert);
  font-family: var(--sans); font-weight: 700; font-size: 9.5px;
  letter-spacing: .12em; text-transform: uppercase;
}

.tt-badge {
  flex: none; align-self: flex-start; min-width: 30px; text-align: center;
  font-family: var(--sans); font-weight: 700; font-size: 10px; letter-spacing: .1em;
  padding: 4px 6px; border: 1px solid var(--line); color: var(--ink-70);
}

.tt-free {
  font-family: var(--serif); font-style: italic; font-size: 15px;
  color: var(--ink-soft); padding: 14px 0; border-top: 1px solid var(--line);
}

/* pre-semester course — yellow, ends before term starts */
.tt.pre { background: var(--pre-bg); box-shadow: inset 3px 0 0 var(--pre); padding-left: 11px; }
.tt.pre .tt-s,
.tt.pre .tt-n     { color: var(--pre); }
.tt.pre .tt-m     { color: var(--pre); opacity: .85; }
.tt.pre .tt-badge { color: var(--pre); border-color: var(--pre); }
