/* Mawaid -- the iOS Calendar look on both phones: system fonts, hairlines, a red "today",
   the two people in blue (a) and orange (b), light and dark by the system or by the Appearance setting.
   Logical properties only (Arabic is RTL); 44 px targets; safe-area insets on the bars. */

:root {
  --bg: #ffffff; --bg-2: #f2f2f7; --card: #ffffff; --bar: rgba(249, 249, 249, 0.94); --fill: #e9e9eb;
  --ink: #000000; --ink-2: #3c3c43; --muted: #6c6c70; --quiet: #6e6e73;
  --sheet: var(--bg-2); --sheet-group: var(--card); --seg-on: var(--card); --act-day: var(--bg-2); --cd-cell: var(--bg-2);
  --line: rgba(60, 60, 67, 0.22); --line-strong: rgba(60, 60, 67, 0.36);
  --accent: #e0241b; --accent-fill: #e0241b; --accent-ink: #d70015; --on-accent: #ffffff; --link: #d70015;
  --sel: #000000; --on-sel: #ffffff;
  --pa: #007aff; --pa-ink: #0060d6; --pa-soft: rgba(0, 122, 255, 0.12);
  --pb: #ff9500; --pb-ink: #b35900; --pb-soft: rgba(255, 149, 0, 0.16);
  --pm: #8e8e93;
  --danger: #d70015;
  --shadow: 0 -8px 30px rgba(0, 0, 0, 0.12);
  --r: 10px; --r-sheet: 14px;
  --font: -apple-system, system-ui, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif;
  --top: env(safe-area-inset-top, 0px); --bottom: env(safe-area-inset-bottom, 0px);
  --left: env(safe-area-inset-left, 0px); --right: env(safe-area-inset-right, 0px);
  --bar-h: 52px; --tab-h: 58px;
  color-scheme: light dark;
}
:root[data-theme="light"] { color-scheme: light; }
/* the dark set, twice: forced by Appearance (data-theme="dark", theme.js) and by the phone under System;
   keep the two bodies the same (tests/theme-css.test.js checks it) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000; --bg-2: #000000; --card: #1c1c1e; --bar: rgba(22, 22, 24, 0.94); --fill: #39393d;
  --ink: #ffffff; --ink-2: #ebebf5; --muted: #a1a1a8; --quiet: #8d8d93;
  --sheet: #1c1c1e; --sheet-group: #2c2c2e; --seg-on: #636366; --act-day: #1c1c1e; --cd-cell: #1c1c1e;
  --line: rgba(84, 84, 88, 0.55); --line-strong: rgba(84, 84, 88, 0.8);
  --accent: #ff453a; --accent-fill: #d70015; --accent-ink: #ff6961; --on-accent: #ffffff; --link: #ff6961;
  --sel: #ffffff; --on-sel: #000000;
  --pa: #0a84ff; --pa-ink: #5eaeff; --pa-soft: rgba(10, 132, 255, 0.24);
  --pb: #ff9f0a; --pb-ink: #ffb54d; --pb-soft: rgba(255, 159, 10, 0.22);
  --pm: #98989d;
  --danger: #ff6961;
  --shadow: 0 -8px 30px rgba(0, 0, 0, 0.6);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000; --bg-2: #000000; --card: #1c1c1e; --bar: rgba(22, 22, 24, 0.94); --fill: #39393d;
    --ink: #ffffff; --ink-2: #ebebf5; --muted: #a1a1a8; --quiet: #8d8d93;
    --sheet: #1c1c1e; --sheet-group: #2c2c2e; --seg-on: #636366; --act-day: #1c1c1e; --cd-cell: #1c1c1e;
    --line: rgba(84, 84, 88, 0.55); --line-strong: rgba(84, 84, 88, 0.8);
    --accent: #ff453a; --accent-fill: #d70015; --accent-ink: #ff6961; --on-accent: #ffffff; --link: #ff6961;
    --sel: #ffffff; --on-sel: #000000;
    --pa: #0a84ff; --pa-ink: #5eaeff; --pa-soft: rgba(10, 132, 255, 0.24);
    --pb: #ff9f0a; --pb-ink: #ffb54d; --pb-soft: rgba(255, 159, 10, 0.22);
    --pm: #98989d;
    --danger: #ff6961;
    --shadow: 0 -8px 30px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 17px; line-height: 1.35; overflow-wrap: break-word;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.sr { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sprite { position: absolute; inline-size: 0; block-size: 0; overflow: hidden; }
.ic { inline-size: 24px; block-size: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[dir="rtl"] .ic-dir { transform: scaleX(-1); }
.quiet { color: var(--quiet); font-size: 15px; padding: 12px 16px; }
.center { text-align: center; }
.pad { padding: 8px 16px 24px; }
:focus-visible { outline: 2px solid var(--pa); outline-offset: 2px; }

/* ---------------------------------------------------------------- buttons */
.btn-text, .btn-icon {
  background: none; border: 0; color: var(--link); min-block-size: 44px; min-inline-size: 44px;
  padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px;
}
.btn-text { font-size: 17px; }
.btn-strong { font-weight: 600; }
.btn-icon { padding: 0; }
.btn-text:active, .btn-icon:active { opacity: 0.5; }
.btn-text:disabled { opacity: 0.4; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-block-size: 50px; padding: 0 20px;
  border-radius: 12px; border: 0; font-weight: 600; font-size: 17px;
}
.btn-primary { background: var(--accent-fill); color: var(--on-accent); }
.btn-primary:active { filter: brightness(0.9); }
.btn-plain { background: none; color: var(--link); }
.btn-block { display: flex; inline-size: 100%; margin-block-start: 10px; }

/* ---------------------------------------------------------------- login */
.login-page { min-block-size: 100vh; min-block-size: 100dvh; background: var(--bg-2); }
.login {
  max-inline-size: 420px; margin: 0 auto; padding: calc(48px + var(--top)) calc(20px + var(--right)) calc(32px + var(--bottom)) calc(20px + var(--left));
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.login-mark { inline-size: 88px; block-size: 88px; margin-block-end: -8px; } /* the 0.4.0 mark has its own margin inside the SVG */
.login-title { font-size: 34px; font-weight: 700; margin-block-start: 16px; letter-spacing: -0.01em; }
.login-tag { color: var(--muted); margin-block: 4px 28px; }
.login-form { inline-size: 100%; text-align: start; }
.field { display: block; background: var(--card); border-radius: var(--r); padding: 10px 14px; margin-block-end: 12px; }
.field-label { display: block; font-size: 13px; color: var(--muted); }
.field input { display: block; inline-size: 100%; border: 0; background: none; padding: 6px 0 2px; font-size: 17px; outline: none; min-block-size: 32px; }
/* the passphrase: visible by default (the owner's ask, 2026-11-01), Hide / Show at the end of the field */
.field-row { display: flex; align-items: center; gap: 8px; }
.field-row input { flex: 1; min-inline-size: 0; }
.field-toggle { flex: none; min-block-size: 36px; min-inline-size: 44px; padding: 0 4px; font-size: 15px; font-weight: 600; }
.field-hint { display: block; font-size: 13px; color: var(--quiet); margin-block-start: 2px; }
.login-error { color: var(--danger); margin-block: 4px 8px; font-size: 15px; }

/* ---------------------------------------------------------------- app frame */
.app { block-size: 100vh; block-size: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  flex: none; display: flex; align-items: center; gap: 4px; min-block-size: calc(var(--bar-h) + var(--top));
  padding: var(--top) calc(8px + var(--right)) 0 calc(16px + var(--left)); background: var(--bar);
  border-block-end: 0.5px solid var(--line); z-index: 5;
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
.topbar-title { flex: 1; min-inline-size: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; flex: none; }
.topbar .btn-text { color: var(--accent-ink); }
.topbar .btn-icon { color: var(--accent-ink); }
.offline { flex: none; text-align: center; font-size: 13px; color: var(--muted); background: var(--bg-2); padding: 6px 16px; border-block-end: 0.5px solid var(--line); }
.main { flex: 1; min-block-size: 0; position: relative; }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; min-block-size: 0; }
.scroll { flex: 1; min-block-size: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-block-end: 16px; }

.bottombar {
  flex: none; display: flex; align-items: center; gap: 12px;
  padding: 7px calc(16px + var(--right)) calc(7px + var(--bottom)) calc(16px + var(--left));
  background: var(--bar); border-block-start: 0.5px solid var(--line); z-index: 5;
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
.segments { flex: 1; display: flex; background: var(--fill); border-radius: 10px; padding: 2px; max-inline-size: 360px; }
/* four segments: each as wide as its label plus an equal share of the rest, so "Countdowns" fits at 375 px */
.segment {
  flex: 1 1 auto; min-inline-size: 0; min-block-size: 44px; padding: 0 6px; border: 0; background: none; border-radius: 8px;
  font-size: 15px; font-weight: 500; color: var(--ink); white-space: nowrap;
}
.segment.on { background: var(--seg-on); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); font-weight: 600; }
.fab {
  flex: none; inline-size: 48px; block-size: 48px; border-radius: 50%; border: 0; background: var(--accent-fill); color: var(--on-accent);
  display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
}
.fab .ic { inline-size: 26px; block-size: 26px; stroke-width: 2.4; }
.fab:active { transform: scale(0.94); }

.install-hint {
  flex: none; display: flex; align-items: center; gap: 8px; margin: 0 12px 8px; padding: 6px 6px 6px 14px;
  background: var(--card); border-radius: 12px; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12); font-size: 15px;
}
.install-hint span { flex: 1; }
.install-hint .btn-icon { color: var(--muted); }

/* person colours */
.c-a { --p: var(--pa); --p-ink: var(--pa-ink); --p-soft: var(--pa-soft); }
.c-b { --p: var(--pb); --p-ink: var(--pb-ink); --p-soft: var(--pb-soft); }
.c-m { --p: var(--pm); --p-ink: var(--muted); --p-soft: var(--bg-2); }
.dot { display: inline-block; inline-size: 6px; block-size: 6px; border-radius: 50%; background: var(--p); flex: none; }

/* ---------------------------------------------------------------- countdown strip */
.strip {
  flex: none; display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory;
  padding: 8px calc(16px + var(--right)) 8px calc(16px + var(--left)); background: var(--bg); border-block-end: 0.5px solid var(--line);
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.strip::-webkit-scrollbar { display: none; }
.cd-card {
  flex: 0 0 auto; min-inline-size: 150px; max-inline-size: 78%; scroll-snap-align: start; text-align: start;
  display: flex; flex-direction: column; gap: 2px; min-block-size: 52px; padding: 8px 12px;
  border: 0; border-radius: 12px; background: var(--p-soft); border-inline-start: 4px solid var(--p);
}
.strip .cd-card:only-child { flex: 1; max-inline-size: none; }
.cd-card-title { font-size: 13px; font-weight: 600; color: var(--p-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-card-time { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- the Countdowns view */
body[data-view="count"] #todayBtn { display: none; }
.cdl-list { display: flex; flex-direction: column; gap: 12px; padding: 12px calc(16px + var(--right)) 8px calc(16px + var(--left)); }
.cdl-list:empty { display: none; }
.cdl-card { position: relative; border-radius: 14px; background: var(--p-soft); border-inline-start: 4px solid var(--p); }
.cdl-open {
  display: flex; flex-direction: column; gap: 2px; inline-size: 100%; padding: 14px 16px 16px; border: 0; border-radius: inherit;
  background: none; color: var(--ink); text-align: start;
}
.cdl-open:active { opacity: 0.7; }
.cdl-title { font-size: 20px; font-weight: 700; line-height: 1.25; padding-inline-end: 64px; }
.cdl-when { font-size: 14px; color: var(--p-ink); padding-inline-end: 8px; }
.cdl-place { color: var(--muted); }
.cdl-count { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 8px; margin-block-start: 10px; font-variant-numeric: tabular-nums; }
.cdl-num { font-size: 44px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.cdl-word { letter-spacing: 0; }
.cdl-unit { font-size: 17px; font-weight: 600; color: var(--ink-2); }
.cdl-line { font-size: 34px; font-weight: 700; line-height: 1.1; }
.cdl-now { color: var(--accent-ink); }
.cdl-edit { position: absolute; inset-block-start: 4px; inset-inline-end: 4px; font-size: 15px; font-weight: 600; color: var(--p-ink); }
.cdl-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; max-inline-size: 340px; margin: 0 auto; padding: 72px 24px 24px; text-align: center; }
.cdl-empty-head { font-size: 20px; font-weight: 700; }
.cdl-empty-line { color: var(--muted); font-size: 15px; margin-block-end: 12px; }

/* ---------------------------------------------------------------- month */
.weekdays {
  flex: none; display: grid; grid-template-columns: repeat(7, 1fr); padding-inline: var(--left) var(--right);
  font-size: 12px; color: var(--muted); text-align: center; padding-block: 4px; background: var(--bar);
  border-block-end: 0.5px solid var(--line);
}
.month-scroll { flex: 1; min-block-size: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; position: relative; padding-inline: var(--left) var(--right); }
.month-block { padding-block-end: 8px; }
.month-label { font-size: 20px; font-weight: 700; padding: 12px 12px 6px; color: var(--ink); }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cell { min-block-size: 50px; }
.day {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0 6px; border: 0; background: none;
  border-block-start: 0.5px solid var(--line); min-inline-size: 0;
}
.num {
  inline-size: 32px; block-size: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; font-variant-numeric: tabular-nums;
}
.dots { display: flex; gap: 3px; block-size: 6px; }
.day.today .num { color: var(--accent-ink); font-weight: 600; box-shadow: inset 0 0 0 1.5px var(--accent); }
.day.selected .num { background: var(--sel); color: var(--on-sel); font-weight: 600; box-shadow: none; }
.day.today.selected .num { background: var(--accent-fill); color: var(--on-accent); }
.day:active .num { background: var(--fill); }
.day.flash .num { animation: flash 1.2s ease-out 1; }
@keyframes flash {
  0% { transform: scale(1); box-shadow: 0 0 0 0 var(--accent); }
  30% { transform: scale(1.25); box-shadow: 0 0 0 8px rgba(224, 36, 27, 0.25); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(224, 36, 27, 0); }
}
.agenda {
  flex: none; max-block-size: 38%; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  border-block-start: 0.5px solid var(--line-strong); background: var(--bg); padding-block-end: 8px;
}
.agenda-head {
  position: sticky; inset-block-start: 0; z-index: 1; display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-size: 15px; font-weight: 600; padding: 10px 16px 6px; background: var(--bg);
}
.agenda-count { font-weight: 400; color: var(--muted); font-size: 13px; white-space: nowrap; }

/* ---------------------------------------------------------------- event rows */
.event {
  display: flex; align-items: stretch; gap: 10px; inline-size: calc(100% - 24px); margin: 4px 12px; padding: 0; min-block-size: 52px;
  background: var(--p-soft); border: 0; border-radius: 8px; text-align: start; overflow: hidden;
}
.event:active { filter: brightness(0.94); }
.event-bar { flex: none; inline-size: 4px; background: var(--p); }
.event-main { flex: 1; min-inline-size: 0; display: flex; flex-direction: column; justify-content: center; padding-block: 7px; padding-inline: 0 10px; gap: 1px; }
.event-title { font-weight: 600; font-size: 16px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-meta { font-size: 14px; color: var(--p-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-place { color: var(--muted); }

/* ---------------------------------------------------------------- week and day */
.pager {
  flex: none; display: flex; align-items: center; gap: 4px; padding: 2px calc(4px + var(--right)) 2px calc(4px + var(--left));
  border-block-end: 0.5px solid var(--line);
}
.pager .btn-icon { color: var(--accent-ink); }
.pager-label { flex: 1; text-align: center; font-size: 17px; font-weight: 600; }
.week-day { padding-block: 4px 6px; border-block-end: 0.5px solid var(--line); }
.list-day { display: flex; align-items: baseline; gap: 6px; padding: 10px 16px 4px; font-size: 15px; font-weight: 600; }
.list-wd { color: var(--muted); font-weight: 500; text-transform: uppercase; font-size: 13px; letter-spacing: 0.02em; }
.list-dn { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.list-mo { color: var(--muted); font-weight: 500; }
.list-day.is-today .list-dn, .list-day.is-today .list-wd { color: var(--accent-ink); }
.week-day .quiet { padding-block: 2px 8px; font-size: 14px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; color: var(--on-accent); background: var(--accent-fill); border-radius: 6px; padding: 1px 7px; margin-inline-start: auto; }
.list-note { display: flex; align-items: center; gap: 8px; padding: 10px 16px 2px; font-size: 13px; color: var(--muted); }
.view-day .list-note .badge { margin: 0; }
.slide-next { animation: slide-next 0.22s ease-out; }
.slide-prev { animation: slide-prev 0.22s ease-out; }
@keyframes slide-next { from { opacity: 0.2; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes slide-prev { from { opacity: 0.2; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
[dir="rtl"] .slide-next { animation-name: slide-prev; }
[dir="rtl"] .slide-prev { animation-name: slide-next; }

/* ---------------------------------------------------------------- activity */
.act-day {
  position: sticky; inset-block-start: 0; z-index: 1; font-size: 13px; font-weight: 600; color: var(--muted);
  padding: 14px 16px 6px; background: var(--act-day); border-block-end: 0.5px solid var(--line);
}
.act-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 16px; border-block-end: 0.5px solid var(--line); min-block-size: 44px; }
.act-row .dot { inline-size: 10px; block-size: 10px; margin-block-start: 6px; }
.act-main { flex: 1; min-inline-size: 0; }
.act-text { font-size: 16px; }
.act-meta { font-size: 13px; color: var(--muted); margin-block-start: 2px; }

/* ---------------------------------------------------------------- sheets */
dialog { color: var(--ink); }
.sheet {
  inline-size: 100%; max-inline-size: 640px; max-block-size: calc(100dvh - var(--top) - 24px);
  margin: auto auto 0; padding: 0 0 calc(12px + var(--bottom)); border: 0; border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  background: var(--sheet); box-shadow: var(--shadow); overflow: hidden;
}
.sheet .group { background: var(--sheet-group); }
.sheet[open] { display: flex; flex-direction: column; animation: sheet-up 0.32s cubic-bezier(0.32, 0.72, 0, 1); }
.sheet::backdrop { background: rgba(0, 0, 0, 0.35); animation: fade 0.25s ease-out; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet-form { display: flex; flex-direction: column; min-block-size: 0; flex: 1; }
.sheet-handle { flex: none; inline-size: 36px; block-size: 5px; border-radius: 3px; background: var(--line-strong); margin: 6px auto 2px; }
.sheet-bar { flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 8px; }
.sheet-bar > :first-child { justify-self: start; }
.sheet-bar > :last-child { justify-self: end; }
.sheet-bar .btn-text { color: var(--link); }
.sheet-title { font-size: 17px; font-weight: 600; text-align: center; }
.sheet-body { flex: 1; min-block-size: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 4px 16px 16px; }
.sheet-small { padding-inline: 16px; }
.sheet-small form { display: flex; flex-direction: column; }
.sheet-big { font-size: 22px; font-weight: 700; text-align: center; margin-block: 12px 6px; }
.why { display: block; color: var(--muted); font-size: 13px; font-weight: 400; margin-block: 2px 12px; }
.why.center { font-size: 15px; margin-block-end: 16px; }
.notify-bell { display: flex; justify-content: center; margin-block-start: 14px; color: var(--accent); }
.notify-bell .ic { inline-size: 44px; block-size: 44px; stroke-width: 1.6; }
.scope-msg { text-align: center; color: var(--muted); font-size: 13px; padding: 10px 8px 12px; }

.group { background: var(--card); border-radius: var(--r); margin-block: 0 16px; overflow: hidden; }
.group-head { font-size: 13px; font-weight: 400; color: var(--muted); text-transform: uppercase; padding: 4px 16px 6px; letter-spacing: 0.02em; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-block-size: 46px; padding: 4px 16px;
  border: 0; margin: 0; background: none; inline-size: 100%;
}
.row + .row { border-block-start: 0.5px solid var(--line); }
.row > span:first-child { flex: 0 1 auto; min-inline-size: 0; }
.row > .row-text { flex: 1; }
.row-tall { padding-block: 8px; }
.row-text { display: flex; flex-direction: column; min-inline-size: 0; }
.row-text .why { margin: 2px 0 0; }
.row-input input, .row-input textarea { flex: 1; inline-size: 100%; border: 0; background: none; padding: 10px 0; font-size: 17px; outline: none; min-block-size: 44px; }
.row-input textarea { resize: vertical; min-block-size: 76px; }
.row-name { align-items: flex-end; }
.row-name .grow { flex: 1; min-inline-size: 0; padding-block-start: 6px; }
.row-name input { padding-block: 2px 8px; min-block-size: 36px; }
/* Appearance (Settings): a small segmented control at the end of the row */
.seg-small { flex: 0 1 auto; display: flex; background: var(--fill); border-radius: 9px; padding: 2px; }
/* its own class, not .segment: app.js binds every .segment to the view tabs */
.seg-choice {
  flex: 0 1 auto; min-inline-size: 0; min-block-size: 32px; padding: 0 12px; border: 0; background: none; border-radius: 7px;
  font-size: 14px; font-weight: 500; color: var(--ink); white-space: nowrap;
}
.seg-choice.on { background: var(--seg-on); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); font-weight: 600; }
.row-button { border: 0; justify-content: center; font-size: 17px; color: var(--link); text-align: center; }
.row-button.danger, .danger { color: var(--danger); }
.row select, .row input[type="date"], .row input[type="time"], .row input[type="number"] {
  border: 0; border-radius: 7px; background: var(--fill); padding: 6px 10px; font-size: 16px; min-block-size: 36px; max-inline-size: 62%;
}
.row input[type="number"] { inline-size: 96px; text-align: center; }
.row select { appearance: none; -webkit-appearance: none; text-align: end; text-align-last: end; color: var(--muted); background: none; padding-inline-end: 0; }
.when { flex: 1; min-inline-size: 0; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; padding-block: 4px; }
.when input[type="date"] { max-inline-size: none; }
.when input.time { inline-size: auto; }
.form-error { color: var(--danger); font-size: 15px; padding: 8px 4px; }
.form-error.inset { padding: 0 16px 10px; }

/* the calendar feed link (Settings): shown once, copyable */
.quiet-inline { color: var(--quiet); }
.form-error-inline { color: var(--danger); font-size: 15px; }
.feed-link { padding: 4px 16px 14px; border-block-start: 0.5px solid var(--line); }
.feed-link .why { margin-block: 8px 8px; }
.feed-url {
  margin: 0 0 12px; padding: 10px 12px; background: var(--bg-2); border-radius: 10px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.4; color: var(--ink-2);
  overflow-wrap: anywhere; word-break: break-all; user-select: all; -webkit-user-select: all;
}
.nowrap { white-space: nowrap; }
.feed-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.feed-actions .btn { flex: 1 1 auto; min-block-size: 44px; text-decoration: none; }
.feed-how { padding: 6px 16px 8px; }
.feed-step { margin: 0; padding-block: 6px; font-size: 15px; line-height: 1.4; color: var(--ink-2); }
.feed-step + .feed-step { border-block-start: 0.5px solid var(--line); }
#evBy { padding-block: 0 12px; }

/* the iOS switch */
.switch {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; inline-size: 51px; block-size: 31px; margin: 0;
  border-radius: 16px; background: var(--fill); transition: background 0.2s; cursor: pointer;
}
.switch::before {
  content: ""; position: absolute; inset-block-start: 2px; inset-inline-start: 2px; inline-size: 27px; block-size: 27px; border-radius: 50%;
  background: #ffffff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25); transition: transform 0.2s;
}
.switch:checked { background: #34c759; }
.switch:checked::before { transform: translateX(20px); }
[dir="rtl"] .switch:checked::before { transform: translateX(-20px); }

/* ---------------------------------------------------------------- full-screen countdown */
.countdown-full {
  inline-size: 100%; block-size: 100%; max-inline-size: none; max-block-size: none; margin: 0; padding: 0; border: 0;
  background: var(--bg); color: var(--ink);
}
.countdown-full[open] { display: flex; animation: fade 0.25s ease-out; }
.countdown-full::backdrop { background: var(--bg); }
.cd-close { position: absolute; inset-block-start: calc(8px + var(--top)); inset-inline-end: calc(8px + var(--right)); color: var(--muted); }
.cd-body { margin: auto; padding: 24px 20px; text-align: center; inline-size: 100%; max-inline-size: 640px; }
.cd-title { font-size: 30px; font-weight: 700; letter-spacing: -0.01em; }
.cd-when { color: var(--muted); margin-block: 8px 32px; }
.cd-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cd-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 0; border-radius: 14px; background: var(--cd-cell); }
.cd-num { font-size: clamp(34px, 11vw, 72px); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.cd-unit { font-size: 13px; color: var(--muted); }
.cd-state { font-size: 44px; font-weight: 700; color: var(--accent-ink); }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed; inset-inline: 16px; inset-block-end: calc(var(--tab-h) + var(--bottom) + 16px); z-index: 50; margin: 0 auto; max-inline-size: 480px;
  background: rgba(30, 30, 32, 0.94); color: #ffffff; padding: 12px 16px; border-radius: 12px; font-size: 15px; text-align: center;
}

@media (min-width: 700px) {
  .cell { min-block-size: 64px; }
  .num { inline-size: 36px; block-size: 36px; }
  .event { inline-size: calc(100% - 32px); margin-inline: 16px; }
  /* the Fold open and tablets: the month grid on the start side, the selected day's agenda beside it */
  .view-month { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 38%); grid-template-rows: auto minmax(0, 1fr); }
  .view-month .weekdays { grid-column: 1; grid-row: 1; }
  .view-month .month-scroll { grid-column: 1; grid-row: 2; }
  .view-month .agenda {
    grid-column: 2; grid-row: 1 / span 2; max-block-size: none; min-block-size: 0;
    border-block-start: 0; border-inline-start: 0.5px solid var(--line-strong); background: var(--bg-2);
  }
  .view-month .agenda-head { background: var(--bg-2); padding-block-start: 14px; font-size: 17px; }
  /* the lists keep a reading width; the pager and the bottom bar centre on it */
  .view-week .scroll, .view-day .scroll, #activityScroll, #countScroll, .view-week .pager, .view-day .pager {
    padding-inline: max(0px, calc((100% - 720px) / 2));
  }
  .bottombar { justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
