@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  src: url(/fonts/archivo-latin.woff2) format("woff2-variations"), url(/fonts/archivo-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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  src: url(/fonts/archivo-latin-ext.woff2) format("woff2-variations"), url(/fonts/archivo-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Gauges fill up as hours are missed: light green while there's room,
   red when nearly or completely full. */
:root {
  --panel: #eef1ed;
  --ink: #18212a;
  --muted: #56636a;
  --rule: #d5dad3;
  --field-border: #c3c9c2;
  --field: #ffffff;
  --track: #dbe0da;
  --ok: #3cb371;
  --full: #d63a24;
  --full-ink: #b02f1b;
  --focus: #2f8f59;
  --control: #dde2dc;
  --control-ink: #18212a;
  --primary: #18212a;
  --primary-ink: #ffffff;
  --sheet: #f8f9f7;
  /* iOS draws the status bar text white, so light themes put a dark strip behind it. */
  --statusbar: #18212a;
  color-scheme: light;
}

/* Auto follows the phone; the other themes are picked in Settings. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --panel: #12181b;
    --ink: #e8e4d9;
    --muted: #8e989b;
    --rule: #263035;
    --field-border: #2f3a3f;
    --field: #1a2327;
    --track: #263035;
    --ok: #7ad696;
    --full: #ff5b3f;
    --full-ink: #ff6b50;
    --focus: #7ad696;
    --control: #222c30;
    --control-ink: #e8e4d9;
    --primary: #e8e4d9;
    --primary-ink: #12181b;
    --sheet: #182024;
    --statusbar: transparent;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --panel: #12181b;
  --ink: #e8e4d9;
  --muted: #8e989b;
  --rule: #263035;
  --field-border: #2f3a3f;
  --field: #1a2327;
  --track: #263035;
  --ok: #7ad696;
  --full: #ff5b3f;
  --full-ink: #ff6b50;
  --focus: #7ad696;
  --control: #222c30;
  --control-ink: #e8e4d9;
  --primary: #e8e4d9;
  --primary-ink: #12181b;
  --sheet: #182024;
  --statusbar: transparent;
  color-scheme: dark;
}

/* Colourful themes. Gauges stay green for room and red for full in all of them. */
:root[data-theme="pink"] {
  --panel: #ffe4ef;
  --ink: #3a0f24;
  --muted: #7a4a60;
  --rule: #f5c6da;
  --field-border: #eab2c9;
  --field: #ffffff;
  --track: #f8cfe0;
  --ok: #2fa866;
  --full: #d7263d;
  --full-ink: #b31d31;
  --focus: #c2185b;
  --control: #fbd0e2;
  --control-ink: #3a0f24;
  --primary: #c2185b;
  --primary-ink: #ffffff;
  --sheet: #fff3f8;
  --statusbar: #3a0f24;
  color-scheme: light;
}

:root[data-theme="babyblue"] {
  --panel: #dcefff;
  --ink: #0f2740;
  --muted: #4a6680;
  --rule: #bcdcf5;
  --field-border: #a9cdea;
  --field: #ffffff;
  --track: #c4e0f7;
  --ok: #2a9d5c;
  --full: #d63a2f;
  --full-ink: #b32d24;
  --focus: #1f6fb2;
  --control: #c6e2f8;
  --control-ink: #0f2740;
  --primary: #1f6fb2;
  --primary-ink: #ffffff;
  --sheet: #eef7ff;
  --statusbar: #0f2740;
  color-scheme: light;
}

/* ACT burgundy, as on the student portal. */
:root[data-theme="burgundy"] {
  --panel: #7f1d37;
  --ink: #fff4f6;
  --muted: #ebc3ce;
  --rule: #96334e;
  --field-border: #a64561;
  --field: #8d2642;
  --track: #973250;
  --ok: #9be5b0;
  --full: #ff6b5e;
  --full-ink: #ffb3aa;
  --focus: #ffd6de;
  --control: #93304b;
  --control-ink: #fff4f6;
  --primary: #fff4f6;
  --primary-ink: #7f1d37;
  --sheet: #6e1830;
  --statusbar: transparent;
  color-scheme: dark;
}

:root[data-theme="brat"] {
  --panel: #8ace00;
  --ink: #000000;
  --muted: #2d4200;
  --rule: #74ad00;
  --field-border: #5c8a00;
  --field: #c4ec6a;
  --track: #78b400;
  --ok: #1e5c00;
  --full: #e3002b;
  --full-ink: #a3001e;
  --focus: #000000;
  --control: #7cba00;
  --control-ink: #000000;
  --primary: #000000;
  --primary-ink: #8ace00;
  --sheet: #9bd91a;
  --statusbar: #000000;
  color-scheme: light;
}

:root[data-theme="brat"] .wordmark {
  font-family: Arial, "Helvetica Neue", sans-serif;
  font-weight: 400;
  font-stretch: 85%;
  letter-spacing: -0.05em;
  text-transform: lowercase;
  filter: blur(0.5px);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--panel);
  color: var(--ink);
  font-family: "Archivo", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.statusbar-shade {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  height: env(safe-area-inset-top, 0px);
  background: var(--statusbar);
  pointer-events: none;
}

.num {
  font-variant-numeric: tabular-nums;
}

#app {
  max-width: 760px;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top, 0px) + 18px)
    calc(env(safe-area-inset-right, 0px) + 16px)
    calc(env(safe-area-inset-bottom, 0px) + 28px)
    calc(env(safe-area-inset-left, 0px) + 16px);
}

.wordmark {
  margin: 0;
  font-size: 30px;
  line-height: 1.05;
  font-weight: 800;
  font-stretch: 125%;
  letter-spacing: -0.015em;
}

/* ---------- Header ---------- */

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.top-text {
  min-width: 0;
}

.subline {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--control);
  color: var(--control-ink);
  cursor: pointer;
}

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

.emoji-button span {
  font-size: 21px;
  line-height: 1;
}

/* Small phones (iPhone SE and similar): room for the title and three buttons. */
@media (max-width: 359px) {
  .top .wordmark {
    font-size: 24px;
    font-stretch: 115%;
  }

  .top-actions {
    gap: 6px;
  }

  .top-actions .icon-button {
    width: 40px;
    height: 40px;
  }
}

.support-emoji {
  margin: 0 0 -6px;
  font-size: 40px;
  line-height: 1;
}

.support-link {
  text-align: center;
  text-decoration: none;
  line-height: 26px;
}

#refresh svg {
  transform: rotate(var(--pull-turn, 0deg));
}

#refresh.spinning svg {
  animation: spin 0.9s linear infinite;
}

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

button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Status ---------- */

.status {
  margin: 22px 0 0;
  max-width: 34ch;
  font-size: 19px;
  line-height: 1.3;
  font-weight: 600;
  text-wrap: pretty;
}

.status[data-tone="full"] {
  color: var(--full-ink);
}

.notice {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Gauges ---------- */

.meters {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 30px 14px;
}

@media (min-width: 620px) {
  .meters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 36px 20px;
  }
}

.tile {
  display: block;
  width: 100%;
  padding: 4px 0;
  border: 0;
  border-radius: 14px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: center;
  cursor: pointer;
}

.tile .gauge {
  max-width: 150px;
  margin: 0 auto;
  transition: transform 0.15s ease;
}

.tile:active .gauge {
  transform: scale(0.97);
}

.gauge-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.g-track,
.g-fill {
  fill: none;
  stroke-width: 9;
  stroke-linecap: round;
}

.g-track {
  stroke: var(--track);
}

.g-fill {
  stroke: var(--ok);
}

[data-tone="full"] .g-fill {
  stroke: var(--full);
}

.animate .g-fill {
  transition: stroke-dashoffset 0.9s cubic-bezier(0.2, 0.8, 0.2, 1), stroke 0.3s ease, opacity 0.2s ease;
}

.g-fill.empty {
  opacity: 0;
}

.g-num {
  fill: var(--ink);
  font-size: 30px;
  font-weight: 700;
  font-stretch: 112%;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  text-anchor: middle;
  dominant-baseline: central;
}

.g-num.long {
  font-size: 27px;
}

.g-num.longer {
  font-size: 22px;
}

[data-tone="full"] .g-num {
  fill: var(--full-ink);
}

.g-unit {
  fill: var(--muted);
  font-size: 11px;
  text-anchor: middle;
  dominant-baseline: central;
}

.meta {
  margin: 8px 0 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 0.01em;
}

.pill {
  padding: 0 6px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--field-border);
  font-size: 11px;
  font-weight: 600;
  line-height: 17px;
}

.name {
  margin: 2px auto 0;
  max-width: 20ch;
  font-size: 15px;
  line-height: 1.2;
  font-weight: 600;
  font-stretch: 78%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta[hidden] + .name {
  margin-top: 8px;
}

.used {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Footer ---------- */

.foot {
  margin-top: 34px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 14px;
}

.foot p {
  margin: 0 0 8px;
  max-width: 60ch;
}

.total {
  color: var(--ink);
}

.credits {
  color: var(--muted);
  font-size: 13px;
}

.portal-link {
  margin: 14px 0 12px;
  text-align: center;
  text-decoration: none;
  line-height: 26px;
}

/* ---------- Login ---------- */

.login {
  max-width: 400px;
  margin: 0 auto;
  padding-top: 6vh;
}

.login-gauge {
  width: 88px;
  margin: 0 0 22px;
}

.login .wordmark {
  font-size: 40px;
}

.login-lede {
  margin: 12px 0 26px;
  font-size: 17px;
  max-width: 34ch;
}

.login-form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
}

.field input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  font-weight: 400;
}

.message {
  margin: 0;
  padding: 12px 14px;
  border-left: 3px solid var(--full-ink);
  background: var(--field);
  border-radius: 0 8px 8px 0;
  font-size: 15px;
}

.fineprint {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 13.5px;
  max-width: 44ch;
}

.login .credits {
  margin: 10px 0 0;
}

/* ---------- Buttons ---------- */

.button {
  display: block;
  width: 100%;
  min-height: 50px;
  padding: 12px 16px;
  border: 0;
  border-radius: 25px;
  font: inherit;
  font-size: 17px;
  font-weight: 650;
  font-stretch: 108%;
  cursor: pointer;
}

.button.primary {
  background: var(--primary);
  color: var(--primary-ink);
}

.button.primary:disabled {
  opacity: 0.6;
}

.button.quiet {
  background: var(--control);
  color: var(--control-ink);
}

.button.danger {
  background: transparent;
  color: var(--full-ink);
  box-shadow: inset 0 0 0 1.5px currentColor;
}

/* ---------- MWF / TT toggle ---------- */

.seg {
  display: inline-flex;
  flex-shrink: 0;
  padding: 3px;
  border-radius: 20px;
  background: var(--control);
}

.seg label {
  position: relative;
  cursor: pointer;
}

.seg input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.seg span {
  display: block;
  min-width: 54px;
  padding: 7px 12px;
  border-radius: 17px;
  color: var(--control-ink);
  font-size: 15px;
  font-weight: 600;
  font-stretch: 105%;
  text-align: center;
}

.seg input:checked + span {
  background: var(--primary);
  color: var(--primary-ink);
}

.seg input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

/* ---------- Sheets ---------- */

.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 22px 22px 0 0;
  background: var(--sheet);
  color: var(--ink);
  overflow-y: auto;
}

.sheet::backdrop {
  background: rgba(8, 12, 14, 0.45);
}

.sheet[open] {
  animation: sheet-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes sheet-in {
  from {
    transform: translateY(40px);
    opacity: 0.4;
  }
}

@media (min-width: 620px) {
  .sheet {
    margin: auto;
    border-radius: 22px;
  }
}

.sheet-body {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 22px 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
}

.sheet-kicker {
  margin: 0 0 -10px;
  color: var(--muted);
  font-size: 14px;
}

.sheet-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  font-weight: 700;
  font-stretch: 82%;
}

.sheet-gauge {
  width: 100%;
  max-width: 220px;
  margin: 8px auto 4px;
}

.rows {
  margin: 0;
  border-top: 1px solid var(--rule);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  border-bottom: 1px solid var(--rule);
}

.row dt {
  font-weight: 600;
}

.row dd {
  margin: 0;
  font-size: 17px;
}

.sheet-note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.sheet-done {
  margin-top: 6px;
}

.sched-all {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sched-all .button {
  min-height: 44px;
  font-size: 16px;
}

.sched-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.sched-row {
  display: grid;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule);
}

.sched-row.missing .sched-name {
  color: var(--full-ink);
}

.sched-name {
  min-width: 0;
  font-weight: 600;
  font-stretch: 85%;
  line-height: 1.25;
}

.sched-name small {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 400;
  font-stretch: 100%;
}

.hint {
  color: var(--full-ink);
}

/* ---------- Schedule editor ---------- */

.editor {
  display: grid;
  gap: 10px;
  justify-items: start;
}

.custom-panel {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  background: var(--field);
  box-shadow: inset 0 0 0 1px var(--field-border);
}

.custom-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}

.custom-label {
  font-size: 15px;
  font-weight: 600;
}

.amount {
  display: flex;
  align-items: center;
  gap: 8px;
}

.amount input[type="number"] {
  width: 72px;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.custom-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.sheet-section {
  display: grid;
  gap: 10px;
}

.section-label {
  margin: 0;
  font-weight: 600;
}

/* ---------- Install ---------- */

.install-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 18px;
  padding: 10px 10px 10px 14px;
  border-radius: 16px;
  background: var(--control);
  color: var(--control-ink);
}

.install-bar p {
  margin: 0;
  font-size: 14px;
  line-height: 1.3;
}

.install-btn {
  flex-shrink: 0;
  min-height: 38px;
  padding: 8px 16px;
  border: 0;
  border-radius: 19px;
  background: var(--primary);
  color: var(--primary-ink);
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
}

.howto h3 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
  font-stretch: 90%;
}

.howto ol {
  margin: 0;
  padding-left: 22px;
  color: var(--ink);
}

.howto li {
  margin: 0 0 6px;
  padding-left: 2px;
}

.glyph {
  width: 18px;
  height: 18px;
  vertical-align: -3px;
}

.welcome-text {
  margin: 0;
  font-size: 17px;
}

.themes {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.themes legend {
  margin-bottom: 10px;
  padding: 0;
  font-weight: 600;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.theme-opt {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 12px 4px 10px;
  border-radius: 14px;
  background: var(--control);
  color: var(--control-ink);
  cursor: pointer;
}

.theme-opt input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.theme-opt:has(input:checked) {
  box-shadow: inset 0 0 0 2px var(--primary);
}

.theme-opt:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.theme-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
}

/* Each swatch is a tiny gauge in that theme's colours. */
.swatch {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--sw-bg);
  box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.35);
}

.swatch::after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 4px solid var(--sw-track);
  border-top-color: var(--sw-ok);
  border-left-color: var(--sw-ok);
  border-radius: 50%;
  transform: rotate(-20deg);
}

.swatch[data-swatch="auto"] {
  --sw-bg: linear-gradient(135deg, #eef1ed 50%, #12181b 50%);
  --sw-ok: #3cb371;
  --sw-track: #8f9a94;
}

.swatch[data-swatch="light"] {
  --sw-bg: #eef1ed;
  --sw-ok: #3cb371;
  --sw-track: #d3d9d2;
}

.swatch[data-swatch="dark"] {
  --sw-bg: #12181b;
  --sw-ok: #7ad696;
  --sw-track: #2c373c;
}

.swatch[data-swatch="pink"] {
  --sw-bg: #ffe4ef;
  --sw-ok: #2fa866;
  --sw-track: #f3bcd3;
}

.swatch[data-swatch="babyblue"] {
  --sw-bg: #dcefff;
  --sw-ok: #2a9d5c;
  --sw-track: #b3d6f2;
}

.swatch[data-swatch="burgundy"] {
  --sw-bg: #7f1d37;
  --sw-ok: #9be5b0;
  --sw-track: #a13a57;
}

.swatch[data-swatch="brat"] {
  --sw-bg: #8ace00;
  --sw-ok: #1e5c00;
  --sw-track: #6fa300;
}

.policy {
  padding: 12px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.policy summary {
  cursor: pointer;
  font-weight: 600;
}

.policy p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.raw {
  display: grid;
  gap: 10px;
}

.raw pre {
  margin: 0;
  max-height: 40vh;
  overflow: auto;
  padding: 12px;
  border-radius: 10px;
  background: var(--field);
  font-size: 11.5px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (prefers-reduced-motion: reduce) {
  .animate .g-fill,
  .tile .gauge {
    transition: none;
  }
  .sheet[open] {
    animation: none;
  }
  #refresh.spinning svg {
    animation-duration: 2.4s;
  }
}
