/* Seeday — web interface for the people editing the calendar.

   The template is "Seeday Backend Kalender" from the brand package, followed
   one to one: 14px base type, 1px lines, radii 8/12/14. The backend is a
   tool for relatives at a computer, not a tablet in a care room — the large
   targets of the app do not apply here. Where the design says nothing
   (login, image picker, tablets, codes), the structure stays and the same
   tokens apply. */

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../assets/atkinson-hyperlegible.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

/* ------------------------------------------------------------------ Tokens --

   Three states, as on the landing page: without data-theme the device
   decides, "light" and "dark" are an explicit choice (assets/seeday.js). The
   dark values therefore appear twice — once for "system, and the device is
   dark", once for "explicitly dark". */

:root {
  /* Tells the browser which controls to draw: the calendar in date fields,
     the clock, scroll bars. Without it they would come out black on dark. */
  color-scheme: light;

  /* Brand — the same in both themes. Text on coral and sun is always
     aubergine. */
  --aubergine: #35283D;
  --coral: #F66B5D;
  --coral-hover: #F4594A;
  --sun: #FFC857;
  --sage: #83B692;
  --sky: #7FA5C6;

  /* Neutral, light */
  --bg: #FAF8F4;
  --surface: #FFFFFF;
  --sunken: #FCFAF6;
  --line: #ECE6DD;
  --line-soft: #F5F1EA;
  --field-line: #DFD8CD;
  --segment-bg: #F4F0E9;
  --text: #35283D;
  --text-2: #6B5F72;
  --text-3: #9A8FA0;
  --text-4: #C3B9C6;
  --hover: #F7F3EC;
  --scrim: rgba(53, 40, 61, 0.28);
  --avatar: #EADFF0;
  --danger: #C7442F;

  --shadow-menu: 0 12px 28px rgba(20, 14, 26, 0.18);
  --shadow-dialog: 0 24px 60px rgba(20, 14, 26, 0.3);
  --shadow-segment: 0 1px 2px rgba(20, 14, 26, 0.18);

  /* How strongly an event's colour tints its entry. The dark theme needs more
     of it: 18% of a colour on a dark surface is barely there. */
  --event-tint: 18%;
  --event-tint-hover: 26%;
  --event-tint-quiet: 9%;
  --row-tint: 13%;
  --row-tint-hover: 19%;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1B1522;
    --surface: #251E2E;
    --sunken: #201929;
    --line: #3A3143;
    --line-soft: #322A3B;
    --field-line: #453C4F;
    --segment-bg: #1F1826;
    --text: #F3EEF5;
    --text-2: #B3A7B9;
    --text-3: #8B7F92;
    --text-4: #6A5F71;
    --hover: #2E2637;
    --scrim: rgba(12, 8, 16, 0.55);
    --avatar: #3B3145;
    --danger: #FF8C7B;
    --event-tint: 28%;
    --event-tint-hover: 36%;
    --event-tint-quiet: 14%;
    --row-tint: 20%;
    --row-tint-hover: 27%;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1B1522;
  --surface: #251E2E;
  --sunken: #201929;
  --line: #3A3143;
  --line-soft: #322A3B;
  --field-line: #453C4F;
  --segment-bg: #1F1826;
  --text: #F3EEF5;
  --text-2: #B3A7B9;
  --text-3: #8B7F92;
  --text-4: #6A5F71;
  --hover: #2E2637;
  --scrim: rgba(12, 8, 16, 0.55);
  --avatar: #3B3145;
  --danger: #FF8C7B;
  --event-tint: 28%;
  --event-tint-hover: 36%;
  --event-tint-quiet: 14%;
  --row-tint: 20%;
  --row-tint-hover: 27%;
}

/* -------------------------------------------------------------- Foundation -- */

* { box-sizing: border-box; }

/* The hidden attribute has to beat every layout rule in here. The browser's
   own [hidden] { display: none } comes from the UA stylesheet and loses
   against ANY author rule that sets display. .login { display: grid } once
   kept the login screen visible although it had long been hidden — one was
   logged in and still saw the form, with the calendar below the fold. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Atkinson Hyperlegible", system-ui, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}

input, select, button, textarea { font-family: inherit; }

h1, h2, h3 { margin: 0; }

.symbol-store { position: absolute; width: 0; height: 0; overflow: hidden; }

.quiet { color: var(--text-2); font-weight: 400; }
.hint { margin: 0; font-size: 12px; color: var(--text-3); }
.error { margin: 0; font-size: 13px; font-weight: 700; color: var(--danger); }
.hidden-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.spacer { flex: 1; }

/* Last resort: visible even when nothing else runs. */
.start-error {
  margin: 0;
  padding: 12px 20px;
  background: var(--coral);
  color: var(--aubergine);
  font-weight: 700;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 14px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

/* Aubergine instead of white: white on coral only reaches 2.9:1. */
.btn-primary {
  padding: 9px 17px;
  background: var(--coral);
  color: var(--aubergine);
  font-weight: 700;
}
.btn-primary:hover { background: var(--coral-hover); }

.btn-secondary { background: var(--surface); border-color: var(--field-line); }
.btn-secondary:hover { background: var(--hover); }

.btn-ghost { padding: 7px 10px; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }

.btn-outline { padding: 6px 12px; border-color: var(--line); }
.btn-outline:hover { background: var(--hover); }

.btn-compact { padding: 7px 12px; font-size: 13px; }

/* In list rows: a border instead of a fill, quiet text. */
.btn-small {
  padding: 6px 10px;
  border-color: var(--line);
  border-radius: 7px;
  font-size: 13px;
  color: var(--text-2);
}
.btn-small:hover { background: var(--hover); color: var(--text); }

/* Delete and remove: a text button in the danger colour. */
.btn-danger {
  font: inherit;
  font-size: 14px;
  padding: 8px 2px;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--danger);
  cursor: pointer;
}
.btn-danger:hover { text-decoration: underline; }
.btn-danger-small { padding: 6px 8px; font-size: 13px; }

/* While a request runs, the button is dead — but visibly dead. Without that a
   second click sends the same login again. */
.btn[disabled], .btn-danger[disabled] { opacity: 0.55; cursor: default; }
.btn-primary[disabled]:hover { background: var(--coral); }

/* ------------------------------------------------------------------ Fields -- */

label, .field-name { display: block; font-size: 13px; color: var(--text-2); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-grow { flex: 1; min-width: 0; }

/* :where() keeps the specificity at zero: every more specific rule further
   down (date next to time, the field inside the password frame) must be able
   to win without having to outbid three :not(). */
:where(input:not([type="checkbox"], [type="radio"], [type="file"])),
:where(select) {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--field-line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

:where(input:not([type="checkbox"], [type="radio"])):focus,
:where(select):focus {
  outline: none;
  border-color: var(--text);
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}
.check input { width: 15px; height: 15px; margin: 0; accent-color: var(--coral); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-repeat { display: grid; grid-template-columns: 1.1fr 0.7fr 1fr; gap: 12px; }

.date-time { display: flex; gap: 8px; }
.date-time > input { width: 104px; flex: none; }

/* A date is a text field in the account's format — the browser's own date
   field shows whatever its language dictates. The calendar button opens the
   browser's picker through a hidden date input; only that popup keeps the
   browser's language. */
.date-field { position: relative; display: flex; flex: 1; min-width: 0; }
.date-field input[type="text"] { padding-right: 38px; }
.picker-button {
  position: absolute;
  top: 50%;
  right: 5px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-2);
  cursor: pointer;
}
.picker-button:hover { background: var(--hover); color: var(--text); }
.picker-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}
.native-picker {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 560px) {
  .grid-2, .grid-repeat { grid-template-columns: 1fr; }
}

/* --- Password fields --- */

/* Field and toggle share one frame; the frame lights up as a whole, not just
   the input inside it. */
.password-field {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--field-line);
  border-radius: 8px;
  background: var(--surface);
}
.password-field:focus-within { border-color: var(--text); }

.password-field input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  border-radius: 8px 0 0 8px;
  background: transparent;
}

.reveal-button {
  flex: none;
  font: inherit;
  font-size: 13px;
  padding: 0 12px;
  border: none;
  border-left: 1px solid var(--field-line);
  border-radius: 0 8px 8px 0;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.reveal-button:hover { background: var(--hover); color: var(--text); }

/* A visible password: sun, bold and a different word — not colour alone. */
.reveal-button[aria-pressed="true"] { background: var(--sun); color: var(--aubergine); font-weight: 700; }

.caps-lock { margin: 0; font-size: 13px; font-weight: 700; color: var(--text); }
.caps-lock::before { content: "\26A0\FE0E  "; }

/* --- Feedback on codes and passwords --- */

/* A badge rather than coloured text; the sign in front says the same thing
   again, so the colour never has to say it alone. */
.finding {
  align-self: flex-start;
  max-width: 100%;
  margin: 0;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--segment-bg);
  color: var(--text);
}
.finding[data-state="good"] { background: var(--sage); color: var(--aubergine); }
.finding[data-state="good"]::before { content: "\2713  "; }
.finding[data-state="bad"] { background: var(--coral); color: var(--aubergine); }
.finding[data-state="bad"]::before { content: "\2715  "; }

.strength { display: flex; flex-direction: column; gap: 6px; }

.strength-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--segment-bg);
  overflow: hidden;
}

.strength-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--coral);
  transition: width 0.2s ease;
}
.strength-bar span[data-level="2"] { background: var(--sun); }
.strength-bar span[data-level="3"] { background: var(--sage); }

@media (prefers-reduced-motion: reduce) {
  .strength-bar span { transition: none; }
}

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

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  position: relative;
  width: min(440px, 100%);
  padding: 26px 28px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-menu);
}

/* The login's mark — the canonical version from favicon.svg. */
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.brand-mark { flex: none; width: 40px; height: 40px; }
.brand h1 { font-size: 17px; letter-spacing: -0.01em; }
.brand-tagline { margin: 0; font-size: 13px; color: var(--text-3); }

/* The language switch sits in the card's corner, where it is found before
   anything has to be read. */
.language-link { position: absolute; top: 18px; right: 20px; }

.panel, .panel-group { display: flex; flex-direction: column; }
.panel h2 { margin: 18px 0 4px; font-size: 17px; }
.panel > .hint { font-size: 13px; }
.panel > label:not(.check), .panel-group > label:not(.check) { margin: 14px 0 6px; }
.panel input + .hint, .panel .caps-lock, .panel .finding, .panel .strength { margin-top: 6px; }
.panel .check { margin-top: 14px; }
.panel .error { margin-top: 12px; }
.panel .btn-primary { margin-top: 18px; }
.panel .notice-box .btn-primary { margin-top: 0; }

/* Switching between panels: looks like a link, but is a button — it leads
   nowhere, it only opens something else. */
.switch-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0 18px;
  margin: 12px 0 0;
}

.link-button {
  font: inherit;
  font-size: 13px;
  padding: 6px 2px;
  border: none;
  background: none;
  color: var(--text-2);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link-button:hover { color: var(--text); }

/* A box for information that changes the path — here: "you already have an
   account, log in". More noticeable than a hint, calmer than an error. */
.notice-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--sunken);
}
.notice-box p { margin: 0; }
.notice-box .btn { align-self: flex-start; }

@media (max-width: 480px) {
  .login { padding: 12px; }
  .card { padding: 20px 18px; }
}

/* ------------------------------------------------------------------ Topbar -- */

.calendar { min-height: 100vh; display: flex; flex-direction: column; }

/* 56px high as long as everything fits on one line. On a phone the bar may
   wrap instead of making the page scroll sideways. */
.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  min-height: 56px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex: none;
}

.topbar-brand { display: flex; align-items: center; gap: 8px; }
.topbar-brand svg { flex: none; display: block; }
.wordmark { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }

.topbar-divider { width: 1px; height: 22px; background: var(--line); }

.chevron {
  width: 12px;
  height: 12px;
  flex: none;
  opacity: 0.5;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Round, with an initial — or the calendar's picture, if it has one. */
.avatar {
  width: 24px;
  height: 24px;
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: var(--avatar);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-coral { background: var(--coral); color: var(--aubergine); }
.avatar-large { width: 44px; height: 44px; font-size: 16px; }
.avatar-person { width: 32px; height: 32px; font-size: 12px; background: var(--segment-bg); }

.calendar-picker { position: relative; min-width: 0; }

.calendar-button {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 5px 8px 5px 5px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
button.calendar-button:hover, .calendar-button[aria-expanded="true"] { background: var(--hover); border-color: var(--line); }
div.calendar-button { cursor: default; }

.calendar-name {
  font-weight: 700;
  /* A long calendar name must not break the topbar. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 24ch;
}

.topbar-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.status { font-size: 12px; color: var(--text-3); margin-right: 4px; }
.status:empty { display: none; }
.status[data-state="error"] { color: var(--danger); font-weight: 700; }
/* Feedback such as "Saved": stronger than the sync status, and with a check
   mark, so it does not stand out through colour alone. */
.status[data-state="ok"] { font-size: 13px; color: var(--text); font-weight: 700; }
.status[data-state="ok"]::before { content: "\2713  "; color: var(--sage); }

.theme-button { gap: 7px; padding: 6px 10px; font-size: 13px; color: var(--text-2); }
.theme-button:hover { color: var(--text); }
.symbol {
  width: 15px;
  height: 15px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.user { position: relative; }

.user-button {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.user-button:hover, .user-button[aria-expanded="true"] { background: var(--hover); }
.person { max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.menu {
  position: absolute;
  top: 42px;
  right: 0;
  z-index: 30;
  width: 210px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-menu);
}
.menu-start { left: 0; right: auto; width: 240px; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 14px;
  padding: 9px 10px;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--text);
  cursor: pointer;
}
.menu-item:hover { background: var(--hover); }
.menu-item-quiet { color: var(--text-2); }
.menu-item-quiet:hover { color: var(--text); }
/* The open calendar in the menu: bold and with a check mark, not merely
   highlighted. */
.menu-item[aria-current="true"] { font-weight: 700; }
.menu-item[aria-current="true"]::after { content: "✓"; margin-left: auto; }
.menu-item .avatar { width: 22px; height: 22px; font-size: 10px; }
.menu-item span:not(.avatar) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.menu-divider { width: auto; height: 1px; margin: 4px 6px; border: none; background: var(--line); }

@media (max-width: 720px) {
  .topbar { padding: 8px 12px; }
  .topbar-divider, .wordmark { display: none; }
  /* The symbol stays, the word goes: aria-label still says it. */
  #theme-word { display: none; }
  .calendar-name { max-width: 14ch; }
}

/* ----------------------------------------------------------------- Toolbar -- */

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex: none;
}

.nav { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }

.arrows {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.arrows button {
  padding: 6px 10px;
  border: none;
  background: none;
  color: var(--text-2);
  line-height: 0;
  cursor: pointer;
}
.arrows button:hover { background: var(--hover); color: var(--text); }
.arrow-divider { width: 1px; height: 20px; background: var(--line); }
.arrow-icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.period { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; min-width: 220px; }

.segment {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 9px;
  background: var(--segment-bg);
}

.view-button {
  font: inherit;
  font-size: 14px;
  padding: 6px 15px;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--text-2);
  cursor: pointer;
}
.view-button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  box-shadow: var(--shadow-segment);
}

.weekend {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.weekend[aria-pressed="true"] { border-color: var(--text); color: var(--text); }

.box {
  width: 15px;
  height: 15px;
  display: grid;
  place-items: center;
  border: 1px solid var(--field-line);
  border-radius: 4px;
  font-size: 10px;
  color: var(--aubergine);
}
.weekend[aria-pressed="true"] .box { background: var(--sun); border-color: var(--sun); }
.weekend[aria-pressed="true"] .box::after { content: "✓"; }

.toolbar-end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
#new-event { padding: 8px 14px; }
.plus {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: var(--aubergine);
  stroke-width: 1.8;
  stroke-linecap: round;
}

/* ------------------------------------------------------------------- Views -- */

.view { flex: 1; padding: 20px; }

/* An event's colour: a bar on the left, the same in all three views. */
[data-color="coral"] { --event-color: var(--coral); }
[data-color="sun"] { --event-color: var(--sun); }
[data-color="sage"] { --event-color: var(--sage); }
[data-color="sky"] { --event-color: var(--sky); }

/* --- Day --- */

.day-card {
  max-width: 760px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.day-card-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.day-card-head h3 { font-size: 15px; }
.day-card-head span { font-size: 13px; color: var(--text-3); }

.day-list { list-style: none; margin: 0; padding: 0; }

/* An event carries its colour as a tinted surface, and the picture lies on
   it: one sign instead of a colour bar next to a picture. The rows are
   separated by a line of the card's own surface, so the tints do not run
   into each other. */
.day-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-bottom: 1px solid var(--surface);
  background: color-mix(in srgb, var(--event-color, var(--coral)) var(--row-tint), var(--surface));
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.day-row:hover { background: color-mix(in srgb, var(--event-color, var(--coral)) var(--row-tint-hover), var(--surface)); }

.day-image {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 8px;
  object-fit: cover;
  background: var(--segment-bg);
}

.day-time {
  width: 104px;
  flex: none;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
/* "3:00 PM – 4:00 PM" does not fit where "15:00 – 16:00 Uhr" does. */
.view[data-clock="12h"] .day-time { width: 150px; }

/* Without a picture the space stays, so the times line up — but empty: a
   grey square on a tinted row would look like a picture that failed. */
span.day-image { background: none; }

.day-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.day-title { font-size: 15px; }
.day-sub { font-size: 12px; color: var(--text-3); }

.empty-day { margin: 0; padding: 14px 16px; color: var(--text-2); }

/* --- Week --- */

.week-grid { display: grid; gap: 12px; }

.week-day {
  display: flex;
  flex-direction: column;
  min-height: 260px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.week-day-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.week-day-head:hover { background: var(--sunken); }
/* The selected day: where "Day" and "New event" lead. */
.week-day-head[aria-pressed="true"] { background: var(--segment-bg); }

.weekday, .month-head span {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.day-number {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.day-number[data-today="yes"] {
  padding: 1px 8px;
  border-radius: 7px;
  background: var(--coral);
  color: var(--aubergine);
}

.week-day-body { display: flex; flex-direction: column; gap: 6px; padding: 8px; }

/* An event in the week or month grid: small image, time first, on a surface
   tinted with the event's colour. */
.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 6px;
  border: none;
  border-radius: 8px;
  background: color-mix(in srgb, var(--event-color, var(--coral)) var(--event-tint), var(--surface));
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.chip:hover { background: color-mix(in srgb, var(--event-color, var(--coral)) var(--event-tint-hover), var(--surface)); }

.chip img {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 6px;
  object-fit: cover;
  background: var(--segment-bg);
}
.chip .time { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip .title { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The following days of a multi-day event: quieter than the entry itself —
   a fainter tint and quieter text. */
.continuation {
  color: var(--text-2);
  background: color-mix(in srgb, var(--event-color, var(--coral)) var(--event-tint-quiet), var(--surface));
}
.continuation .arrow { display: block; flex: none; }

/* --- Month --- */

.month-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.month-head { display: grid; border-bottom: 1px solid var(--line-soft); }
.month-head span { padding: 9px 12px; }

.month-grid { display: grid; }

.month-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 104px;
  min-width: 0;
  padding: 8px 9px 10px;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}
.month-cell[data-outside="yes"] { background: var(--sunken); }

.cell-number {
  align-self: flex-start;
  padding: 1px 2px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.month-cell[data-outside="yes"] .cell-number { color: var(--text-4); font-weight: 400; }
.month-cell[aria-current="date"] .cell-number { background: var(--segment-bg); padding: 1px 7px; }
.month-cell[data-today="yes"] .cell-number {
  padding: 1px 7px;
  background: var(--coral);
  color: var(--aubergine);
  font-weight: 700;
}

.cell-list { display: flex; flex-direction: column; gap: 4px; }
.cell-list .chip { gap: 6px; padding: 3px 4px; border-radius: 6px; }
.cell-list .chip img { width: 20px; height: 20px; border-radius: 5px; }
.cell-list .chip .time, .cell-list .chip .title { font-size: 12px; }

/* Narrow screens: the grids become one column, otherwise an event is
   squeezed to twenty pixels. */
@media (max-width: 900px) {
  .week-grid, .month-grid { grid-template-columns: 1fr !important; }
  .week-day { min-height: 0; }
  .month-head, .month-cell[data-outside="yes"] { display: none; }
  .month-cell { min-height: 0; border-right: none; }
}

@media (max-width: 560px) {
  .view { padding: 12px; }
  .day-time { width: auto; min-width: 64px; }
  .day-row { gap: 10px; padding: 12px; }
}

/* ----------------------------------------------------------------- Dialogs -- */

/* Three fixed parts: head, scrolling body, foot. The foot does not float
   over the content, it bounds it. */
.dialog {
  width: min(640px, calc(100% - 48px));
  max-height: 88vh;
  padding: 0;
  overflow: hidden;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-dialog);
}
.dialog-wide { width: min(660px, calc(100% - 48px)); }
.dialog-narrow { width: min(520px, calc(100% - 48px)); }
.code-dialog { width: min(420px, calc(100% - 48px)); }

.dialog[open] { display: flex; flex-direction: column; }
.dialog::backdrop { background: var(--scrim); }

.dialog form { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.dialog-head { padding: 18px 22px 14px; border-bottom: 1px solid var(--line-soft); flex: none; }
.dialog-head h2 { font-size: 17px; }
.dialog-subtitle { margin: 4px 0 0; font-size: 13px; color: var(--text-3); }
.dialog-text { margin: 0; }

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 22px;
}
.dialog-body-wide { gap: 22px; padding: 18px 22px 22px; }

.dialog-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--line-soft);
  background: var(--sunken);
  flex: none;
}
.dialog-foot-end { justify-content: flex-end; }

@media (max-width: 480px) {
  .dialog, .dialog-wide, .dialog-narrow, .code-dialog { width: calc(100% - 16px); max-height: 94vh; }
  .dialog-head, .dialog-body, .dialog-foot { padding-left: 16px; padding-right: 16px; }
}

/* --- Editor: image --- */

.image-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--sunken);
}
.image-row-picture {
  width: 40px;
  height: 40px;
  flex: none;
  overflow: hidden;
  border-radius: 8px;
  background: var(--segment-bg);
}
.image-row-picture img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-row-text { display: flex; flex-direction: column; min-width: 0; }
.image-row-label { font-size: 13px; color: var(--text-2); }
#image-change { margin-left: auto; }

/* The choice that "Change" opens. It scrolls inside itself, otherwise the
   dialog grows with every motif and Save slides out of view. */
.image-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-top: -6px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}

.image-choices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  width: 100%;
  max-height: 232px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.image-tile {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--segment-bg);
  cursor: pointer;
}
.image-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-tile[aria-pressed="true"] { border-color: var(--coral); }

/* The selection is never conveyed through the border colour alone. */
.image-tile[aria-pressed="true"]::after {
  content: "✓";
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--coral);
  color: var(--aubergine);
  font-size: 11px;
  line-height: 20px;
  text-align: center;
}

.image-tile.no-image { display: grid; place-items: center; color: var(--text-2); font-size: 12px; }

/* Own pictures carry a trash can at the top right — opposite the check mark
   at the bottom right, so the two never overlap. */
.image-tile-wrap { position: relative; }
.image-tile-wrap > .image-tile { display: block; width: 100%; }

.image-delete {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
}
.image-delete svg { width: 15px; height: 15px; }
.image-delete:hover { background: var(--hover); color: var(--danger); }
.image-delete:disabled { opacity: 0.5; cursor: progress; }

/* Separates the templates from one's own pictures, across the full width. */
.image-group {
  grid-column: 1 / -1;
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-2);
}

/* --- Editor: colour --- */

.color-choices { display: flex; align-items: center; gap: 8px; height: 38px; }

.swatch {
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--event-color);
  cursor: pointer;
}
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--text); }
.swatch-name { margin-left: 4px; font-size: 13px; color: var(--text-3); }

/* ------------------------------------------------------------------ Manage -- */

.section { display: flex; flex-direction: column; gap: 12px; }
.section h3 { font-size: 14px; }
.section-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }

.calendar-head { display: flex; align-items: center; gap: 14px; }
.picture-choose { align-self: flex-end; padding: 9px 13px; font-size: 13px; }
#calendar-picture-remove { margin-left: 6px; }

@media (max-width: 480px) {
  .calendar-head { flex-wrap: wrap; }
}

.list { border: 1px solid var(--line-soft); border-radius: 10px; overflow: hidden; }

.list-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}

/* Blocked and long silent: a bar on the left like on an event — the message
   itself stands as a word in the row, the colour is extra. */
.list-row[data-state="blocked"] { box-shadow: inset 3px 0 0 var(--coral); }
.list-row[data-state="quiet"] { box-shadow: inset 3px 0 0 var(--sun); }
.list-row[data-state="quiet"] .meta { color: var(--text); }
.list-row[data-state="pending"] .avatar { background: none; border: 1px dashed var(--field-line); }

.who { display: flex; flex-direction: column; min-width: 0; flex: 1 1 10rem; }
.who strong { font-size: 14px; }
.meta { font-size: 12px; color: var(--text-3); overflow-wrap: anywhere; }

.actions { margin-left: auto; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }

.list-empty { margin: 0; padding: 12px 14px; color: var(--text-2); border-bottom: 1px solid var(--line-soft); }

.list-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 11px 14px;
  background: var(--sunken);
}
.btn-list-foot { padding: 8px 12px; font-size: 13px; }

.list-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid var(--line-soft);
}

/* ------------------------------------------------------------ Codes and QR -- */

.code-dialog .dialog-body { text-align: center; }

/* 320 pixels, measured rather than guessed: since the device QR also names
   the server, it is 102 instead of 54 characters long and needs QR version 6
   instead of 4 — 41x41 modules instead of 33x33. Border and padding of
   .qr-image (2*1px + 2*10px = 22px) come off the width, leaving about 6px per
   module. min(), so the dialog does not burst open on a narrow phone. */
.qr { margin: 0 auto; width: 100%; max-width: min(320px, 100%); }

/* White ground and a border: in dark mode the code would otherwise lie on a
   surface no camera can tell it apart from. */
.qr-image {
  padding: 10px;
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.qr-image svg { display: block; width: 100%; height: auto; }

/* A code is read out and typed. Large, in a monospace font, with air between
   the characters — and selectable, even though the rest of the dialog is
   not. */
.plain-code {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--sunken);
  font-family: ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  /* A device token is 32 characters long and fits on no line. */
  overflow-wrap: anywhere;
  user-select: all;
}
