/* Flat, phone view.
   One loud element (the "now" panel, colored by the time of day); everything
   else is quiet. Each flatmate keeps one color everywhere, behind their photo. */

@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(/fonts/bricolage-grotesque-latin-ext-opsz-normal.woff2) format("woff2-variations");
  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;
}
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(/fonts/bricolage-grotesque-latin-opsz-normal.woff2) format("woff2-variations");
  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;
}

:root {
  color-scheme: light dark;

  --bg: #EEF0EC;
  --surface: #FFFFFF;
  --sunken: #E2E5DF;
  --ink: #1A1D29;
  --muted: #5D6371;
  --line: #D3D7D0;
  --focus: #2F5BEA;
  --danger: #A61B1B;
  --scrim: rgba(26, 29, 41, 0.32);

  --k0: #2F5BEA; --k0-on: #FFFFFF; --k0-tint: #DCE5FF;   /* cobalt */
  --k1: #E9B10E; --k1-on: #1A1D29; --k1-tint: #FBEFC6;   /* sunflower */
  --k2: #119C74; --k2-on: #FFFFFF; --k2-tint: #CDEDE3;   /* jade */
  --k3: #8C4FC4; --k3-on: #FFFFFF; --k3-tint: #EADCF6;   /* plum */
  --k4: #DB5A1E; --k4-on: #FFFFFF; --k4-tint: #F9DCCD;   /* tangerine */
  --k5: #4B5D73; --k5-on: #FFFFFF; --k5-tint: #DDE2E8;   /* slate */

  --night: #151A3B;     --night-ink: #D9DEFF;
  --morning: #FFDDB0;   --morning-ink: #3B2A12;
  --afternoon: #C5E3FF; --afternoon-ink: #10304F;
  --evening: #4E4AA8;   --evening-ink: #F1EEFF;

  --hatch-a: #DADDD7; --hatch-b: #F1F2EF;
  --row: 48px;

  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141B;
    --surface: #1C1F29;
    --sunken: #262A36;
    --ink: #ECEEF4;
    --muted: #9AA0AE;
    --line: #2E3240;
    --focus: #7D9BFF;
    --danger: #FF8A80;
    --scrim: rgba(0, 0, 0, 0.55);

    --k0: #5B7FFF; --k0-tint: #26315C;
    --k1: #F2C230; --k1-tint: #4A3F17;
    --k2: #2DBB8F; --k2-on: #0D1F18; --k2-tint: #173D33;
    --k3: #A97BE0; --k3-tint: #3A2A50;
    --k4: #F07B47; --k4-on: #2A1206; --k4-tint: #4A2817;
    --k5: #7D8EA6; --k5-on: #12141B; --k5-tint: #2E3644;

    --night: #0B0E22;     --night-ink: #C9D0FF;
    --morning: #3D2F1B;   --morning-ink: #FFDDB0;
    --afternoon: #17324B; --afternoon-ink: #C5E3FF;
    --evening: #2C2966;   --evening-ink: #E3E0FF;

    --hatch-a: #2E3240; --hatch-b: #1C1F29;
  }
}

.k0 { --k: var(--k0); --k-on: var(--k0-on); --k-tint: var(--k0-tint); }
.k1 { --k: var(--k1); --k-on: var(--k1-on); --k-tint: var(--k1-tint); }
.k2 { --k: var(--k2); --k-on: var(--k2-on); --k-tint: var(--k2-tint); }
.k3 { --k: var(--k3); --k-on: var(--k3-on); --k-tint: var(--k3-tint); }
.k4 { --k: var(--k4); --k-on: var(--k4-on); --k-tint: var(--k4-tint); }
.k5 { --k: var(--k5); --k-on: var(--k5-on); --k-tint: var(--k5-tint); }

.hatch { background: repeating-linear-gradient(135deg, var(--hatch-a) 0 6px, var(--hatch-b) 6px 12px); }

/* ------------------------------------------------------------- base */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--body);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.sprite { display: none; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; touch-action: manipulation; }
button:disabled { cursor: default; opacity: 0.45; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.01em; margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.screen {
  max-width: 30rem;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 14px calc(96px + env(safe-area-inset-bottom));
}

.muted { color: var(--muted); }
.quiet { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; padding: 8px 0; }

/* --------------------------------------------------------- now panel */

.now {
  --sky: var(--afternoon);
  --sky-ink: var(--afternoon-ink);
  background: var(--sky);
  color: var(--sky-ink);
  border-radius: 26px;
  padding: 16px 22px 24px;
}
.now[data-phase="night"] { --sky: var(--night); --sky-ink: var(--night-ink); }
.now[data-phase="morning"] { --sky: var(--morning); --sky-ink: var(--morning-ink); }
.now[data-phase="afternoon"] { --sky: var(--afternoon); --sky-ink: var(--afternoon-ink); }
.now[data-phase="evening"] { --sky: var(--evening); --sky-ink: var(--evening-ink); }
.now-top { font-size: 14px; font-weight: 600; }
.now-line {
  font-size: clamp(28px, 8.4vw, 38px);
  font-weight: 700;
  font-variation-settings: "opsz" 96;
  line-height: 1.04;
  margin-top: 14px;
  text-wrap: balance;
}
.now-detail { margin: 8px 0 0; font-size: 17px; }

/* --------------------------------------------------------- buttons */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 52px;
  padding: 0 18px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 17px;
  text-decoration: none;
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}
.btn.primary { background: var(--ink); color: var(--bg); box-shadow: none; }
.btn.accent { background: var(--k0); color: var(--k0-on); box-shadow: none; }
.btn.danger { color: var(--danger); }
.btn.small { height: 40px; font-size: 15px; padding: 0 14px; border-radius: 12px; }
.round {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}
.round svg { width: 20px; height: 20px; }

/* --------------------------------------------------------------- tabs */

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px 4px max(10px, env(safe-area-inset-bottom));
}
.tabs a {
  flex: 1;
  max-width: 120px;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 4px 0;
  font-size: 12px;
  text-decoration: none;
  color: var(--muted);
}
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 700; }

/* -------------------------------------------------------------- week */

/* As tall as its arrows, with or without "Back to …": the arrows and what's below stay put. */
.bar-nav { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; height: 44px; margin: 16px 0 8px; text-align: center; }
.bar-nav :is(h1, h2) { font-size: 21px; font-weight: 650; line-height: 1.15; }
.bar-nav .quiet { display: block; font-size: 14px; color: var(--muted); padding: 0; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.week a {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 7px 3px 12px;
  border-radius: 14px;
  overflow: hidden; /* the chip's corners clip the day strip below */
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  text-decoration: none;
}
/* The day's 24 hours run flush along the chip's bottom edge; only taken and
   blocked hours are drawn, so an empty day is a plain chip. */
.week a .minibar { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; border-radius: 0; }
.week a .minibar span:not(.taken):not(.hatch) { background: transparent; }
.week .wd { font-size: 12px; }
.week .num { font-family: var(--display); font-size: 18px; font-weight: 650; line-height: 1.1; }
.week a[aria-current="date"] { background: var(--ink); color: var(--bg); box-shadow: none; }
.week a.today .num { text-decoration: underline; text-underline-offset: 3px; }

.minibar { display: flex; width: 100%; height: 5px; gap: 1px; border-radius: 3px; overflow: hidden; }
.minibar span { background: var(--sunken); }
.minibar span.taken { background: var(--k); }
.minibar span.hatch, .mday .bar span.hatch {
  background: repeating-linear-gradient(135deg, var(--muted) 0 1.5px, var(--sunken) 1.5px 4px);
}

/* ---------------------------------------------------------- timeline */

.day-title { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 4px 8px; }
.day-title h2 { font-size: 20px; font-weight: 650; }

.timeline {
  position: relative;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  grid-template-rows: repeat(var(--hours), var(--row));
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.timeline .label {
  grid-column: 1;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  transform: translateY(-8px);
}
.timeline .hour { grid-column: 2; border-top: 1px solid var(--line); text-align: left; }
.timeline button.hour:active { background: var(--sunken); }

.slot {
  grid-column: 2;
  z-index: 2;
  margin: 2px 0 2px 4px;
  border-radius: 12px;
  padding: 7px 10px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  text-align: left;
  overflow: hidden;
  min-width: 0;
}
.slot .text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.slot strong { font-size: 15px; }
.slot .sub { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot.mine { background: var(--k); color: var(--k-on); }
.slot.other { background: var(--k-tint); color: var(--ink); }
.slot.blocked { color: var(--ink); }
.slot.past { opacity: 0.55; }
/* one-hour slots: everything on one line */
.slot.short { align-items: center; padding: 6px 10px; }
.slot.short .text { flex-direction: row; gap: 8px; align-items: baseline; }
.slot.short .note { display: none; }

.selection {
  grid-column: 2;
  z-index: 3;
  margin: 2px 0 2px 4px;
  border-radius: 12px;
  border: 2px solid var(--k0);
  background: color-mix(in srgb, var(--k0) 18%, transparent);
  pointer-events: none;
}

.nowline {
  grid-column: 2; /* not across the hour label next to it */
  z-index: 1; /* above the hour grid, below bookings */
  align-self: start;
  height: 2px;
  background: var(--ink);
  position: relative;
  pointer-events: none;
}
.nowline::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink);
}

/* ------------------------------------------------------------ avatar */

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: var(--size, 30px);
  height: var(--size, 30px);
  border-radius: 50%;
  overflow: hidden;
  background: var(--k);
  color: var(--k-on);
  font-weight: 800;
  font-size: calc(var(--size, 30px) * 0.42);
  line-height: 1;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slot.mine .avatar { box-shadow: 0 0 0 2px var(--k-on); }

/* ------------------------------------------------------------- month */

.card { background: var(--surface); border-radius: 22px; padding: 18px; }
.share-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.share-amount { font-family: var(--display); font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.split { width: 100%; border-collapse: collapse; margin-top: 8px; font-variant-numeric: tabular-nums; }
.split td { padding: 9px 0; border-top: 1px solid var(--line); }
.split td + td { text-align: right; padding-left: 10px; }
.split tr.me td { font-weight: 700; }
.who { display: flex; align-items: center; gap: 10px; }

.pay { margin-bottom: 12px; }
.pay .qr { display: block; width: min(260px, 100%); aspect-ratio: 1; margin: 12px auto; border-radius: 10px; background: #fff; }
.pay dl { margin: 12px 0 14px; }
.pay dl div { display: flex; align-items: baseline; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.pay dt { width: 76px; flex: none; color: var(--muted); font-size: 14px; }
.pay dd { margin: 0; flex: 1; display: flex; justify-content: space-between; gap: 10px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.pay dd .quiet { padding: 0; font-size: 14px; }
.pay .btn { width: 100%; }

.axis, .mday { display: grid; grid-template-columns: 52px minmax(0, 1fr) 64px; gap: 8px; align-items: center; }
.axis { margin: 22px 0 6px; font-size: 11px; color: var(--muted); }
.axis .ticks { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.mdays { display: flex; flex-direction: column; gap: 3px; }
.mday { min-height: 34px; text-decoration: none; font-size: 13px; font-variant-numeric: tabular-nums; }
.mday.week-start { margin-top: 10px; }
.mday.past { opacity: 0.5; }
.mday.today .d { font-weight: 800; }
.mday .bar { display: flex; height: 14px; gap: 1px; border-radius: 4px; overflow: hidden; }
.mday .bar span { background: var(--sunken); }
.mday .bar span.taken { background: var(--k); }
.stack { display: flex; justify-content: flex-end; }
.stack .avatar { --size: 22px; margin-left: -6px; box-shadow: 0 0 0 2px var(--bg); }

/* ---------------------------------------------------------------- me */

.profile { display: grid; justify-items: center; gap: 12px; padding: 28px 0 6px; }
.profile .avatar { --size: 104px; }
.stackv { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.links { display: flex; justify-content: center; gap: 28px; margin-top: 20px; }
.install { display: flex; align-items: flex-start; gap: 12px; margin-top: 12px; }
.install > div { flex: 1; }
.install .hint { margin-top: 4px; }
.install .hint svg { width: 17px; height: 17px; vertical-align: -3px; }
.install .round { margin: -8px -8px 0 0; }

/* -------------------------------------------------------------- forms */

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .field > label, .label { font-weight: 600; font-size: 14px; }
.input {
  height: 50px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 17px;
  min-width: 0;
  width: 100%;
}
select.input { padding: 0 10px; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.inline { display: flex; gap: 8px; }
.inline .input { flex: 1; }
.inline .btn { height: auto; } /* as tall as the input next to it */
.form-error { margin: 0; min-height: 1.35em; color: var(--danger); font-weight: 600; font-size: 15px; }
.hint { margin: 0; color: var(--muted); font-size: 14px; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: var(--sunken); }
.segmented a, .segmented button {
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 14px;
  text-decoration: none;
  color: var(--muted);
}
.segmented [aria-current="page"], .segmented [aria-checked="true"] { background: var(--surface); color: var(--ink); font-weight: 700; }

.chips { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.chips button { height: 44px; border-radius: 12px; font-size: 14px; font-weight: 600; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.chips button[aria-pressed="true"] { background: var(--ink); color: var(--bg); box-shadow: none; }

.stepper { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 6px; height: 60px; padding: 0 6px; border-radius: 14px; background: var(--sunken); }
.stepper .val { text-align: center; line-height: 1.1; }
.stepper .val small { display: block; font-size: 12px; color: var(--muted); }
.stepper .val b { font-size: 19px; font-variant-numeric: tabular-nums; }
.stepper button { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); }
.stepper svg { width: 20px; height: 20px; }

/* ------------------------------------------------------------- lists */

.list { list-style: none; margin: 0; padding: 4px 16px; border-radius: 22px; background: var(--surface); }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.list li + li { border-top: 1px solid var(--line); }
.list .grow { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.list .grow span { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.list .swatch { width: 40px; height: 40px; border-radius: 12px; flex: none; }
.list + .btn { width: 100%; margin-top: 14px; } /* "Add …" under its list; a <button> would shrink to its text */
.section-title { font-size: 15px; font-weight: 600; margin: 24px 4px 8px; font-family: var(--body); letter-spacing: 0; }
.empty { color: var(--muted); padding: 14px 0; }

/* ------------------------------------------------------------- sheet */

.scrim { position: fixed; inset: 0; z-index: 20; background: var(--scrim); }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  max-height: 92vh;
  overflow-y: auto;
  max-width: 30rem;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 10px 20px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: rise 160ms ease-out;
}
.sheet .grabber { align-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
.sheet-head { display: flex; align-items: center; gap: 12px; }
.sheet-head h2 { flex: 1; font-size: 22px; font-weight: 700; }
.sheet .input, .sheet select.input { background: var(--bg); }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }

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

.welcome .now { padding: 18px 22px 34px; }
.brand { margin: 0; font-family: var(--display); font-weight: 700; font-size: 20px; }
.welcome .now-line { margin-top: 64px; font-size: clamp(36px, 11vw, 52px); }
.welcome form { display: flex; flex-direction: column; gap: 6px; padding: 26px 8px 0; }
.welcome label { font-weight: 600; font-size: 15px; margin-top: 8px; }
.welcome form .btn.primary { margin-top: 10px; }
.hint.center { text-align: center; margin: 22px 8px; }
.hint a { color: inherit; font-weight: 600; }
.welcome .btn { margin-top: 12px; }

/* ------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--bg);
  font-size: 15px;
  z-index: 30;
  pointer-events: none; /* never swallow a tap meant for what's underneath */
}
.toast:empty { display: none; }

@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
}
