/* ============================================================
   Life OS — لوحة إدارة حياتي
   Layout + components. All colour comes from the Droos Online
   design tokens in _ds/; nothing is hard-coded except the two
   night-mode ramp overrides below.
   ============================================================ */

/* ---- Night mode: re-point the ink ramp, everything follows ---- */
:root[data-theme="night"] {
  --paper:         #1C1C1E;   /* Apple secondarySystemGroupedBackground */
  --ink-75:        #101010;
  --ink-50:        #2C2C2E;   /* Apple tertiarySystemGroupedBackground */
  --ink-100:       #272727;
  --ink-200:       rgba(255, 255, 255, .16);
  --ink-300:       rgba(255, 255, 255, .26);
  --ink-400:       #8b8b8b;
  --ink-500:       #a4a4a4;
  --ink-600:       #bfbfbf;
  --ink-700:       #d8d8d8;
  --ink-800:       #ebebeb;
  --ink-900:       #f6f6f6;
  --border-subtle: rgba(255, 255, 255, .12);
  --border-strong: rgba(255, 255, 255, .22);
  --page-bg:       #000000;
}

:root {
  color-scheme: light;
  --page-bg:     #F2F2F7;   /* Apple systemGroupedBackground */
  /* A day with nothing in it. Owned by CSS rather than the model so it can
     follow the theme — a fixed light grey left its numerals unreadable at
     night. */
  --empty-tile:  #C3CAD4;
  --empty-ink:   #46505F;
  /* Ruling of the paper behind everything. Barely there on purpose. */
  --rule:        rgba(22, 36, 59, .085);

  /* Overall scale of the interface. Everything in this file is in px, so
     one factor here resizes the lot — see the .app/.gate/.sheet rule below
     for what it applies to and what has to be divided back out.

     The real value is proportional to the viewport and set at runtime by
     fitZoom() in app.js (phones and desktops each get their own curve);
     what's here only covers the moment before that script runs. */
  --zoom:        1;
}

/* ============================================================
   Apple system palette
   ------------------------------------------------------------
   Apple ships two variants of every system colour: the light one is
   held back so it doesn't glare on white, the dark one lifted so it
   doesn't sink into black. Both are listed here because the app's night
   mode is a true black page, where the light variants go muddy.

   model.js owns the same table, since colours stored in the data have
   to be mapped in JS before they reach the DOM; these tokens are for
   the colours the stylesheet picks itself.
   ============================================================ */
:root {
  --sys-red:    #FF3B30;  --sys-orange: #FF9500;  --sys-yellow: #FFCC00;
  --sys-green:  #34C759;  --sys-mint:   #00C7BE;  --sys-teal:   #30B0C7;
  --sys-cyan:   #32ADE6;  --sys-blue:   #007AFF;  --sys-indigo: #5856D6;
  --sys-purple: #AF52DE;  --sys-pink:   #FF2D55;  --sys-brown:  #A2845E;
  --sys-gray:   #8E8E93;

  /* Status and meaning come from the system palette too, so a green drawn
     by the stylesheet matches a green drawn by JS. --danger is left alone
     on purpose: that red is the logo's, not a status colour. */
  --info:    var(--sys-blue);
  --success: var(--sys-green);
  --warning: var(--sys-orange);

  /* ---- Cards ----
     Apple separates a card from its page by surface and depth, never by
     a drawn edge: white on grey, lifted by a shadow soft enough that you
     read it as height rather than as a line. */
  --card-bg:      var(--paper);
  --card-radius:  calc(16px * var(--zoom));
  --card-border:  transparent;
  --card-shadow:  0 1px 2px rgba(0, 0, 0, .05), 0 6px 16px rgba(0, 0, 0, .05);
  --card-shadow-hover: 0 2px 4px rgba(0, 0, 0, .06), 0 12px 28px rgba(0, 0, 0, .09);
  /* The quiet surface for a container that holds cards — a kanban column,
     a grouped list. A well sits *under* the page rather than above it, so
     it steps down one stop on Apple's grey ramp (systemGray5) instead of
     taking a shadow. */
  --card-well:    #E5E5EA;
}

:root[data-theme="night"] {
  --sys-red:    #FF453A;  --sys-orange: #FF9F0A;  --sys-yellow: #FFD60A;
  --sys-green:  #30D158;  --sys-mint:   #66D4CF;  --sys-teal:   #40C8E0;
  --sys-cyan:   #64D2FF;  --sys-blue:   #0A84FF;  --sys-indigo: #5E5CE6;
  --sys-purple: #BF5AF2;  --sys-pink:   #FF375F;  --sys-brown:  #AC8E68;
  --sys-gray:   #98989D;

  --info:    var(--sys-blue);
  --success: var(--sys-green);
  --warning: var(--sys-orange);

  /* In the dark there is nothing for a shadow to fall on, so Apple raises
     a surface by lightening it instead and marks the edge with a hairline. */
  --card-border:  rgba(255, 255, 255, .08);
  --card-shadow:  none;
  --card-shadow-hover: none;
  --card-well:    #161618;
}

:root[data-theme="night"] {
  color-scheme: dark;
  --empty-tile:  #2b2b2b;
  --empty-ink:   #9b9b9b;
  --rule:        rgba(255, 255, 255, .07);
}

/* The `hidden` attribute is only `display: none` in the UA stylesheet, so any
   author `display` declaration silently beats it. .gate, .month-grid and
   .calendar all set `display: grid` and are all toggled with `hidden` — which
   left the sign-in card painted over the dashboard after signing in, and both
   month views stacked on top of each other. */
[hidden] { display: none !important; }

body {
  background: var(--page-bg);
  color: var(--ink-700);
  transition: background var(--dur-base) var(--ease-out);
}

/* ---- Squared-paper backdrop ----
   0.5cm ruling, like an exercise book. Fixed rather than scrolling, so the
   app reads as sheets resting on paper instead of printed onto it. The mask
   fades the ruling out toward the edges, which keeps it from framing the
   content or drawing the eye off it. `cm` here is the CSS centimetre
   (96dpi), so the squares match across devices even where they don't match
   a ruler. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right,  var(--rule) 1px, transparent 1px),
    linear-gradient(to bottom, var(--rule) 1px, transparent 1px);
  background-size: .8cm .8cm;
  -webkit-mask-image: radial-gradient(ellipse 76% 72% at 50% 42%, #000 30%, transparent 100%);
          mask-image: radial-gradient(ellipse 76% 72% at 50% 42%, #000 30%, transparent 100%);
}

/* ---- Dots backdrop ----
   The alternative paper: a dot lattice that drifts slowly. The direction
   is picked at random by app.js on every load (--wave-x/--wave-y), and
   the intermediate keyframes bow the path so it reads as a wave rather
   than a slide. The pseudo-element is oversized so the drift never drags
   an edge into view. */
body[data-bg="dots"]::before {
  inset: -30%;
  background-image:
    radial-gradient(circle, var(--rule) 1.6px, transparent 1.9px),
    radial-gradient(circle, var(--rule) 1.2px, transparent 1.5px);
  background-size: .8cm .8cm, 1.13cm 1.13cm;
  background-position: 0 0, .4cm .55cm;
  animation: dots-wave var(--wave-dur, 75s) ease-in-out infinite;
}

@keyframes dots-wave {
  0%   { transform: translate(0, 0); }
  22%  { transform: translate(calc(var(--wave-x, 40px) * .55), calc(var(--wave-y, 26px) * .2)); }
  50%  { transform: translate(var(--wave-x, 40px), var(--wave-y, 26px)); }
  76%  { transform: translate(calc(var(--wave-x, 40px) * .3), calc(var(--wave-y, 26px) * .75)); }
  100% { transform: translate(0, 0); }
}

@media (prefers-reduced-motion: reduce) {
  body[data-bg="dots"]::before { animation: none; }
}

/* The paper is behind, not under: without a stacking context of their own
   these sit at z-index auto and the fixed layer paints over them. */
.app,
.gate { position: relative; z-index: 1; }

/* ---- Interface scale ----
   `zoom` rather than `transform: scale()`: it is a real layout scale, so
   the page reflows, wraps and hit-tests at the new size instead of being
   stretched. Applied to the three roots rather than <body>, which keeps two
   things out of it — the paper backdrop, whose squares are meant to be half
   a centimetre whatever the interface does, and the confetti layer, whose
   position comes from JS in unscaled client coordinates.

   The catch is viewport units: inside a zoomed subtree `100dvh` still means
   the whole viewport and then gets multiplied, so anything sized against
   the viewport has to be divided back out or it overflows. Those few places
   are marked below. */
.app,
.gate,
.sheet { zoom: var(--zoom); }

/* Scaled from inside, so the burst grows with the checkbox it fires from
   while the layer stays anchored at the unscaled point JS gave it. */
.confetti i { zoom: var(--zoom); }

.app {
  max-width: 1280px;
  margin-inline: auto;
  padding: clamp(16px, 3vw, 34px) clamp(14px, 3vw, 30px) 60px;
}

/* The app used to be anchored a step in from the inline start (the right,
   in RTL) so the floating layer could have the rest. On a wide display
   that read as the whole interface leaning right with a gulf of empty
   page on the left, so it is centred again — and the drawer now takes
   its room from the content rather than from the margin (see .nav below). */

/* ============================================================
   Topbar
   ============================================================ */

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.topbar__logo { height: 30px; width: auto; flex: 0 0 auto; cursor: pointer; }

/* The profile picture slot. Empty, it invites: a dashed circle with an
   add-a-person mark; set, it shows the face and drops the invitation. */
.avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1.5px dashed var(--border-strong);
  border-radius: 50%;
  background: var(--ink-50) center / cover no-repeat;
  color: var(--ink-500);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.avatar svg { width: 21px; height: 21px; }
.avatar:hover { color: var(--ink-800); border-color: var(--ink-500); }
.avatar--set { border: none; box-shadow: 0 0 0 2px var(--border-strong); }

.topbar__titles { margin-inline-end: auto; min-width: 0; }

.topbar__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 17px;
  line-height: 1.15;
  letter-spacing: 0;
  color: var(--ink-900);
}

.topbar__sub {
  margin: 2px 0 0;
  font-family: var(--font-body);
  font-weight: var(--fw-medium);
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-500);
}

/* ---- Month stepper ---- */

.monthnav {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--ink-50);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
}

.monthnav__btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-700);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: var(--fw-bold);
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.monthnav__btn:hover { background: color-mix(in srgb, var(--ink-900) 8%, transparent); }

/* The month/week switch rides in the nav — it labels the *other* view. */
.monthnav__btn--view {
  width: auto;
  padding: 0 12px;
  margin-inline-start: 4px;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--paper);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: var(--fw-semibold);
}

.monthnav__label {
  min-width: 108px;
  text-align: center;
  font-family: var(--font-num);
  font-weight: var(--fw-bold);
  font-size: 13px;
  color: var(--ink-900);
}

/* ---- Pills ---- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: filter var(--dur-base) var(--ease-out),
              background var(--dur-base) var(--ease-out);
}
.pill:hover { filter: brightness(.96); }

.pill--sync {
  background: var(--paper);
  color: var(--ink-700);
  border: 1px solid var(--border-subtle);
}

/* Year progress: a quiet counter, not a control — hence no hover. The
   spent share of the year fills the pill from the right (--pct comes
   from renderChrome), so the badge doubles as a tiny progress bar. */
.pill--year {
  background:
    linear-gradient(
      to left,
      color-mix(in srgb, var(--success) 30%, transparent) var(--pct, 0%),
      transparent var(--pct, 0%)
    ) var(--ink-50);
  color: var(--ink-700);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-num);
  cursor: default;
}
.pill--year:hover { filter: none; }

/* The theme switch, beside the year bar. Icon only and quiet: it sits in
   the topbar permanently, so it has to read as a control without competing
   with the date. The icon shows what a press will GIVE you — a moon while
   you are in daylight — which is what makes it answerable at a glance. */
.pill--theme {
  padding: 8px 10px;
  background: var(--ink-50);
  color: var(--ink-600);
  border: 1px solid var(--border-subtle);
}
.pill--theme:hover { color: var(--ink-900); }
.pill--theme svg {
  width: 15px;
  height: 15px;
  display: block;
  /* Swapped on a quarter turn rather than cut, so the change registers as
     the same control changing its mind. */
  animation: theme-swap var(--dur-snap) var(--ease-emph);
}
@keyframes theme-swap {
  from { opacity: 0; transform: rotate(-35deg) scale(.7); }
}
:root[data-theme="night"] .pill--theme { color: #F5C518; }

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

/* ---- Sync status dot / spinner ---- */

.dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tone, var(--ink-400));
}
.dot[data-tone="ok"]   { --tone: var(--success); }
.dot[data-tone="warn"] { --tone: var(--warning); }
.dot[data-tone="bad"]  { --tone: var(--danger); }
.dot[data-tone="idle"] { --tone: var(--ink-400); }

.dot[data-spin="1"] {
  width: 12px;
  height: 12px;
  background: none;
  border: 2px solid color-mix(in srgb, var(--tone, var(--info)) 28%, transparent);
  border-top-color: var(--tone, var(--info));
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .dot[data-spin="1"] { animation-duration: 2.4s; }
  * { scroll-behavior: auto; }
}

/* ============================================================
   Area editor
   ============================================================ */

/* The native colour well, dressed to sit beside .field */
.colorfield {
  display: block;
  width: 64px;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--paper);
  cursor: pointer;
}

/* "+" chip at the end of the composer's area picker */
.areapick__opt--add { border-style: dashed; }
.areapick__opt--add::before { display: none; }
.areapick__opt--add:hover { border-style: solid; background: var(--ink-50); }

/* ============================================================
   Layout — one engine, three shapes
   wide   : day panel beside a broad month grid
   medium : day panel stacked above the grid
   narrow : same, tightened for phones
   ============================================================ */

.layout {
  display: grid;
  gap: 22px;
  margin-top: 18px;
  align-items: start;
}

/* Two columns once the app has ~1000px of its own space. With the
   proportional zoom (see fitZoom in app.js) a desktop viewport of 1000px
   real pixels is guaranteed at least that much effective width: the zoom
   stays at 1 until 1400px and grows in step with the viewport after. */
@media (min-width: 1000px) {
  /* The panel is where the actual work happens, so it gets the room. */
  .layout { grid-template-columns: minmax(0, 460px) minmax(0, 1fr); }

  /* The box holds its place and size; when a day outgrows it, the task
     list inside scrolls (see .panel__list). The height cap is set live
     by fitPanel() in app.js, measured from the panel's on-screen
     position — a static calc() here overflowed whenever the topbar sat
     above the panel. */
  .layout__panel {
    position: sticky;
    top: 20px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }
}

.grid-title {
  margin: 2px 2px 14px;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 13px;
  letter-spacing: 0;
  color: var(--ink-700);
}

/* The week number pops out of the title on a highlighter swatch. */
.grid-title__week {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 7px;
  background: #F5C518;
  color: #16243B;
  font-family: var(--font-num);
  font-size: 12px;
}

/* ============================================================
   Day panel
   ============================================================ */

/* The panel is a transparent column of two sheets: the day card
   (.panel__main) and the composer card below it, with a clear gap. */
.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* The weekday and the dates split the head between them — the name
   big at the start, the calendar lines end-aligned opposite it. */
.panel__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px 14px;
  padding-block: 2px 6px;
}

.panel__dates { flex: 0 1 auto; min-width: 0; text-align: end; }

.panel__weekday {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: clamp(24px, 2.2vw, 30px);
  line-height: 1.1;
  color: var(--ink-900);
}

.panel__greg {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 18px;
  line-height: 1.15;
  color: var(--ink-700);
}

.panel__hijri {
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--ink-500);
  margin-top: 4px;
}

.panel__tasksbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 18px 0 9px;
}

.panel__taskstitle {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 14px;
  color: var(--ink-900);
}

.panel__progress {
  font-family: var(--font-num);
  font-weight: var(--fw-semibold);
  font-size: 12.5px;
  color: var(--ink-500);
}

/* Only the list gives way when height runs out — everything else in the
   panel (composer included, whose size never changes) keeps its natural
   size. The shrink chain runs panel → main → listwrap → list. */
.panel > * { flex: 0 0 auto; }
.panel > .panel__main { flex: 0 1 auto; }

/* The day's areas draw the card's stroke: a thin ring where each colour
   takes its share of the tasks (--accent-bg, built in renderPanel). The
   paper paints the padding-box and the bands show through a transparent
   border — the way to a gradient stroke that still follows the radius. */
.panel__main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  border: 2.25px solid transparent;
  background:
    linear-gradient(var(--paper), var(--paper)) padding-box,
    var(--accent-bg, linear-gradient(var(--accent), var(--accent))) border-box;
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  padding: clamp(16px, 2.4vw, 22px);
  padding-top: 36px;
}
/* Punched holes along the top edge — the card reads like a sheet
   pulled off a ring binder. Each hole is the page background with a
   slightly larger dark circle peeking above it as an inner shadow. */
.panel__main::before {
  content: '';
  position: absolute;
  top: 10px;
  inset-inline: 22px;
  height: 13px;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 6.5px 7px, var(--page-bg) 0 4.2px, transparent 5px),
    radial-gradient(circle at 6.5px 6.2px, rgba(15, 25, 42, .35) 0 4.7px, transparent 5.5px);
  background-size: 34px 13px;
  background-repeat: repeat-x;
  background-position-x: center;
}
/* The compact day sheet strips the card look — no paper, no holes. */
.day-view:not(.day-view--full) .panel__main::before { display: none; }
.panel__main > * { flex: 0 0 auto; }
.panel__main > .panel__listwrap { flex: 0 1 auto; }

/* ---- The scrolling middle ----
   Rows keep one fixed, readable size no matter how many there are. When
   a day outgrows the box, only the list scrolls — head, progress and
   composer hold still — and a floating hint marks the cut-off tasks. */

.panel__listwrap {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel__list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
  min-height: 0;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.panel__more {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  border: none;
  margin: 0;
  padding: 22px 0 4px;
  background: linear-gradient(to bottom, transparent, var(--paper) 72%);
  color: var(--ink-500);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}
.panel__more:hover { color: var(--ink-800); }

.panel__empty {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink-500);
  padding: 10px 2px;
}

/* ---- Task row ---- */

.task {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--tint);
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
  border-radius: var(--radius-md);
  padding: 9px 11px;
  /* The whole row is a drag target; selection would fight the gesture. */
  user-select: none;
  -webkit-user-select: none;
  transition: opacity var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
}
/* A finished task turns grey: the area tint and stroke give way to
   neutral ink, so the day's colours belong to what's still open.
   The grey is deliberately dark — done should read at a glance. */
.task[data-done="1"] {
  background: var(--ink-300);
  border-color: var(--ink-400);
}
.task[data-done="1"]:hover { box-shadow: 0 2px 10px rgba(22, 36, 59, .12); }

/* The row on its way down rides above its neighbours with a lift. */
.task--sinking {
  position: relative;
  z-index: 3;
  box-shadow: 0 12px 26px rgba(22, 36, 59, .28);
}
.task[data-done="1"] .task__text,
.task[data-done="1"] .task__num,
.task[data-done="1"] .task__time { color: var(--ink-600); }

.task__open {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 0;
  border: none;
  background: transparent;
  text-align: start;
  cursor: pointer;
}

.task__box {
  flex: 0 0 auto;
  padding: 0;
  cursor: pointer;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--box-border);
  background: transparent;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.task[data-done="1"] .task__box {
  background: var(--ink-500);
  border: 1px solid var(--ink-500);
}

.task__num {
  flex: 0 0 auto;
  width: 14px;
  text-align: center;
  font-family: var(--font-num);
  font-weight: var(--fw-bold);
  font-size: 12px;
  color: var(--num-ink);
}

.task__text {
  flex: 1;
  min-width: 0;
  font-family: var(--font-body);
  font-weight: var(--fw-semibold);
  font-size: 14px;
  line-height: 1.4;
  color: var(--task-ink);
  overflow-wrap: anywhere;
}
.task[data-done="1"] .task__text { text-decoration: line-through; }

/* ---- Per-task area reassignment ---- */

.task__areas {
  display: flex;
  gap: 5px;
  flex: 0 0 auto;
  align-items: center;
  padding-inline-start: 8px;
}

.task__area {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: var(--c);
  opacity: .4;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.task__area[aria-pressed="true"] {
  width: 15px;
  height: 15px;
  opacity: 1;
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--c);
}

/* ---- Task delete ----
   The ✕ at the row's end. Dragging needs no handle — any point on the
   row moves it (see makeTaskDraggable). */

.task__del {
  flex: 0 0 auto;
  width: 24px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--task-ink);
  opacity: .4;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.task__del:hover {
  opacity: 1;
  color: #fff;
  background: var(--danger);
}

.task--dragging { opacity: .35; }

.task--ghost {
  box-shadow: 0 18px 40px rgba(22, 36, 59, .35);
  transform: rotate(1.5deg);
  opacity: .95;
}

/* A tile ready to receive the dragged task */
.day--drop {
  outline: 3px solid var(--info);
  outline-offset: 2px;
  transform: scale(1.06);
}

/* The tasks box, ready to take a canvas card back into the list. */
.panel--catch .panel__main {
  outline: 3px solid var(--info);
  outline-offset: 2px;
}
/* Week boxes are big already — glow without the jump. */
.wday.day--drop { transform: none; }

/* ============================================================
   Week view — seven roomy boxes, tasks in miniature
   ============================================================ */

/* Three boxes to a row, then three, then the last one — each day gets
   the footprint of roughly four month tiles. */
.week-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.wday {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  aspect-ratio: 1.15 / 1;
  min-height: 210px;
  padding: 11px 12px 12px;
  /* The month tiles' proportional area bands, washed toward the paper so
     the miniature task text stays readable on top of them. */
  background:
    linear-gradient(color-mix(in srgb, var(--paper) 76%, transparent),
                    color-mix(in srgb, var(--paper) 76%, transparent)),
    var(--bg, var(--paper));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  text-align: start;
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.wday:hover { box-shadow: 0 6px 18px rgba(22, 36, 59, .16); }
.wday[data-empty="1"] { background: var(--paper); }
.wday[data-selected="1"] { border: 1.5px solid var(--accent); }
.wday[data-today="1"] .wday__num {
  background: var(--ink-900);
  color: var(--paper);
}

.wday__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 3px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border-subtle);
}
.wday__name {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 12px;
  color: var(--ink-700);
}
.wday__num {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  border-radius: 50%;
  font-family: var(--font-num);
  font-weight: var(--fw-bold);
  font-size: 12px;
  color: var(--ink-700);
}

.wday__task {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  font-family: var(--font-body);
  font-weight: var(--fw-medium);
  font-size: 11px;
  line-height: 1.35;
  color: var(--ink-800);
  min-width: 0;
}
.wday__task[data-done="1"] { opacity: .6; text-decoration: line-through; color: var(--ink-500); }
.wday__task[data-done="1"] .wday__dot { background: var(--ink-300); }
.wday__dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin-top: 3.5px;
  border-radius: 50%;
  background: var(--c, var(--ink-300));
}
.wday__text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  /* Miniature means a glance, not the whole essay. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wday__more,
.wday__empty {
  font-family: var(--font-body);
  font-size: 10.5px;
  color: var(--ink-500);
}
.wday__empty { margin-top: 4px; }

/* Narrow screens: two to a row instead of three. */
@media (max-width: 1000px) {
  .week-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wday { min-height: 170px; aspect-ratio: auto; }
}

/* ---- Sync footer ---- */

/* A button since the topbar pill went admin-only: this line is now the
   way into settings (sign-out, calendar, data) for everyone. */
.panel__sync {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  padding: 0 4px;
  border: none;
  background: transparent;
  text-align: start;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--ink-500);
}
.panel__sync:hover { color: var(--ink-700); }
.panel__sync:hover .panel__settings { text-decoration: underline; }

.panel__settings {
  margin-inline-start: auto;
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  color: var(--ink-400);
}

/* ============================================================
   Month grid
   ============================================================ */

/* Week number, then Monday…Sunday. Kept LTR so the week column lands on the
   left and the days run in reading order for a calendar, independent of the
   surrounding RTL page. */
.month-grid {
  display: grid;
  grid-template-columns: 30px repeat(7, 1fr);
  gap: clamp(6px, 1vw, 11px);
  align-items: center;
  direction: ltr;
  max-width: 740px;
}

.grid__head {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 11px;
  text-align: center;
  color: var(--ink-500);
  padding-bottom: 2px;
}

.grid__week {
  font-family: var(--font-num);
  font-weight: var(--fw-bold);
  font-size: 12px;
  text-align: center;
  color: var(--ink-400);
}

/* Days that belong to a neighbouring month: hold the column, show nothing. */
.day-pad { aspect-ratio: 1; }

.day {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--bg);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--c) 32%, transparent);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out);
}
.day:hover { transform: translateY(-2px); }

.day[data-selected="1"] {
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .92),
              0 6px 16px color-mix(in srgb, var(--c) 40%, transparent);
}
.day[data-today="1"] {
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .9),
              0 10px 24px color-mix(in srgb, var(--c) 50%, transparent);
}

.day__today {
  position: absolute;
  top: 6px;
  inset-inline-end: 8px;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 9px;
  color: #fff;
  opacity: .92;
}

.day__num {
  font-family: var(--font-num);
  font-weight: var(--fw-bold);
  font-size: clamp(17px, 2.1vw, 23px);
  line-height: 1;
  color: var(--num);
}
.day[data-ondark="1"] .day__num { text-shadow: 0 1px 2px rgba(0, 0, 0, .18); }

.day__dots {
  display: flex;
  gap: 3px;
  height: 5px;
  align-items: center;
}

.day__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--dot);
}

/* ============================================================
   Settings sheet
   ============================================================ */

.sheet {
  /* /var(--zoom): viewport units are not scaled by the zoom around them. */
  width: min(440px, calc((100vw - 32px) / var(--zoom)));
  max-height: calc((100dvh - 32px) / var(--zoom));
  padding: 22px 24px 26px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--paper);
  color: var(--ink-700);
  box-shadow: var(--shadow-xl);

  /* A dialog defaults to overflow:auto, and RTL subpixel rounding is enough
     to summon a horizontal scrollbar whose light UA track cuts across the
     sheet in night mode. Nothing here ever needs to scroll sideways. */
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-300) transparent;
}
.sheet::backdrop { background: rgba(10, 20, 32, .48); }

.sheet__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.sheet__title {
  margin: 0;
  margin-inline-end: auto;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 17px;
  letter-spacing: 0;
  color: var(--ink-900);
}

.sheet__close {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: var(--ink-50);
  color: var(--ink-600);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.sheet__close:hover { background: var(--ink-100); }

.sheet__heading {
  margin: 20px 0 8px;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 12px;
  letter-spacing: .02em;
  color: var(--ink-400);
}

.sheet__note {
  margin: 0 0 8px;
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-600);
  overflow-wrap: anywhere;
}
.sheet__note--bad { color: var(--danger); }

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

.theme-option {
  min-width: 0;
  padding: 11px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--paper);
  color: var(--ink-700);
  text-align: start;
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}
.theme-option:hover { background: var(--ink-50); }
.theme-option[aria-checked="true"] {
  border-color: var(--red-500);
  background: color-mix(in srgb, var(--red-500) 8%, var(--paper));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--red-500) 12%, transparent);
}

.theme-option__label {
  display: block;
  margin-bottom: 3px;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 13px;
  color: var(--ink-900);
}

.theme-option__note {
  display: block;
  font-family: var(--font-body);
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--ink-500);
}

@media (max-width: 420px) {
  .theme-options { grid-template-columns: 1fr; }
}

.sheet__row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}

.field {
  flex: 1 1 180px;
  min-width: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 13px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink-800);
  background: var(--paper);
}
.field:focus {
  outline: none;
  border-color: var(--red-500);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--red-500) 14%, transparent);
}

.btn {
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  background: var(--red-500);
  color: #fff;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 14px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.btn:hover:not(:disabled) { background: var(--red-600); }
.btn:disabled { opacity: .55; cursor: default; }

/* Links dressed as controls — the settings sheet's "لوحة المشرف" and
   the topbar's admin-only "داشبورد" pill. */
a.btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
a.pill { text-decoration: none; color: var(--ink-700); }

.pill__icon { width: 14px; height: 14px; flex: 0 0 auto; }

.btn--ghost {
  background: transparent;
  color: var(--ink-600);
  border-color: var(--border-subtle);
}
.btn--ghost:hover:not(:disabled) { background: var(--ink-50); color: var(--ink-800); }

/* ---- Standalone / notched phones ---- */

@media (display-mode: standalone) {
  .app { padding-top: max(clamp(16px, 3vw, 34px), env(safe-area-inset-top)); }
}
.app {
  padding-inline-start: max(clamp(14px, 3vw, 30px), env(safe-area-inset-left));
  padding-inline-end: max(clamp(14px, 3vw, 30px), env(safe-area-inset-right));
  padding-bottom: max(60px, env(safe-area-inset-bottom));
}

/* ---- Sign-in options ---- */

.btn--google {
  display: block;
  width: 100%;
  background: var(--ink-900);
  color: var(--paper);
}
.btn--google:hover:not(:disabled) { background: var(--ink-800); }
:root[data-theme="night"] .btn--google { background: var(--paper); color: var(--ink-900); }
:root[data-theme="night"] .btn--google:hover:not(:disabled) { background: var(--ink-800); }

/* "or" rule — a hairline either side of the label */
.sheet__or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 10px;
  font-family: var(--font-display);
  font-size: 11.5px;
  color: var(--ink-400);
}
.sheet__or::before,
.sheet__or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* ============================================================
   Sign-in gate
   ============================================================ */

.gate {
  min-height: calc(100dvh / var(--zoom));   /* see the zoom note above */
  display: grid;
  place-items: center;
  padding: 24px max(24px, env(safe-area-inset-left)) 24px max(24px, env(safe-area-inset-right));
  /* No background of its own — body already paints the page colour, and an
     opaque layer here would hide the ruled paper behind the sign-in card. */
}

.gate__card {
  width: min(400px, 100%);
  padding: 32px 28px 30px;
  text-align: center;
  background: var(--paper);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--card-shadow);
}

.gate__logo { height: 40px; width: auto; margin: 0 auto 18px; }

.gate__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 20px;
  letter-spacing: 0;
  color: var(--ink-900);
}

.gate__sub {
  margin: 6px 0 22px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink-500);
}

.gate__note {
  margin: 10px 0 0;
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-600);
  overflow-wrap: anywhere;
}
.gate__note--bad { color: var(--danger); font-weight: var(--fw-semibold); }

/* Stacked auth fields — email, password, then the one action. */
.gate__form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.gate__form .field { flex: 0 0 auto; }
.gate__form .btn { width: 100%; }

.gate__links {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 14px;
}
.gate__link {
  padding: 4px 2px;
  border: none;
  background: transparent;
  color: var(--info);
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: 12.5px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.gate__link:hover { color: var(--ink-800); }

/* ---- Empty day ---- */

.day[data-empty="1"] {
  /* Beats the inline --bg the renderer sets, so the theme wins here. */
  background: var(--empty-tile);
  border-color: var(--border-subtle);
}

/* An empty day drops its coloured glow, but today and the selected day keep
   their ring — this rule sits after those and would otherwise erase them. */
.day[data-empty="1"]:not([data-today="1"]):not([data-selected="1"]) {
  box-shadow: none;
}
.day[data-empty="1"] .day__num {
  color: var(--empty-ink);
  text-shadow: none;
}

/* ============================================================
   Task row additions
   ============================================================ */

.task {
  touch-action: pan-y;
  /* transform is driven by the swipe gesture, so hover must not touch it —
     a hover transform here fought the drag and made rows twitch. */
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.task:hover { box-shadow: 0 2px 10px color-mix(in srgb, var(--c) 24%, transparent); }
.task:hover .task__menu { opacity: .9; }

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

.task__time {
  font-family: var(--font-num);
  font-weight: var(--fw-semibold);
  font-size: 11.5px;
  color: var(--task-ink);
  opacity: .72;
}

.task__menu {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--task-ink);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  opacity: .5;
}
.task__menu:hover { opacity: 1; background: color-mix(in srgb, var(--c) 22%, transparent); }

  /* ============================================================
   Task editor sheet
   ============================================================ */

.sheet__label {
  display: block;
  margin: 14px 0 6px;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 11.5px;
  color: var(--ink-500);
}

.sheet__grid { display: flex; gap: 10px; }
.sheet__grid > div { flex: 1; min-width: 0; }

.sheet__actions { display: flex; gap: 8px; margin-top: 20px; }
.sheet__actions .btn { flex: 1; }
.sheet__actions--col { flex-direction: column; }

/* ---- Profile picture sheet ---------------------------------- */

.avatarmenu { display: flex; justify-content: center; margin-top: 16px; }
.avatarmenu__pic {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px var(--border-strong);
}

/* The crop frame: a circular window onto the photo; the image is
   positioned by app.js and anything past the circle is simply cut. */
.avatarcrop {
  position: relative;
  width: 240px;
  height: 240px;
  margin: 16px auto 14px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--ink-100);
  box-shadow: 0 0 0 2px var(--border-strong);
  touch-action: none;
  cursor: grab;
}
.avatarcrop:active { cursor: grabbing; }
.avatarcrop__img {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
.avatarcrop__zoom {
  display: block;
  width: 240px;
  margin: 0 auto;
  accent-color: var(--ink-700);
}
.avatarcrop__hint {
  margin: 10px 0 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-500);
}

.areapick { display: flex; flex-wrap: wrap; gap: 6px; }

.areapick__opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  background: transparent;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.areapick__opt::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--c);
}
.areapick__opt[aria-pressed="true"] {
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
}

.areapick__label {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: 12px;
  color: var(--ink-700);
}

.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover:not(:disabled) { background: var(--red-700); }

/* Saving is confirmation, not danger — so it doesn't share the red base. */
.btn--save { background: var(--success); }
.btn--save:hover:not(:disabled) { background: color-mix(in srgb, var(--success) 82%, #000); }

/* The task-title field in the editor: tall enough to read a long title
   whole. Enter still saves; the model keeps tasks single-line. */
.field--title {
  display: block;
  width: 100%;
  min-height: 96px;
  resize: none;
  line-height: 1.6;
  font-family: var(--font-body);
}

.field--notes {
  display: block;
  width: 100%;
  min-height: 88px;
  resize: vertical;
  line-height: 1.6;
  font-family: var(--font-body);
}

/* The editor a dropped task lands in: roomier, and it blooms open —
   a soft overshoot rather than the dialog's usual instant appearance. */
.sheet--wide { width: min(600px, calc((100vw - 32px) / var(--zoom))); }

@keyframes sheet-pop {
  from { transform: scale(.55); opacity: 0; }
  60%  { transform: scale(1.02); opacity: 1; }
  to   { transform: scale(1); opacity: 1; }
}
.sheet--pop { animation: sheet-pop .38s cubic-bezier(.22, 1, .36, 1); }

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

/* Escape hatch on the gate — small, always present, never the main action */
.gate__reset {
  display: block;
  margin: 18px auto 0;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink-400);
  font-family: var(--font-display);
  font-size: 11.5px;
  text-decoration: underline;
  cursor: pointer;
}
.gate__reset:hover { color: var(--ink-700); }

/* ============================================================
   Composer — the panel's primary action, so it leads and it's loud
   ============================================================ */

.composer {
  margin: 14px 0 0;
  padding: 12px 12px 12px;
  background: var(--paper);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
/* focus-within so the whole card lights up, not just the field inside it */
.composer:focus-within {
  border-color: var(--info);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--info) 15%, transparent);
}

.composer__input {
  width: 100%;
  min-height: 76px;          /* twice the old single-line field */
  resize: none;
  border: none;
  background: transparent;
  padding: 8px 6px;
  line-height: 1.5;
  font-family: var(--font-body);
  font-weight: var(--fw-medium);
  font-size: 16px;
  color: var(--ink-900);
}
.composer__input::placeholder { color: var(--ink-400); font-weight: var(--fw-regular); }
.composer__input:focus { outline: none; }

.composer__row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.composer__time {
  flex: 0 0 auto;
  width: 122px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 11px;
  background: var(--paper);
  font-family: var(--font-num);
  font-size: 13px;
  color: var(--ink-800);
}
.composer__time:focus { outline: none; border-color: var(--border-strong); }

.composer__add {
  flex: 1;
  border: none;
  border-radius: var(--radius-md);
  padding: 11px 18px;
  background: var(--info);
  color: #fff;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 15px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.composer__add:hover { background: #255c94; }

/* ---- Recurrence controls ---- */

.composer__row--repeat { align-items: center; }

.composer__repeat {
  flex: 0 1 auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 9px 10px;
  background: var(--paper);
  color: var(--ink-800);
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: 12.5px;
}
.composer__repeat:focus { outline: none; border-color: var(--border-strong); }

/* The project link select sits beside the recurrence one. */
.composer__project {
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer__untilwrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.composer__untillab {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--ink-500);
}
.composer__until {
  min-width: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 9px;
  background: var(--paper);
  font-family: var(--font-num);
  font-size: 12.5px;
  color: var(--ink-800);
}
.composer__until:focus { outline: none; border-color: var(--border-strong); }

.daypick {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}
.daypick__opt {
  padding: 5px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink-600);
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.daypick__opt[aria-pressed="true"] {
  border-color: var(--info);
  background: color-mix(in srgb, var(--info) 14%, transparent);
  color: var(--ink-800);
}

/* Series checkbox in the task editor */
.sheet__check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 0;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink-600);
  cursor: pointer;
}
.sheet__checkbox { accent-color: var(--success); }

/* The ↻ beside a recurring task's title */
.task__recur {
  font-family: var(--font-num);
  font-size: 11.5px;
  color: var(--task-ink);
  opacity: .6;
}

/* A linked project rides the row as a small chip in its colour. */
.task__proj {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 140px;
  padding: 1px 9px;
  border: 1px solid var(--box-border);
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  font-weight: var(--fw-semibold);
  color: var(--task-ink);
  opacity: .85;
  white-space: nowrap;
}
.task__proj i {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pc);
}
.task__proj span {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Day progress ---- */

.progress {
  height: 8px;
  margin: 0 0 12px;
  border-radius: var(--radius-pill);
  background: var(--ink-100);
  overflow: hidden;
}

.progress__fill {
  width: var(--pct);
  height: 100%;
  border-radius: inherit;
  /* --accent is the day's colour, set on .panel */
  background: var(--accent);
  transition: width var(--dur-base) var(--ease-out),
              background var(--dur-base) var(--ease-out);
}
.progress__fill[data-full="1"] { background: var(--success); }

/* ---- Composer area chips ---- */

.areapick--composer {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}
.areapick--composer .areapick__opt { padding: 5px 9px; }
.areapick--composer .areapick__label { font-size: 11px; }

/* ---- Confetti ---- */

.confetti {
  position: fixed;
  z-index: 90;
  pointer-events: none;
}
.confetti i {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--c);
}

/* ---- Floating sticky notes ----
   The layer is fixed and *unscaled*, so notes drag in real client pixels
   — the same trade the confetti layer makes. The content follows the
   interface scale through font-size calc() instead, and notes.js
   multiplies the default box by --zoom once at creation. */

.notes-layer {
  position: fixed;
  inset: 0;
  z-index: 70;              /* over the app; dialogs live in the top layer anyway */
  pointer-events: none;     /* only the notes themselves catch the pointer */
}

.note {
  position: absolute;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  background: var(--note-c, #FFF3A0);
  color: #16243B;
  border-radius: calc(4px * var(--zoom));
  /* A hair of paper curl: heavier shadow low and to one side. */
  box-shadow: 0 1px 3px rgba(22, 36, 59, .14), 0 12px 26px rgba(22, 36, 59, .22);
}
:root[data-theme="night"] .note {
  filter: brightness(.94) saturate(.92);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 14px 30px rgba(0, 0, 0, .55);
}

.note__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: calc(6px * var(--zoom)) calc(8px * var(--zoom)) 0;
  cursor: grab;
  touch-action: none;       /* the drag owns the gesture on touch */
  user-select: none;
  -webkit-user-select: none;
}
.note__bar:active { cursor: grabbing; }

.note__palette {
  display: flex;
  gap: calc(4px * var(--zoom));
}

.note__swatch {
  width: calc(13px * var(--zoom));
  height: calc(13px * var(--zoom));
  padding: 0;
  border: 1px solid rgba(22, 36, 59, .28);
  border-radius: 50%;
  background: var(--c);
  cursor: pointer;
}
.note__swatch[aria-pressed="true"] {
  border-color: rgba(22, 36, 59, .75);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .8);
}

.note__del {
  border: 0;
  padding: 2px 4px;
  background: transparent;
  color: rgba(22, 36, 59, .55);
  font-size: calc(12px * var(--zoom));
  line-height: 1;
  cursor: pointer;
}
.note__del:hover { color: #16243B; }

.note__text {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: calc(7px * var(--zoom)) calc(10px * var(--zoom)) calc(10px * var(--zoom));
  border: 0;
  background: transparent;
  resize: none;             /* resizing is the corner grip's job */
  outline: none;
  color: inherit;
  font-family: var(--font-body);
  font-size: calc(13.5px * var(--zoom));
  line-height: 1.55;
}
.note__text::placeholder { color: rgba(22, 36, 59, .4); }

.note__grip {
  position: absolute;
  bottom: 0;
  right: 0;                 /* the box is anchored by `left`, so it grows away from its pin */
  width: calc(18px * var(--zoom));
  height: calc(18px * var(--zoom));
  cursor: nwse-resize;
  touch-action: none;
  /* Two little ridges, like a window corner. */
  background:
    linear-gradient(135deg,
      transparent 0 52%,
      rgba(22, 36, 59, .35) 52% 58%, transparent 58% 70%,
      rgba(22, 36, 59, .35) 70% 76%, transparent 76%);
  border-radius: 0 0 calc(4px * var(--zoom)) 0;
}

/* Hiding is a menu switch now, so the notes need nothing on screen to get
   back from. */
.notes-layer--hidden .note { display: none; }

/* ============================================================
   Task lists & brain dump
   ------------------------------------------------------------
   The menu lists the lists; each opens a small panel whose items
   drag onto calendar days. The brain dump is the same panel, tuned
   for fast capture. The layer is unscaled like the notes layer; the
   panel re-applies --zoom itself.
   ============================================================ */

.lists-layer {
  position: fixed;
  inset: 0;
  z-index: 65;              /* under the notes, over the app */
  pointer-events: none;
}
.lists-layer > * { pointer-events: auto; }

/* The folder rides the left edge just below the notes dock. */

/* The fan: chips start folded into the button's centre and spring out
   to their spot on the arc (--tx/--ty, computed per chip in JS). */

/* Chips hang off their arc point by the leading edge, growing away from
   the screen edge — so even a long name never reaches back over the
   buttons. The spring curve gives the fan its bounce. */

/* A tap on a floating button answers with a quick dip-and-bounce. */
@keyframes fab-bounce {
  0%   { transform: scale(1); }
  35%  { transform: scale(.85); }
  70%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* ---- The list panel ---- */

.tlist-panel {
  position: fixed;
  zoom: var(--zoom);        /* offsets below are multiplied by it */
  left: 64px;
  top: calc(50vh / var(--zoom));
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  width: min(280px, calc(78vw / var(--zoom)));
  max-height: calc(72vh / var(--zoom));
  padding: 12px;
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  background: var(--card-bg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 16px 40px rgba(0, 0, 0, .14);
  z-index: 5;
  transform-origin: left center;       /* the pop grows out of the edge */
}

.tlist-panel__palette {
  display: flex;
  gap: 6px;
  margin: -2px 0 10px;
}
.tlist-panel__palette[hidden] { display: none; }

.tlist-panel__swatch {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(0, 0, 0, .12);
  border-radius: 50%;
  background: var(--c);
  cursor: pointer;
}
.tlist-panel__swatch[aria-pressed="true"] {
  outline: 2px solid var(--ink-700);
  outline-offset: 1px;
}

/* The brain dump docks above its own button instead of mid-screen. */
.tlist-panel--brain {
  top: auto;
  bottom: 74px;
  transform: none;
  transform-origin: left bottom;    /* grows out of its button */
}

/* Opening springs the panel out of its edge with a light bounce. The
   `scale` property animates on its own, so the side panel's translateY
   centring survives untouched. */
@keyframes tlist-pop {
  0%   { scale: .6; opacity: 0; }
  65%  { scale: 1.04; opacity: 1; }
  100% { scale: 1; opacity: 1; }
}
.tlist-panel--pop { animation: tlist-pop .45s cubic-bezier(.22, 1, .36, 1); }

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

/* ============================================================
   Colour dot
   ------------------------------------------------------------
   What replaced the coloured edges. Apple carries identity in a small
   filled circle set against the name — Reminders lists, Calendar
   calendars, Finder tags all do this — so the colour reads as a label
   on the thing rather than as decoration applied to its container.

   Deliberately small: at this size colour identifies without competing
   with the text it sits beside.
   ============================================================ */
.cdot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c, var(--sys-gray));
  /* A pure-white or near-black dot would vanish into the card, so every
     dot carries a faint rim of its own colour, darkened. */
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
}
.cdot--lg { width: 13px; height: 13px; }

.tlist-panel__bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.tlist-panel__name {
  flex: 1;
  min-width: 0;
  border: none;
  border-bottom: 1px dashed transparent;
  background: transparent;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 14px;
  color: var(--ink-900);
}
.tlist-panel__name:not(:read-only):hover,
.tlist-panel__name:not(:read-only):focus {
  outline: none;
  border-bottom-color: var(--border-strong);
}

.tlist-panel__del,
.tlist-panel__close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-400);
  font-size: 13px;
  cursor: pointer;
}
.tlist-panel__del:hover { background: var(--ink-50); color: var(--danger); }
.tlist-panel__close:hover { background: var(--ink-50); color: var(--ink-800); }

.tlist-panel__items {
  flex: 1;
  min-height: 34px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.tlist-panel__empty {
  margin: 8px 0;
  text-align: center;
  font-size: 12px;
  color: var(--ink-500);
}

.tlist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--ink-50);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.tlist-item--dragging { opacity: .35; }
.tlist-item--ghost {
  background: var(--paper);
  box-shadow: 0 14px 34px rgba(22, 36, 59, .3);
  cursor: grabbing;
}

.tlist-item__text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-800);
  overflow-wrap: anywhere;
}

.tlist-item__del {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-400);
  font-size: 11px;
  cursor: pointer;
}
.tlist-item__del:hover { background: var(--paper); color: var(--danger); }

.tlist-panel__composer input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink-900);
  font-family: var(--font-body);
  font-size: 13px;
}
.tlist-panel__composer input:focus {
  outline: none;
  border-color: var(--info);
}

.tlist-panel__hint {
  margin: 8px 2px 0;
  font-size: 10.5px;
  color: var(--ink-400);
}

/* ============================================================
   Focused day view
   ------------------------------------------------------------
   Double-click a day tile and the live day panel moves in here.
   ============================================================ */

.day-view {
  width: min(620px, calc((100vw - 36px) / var(--zoom)));
  max-height: calc((100dvh - 48px) / var(--zoom));
}
/* Scoped to [open] — an unconditional display would keep a closed dialog visible. */
.day-view[open] { display: flex; flex-direction: column; }

.day-view__bar { display: flex; align-items: center; gap: 10px; }
.day-view__bar .sheet__title { flex: 1; margin: 0; }

.day-view__btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: transparent;
  color: var(--ink-600);
  font-size: 15px;
  cursor: pointer;
}
.day-view__btn:hover { background: var(--ink-50); color: var(--ink-800); }
.day-view__btn[aria-pressed="true"] { background: var(--ink-100); color: var(--ink-900); }

.day-view__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 12px;
}

/* Inside the sheet the panel sheds its card chrome — the sheet is the
   card now — and the type gets more room to breathe. */
.day-view .panel { min-height: 0; }
.day-view .panel__main {
  border: none;
  box-shadow: none;
  border-radius: var(--radius-md);
  background: transparent;
  padding: 14px 4px 0;
}
.day-view .composer {
  background: var(--ink-50);
  border: 1.5px solid var(--border-subtle);
  box-shadow: none;
}
.day-view .panel__list { gap: 9px; }
.day-view .task { padding: 10px 12px; }
.day-view .task__text { font-size: 15px; line-height: 1.5; }

/* ---- The page's fixtures, along for the ride ----
   A modal dialog makes everything outside it inert, so app.js moves the
   sticky-notes layer and the background toggle inside while the view is
   open. The notes layer is normally unscaled (its maths run in real
   client pixels); inside the zoomed sheet it has to be divided back out. */
.day-view .notes-layer,
.day-view .lists-layer { zoom: calc(1 / var(--zoom)); }
.day-view__bar .avatar { width: 34px; height: 34px; }
.day-view__bar .avatar svg { width: 18px; height: 18px; }

/* Full screen: the sheet becomes the whole application for that day. */
.day-view--full {
  width: calc(100vw / var(--zoom));
  height: calc(100dvh / var(--zoom));
  max-width: none;
  max-height: none;
  margin: 0;
  border: none;
  border-radius: 0;
  background: var(--page-bg);
}

/* The same paper as the page behind it — squares or dots follow the
   body's data-bg. Pattern sizes divide the zoom back out so the ruling
   stays a true half-centimetre inside the scaled sheet. */
.day-view--full::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right,  var(--rule) 1px, transparent 1px),
    linear-gradient(to bottom, var(--rule) 1px, transparent 1px);
  background-size: calc(.8cm / var(--zoom)) calc(.8cm / var(--zoom));
  -webkit-mask-image: radial-gradient(ellipse 76% 72% at 50% 42%, #000 30%, transparent 100%);
          mask-image: radial-gradient(ellipse 76% 72% at 50% 42%, #000 30%, transparent 100%);
}
body[data-bg="dots"] .day-view--full::before {
  inset: -30%;
  background-image:
    radial-gradient(circle, var(--rule) 1.6px, transparent 1.9px),
    radial-gradient(circle, var(--rule) 1.2px, transparent 1.5px);
  background-size: calc(.8cm / var(--zoom)) calc(.8cm / var(--zoom)),
                   calc(1.13cm / var(--zoom)) calc(1.13cm / var(--zoom));
  background-position: 0 0, calc(.4cm / var(--zoom)) calc(.55cm / var(--zoom));
  animation: dots-wave var(--wave-dur, 75s) ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  body[data-bg="dots"] .day-view--full::before { animation: none; }
}
.day-view--full .day-view__bar,
.day-view--full .day-view__body { position: relative; z-index: 1; }

.day-view--full .day-view__body {
  max-width: 496px;
  width: 100%;
  margin-inline: auto;
  margin-top: 26px;   /* a breath between the bar and the cards */
}

/* The boxes can hug the right edge instead of the centre — a bar toggle,
   only meaningful in fullscreen where there's space to differ. */
/* Flush right still breathes: the inset roughly lines the cards' start
   up with where the bar's title ends, past the avatar. */
.day-view--full.day-view--right .day-view__body { margin-inline: 150px auto; }

/* ---- The day canvas: tasks pinned to open ground ---- */

/* The layer spans the dialog; only the cards catch the pointer. */
.day-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.day-view:not(.day-view--full) .day-canvas { display: none; }

/* Small form: the task exactly as it read in the list — the same tint,
   border and type its row wore (--c/--tint/--task-ink come from JS). */
.dcard {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 240px;
  padding: 10px 12px;      /* the row's own padding in the day view */
  border: 1px solid color-mix(in srgb, var(--c, transparent) 35%, transparent);
  border-radius: var(--radius-md);
  background: var(--tint, var(--paper));
  box-shadow: var(--card-shadow);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: auto;
  transition: box-shadow var(--dur-base) var(--ease-out);
}
.dcard--moving { box-shadow: 0 16px 38px rgba(22, 36, 59, .3); cursor: grabbing; }

/* Shrinking snaps back with a light bounce — scale only, position holds. */
@keyframes dcard-pop {
  0%   { scale: .8; }
  65%  { scale: 1.05; }
  100% { scale: 1; }
}
.dcard--pop { animation: dcard-pop .4s cubic-bezier(.22, 1, .36, 1); }

/* Growing unrolls downward like a curtain: the top edge holds still and
   the body is revealed beneath it. */
@keyframes dcard-curtain {
  0%   { clip-path: inset(0 0 calc(100% - 46px) 0 round var(--radius-md)); }
  100% { clip-path: inset(0 0 0 0 round var(--radius-md)); }
}
.dcard--curtain { animation: dcard-curtain .45s cubic-bezier(.22, 1, .36, 1); }

@media (prefers-reduced-motion: reduce) {
  .dcard--pop, .dcard--curtain { animation: none; }
  .dcard { transition: none; }
}

/* The row's checkmark circle, read-only here — completion is toggled
   from the grown card. */
.dcard__box {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 2px solid var(--box-border, var(--border-strong));
  border-radius: 50%;
  font-size: 11px;
  color: var(--task-ink, var(--ink-800));
}

.dcard__dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--c, var(--ink-300));
}

.dcard__text {
  flex: 1;
  min-width: 0;
  font-family: var(--font-body);
  font-weight: var(--fw-semibold);
  font-size: 15px;         /* matches .day-view .task__text */
  line-height: 1.5;
  color: var(--task-ink, var(--ink-800));
  overflow-wrap: anywhere;
}
.dcard__text--done { text-decoration: line-through; opacity: .65; }

.dcard__time {
  flex: 0 0 auto;
  font-family: var(--font-num);
  font-weight: var(--fw-semibold);
  font-size: 11.5px;
  color: var(--task-ink, var(--ink-500));
  opacity: .72;
}

/* Grown form: an in-place editor, nothing modal about it. It keeps its
   area's tint; width comes inline from JS (never below the small form's). */
.dcard--big {
  display: block;
  cursor: default;
  user-select: auto;
  -webkit-user-select: auto;
}

.dcard__bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  cursor: grab;               /* the bar is the big card's handle */
}
.dcard__bar .dcard__dot { margin-inline-end: auto; }

.dcard__btn {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--task-ink, var(--ink-400));
  opacity: .7;
  font-size: 13px;
  cursor: pointer;
}
.dcard__btn:hover { opacity: 1; background: rgba(0, 0, 0, .07); }

.dcard__field {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--ink-50);
  color: var(--ink-900);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
}
.dcard__field:focus { outline: none; border-color: var(--info); background: var(--paper); }

.dcard__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dcard__check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--task-ink, var(--ink-700));
  cursor: pointer;
}

.dcard__timein {
  padding: 5px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink-800);
  font-family: var(--font-num);
  font-size: 12px;
}
.day-view__btn--align { display: none; }
.day-view--full .day-view__btn--align { display: grid; }
.day-view__btn--align svg { width: 16px; height: 16px; }

/* In fullscreen the sheet turns into the page (paper + ruling), so the
   content takes card chrome back — as two separate sheets: the day with
   its tasks, then a clear gap, then the composer. Each card hugs its own
   content; neither one's size depends on the other's. */
.day-view--full .panel {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  margin-bottom: 16px;
}
.day-view--full .panel__main {
  border: 2.25px solid transparent;
  background:
    linear-gradient(var(--paper), var(--paper)) padding-box,
    var(--accent-bg, linear-gradient(var(--accent), var(--accent))) border-box;
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  padding: clamp(14px, 2vw, 18px);
  padding-top: 34px;    /* room for the punched holes */
}
.day-view--full .composer {
  margin: 16px 0 0;
  background: var(--paper);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--card-shadow);
}
.day-view--full .panel__sync { border-top: none; padding-top: 8px; }

/* With room to spare, the page splits in two: the tasks own the right
   column whole; the composer, the habits and the sync line stack in
   the left one. The panel wrapper dissolves (display: contents) so
   its children can sit in the grid directly. */
@media (min-width: 960px) {
  .day-view--full .day-view__body {
    max-width: 940px;
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    /* The tasks span all three rows; the open 1fr tail soaks up their
       extra height so the habits stay snug under the composer. */
    grid-template-rows: auto auto 1fr;
    column-gap: 18px;
    align-items: start;
  }
  .day-view--full .panel { display: contents; }
  .day-view--full .panel__main { grid-column: 1; grid-row: 1 / span 3; }
  .day-view--full .composer { grid-column: 2; grid-row: 1; margin: 0; }
  .day-view--full .hb-w--day { grid-column: 2; grid-row: 2; margin-top: 16px; }
  .day-view--full .panel__sync { grid-column: 2; grid-row: 3; }
}

/* ============================================================
   Statistics dashboard
   ------------------------------------------------------------
   A fullscreen page of KPI cards and hand-drawn SVG charts
   (see stats.js). Everything rides the theme tokens, so night
   mode needs no special casing beyond the track colour.
   ============================================================ */

/* Size, radius and padding come from .pm-view now — this keeps only what
   is actually about statistics. Leaving the old full-screen box here would
   have quietly overridden the panel it is supposed to be. */
.stats-view { --stats-track: var(--ink-100); }

.stats-view__bar {
  position: sticky;
  top: -4px;
  z-index: 2;
  padding: 4px 0 8px;
  background: var(--page-bg);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 1080px;
  margin: 0 auto 18px;
}
.stats-view__bar .sheet__title { flex: 1; margin: 0; }

/* The range filter: one pill, four chips, the active one on paper. */
.stats-range {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--ink-50);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
}

.stats-range__btn {
  border: none;
  background: transparent;
  padding: 5px 14px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: 12px;
  color: var(--ink-600);
  cursor: pointer;
}
.stats-range__btn:hover { color: var(--ink-900); }
.stats-range__btn[aria-pressed="true"] {
  background: var(--paper);
  color: var(--ink-900);
  box-shadow: 0 1px 3px rgba(22, 36, 59, .14);
}

.stats-body {
  max-width: 1080px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stats-empty {
  padding: 80px 0;
  text-align: center;
  font-size: 14px;
  color: var(--ink-500);
}

/* The counted window, spelled out under the bar. */
.stats-span {
  margin: -6px 2px 0;
  font-size: 11.5px;
  font-weight: var(--fw-semibold);
  color: var(--ink-400);
}

/* ---- KPI cards ---- */

.stats-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.kpi {
  background: var(--paper);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  padding: 14px 16px 12px;
  min-width: 0;
}

.kpi__value {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 27px;
  line-height: 1.15;
  color: var(--ink-900);
}

.kpi__unit {
  margin-inline-start: 5px;
  font-family: var(--font-body);
  font-weight: var(--fw-semibold);
  font-size: 12px;
  color: var(--ink-400);
}

.kpi__label {
  margin-top: 4px;
  font-family: var(--font-body);
  font-weight: var(--fw-semibold);
  font-size: 11.5px;
  color: var(--ink-500);
}

/* Textual superlatives (best day, top area) read at title size. */
.kpi--text .kpi__value {
  font-family: var(--font-display);
  font-size: 15.5px;
  line-height: 1.4;
  padding-top: 6px;
}

/* ---- Chart cards ---- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.stats-card--wide { grid-column: 1 / -1; }

@media (max-width: 880px) {
  .stats-grid { grid-template-columns: 1fr; }
}

.stats-card {
  background: var(--paper);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  padding: 16px 18px 14px;
  min-width: 0;
}

.stats-card__title {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 13.5px;
  color: var(--ink-800);
}

/* ---- Shared SVG bits ---- */

.chart { display: block; width: 100%; height: auto; }
.chart-ltr { direction: ltr; }   /* time flows oldest → newest regardless of UI language */

.chart text {
  font-family: var(--font-num);
  font-size: 10px;
  fill: var(--ink-500);
}
.chart .chart__label { font-size: 9.5px; fill: var(--ink-400); font-family: var(--font-body); font-weight: var(--fw-semibold); }
.chart .chart__value { font-size: 10px; fill: var(--ink-500); }
.chart .chart__big { font-size: 36px; font-weight: 700; fill: var(--ink-900); }
.chart .chart__sub { font-size: 11px; fill: var(--ink-500); font-family: var(--font-body); }

.chart .chart__grid { stroke: var(--border-subtle); stroke-dasharray: 3 5; }
.chart .chart__axis { stroke: var(--border-strong); }
.chart .chart__bar-track { fill: var(--stats-track); }
.chart .chart__line-muted {
  stroke: var(--ink-300);
  stroke-width: 1.6;
  stroke-dasharray: 4 6;
  stroke-linecap: round;
}

.chart-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 8px;
  font-size: 11px;
  font-weight: var(--fw-semibold);
  color: var(--ink-500);
}
.chart-legend__item { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend__item i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--ink-300);
}

/* ---- Donut ---- */

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.donut-wrap .chart--donut { width: 185px; flex: 0 0 auto; margin-inline: auto; }

.donut-legend {
  flex: 1 1 190px;
  min-width: 170px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.donut-legend__row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: var(--fw-semibold);
  color: var(--ink-700);
}
.donut-legend__dot { width: 11px; height: 11px; border-radius: 4px; flex: 0 0 auto; }
.donut-legend__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend__count { font-family: var(--font-num); color: var(--ink-900); }
.donut-legend__pct { font-family: var(--font-num); font-size: 11px; color: var(--ink-400); width: 40px; text-align: end; }

/* ---- Completion per area ---- */

.arate { display: flex; flex-direction: column; gap: 13px; }
.arate__row {
  display: grid;
  grid-template-columns: minmax(96px, auto) 1fr auto;
  align-items: center;
  gap: 10px;
}
.arate__name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: var(--fw-semibold);
  color: var(--ink-700);
  min-width: 0;
}
.arate__dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.arate__track {
  height: 10px;
  border-radius: 999px;
  background: var(--stats-track);
  overflow: hidden;
}
.arate__fill { height: 100%; border-radius: 999px; transition: width var(--dur-base) var(--ease-out); }
.arate__num { font-family: var(--font-num); font-size: 11px; color: var(--ink-500); }

/* ---- Year heatmap ---- */

.heatmap-scroll {
  direction: ltr;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-300) transparent;
}
.heatmap-scroll .chart--heat { width: auto; }

.chart--heat .hm0 { fill: var(--stats-track); }
.chart--heat .hm1 { fill: #BCE3CE; }
.chart--heat .hm2 { fill: #7CC9A4; }
.chart--heat .hm3 { fill: #3CAB79; }
.chart--heat .hm4 { fill: #187A4B; }
.chart--heat .hm-future { fill: var(--stats-track); opacity: .45; }

.heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 8px;
  font-size: 10.5px;
  color: var(--ink-400);
}
.heatmap-legend span { margin-inline: 4px; }

/* The opener rides in the month stepper. */
.monthnav__btn--stats svg { width: 15px; height: 15px; }

/* ============================================================
   Projects — overview cards + kanban boards
   ============================================================ */

/* The briefcase joins the left-edge column, just under the folder. */
.pm-fab {
  position: absolute;
  left: 14px;
  top: calc(50% + 115px * var(--zoom));
}

/* -- The fullscreen page (same shell as the stats view) -- */

/* A floating panel by default, not the whole screen. Opening a page to
   glance at it should not feel like leaving where you were — the page
   underneath stays visible, and a click past the edge brings it back. */
.pm-view {
  width: min(1120px, calc((100vw - 76px) / var(--zoom)));
  height: min(840px, calc((100dvh - 76px) / var(--zoom)));
  max-width: none;
  max-height: none;
  margin: auto;
  border: 1px solid var(--card-border);
  border-radius: calc(20px * var(--zoom));
  background: var(--page-bg);
  padding: 20px clamp(16px, 3vw, 34px) 28px;
  overflow: auto;
  overscroll-behavior: contain;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .10), 0 32px 80px rgba(0, 0, 0, .28);
  /* The size animates when the fullscreen button is pressed, so the panel
     grows into the screen instead of being replaced by a bigger one. */
  transition:
    width var(--dur-soft) var(--ease-emph),
    height var(--dur-soft) var(--ease-emph),
    border-radius var(--dur-soft) var(--ease-emph),
    opacity var(--dur-snap) var(--ease-soft),
    transform var(--dur-snap) var(--ease-emph),
    overlay var(--dur-snap) allow-discrete,
    display var(--dur-snap) allow-discrete;
}

.pm-view--full {
  width: calc(100vw / var(--zoom));
  height: calc(100dvh / var(--zoom));
  border-radius: 0;
  border-color: transparent;
  padding: 24px clamp(16px, 4vw, 44px) 56px;
}

/* On a phone there is no "over the page" to speak of — the panel is the
   screen either way, so it takes it and keeps only its top corners. */
@media (max-width: 640px) {
  .pm-view {
    width: calc(100vw / var(--zoom));
    height: calc((100dvh - 34px) / var(--zoom));
    margin: auto auto 0;
    border-radius: calc(22px * var(--zoom)) calc(22px * var(--zoom)) 0 0;
  }
}

.pm-expand {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: var(--ink-50);
  color: var(--ink-500);
  cursor: pointer;
  transition: background var(--dur-quick) var(--ease-soft),
              color var(--dur-quick) var(--ease-soft);
}
.pm-expand:hover { background: var(--ink-100); color: var(--ink-800); }
.pm-expand svg { width: 16px; height: 16px; }

.pm-view__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1120px;
  margin: 0 auto 18px;
  /* The panel scrolls inside itself now, so the title and the two buttons
     ride along instead of scrolling away from the content they act on. */
  position: sticky;
  top: calc(-4px);
  z-index: 2;
  padding: 4px 0 8px;
  background: var(--page-bg);
}
.pm-view__bar .sheet__title { flex: 1; margin: 0; }

.pm-back {
  border: 1px solid var(--border-subtle);
  background: var(--paper);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: 12.5px;
  color: var(--ink-600);
  cursor: pointer;
}
.pm-back:hover { color: var(--ink-800); border-color: var(--ink-300); }

.pm-body {
  max-width: 1120px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* -- Overview: header row, filter pills, the project grid -- */

.pm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pm-filter {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--ink-50);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
}
.pm-filter__btn {
  border: none;
  background: transparent;
  padding: 5px 13px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: 12px;
  color: var(--ink-600);
  cursor: pointer;
}
.pm-filter__btn--on {
  background: var(--paper);
  color: var(--ink-800);
  box-shadow: 0 1px 4px rgba(22, 36, 59, .18);
}

.pm-new {
  border: none;
  background: #1F9D63;
  color: #fff;
  border-radius: var(--radius-pill);
  padding: 8px 18px;
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(31, 157, 99, .35);
  transition: transform var(--dur-fast) var(--ease-out);
}
.pm-new:hover { transform: translateY(-1px); }

.pm-empty {
  padding: 80px 0;
  text-align: center;
  font-size: 14px;
  color: var(--ink-500);
}

.pm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

/* The project's colour used to be a 4px slab across the top of the card.
   Apple never spends an edge on identity — colour arrives as a small filled
   dot beside the name, the way a list does in Reminders. The card itself
   stays a neutral surface. */
.pm-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.pm-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow-hover);
}
/* Nothing for a shadow to fall on in the dark, so the lift is carried by
   the surface getting lighter — the way elevation works in dark mode. */
:root[data-theme="night"] .pm-card:hover { background: #2C2C2E; }

.pm-card__head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pm-card__name {
  flex: 1;
  margin: 0;
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: var(--fw-bold);
  color: var(--ink-800);
}
.pm-card__desc {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-500);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pm-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 11.5px;
  font-weight: var(--fw-semibold);
  color: var(--ink-400);
}

.pm-status {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: var(--fw-semibold);
  color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
  white-space: nowrap;
}

.pm-due--late { color: #E24444; }
.pm-flag { color: #E24444; }

.pm-progress {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pm-progress__track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--ink-100);
  overflow: hidden;
}
.pm-progress__track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  transition: width var(--dur-base) var(--ease-out);
}
.pm-progress__num {
  font-size: 11px;
  font-weight: var(--fw-bold);
  color: var(--ink-500);
  min-width: 32px;
  text-align: end;
}

/* -- Board: the project header card -- */

.pm-meta {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pm-meta__row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pm-meta__name {
  flex: 1;
  min-width: 200px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: var(--fw-bold);
  color: var(--ink-800);
  padding: 2px 0;
}
.pm-meta__name:focus {
  outline: none;
  border-bottom-color: var(--pc);
}

.pm-meta__del {
  margin-inline-start: auto;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 9px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: var(--fw-semibold);
  color: var(--ink-400);
  cursor: pointer;
}
.pm-meta__del:hover {
  color: #E24444;
  border-color: color-mix(in srgb, #E24444 40%, transparent);
  background: color-mix(in srgb, #E24444 8%, transparent);
}

.pm-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  font-weight: var(--fw-semibold);
  color: var(--ink-400);
}

.pm-select,
.pm-date {
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink-700);
  font: inherit;
  font-size: 12.5px;
  padding: 6px 9px;
}
.pm-select:focus,
.pm-date:focus { outline: none; border-color: var(--info); }

.pm-palette {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-inline-start: auto;
  align-self: flex-end;
  padding-bottom: 4px;
}
.pm-palette__dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--c);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out);
}
.pm-palette__dot:hover { transform: scale(1.18); }
.pm-palette__dot[aria-pressed="true"] {
  border-color: var(--paper);
  box-shadow: 0 0 0 2px var(--c);
}

.pm-meta__desc {
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--ink-50);
  color: var(--ink-700);
  font: inherit;
  font-size: 13px;
  line-height: 1.55;
  padding: 8px 11px;
  resize: vertical;
}
.pm-meta__desc:focus { outline: none; border-color: var(--info); }

/* -- Board: columns -- */

.pm-board {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-300) transparent;
}

/* A column is a well, not a card: it holds cards, so it sits *below* the
   page rather than above it — no shadow, no tint of the column's colour
   washed across the whole surface. The colour is a dot in the header. */
.pm-col {
  flex: 0 0 272px;
  background: var(--card-well);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.pm-col--drop {
  border-color: var(--info);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--info) 35%, transparent);
}

.pm-col__head {
  display: flex;
  align-items: center;
  gap: 7px;
}
.pm-col__name {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: var(--fw-bold);
  color: var(--ink-700);
  padding: 2px 4px;
  border-radius: 6px;
}
.pm-col__name:focus { outline: none; background: var(--paper); }
.pm-col__count {
  font-size: 11px;
  font-weight: var(--fw-bold);
  color: var(--cc, var(--ink-400));
  background: var(--paper);
  border: 1px solid color-mix(in srgb, var(--cc, var(--border-subtle)) 45%, transparent);
  border-radius: 999px;
  padding: 1px 8px;
}
.pm-col__del {
  border: none;
  background: transparent;
  color: var(--ink-300);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
}
.pm-col__del:hover { color: #E24444; }

.pm-col__cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 10px;
  max-height: 52vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-300) transparent;
}

.pm-col__composer input {
  width: 100%;
  border: 1px dashed var(--ink-300);
  border-radius: 10px;
  background: transparent;
  color: var(--ink-700);
  font: inherit;
  font-size: 12.5px;
  padding: 8px 11px;
}
.pm-col__composer input:focus {
  outline: none;
  border-style: solid;
  border-color: var(--info);
  background: var(--paper);
}

.pm-addcol {
  flex: 0 0 170px;
  border: 1.5px dashed var(--ink-300);
  border-radius: 14px;
  background: transparent;
  color: var(--ink-500);
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: 13px;
  padding: 16px 10px;
  cursor: pointer;
}
.pm-addcol:hover { color: var(--ink-700); border-color: var(--ink-400); }

/* -- Cards on the board -- */

.pm-task {
  background: var(--paper);
  border: 1px solid var(--border-subtle);
  border-inline-start: 3px solid var(--prio, transparent);
  border-radius: 11px;
  padding: 9px 11px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}
.pm-task--dragging { opacity: .35; }
.pm-task--ghost {
  box-shadow: 0 14px 30px rgba(22, 36, 59, .3);
  transform: rotate(-1.2deg);
  cursor: grabbing;
}

.pm-task__top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.pm-task__check {
  position: relative;
  flex: none;
  width: 20px;
  height: 20px;
  border: 1.6px solid var(--ink-300);
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font-size: 11px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
/* The circle is small on screen — its touchable footprint is not. */
.pm-task__check::after {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
}
.pm-task__check:hover {
  border-color: #1F9D63;
  background: color-mix(in srgb, #1F9D63 14%, transparent);
}
.pm-task__check[aria-pressed="true"] {
  background: #1F9D63;
  border-color: #1F9D63;
}

.pm-task__text {
  flex: 1;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink-800);
  word-break: break-word;
}
.pm-task--done .pm-task__text {
  color: var(--ink-400);
  text-decoration: line-through;
}

.pm-task__del {
  flex: none;
  border: none;
  background: transparent;
  color: var(--ink-300);
  font-size: 11px;
  cursor: pointer;
  padding: 2px;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.pm-task:hover .pm-task__del,
.pm-task--open .pm-task__del { opacity: 1; }
.pm-task__del:hover { color: #E24444; }

.pm-task__meta {
  display: flex;
  gap: 10px;
  margin-top: 4px;
  padding-inline-start: 26px;
  font-size: 11px;
  font-weight: var(--fw-semibold);
  color: var(--ink-400);
}

/* -- The unfolded card editor -- */

.pm-task__editor {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px dashed var(--ink-200, var(--border-subtle));
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: auto;
  user-select: text;
  -webkit-user-select: text;
}

.pm-task__field {
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  background: var(--ink-50);
  color: var(--ink-700);
  font: inherit;
  font-size: 12.5px;
  line-height: 1.5;
  padding: 7px 9px;
  resize: vertical;
}
.pm-task__field:focus { outline: none; border-color: var(--info); }

.pm-task__row {
  display: flex;
  gap: 10px;
}
.pm-task__row .pm-field { flex: 1; }
.pm-task__row .pm-select,
.pm-task__row .pm-date { width: 100%; }

.pm-task__send {
  align-self: flex-start;
  border: 1px solid var(--border-subtle);
  background: var(--paper);
  border-radius: var(--radius-pill);
  padding: 6px 13px;
  font-size: 12px;
  font-weight: var(--fw-semibold);
  color: var(--ink-600);
  cursor: pointer;
}
.pm-task__send:hover { border-color: var(--info); color: var(--info); }

/* ============================================================
   Habits — streaks and a two-week strip per practice
   ============================================================ */

/* The loop button, one slot under the briefcase. */
.hb-fab {
  position: absolute;
  left: 14px;
  top: calc(50% + 169px * var(--zoom));
}

.hb-body { max-width: 780px; }

.hb-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hb-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 12px 16px;
}

/* Today's tick: one big, generous circle. */
.hb-today {
  position: relative;
  flex: none;
  width: 46px;
  height: 46px;
  border: 2px solid var(--hc);
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.hb-today::after {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 50%;
}
.hb-today:hover { background: color-mix(in srgb, var(--hc) 16%, transparent); }
.hb-today[aria-pressed="true"] {
  background: var(--hc);
  transform: scale(1.04);
}

.hb-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hb-title {
  display: flex;
  align-items: center;
  gap: 9px;
}
.hb-dot {
  flex: none;
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: var(--hc);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out);
}
.hb-dot:hover { transform: scale(1.25); }
.hb-name {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: var(--fw-bold);
  color: var(--ink-800);
  padding: 2px 4px;
  border-radius: 6px;
}
.hb-name:focus { outline: none; background: var(--ink-50); }
.hb-del {
  flex: none;
  border: none;
  background: transparent;
  color: var(--ink-300);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
}
.hb-del:hover { color: #E24444; }

.hb-under {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* The record: fourteen tappable days, today ringed. */
.hb-strip {
  display: flex;
  gap: 5px;
}
.hb-cell {
  width: 17px;
  height: 17px;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  background: var(--ink-50);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.hb-cell:hover { border-color: var(--hc); }
.hb-cell[aria-pressed="true"] {
  background: var(--hc);
  border-color: var(--hc);
}
.hb-cell--today { box-shadow: 0 0 0 2px color-mix(in srgb, var(--hc) 55%, transparent); }

.hb-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-inline-start: auto;
  font-size: 11.5px;
  font-weight: var(--fw-semibold);
  color: var(--ink-400);
  white-space: nowrap;
}
.hb-stat--streak {
  font-size: 13px;
  font-weight: var(--fw-bold);
  color: #F2762E;
}

.hb-composer { margin-top: 16px; }
.hb-composer__input {
  width: 100%;
  border: 1.5px dashed var(--ink-300);
  border-radius: 12px;
  background: transparent;
  color: var(--ink-700);
  font: inherit;
  font-size: 13.5px;
  padding: 12px 15px;
}
.hb-composer__input:focus {
  outline: none;
  border-style: solid;
  border-color: var(--info);
  background: var(--paper);
}

/* ============================================================
   Areas — a page of the life areas themselves
   ------------------------------------------------------------
   One card per area (see areas.js): the colour and name edited
   in place, the linked projects as chips, and the calendar
   tasks filed under it. Same fullscreen shell as the projects.
   ============================================================ */

.ar-fab {
  position: absolute;
  left: 14px;
  top: calc(50% + 223px * var(--zoom));
}

.ar-body {
  max-width: 1080px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
@media (max-width: 860px) {
  .ar-body { grid-template-columns: minmax(0, 1fr); }
}
.ar-composer,
.ar-empty--page { grid-column: 1 / -1; }

.ar-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ar-head { display: flex; align-items: center; gap: 10px; }

.ar-color {
  width: 32px;
  height: 32px;
  flex: none;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  background: none;
  cursor: pointer;
}
.ar-color::-webkit-color-swatch-wrapper { padding: 3px; }
.ar-color::-webkit-color-swatch { border: none; border-radius: 50%; }

.ar-name {
  flex: 1;
  min-width: 0;
  border: none;
  border-bottom: 2px dashed transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 17px;
  font-weight: var(--fw-bold);
  padding: 3px 2px;
}
.ar-name:hover { border-bottom-color: var(--border-subtle); }
.ar-name:focus { outline: none; border-bottom-color: var(--info); }

.ar-counts { font-size: 12px; color: var(--ink-500); white-space: nowrap; }

.ar-del {
  border: none;
  background: transparent;
  color: var(--ink-400);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 7px;
  border-radius: 8px;
}
.ar-del:hover { color: #E24444; }

.ar-sec { display: flex; flex-direction: column; gap: 8px; }
.ar-sec__title {
  margin: 0;
  font-size: 12px;
  font-weight: var(--fw-bold);
  color: var(--ink-500);
}

.ar-projs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.ar-proj {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
  background: color-mix(in srgb, var(--c) 10%, var(--paper));
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
  font-size: 13px;
  color: inherit;
}
.ar-proj:hover { border-color: var(--c); }
.ar-proj__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.ar-proj__name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-proj__unlink { color: var(--ink-400); font-size: 11px; padding: 0 2px; }
.ar-proj__unlink:hover { color: #E24444; }

.ar-link {
  border: 1px dashed var(--border-subtle);
  background: transparent;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12.5px;
  color: var(--ink-500);
  cursor: pointer;
  max-width: 210px;
}

.ar-tasks {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 232px;
  overflow: auto;
  padding-inline-end: 4px;
}

.ar-task {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 13.5px;
  padding: 6px 9px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--c) 7%, var(--paper));
}
.ar-task--done { opacity: .55; }
.ar-task--done .ar-task__text { text-decoration: line-through; }
.ar-task__date {
  flex: none;
  min-width: 52px;
  font-family: var(--font-num);
  font-size: 11.5px;
  color: var(--ink-500);
}
.ar-task__text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ar-task__at { font-family: var(--font-num); font-size: 11px; color: var(--ink-500); }

.ar-more { margin: 2px 0 0; font-size: 12px; color: var(--ink-500); }
.ar-empty { font-size: 12.5px; color: var(--ink-400); }
.ar-empty--page { text-align: center; margin: 30px 0 0; }

.ar-composer__input {
  width: 100%;
  border: 1px dashed var(--border-subtle);
  border-radius: 12px;
  padding: 10px 14px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 14px;
}
.ar-composer__input:focus { outline: none; border-color: var(--info); background: var(--paper); }

/* The area chip on a project card and next to the board title. */
.pm-area {
  flex: none;
  font-size: 11px;
  font-weight: var(--fw-bold);
  color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}

/* ============================================================
   Pomodoro — a timer above the background toggle
   ============================================================ */

/* Bottom-left, shoulder to shoulder with the brain-dump button. The
   brain sits at a fixed 14px inset with a 42px·zoom body, while this
   layer is itself zoomed — so the offsets divide the fixed parts back
   out to land at real 14 + (42 + 14)·zoom, matched at every scale. */
.pomo-layer {
  position: fixed;
  left: calc(14px / var(--zoom));
  bottom: calc(18px / var(--zoom));
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  zoom: var(--zoom);
}

/* The layer rides inside whichever fullscreen page is open (see
   pomodoro.js) — those sheets are already zoomed, so the layer must
   not scale a second time on top of them. */
.sheet .pomo-layer { zoom: 1; }

.pomo-fab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 42px;
  height: 42px;
  padding: 0 10px;
  border: 1px solid var(--card-border);
  /* A square-ish 14px like the menu button and the brain dump; it stretches
     to a pill on its own once a countdown is sitting inside it. */
  border-radius: 14px;
  background: var(--card-bg);
  color: var(--ink-600);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .08), 0 8px 24px rgba(0, 0, 0, .12);
  transition: transform var(--dur-quick) var(--ease-back),
              border-radius var(--dur-snap) var(--ease-emph),
              color var(--dur-quick) var(--ease-out);
}
.pomo-layer--running .pomo-fab { border-radius: 999px; }
.pomo-fab:hover { transform: scale(1.07); }
.pomo-fab:active { transform: scale(.95); }
.pomo-fab svg { width: 21px; height: 21px; flex: none; }
.pomo-fab__time {
  display: none;
  font-family: var(--font-num);
  font-weight: var(--fw-bold);
  font-size: 13px;
}
.pomo-layer--running .pomo-fab {
  border-color: var(--pm);
  color: var(--pm);
}
.pomo-layer--running .pomo-fab__time { display: inline; }

/* While the alarm rings the button throbs until someone settles it. */
.pomo-layer--alarm .pomo-fab {
  border-color: #E24444;
  animation: pomo-throb 1.1s ease-in-out infinite;
}
@keyframes pomo-throb {
  0%, 100% { transform: scale(1);    box-shadow: 0 6px 18px rgba(226, 68, 68, .35); }
  50%      { transform: scale(1.12); box-shadow: 0 6px 26px rgba(226, 68, 68, .6); }
}
@media (prefers-reduced-motion: reduce) {
  .pomo-layer--alarm .pomo-fab { animation: none; }
}

/* The ringing strip at the top of the panel: stop, or borrow time. */
.pomo-alarm {
  background: color-mix(in srgb, #E24444 12%, var(--paper));
  border: 1px solid color-mix(in srgb, #E24444 45%, transparent);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pomo-alarm__msg {
  margin: 0;
  font-size: 13px;
  font-weight: var(--fw-bold);
  color: #C43333;
  text-align: center;
}
.pomo-alarm__row { display: flex; gap: 6px; }
.pomo-alarm__stop,
.pomo-alarm__ext {
  flex: 1;
  border-radius: 9px;
  padding: 7px 4px;
  font-size: 12px;
  font-weight: var(--fw-bold);
  cursor: pointer;
}
.pomo-alarm__stop {
  border: none;
  background: #E24444;
  color: #fff;
}
.pomo-alarm__ext {
  border: 1px solid var(--border-subtle);
  background: var(--paper);
  color: var(--ink-700);
}
.pomo-alarm__ext:hover { border-color: var(--ink-400); }

/* The day's ledger: focus minutes grouped by intent. */
.pomo-log__toggle {
  border: none;
  background: transparent;
  color: var(--ink-500);
  font-size: 12px;
  font-weight: var(--fw-bold);
  cursor: pointer;
  padding: 2px 4px;
  text-align: start;
  border-radius: 6px;
}
.pomo-log__toggle:hover { color: var(--ink-700); }
.pomo-log {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 10px;
}
.pomo-log__row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 12.5px;
}
.pomo-log__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-700);
}
.pomo-log__meta {
  flex: none;
  font-family: var(--font-num);
  font-weight: var(--fw-bold);
  color: var(--pm);
  font-size: 12px;
}
.pomo-log__total {
  margin-top: 3px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-subtle);
  font-size: 12px;
  font-weight: var(--fw-bold);
  color: var(--ink-600);
}
.pomo-log__empty { margin: 0; font-size: 12px; color: var(--ink-400); }

.pomo-panel {
  width: 252px;
  background: var(--paper);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  box-shadow: 0 18px 44px rgba(22, 36, 59, .28);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pomo-modes {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--ink-50);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
}
.pomo-mode {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 5px 2px;
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: 11px;
  color: var(--ink-500);
  cursor: pointer;
  white-space: nowrap;
}
.pomo-mode--on {
  background: var(--paper);
  color: var(--c);
  box-shadow: 0 1px 4px rgba(22, 36, 59, .18);
}

.pomo-clock {
  position: relative;
  width: 150px;
  height: 150px;
  margin-inline: auto;
}
.pomo-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.pomo-ring circle { fill: none; stroke-width: 7; }
.pomo-ring__track { stroke: var(--ink-100); }
.pomo-ring__arc {
  stroke: var(--pm);
  stroke-linecap: round;
  transition: stroke-dashoffset .45s linear, stroke var(--dur-base) var(--ease-out);
}
.pomo-time {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-num);
  font-size: 30px;
  font-weight: var(--fw-bold);
  color: var(--ink-800);
  letter-spacing: 1px;
}

/* What the session is for — focus and breaks each keep their line. */
.pomo-intent {
  width: 100%;
  border: 1px dashed var(--ink-300);
  border-radius: 10px;
  background: transparent;
  color: var(--ink-700);
  font: inherit;
  font-size: 12.5px;
  text-align: center;
  padding: 8px 10px;
}
.pomo-intent::placeholder { color: var(--ink-400); }
.pomo-intent:focus {
  outline: none;
  border-style: solid;
  border-color: var(--pm);
  background: var(--ink-50);
}

.pomo-count {
  margin: 0;
  text-align: center;
  font-size: 11.5px;
  font-weight: var(--fw-semibold);
  color: var(--ink-400);
}

.pomo-actions { display: flex; gap: 8px; }
.pomo-main {
  flex: 1;
  border: none;
  background: var(--pm);
  color: #fff;
  border-radius: 12px;
  padding: 9px;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 13.5px;
  cursor: pointer;
  transition: filter var(--dur-fast) var(--ease-out);
}
.pomo-main:hover { filter: brightness(1.08); }
.pomo-side {
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--ink-500);
  border-radius: 12px;
  padding: 9px 10px;
  font-size: 11.5px;
  font-weight: var(--fw-semibold);
  cursor: pointer;
}
.pomo-side:hover { color: var(--ink-700); border-color: var(--ink-300); }

.pomo-durs { display: flex; gap: 8px; }
.pomo-dur {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 10px;
  font-weight: var(--fw-semibold);
  color: var(--ink-400);
}
.pomo-dur input {
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--ink-50);
  color: var(--ink-700);
  font: inherit;
  font-size: 12px;
  padding: 5px 6px;
  text-align: center;
}
.pomo-dur input:focus { outline: none; border-color: var(--info); }

/* ---- The compact habits widget ---- */

.hb-w {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px 14px;
  background: var(--paper);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

/* Week view: the two spare cells beside the last day. The row's height
   comes from the day tile — many habits scroll inside. It wears the
   sticky notes' yellow, so its ink stays dark in either theme. */
.hb-w--week {
  grid-column: span 2;
  background: #FFF3A0;
  border-color: rgba(22, 36, 59, .18);
}
.hb-w--week .hb-w__title,
.hb-w--week .hb-w__name { color: #16243B; }
.hb-w--week .hb-w__open { color: rgba(22, 36, 59, .55); }
.hb-w--week .hb-w__open:hover {
  color: #16243B;
  background: rgba(22, 36, 59, .08);
}
.hb-w--week .hb-w__rows { scrollbar-color: rgba(22, 36, 59, .35) transparent; }

/* This week, day by day, beside each habit. */
.hb-w__week {
  display: flex;
  gap: 4px;
  flex: none;
}
.hb-w__cell {
  width: 15px;
  height: 15px;
  padding: 0;
  border: 1px solid rgba(22, 36, 59, .3);
  border-radius: 4px;
  background: rgba(255, 255, 255, .55);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.hb-w__cell:hover { border-color: var(--hc); }
.hb-w__cell[aria-pressed="true"] {
  background: var(--hc);
  border-color: var(--hc);
}
.hb-w__cell--today { box-shadow: 0 0 0 2px rgba(22, 36, 59, .35); }

/* New habits, without leaving the page. */
.hb-w__composer { flex: none; }
.hb-w__input {
  width: 100%;
  border: 1.5px dashed rgba(22, 36, 59, .35);
  border-radius: 9px;
  background: transparent;
  color: #16243B;
  font: inherit;
  font-size: 12px;
  padding: 7px 10px;
}
.hb-w__input::placeholder { color: rgba(22, 36, 59, .5); }
.hb-w__input:focus {
  outline: none;
  border-style: solid;
  border-color: rgba(22, 36, 59, .55);
  background: rgba(255, 255, 255, .6);
}
.hb-w__hint {
  flex: 1;
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: rgba(22, 36, 59, .6);
}

/* Day view: its own card under the composer, matching its siblings. */
.hb-w--day { margin-top: 12px; flex: none; }
.day-view:not(.day-view--full) .hb-w--day { display: none; }

.hb-w__head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hb-w__title {
  flex: 1;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 13.5px;
  color: var(--ink-700);
}
.hb-w__open {
  border: none;
  background: transparent;
  color: var(--ink-400);
  font-size: 14px;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 7px;
  cursor: pointer;
}
.hb-w__open:hover { color: var(--ink-700); background: var(--ink-50); }

.hb-w__rows {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-300) transparent;
}

.hb-w__row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.hb-w__check {
  position: relative;
  flex: none;
  width: 24px;
  height: 24px;
  border: 1.8px solid var(--hc);
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.hb-w__check::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
}
.hb-w__check:hover { background: color-mix(in srgb, var(--hc) 16%, transparent); }
.hb-w__check[aria-pressed="true"] { background: var(--hc); }

.hb-w__name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: var(--fw-semibold);
  color: var(--ink-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hb-w__streak {
  flex: none;
  font-size: 11.5px;
  font-weight: var(--fw-bold);
  color: #F2762E;
  white-space: nowrap;
}

/* No habits yet: the whole body is one inviting button. */
.hb-w__empty {
  flex: 1;
  border: 1.5px dashed var(--ink-300);
  border-radius: 10px;
  background: transparent;
  color: var(--ink-500);
  font: inherit;
  font-size: 12px;
  line-height: 1.6;
  padding: 10px;
  cursor: pointer;
  text-align: center;
}
.hb-w__empty:hover { color: var(--ink-700); border-color: var(--ink-400); }

/* ============================================================
   Life wheel
   ------------------------------------------------------------
   The widget in the column left of the calendar, the weekly
   check-in sheet, and the page with suggestions and history.
   ============================================================ */

/* ---- The widget: the column to the left of the calendar ------ */

.lw {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 16px 16px 18px;
}

.lw__head { display: flex; align-items: baseline; gap: 8px; }
.lw__title {
  margin: 0;
  margin-inline-end: auto;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 14px;
  color: var(--ink-900);
}
.lw__week { font-size: 11.5px; color: var(--ink-400); font-weight: var(--fw-semibold); }

/* The score. Big, because it is the one number the widget exists for. */
.lw__score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  font-family: var(--font-num, var(--font-display));
  line-height: 1;
}
.lw__score b { font-size: 34px; font-weight: var(--fw-bold); color: var(--ink-900); }
.lw__score i { font-size: 14px; font-style: normal; color: var(--ink-400); }
.lw__cover {
  text-align: center;
  font-size: 11px;
  color: var(--ink-400);
  margin: -8px 0 0;
}

.lw__wheel { display: block; width: 100%; height: auto; }

/* The page's copy of the button sits under the dial, not against it. */
.lwp__card > .lw__cta { margin-top: 14px; }

.lw__cta {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 11px;
  background: var(--info);
  color: #fff;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 13px;
  cursor: pointer;
  transition: filter var(--dur-fast) var(--ease-out);
}
.lw__cta:hover { filter: brightness(1.08); }
.lw__cta--quiet {
  background: var(--ink-50);
  color: var(--ink-600);
}

.lw__legend { display: flex; flex-direction: column; gap: 2px; }
.lw__row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 6px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  text-align: start;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--ink-700);
  transition: background var(--dur-fast) var(--ease-out);
}
.lw__row:hover { background: var(--ink-50); }
.lw__row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lw__row b {
  font-family: var(--font-num, var(--font-display));
  font-size: 12.5px;
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
}
.lw__row b[data-empty="1"] { color: var(--ink-300); font-weight: var(--fw-regular); }

/* A bar under the number: the trend at a glance without a chart. */
.lw__spark { flex: 0 0 46px; height: 16px; }

/* ---- Wheel ---------------------------------------------------- */

.wheel__ring { fill: none; stroke: var(--border-subtle); stroke-width: 1; }
.wheel__spoke { stroke: var(--border-subtle); stroke-width: 1; }
.wheel__slice { transition: opacity var(--dur-fast) var(--ease-out); cursor: pointer; }
.wheel__slice:hover { opacity: .78; }
/* Last check-in, drawn as an outline over the current fill: the shape
   of the change is the whole point of looking at a wheel twice. */
.wheel__ghost {
  fill: none;
  stroke: var(--ink-500);
  stroke-width: 1.6;
  stroke-dasharray: 3 3;
  opacity: .75;
  pointer-events: none;
}
.wheel__label {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  fill: var(--ink-500);
  /* `start`/`end` follow the writing direction, and under the page's RTL
     every right-hand label anchored back across the dial. Pinning LTR here
     fixes the anchors; a pure-Arabic string still shapes right-to-left. */
  direction: ltr;
}
.wheel__tick {
  font-family: var(--font-num, var(--font-display));
  font-size: 7px;
  fill: var(--ink-300);
}

/* ---- Check-in ------------------------------------------------- */

.ci {
  width: min(560px, calc((100vw - 32px) / var(--zoom)));
  max-height: calc((100dvh - 40px) / var(--zoom));
  padding: 0;
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  background: var(--card-bg);
  color: var(--ink-700);
  box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 24px 60px rgba(0,0,0,.22);
  overflow: hidden;
}
.ci::backdrop { background: rgba(0, 0, 0, .42); }

/* The rail of eight: where you are, what is done, and a way to jump.
   Eight areas is long enough that "which one am I on" is a real
   question, and short enough to answer with eight dots. */
.ci__rail {
  display: flex;
  gap: 5px;
  padding: 14px 18px 0;
}
.ci__step {
  flex: 1;
  height: 4px;
  border: none;
  padding: 0;
  border-radius: 2px;
  background: var(--ink-100);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.ci__step[data-state="done"] { background: var(--c); }
.ci__step[data-state="here"] { background: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent); }

.ci__head { padding: 14px 18px 10px; display: flex; align-items: center; gap: 9px; }
.ci__name {
  margin: 0;
  margin-inline-end: auto;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 17px;
  color: var(--ink-900);
}
.ci__blurb { font-size: 12px; color: var(--ink-400); }
.ci__close {
  flex: none; width: 28px; height: 28px; display: grid; place-items: center;
  border: none; border-radius: 50%; background: var(--ink-50);
  color: var(--ink-500); font-size: 13px; cursor: pointer;
}

.ci__body { padding: 0 18px; overflow-y: auto; max-height: 52vh; }

.ci__q { padding: 11px 0; border-bottom: 1px solid var(--border-subtle); }
.ci__q:last-child { border-bottom: none; }
.ci__text { margin: 0 0 8px; font-size: 13.5px; color: var(--ink-800); line-height: 1.45; }

/* Five taps, labelled with this question's own units. A slider reads as
   precision the answer does not have; five named steps are faster and
   more honest.

   A grid, not a flex row: the labels differ in length from question to
   question ('٧ أيام' against '٦ شهور أو أكتر'), and equal columns keep
   the five hit targets the same size down the whole sheet instead of
   letting the longest word decide. */
.ci__scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}
.ci__opt {
  min-height: 34px;
  padding: 6px 3px;
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  background: transparent;
  color: var(--ink-500);
  font-family: var(--font-body);
  font-size: 10.5px;
  line-height: 1.25;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.ci__opt:hover { border-color: var(--c); color: var(--ink-700); }
.ci__opt[aria-pressed="true"] {
  background: var(--c);
  border-color: var(--c);
  color: #fff;
  font-weight: var(--fw-semibold);
}
/* The escape for a conditional question. Stored as NA and skipped by the
   scoring, so a week with no argument in it does not count as a bad week
   at handling arguments — which is what any of the five points would
   have meant. */
.ci__na {
  margin-top: 6px;
  padding: 5px 11px;
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-400);
  font-family: var(--font-body);
  font-size: 11px;
  cursor: pointer;
}
.ci__na[aria-pressed="true"] {
  border-style: solid;
  border-color: var(--ink-400);
  background: var(--ink-50);
  color: var(--ink-700);
}

/* Answering is optional and the interface has to mean it: skipping is a
   button, not an absence, so an unanswered area is a choice on record. */
.ci__skip {
  margin: 10px 0 0;
  background: none; border: none; padding: 0;
  font-family: var(--font-body); font-size: 12px;
  color: var(--ink-400); cursor: pointer; text-decoration: underline;
}

.ci__foot {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border-subtle);
  background: var(--ink-75);
}
.ci__live { margin-inline-end: auto; font-size: 12px; color: var(--ink-500); }
.ci__live b {
  font-family: var(--font-num, var(--font-display));
  font-size: 16px; color: var(--ink-900);
}
.ci__btn {
  padding: 9px 16px; border: none; border-radius: 10px;
  background: var(--info); color: #fff;
  font-family: var(--font-display); font-weight: var(--fw-bold); font-size: 13px;
  cursor: pointer;
}
.ci__btn--ghost { background: var(--ink-100); color: var(--ink-700); }

/* ---- Full page ------------------------------------------------- */

.lwp { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 20px; }
@media (max-width: 900px) { .lwp { grid-template-columns: minmax(0, 1fr); } }

.lwp__card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 16px 18px 18px;
}
.lwp__h {
  margin: 0 0 12px;
  font-family: var(--font-display); font-weight: var(--fw-bold);
  font-size: 14px; color: var(--ink-900);
}
.lwp__stack { display: flex; flex-direction: column; gap: 16px; }

/* -- suggestions -- */
.sg { display: flex; flex-direction: column; gap: 9px; }
.sg__item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--c) 8%, var(--card-bg));
  border: 1px solid color-mix(in srgb, var(--c) 20%, transparent);
}
.sg__body { flex: 1; min-width: 0; }
.sg__from {
  font-size: 10.5px; font-weight: var(--fw-bold);
  color: var(--c); margin: 0 0 3px;
  filter: brightness(.82);
}
:root[data-theme="night"] .sg__from { filter: brightness(1.15); }
.sg__fix { margin: 0; font-size: 13px; line-height: 1.5; color: var(--ink-800); }
.sg__acts { display: flex; gap: 6px; margin-top: 8px; }
.sg__act {
  padding: 5px 10px; border: 1px solid var(--border-subtle);
  border-radius: 999px; background: var(--card-bg);
  font-family: var(--font-body); font-size: 11.5px; color: var(--ink-600);
  cursor: pointer;
}
.sg__act--go { background: var(--info); border-color: var(--info); color: #fff; font-weight: var(--fw-semibold); }
.sg__done { font-size: 12px; color: var(--success); font-weight: var(--fw-semibold); }

/* -- history -- */
.hx { display: flex; flex-direction: column; gap: 3px; }
/* A button now: each row opens its own area's questions. */
.hx__row {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 7px 8px; border-radius: 9px;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  text-align: start;
  cursor: pointer;
  transition: background var(--dur-quick) var(--ease-soft);
}
.hx__row:hover { background: var(--ink-50); }
.hx__row:active { background: var(--ink-100); }
.hx__name { flex: 0 0 120px; font-size: 12.5px; color: var(--ink-700); display: flex; align-items: center; gap: 7px; }
.hx__name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* preserveAspectRatio:none on the svg lets the line stretch to whatever
   width the row has; the trend's shape is what matters, not its scale. */
.hx__line { flex: 1; min-width: 0; height: 26px; }
.hx__now {
  flex: 0 0 56px; text-align: end;
  font-family: var(--font-num, var(--font-display));
  font-size: 13px; color: var(--ink-900); font-variant-numeric: tabular-nums;
}
.hx__delta { font-size: 11px; font-weight: var(--fw-semibold); margin-inline-start: 5px; }
.hx__delta[data-dir="up"] { color: var(--success); }
.hx__delta[data-dir="down"] { color: var(--danger); }
.hx__delta[data-dir="flat"] { color: var(--ink-400); }

/* The widget's own column. Narrow on purpose: the wheel is a glance, and
   the calendar beside it is the thing being used. */
.layout__wheel { display: none; }

@media (min-width: 1250px) {
  /* A third column, which RTL puts on the far left — the strip that sat
     empty between the rail and the month grid. Below this width the
     calendar needs all the room it has, so the wheel lives behind its
     rail button alone. */
  .layout { grid-template-columns: minmax(0, 460px) minmax(0, 1fr) 300px; }
  .layout__wheel { display: block; position: sticky; top: 20px; }

  /* ---- Week view ----
     Only the month grid can spare the third column: it caps at 740px and
     leaves the rest over. The week view has no cap — its seven cards divide
     whatever width exists — so taking 300px away squeezed three columns
     into 416px and left the day cards as tall slivers.

     So in week mode the wheel steps out of the side column and lies down in
     the band under the grid, which the three rows of cards leave empty
     anyway. The grid gets its width back and the two never meet. */
  .layout--week { grid-template-columns: minmax(0, 460px) minmax(0, 1fr); }
  .layout--week .layout__grid  { grid-column: 2; grid-row: 1; }
  .layout--week .layout__wheel { grid-column: 2; grid-row: 2; position: static; }

  /* The same card laid on its side. Placed on an explicit grid rather than
     left to flex-wrap: the legend needs real width, so on one wrapping line it
     kept dropping to a row of its own and the card grew to 354px — tall enough
     to fall off the bottom of the screen, which is the problem this layout
     exists to solve. Three columns, and the height is just the wheel.

     RTL puts column 1 on the right, so it reads wheel · numbers · areas. */
  .layout--week .lw {
    display: grid;
    grid-template-columns: 156px auto minmax(0, 1fr);
    grid-template-rows: auto repeat(4, auto);
    column-gap: 24px;
    row-gap: 4px;
    align-items: center;
    padding: 14px 20px 16px;
  }
  .layout--week .lw__head   { grid-column: 1 / -1; grid-row: 1; margin-bottom: 4px; }
  .layout--week .lw__wheel  { grid-column: 1; grid-row: 2 / 6; width: 156px; }
  .layout--week .lw__score  { grid-column: 2; grid-row: 2; justify-content: flex-start; }
  .layout--week .lw__cover  { grid-column: 2; grid-row: 3; margin: 0; text-align: start; }
  .layout--week .lw__cta    { grid-column: 2; grid-row: 4; width: auto; padding: 9px 18px; margin-top: 6px; }
  .layout--week .lw__more   { grid-column: 2; grid-row: 5; width: auto; padding: 5px 8px; }
  .layout--week .lw__legend { grid-column: 3; grid-row: 2 / 6;
                              display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
                              column-gap: 16px; align-content: center; }
}

.lw__more {
  width: 100%;
  margin-top: 2px;
  padding: 7px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-500);
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
}
.lw__more:hover { background: var(--ink-50); color: var(--ink-700); }

/* The check-in is a dialog of its own rather than a .sheet: it is taller,
   it scrolls inside, and the rail has to sit flush at the top. */
#wheel-checkin.ci { padding: 0; }

.lw-view { width: min(1100px, calc((100vw - 32px) / var(--zoom))); }
.lw-body { padding-top: 4px; }

/* ============================================================
   Motion
   ------------------------------------------------------------
   The app moved in steps: things appeared and disappeared with
   nothing in between, which reads as cheap however good the rest
   looks. These are the few curves everything now shares.

   --ease-emph is the curve Apple uses on sheets: it leaves fast
   and arrives slowly, which is what makes a panel feel like it
   was pushed rather than played back.
   ============================================================ */

:root {
  --dur-quick: 140ms;
  --dur-snap:  240ms;
  --dur-soft:  340ms;
  --ease-emph: cubic-bezier(.32, .72, 0, 1);
  --ease-soft: cubic-bezier(.4, 0, .2, 1);
  --ease-back: cubic-bezier(.34, 1.32, .64, 1);   /* a little overshoot */
}

/* ---- Windows ----
   Every dialog in the app fades and lifts into place, and — the part
   that needs @starting-style and allow-discrete — fades back out
   instead of vanishing. Without the discrete transitions the browser
   drops `display` the instant the dialog closes and there is nothing
   left on screen to animate. */
dialog.sheet,
dialog.ci {
  opacity: 0;
  transform: translateY(10px) scale(.985);
  transition:
    opacity var(--dur-snap) var(--ease-soft),
    transform var(--dur-snap) var(--ease-emph),
    overlay var(--dur-snap) allow-discrete,
    display var(--dur-snap) allow-discrete;
}
dialog.sheet[open],
dialog.ci[open] { opacity: 1; transform: none; }
@starting-style {
  dialog.sheet[open],
  dialog.ci[open] { opacity: 0; transform: translateY(10px) scale(.985); }
}

dialog.sheet::backdrop,
dialog.ci::backdrop {
  opacity: 0;
  transition: opacity var(--dur-snap) var(--ease-soft),
              overlay var(--dur-snap) allow-discrete,
              display var(--dur-snap) allow-discrete;
}
dialog.sheet[open]::backdrop,
dialog.ci[open]::backdrop { opacity: 1; }
@starting-style {
  dialog.sheet[open]::backdrop,
  dialog.ci[open]::backdrop { opacity: 0; }
}

/* The panels come up from a little further down than a sheet — they are a
   change of place, not a question on top of the page. The transition
   itself lives with .pm-view, which also animates the fullscreen flip. */
dialog.pm-view { transform: translateY(18px) scale(.985); }
@starting-style { dialog.pm-view[open] { transform: translateY(18px) scale(.985); } }

/* ============================================================
   Side menu
   ============================================================ */

/* Above the notes layer (70), which is appended after it and would
   otherwise paint its buttons over the open drawer. Below the confetti. */
.nav { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.nav > * { pointer-events: auto; }

.nav__scrim {
  position: absolute;
  inset: 0;
  background: rgba(10, 15, 22, .34);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur-snap) var(--ease-soft),
              visibility var(--dur-snap);
}
.nav--open .nav__scrim { opacity: 1; visibility: visible; }

/* The button stays put whether the menu is open or shut: it is the one
   fixed landmark, and a control that moves when you press it makes you
   look for it again every time. */
.nav__toggle {
  position: absolute;
  /* `left`, not `inset-inline-start`: the interface is RTL, so the logical
     start edge is the right one and the menu came out on the wrong side.
     This belongs where the old column of circles was. */
  left: calc(14px * var(--zoom));
  top: calc(18px * var(--zoom));
  display: grid;
  place-items: center;
  width: calc(42px * var(--zoom));
  height: calc(42px * var(--zoom));
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: var(--card-bg);
  color: var(--ink-700);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .08), 0 8px 24px rgba(0, 0, 0, .10);
  transition: transform var(--dur-quick) var(--ease-back),
              background var(--dur-quick) var(--ease-soft);
}
.nav__toggle:hover { transform: scale(1.06); }
.nav__toggle:active { transform: scale(.96); }

/* Three lines that fold into a cross. The middle one fades while the
   outer two rotate onto each other. */
.nav__burger,
.nav__burger::before,
.nav__burger::after {
  content: "";
  display: block;
  width: calc(17px * var(--zoom));
  height: 1.8px;
  border-radius: 2px;
  background: currentColor;
  transition: transform var(--dur-snap) var(--ease-emph),
              opacity var(--dur-quick) var(--ease-soft);
}
.nav__burger { position: relative; transition: background var(--dur-quick) var(--ease-soft); }
.nav__burger::before { position: absolute; top: calc(-5px * var(--zoom)); }
.nav__burger::after  { position: absolute; top: calc(5px * var(--zoom)); }
/* The middle bar goes transparent rather than opacity:0, and it does not
   scale: opacity and transform on the bar apply to its own ::before and
   ::after as well, so both of those took the whole X away with it. */
.nav--open .nav__burger { background: transparent; }
.nav--open .nav__burger::before { transform: translateY(calc(5px * var(--zoom))) rotate(45deg); }
.nav--open .nav__burger::after  { transform: translateY(calc(-5px * var(--zoom))) rotate(-45deg); }

.nav__panel {
  position: absolute;
  inset-block: 0;
  left: 0;
  width: min(282px, 82vw);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: calc(74px * var(--zoom)) 12px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--card-bg);
  border-right: 1px solid var(--border-subtle);
  box-shadow: 0 0 40px rgba(0, 0, 0, .18);
  /* Translated by its own width rather than hidden: the drawer has to be
     laid out to slide, and `inert` keeps it off the keyboard meanwhile. */
  transform: translateX(-102%);
  transition: transform var(--dur-soft) var(--ease-emph);
}
.nav--open .nav__panel { transform: none; }

.nav__head { padding: 0 10px 10px; }
.nav__brand {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 15px;
  color: var(--ink-900);
}

.nav__group { padding-bottom: 10px; }
.nav__glabel {
  margin: 10px 10px 6px;
  font-size: 10.5px;
  font-weight: var(--fw-bold);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-400);
}

.nav__item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: var(--ink-700);
  font-family: var(--font-body);
  font-size: 13.5px;
  text-align: start;
  cursor: pointer;
  transition: background var(--dur-quick) var(--ease-soft),
              color var(--dur-quick) var(--ease-soft);
}
.nav__item:hover { background: var(--ink-50); color: var(--ink-900); }
.nav__item:active { background: var(--ink-100); }
.nav__item--on { color: var(--info); }

.nav__icon { flex: none; display: grid; place-items: center; width: 22px; height: 22px; }
.nav__icon svg { width: 20px; height: 20px; }
.nav__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* A chevron that turns rather than swaps. */
.nav__chev {
  flex: none;
  width: 7px; height: 7px;
  border-inline-end: 1.6px solid var(--ink-400);
  border-block-end: 1.6px solid var(--ink-400);
  transform: rotate(-45deg);
  transition: transform var(--dur-snap) var(--ease-emph);
}
.nav__chev--open { transform: rotate(45deg); }

.nav__switch {
  flex: none;
  width: 30px; height: 18px;
  border-radius: 999px;
  background: var(--ink-200);
  position: relative;
  transition: background var(--dur-snap) var(--ease-soft);
}
.nav__switch::after {
  content: "";
  position: absolute;
  left: 2px; top: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: transform var(--dur-snap) var(--ease-emph);
}
.nav__item--on .nav__switch { background: var(--info); }
.nav__item--on .nav__switch::after { transform: translateX(12px); }

.nav__sub {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 2px 0 6px;
  padding-inline-start: 22px;
}

/* The panel is pinned to the physical left, but its contents are Arabic:
   the text stays RTL and only the box is placed by physical side. */
.nav__panel { direction: rtl; }
:root[lang="en"] .nav__panel { direction: ltr; }
.nav__subitem {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-600);
  font-family: var(--font-body);
  font-size: 12.5px;
  text-align: start;
  cursor: pointer;
  animation: nav-sub var(--dur-snap) var(--ease-emph) backwards;
  animation-delay: calc(var(--i) * 22ms);
  transition: background var(--dur-quick) var(--ease-soft);
}
.nav__subitem:hover { background: var(--ink-50); color: var(--ink-900); }
.nav__subitem span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes nav-sub {
  from { opacity: 0; transform: translateY(-6px); }
}

/* The rows arrive one after another, which is what makes the drawer read
   as opening rather than as a block appearing. Short enough that the last
   row lands before the panel finishes its own slide. */
.nav--open .nav__item {
  animation: nav-row var(--dur-snap) var(--ease-emph) backwards;
  animation-delay: calc(90ms + var(--i) * 26ms);
}
@keyframes nav-row {
  from { opacity: 0; transform: translateX(-10px); }
}

/* On a phone the drawer is the whole screen, so it gets the full height
   and the toggle sits on top of it. */
@media (max-width: 560px) {
  .nav__panel { width: min(320px, 88vw); }
}

/* ---- Everything above, switched off ----
   One block, so there is a single place to check what a reduced-motion
   viewer actually gets: the same app, arriving instantly. */
@media (prefers-reduced-motion: reduce) {
  .nav__panel,
  .nav__scrim,
  .nav__burger,
  .nav__burger::before,
  .nav__burger::after,
  .nav__chev,
  .nav__switch,
  .nav__switch::after,
  dialog.sheet,
  dialog.ci,
  dialog.sheet::backdrop,
  dialog.ci::backdrop { transition-duration: 1ms; }
  .nav--open .nav__item,
  .nav__subitem { animation: none; }
  .nav__toggle:hover,
  .nav__toggle:active { transform: none; }
}

/* ---- The two that stay on the edge ----
   Everything else moved into the menu. These two are the ones you reach for
   without deciding to: a timer has to be glanceable while it runs, and a
   thought you need to dump is gone by the time you have opened a menu. */

.edge-fab {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: var(--card-bg);
  color: var(--ink-600);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .08), 0 8px 24px rgba(0, 0, 0, .12);
  transition: transform var(--dur-quick) var(--ease-back),
              color var(--dur-quick) var(--ease-soft);
}
.edge-fab:hover { transform: scale(1.07); }
.edge-fab:active { transform: scale(.95); }
.edge-fab svg { width: 20px; height: 20px; }
.edge-fab[aria-pressed="true"] { color: var(--info); }

/* Stacked bottom-left, clear of the menu button at the top: the timer on
   the floor, the brain dump above it, a new note above that. */
.brain-fab,
.note-fab {
  position: fixed;
  left: calc(14px / var(--zoom));
  z-index: 60;
  zoom: var(--zoom);
}
.brain-fab { bottom: calc(74px / var(--zoom)); }
.note-fab  { bottom: calc(130px / var(--zoom)); }

/* Those three ride inside the fullscreen day view, which is already scaled —
   so they must not take the zoom a second time on top of it. */
.day-view .brain-fab,
.day-view .note-fab { zoom: calc(1 / var(--zoom)); }

/* .notes-layer is pointer-events:none so only the notes catch the pointer;
   the button has to opt back in. */
.note-fab {
  pointer-events: auto;
  /* Its own paper colour, the way the notes have. */
  background: #FFF3A0;
  color: #16243B;
  border-color: rgba(0, 0, 0, .08);
}
:root[data-theme="night"] .note-fab { filter: brightness(.94); }

/* ---- Content settling ----
   The panel lands first and its contents rise a beat later, so opening
   reads as one movement with a tail rather than a box appearing with
   everything already inside it. */
.pm-view[open] .pm-body,
.pm-view[open] .lw-body {
  animation: panel-body var(--dur-soft) var(--ease-emph) 60ms backwards;
}
@keyframes panel-body {
  from { opacity: 0; transform: translateY(8px); }
}

/* ---- Changing month or view ----
   app.js adds .month-grid--turn for one beat when the month steps or the
   view flips — not on an ordinary re-render, which happens on every edit
   and would set the whole calendar twitching while you type. */
.month-grid--turn .day,
.month-grid--turn .wday {
  animation: tile-in 260ms var(--ease-emph) backwards;
  animation-delay: calc(var(--n, 0) * 7ms);
}
@keyframes tile-in {
  from { opacity: 0; transform: translateY(6px) scale(.97); }
}

/* ---- Press ----
   Every control the hand lands on answers it. Small enough to feel like
   the surface giving rather than the button moving. */
.btn:active:not(:disabled),
.pill:active,
.monthnav__btn:active,
.sheet__close:active,
.lw__cta:active,
.ci__btn:active,
.ci__opt:active,
.sg__act:active,
.pm-expand:active { transform: scale(.96); }

.btn, .pill, .monthnav__btn, .sheet__close,
.lw__cta, .ci__btn, .ci__opt, .sg__act {
  transition: transform var(--dur-quick) var(--ease-back),
              background var(--dur-quick) var(--ease-soft),
              color var(--dur-quick) var(--ease-soft),
              border-color var(--dur-quick) var(--ease-soft);
}

@media (prefers-reduced-motion: reduce) {
  .pm-view[open] .pm-body,
  .pm-view[open] .lw-body,
  .month-grid--turn .day,
  .month-grid--turn .wday { animation: none; }
  .pm-view { transition-duration: 1ms; }
  .btn:active:not(:disabled),
  .pill:active,
  .monthnav__btn:active,
  .sheet__close:active,
  .lw__cta:active,
  .ci__btn:active,
  .ci__opt:active,
  .sg__act:active,
  .pm-expand:active { transform: none; }
}

/* ---- The week log ----
   Every rated week, newest first. The selected one is marked, because the
   wheel above it is showing that week and nothing else on the page says so. */

.lg { display: flex; flex-direction: column; gap: 2px; }

.lg__row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-family: var(--font-body);
  text-align: start;
  cursor: pointer;
  transition: background var(--dur-quick) var(--ease-soft);
}
.lg__row:hover { background: var(--ink-50); }
.lg__row:active { background: var(--ink-100); }
.lg__row[aria-current="true"] {
  background: color-mix(in srgb, var(--info) 12%, transparent);
  box-shadow: inset 2px 0 0 var(--info);
}
[dir="rtl"] .lg__row[aria-current="true"] { box-shadow: inset -2px 0 0 var(--info); }

.lg__when { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.lg__when b { font-size: 12.5px; font-weight: var(--fw-semibold); color: var(--ink-900); }
.lg__when span { font-size: 11px; color: var(--ink-400); }

.lg__score { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.lg__score b {
  font-family: var(--font-num, var(--font-display));
  font-size: 15px;
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
}
.lg__score span { font-size: 10.5px; color: var(--ink-400); white-space: nowrap; }

.lg__delta {
  flex: 0 0 38px;
  text-align: end;
  font-size: 11.5px;
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}
.lg__delta[data-dir="up"]   { color: var(--success); }
.lg__delta[data-dir="down"] { color: var(--danger); }
.lg__delta[data-dir="flat"] { color: var(--ink-400); }

/* Looking at a past week: the button edits that week rather than this one,
   and the way back out sits under it. */
.lw__past { display: flex; flex-direction: column; gap: 2px; margin-top: 14px; }
.lw__cta--quiet { background: var(--ink-100); color: var(--ink-800); }
.lw__cta--quiet:hover { background: var(--ink-200); }

/* The check-in says which week it is answering when it is not this one. */
.ci__blurb--past {
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--warning) 20%, transparent);
  color: color-mix(in srgb, var(--warning) 70%, var(--ink-900));
  font-weight: var(--fw-semibold);
}

/* ============================================================
   الدفتر — the notebook skin
   ------------------------------------------------------------
   One idea: the app is paper, not glass.

   Surfaces stop floating. No shadows, no filled tiles — things
   are separated by hairlines, the way a ruled page separates
   its lines. Colour stops being the surface and becomes a mark
   on it: a dot, a stroke, a wash. That is what lets eight life
   areas all be present at once without the page shouting.

   And the numerals are set in a serif. This app is mostly
   numbers — day numbers, week numbers, scores, percentages,
   timers — so that single swap does more than any other to make
   a screen read as something written rather than something
   rendered.

   This is a skin, not a rewrite: almost all of it re-points
   tokens the rest of the file already consumes. The component
   overrides at the end are only for the places where "card" and
   "ruled line" are genuinely different shapes, not just
   different colours.
   ============================================================ */

/* ---- 1 · Type ----------------------------------------------
   Running text and controls stay IBM Plex Sans Arabic. A Naskh
   at 11px is a lovely idea and an unreadable label; the serif
   is for the things you read slowly. */
:root {
  --font-num:   'Lora', Georgia, 'Times New Roman', serif;
  --font-serif: 'Noto Naskh Arabic', 'Lora', Georgia, serif;

  /* Paper takes gentler corners than glass does. */
  --radius-xs:  5px;
  --radius-sm:  8px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  18px;
}

/* ---- 2 · The ink ramp, warmed --------------------------------
   The stock ramp is a cool navy, which on a warm sheet reads as
   a screen showing through. Every stop below is the same
   lightness as the one it replaces, rotated to the brown side
   so ink and paper belong to each other. */
:root {
  --page-bg:   #F1EDE4;   /* the desk */
  --paper:     #FBF9F5;   /* the sheet */

  --ink-50:    #F7F4EE;
  --ink-75:    #F1EDE4;
  --ink-100:   #EAE4D8;
  --ink-200:   #DBD3C4;
  --ink-300:   #C3B9A7;
  /* These two carry real text at 11–13px, so they are set to the
     darkest value that still reads as muted: 4.5:1 on the sheet. */
  --ink-400:   #776E62;
  --ink-500:   #655D53;
  --ink-600:   #5C5349;
  --ink-700:   #453D34;   /* running text */
  --ink-800:   #2F2922;
  --ink-900:   #241F1A;   /* the pen */

  --border-subtle: rgba(36, 31, 26, .13);
  --border-strong: rgba(36, 31, 26, .24);

  /* The page ruling, and the heavier line that separates rows. */
  --rule:      rgba(36, 31, 26, .085);
  --rule-line: rgba(36, 31, 26, .13);

  --empty-tile: #EDE7DB;
  --empty-ink:  #8A8073;
}

/* ---- 3 · The same page at night ------------------------------
   Not a black screen: a dark sheet. The ink is warm white, the
   page is warm near-black, and the hairlines carry a trace of
   the paper's colour so the two modes are recognisably one
   design rather than two. */
:root[data-theme="night"] {
  --page-bg:   #121009;
  --paper:     #1C1915;   /* the sheet, one step up from the desk */

  --ink-50:    #221E18;
  --ink-75:    #15120D;
  --ink-100:   #26221B;
  --ink-200:   rgba(255, 248, 235, .15);
  --ink-300:   rgba(255, 248, 235, .26);
  --ink-400:   #7C7366;
  --ink-500:   #988F80;
  --ink-600:   #B9B1A3;
  --ink-700:   #D7D0C4;   /* running text */
  --ink-800:   #E9E3D8;
  --ink-900:   #F5F1E9;   /* the pen */

  --border-subtle: rgba(255, 248, 235, .13);
  --border-strong: rgba(255, 248, 235, .22);

  --rule:      rgba(255, 248, 235, .065);
  --rule-line: rgba(255, 248, 235, .11);

  --empty-tile: #262118;
  --empty-ink:  #9A9182;
}

/* ---- 4 · Surfaces: cards become sheets -----------------------
   A shadow says "this is floating above the page". On paper
   nothing floats, so depth is gone and separation is a drawn
   edge — one hairline, the same weight in both themes. */
:root,
:root[data-theme="night"] {
  --card-bg:           var(--paper);
  --card-radius:       calc(12px * var(--zoom));
  --card-border:       var(--border-subtle);
  --card-shadow:       none;
  --card-shadow-hover: none;
}
:root           { --card-well: #EDE8DD; }
:root[data-theme="night"] { --card-well: #191610; }

/* The stock card rules set a shadow but leave the border at
   `transparent`, so dropping the shadow alone would make every
   sheet dissolve into the page. These are the surfaces that
   need the edge drawn instead. */
.panel__main,
.sheet,
.pm-card,
.stat-card,
.hb-card,
.ar-card,
.lw-card { border: 1px solid var(--card-border); }

/* The day panel wears the day's colour as a ring. Paper takes it
   as a line, not a band. */
.panel__main { border-width: 1.25px; }

/* ---- 5 · The backdrop stays squared --------------------------
   The ruling the rest of this skin implies would be horizontal
   lines, but the squared paper is the backdrop that was asked
   for and it is keeping its verticals. It picks up the warm
   --rule above on its own, so there is nothing to override here
   — this note only exists so the next person does not "fix" it. */

/* ---- 6 · Where the serif goes --------------------------------
   The things you read slowly: titles, the weekday, the dates,
   the line that tells you a day is empty. */
.topbar__title,
.sheet__title,
.grid-title,
.panel__weekday,
.panel__greg,
.panel__hijri,
.day-view__bar .sheet__title { font-family: var(--font-serif); }

.topbar__title { font-weight: 600; letter-spacing: 0; }
.grid-title    { font-weight: 600; font-size: 14px; color: var(--ink-800); }
.panel__weekday { font-weight: 600; letter-spacing: 0; }
.sheet__title  { font-weight: 600; letter-spacing: 0; }

/* An empty day is a note to yourself, so it is set like one. */
.panel__empty {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-500);
}

/* The week number keeps its highlighter — that is a notebook
   gesture — but in a tone that could have come from a real pen
   rather than from a screen. */
.grid-title__week {
  background: #F0DFA0;
  color: #4A3C14;
  font-weight: 600;
}
:root[data-theme="night"] .grid-title__week {
  background: #4A4017;
  color: #F3E6B4;
}

/* ---- 7 · Day tiles: filled squares become ruled cells ---------
   The month grid used to be eight saturated colours competing
   for the same square inch. Here the cell is paper with a
   hairline, the number is large and serif, and the day's areas
   are the row of dots that was already underneath it. The fill
   stays — as a wash at a sixth of its strength, which is enough
   to see the month's rhythm across the grid and not enough to
   fight the numeral sitting on it. */
.day {
  background: var(--paper);
  border: 1px solid var(--rule-line);
  box-shadow: none;
  overflow: hidden;
}
.day::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg);
  opacity: .17;
  pointer-events: none;
}
:root[data-theme="night"] .day::after { opacity: .26; }

.day:hover { transform: none; border-color: var(--border-strong); }

/* Selection and today are drawn, not lit: an inked edge and a
   filled corner instead of a glow. */
.day[data-selected="1"] {
  box-shadow: none;
  border-color: var(--ink-900);
  border-width: 1.5px;
}
.day[data-today="1"] {
  box-shadow: none;
  border-color: var(--c);
  border-width: 1.5px;
}
.day[data-empty="1"] { border-color: var(--rule); }
.day[data-empty="1"]::after { opacity: 0; }

/* The numeral is the point of the cell, so it gets the room —
   and it takes its colour from the ink ramp now, not from the
   black-or-white that JS picked to sit on a saturated fill. */
.day__num {
  position: relative;
  z-index: 1;
  font-family: var(--font-num);
  font-weight: 500;
  /* Stepped down from 26px: the today circle has to fit round a
     numeral inside a 49px cell that also carries its area dots. */
  font-size: clamp(17px, 2vw, 22px);
  color: var(--ink-900);
  text-shadow: none;
}
.day[data-ondark="1"] .day__num { color: var(--ink-900); text-shadow: none; }
.day[data-empty="1"] .day__num { color: var(--ink-400); font-weight: 400; }

.day__today {
  position: absolute;
  z-index: 1;
  color: var(--ink-500);
  font-family: var(--font-serif);
  font-weight: 600;
  opacity: 1;
}

/* The dots carry the colour now, so they are the one thing that
   stays fully saturated. */
.day__dots { position: relative; z-index: 1; }
.day__dot  { background: var(--c); opacity: .95; }

/* ---- 8 · Week boxes, same treatment --------------------------- */
.wday {
  background: var(--paper);
  border: 1px solid var(--rule-line);
  box-shadow: none;
}
.wday:hover { box-shadow: none; border-color: var(--border-strong); }
.wday[data-selected="1"] { border: 1.5px solid var(--ink-900); }
.wday__num { font-family: var(--font-num); font-weight: 500; }
.wday__name { font-family: var(--font-serif); font-weight: 600; }

/* ---- 9 · Tasks: pills become lines ----------------------------
   A tinted pill with a coloured stroke is a card. A task is a
   line in a list, so it is written as one: no fill, no outline,
   a hairline underneath, and the colour kept where it already
   meant something — the checkbox and the area dots. (No bar
   down the edge. That was the thing we took out.) */
.panel__list { gap: 0; }

.task {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule-line);
  border-radius: 0;
  padding: 11px 3px;
}
.task:last-child { border-bottom: none; }

.task[data-done="1"] {
  background: transparent;
  border-color: var(--rule-line);
  opacity: .52;
}
.task[data-done="1"]:hover { box-shadow: none; }
.task[data-done="1"] .task__text,
.task[data-done="1"] .task__num,
.task[data-done="1"] .task__time { color: var(--ink-600); }

.task__text { color: var(--ink-800); font-weight: 500; font-size: 14.5px; }
.task__num  { color: var(--ink-400); font-weight: 500; }
.task__del  { color: var(--ink-500); }

/* The checkbox is where a task's area lives now. */
.task__box { border-color: var(--c); border-width: 1.5px; }
/* A white tick on a mid-grey fill was 3:1 in both themes. The fill
   steps one stop darker and the tick is drawn in the sheet's own
   colour, which inverts correctly at night. */
.task[data-done="1"] .task__box {
  background: var(--ink-600);
  border-color: var(--ink-600);
  color: var(--paper);
}

/* A row being dragged lifts off the page — the one place depth
   is still the right word, because something really is being
   picked up. */
.task--sinking { box-shadow: 0 10px 22px rgba(36, 31, 26, .22); }

/* The fade under a scrolling list has to match the sheet. */
.panel__more { background: linear-gradient(to bottom, transparent, var(--paper) 72%); }

/* ---- 10 · The month as a ruled table --------------------------
   Thirty rounded boxes with a hairline each is a grid of cards;
   it reads as thirty things. A month is one thing, so the cells
   lose their corners and their gaps and share their lines, the
   way a planner page is ruled. The rule colour is the grid's own
   background showing through a one-pixel gap — which is how you
   get single-weight lines between cells without two borders
   meeting and doubling up. */
.month-grid {
  gap: 1px;
  align-items: stretch;
  background: var(--rule-line);
  border: 1px solid var(--rule-line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.month-grid > * { background: var(--paper); }

.grid__head {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  background: var(--ink-100);
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 11.5px;
  color: var(--ink-600);
}

/* The week number is the margin note of a planner page. */
.grid__week {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink-50);
  color: var(--ink-500);
  font-weight: 500;
}

.day,
.day-pad {
  border: none;
  border-radius: 0;
}
/* Days belonging to the months either side: part of the ruling,
   but not part of this page. */
.day-pad { background: var(--ink-50); }

/* With no border left to carry it, the state marks move inside
   the cell as inset strokes — which also keeps them from
   nudging the ruling by half a pixel. */
.day:hover { border: none; background: var(--ink-50); }
.day[data-selected="1"] { border: none; box-shadow: inset 0 0 0 2px var(--ink-900); }
.day[data-today="1"]    { border: none; box-shadow: none; }
.day[data-empty="1"]    { border: none; }

/* ---- Today is a red circle -----------------------------------
   The date sits inside it in white, which says "today" by itself
   — so the little "اليوم" caption that used to sit in the corner
   is gone, and the cell gets its space back.

   The red is mixed for cream, not for white: Apple's #FF3B30 on
   a warm sheet reads as a notification badge. This is closer to
   a red pencil — dark enough to carry white type at 6.3:1, warm
   enough to belong to the paper. */
:root           { --today-red: #C2452F; }
:root[data-theme="night"] { --today-red: #E0583F; }

.day__today { display: none; }

.day[data-today="1"] .day__num {
  display: grid;
  place-items: center;
  width: 1.42em;
  height: 1.42em;
  border-radius: 50%;
  background: var(--today-red);
  color: #FFF;
  font-weight: 600;
  text-shadow: none;
}
/* The numeral is a circle now, so the dots underneath need their
   gap back or the cell runs out of room. */
.day[data-today="1"] { gap: 4px; }

/* Selected *and* today: the circle stays, the selection ring goes
   round the cell as usual. */
/* The circle is already saying "today", so the selection ring beside
   it only has to be legible, not loud. */
.day[data-selected="1"][data-today="1"] { box-shadow: inset 0 0 0 1.5px var(--ink-900); }

/* The week row already draws its number in a circle — it only
   needs the same red. */
.wday[data-today="1"] .wday__num { background: var(--today-red); color: #FFF; }

/* A day with nothing on it still has to be readable — it is the
   one you are most likely to be looking for. */
/* --ink-400 was quiet enough while the numeral was 24px+ and counted
   as large text. At 22px it needs the next stop down to clear 4.5:1.
   Excluding today: this rule sits after the today rule and carries the
   same specificity, so without the :not() a today with nothing on it
   lost the white numeral inside its red circle. */
.day[data-empty="1"]:not([data-today="1"]) .day__num { color: var(--ink-500); }

/* ---- 11 · Primary actions in ink ------------------------------
   A filled blue button is the loudest thing that can happen to a
   sheet of paper. Ink is the strongest mark a page can carry and
   still be a page, and it inverts correctly at night, where the
   ink is light and the sheet is dark. */
.composer__add,
.lw__cta,
.ci__btn,
.sg__act--go {
  background: var(--ink-900);
  border-color: var(--ink-900);
  color: var(--paper);
}
.composer__add:hover,
.lw__cta:hover,
.ci__btn:hover,
.sg__act--go:hover { filter: none; background: var(--ink-800); border-color: var(--ink-800); }

/* ---- 12 · The day's progress, drawn thinner -------------------
   Same bar, same colour — the day's own area answers for it — at
   a third of the weight. Eight pixels of saturated colour is a
   banner; three is a line you have underlined. */
.progress { height: 3px; margin-bottom: 14px; background: var(--ink-200); }

/* ---- 13 · Legibility after flattening -------------------------
   Removing the tinted pill took away the contrast some of the row
   was relying on. `--task-ink` is chosen in JS as black-or-white
   against that tint, so on bare paper a row whose area is dark
   enough came out white on cream — a 1.17 ratio, which is to say
   invisible. Everything inside a row reads off the ink ramp now,
   and the area colour stays where it is still doing work: the
   checkbox and the dots. */
.task__time,
.task__menu,
.task__recur,
.task__proj { color: var(--ink-600); }
.task__num  { color: var(--ink-500); }
.task__recur,
.task__proj { border-color: var(--border-subtle); }

/* A dash standing in for a score you have not given yet still has
   to be seen — it is the prompt to go and give it. */
.lw__row b[data-empty="1"] { color: var(--ink-500); }

/* The faint end of the ramp carries real text at 11–13px, so at
   night it is lifted until it clears 4.5:1 on a dark sheet. */
:root[data-theme="night"] {
  --ink-400: #928979;
  --ink-500: #AEA594;
}

/* Sits on the composer's well rather than the sheet, which costs it
   the last fifth of a stop. */
.panel__settings { color: var(--ink-500); }

/* ---- 14 · The yellow of the notes ----------------------------
   #FFF3A0 is a screen yellow: on a cool grey page it passed, on a
   warm sheet it goes acid. This is the yellow of a legal pad —
   the same signal, mixed back toward the paper under it, and the
   same family as the week-number highlighter above.

   Only the light value moves. At night these two keep the bright
   yellow on purpose: their ink is forced dark in both themes, so
   darkening the paper under it would leave dark on dark. */
.hb-w--week,
.note-fab { background: #F4E9B6; }
:root[data-theme="night"] .hb-w--week,
:root[data-theme="night"] .note-fab { background: #FFF3A0; }

/* ---- 15 · The drawer takes room from the content --------------
   An overlay drawer slides a panel over whatever you were reading
   and dims the rest. With the app centred there is no need for
   that on a wide screen: the content gives up the width instead,
   compressing toward the inline start (the right, in RTL) while
   the menu occupies what it vacates. Nothing is covered, so
   nothing needs dimming.

   Below 1100px there is no width to give, so the drawer goes back
   to being an overlay with its scrim. */
.app { transition: padding var(--dur-soft) var(--ease-emph); }

@media (min-width: 1100px) {
  html.is-nav-open .app {
    /* padding-inline-end is the LEFT side under RTL — which is the
       side the drawer comes in on. */
    padding-inline-end: calc(max(clamp(14px, 3vw, 30px), env(safe-area-inset-left)) + min(282px, 82vw));
  }

  /* Kept clickable — it is still what closes the menu on a click
     past it — but there is nothing left to dim. */
  html.is-nav-open .nav__scrim { opacity: 0; visibility: visible; background: transparent; }

  /* The columns are 460px · 1fr · 300px, so every pixel the drawer took
     came out of the middle one: the day panel and the wheel held their
     width and the calendar collapsed to a third of itself. Switching all
     three to fractions of what they were spreads the loss, so everything
     narrows a little and slides toward the start together instead of one
     panel being crushed. The fractions are the tracks' own proportions
     at full width (460 : 476 : 300). */
  html.is-nav-open .layout {
    grid-template-columns: minmax(0, .97fr) minmax(0, 1fr) minmax(0, .63fr);
    transition: grid-template-columns var(--dur-soft) var(--ease-emph);
  }
  html.is-nav-open .layout--week {
    grid-template-columns: minmax(0, .58fr) minmax(0, 1fr);
  }
}

/* Below the third column, the same idea with two tracks. */
@media (min-width: 1100px) and (max-width: 1249px) {
  html.is-nav-open .layout { grid-template-columns: minmax(0, .58fr) minmax(0, 1fr); }
}

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

/* ============================================================
   16 · The projects page
   ============================================================ */

/* ---- The same paper as the dashboard -------------------------
   The page panels are sheets floating over the app; this one is
   a room of its own, so it gets the desk and its ruling rather
   than a blank card. The grid is the body's, repeated here
   because a dialog paints in the top layer, above the fixed
   backdrop behind the page. */
#projects-view {
  background:
    linear-gradient(to right,  var(--rule) 1px, transparent 1px) 0 0 / .8cm .8cm,
    linear-gradient(to bottom, var(--rule) 1px, transparent 1px) 0 0 / .8cm .8cm,
    var(--page-bg);
}

/* ---- Covers --------------------------------------------------
   A banner across the top of the card, bleeding to its edges —
   the card's own padding would otherwise frame it and make it
   look like a photo pasted in rather than the cover of a thing. */
.pm-cover {
  position: relative;
  container-type: inline-size;
  margin: -14px -16px 2px;
  aspect-ratio: 2 / 1;
  border-radius: calc(var(--card-radius) - 1px) calc(var(--card-radius) - 1px) 0 0;
  overflow: hidden;
  background: linear-gradient(140deg,
      color-mix(in srgb, var(--pc) 44%, var(--paper)),
      color-mix(in srgb, var(--pc) 13%, var(--paper)));
  display: grid;
  place-items: center;
}
.pm-cover--img { background: var(--ink-100) center / cover no-repeat; }

/* The ruling runs over a generated cover so it reads as part of
   the page; over a photograph it would just be dirt. */
.pm-cover:not(.pm-cover--img)::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right,  var(--rule) 1px, transparent 1px) 0 0 / .5cm .5cm,
    linear-gradient(to bottom, var(--rule) 1px, transparent 1px) 0 0 / .5cm .5cm;
}

/* The project's initial, standing in for a picture. */
.pm-cover__mark {
  position: relative;
  z-index: 1;
  font-family: var(--font-serif);
  font-size: clamp(52px, 24cqw, 78px);
  font-weight: 600;
  line-height: 1;
  color: color-mix(in srgb, var(--pc) 55%, var(--ink-900));
  opacity: .58;
}

/* ---- The cover on the board, where it can be changed ---------- */
.pm-meta__cover { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
/* The same 2:1 frame on the board. Capped by width rather than left to
   fill the meta card, which at full screen would have made it far taller
   than it needs to be — the cover is the project's face, not its
   wallpaper. */
.pm-meta__cover .pm-cover {
  margin: 0;
  max-width: 440px;
  aspect-ratio: 2 / 1;
  border-radius: var(--radius-md);
}

/* The card keeps its corners now that something is bleeding into
   them. */
.pm-card { overflow: hidden; }

/* The new-project button was a filled green with a coloured shadow —
   the one thing on the page still behaving like a web app. Ink, like
   every other primary action in this skin. */
.pm-new {
  background: var(--ink-900);
  color: var(--paper);
  box-shadow: none;
}
.pm-new:hover { background: var(--ink-800); box-shadow: none; }

/* ---- 17 · Topbar icon ----------------------------------------
   Matches the account picture beside it: same 38px, same circle,
   so the pair reads as one row of controls. */
.topicon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  background: var(--card-bg);
  color: var(--ink-600);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.topicon svg { width: 19px; height: 19px; }
.topicon:hover { color: var(--ink-900); border-color: var(--ink-400); }

/* ---- 19 · Legibility inside a project board -------------------
   Four marks on the kanban were sitting between 1.6:1 and 3.5:1.
   They predate this skin, but they are on a page this change
   touches and none of them is decorative: each one is a control
   or a count you are meant to read. */

/* The column's ✕ was --ink-300, which is a border colour. */
.pm-col__del { color: var(--ink-500); }
.pm-col__del:hover { color: var(--ink-900); }

/* The card count rides on the column's own colour, which is
   chosen to be a quiet tint — too quiet to set 11px type in. */
.pm-col__count { color: var(--ink-600); }

/* A status pill drawn in its own colour on a 14% wash of that
   same colour: same hue, same lightness, no contrast. Darkening
   the ink against the sheet is enough; the wash still carries
   the hue. */
.pm-status { color: color-mix(in srgb, var(--c) 42%, var(--ink-900)); }
:root[data-theme="night"] .pm-status { color: color-mix(in srgb, var(--c) 58%, var(--ink-900)); }

/* The done card's checkbox. The tick is white and the box carries it;
   an unticked box has no glyph at all, so there is nothing to recolour
   there — setting a generic colour on this button only overrode the
   white tick and left it dark ink on green.

   What it did need was a darker fill: white on #1F9D63 is 3.6:1, which
   is thin for an 11px mark. */
.pm-task__check { color: #FFF; }
.pm-task__check[aria-pressed="true"],
.pm-task__check[data-done="1"] { background: #17794A; border-color: #17794A; }

/* ============================================================
   20 · The card's task drawer
   ============================================================ */

/* The meta line and the chevron share the card's last row, so the
   arrow sits on the baseline of the counts it belongs to rather
   than floating in a corner of its own. */
.pm-card__footer {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pm-card__footer .pm-card__meta { flex: 1; min-width: 0; }

.pm-card__more {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  background: transparent;
  color: var(--ink-600);
  cursor: pointer;
  transition: transform var(--dur-snap) var(--ease-emph),
              color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.pm-card__more svg { width: 14px; height: 14px; }
.pm-card__more:hover { color: var(--ink-900); border-color: var(--ink-400); }
/* Points down to open, up once it is. */
.pm-card__more[aria-expanded="true"] { transform: rotate(180deg); color: var(--ink-900); }

/* An open card stops behaving like a tile and becomes a panel: the
   hover lift would be wrong under a list you are reading. */
.pm-card--open { cursor: default; }
.pm-card--open:hover { transform: none; }

.pm-mini {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--rule-line);
  cursor: default;
}

/* Capped and scrolling: a project with forty cards should not make
   its card taller than the screen. */
.pm-mini__list {
  display: flex;
  flex-direction: column;
  max-height: 190px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.pm-mini__row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 1px;
  border-bottom: 1px solid var(--rule);
}
.pm-mini__row:last-child { border-bottom: none; }
.pm-mini__row[data-done="1"] { opacity: .5; }
.pm-mini__row[data-done="1"] .pm-mini__text { text-decoration: line-through; }

.pm-mini__check {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--ink-300);
  border-radius: 5px;
  background: transparent;
  color: #FFF;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
}
.pm-mini__check[aria-pressed="true"] {
  background: var(--ink-600);
  border-color: var(--ink-600);
}

.pm-mini__text {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: var(--ink-800);
  overflow-wrap: anywhere;
}

/* Which column it is sitting in — the one thing from the board
   worth carrying into a glance. */
.pm-mini__col {
  flex: 0 0 auto;
  font-size: 10.5px;
  color: var(--ink-500);
  background: var(--ink-50);
  padding: 2px 7px;
  border-radius: 999px;
}

.pm-mini__empty {
  margin: 0;
  padding: 8px 1px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 12.5px;
  color: var(--ink-500);
}

.pm-mini__add {
  width: 100%;
  margin-top: 8px;
  padding: 8px 11px;
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink-800);
  font-family: var(--font-body);
  font-size: 12.5px;
}
.pm-mini__add::placeholder { color: var(--ink-500); }
.pm-mini__add:focus { outline: none; border-color: var(--ink-400); }

@media (prefers-reduced-motion: reduce) {
  .pm-card__more { transition: none; }
}

/* ---- 21 · The last three marks on the projects page -----------
   Same pattern as the status pill: ink drawn in its own colour on
   a 14% wash of that colour is the same hue at the same lightness,
   so it reads as a tint rather than as type. Darkening against the
   sheet keeps the hue in the wash and puts the contrast back. */
.pm-area { color: color-mix(in srgb, var(--c) 42%, var(--ink-900)); }
:root[data-theme="night"] .pm-area { color: color-mix(in srgb, var(--c) 58%, var(--ink-900)); }

/* The high-priority flag: a mid red on cream, and the same red on a
   dark sheet at night. */
.pm-flag { color: #B2342C; }
:root[data-theme="night"] .pm-flag { color: #F08A7C; }

/* The drawer's checkbox: the tick has to be the sheet's colour, not
   white, or at night it is white on a light fill. Same correction
   the day panel's checkbox needed. */
.pm-mini__check[aria-pressed="true"] { color: var(--paper); }

/* ---- 22 · Each card is its own ---------------------------------
   A grid row is stretched to its tallest cell, so opening one card's
   drawer pulled every card beside it to the same height and left them
   standing empty underneath — which read as though one press had
   opened all of them. Each card sizes to what it holds instead; a
   ragged row is the honest picture of a shelf where one book is open. */
.pm-grid { align-items: start; }

/* ---- 23 · The cover on the project page ------------------------
   It was capped at 440px so that a full screen would not turn the
   header into a wall. That is the wrong trade on the page you opened
   in order to look AT the project: the cover runs the header card's
   full width now and bleeds to its edges, the way it does on a card
   out on the shelf.

   The height is still held. Past about 320px the fields drop below
   the fold and the banner stops being a header — so on a wide screen
   the picture keeps all of its width and loses a band off the top and
   bottom, which is the crop a banner is meant to take. */
.pm-meta { overflow: hidden; }

.pm-meta__cover .pm-cover {
  margin: -14px -18px 0;
  max-width: none;
  /* The header is a flex column, so the banner's height is its MAIN size
     and a short panel was shrinking it below the cap — the ratio moved
     with the window. It keeps what it is given. */
  flex: none;
  aspect-ratio: 2 / 1;
  max-height: 320px;
  border-radius: calc(var(--card-radius) - 1px) calc(var(--card-radius) - 1px) 0 0;
}

/* ============================================================
   24 · The wheel, trimmed — and the shelf under it
   ============================================================ */

/* ---- The wheel beside the calendar ---------------------------
   The widget listed all eight areas with their scores under the
   chart, which is the chart again in words: the arcs already say
   which area is long and which is short. On a week nobody has
   rated yet it says it eight times over, in dashes.

   So in the side column the list goes and the card keeps what is
   actually a summary — the score, the wheel, the one button that
   starts a rating, and the way through to the log and the
   suggestions. The list stays in week view, where the card lies
   on its side and has the width for it, and the full page has
   always had everything. */
.layout:not(.layout--week) .lw__legend { display: none; }

/* With the list gone the card was still taller than the calendar it
   stands beside, and the chart is the only part with room to give. So
   it stops being a fixed drawing and becomes the slack in the card:
   everything else keeps its height, the wheel takes what is left, and
   the card as a whole comes out level with the month next to it. A
   floor under it so it never collapses to a token. */
.layout:not(.layout--week) .lw { gap: 10px; justify-content: space-between; }
.layout:not(.layout--week) .lw__wheel {
  flex: none;
  width: 170px;
  max-width: 100%;
  margin-inline: auto;
  /* The longest name reaches the viewBox edge at this size and an SVG
     clips at its box by default. The card has padding to spare, so let
     it hang over rather than lose a letter. */
  overflow: visible;
}

@media (min-width: 1250px) {
  /* Level bottoms, whatever the month is: the card takes the row's
     height rather than its own, so the band underneath starts at one
     line across both. */
  .layout:not(.layout--week) .layout__wheel { align-self: stretch; }
  .layout:not(.layout--week) .layout__wheel .lw { height: 100%; }
}

/* ---- The shelf -----------------------------------------------
   What is running, in the band the calendar and the wheel leave
   empty underneath them. A cover and a name — enough to recognise
   a project across the room; the counts and the board are one
   press away. */
.layout__shelf { min-width: 0; }

@media (min-width: 1000px) {
  .layout__shelf { grid-column: 2; grid-row: 2; }
  /* The day panel spans both rows instead of sitting in the first one.
     Otherwise it — the tallest thing on the page — sets the height of
     row 1, and the shelf starts below IT, leaving a hole under the
     calendar. Spanning takes it out of that measurement, so the band
     begins where the calendar and the wheel actually end. */
  .layout__panel { grid-row: 1 / 3; }
}
@media (min-width: 1250px) {
  .layout:not(.layout--week) .layout__shelf { grid-column: 2 / 4; grid-row: 2; }
  /* In week view the wheel is already lying in that band. */
  .layout--week .layout__shelf { grid-column: 2; grid-row: 3; }
}

.shelf__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 2px 2px 12px;
}
.shelf__title {
  margin: 0;
  margin-inline-end: auto;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 13px;
  color: var(--ink-700);
}
.shelf__more {
  padding: 3px 10px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-500);
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
}
.shelf__more:hover { background: var(--ink-50); color: var(--ink-900); }

.shelf__row {
  display: grid;
  /* 140, not 156: the tray's own padding took enough off a phone's width
     that two cards no longer fitted and the strip went single file. */
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}

.shelf__card {
  display: flex;
  flex-direction: column;
  padding: 0 0 10px;
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  text-align: start;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.shelf__card:hover { transform: translateY(-2px); box-shadow: var(--card-shadow-hover); }
:root[data-theme="night"] .shelf__card:hover { background: #2C2C2E; }

/* The cover is built by the same function the cards use, which bleeds
   it past a card's padding. There is none here — it is the top of the
   card — so the negative margins come off. */
.shelf__card .pm-cover {
  margin: 0 0 8px;
  border-radius: calc(var(--card-radius) - 1px) calc(var(--card-radius) - 1px) 0 0;
}
.shelf__card .pm-cover__mark { font-size: clamp(30px, 26cqw, 48px); }

.shelf__name {
  padding: 0 11px;
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: 13px;
  line-height: 1.35;
  color: var(--ink-900);
  /* Two lines, then an ellipsis: a long name must not set the height of
     every card on the shelf. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.shelf__meta {
  padding: 3px 11px 0;
  font-size: 11.5px;
  color: var(--ink-500);
}

/* ---- 25 · The shelf gets a surface of its own -----------------
   The project cards were standing straight on the desk, which read
   as more loose cards rather than a part of the page with a job.
   They sit on a tray now: a warmer tone than the paper above it,
   dark enough to cover the ruling, so the band reads as one thing
   and the covers inside it have something to be light against. */
/* Slate rather than another shade of kraft. The point of the tray is
   that the band reads as its own section, and a warm tone a few steps
   off the paper kept being read as the paper in a different light.
   Cool against a warm page separates at a glance. */
:root {
  --shelf-bg: #DCE2E8;
  --shelf-line: #C7D0DA;
}
:root[data-theme="night"] {
  --shelf-bg: #1B1F24;
  --shelf-line: #2B323B;
}

.layout__shelf {
  padding: 13px 16px 16px;
  border: 1px solid var(--shelf-line);
  border-radius: var(--card-radius);
  background: var(--shelf-bg);
}
.shelf__head { margin: 0 2px 11px; }
.shelf__more:hover { background: var(--paper); }

/* The night red was tuned to glow on a dark page and ended up too light
   to carry white text: 3.73:1 on the date inside today's circle. Pulled
   down until the number reads (4.62:1), while the disc itself still
   clears 3:1 against the card it sits on. */
:root[data-theme="night"] { --today-red: #C94B35; }

/* ============================================================
   26 · The board reads first
   ------------------------------------------------------------
   The project header ran the full width — cover, name, five
   fields, the colours, the description — and the columns began
   under all of it. On the page you opened to work, the work was
   below the fold and the paperwork was above it.

   The columns come first now. On anything wide enough the header
   becomes a side column beside them; below that it simply moves
   under them, which costs the name nothing — the panel's own bar
   has been carrying it all along.

   A container query, not a viewport one: this panel is a dialog
   whose width is its own business, and at the same screen size it
   is one width floating and another full screen.
   ============================================================ */
/* The container is the panel, not the body: an element can never
   answer a query about itself, and the body is the thing being laid
   out. The dialog's padding is the difference between the two. */
#projects-view { container-type: inline-size; }

.pm-body--board .pm-board { order: 0; }
.pm-body--board .pm-meta  { order: 1; }

@container (min-width: 880px) {
  .pm-body--board {
    display: grid;
    grid-template-columns: 278px minmax(0, 1fr);
    align-items: start;
    gap: 18px;
  }
  /* Column 1 is the start edge, which RTL puts on the right — where the
     project's own details sit, the way a page begins with what it is
     about. The columns take the rest. */
  .pm-body--board .pm-meta  { grid-area: 1 / 1; }
  .pm-body--board .pm-board { grid-area: 1 / 2; }

  /* A column, so the header's rows stop being rows. The name takes a
     line of its own and the chip and the delete button share the next;
     the five fields pair up two to a line instead of stretching into
     one. */
  .pm-body--board .pm-meta__row { gap: 8px; }
  .pm-body--board .pm-meta__name {
    flex: 1 1 100%;
    min-width: 0;
    font-size: 17px;
  }
  .pm-body--board .pm-meta__row--fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .pm-body--board .pm-palette {
    grid-column: 1 / -1;
    margin-inline-start: 0;
    align-self: start;
    padding-bottom: 0;
    flex-wrap: wrap;
  }
  .pm-body--board .pm-meta__desc { font-size: 12.5px; }
}

/* ---- 27 · One control on the cover ----------------------------
   The row of four under the picture — fetch, search, change,
   remove — was a toolbar under something that is not a toolbar's
   subject. It is three dots in the corner of the cover now, idle
   until the pointer is over the picture.

   Shown outright wherever there is no pointer to hover with: on a
   phone an on-hover control is no control at all. */
.pm-coverdots {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  z-index: 2;
  width: 28px;
  height: 28px;
  padding: 0 0 7px;        /* the glyph sits low in its line box */
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: color-mix(in srgb, #1B1712 55%, transparent);
  color: #FFF;
  font-size: 15px;
  line-height: 1;
  letter-spacing: .5px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
}
.pm-cover:hover .pm-coverdots,
.pm-coverdots:focus-visible { opacity: 1; }
.pm-coverdots:hover { background: color-mix(in srgb, #1B1712 78%, transparent); }

@media (hover: none) {
  .pm-coverdots { opacity: 1; }
}

/* The credit is not a control and does not come and go with one. */
.pm-covercredit {
  display: block;
  margin-top: -2px;
  font-size: 11px;
  color: var(--ink-500);
}

/* ---- 28 · The board takes the window --------------------------
   Every other panel is a sheet floating over the page, centred and
   capped, because it is something to read. A board is not: it is
   the desk you work at, and the details column belongs against the
   right edge rather than a column's width in from it.

   So on a board — and only on a board — the panel takes the window
   with a margin, and its body stops capping itself at 1120 and
   centring what is left. The list of projects keeps the sheet: a
   shelf of cards has no reason to span a wide screen.

   Fullscreen is excluded by name: that one already took the window
   and sets its own padding. */
#projects-view:not(.pm-view--full):has(.pm-body--board) {
  width: calc((100vw - 48px) / var(--zoom));
  padding-inline: clamp(14px, 2vw, 26px);
}

/* A phone has no margin to give: the panel is the screen there whatever
   is in it, which the rule above would otherwise undo. */
@media (max-width: 640px) {
  #projects-view:not(.pm-view--full):has(.pm-body--board) {
    width: calc(100vw / var(--zoom));
  }
}

.pm-body--board { max-width: none; }

/* ---- 29 · The bar lines up with the board --------------------
   The bar kept the sheet's 1120 cap after the board stopped
   obeying it, so "كل المشاريع" and the project's name sat a
   centred box's width in from the details card they belong over.
   On a board the bar spans what the body spans. */
#projects-view:has(.pm-body--board) .pm-view__bar { max-width: none; }

/* The way out. The ✕ beside it steps up one level — right for a
   page with a level inside it, wrong for "take me back" — so the
   house does the other half, from wherever you are. */
.pm-home {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink-500);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.pm-home svg { width: 17px; height: 17px; }
.pm-home:hover { color: var(--ink-900); border-color: var(--ink-400); }

/* ============================================================
   30 · The menu, read at arm's length
   ------------------------------------------------------------
   The rows were 13.5px of grey text beside a grey glyph — ten of
   them, all the same weight and the same colour, so finding one
   meant reading the list rather than recognising a row in it.

   Bigger type, and every icon gets its own colour on a tinted
   chip. The chip is what does the separating: a thin stroke in a
   bright hue would have had to be dark enough to read against
   cream, and the hues that survive that are the dull half of the
   wheel. A block of colour with a deep version of the same hue
   drawn on it keeps the colour AND the legibility.

   The drawer takes the extra width this needs — it was asked for.
   ============================================================ */
.nav__panel { width: min(304px, 84vw); }

/* The push on a wide screen has to agree with the drawer's width,
   or the page compresses by the wrong amount. */
@media (min-width: 1100px) {
  html.is-nav-open .app {
    padding-inline-end: calc(max(clamp(14px, 3vw, 30px), env(safe-area-inset-left)) + min(304px, 84vw));
  }
}

.nav__glabel { font-size: 11px; margin-bottom: 7px; }

.nav__item {
  gap: 12px;
  padding: 8px 9px;
  font-size: 15px;
}

.nav__icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--c, var(--ink-400)) 15%, var(--paper));
  /* 56, not 68: the glyph has to clear 3:1 against its own chip, and
     yellow is the hue that decides that for all of them — at 68 it sat
     at 2.56. The chip keeps the colour; the glyph keeps the legibility. */
  color: color-mix(in srgb, var(--c, var(--ink-400)) 56%, var(--ink-900));
}
.nav__icon svg { width: 18px; height: 18px; }

/* In the dark the chip lifts off the surface instead of tinting down
   into it, and the glyph goes the other way — toward the light. */
:root[data-theme="night"] .nav__icon {
  background: color-mix(in srgb, var(--c, var(--ink-400)) 22%, var(--card-bg));
  color: color-mix(in srgb, var(--c, var(--ink-400)) 80%, #FFF);
}

/* The sub-list lines up under the label now that the chip is wider. */
.nav__sub { padding-inline-start: 32px; }
.nav__subitem { font-size: 13.5px; }

/* A toggle that is on turned its label the flat system blue, which is
   3.8:1 on this paper — under the bar for 15px text now that the rows
   are bigger. Deepened in daylight only; the dark theme's blue is
   already lighter than its background. */
.nav__item--on { color: color-mix(in srgb, var(--info) 80%, var(--ink-900)); }
:root[data-theme="night"] .nav__item--on { color: var(--info); }

/* ---- 31 · Weight on the menu ----------------------------------
   The rows were regular weight, which at this size reads as prose:
   a list of sentences rather than a list of destinations. Bold and
   a point larger — a label you pick from, not one you read.

   The group headings go up with them, or the rows swallow them. */
.nav__item {
  font-size: 16px;
  font-weight: var(--fw-bold);
}
.nav__glabel { font-size: 11.5px; }
.nav__subitem { font-weight: var(--fw-semibold); }

/* The shelf card's bar sits in the card's own padding, under the count. */
.shelf__card .pm-progress { padding: 6px 11px 0; }
.shelf__card .pm-progress__track { height: 5px; }
.shelf__card .pm-progress__num { font-size: 10.5px; min-width: 28px; }

/* ============================================================
   32 · The microphone
   ------------------------------------------------------------
   A sheet with three faces: listening, what it heard, and the
   form it filled from that. The third is the one that matters —
   a reading you can correct before it is written down.
   ============================================================ */
.topicon--mic svg { width: 18px; height: 18px; }

.voice #voice-body { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }

.voice__note {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-600);
}
.voice__note--bad { color: #B2342C; }
:root[data-theme="night"] .voice__note--bad { color: #F08A7C; }

/* ---- Listening ---- */
.voice__pulse {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  height: 46px;
}
.voice__pulse i {
  width: 7px;
  border-radius: 999px;
  background: var(--ink-400);
  animation: voice-bar 1s var(--ease-soft) infinite;
}
.voice__pulse i:nth-child(1) { height: 16px; animation-delay: 0s; }
.voice__pulse i:nth-child(2) { height: 30px; animation-delay: .16s; }
.voice__pulse i:nth-child(3) { height: 20px; animation-delay: .32s; }
@keyframes voice-bar {
  0%, 100% { transform: scaleY(.45); }
  50%      { transform: scaleY(1); }
}
@media (prefers-reduced-motion: reduce) {
  .voice__pulse i { animation: none; }
}

.voice__heard {
  margin: 0;
  min-height: 1.6em;
  text-align: center;
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-800);
}

/* ---- The two plain buttons ---- */
.voice__start,
.voice__stop,
.voice__add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: 12px;
  background: var(--ink-900);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: var(--fw-bold);
  cursor: pointer;
}
.voice__start:hover,
.voice__stop:hover,
.voice__add:hover { background: var(--ink-800); }
.voice__start svg { width: 19px; height: 19px; }

.voice__again {
  width: 100%;
  padding: 9px;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--card-bg);
  color: var(--ink-600);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: var(--fw-semibold);
  cursor: pointer;
}
.voice__again:hover { color: var(--ink-900); border-color: var(--ink-400); }

/* ---- Typing instead ---- */
.voice__typebox { border-top: 1px solid var(--border-subtle); padding-top: 12px; }
.voice__type {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink-800);
  font-family: var(--font-body);
  font-size: 13.5px;
}
.voice__type:focus { outline: none; border-color: var(--info); }

/* ---- The reading, as a form ---- */
.voice__form { display: flex; flex-direction: column; gap: 12px; }

/* What was heard, kept in view: a wrong guess below explains itself. */
.voice__said {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 13px;
  font-style: italic;
  line-height: 1.6;
  color: var(--ink-500);
}

.voice__text {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--ink-50);
  color: var(--ink-900);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
}
.voice__text:focus { outline: none; border-color: var(--info); }

.voice__fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 10px;
}
.voice__actions { display: flex; flex-direction: column; gap: 8px; }

/* Stopped, waiting for the recogniser's last word. */
.voice__pulse--done i { animation: none; opacity: .45; }
.voice__stop[disabled] { opacity: .6; cursor: default; }

/* The browser's own word for what went wrong. Small, and only on the
   failure face: "nothing happened" is not something anyone can act on. */
.voice__code {
  margin: -8px 0 0;
  font-family: var(--font-num);
  font-size: 11px;
  color: var(--ink-400);
}

/* ============================================================
   33 · The microphone, where you can find it
   ============================================================ */

/* ---- The pair, centred in the bar -----------------------------
   The two icons that OPEN something sat in the right cluster with
   the account picture, which made them read as settings. They are
   a pair of their own now, standing in the middle of the gap the
   bar leaves between the title and the pills.

   Centred by two flexible halves rather than by margin:auto — the
   title takes one and an empty box takes the other, so the pair
   lands midway between the end of the title and the start of the
   pills whatever either of them is wide. */
.topbar__quick {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Two flexible halves were the obvious way to centre the pair and the
   wrong one: this bar WRAPS — the title and the account sit on one
   line, the pills and the month on the next — and a wrapped line has
   no free space left to share. The halves grew by nothing and the pair
   stayed glued to the title.
   
   So it is lifted out of the flow and hung in the middle of the bar:
   half way across, half way down, which on two rows is exactly the
   space between the title above and the year bar below. */
/* 1080, measured: at 900 the centre of the bar is still underneath the
   year pill, and a control sitting on top of another control is worse
   than one sitting beside the title. */
@media (min-width: 1080px) {
  .topbar { position: relative; }
  .topbar__quick {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
  .topbar__gap { display: none; }
}

/* Red, because it is the one control here that starts a recording —
   and the app already has exactly one red, the circle around today. */
.topicon--mic {
  color: var(--today-red);
  border-color: color-mix(in srgb, var(--today-red) 32%, transparent);
}
.topicon--mic:hover {
  color: var(--today-red);
  border-color: var(--today-red);
  background: color-mix(in srgb, var(--today-red) 9%, var(--card-bg));
}

/* Narrow, there is no middle to hang anything in — and after the title
   is the wrong place to fall back to: the bar wraps there, the pair
   lands at the far edge of its line, and the projects icon ended up
   underneath the menu button, unreachable. Measured with
   elementFromPoint, which answered "nav__toggle".
   
   So below the centred width the pair sits where it always did: beside
   the account picture, which keeps the outer edge. */
.topbar__gap { display: none; }
.avatar { order: -2; }
.topbar__quick { order: -1; }

@media (min-width: 1080px) {
  .avatar, .topbar__quick { order: 0; }
}

/* ---- The big one, bottom right --------------------------------
   The bar's icon is small and at the top of a long page. This one is
   where a thumb already is, and it is the size of a thumb. */
.voice-fab {
  position: fixed;
  right: calc(14px / var(--zoom));
  bottom: calc(18px / var(--zoom));
  z-index: 60;
  zoom: var(--zoom);
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  background: var(--today-red);
  color: #FFF;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--today-red) 32%, transparent),
              0 10px 28px rgba(0, 0, 0, .18);
}
.voice-fab svg { width: 25px; height: 25px; }
.voice-fab:hover { background: color-mix(in srgb, var(--today-red) 88%, #000); }

/* It rides over the app, so it goes when the app does. */
.app[hidden] ~ .voice-fab { display: none; }
