/* Paper Wall Calendar — tokens and components from DESIGN.md (§2–§9).
   Light only in v1 (Design §2: dark mode intentionally not supported). */

:root {
  --paper: #F8F4EC;
  --sheet: #FFFDF8;
  --sheet-muted: #F3EEE4;
  --ink: #2A2520;
  --ink-soft: #5E564C;
  --ink-faint: #857B6E;
  --label-ink: #4A433B;
  --rule: #E3DACB;
  --rule-strong: #CFC4B2;
  --grid: #D8CDBB;
  --navy: #1F3A5F;
  --navy-tint: #EAF0F8;
  --go-green: #2E7D46;
  --exit-red: #C23A2B;
  --exit-red-text: #A32F22;
  --coral-tint: #FBE1DA;
  --coral-ink: #7A2617;
  --coral: #A63A24;
  --slate-tint: #E4E9F0;
  --slate-rule: #A7B3C3;
  --slate-ink: #1F2C40;
  --disabled: #ECE6DB;
  --disabled-rule: #A79D8E;
  --gift-gold: #F8E3A6;
  --gift-ink: #3E2C00;
  --gift-icon: #8A5A00;
  --rose: #F6D6E0;
  --rose-ink: #4A1530;
  --rose-icon: #A3365F;
  --all-day: #EFE8DA;
  --sky: #DCE8F5;
  --peach: #FCE3D2;
  --sage: #DDEBD9;
  --lilac: #E8E0F2;

  --font-ui: 'Atkinson Hyperlegible', system-ui, sans-serif;
  --font-display: 'Literata', Georgia, serif;

  --rail: 104px;
  --header-h: 112px;
  --scrim: rgba(42, 37, 32, .55);
  color-scheme: light;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 21px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body.page-calendar { overflow: hidden; overscroll-behavior: none; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--navy); outline-offset: 3px; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.icon { width: 1em; height: 1em; display: block; }
.icon-wrap { display: inline-flex; flex: none; }
.noscript { padding: 24px; font-size: 22px; }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 10px 22px; border-radius: 14px;
  font-size: 21px; font-weight: 700; line-height: 1.15; text-align: center; text-decoration: none;
  border: 2px solid transparent;
}
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-outline { background: var(--sheet); border-color: var(--navy); color: var(--navy); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: progress; }
.text-link {
  background: none; border: 0; padding: 8px 4px; min-height: 48px;
  color: var(--navy); font-size: 20px; font-weight: 700; text-decoration: underline; text-underline-offset: 4px;
}

/* -------------------------------------------------------------------- shell */

.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
}

/* Tablet / desktop: header -> [rail | content | rail] */
.app.shell-wide {
  grid-template-columns: var(--rail) minmax(0, 1fr) var(--rail);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "hdr hdr hdr" "railL content railR";
}
.shell-wide .hdr {
  grid-area: hdr;
  min-height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 12px 24px 12px var(--rail);
}
.shell-wide .head { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.shell-wide .heading { font-size: clamp(25px, 3.5vw, 42px); }
.shell-wide .rail { display: flex; flex-direction: column; align-items: center; padding-bottom: 24px; }
.shell-wide .rail-left { grid-area: railL; }
.shell-wide .rail-right { grid-area: railR; }
.shell-wide .rail-center { flex: 1; display: flex; align-items: center; justify-content: center; }
.shell-wide .content { grid-area: content; display: flex; flex-direction: column; min-height: 0; padding: 4px 0 24px; gap: 12px; }
.shell-wide .create-slot { flex: none; display: flex; justify-content: center; min-height: 80px; }
.shell-wide .settings-spacer { height: 56px; }

/* Wide but short (phone landscape, squat windows): same grid, slimmer chrome. */
.app.shell-short { --rail: 80px; --header-h: 64px; }
.shell-short .hdr { padding-top: 6px; padding-bottom: 6px; }
.shell-short .heading { font-size: clamp(22px, 3vw, 30px); }
.shell-short .today-pill { font-size: 12px; padding: 2px 10px; }
.shell-short .tab { height: 48px; min-width: 96px; font-size: 19px; }
.shell-short .arrow { width: 56px; height: 56px; }
.shell-short .arrow .icon { width: 30px; height: 30px; }
.shell-short .rail { padding-bottom: 8px; }
.shell-short .content { padding-bottom: 8px; gap: 8px; }
.shell-short .create-slot { min-height: 64px; }
.shell-short .create-circle { width: 64px; height: 64px; }
.shell-short .create-circle .icon { width: 36px; height: 36px; }
.shell-short .create-label { font-size: 13px; }
.shell-short .footer { padding: 4px 4px 4px 14px; }
.shell-short .footer-text { font-size: 18px; }
.shell-short .footer-btn { min-height: 48px; font-size: 19px; padding: 4px 16px; }

/* Phone: tabs -> heading row with arrows -> content -> [footer | +] */
.app.shell-phone {
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  grid-template-areas:
    "tabs tabs tabs"
    "prev head next"
    "banner banner banner"
    "view view view"
    "foot foot create";
  column-gap: 8px;
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.shell-phone .hdr, .shell-phone .rail, .shell-phone .rail-center, .shell-phone .content { display: contents; }
.shell-phone .tabs { grid-area: tabs; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-top: 10px; }
.shell-phone .tab { min-width: 0; height: 52px; font-size: 20px; }
.shell-phone .head { grid-area: head; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 8px 0; min-width: 0; gap: 4px; }
.shell-phone .heading { font-size: clamp(22px, 6.6vw, 28px); }
.shell-phone .arrow-prev { grid-area: prev; align-self: center; }
.shell-phone .arrow-next { grid-area: next; align-self: center; }
.shell-phone .arrow { width: 56px; height: 56px; }
.shell-phone .arrow .icon { width: 30px; height: 30px; }
.shell-phone .banner-slot { grid-area: banner; margin-bottom: 8px; }
.shell-phone .view { grid-area: view; }
.shell-phone .footer-slot { grid-area: foot; align-self: end; margin-top: 8px; }
.shell-phone .create-slot { grid-area: create; align-self: end; margin-top: 8px; min-height: 68px; display: flex; justify-content: center; }
.shell-phone .create-circle { width: 68px; height: 68px; }
.shell-phone .create-circle .icon { width: 38px; height: 38px; }
.shell-phone .create-btn { max-width: 84px; }
.shell-phone .create-label { font-size: 13px; }
.app.shell-phone.has-settings {
  grid-template-areas:
    "tabs tabs tabs"
    "prev head next"
    "banner banner banner"
    "view view view"
    "set foot create";
}
.shell-phone .settings-link { grid-area: set; align-self: end; margin-top: 8px; min-width: 48px; padding: 4px; }
.shell-phone .settings-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.shell-phone .settings-spacer { display: none; }

.heading {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.1;
  font-optical-sizing: auto;
  text-wrap: balance;
}
.heading:focus { outline: none; }
.today-pill {
  display: inline-block; background: var(--navy); color: #fff;
  font-size: 15px; font-weight: 700; letter-spacing: .08em; line-height: 1.2;
  padding: 4px 12px; border-radius: 999px;
}

.tabs { display: flex; gap: 8px; flex: none; }
.tab {
  min-width: 128px; height: 60px; padding: 0 18px; border-radius: 14px;
  border: 2px solid var(--rule-strong); background: var(--sheet); color: var(--ink);
  font-size: 22px; font-weight: 700; line-height: 1;
}
.tab.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }

.arrow {
  width: 72px; height: 72px; border-radius: 50%;
  border: 2px solid var(--rule-strong); background: var(--sheet); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 0 var(--rule);
}
.arrow .icon { width: 38px; height: 38px; }

.settings-link {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 56px; min-height: 56px; padding: 6px; border-radius: 14px;
  color: var(--ink-soft); font-size: 14px; font-weight: 700; text-decoration: none;
}
.settings-link .icon { width: 26px; height: 26px; }

.view { position: relative; min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; }
.banner-slot.is-empty, .footer-slot.is-empty { display: none; }
.banner-slot { display: flex; flex-direction: column; gap: 8px; }


/* ------------------------------------------------------- create button (+) */

.create-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  max-width: 100px; padding: 0; border: 0; background: none; border-radius: 16px;
  color: var(--ink); font-size: 15px; font-weight: 700; line-height: 1.15; text-align: center;
}
.create-circle {
  width: 80px; height: 80px; border-radius: 50%; flex: none;
  background: var(--go-green); color: #fff; border: 2px solid var(--go-green);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(46, 125, 70, .35);
}
.create-circle .icon { width: 44px; height: 44px; }
.create-label { overflow-wrap: anywhere; }
/* Writes paused (Outlook unreachable): dashed, grey +, "En pause" under it. */
.create-btn.is-paused { cursor: not-allowed; color: var(--ink-soft); }
.create-btn.is-paused .create-circle { background: var(--disabled); border: 2px dashed var(--disabled-rule); color: var(--ink-faint); box-shadow: none; }
/* Before the first answer from the server: the space stays reserved, nothing shows. */
.create-btn.is-pending { visibility: hidden; }

/* ----------------------------------------------------------- banner/footer */

.banner {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 18px; border-radius: 18px;
}
.banner-stale { background: var(--slate-tint); box-shadow: inset 0 0 0 2px var(--slate-rule); color: var(--slate-ink); }
.banner-admin { background: var(--sheet); box-shadow: inset 0 0 0 2px var(--rule-strong); color: var(--ink); font-size: 18px; }
.banner-icon .icon { width: 32px; height: 32px; }
.banner-text { flex: 1 1 260px; margin: 0; min-width: 0; }
.banner-title { margin: 0; font-weight: 700; font-size: 21px; line-height: 1.25; }
.banner-body { margin: 2px 0 0; font-size: 18px; line-height: 1.35; }
.banner-btn { flex: none; margin-left: auto; }

.footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap;
  background: var(--coral-tint); color: var(--coral-ink);
  border-radius: 18px; padding: 10px 10px 10px 20px;
}
.footer-text { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 700; line-height: 1.2; }
.footer-text .icon { width: 26px; height: 26px; }
.footer-btn {
  min-height: 56px; padding: 8px 22px; border-radius: 14px; border: 0;
  background: var(--coral); color: #fff; font-size: 21px; font-weight: 700; line-height: 1.15;
  margin-left: auto;
}
.shell-phone .footer { padding: 8px 8px 8px 14px; gap: 8px; }
.shell-phone .footer-text { font-size: 18px; }
.shell-phone .footer-btn { font-size: 19px; min-height: 52px; padding: 6px 14px; }

/* ----------------------------------------------------------------- Day view */

.day {
  --gap: 12px;
  height: 100%; width: 100%; max-width: 780px; margin: 0 auto;
  display: flex; flex-direction: column; overflow: hidden;
}
.day-list {
  list-style: none; margin: auto 0; padding: 0;
  display: flex; flex-direction: column; gap: var(--gap);
}
/* Time-of-day layout (set by fitDay): pinned birthdays/anniversaries/all-day stack at the
   top; timed cards are placed at their time, 08:00 top … 20:00 bottom. */
.day-list[data-layout="time"] { position: relative; flex: 1 1 auto; min-height: 0; margin: 0; }
.day-list[data-layout="time"] .day-item { position: absolute; left: 0; right: 0; }
.day-count { display: none; margin: 0 0 8px; font-size: 19px; font-weight: 700; color: var(--ink-soft); }
.more-below {
  flex: none; margin-top: 10px; min-height: 56px; width: 100%;
  border: 2px solid var(--navy); border-radius: 14px; background: var(--sheet); color: var(--navy);
  font-size: 19px; font-weight: 700; line-height: 1.2; padding: 6px 14px;
}

.card {
  width: 100%; display: flex; align-items: center; gap: 20px; text-align: left;
  border: 0; border-radius: 18px; padding: 16px 26px;
  box-shadow: inset 0 0 0 1px rgba(42, 37, 32, .08);
  color: var(--ink); background: var(--sky);
}
.tone-sky { background: var(--sky); }
.tone-peach { background: var(--peach); }
.tone-sage { background: var(--sage); }
.tone-lilac { background: var(--lilac); }
.tone-gift { background: var(--gift-gold); color: var(--gift-ink); }
.tone-rose { background: var(--rose); color: var(--rose-ink); }
.tone-allday { background: var(--all-day); }

.card-time {
  flex: none; width: var(--time-col, 110px);
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  white-space: nowrap;
}
.t-main { font-family: var(--font-display); font-weight: 700; font-size: 30px; line-height: 1.05; }
.t-period { font-size: 16px; font-weight: 700; letter-spacing: .08em; line-height: 1.2; color: var(--label-ink); margin-top: 2px; }
.pill {
  display: inline-block; padding: 5px 10px; border-radius: 999px;
  background: var(--sheet); box-shadow: inset 0 0 0 1px var(--rule-strong);
  font-size: 15px; font-weight: 700; letter-spacing: .08em; line-height: 1.2; color: var(--label-ink);
}
.medallion {
  width: 52px; height: 52px; border-radius: 50%; background: #fff; color: var(--gift-icon);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.medallion .icon { width: 30px; height: 30px; }
.medallion-lg { width: 72px; height: 72px; background: var(--gift-gold); }
.medallion-lg .icon { width: 40px; height: 40px; }
.tone-rose .medallion, .medallion-rose { color: var(--rose-icon); }
.medallion-lg.medallion-rose { background: var(--rose); }

.card-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.card-title {
  font-size: 25px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-sub { display: flex; align-items: center; gap: 4px 10px; flex-wrap: wrap; font-size: 19px; line-height: 1.3; color: var(--ink-soft); }
.tone-gift .card-sub { color: var(--gift-ink); }
.tone-rose .card-sub { color: var(--rose-ink); }
.sub-repeat { display: inline-flex; align-items: center; gap: 6px; }
.sub-repeat .icon { width: 20px; height: 20px; }
.sub-location { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.sub-location .icon { width: 20px; height: 20px; flex: none; }
.sub-location-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sep { color: var(--ink-faint); }

/* Phone comfortable (Design §8) */
.shell-phone .day { --gap: 10px; }
.shell-phone .card { border-radius: 16px; padding: 12px 16px; gap: 14px; }
.shell-phone .t-main { font-size: 22px; }
.shell-phone .t-period { font-size: 13px; }
.shell-phone .card-title { font-size: 19px; }
.shell-phone .card-sub { font-size: 15px; }
.shell-phone .medallion { width: 40px; height: 40px; }
.shell-phone .medallion .icon { width: 24px; height: 24px; }
.shell-phone .pill { font-size: 12px; padding: 4px 8px; }

/* Step 3 — compact: single 46px rows, bold time + one-line title; secondary lines dropped */
.day[data-density="compact"], .day[data-density="overflow"] { --gap: 6px; }
.day[data-density="compact"] .card, .day[data-density="overflow"] .card {
  min-height: 46px; padding: 6px 16px; gap: 12px; border-radius: 14px;
}
.day[data-density="compact"] .card-sub, .day[data-density="overflow"] .card-sub { display: none; }
.day[data-density="compact"] .card-title, .day[data-density="overflow"] .card-title {
  display: block; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; font-size: 20px; line-height: 1.3;
}
.day[data-density="compact"] .card-time, .day[data-density="overflow"] .card-time { flex-direction: row; align-items: baseline; justify-content: flex-start; gap: 5px; }
.day[data-density="compact"] .t-main, .day[data-density="overflow"] .t-main { font-size: 22px; }
.day[data-density="compact"] .t-period, .day[data-density="overflow"] .t-period { font-size: 13px; margin: 0; }
.day[data-density="compact"] .medallion, .day[data-density="overflow"] .medallion { width: 34px; height: 34px; }
.day[data-density="compact"] .medallion .icon, .day[data-density="overflow"] .medallion .icon { width: 22px; height: 22px; }
.day[data-density="compact"] .pill, .day[data-density="overflow"] .pill { font-size: 12px; padding: 3px 8px; }
.shell-phone .day[data-density="compact"] .card-title, .shell-phone .day[data-density="overflow"] .card-title { font-size: 19px; }

/* Step 4 — explicit fallback: the list scrolls inside its own area, with a
   count above, a visible scrollbar, and a "more below" button. Never silent. */
.day[data-density="overflow"] .day-count { display: block; }
.day[data-density="overflow"] .day-list {
  margin: 0; flex: 1 1 auto; min-height: 0; overflow-y: scroll; padding-right: 10px;
  scrollbar-width: auto; scrollbar-color: var(--navy) var(--sheet-muted);
  overscroll-behavior: contain;
}
.day[data-density="overflow"] .day-list::-webkit-scrollbar { width: 12px; }
.day[data-density="overflow"] .day-list::-webkit-scrollbar-track { background: var(--sheet-muted); border-radius: 6px; }
.day[data-density="overflow"] .day-list::-webkit-scrollbar-thumb { background: var(--navy); border-radius: 6px; }

.time-probe { position: absolute; visibility: hidden; left: -9999px; top: 0; display: flex; flex-direction: column; width: max-content; padding: 0; box-shadow: none; }
.time-probe .card-time { width: auto; }

.day-message {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  text-align: center; padding: 16px;
}
.empty { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: clamp(26px, 4vw, 38px); color: var(--ink-soft); }
.loading { margin: 0; color: var(--ink-soft); font-size: 21px; }
.unavailable-icon .icon { width: 48px; height: 48px; color: var(--slate-ink); }
.unavailable-title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(26px, 4vw, 36px); }
.unavailable-body { margin: 0 0 8px; color: var(--ink-soft); }

/* ---------------------------------------------------------------- Week view
   Design §4 "Week column / row", §5, §8. Layout and density are set by
   week-view.js from the measured container: data-layout="columns|rows",
   per-day data-density="comfortable|compact|overflow". */

.week { flex: 1 1 auto; min-height: 0; width: 100%; display: grid; gap: 8px; }
.week[data-layout="columns"] { grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); }
.week[data-layout="rows"] { display: flex; flex-direction: column; gap: 6px; overflow: hidden; }

.wday {
  background: var(--sheet); border-radius: 16px; box-shadow: inset 0 0 0 1px var(--rule);
  display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden;
}
.wday.is-today { background: var(--navy-tint); box-shadow: inset 0 0 0 3px var(--navy); }
.wday-head {
  flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 48px; padding: 8px 4px 6px; margin: 0 3px;
  background: none; border: 0; border-bottom: 1px solid var(--rule); border-radius: 14px 14px 0 0; color: var(--ink);
}
.wday-caps { font-size: 15px; font-weight: 700; letter-spacing: .08em; line-height: 1.2; color: var(--ink-soft); }
.wday-num {
  font-family: var(--font-display); font-weight: 700; font-size: 28px; line-height: 1;
  min-width: 46px; height: 46px; padding: 0 4px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
}
.is-today .wday-caps { color: var(--navy); }
.is-today .wday-num { background: var(--navy); color: #fff; }

.wday-body { flex: 1 1 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 6px; padding: 6px; }
.wday-items { flex: 1 0 auto; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.wday-pinned, .zone { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.wday-pinned { flex: none; }
/* Invisible morning / afternoon / evening zones share the spare height:
   busy zones grow, empty ones give their space back. No bands, lines or labels. */
.wday-zones { flex: 1 0 auto; display: flex; flex-direction: column; gap: 6px; }
.zone { flex: 1 0 auto; }
.zone-afternoon { justify-content: center; }
.zone-evening { justify-content: flex-end; }
.wday[data-density="overflow"] .wday-items, .wday[data-density="overflow"] .wday-zones, .wday[data-density="overflow"] .zone { flex: 0 0 auto; }
.wday-empty { margin: auto; padding: 4px; text-align: center; font-size: 16px; line-height: 1.3; color: var(--ink-soft); }

.wcard, .chip {
  width: 100%; border: 0; border-radius: 12px; text-align: left; color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(42, 37, 32, .08);
}
.wcard { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 10px; min-height: 48px; }
.wcard-time { font-size: 14px; font-weight: 700; letter-spacing: .02em; line-height: 1.2; color: var(--label-ink); white-space: nowrap; }
.wcard-title {
  max-width: 100%; font-size: 16px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.wcard-dur { font-size: 14px; line-height: 1.2; color: var(--ink-soft); }

.chip {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; padding: 6px 8px; min-height: 40px;
  font-size: 15px; font-weight: 700; line-height: 1.2;
}
.chip-birthday, .chip-anniversary { flex-wrap: nowrap; align-items: flex-start; }
.chip-icon { padding-top: 1px; }
.chip-icon .icon { width: 18px; height: 18px; }
.chip-birthday .chip-icon { color: var(--gift-icon); }
.chip-anniversary .chip-icon { color: var(--rose-icon); }
.chip-text {
  flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mini-pill {
  flex: none; display: inline-block; padding: 2px 6px; border-radius: 999px;
  background: var(--sheet); box-shadow: inset 0 0 0 1px var(--rule-strong);
  font-size: 12px; font-weight: 700; letter-spacing: .08em; line-height: 1.2; color: var(--label-ink);
}

/* Step "compact": no duration, one-line titles (the details modal still has everything). */
.wday[data-density="compact"] .wcard, .wday[data-density="overflow"] .wcard { padding: 5px 8px; min-height: 44px; gap: 1px; }
.wday[data-density="compact"] .wcard-dur, .wday[data-density="overflow"] .wcard-dur { display: none; }
.wday[data-density="compact"] .wcard-title, .wday[data-density="overflow"] .wcard-title,
.wday[data-density="compact"] .chip-text, .wday[data-density="overflow"] .chip-text {
  display: block; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; font-size: 15px;
}
.wday[data-density="compact"] .chip, .wday[data-density="overflow"] .chip { padding: 4px 8px; min-height: 36px; }
.wday[data-density="compact"] .wday-body, .wday[data-density="overflow"] .wday-body { gap: 4px; }
.wday[data-density="compact"] .wday-items, .wday[data-density="overflow"] .wday-items,
.wday[data-density="compact"] .wday-pinned, .wday[data-density="overflow"] .wday-pinned,
.wday[data-density="compact"] .zone, .wday[data-density="overflow"] .zone,
.wday[data-density="compact"] .wday-zones, .wday[data-density="overflow"] .wday-zones { gap: 4px; }

/* Step "overflow": the last chip that fits becomes "+N autres ›" → that day in Day view. */
.more-chip {
  flex: none; width: 100%; min-height: 44px; padding: 4px 8px;
  display: flex; align-items: center; justify-content: center; gap: 2px;
  border: 2px solid var(--navy); border-radius: 12px; background: var(--sheet); color: var(--navy);
  font-size: 16px; font-weight: 700; line-height: 1.15; text-align: center;
}
.more-chev { display: inline-flex; flex: none; }
.more-chev .icon { width: 16px; height: 16px; }

/* Rows (container taller than wide): date block on the left, items wrap left → right in time order. */
.week[data-layout="rows"] .wday { flex: none; flex-direction: row; }
.week[data-layout="rows"] .wday-head {
  width: 78px; margin: 3px 0; padding: 4px 2px; border-bottom: 0; border-right: 1px solid var(--rule); border-radius: 14px 0 0 14px;
}
.week[data-layout="rows"] .wday-caps { font-size: 13px; }
.week[data-layout="rows"] .wday-num { font-size: 22px; min-width: 34px; height: 34px; }
.week[data-layout="rows"] .wday-body { flex: 1 1 auto; min-width: 0; flex-direction: row; align-items: flex-start; }
.week[data-layout="rows"] .wday-items {
  flex: 1 1 auto; flex-direction: row; flex-wrap: wrap; align-content: flex-start; align-items: stretch;
}
.week[data-layout="rows"] .wday[data-density="overflow"] .wday-items { flex: 1 1 auto; }
.week[data-layout="rows"] .wday-pinned, .week[data-layout="rows"] .wday-zones,
.week[data-layout="rows"] .zone, .week[data-layout="rows"] .wday-items li { display: contents; }
.week[data-layout="rows"] .wcard, .week[data-layout="rows"] .chip { width: auto; flex: 0 1 auto; max-width: min(100%, 300px); }
.week[data-layout="rows"] .more-chip { width: auto; flex: none; padding: 4px 12px; align-self: center; }
/* Compact rows: a timed card is one line, "20 h  Soirée cinéma", like the chips. */
.week[data-layout="rows"] .wday[data-density="compact"] .wcard,
.week[data-layout="rows"] .wday[data-density="overflow"] .wcard { flex-direction: row; align-items: center; gap: 6px; min-height: 36px; padding: 4px 8px; }
.week[data-layout="rows"] .wday[data-density="compact"] .wcard-title,
.week[data-layout="rows"] .wday[data-density="overflow"] .wcard-title { min-width: 0; }
.week[data-layout="rows"] .wday-empty { margin: auto 0; align-self: center; text-align: left; padding: 0 6px; }
.shell-phone .week[data-layout="rows"] .wday-head { width: 64px; }
.week[data-tight] .wday-head { flex-direction: row; gap: 4px; padding: 2px; }
.week[data-tight] .wday-num { min-width: 28px; height: 28px; font-size: 20px; }
.week[data-tight] .wday-body { padding: 4px; }
.week[data-tight] .chip, .week[data-tight] .wcard { min-height: 32px !important; padding-top: 2px !important; padding-bottom: 2px !important; }
.week[data-tight] .more-chip { min-height: 34px; padding: 2px 10px; }

/* --------------------------------------------------------------- Month view
   Design §4 "Month cell", §8. month-view.js measures the cells and sets
   data-treatment="roomy|compact". The whole cell is one button → Day view. */

.month { --line-h: 20px; flex: 1 1 auto; min-height: 0; width: 100%; display: flex; flex-direction: column; }
.month-head { flex: none; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); padding-bottom: 6px; }
.month-dow { text-align: center; font-size: 15px; font-weight: 700; letter-spacing: .08em; line-height: 1.2; color: var(--ink-soft); }
.month-grid {
  /* Size from the space left, never from the content, so all 5–6 rows are equal. */
  flex: 1 1 0; min-height: 0; contain: size;
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: repeat(var(--weeks), minmax(0, 1fr));
  gap: 1px; background: var(--grid); border: 1px solid var(--grid); border-top: 2px solid var(--ink);
}
.mcell {
  min-width: 0; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; align-items: stretch; gap: 2px; padding: 6px 8px;
  border: 0; border-radius: 0; background: var(--sheet); color: var(--ink); text-align: left;
}
.mcell:focus-visible { outline-offset: -5px; }
.mcell.is-out { background: var(--sheet-muted); }
.mcell.is-out .mcell-num { color: var(--ink-faint); }
.mcell.is-today { background: var(--navy-tint); box-shadow: inset 0 0 0 3px var(--navy); }
.mcell-top { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.mcell-num {
  font-family: var(--font-display); font-weight: 700; font-size: 22px; line-height: 1;
  min-width: 32px; height: 32px; padding: 0 3px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; margin-left: -4px;
}
.mcell.is-today .mcell-num { background: var(--navy); color: #fff; }
.mbadge {
  min-width: 30px; height: 30px; padding: 0 7px; border-radius: 999px; background: var(--navy); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; line-height: 1;
}
.month[data-treatment="roomy"] .mbadge { display: none; }
.month[data-treatment="compact"] .mlines { display: none; }
.month[data-treatment="compact"] .mcell { padding: 4px 2px; align-items: center; }
.month[data-treatment="compact"] .mcell-top { flex-direction: column; justify-content: flex-start; gap: 4px; }
.month[data-treatment="compact"] .mcell-num { margin: 0; font-size: 19px; min-width: 28px; height: 28px; }
.month[data-tight] .mcell { padding: 2px; }
.month[data-tight] .mcell-top { height: 100%; justify-content: space-between; align-items: stretch; gap: 0; }
.month[data-tight] .mcell-num { align-self: flex-start; height: 24px; min-width: 24px; }
.month[data-tight] .mbadge { align-self: flex-end; min-width: 26px; height: 26px; padding: 0 5px; font-size: 15px; }

.mlines { flex: 1 1 auto; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 2px; }
.mline {
  flex: none; height: var(--line-h); min-width: 0; display: flex; align-items: center; gap: 4px;
  font-size: 15px; line-height: var(--line-h); white-space: nowrap;
}
.mline-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.mline-time { flex: none; font-weight: 700; }
.mline-icon { flex: none; }
.mline-icon .icon { width: 16px; height: 16px; }
.mline-birthday { font-weight: 700; color: var(--gift-ink); }
.mline-birthday .mline-icon { color: var(--gift-icon); }
.mline-anniversary { font-weight: 700; color: var(--rose-ink); }
.mline-anniversary .mline-icon { color: var(--rose-icon); }
.mline .mini-pill { padding: 0 5px; line-height: 16px; }
.mline-more { font-weight: 700; color: var(--navy); text-decoration: underline; text-underline-offset: 3px; }
.shell-phone .month-dow { font-size: 13px; letter-spacing: .04em; }

/* ------------------------------------------------------------------- modals */

.modal {
  width: min(760px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 0; border-radius: 28px; background: var(--sheet); color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .25); overflow: auto;
}
.modal::backdrop { background: var(--scrim); }
.modal-panel { padding: 28px 32px 32px; display: flex; flex-direction: column; gap: 16px; }
.modal-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.modal-title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(26px, 4vw, 34px); line-height: 1.15; overflow-wrap: anywhere; }
.btn-close {
  margin-left: auto; background: none; border: 0; padding: 0; border-radius: 16px;
  display: inline-flex; flex-direction: column; align-items: center; gap: 4px; color: var(--exit-red-text);
}
.btn-close-circle {
  width: 72px; height: 72px; border-radius: 50%; background: var(--exit-red); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-close-circle .icon { width: 34px; height: 34px; }
.btn-close-label { font-size: 16px; font-weight: 700; }

.detail-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.detail-row { display: flex; align-items: flex-start; gap: 14px; font-size: 22px; line-height: 1.35; }
.detail-icon { padding-top: 3px; color: var(--ink-soft); }
.detail-row > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.detail-icon .icon { width: 26px; height: 26px; }
.notes { background: var(--sheet-muted); border-radius: 16px; padding: 16px 20px; }
.notes-title { margin: 0 0 6px; font-size: 17px; font-weight: 700; color: var(--label-ink); letter-spacing: .02em; }
.notes-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 21px; line-height: 1.45; max-height: 40vh; overflow: auto; }
.notes-info { margin: 0; font-size: 20px; color: var(--ink-soft); }

@media (max-width: 520px) {
  .modal-panel { padding: 20px 20px 24px; }
  .btn-close-circle { width: 64px; height: 64px; }
  .detail-row { font-size: 20px; }
}


/* ------------------------------------------------- details: edit; add/edit form */

.btn-edit { min-height: 56px; padding: 8px 20px; }
.btn-edit .icon { width: 24px; height: 24px; }
.btn-edit[aria-disabled="true"] { border-style: dashed; border-color: var(--disabled-rule); color: var(--ink-soft); cursor: not-allowed; }
.notes-paused { display: flex; gap: 12px; align-items: flex-start; background: var(--slate-tint); color: var(--slate-ink); }
.notes-paused .icon { width: 26px; height: 26px; margin-top: 2px; }

.modal-actions { display: flex; align-items: flex-start; gap: 12px; margin-left: auto; flex: none; }
.btn-go {
  background: none; border: 0; padding: 0; border-radius: 16px;
  display: inline-flex; flex-direction: column; align-items: center; gap: 4px; color: var(--go-green);
}
.btn-go-circle {
  width: 72px; height: 72px; border-radius: 50%; background: var(--go-green); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-go-circle .icon { width: 36px; height: 36px; }
.btn-go-label { font-size: 16px; font-weight: 700; max-width: 112px; text-align: center; line-height: 1.15; }
.btn-close-label { max-width: 96px; text-align: center; line-height: 1.15; }
.btn-close-sm .btn-close-circle { width: 56px; height: 56px; }
.btn-close-sm .btn-close-circle .icon { width: 28px; height: 28px; }
.btn-go[disabled], .btn-close[disabled] { cursor: progress; }
.btn-close[disabled] .btn-close-circle { opacity: .5; }

.event-form { gap: 18px; }
.event-form.is-saving { cursor: progress; }
.form-heading:focus { outline: none; }
.form-heading { align-self: center; }
.form-error-slot:empty { display: none; }
.form-note { display: flex; gap: 12px; align-items: flex-start; }
.form-note .icon, .confirm-note .icon { width: 24px; height: 24px; margin-top: 3px; }

.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field-pair[hidden] { display: none; }
.textarea { height: auto; min-height: 112px; padding: 12px 16px; line-height: 1.4; resize: vertical; }
.textarea:focus { padding: 11px 15px; }
.input[disabled], .picker-btn[disabled], .switch[disabled] { opacity: .65; }

.picker-btn {
  width: 100%; min-height: 60px; border-radius: 14px; border: 2px solid var(--rule-strong); background: #fff;
  display: flex; align-items: center; gap: 12px; padding: 6px 16px; font-size: 22px; line-height: 1.2; text-align: left;
}
.picker-btn:focus-visible { outline: none; border: 3px solid var(--navy); padding: 5px 15px; }
.picker-icon { color: var(--ink-soft); }
.picker-icon .icon { width: 24px; height: 24px; }
.picker-value { min-width: 0; overflow-wrap: anywhere; }

.field.has-error .input, .field.has-error .picker-btn { border: 3px solid var(--exit-red); }
.field.has-error .input { padding: 0 15px; }
.field.has-error .textarea { padding: 11px 15px; }
.field-error { margin: 2px 0 0; display: flex; gap: 8px; align-items: flex-start; color: var(--exit-red-text); font-size: 17px; font-weight: 700; line-height: 1.3; }
.field-error .icon { width: 20px; height: 20px; margin-top: 1px; }

.field.field-switch { flex-direction: row; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.field.field-switch .field-label { font-size: 19px; color: var(--ink); }
.switch {
  display: inline-flex; align-items: center; gap: 10px; min-height: 56px; padding: 6px 4px;
  background: none; border: 0; border-radius: 14px; font-size: 21px; font-weight: 700;
}
.switch-track {
  position: relative; width: 76px; height: 42px; border-radius: 999px; background: #BDB3A3; flex: none;
  transition: background-color .15s ease;
}
.switch-knob {
  position: absolute; top: 5px; left: 5px; width: 32px; height: 32px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s ease;
}
.switch[aria-checked="true"] .switch-track { background: var(--go-green); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(34px); }
.switch-state { min-width: 2.2em; text-align: left; }

.allday-info {
  margin: 0; display: flex; gap: 12px; align-items: flex-start;
  background: var(--all-day); border-radius: 14px; padding: 14px 18px; font-size: 19px; line-height: 1.35;
}
.allday-info .icon { width: 24px; height: 24px; margin-top: 1px; color: var(--ink-soft); }
.form-bottom { display: flex; padding-top: 4px; }
.btn-danger .icon { width: 24px; height: 24px; }
.btn-delete { min-height: 56px; }

@keyframes cal-spin { to { transform: rotate(360deg); } }
.is-saving .btn-go-circle .icon, .btn-xl[disabled] .icon-wrap .icon { animation: cal-spin 1s linear infinite; }
@media (prefers-reduced-motion: reduce) {
  .is-saving .btn-go-circle .icon, .btn-xl[disabled] .icon-wrap .icon { animation: none; }
  .switch-track, .switch-knob { transition: none; }
}

/* ------------------------------------------------------------------ pickers */

.picker { width: min(560px, calc(100vw - 24px)); }
.picker .modal-panel { gap: 12px; }
.picker-kicker { margin: 0; align-self: center; font-size: 17px; font-weight: 700; color: var(--label-ink); }
.picker-title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 26px; line-height: 1.15; }
.picker-time .picker-title { align-self: center; }
.dp-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dp-nav .picker-title { text-align: center; flex: 1; }
.arrow-sm { width: 56px; height: 56px; }
.arrow-sm .icon { width: 30px; height: 30px; }
.dp-grid { display: flex; flex-direction: column; gap: 6px; }
.dp-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.dp-dow { text-align: center; font-size: 14px; font-weight: 700; letter-spacing: .06em; color: var(--ink-soft); padding: 4px 0; }
.dp-row > span { display: flex; }
.dp-day {
  width: 100%; min-height: 48px; aspect-ratio: 1 / 1; max-height: 64px; border-radius: 12px;
  border: 0; background: var(--sheet-muted); color: var(--ink);
  font-family: var(--font-display); font-weight: 700; font-size: 20px;
}
.dp-day.is-today { box-shadow: inset 0 0 0 3px var(--navy); background: var(--navy-tint); }
.dp-day.is-selected { background: var(--navy); color: #fff; }
.dp-day.is-selected.is-today { box-shadow: inset 0 0 0 3px #fff, 0 0 0 2px var(--navy); }

.tp-preview { margin: 0; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 36px; line-height: 1.1; }
.tp-label { margin: 4px 0 0; font-size: 17px; font-weight: 700; color: var(--label-ink); }
.tp-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.tp-btn {
  min-height: 52px; border-radius: 12px; border: 2px solid var(--rule-strong); background: var(--sheet);
  font-size: 19px; font-weight: 700; padding: 4px 2px; white-space: nowrap;
}
.tp-btn.is-selected { background: var(--navy); border-color: var(--navy); color: #fff; }
.picker-time .modal-actions .btn-go-circle { width: 56px; height: 56px; }
.picker-time .modal-actions .btn-go-circle .icon { width: 28px; height: 28px; }
:lang(en-CA) .tp-hours { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ------------------------------------------------------ delete confirmation */

.modal-confirm { width: min(620px, calc(100vw - 32px)); }
.modal-confirm::backdrop { background: rgba(42, 37, 32, .62); }
.confirm-panel { align-items: stretch; }
.confirm-medallion {
  align-self: flex-start; width: 72px; height: 72px; border-radius: 50%;
  background: var(--coral-tint); color: var(--exit-red); display: inline-flex; align-items: center; justify-content: center;
}
.confirm-medallion .icon { width: 36px; height: 36px; }
.confirm-summary { background: var(--sheet-muted); border-radius: 16px; padding: 16px 20px; display: flex; flex-direction: column; gap: 6px; }
.confirm-summary p { margin: 0; }
.confirm-summary-title { font-size: 22px; font-weight: 700; overflow-wrap: anywhere; }
.confirm-summary-line { display: flex; gap: 12px; align-items: center; font-size: 19px; }
.confirm-summary-line .icon { width: 22px; height: 22px; color: var(--ink-soft); }
.confirm-body { margin: 0; font-size: 20px; }
.confirm-note { display: flex; gap: 12px; align-items: flex-start; font-size: 19px; font-weight: 700; padding-top: 4px; }
.confirm-actions { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.btn-xl { width: 100%; min-height: 72px; font-size: 21px; padding: 10px 20px; white-space: normal; }
.btn-xl .icon { width: 26px; height: 26px; }

@media (max-width: 520px) {
  /* Narrow: ✓ and ✕ stay top-right; the heading takes its own line below them. */
  .event-form > .modal-top { flex-wrap: wrap; row-gap: 4px; }
  .event-form > .modal-top .form-heading { order: 2; flex: 1 1 100%; }
  .btn-go-circle { width: 64px; height: 64px; }
  .field-pair { gap: 10px; }
  .picker-btn { font-size: 20px; padding: 6px 12px; gap: 8px; }
  .picker-btn:focus-visible { padding: 5px 11px; }
  .tp-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .modal-actions { gap: 8px; }
}

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

.page-login .login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card {
  width: min(520px, 100%); background: var(--sheet); border-radius: 28px;
  box-shadow: inset 0 0 0 1px var(--rule); padding: 36px 32px;
  display: flex; flex-direction: column; gap: 16px;
}
.login-title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 40px; line-height: 1.1; }
.login-intro { margin: 0; color: var(--ink-soft); }
.login-form { display: flex; flex-direction: column; gap: 18px; }
.login-lang { display: flex; justify-content: center; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 17px; font-weight: 700; color: var(--label-ink); }
.input, .select {
  height: 60px; border-radius: 14px; border: 2px solid var(--rule-strong); background: #fff;
  padding: 0 16px; font-size: 22px; width: 100%;
}
.input:focus, .select:focus { outline: none; border: 3px solid var(--navy); padding: 0 15px; }
.form-error {
  margin: 0; display: flex; gap: 10px; align-items: flex-start;
  color: var(--exit-red-text); font-size: 18px; font-weight: 700;
  background: #fff; border-radius: 14px; box-shadow: inset 0 0 0 2px var(--exit-red); padding: 12px 14px;
}
.form-error .icon { width: 22px; height: 22px; flex: none; margin-top: 2px; }

/* -------------------------------------------------------------------- admin */

.page-admin { font-size: 19px; }
.admin { max-width: 1040px; margin: 0 auto; padding: 24px 16px 64px; display: flex; flex-direction: column; gap: 24px; }
.admin-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.admin-top h1 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 36px; }
.admin-top .actions { display: flex; gap: 12px; flex-wrap: wrap; }
.admin-card { background: var(--sheet); border-radius: 22px; box-shadow: inset 0 0 0 1px var(--rule); padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.admin-card h2 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 26px; }
.admin-card p { margin: 0; }
.muted { color: var(--ink-soft); }
.status-badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 16px; font-weight: 700; }
.status-connected { background: var(--sage); }
.status-needs_reconnect { background: var(--coral-tint); color: var(--coral-ink); }
.status-disconnected { background: var(--sheet-muted); }
.alert-list { margin: 0; padding-left: 22px; color: var(--coral-ink); font-weight: 700; }
.notice { padding: 12px 16px; border-radius: 14px; background: var(--slate-tint); color: var(--slate-ink); font-weight: 700; }
.notice-error { background: var(--coral-tint); color: var(--coral-ink); }
.table-wrap { overflow-x: auto; }
.admin table { width: 100%; border-collapse: collapse; font-size: 18px; }
.admin th, .admin td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.admin th { font-size: 15px; letter-spacing: .04em; color: var(--label-ink); }
.admin td.center, .admin th.center { text-align: center; }
.admin input[type="checkbox"], .admin input[type="radio"] { width: 26px; height: 26px; accent-color: var(--navy); }
.tag { display: inline-block; margin: 2px 4px 0 0; padding: 2px 8px; border-radius: 999px; background: var(--sheet-muted); font-size: 14px; font-weight: 700; color: var(--label-ink); }
.tag-problem { background: var(--coral-tint); color: var(--coral-ink); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form .input { height: 48px; font-size: 18px; width: 220px; }
.inline-form .btn, .admin .btn-sm { min-height: 48px; font-size: 17px; padding: 6px 14px; }
.admin .select { height: 48px; font-size: 18px; width: auto; }
.btn-danger { background: var(--sheet); border-color: var(--exit-red); color: var(--exit-red-text); }
.sub-item { display: inline-flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%; }

.nowrap { white-space: nowrap; }

/* ===== Cat of the Day (Phase 4) =====
   PHASE4 §3.5–§3.6, mockups CotD-Day / CotD-Phone-Day / CotD-Modal / CotD-Phone-Modal.
   An optional skin: it never covers, moves or delays appointments. On wide
   screens the Polaroid is absolutely placed inside .rail-bottom, so the arrow
   and the gear keep their places whether or not a cat is shown. */

/* ------------------------------------------------- rail bottom + cat slot */

/* Wide: wraps the gear / 56 px spacer. The cat slot is out of flow, so this box
   keeps exactly the height the gear or spacer had before. */
.shell-wide .rail-bottom {
  position: relative; flex: none; align-self: stretch;
  display: flex; flex-direction: column; align-items: center;
}
.shell-wide .cat-slot {
  position: absolute; left: 50%; bottom: 0; z-index: 1;
  width: max-content; transform: translateX(-50%);
}
/* Admin: the cat sits above the Settings gear. */
.shell-wide .rail-bottom.has-gear .cat-slot { bottom: calc(100% + 12px); }
/* Within 16 px of the arrow (set by cat.js): hidden but still measured. */
.cat-slot[data-fit="no"] { visibility: hidden; }

/* Phone: the rail dissolves into the shell grid; the cat takes the footer's area. */
.shell-phone .rail-bottom { display: contents; }
.shell-phone .cat-slot { grid-area: foot; align-self: end; margin-top: 8px; min-width: 0; }

/* ------------------------------------------------------- rail Polaroid */

.cat-polaroid {
  width: 94px; padding: 6px 6px 0; border: 0; border-radius: 6px;
  background: var(--sheet); color: var(--ink);
  display: flex; flex-direction: column; align-items: center;
  box-shadow: 0 0 0 1px var(--rule), 0 3px 0 1px var(--rule);
  transform: rotate(-2deg);
}
.cat-polaroid-photo {
  display: block; flex: none; width: 82px; height: 82px;
  border-radius: 3px; overflow: hidden; background: var(--sheet-muted);
}
.cat-polaroid-photo img,
.cat-thumb img {
  display: block; width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 35%;
}
/* No padding here: cat.js counts lines from scrollHeight / line-height. */
.cat-polaroid-caption {
  display: block; width: 100%; margin: 5px 0 7px; padding: 0;
  font-size: 14px; font-weight: 700; line-height: 1.15; text-align: center;
  overflow-wrap: anywhere; hyphens: auto;
}
.cat-polaroid-caption.is-clamped {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* Short (80 px rail). */
.shell-short .cat-polaroid { width: 70px; padding: 5px 5px 0; }
.shell-short .cat-polaroid-photo { width: 60px; height: 60px; }
.shell-short .cat-polaroid-caption { font-size: 13px; margin: 4px 0 5px; }

/* ----------------------------------------------------------- phone card */

.cat-card {
  width: 100%; min-height: var(--foot-h, 68px);
  display: flex; align-items: center; gap: 12px;
  padding: 6px 10px 6px 8px; border: 0; border-radius: 14px;
  background: var(--sheet); color: var(--ink); text-align: left;
  box-shadow: inset 0 0 0 1px var(--rule), 0 2px 0 var(--rule);
}
.cat-thumb {
  flex: none; display: block; width: 62px; height: 62px; padding: 3px;
  border-radius: 5px; background: var(--sheet);
  box-shadow: 0 0 0 1px var(--rule-strong);
  transform: rotate(-2deg);
}
.cat-thumb img { border-radius: 3px; }
.cat-card-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.cat-card-kicker {
  font-size: 12px; font-weight: 700; letter-spacing: .08em; line-height: 1.2;
  text-transform: uppercase; color: var(--ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cat-card-name {
  display: block; font-family: var(--font-display); font-size: 20px; font-weight: 700; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cat-card-origin {
  display: block; font-size: 15px; line-height: 1.3; color: var(--ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cat-card-chev { flex: none; color: var(--ink-soft); }
.cat-card-chev .icon { width: 26px; height: 26px; }
/* The card's width depends on what shares the row (the admin gear, the +):
   when it is narrow, the chevron goes first so the breed name keeps its room. */
.shell-phone .cat-slot { container-type: inline-size; }
@container (max-width: 240px) {
  .cat-card { gap: 8px; padding-right: 10px; }
  .cat-card-chev { display: none; }
}

/* ------------------------------------------------------------ fade in */

.cat-polaroid, .cat-card { transition: opacity 150ms ease; }
.cat-enter { opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .cat-polaroid, .cat-card { transition: none; }
  .cat-enter { opacity: 1; }
}

/* ------------------------------------------------------ Polaroid modal */

/* The <dialog> is a transparent frame the size of the card; the ✕ hangs
   outside it on the backdrop. */
.modal.modal-cat {
  width: min(860px, calc(100vw - 2 * var(--rail)));
  max-width: none; max-height: none; height: fit-content; /* auto would stretch to the inset and pin the card to the top */
  background: transparent; border-radius: 0; box-shadow: none; overflow: visible;
}
.modal-cat::backdrop { background: rgba(42, 37, 32, .66); }
.cat-modal { position: relative; width: 100%; }

.cat-close {
  position: absolute; top: 0; left: calc(100% + 16px); margin: 0;
  color: var(--sheet);
}
.cat-close .btn-close-circle { box-shadow: 0 4px 12px rgba(0, 0, 0, .35); }
.cat-close .btn-close-circle .icon { width: 38px; height: 38px; }
.cat-close .btn-close-label { color: var(--sheet); font-size: 16px; text-shadow: 0 1px 2px rgba(0, 0, 0, .45); }
.cat-close:focus-visible { outline-color: var(--sheet); outline-offset: 4px; }

.cat-sheet {
  display: flex; flex-direction: column;
  max-height: min(820px, calc(100dvh - 32px));
  padding: 24px 24px 30px; border-radius: 6px;
  background: var(--sheet); color: var(--ink);
  box-shadow: 0 2px 0 var(--rule), 0 28px 70px rgba(0, 0, 0, .35);
}
/* The whole photo, in its own proportions (cat.js sets --cat-ar = w / h):
   full width until it reaches --cat-photo-max tall, then narrower, centred. */
.cat-photo {
  --cat-photo-max: min(440px, 46dvh);
  position: relative; flex: none; align-self: center;
  aspect-ratio: var(--cat-ar, 1.5);
  width: min(100%, calc(var(--cat-photo-max) * var(--cat-ar, 1.5)));
  border-radius: 2px; overflow: hidden; background: var(--sheet-muted);
}
.cat-photo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.cat-photo::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(42, 37, 32, .12);
}

.cat-bottom {
  flex: 1 1 auto; min-height: 0;
  display: grid; grid-template-columns: 250px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr);
  gap: 36px; padding-top: 22px;
}
.cat-left { min-width: 0; min-height: 0; }
.cat-kicker {
  margin: 0; font-size: 15px; font-weight: 700; letter-spacing: .08em; line-height: 1.2;
  text-transform: uppercase; color: var(--ink-soft);
}
.cat-name {
  margin: 2px 0 0; font-family: var(--font-display); font-size: 40px; font-weight: 700; line-height: 1.1;
  overflow-wrap: anywhere; hyphens: auto;
}
.cat-facts { margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; }
.cat-fact { border-top: 1px solid var(--rule); padding: 7px 0; }
.cat-fact dt {
  font-size: 14px; font-weight: 700; letter-spacing: .08em; line-height: 1.25;
  text-transform: uppercase; color: var(--ink-soft);
}
.cat-fact dd { margin: 2px 0 0; font-size: 20px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }

/* Right column: only the text scrolls; the photo and the ✕ never move. */
.cat-right { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.cat-text {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding-right: 10px; border-radius: 4px;
  scrollbar-width: auto; scrollbar-color: var(--navy) var(--sheet-muted);
}
.cat-text::-webkit-scrollbar { width: 12px; }
.cat-text::-webkit-scrollbar-track { background: var(--sheet-muted); border-radius: 6px; }
.cat-text::-webkit-scrollbar-thumb { background: var(--navy); border-radius: 6px; }
.cat-text:focus-visible { outline-offset: 2px; }
.cat-text > :last-child { margin-bottom: 0; }
.cat-desc { margin: 0 0 14px; font-size: 19px; line-height: 1.5; overflow-wrap: break-word; }
.cat-sub {
  margin: 4px 0 6px; font-family: var(--font-ui); font-size: 15px; font-weight: 700;
  letter-spacing: .08em; line-height: 1.2; text-transform: uppercase; color: var(--ink-soft);
}
.cat-temper { margin: 0; font-size: 19px; font-weight: 700; line-height: 1.4; overflow-wrap: break-word; }
.cat-dyk { margin-top: 14px; padding: 12px 16px; border-radius: 14px; background: var(--sheet-muted); }
.cat-dyk-title {
  margin: 0 0 2px; font-size: 14px; font-weight: 700; letter-spacing: .08em; line-height: 1.25;
  text-transform: uppercase; color: var(--ink-soft);
}
.cat-dyk-body { margin: 0; font-size: 18px; line-height: 1.45; overflow-wrap: break-word; }
.cat-credit { margin: 10px 0 0; font-size: 13px; line-height: 1.3; color: var(--ink-soft); text-align: right; }

/* Phone-only "More below ↓" chip and fade (cat.js toggles [hidden]). */
.cat-fade, .cat-more { display: none; }

/* Narrow tablets: same two columns, a slimmer left one. */
@media (min-width: 640px) and (max-width: 899px) {
  .cat-bottom { grid-template-columns: minmax(0, 210px) minmax(0, 1fr); gap: 24px; }
  .cat-name { font-size: 32px; }
}

/* Wide but short (phone landscape, squat windows): a lower photo, and the whole
   bottom scrolls as one so neither column is cut off. */
@media (min-width: 640px) and (max-height: 600px) {
  .cat-sheet { padding: 16px 20px 20px; }
  .cat-photo { --cat-photo-max: 32dvh; }
  .cat-bottom { grid-template-rows: auto; align-items: start; padding-top: 14px; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: var(--navy) var(--sheet-muted); }
  .cat-text { overflow: visible; padding-right: 0; }
  .cat-name { font-size: 30px; }
}

@media (max-width: 639px) {
  .modal.modal-cat { width: calc(100vw - 24px); }
  .cat-modal {
    display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
    max-height: calc(100dvh - 28px);
  }
  .cat-close { position: static; flex: none; }
  .cat-close .btn-close-circle .icon { width: 34px; height: 34px; }
  .cat-close .btn-close-label { font-size: 15px; }
  .cat-sheet {
    flex: 1 1 auto; min-height: 0; width: 100%; max-height: none;
    padding: 12px 12px 0; border-radius: 5px;
    box-shadow: 0 2px 0 var(--rule), 0 24px 60px rgba(0, 0, 0, .35);
  }
  .cat-photo { --cat-photo-max: 196px; }
  .cat-bottom { display: flex; flex-direction: column; gap: 0; padding: 14px 6px 0; }
  .cat-left { flex: none; }
  .cat-kicker { font-size: 13px; }
  .cat-name { margin: 0; font-size: 32px; line-height: 1.15; }
  .cat-facts { margin-top: 10px; }
  .cat-fact { display: flex; align-items: baseline; gap: 10px; padding: 6px 0; }
  .cat-fact:last-child { border-bottom: 1px solid var(--rule); }
  .cat-fact dt { flex: none; width: 96px; font-size: 13px; }
  .cat-fact dd { margin: 0; min-width: 0; font-size: 17px; }
  .cat-right { flex: 1 1 auto; min-height: 72px; }
  .cat-text { padding: 8px 4px 16px 0; }
  .cat-desc { margin-bottom: 12px; font-size: 17px; line-height: 1.45; }
  .cat-sub { font-size: 13px; margin: 4px 0; }
  .cat-temper { font-size: 17px; }
  .cat-dyk { margin-top: 12px; padding: 10px 14px; }
  .cat-dyk-title { font-size: 13px; }
  .cat-dyk-body { font-size: 16px; }
  .cat-credit { text-align: left; }
  .cat-fade {
    display: block; position: absolute; left: 0; right: 0; bottom: 0; height: 84px; pointer-events: none;
    background: linear-gradient(rgba(255, 253, 248, 0), var(--sheet) 62%);
  }
  .cat-more {
    display: inline-flex; align-items: center; gap: 6px;
    position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
    min-height: 44px; padding: 6px 16px; border: 0; border-radius: 999px;
    background: var(--sheet); color: var(--navy); box-shadow: inset 0 0 0 2px var(--rule-strong);
    font-size: 15px; font-weight: 700; line-height: 1.2; white-space: nowrap;
  }
  .cat-more .icon { width: 18px; height: 18px; }
}
/* Short phones (e.g. 375×600–680): a smaller photo leaves room to read. */
@media (max-width: 639px) and (max-height: 700px) {
  .cat-photo { --cat-photo-max: 140px; }
}

/* ===== Admin: Cat of the Day (Phase 4) ===== */
/* PHASE4 §3.7, mockup CotD-Settings: two cards side by side (people | today's
   cat), stacked on narrow screens. Reuses .admin-card, .switch, .notice, .btn. */
.cat-admin { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 24px; align-items: start; }
.cat-admin .muted { font-size: 17px; line-height: 1.4; }

.cat-people { list-style: none; margin: 0; padding: 0; border-bottom: 1px solid var(--rule); }
.cat-person {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 8px 0; border-top: 1px solid var(--rule);
}
.cat-admin-people .cat-people + .notice { margin-top: 12px; }
.cat-person-name { min-width: 0; overflow-wrap: break-word; }
.cat-person-name strong { display: block; font-size: 21px; line-height: 1.2; }
.cat-person-name small { display: block; margin-top: 2px; font-size: 15px; color: var(--ink-soft); }
.cat-admin .switch { font-size: 17px; }
.cat-admin .switch-state { min-width: 5.4em; } /* room for "Désactivé": the knob does not move */
.cat-admin .switch:focus-visible { outline: 3px solid var(--navy); outline-offset: 3px; }
.cat-admin .switch[aria-busy="true"] { cursor: progress; }

.cat-today { display: flex; align-items: flex-start; gap: 32px; padding-top: 6px; }
.cat-admin-pol {
  flex: none; width: 236px; margin: 0; padding: 10px 10px 0; background: var(--sheet); border-radius: 6px;
  box-shadow: 0 0 0 1px var(--rule), 0 3px 0 1px var(--rule); transform: rotate(-1.5deg);
}
.cat-admin-pol img {
  display: block; width: 216px; height: 216px; object-fit: cover; object-position: 50% 35%;
  border-radius: 3px; background: var(--sheet-muted);
}
.cat-admin-pol figcaption {
  padding: 10px 0 12px; text-align: center; font-family: var(--font-display); font-size: 22px; font-weight: 700;
  line-height: 1.2; overflow-wrap: anywhere; hyphens: auto;
}
.cat-admin-none { flex: none; width: 236px; padding: 16px; border-radius: 6px; border: 2px dashed var(--rule-strong); }
.cat-today-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.cat-stats { margin: 0; border-bottom: 1px solid var(--rule); }
.cat-stat {
  display: flex; align-items: baseline; justify-content: space-between; gap: 4px 16px;
  padding: 12px 0; border-top: 1px solid var(--rule); font-size: 18px; line-height: 1.35;
}
.cat-stat dt { flex: 0 1 auto; color: var(--ink-soft); }
.cat-stat dd { margin: 0; min-width: 0; font-weight: 700; text-align: right; overflow-wrap: anywhere; }
.cat-api { display: inline-flex; align-items: center; gap: 8px; }
.cat-api .icon { width: 22px; height: 22px; }
.cat-api-ok { color: var(--go-green); }
.cat-api-problem { color: var(--exit-red-text); }
.cat-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.cat-actions .btn { min-height: 52px; padding: 8px 20px; font-size: 19px; }

@media (max-width: 879px) {
  .cat-admin { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 639px) {
  .cat-today { flex-direction: column; align-items: stretch; gap: 20px; }
  .cat-admin-pol { align-self: center; width: 196px; }
  .cat-admin-pol img { width: 176px; height: 176px; }
  .cat-admin-none { width: auto; }
  .cat-stat { flex-direction: column; align-items: flex-start; }
  .cat-stat dd { text-align: left; }
  .cat-actions .btn { flex: 1 1 auto; }
}
