/* The design tokens (colours, radii, shadows, fonts, light and dark) are in
   tokens.css, which index.html loads before this file. */

/* ==========================================================================
   Reset and base
   ========================================================================== */

* { box-sizing: border-box; }
html, body { margin: 0; }
/* No double-tap zoom anywhere; the page is an app, not a document. */
html { touch-action: manipulation; }

body {
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ==========================================================================
   Primitives
   ========================================================================== */

/* --- Button ------------------------------------------------------------- */
.btn {
  border: 0;
  border-radius: var(--r-btn);
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 800;
  background: var(--pill);
  color: var(--ink);
  line-height: 1.2;
  white-space: nowrap;
}
.btn { transition: background .18s, color .18s, border-color .18s, box-shadow .18s, transform .12s, filter .18s; }
.btn:hover { filter: brightness(.97); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--ok { background: var(--ok); color: var(--on-ink); }
.btn--danger { background: none; color: var(--warn); padding-left: 8px; padding-right: 8px; }
.btn--outline {
  background: var(--card); border: 1px solid var(--line-strong);
  border-radius: var(--r-pill); padding: 10px 19px; font-size: 14px; font-weight: 700;
}
.btn--soft {
  background: var(--card); border: 1px solid var(--line-strong);
  border-radius: 9px; padding: 7px 13px; font-size: 13px; font-weight: 700;
}
.btn--chip {
  background: var(--pill); border: 0; border-radius: var(--r-pill);
  padding: 7px 13px; font-size: 12.5px; font-weight: 700;
}
.btn--link {
  background: none; border: 0; padding: 4px 2px; font-size: 13px; font-weight: 400;
  color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px;
}
.btn--sm { padding: 9px 15px; font-size: 14px; }
/* Icon-only, round, sized to sit level with the outline buttons beside it. */
.histbtn {
  flex: none; width: 38px; height: 38px; padding: 0;
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  background: var(--card); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.histbtn { transition: color .18s, border-color .18s, transform .12s, opacity .18s; }
.histbtn:not(:disabled):hover { color: var(--ink); border-color: var(--muted-2); }
.histbtn:not(:disabled):active { transform: scale(.92); }
.histbtn:disabled { opacity: .4; cursor: default; }
.btn--lg { padding: 13px 26px; font-size: 16px; }
.btn[disabled] { opacity: .5; cursor: default; }

/* --- Pill --------------------------------------------------------------- */
.pill {
  border: 0;
  background: var(--pill);
  border-radius: var(--r-pill);
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.pill { transition: background .18s, color .18s, transform .12s; }
.pill:active { transform: scale(.96); }
.pill[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.pill:hover:not([aria-pressed="true"]) { background: var(--hover); }
.pill__dot { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.pillgroup { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; min-width: 0; }

/* --- Stepper ------------------------------------------------------------ */
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper__btn {
  border: 0; background: var(--pill); border-radius: var(--r-field);
  width: 34px; height: 32px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: var(--muted); flex: none; padding: 0;
}
.stepper__btn:hover { background: var(--hover); }
.stepper__value { font-size: 15px; font-weight: 800; min-width: 68px; text-align: center; }
.stepper--tight .stepper__btn { width: 26px; height: 24px; border-radius: 7px; background: var(--card); font-size: 14px; }
.stepper--tight .stepper__value {
  font-size: 13px; font-weight: 400; color: var(--muted-2);
  min-width: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* --- Tag ---------------------------------------------------------------- */
.tag {
  font-size: 11px; font-weight: 700; border-radius: 5px; padding: 2px 7px;
  line-height: 1.45; flex: none; white-space: nowrap;
}
.tag--high { background: var(--warn); color: var(--on-ink); }
/* the day a card sits on, worn on the radar when All tasks is on */
.tag--day { background: var(--accent-soft); color: var(--accent-ink); font-size: 11px; font-weight: 800; border-radius: 6px; padding: 2px 7px; }
.tag--today { background: var(--accent); color: var(--on-accent); font-size: 12px; border-radius: 7px; padding: 3px 10px; }
.tag--count {
  background: var(--pill); color: var(--muted-2); border-radius: var(--r-pill);
  min-width: 22px; text-align: center; padding: 2px 7px; font-size: 12px; font-weight: 700;
}

/* --- Fields ------------------------------------------------------------- */
.field {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--r-field);
  padding: 9px 12px;
  font-size: 14px;
  color: var(--ink);
  max-width: 100%;
  min-width: 0;
}
.field::placeholder { color: var(--faint); }
.field--grow { flex: 1; min-width: 170px; }
/*
 * A <select> is sized by its widest option in some engines, and the "After"
 * menu carries whole project titles — Safari will not shrink one below that,
 * min-width: 0 or not. Dropping the native appearance takes its intrinsic
 * sizing out of the picture, and the caret is drawn back on by hand.
 */
select.field {
  width: 100%;
  appearance: none; -webkit-appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%238A8F9A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 4.5l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 11px 11px;
  text-overflow: ellipsis;
}
.srow__value > .field { max-width: 100%; min-width: 0; }
.field--full { width: 100%; }
textarea.field { font-family: var(--mono); font-size: 13px; line-height: 1.45; resize: vertical; }
/* prose, not a backup blob: the quest's "why" and a quarter's wrap-up */
textarea.field--prose { font-family: var(--font); font-size: 14px; }

/* --- Meta line ---------------------------------------------------------- */
.meta { display: flex; gap: 2px 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted-2); }
.meta--warn { color: var(--warn); font-weight: 700; }
.duesoon { color: var(--warn); font-weight: 700; }

/* --- Progress bar ------------------------------------------------------- */
.progress { display: block; height: 4px; border-radius: var(--r-pill); background: var(--line-faint); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: var(--r-pill); transition: width .3s ease; }

/* A reviewer's board says so, next to the name. */
.demo-tag {
  display: inline-block; vertical-align: middle; margin-left: 8px;
  font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; line-height: 1;
  color: var(--accent); background: var(--accent-soft); border-radius: var(--r-pill); padding: 4px 7px;
}

/* --- The conflict sheet's two columns ----------------------------------- */
.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.diff__side { background: var(--field); border: 1px solid var(--line); border-radius: var(--r-field); padding: 10px 12px; min-width: 0; }
.diff__side h4 { margin: 0 0 6px; font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); }
.diff__side ul { margin: 0; padding-left: 16px; font-size: 13px; line-height: 1.45; }
.diff__side li { overflow-wrap: anywhere; }
.diff__none { margin: 0; font-size: 13px; color: var(--muted); }
@media (max-width: 720px) { .diff { grid-template-columns: 1fr; } }

/* --- Icons -------------------------------------------------------------- */
.icon { flex: none; }
.icon--loop { width: 14px; height: 14px; color: var(--muted); vertical-align: -2px; }
/* the same loop on a task that repeats, in the accent so it reads as its own thing */
.card__repeat { display: inline-flex; flex: none; margin-right: 5px; }
.card__repeat .icon--loop { color: var(--accent); }
.icon--chev { width: 11px; height: 11px; color: var(--faint-2); transition: transform .15s; }
[aria-expanded="true"] > .icon--chev { transform: rotate(90deg); }
.icon--caret { width: 11px; height: 11px; transition: transform .15s; }
.icon--hist { width: 17px; height: 17px; }
.icon--gear { width: 17px; height: 17px; }
[aria-expanded="true"] .icon--caret { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ==========================================================================
   App shell
   ========================================================================== */

.top {
  display: flex; align-items: center; gap: 20px;
  padding: 16px 20px; flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; gap: 1px; min-width: 180px; }
.brand h1 { font-size: 27px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.brand .date { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.savestat { font-size: 12px; color: var(--ok); display: inline-flex; align-items: center; gap: 6px; }
.savestat.is-bad { color: var(--warn); font-weight: 700; }
.savestat .icon { width: 12px; height: 12px; }
.savestat .icon--spin { color: var(--muted); animation: turn .9s linear infinite; }
.savestat--compact { vertical-align: -2px; }
@keyframes turn { to { transform: rotate(360deg); } }
.savestat button {
  background: none; border: 0; padding: 0 0 0 6px; font-size: 12px;
  font-weight: 800; color: var(--accent); text-decoration: underline;
}

.modes { display: flex; align-items: center; gap: 4px; background: var(--pill); border-radius: var(--r-pill); padding: 5px; position: relative; }
/* the pill that slides to whichever view is on; the buttons sit on top of it */
.modes__thumb {
  position: absolute; top: 5px; bottom: 5px; left: var(--x, 5px); width: var(--w, 0);
  border-radius: var(--r-pill); background: var(--ink);
  transition: left .28s cubic-bezier(.2, .8, .2, 1), width .28s cubic-bezier(.2, .8, .2, 1);
  pointer-events: none;
}
.modes button { position: relative; z-index: 1; }
.modes button {
  border: 0; background: none; color: var(--muted);
  font-size: 14.5px; font-weight: 700; padding: 9px 20px; border-radius: var(--r-pill);
}
.modes button { transition: color .2s; }
.modes button[aria-pressed="true"] { color: var(--on-ink); }

.addbar { flex: 1; min-width: 300px; max-width: 720px; display: flex; align-items: stretch; position: relative; }
/* The add field is capped, so the trailing controls take the remaining slack
   and finish the row against the right edge. */
.top__actions {
  margin-left: auto; display: flex; align-items: center;
  gap: 12px; flex-wrap: wrap; justify-content: flex-end;
}
.addbar input {
  flex: 1; min-width: 0; border: 0; background: var(--card);
  border-radius: 12px 0 0 12px; padding: 13px 18px; font-size: 14.5px;
}
.addbar input:focus { outline: none; }
.addbar:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 12px; }
.addbar__go {
  border: 0; background: var(--accent); color: var(--on-accent);
  font-size: 15px; font-weight: 700; padding: 13px 22px;
}
.addbar__caret {
  border: 0; background: var(--accent); color: var(--on-accent); padding: 13px 12px;
  border-left: 1px solid rgba(255, 255, 255, .25); border-radius: 0 12px 12px 0;
  display: flex; align-items: center;
}
.addmenu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 25;
  background: var(--card); border-radius: 12px; padding: 6px; min-width: 280px;
  box-shadow: 0 12px 32px rgba(31, 36, 48, .22);
}
.addmenu button {
  display: block; width: 100%; text-align: left; border: 0; background: none;
  border-radius: 8px; padding: 10px 12px; font-weight: 800; font-size: 14.5px;
}
.addmenu button:hover, .addmenu button:focus-visible { background: var(--accent-soft); }
.addmenu span { display: block; font-weight: 400; font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ==========================================================================
   Plan view
   ========================================================================== */

/*
 * On a desktop the page itself never scrolls. The header is fixed height and
 * whatever view is showing takes the rest; inside it, the rail and the week
 * each scroll on their own, so nothing has to be scrolled twice to reach.
 */
@media (min-width: 721px) {
  html, body { height: 100%; overflow: hidden; }
  #app { height: 100dvh; display: flex; flex-direction: column; }
  .top { flex: none; }
}

.plan {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px;
  padding: 0 20px 20px; align-items: stretch;
}

/* --- radar rail --------------------------------------------------------- */
.rail {
  background: var(--card); border-radius: var(--r-panel); padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
  min-height: 0; overflow: auto;
}
.rail > * { flex: none; }
/* The title, the switch and the caret share one centre line; "All tasks" hangs under its switch. */
.rail__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px 10px; flex-wrap: wrap; }
.rail__top h2 { white-space: nowrap; line-height: 20px; }
/* two chips no longer fit beside the title; they drop under it, right-aligned */
.rail__acts { display: flex; align-items: flex-start; gap: 6px; flex: none; margin-left: auto; }
.rail__acts .foldall { margin-top: -5px; }
.rail__acts .btn--chip[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
/* All tasks: a small switch with its name under it, on the rail and in the phone's drawer. */
.alltasks { display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.alltasks__text { font-size: 10.5px; font-weight: 700; color: var(--muted); white-space: nowrap; letter-spacing: .01em; }
/* Expand all / Collapse all as one caret: down to open every section, up to fold them. */
.foldall {
  width: 34px; height: 30px; padding: 0; flex: none; border: 0; cursor: pointer;
  background: var(--pill); border-radius: var(--r-pill); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.foldall .icon--caret { width: 12px; height: 12px; transition: transform .15s; }
.foldall[aria-expanded="true"] .icon--caret { transform: rotate(180deg); }
.rail__top h2 { font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.rail__sub { font-size: 12.5px; color: var(--muted-2); margin-top: -6px; }

.section {
  border: 1px dashed var(--dash); border-radius: 12px; padding: 12px 13px;
  display: flex; flex-direction: column; gap: 8px;
}
.section__head {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: none; border: 0; padding: 0; text-align: left;
  font-size: 14.5px; font-weight: 800; line-height: 1.25;
}
.section__dot { width: 11px; height: 11px; border-radius: 3px; background: var(--c); flex: none; }
.section__label { flex: 1; min-width: 0; }
.section__hint { font-size: 12.5px; line-height: 1.45; color: var(--muted-2); text-wrap: pretty; }
.section__peek { font-size: 13px; color: var(--muted-2); line-height: 1.7; padding-left: 26px; }
.section__empty { font-size: 12.5px; color: var(--faint-2); }
.section__list { display: flex; flex-direction: column; gap: 10px; }

/* --- week --------------------------------------------------------------- */
.week { display: flex; flex-direction: column; gap: 14px; min-width: 0; min-height: 0; }
.weekbar { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.weekbar h2 { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.legend { display: flex; align-items: center; gap: 16px; flex: 1; flex-wrap: wrap; min-width: 220px; }
.legend span { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--ink-2); }
.legend i { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.legend i.deep { background: var(--deep); }
.legend i.lunch { background: var(--lunch); }
.legend i.mtg { background: var(--mtg); }
.legend i.free { background: var(--card); border: 1px solid var(--line-strong); }

.weekscroll { flex: 1; min-height: 0; overflow: auto; padding-bottom: 6px; display: flex; flex-direction: column; }
/* Six columns need real room; below this the week scrolls sideways rather than
   squeezing the cards, which is the normal case on an iPad anyway. */
/* The columns fill whatever height the window gives the week, so a short
   window shows whole columns and a tall one has no dead space under them;
   only a day with more on it than fits makes the week scroll. */
.days {
  display: grid;
  grid-template-columns: repeat(5, minmax(186px, 1fr)) minmax(170px, .9fr);
  gap: 14px; align-items: stretch; min-width: 1170px;
  /* its height is measured and set inline (ui/scale.js); never shrinks below its content */
  flex: none;
}

.day {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
  padding: 14px; display: flex; flex-direction: column; gap: 10px; min-height: 320px;
}
.day.is-today { background: var(--today-bg); border: 2px solid var(--accent); padding: 13px; }
.day.is-past { opacity: .68; }
.day__head { display: flex; align-items: baseline; gap: 7px; min-width: 0; flex-wrap: wrap; }
.day__name { font-size: 19px; font-weight: 800; flex: none; min-width: 0; }
.day__num { font-size: 15px; color: var(--faint); white-space: nowrap; flex: none; }
.day__head .tag--today { margin-left: auto; align-self: center; }
/* the slim outline under an area's cards: Guided add with the area chosen */
.section__add {
  width: 100%; margin-top: 2px; border: 1px dashed var(--line-strong); border-radius: 9px; background: none;
  padding: 7px 10px; font-size: 12.5px; font-weight: 700; color: var(--muted); text-align: center;
}
.section__add { transition: color .18s, border-color .18s, background .18s; }
.section__add:hover { color: var(--ink); border-color: var(--muted-2); background: var(--hover); }
/* the way into Guided add with this day filled in */
.day__add {
  margin-left: auto; align-self: center; flex: none;
  width: 22px; height: 22px; border: 0; border-radius: 7px; padding: 0;
  background: var(--pill); color: var(--muted); font-size: 17px; font-weight: 800; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.day__head .tag--today + .day__add { margin-left: 0; }
.day__add { transition: background .18s, color .18s, transform .12s; }
.day__add:hover { background: var(--hover); color: var(--ink); }
.day__add:active { transform: scale(.92); }
.day.is-today .day__add { background: var(--accent-soft); color: var(--accent-ink); }

.strip { display: flex; height: 7px; border-radius: var(--r-pill); overflow: hidden; background: var(--track); }
.strip .seg.deep { background: var(--deep); }
.strip .seg.lunch { background: var(--lunch); }
.strip .seg.mtg { background: var(--mtg); }
.strip .seg.free { background: transparent; }

.freeline { display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted-2); }
.freeline b { color: var(--ink); font-weight: 700; }
.freeline .is-none { color: var(--warn); }

.day__body { position: relative; display: flex; flex-direction: column; gap: 10px; }
.day__body .capline {
  position: absolute; left: -8px; right: -8px; border-top: 1px dashed var(--dash);
  pointer-events: none;
}
.day__nofree { font-size: 13px; color: var(--muted-2); }
.day__spacer { flex: 1; min-height: 4px; }
.day__foot { border-top: 1px dashed var(--dash); padding-top: 9px; font-size: 13px; color: var(--muted-2); }
.day__foot.is-done { color: var(--ok); font-weight: 700; }
.day__foot.is-over {
  border-top: 0; background: var(--warn-soft); border-radius: 9px;
  padding: 9px 11px; font-weight: 800; color: var(--warn-ink);
}
.day__done { display: flex; flex-direction: column; gap: 8px; }

/* drop targets */
/* Tapping a day or a rail section while a card is selected still drops it
   there; the dashed outlines that used to say so were more noise than help
   once the editor was open, so only the target under the pointer lights up. */
.is-over { background: var(--accent-soft) !important; }
/* While a card is dragged it leaves the list, and a slot its size stands where it would land. */
/* Out of the flow rather than display:none, which would end the browser's drag. */
.card.is-dragging { position: absolute; visibility: hidden; pointer-events: none; }
.drop-slot {
  flex: none; box-sizing: border-box; width: 100%;
  border: 2px dashed var(--accent-line); border-radius: var(--r-card); background: var(--accent-soft);
  animation: slot-in .16s ease-out;
}
@keyframes slot-in { from { height: 0; opacity: 0; } }

/* ==========================================================================
   Cards — one look, many states
   ========================================================================== */

.card {
  display: flex; flex-direction: column; width: 100%; text-align: left;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-left: 4px solid var(--area, var(--none));
  border-radius: var(--r-card);
  padding: 11px 12px;
  box-shadow: var(--shadow-card);
  gap: 7px;
  transition: box-shadow .18s, transform .18s, border-color .18s, background .18s, opacity .18s;
  animation: card-in .22s ease-out backwards;
  overflow: hidden;
  min-width: 0;
}
.card__top { display: flex; align-items: flex-start; gap: 7px; flex-wrap: wrap; min-width: 0; }
.card__title {
  font-size: 14px; font-weight: 800; line-height: 1.3; text-wrap: pretty;
  flex: 1; min-width: 0;
  overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.card__sub {
  font-size: 12.5px; color: var(--muted-2); line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card__spacer { flex: 1; min-height: 0; }
/* Badges and meta on one line, for the cards with room for only two. */
.card__foot { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.card__foot .card__badges { flex: none; flex-wrap: nowrap; gap: 4px; }
/* A size down on the shared line, so a chip and the minutes fit a narrow column. */
.card__foot .streak, .card__foot .tag--high { padding: 2px 7px; font-size: 11px; }
.card__foot .card__quest { font-size: 11px; }
.card__foot .meta { flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* row layout: short cards put the size on the same line as the title */
.card--row { flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; }
.card--row .card__top { flex: 1; align-items: center; flex-wrap: nowrap; }
.card--row .card__title { -webkit-line-clamp: 1; white-space: nowrap; text-overflow: ellipsis; }
.card--row .meta { flex: none; }
/* short layout: a half-hour card, one title line over its meta, tighter padding to fit */
.card--short { padding: 7px 12px 6px; gap: 2px; overflow: hidden; }
.card--short .card__top { align-items: center; flex-wrap: nowrap; }
.card--short .card__title { -webkit-line-clamp: 1; white-space: nowrap; text-overflow: ellipsis; }
.card--short .meta { flex-wrap: nowrap; white-space: nowrap; overflow: hidden; }
.card--tall .card__title { -webkit-line-clamp: 5; }
.card--compact .card__title { -webkit-line-clamp: 3; }

/* states */
.card--selected { outline: 3px solid var(--accent); outline-offset: 1px; }
.card--spill { background: var(--warn-soft); border-color: var(--warn-line); border-left-color: var(--warn); }
.card--bounced { border-style: dashed; border-left-style: solid; }
.card--blocked { opacity: .55; }
.card--done .card__title { text-decoration: line-through; color: var(--faint); }
/* a spurt belongs to a project: doubled left edge */
.card--spurt { border-left-style: double; border-left-width: 7px; }
.card--habit-session { border-style: dashed; border-left-style: solid; }
.card--project { background: var(--card); }
.card--habit { background: color-mix(in srgb, var(--card) 55%, transparent); border-style: dashed; border-left-style: dashed; }
button.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-raised); transform: translateY(-1px); }
button.card:active { transform: translateY(0) scale(.99); }
@keyframes card-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   Soft suggestion boxes (habits)
   ========================================================================== */

.suggest {
  border: 1px dashed var(--accent-line); border-radius: 11px; padding: 12px;
  display: flex; flex-direction: column; gap: 8px; background: var(--card);
}
.suggest__lead { font-size: 13px; color: var(--muted); }
.suggest__title { font-size: 15px; font-weight: 800; color: var(--accent-ink); }
.suggest__acts { display: flex; gap: 8px; flex-wrap: wrap; }
.suggest--lg { border-radius: 12px; padding: 16px 18px; gap: 9px; background: var(--surface-2); }
.suggest--lg .suggest__lead { font-size: 14px; }
.suggest--lg .suggest__title { font-size: 19px; }
.suggest--lg .btn { padding: 9px 15px; font-size: 14px; }

/* ==========================================================================
   Just today
   ========================================================================== */

.today {
  flex: 1; min-height: 0; overflow: auto;
  padding: 4px 20px 40px;
  display: grid; grid-template-columns: minmax(0, 860px) 340px; gap: 22px;
  align-items: start; align-content: start; justify-content: center;
}
.today__head { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.today__head h2 { font-size: 34px; font-weight: 800; letter-spacing: -.02em; }
.today__head span { font-size: 14px; color: var(--muted); }
.today__main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.now {
  background: var(--card); border-left: 7px solid var(--area, var(--none));
  border-radius: var(--r-panel); padding: 20px 24px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow-raised); min-height: 260px;
  transition: transform .2s ease, opacity .2s ease;
}
.now.is-leaving { transform: translateX(40px); opacity: 0; }
.now__label { font-size: 15px; font-weight: 800; color: var(--ink-2); }
.now__title { font-size: 38px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; text-wrap: pretty; max-width: 22ch; }
.now__meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 14.5px; color: var(--muted); }
.now__acts { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 6px; }
.now--empty { border-left-color: var(--none); }
.now--empty p { color: var(--muted); max-width: 46ch; font-size: 15px; }

.box { border-radius: var(--r-field); padding: 11px 13px; font-size: 14px; max-width: 62ch; }
.box--note { background: var(--field); border: 1px solid var(--line); }
.box--crumb { background: var(--accent-soft); }
.box--crumb b { display: block; font-size: 13px; color: var(--accent); margin-bottom: 2px; }
.warnline { color: var(--warn); font-weight: 800; font-size: 14.5px; }

.nudge {
  background: var(--accent-soft); border-radius: var(--r-field); padding: 10px 13px;
  font-size: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}

.next { display: flex; flex-direction: column; gap: 10px; }
.next h3 { font-size: 17px; font-weight: 800; }
.next .hint { font-size: 13px; color: var(--muted); }

.parked {
  grid-column: 1 / -1;
  background: var(--surface-2); border-radius: 12px; padding: 16px 20px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  font-size: 14.5px; color: var(--ink-2);
}
.parked span { flex: 1; min-width: 260px; }

.gap { background: var(--surface-2); border-radius: var(--r-panel); padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.gap h3 { font-size: 18px; font-weight: 800; }
.gap p { font-size: 14px; color: var(--muted); line-height: 1.45; text-wrap: pretty; }
.gap__btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.gap__btns button {
  background: var(--card); border: 0; border-radius: var(--r-btn); padding: 14px 4px;
  text-align: center; font-size: 15px; font-weight: 800; box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}
.gap__btns button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.gap__empty { font-size: 14px; color: var(--muted); }
.gap__list { display: flex; flex-direction: column; gap: 8px; }

.cand {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line-soft);
  border-left: 4px solid var(--area, var(--none)); border-radius: var(--r-card);
  padding: 11px 12px; box-shadow: var(--shadow-card);
}
.cand--habit { border-style: dashed; border-left-style: solid; background: color-mix(in srgb, var(--card) 60%, transparent); }
.cand__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cand__title { font-size: 14px; font-weight: 800; line-height: 1.3; display: flex; align-items: center; gap: 6px; }
.cand__title span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cand__src { font-size: 12.5px; color: var(--muted-2); text-align: right; flex: none; max-width: 46%; line-height: 1.35; }

/* ==========================================================================
   Sheets
   ========================================================================== */

.sheet-scrim {
  position: fixed; inset: 0; background: var(--scrim); z-index: 19; animation: fade-in .2s ease-out backwards;
}
.sheet {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: min(840px, calc(100% - 24px));
  background: var(--card); border-radius: var(--r-sheet);
  border-top: 5px solid var(--area, var(--accent));
  box-shadow: var(--shadow-sheet);
  padding: 16px 24px 14px;
  z-index: 20; max-height: 86vh; overflow: auto;
  display: flex; flex-direction: column; gap: 10px;
  animation: sheet-up .26s cubic-bezier(.2, .8, .2, 1) backwards;
}
.sheet--center { top: 50%; bottom: auto; transform: translate(-50%, -50%); animation-name: sheet-center; }
@keyframes sheet-up { from { opacity: 0; transform: translate(-50%, 28px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes sheet-center { from { opacity: 0; transform: translate(-50%, -50%) scale(.96); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
/* The sheet is a scrolling flex column, so nothing inside it may shrink to fit:
   a textarea sized to its content would otherwise be squashed to a sliver. */
.sheet > * { flex: none; }
.sheet h3 { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.sheet__title {
  display: block; width: 100%; box-sizing: border-box;
  font: inherit; font-size: 22px; font-weight: 800; letter-spacing: -.01em; line-height: 1.25;
  border: 0; border-bottom: 1px solid var(--line-faint); padding: 0 0 11px;
  background: none; color: var(--ink);
  resize: none; overflow: hidden; /* it grows to fit rather than scrolling */
}
.sheet__title:focus { outline: none; border-bottom-color: var(--accent); }
.sheet__sub {
  font-size: 13px; color: var(--muted);
  border-bottom: 1px solid var(--line-faint); padding-bottom: 10px; margin-top: -3px;
}
.sheet__sub--plain { border-bottom: 0; padding-bottom: 0; }
.sheet__body { display: flex; flex-direction: column; gap: 10px; }

.srow { display: grid; grid-template-columns: 88px minmax(0, 1fr); align-items: center; gap: 12px; }
.srow > .srow__label { font-size: 13px; color: var(--muted); }
.srow__value { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; min-width: 0; }
.srow--top { align-items: start; }
.srow--divider { border-bottom: 1px solid var(--line-faint); padding-bottom: 12px; }
.srow__inline { font-size: 13px; color: var(--muted); margin-left: 4px; }
.srow__spacer { flex: 1; min-width: 0; }

.actions {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border-top: 1px solid var(--line-faint); padding-top: 12px;
}
.actions .hint { flex: 1; min-width: 170px; font-size: 13px; color: var(--muted); }
/* a lone action in the body of a page, not the sheet's footer */
.actions--start { border-top: 0; padding-top: 2px; justify-content: flex-start; }

/* Controls sit a size down inside a sheet, where they come in long rows. */
.sheet .pill { padding: 7px 14px; font-size: 13.5px; gap: 7px; }
.sheet .btn { padding: 10px 17px; font-size: 14.5px; }
.sheet .btn--danger { padding-left: 6px; padding-right: 6px; }
.sheet .field { padding: 7px 10px; font-size: 13.5px; }
.sheet .stepper__btn { width: 30px; height: 28px; }
.sheet .stepper__value { font-size: 14px; min-width: 60px; }
.sheet .nudge { padding: 8px 11px; font-size: 13.5px; gap: 10px; }

/* --- Plus: the badge beside a locked thing, and the sheet it opens --- */
.upbadge {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--accent-ink);
  border-radius: var(--r-pill); padding: 2px 9px 2px 7px;
  font: inherit; font-size: 11.5px; font-weight: 800; letter-spacing: .01em; line-height: 1.5;
  cursor: pointer; transition: background .2s, color .2s;
}
.upbadge:hover { background: var(--accent); color: var(--on-accent); }
.upbadge--inert { cursor: inherit; }
.upbadge--inert:hover { background: var(--accent-soft); color: var(--accent-ink); }
/* A look kept for Plus: still shown, a little quieter, wearing its badge. */
.look.is-locked .look__icon { opacity: .55; }
.look .upbadge { margin-top: 2px; }
.upbadge:active { transform: scale(.96); }
.icon--up { width: 10px; height: 10px; }
.icon--check { width: 14px; height: 14px; }

/* Over whatever opened it — a card's sheet, Settings — and dimming it. */
.sheet--upgrade { width: min(560px, calc(100% - 24px)); z-index: 31; gap: 14px; padding: 22px 26px 16px; }
.sheet-scrim:has(+ .sheet--upgrade) { z-index: 30; background: var(--scrim-strong); }
.upgrade__head { display: flex; flex-direction: column; gap: 6px; }
.upgrade__mark {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 5px;
  background: var(--accent); color: var(--on-accent); border-radius: var(--r-pill);
  padding: 3px 11px 3px 9px; font-size: 12px; font-weight: 800; letter-spacing: .02em;
}
.sheet--upgrade h3 { font-size: 24px; line-height: 1.2; }
.upgrade__why { font-size: 14px; color: var(--ink-2); }
.upgrade__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.upgrade__item { display: flex; gap: 10px; align-items: flex-start; padding: 2px 0; border-radius: var(--r-field); }
.upgrade__item.is-reached { background: var(--accent-soft); padding: 8px 10px; margin: 0 -10px; }
.upgrade__tick {
  flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ok-soft); color: var(--ok); margin-top: 1px;
}
.upgrade__text { display: flex; flex-direction: column; gap: 1px; font-size: 13.5px; color: var(--muted); }
.upgrade__text b { font-size: 14.5px; color: var(--ink); }
.upgrade__prices { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.upgrade__price {
  position: relative; display: flex; flex-direction: column; gap: 3px; text-align: left;
  border: 1.5px solid var(--line-strong); background: var(--card); color: var(--ink);
  border-radius: var(--r-card); padding: 12px 12px 10px; font: inherit; cursor: pointer;
  transition: border-color .2s, background .2s;
}
.upgrade__price:hover { border-color: var(--accent-line); }
.upgrade__price[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.upgrade__amount { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.upgrade__amount small { font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.upgrade__note { font-size: 12px; color: var(--muted); line-height: 1.35; }
.upgrade__best {
  position: absolute; top: -9px; right: 10px; background: var(--accent); color: var(--on-accent);
  border-radius: var(--r-pill); padding: 1px 8px; font-size: 10.5px; font-weight: 800; letter-spacing: .03em;
}
.sheet .btn.upgrade__go { width: 100%; padding: 15px 18px; font-size: 16.5px; font-weight: 800; justify-content: center; }
.upgrade__fine { font-size: 12.5px; color: var(--muted); text-align: center; }
/* where the iPhone app can't sell: the address to go to, said plainly in place of the button */
.upgrade__elsewhere {
  font-size: 14.5px; line-height: 1.45; color: var(--ink-2); text-align: center;
  background: var(--accent-soft); border-radius: var(--r-card); padding: 12px 14px;
}
.upgrade__elsewhere b { color: var(--ink); }
.upgrade__later { display: flex; justify-content: center; margin-top: -6px; }
/* a row in Settings that ends in a badge rather than a button */
.introw__acts .upbadge { align-self: center; }

/* --- Settings: nav down the left, page on the right --- */
/* The settings sheet keeps one height whichever tab is open, so switching
   tabs does not make the board behind it jump; a short page leaves room. */
.sheet--settings { height: min(640px, 86vh); }
/* the walk-through keeps one height across its pages, so Next never jumps */
.sheet--onboarding { min-height: 380px; }
.sheet--onboarding .actions { margin-top: auto; }
.onb__list { display: flex; flex-direction: column; gap: 6px; padding-left: 18px; font-size: 14px; color: var(--ink-2); }
.onb__list b { color: var(--ink); }
.onb__step { font-size: 12.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.sheet--settings .settings { flex: 1; min-height: 0; overflow: auto; }
.settings { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 18px; align-items: start; align-content: start; }
.settings__nav { display: flex; flex-direction: column; gap: 4px; }
.settings__tab {
  border: 0; background: none; text-align: left; border-radius: var(--r-field);
  padding: 9px 12px; font-size: 14px; font-weight: 700; color: var(--muted);
}
.settings__tab { transition: background .18s, color .18s; }
.settings__tab:hover { background: var(--pill); color: var(--ink); }
.settings__tab[aria-current="page"] { background: var(--ink); color: var(--on-ink); }
.settings__page { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.settings__page .sheet__sub { border-bottom: 0; padding-bottom: 0; margin-top: 0; }

/* --- The areas editor --- */
.arealist { display: flex; flex-direction: column; gap: 10px; }
.area {
  border: 1px solid var(--line); border-left: 5px solid var(--area, var(--none));
  border-radius: var(--r-card); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px; background: var(--card);
}
.area__row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.area__row .field { min-width: 0; }
.area__colour {
  flex: none; width: 34px; height: 32px; padding: 2px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--field); cursor: pointer;
}
.area__colour::-webkit-color-swatch-wrapper { padding: 0; }
.area__colour::-webkit-color-swatch { border: 0; border-radius: 5px; }
.area__order { display: flex; gap: 4px; flex: none; }
.area__order .btn { padding: 6px 9px; }
.area__tagslabel {
  flex: none; font-family: var(--mono); font-size: 12.5px; color: var(--muted);
  background: var(--pill); border-radius: 6px; padding: 5px 8px;
}
.arealist__add { display: flex; }

/* the help drawer's list of areas and their tags */
.help__areas { display: flex; flex-direction: column; gap: 8px; }
.help__area { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.help__area .pill__dot { width: 10px; height: 10px; }
.help__area b { font-weight: 800; }
.help__area .help__tags { gap: 5px; }

/* activity log */
.activity { background: var(--field); border: 1px solid var(--line); border-radius: var(--r-field); padding: 4px 10px; }
.actrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 0; }
.actrow + .actrow { border-top: 1px solid var(--line); }
.actrow .stepper__value { min-width: 62px; font-size: 14px; }
.actempty { color: var(--muted); font-size: 13.5px; padding: 8px 0; }

/* snapshots */
.snaplist { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow: auto; }
.snap {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: var(--field); border: 1px solid var(--line); border-radius: var(--r-field);
  padding: 9px 12px; font-size: 13.5px;
}
.snap b { flex: 1; font-weight: 700; }
.snap span { color: var(--muted); font-size: 12.5px; }

/* ==========================================================================
   How it works drawer
   ========================================================================== */

.help {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(500px, 100%);
  background: var(--card); z-index: 30; padding: 26px 30px 40px; overflow: auto;
  box-shadow: var(--shadow-drawer);
  display: flex; flex-direction: column; gap: 14px;
  animation: drawer-in .28s cubic-bezier(.2, .8, .2, 1) backwards;
}
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
/* A flex column shrinks its children to fit, which squashed the backup box to
   a single line. Nothing in the drawer should shrink; it scrolls instead. */
.help > * { flex: none; }
/* The heading and Close stay put while the rest scrolls under them. */
.help__top {
  position: sticky; top: -26px; z-index: 1; margin: -26px -30px 0; padding: 26px 30px 12px;
  background: var(--card); box-shadow: 0 8px 12px -10px rgba(0, 0, 0, .25);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.help__top h2 { font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.help h3 { font-size: 17px; font-weight: 800; margin-top: 4px; }
.help p, .help li { font-size: 14.5px; line-height: 1.55; color: var(--ink-2); text-wrap: pretty; }
.help ol { padding-left: 20px; margin: 6px 0; display: flex; flex-direction: column; gap: 6px; }
.help__tags { display: flex; flex-wrap: wrap; gap: 7px; }
.help__tags code {
  background: var(--surface); border-radius: 6px; padding: 4px 9px; font-size: 13px; font-family: var(--mono);
}
.help__acts { display: flex; gap: 10px; flex-wrap: wrap; }

/* ==========================================================================
   Toast
   ========================================================================== */

.toast {
  /* Below the status bar, the notch or the Dynamic Island, whatever the phone has. */
  position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); left: 50%; transform: translate(-50%, -16px);
  opacity: 0; pointer-events: none; z-index: 40;
  background: var(--ink); color: var(--on-ink); font-size: 14px; font-weight: 700;
  padding: 10px 20px; border-radius: var(--r-pill);
  transition: opacity .2s, transform .2s; max-width: 90vw; text-align: center;
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }
/* On a phone the toast is a wide band, not a pill the size of its words. */
@media (max-width: 720px) {
  .toast { min-width: 72vw; max-width: calc(100vw - 24px); padding: 12px 18px; font-size: 14.5px; }
}

/* --- Loading: the mark, alive, on the brand's purple ---------------------- */
body.is-loading { background: #4C2FBF; }
.loading {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: #4C2FBF; color: #fff;
}
/* Sized as the iOS launch image draws it — 16% of the longer side — so one takes over from the other without a jump. */
.mark { width: 16vmax; height: 16vmax; max-width: 260px; max-height: 260px; overflow: visible; }
.mark__bar { fill: #fff; transform-box: fill-box; transform-origin: 50% 100%; animation: mark-stretch 1.1s ease-in-out infinite; }
.mark__bar--d { fill: #B0A6EA; }
/* Each bar breathes on its own beat; the two halves of the middle column trade room. */
.mark__bar--a { animation-delay: -0.2s; }
.mark__bar--b { transform-origin: 50% 0%; animation-name: mark-stretch-b; animation-delay: -0.55s; }
.mark__bar--c { animation-name: mark-stretch-c; animation-delay: -0.55s; }
.mark__bar--d { animation-delay: -0.85s; }
@keyframes mark-stretch { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.55); } }
@keyframes mark-stretch-b { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(1.7); } }
@keyframes mark-stretch-c { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.45); } }

/* Confetti: decoration only, so it never takes a tap and sits under the toast
   that says what actually happened. */
.confetti {
  position: fixed; inset: 0; z-index: 38;
  width: 100%; height: 100%;
  pointer-events: none;
}

/* ==========================================================================
   Narrow screens
   ========================================================================== */

@media (max-width: 1000px) {
  .plan { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .rail { max-height: 40vh; }
  .today { grid-template-columns: 1fr; }
  .now__title { font-size: 30px; }
  .today__head h2 { font-size: 28px; }
}
@media (max-width: 720px) {
  /* The editors are the one desktop surface the phone keeps, so they get the
     phone's proportions rather than the desktop's. */
  .sheet {
    width: 100%; left: 0; right: 0; bottom: 0; transform: none;
    border-radius: 22px 22px 0 0;
    padding: 14px 18px 0;
    max-height: 92dvh;
    gap: 9px;
    /* The sheet scrolls down, never sideways: a control that still manages to
       be too wide gets clipped rather than sliding the whole form off-screen. */
    overflow-x: clip;
    overflow-y: auto;
    /* Above the phone's own overlays, so an editor is never buried by one. */
    z-index: 35;
    animation-name: m-sheet-up;
  }
  @keyframes m-sheet-up { from { transform: translateY(100%); } to { transform: none; } }
  /* Plus rises from the bottom like every phone sheet, over the one that opened it. */
  .sheet--upgrade { top: auto; z-index: 37; padding: 18px 18px 0; }
  .sheet-scrim:has(+ .sheet--upgrade) { z-index: 36; }
  .sheet--upgrade .upgrade__later { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  /* The list is long on a phone; the button that matters stays in reach. */
  .sheet .btn.upgrade__go { position: sticky; bottom: 10px; z-index: 1; box-shadow: 0 6px 20px var(--scrim-strong); }
  .sheet__title { font-size: 19px; padding-bottom: 9px; }
  .sheet__sub { font-size: 12.5px; padding-bottom: 8px; }

  .srow { grid-template-columns: 1fr; gap: 3px; }
  .srow > .srow__label { font-size: 12px; font-weight: 700; color: var(--faint); }
  .srow__value { gap: 6px; }
  /* On one column there is nothing to push apart, and a spacer only strands
     the label that follows it against the far edge. */
  .srow__spacer { display: none; }
  .srow__inline { margin-left: 0; }
  .srow--divider { padding-bottom: 9px; }

  /* One column, so the date gets its own line and the "After" menu takes the
     rest of the next one. Neither can then be pushed out of the sheet by a
     native control that renders wider than expected. */
  /* flex-shrink must stay 1: a native date control reports an intrinsic width
     of its own, and with shrink 0 it would sit at that however narrow the row. */
  .srow__value > input[type="date"].field { flex: 1 1 100%; width: 100%; min-width: 0; }
  .srow__value > select.field { flex: 1 1 0; min-width: 0; }
  .sheet .field--grow { min-width: 0; }

  .sheet .pill { padding: 8px 13px; font-size: 13.5px; }
  .sheet .btn { padding: 11px 15px; font-size: 14.5px; }
  .sheet .field { font-size: 16px; } /* 16px keeps iOS from zooming on focus */
  .sheet .stepper__value { min-width: 52px; }

  /* The actions stay put while the rest scrolls, so Close, Done and Delete are
     always one tap away however long the form is. */
  .actions {
    position: sticky; bottom: 0; z-index: 2;
    gap: 8px; background: var(--card);
    margin: 0 -18px; padding: 10px 18px calc(12px + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 14px rgba(31, 36, 48, .07);
  }
  .actions .hint { display: none; }

  /* No room for a side nav on a phone: the sections become tabs across the top. */
  /* Five sections no longer fit across a phone, so the tabs scroll sideways
     and the page beneath can never be wider than the sheet. */
  .sheet--settings { height: 88dvh; }
  /* The tab strip bleeds to the sheet's edges. The bleed belongs on the
     scroll container, not on the strip inside it: a scroll container cannot
     reach anything hanging past its own left edge, so a strip with a
     negative margin of its own lost its first tab. Snap points keep the
     18px in, so the first and last tabs land clear of the edge. */
  .settings { grid-template-columns: minmax(0, 1fr); gap: 12px; margin: 0 -18px; padding: 0 18px; }
  /* The strip stays put while the page scrolls under it, on an opaque back
     so nothing shows through between the tabs. */
  .settings__nav {
    flex-direction: row; gap: 6px; overflow-x: auto; scrollbar-width: none;
    margin: 0 -18px; padding: 2px 18px 10px; scroll-snap-type: x proximity; scroll-padding-inline: 18px;
    position: sticky; top: 0; z-index: 2; background: var(--card);
  }
  .settings__nav::-webkit-scrollbar { display: none; }
  .settings__tab { flex: none; white-space: nowrap; text-align: center; background: var(--pill); scroll-snap-align: start; }
  .settings__page { max-width: 100%; overflow-x: clip; }
  .settings__page .srow__value, .settings__page .pillgroup { max-width: 100%; }
  .area__row { flex-wrap: wrap; }
  .area__row .field--grow { min-width: 140px; }

  .help { width: 100%; padding: calc(12px + env(safe-area-inset-top)) 18px calc(30px + env(safe-area-inset-bottom)); gap: 12px; }
  .help__top { top: calc(-12px - env(safe-area-inset-top)); margin: calc(-12px - env(safe-area-inset-top)) -18px 0; padding: calc(12px + env(safe-area-inset-top)) 18px 10px; }
  .help__top h2 { font-size: 19px; }
  .help h3 { font-size: 16px; }
  .help p, .help li { font-size: 14px; }

}

/* ==========================================================================
   Quarterly quests
   ========================================================================== */

.quests {
  flex: 1; min-height: 0; overflow: auto;
  padding: 6px 40px 40px;
  display: flex; flex-direction: column; gap: 18px;
}
.quests__body { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 22px; align-items: start; }

/* --- the hero band ------------------------------------------------------ */
.qhero {
  background: var(--card); border-radius: var(--r-sheet); box-shadow: var(--shadow-raised);
  padding: 24px 30px;
  display: grid; grid-template-columns: 360px minmax(0, 1fr) auto; gap: 34px; align-items: center;
}
.qhero__when { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.qhero__nav { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; position: relative; }
.qhero__arrow {
  width: 26px; height: 26px; border: 0; border-radius: 8px; background: var(--pill); color: var(--ink-2);
  font-size: 15px; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0; flex: none;
}
.qhero__arrow { transition: background .18s, transform .12s; }
.qhero__arrow:hover:not(:disabled) { background: var(--hover); }
.qhero__arrow:active:not(:disabled) { transform: scale(.92); }
.qhero__arrow:disabled { opacity: .35; cursor: default; }
.qhero__label {
  border: 0; background: none; padding: 2px 4px; border-radius: 6px;
  font-size: 13px; font-weight: 800; letter-spacing: .06em; color: var(--muted); text-transform: uppercase;
  white-space: nowrap;
}
.qhero__label:hover { color: var(--ink); background: var(--pill); }
.qhero__big { font-size: 56px; font-weight: 800; letter-spacing: -.03em; line-height: 1.02; text-wrap: balance; }
.qhero__sub { font-size: 15px; font-weight: 300; color: var(--muted); }
.qhero__clock { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.qhero__line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--muted); }
.qhero__line b { color: var(--accent-ink); font-weight: 800; }
.qhero__tally { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.qhero__tally b { color: var(--ink); font-weight: 800; }
.qhero__tally--closed { font-size: 16px; }
.qdot { color: var(--dash); }
.qhero__act { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.qhero__act .btn { text-align: center; }
.qhero__hint { font-size: 12.5px; font-weight: 300; color: var(--muted); text-align: center; max-width: 190px; align-self: center; }

/* the jump list, dropped under the quarter's name */
.qjump {
  position: absolute; top: calc(100% + 6px); left: 34px; z-index: 12;
  animation: sheet-center .18s ease-out backwards; transform-origin: top left;
  min-width: 280px; background: var(--card); border: 1px solid var(--line-strong);
  border-radius: 12px; box-shadow: var(--shadow-sheet); padding: 6px;
  display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow: auto;
}
.qjump__row {
  border: 0; background: none; border-radius: 8px; padding: 8px 10px; text-align: left;
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  font-size: 13.5px; font-weight: 700; color: var(--ink); white-space: nowrap;
}
.qjump__row:hover { background: var(--pill); }
.qjump__row[aria-current="true"] { background: var(--accent-soft); color: var(--accent-ink); }
.qjump__note { font-size: 12px; font-weight: 400; color: var(--muted); }

/* --- bars ---------------------------------------------------------------- */
.qbar { position: relative; display: flex; height: 12px; border-radius: var(--r-pill); background: var(--sunken); overflow: hidden; }
.qbar > i { display: block; height: 100%; background: var(--area, var(--accent)); border-radius: var(--r-pill); transition: width .25s ease; position: relative; z-index: 1; }
.qbar--big { height: 16px; }
.qbar--big > i { background: var(--accent); }
/* what a number about to be logged would do, drawn faintly behind the bar */
.qbar > i.qbar__pending {
  position: absolute; left: 0; top: 0; bottom: 0; z-index: 0;
  background: color-mix(in srgb, var(--area, var(--accent)) 35%, transparent);
}

/* --- the list ------------------------------------------------------------ */
.qlist { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.qlist__head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.qlist__head h2 { font-size: 20px; font-weight: 800; }
.qlist__head span { font-size: 13.5px; color: var(--muted); }
.qlist__empty { font-size: 14px; color: var(--muted); }

.quest {
  background: var(--card); border-left: 7px solid var(--area, var(--none)); border-radius: var(--r-panel);
  padding: 18px 22px; box-shadow: var(--shadow-raised);
  display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 22px; align-items: center;
}
.quest__main { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.quest__top { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }
.quest__title { font-size: 20px; font-weight: 800; letter-spacing: -.01em; margin: 0; text-wrap: pretty; }
.quest__number { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.quest__number b { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.quest__number span { font-size: 14px; font-weight: 300; color: var(--muted); }
.quest__stats { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.quest__stats b { color: var(--ink); font-weight: 800; }
.quest__sub { font-size: 14px; font-weight: 300; color: var(--muted); }
.quest__links { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 2px; }
.quest__link { background: var(--surface); border-radius: 6px; padding: 4px 10px; font-size: 13px; font-weight: 700; }
.quest__side { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.quest__side .btn { text-align: center; }
.quest__side .btn--link { color: var(--muted); font-weight: 800; text-decoration: none; }
.quest__side .btn--link:hover { color: var(--ink); }
.quest--closed { background: var(--sunken); box-shadow: none; padding: 16px 22px; }
.quest--closed .quest__title { font-size: 18px; color: var(--muted); }
.quest--closed .quest__main { gap: 5px; }
.quest--done .quest__title { text-decoration: none; }
/* the phone's way into a quest; the desktop has "Open quest" */
.quest__open { display: none; }

.btn--ink { background: var(--ink); color: var(--on-ink); }
.tag--ok { background: var(--ok-soft); color: var(--ok); font-size: 12px; font-weight: 800; border-radius: 6px; padding: 3px 9px; }
.tag--warn { background: var(--warn-soft); color: var(--warn-ink); font-size: 12px; font-weight: 800; border-radius: 6px; padding: 3px 9px; }

.qadd {
  border: 1px dashed var(--accent-line); border-radius: var(--r-panel); background: var(--sunken);
  padding: 16px 22px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; text-align: left;
}
.qadd:hover:not(:disabled) { background: var(--accent-soft); }
.qadd:disabled { cursor: default; border-color: var(--dash); }
.qadd__label { font-size: 17px; font-weight: 800; color: var(--accent-ink); }
.qadd:disabled .qadd__label { color: var(--muted); }
.qadd__note { font-size: 13.5px; color: var(--muted); }
.qadd__label .upbadge { margin-left: 8px; vertical-align: 2px; }

/* --- the sidebar --------------------------------------------------------- */
.qside { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.qpanel { background: var(--sunken); border-radius: var(--r-panel); padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.qpanel--raised { background: var(--card); box-shadow: var(--shadow-raised); gap: 12px; }
.qpanel h3 { font-size: 18px; font-weight: 800; }
.qpanel p { font-size: 14px; color: var(--muted); line-height: 1.45; text-wrap: pretty; }
.qpanel__note { font-size: 13.5px; }
.qpanel__empty { font-size: 13.5px; color: var(--faint); }
.qpanel--link { cursor: pointer; }
.qpanel--link:hover { background: var(--surface); }
.qtags { display: flex; flex-wrap: wrap; gap: 7px; }
.qtags code { background: var(--card); border-radius: 6px; padding: 4px 10px; font-size: 13px; font-family: var(--mono); }
.qpanel--raised .qtags code { background: var(--surface); }
.qlogs { display: flex; flex-direction: column; gap: 10px; }
.qlog { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line-faint); padding-bottom: 10px; }
.qlog:last-child { border-bottom: 0; padding-bottom: 0; }
.qlog__what { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.qlog__quest { font-size: 14.5px; font-weight: 700; }
.qlog__when { font-size: 13px; font-weight: 300; color: var(--muted); }
.qlog__delta { font-size: 15px; font-weight: 800; white-space: nowrap; }

/* --- the quest chip on a card -------------------------------------------- */
.card__quest {
  display: inline-flex; align-items: center; gap: 5px; align-self: flex-start;
  background: var(--quest-chip); color: var(--quest-chip-ink);
  font-size: 11px; font-weight: 800; border-radius: 5px; padding: 2px 7px; line-height: 1.45;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card__quest i { width: 7px; height: 7px; border-radius: 2px; background: var(--accent); flex: none; }

/* --- the quest sheet's numbers ------------------------------------------- */
.qnums { display: flex; flex-direction: column; gap: 10px; background: var(--field); border: 1px solid var(--line); border-radius: var(--r-field); padding: 12px; }
.qnums__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.qnums__field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.qnums__label { font-size: 12px; font-weight: 700; color: var(--muted); }
.qnums__sub { font-size: 11.5px; color: var(--faint); }
.qnums__preview { display: flex; flex-direction: column; gap: 6px; }
.qnums__hint { font-size: 13px; color: var(--muted); }
.field--num { font-variant-numeric: tabular-nums; }
.qtag__prefix { margin-left: 0; font-family: var(--mono); color: var(--ink-2); }

/* --- log progress --------------------------------------------------------- */
.logbig__label { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: -4px; }
.logbig__last { font-size: 12.5px; color: var(--faint); margin-top: -4px; }
.logbig { display: flex; align-items: baseline; gap: 10px; }
.logbig__input {
  flex: 1; min-width: 0; width: 100%;
  background: var(--field); border: 1px solid var(--line); border-radius: var(--r-field);
  padding: 8px 14px; font-size: 40px; font-weight: 800; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; color: var(--ink);
  appearance: textfield; -moz-appearance: textfield;
}
.logbig__input::-webkit-outer-spin-button, .logbig__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.logbig__input::placeholder { color: var(--faint-2); }
.logbig__unit { font-size: 16px; color: var(--muted); flex: none; }
.lognudge { display: flex; gap: 8px; flex-wrap: wrap; }
.logpreview { display: flex; flex-direction: column; gap: 6px; background: var(--field); border: 1px solid var(--line); border-radius: var(--r-field); padding: 10px 12px; }
.logpreview__line { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); }
.logpreview__line b { color: var(--ink); font-weight: 800; }
.logpreview__sub { font-size: 12.5px; color: var(--muted); }
.earlier { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--line-faint); padding-top: 10px; }
.earlier__head { font-size: 12px; font-weight: 700; color: var(--faint); }
.earlier__row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13.5px; }
.earlier__row--edit { flex-wrap: wrap; }
.earlier__what { flex: 1; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.earlier__what b { color: var(--ink); }
.earlier__tools { display: flex; gap: 2px; flex: none; }
.iconbtn {
  width: 28px; height: 28px; border: 0; border-radius: 7px; background: none; color: var(--muted);
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.iconbtn:hover { background: var(--pill); color: var(--ink); }
.iconbtn--danger:hover { color: var(--warn); }
.icon--small { width: 15px; height: 15px; }

/* --- rollover and close-out --------------------------------------------- */
.rollover { display: flex; flex-direction: column; gap: 8px; }
.rollover__row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border-left: 5px solid var(--area, var(--none)); background: var(--field); border-radius: var(--r-field); padding: 10px 12px;
}
.rollover__what { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 14px; }
.rollover__what span { font-size: 12.5px; color: var(--muted); }
.rollover__tools { display: flex; gap: 8px; flex: none; }

/* --- appearance ------------------------------------------------------------ */
.looks { display: flex; gap: 10px; flex-wrap: wrap; }
.look {
  flex: 1; min-width: 110px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--card);
  padding: 14px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 13.5px; font-weight: 700; color: var(--muted);
}
.look:hover { border-color: var(--muted-2); color: var(--ink); }
.look[aria-checked="true"] { border-color: var(--accent); color: var(--ink); box-shadow: inset 0 0 0 1px var(--accent); }
.look__icon { width: 34px; height: 34px; border-radius: 10px; background: var(--pill); display: flex; align-items: center; justify-content: center; }
.look[aria-checked="true"] .look__icon { background: var(--accent-soft); color: var(--accent-ink); }
.icon--look { width: 18px; height: 18px; }

@media (max-width: 1100px) {
  .quests__body { grid-template-columns: 1fr; }
  .qhero { grid-template-columns: 1fr; gap: 18px; }
  .qhero__act { flex-direction: row; align-items: center; }
  .qhero__hint { text-align: left; align-self: auto; }
}

@media (max-width: 720px) {
  /* The phone scrolls the page itself; the bottom bar is cleared by .m-main.
     Layout per the "6A" design: the band keeps the big number and stacks the
     bar under it, every quest is one full-width card, Log progress is a row. */
  .quests { padding: 0; gap: 11px; overflow: visible; flex: none; }
  .quests__body { grid-template-columns: 1fr; gap: 11px; }
  .qhero { grid-template-columns: 1fr; gap: 10px; padding: 16px 16px 14px; border-radius: var(--r-sheet); }
  .qhero__nav { gap: 8px; }
  .qhero__arrow { width: 30px; height: 30px; border-radius: 9px; }
  .qhero__label { flex: 1; text-align: center; font-size: 12px; white-space: normal; pointer-events: none; }
  .qhero__nav .tag { display: none; }
  .qjump { display: none; }
  .qhero__big { font-size: 38px; line-height: 1.05; }
  .qhero__sub { font-size: 13px; }
  .qhero__clock { gap: 10px; }
  .qbar--big { height: 12px; }
  .qhero__tally { font-size: 12.5px; gap: 8px; }
  .qhero__act { flex-direction: row; align-items: center; gap: 10px; }
  .qhero__act .btn { flex: 1; }
  .qhero__hint { text-align: left; align-self: auto; max-width: none; flex: 1; }
  .qlist { gap: 11px; }
  .qlist__head { gap: 4px; flex-direction: column; }
  .qlist__head h2 { font-size: 17px; }
  .qlist__head span { font-size: 12.5px; }
  .quest { grid-template-columns: 1fr; gap: 9px; padding: 14px 15px; box-shadow: var(--shadow-raised); }
  .quest__main { gap: 9px; }
  .quest__top { flex-wrap: nowrap; align-items: flex-start; gap: 8px; }
  .quest__title { flex: 1; font-size: 16px; line-height: 1.25; }
  .quest__top .tag { font-size: 11px; padding: 3px 7px; }
  .quest__open {
    display: flex; align-items: center; justify-content: center; flex: none;
    width: 28px; height: 24px; margin: -2px -6px 0 0; border: 0; background: none;
    font-size: 19px; color: var(--faint); padding: 0;
  }
  .quest__number { gap: 8px; }
  .quest__number b { font-size: 22px; }
  .quest__number span { font-size: 12.5px; }
  .qbar { height: 11px; }
  .quest__stats { font-size: 12px; gap: 6px; }
  .quest__side { flex-direction: row; align-items: center; margin-top: 2px; }
  .quest__side .btn { flex: 1; padding: 13px 0; border-radius: 12px; }
  .quest__side .btn--link { display: none; }
  .quest--closed { padding: 12px 15px; }
  .quest--closed .quest__title { font-size: 15px; }
  /* the bar has its own Add button; the dashed row is the desktop's */
  .qadd { display: none; }
  .qnums { padding: 10px; }
  .qnums__grid { grid-template-columns: 1fr 1fr; }
  .qnums__field:last-child { grid-column: 1 / -1; }
  .logbig__input { font-size: 32px; }
  .earlier__what { white-space: normal; }
}
}

/* ==========================================================================
   Habit streaks
   Weeks that hit the target, never days in a row. Never red.
   ========================================================================== */

:root {
  --flame-bg: #FFF2E8; --flame-ink: #9C4A17; --flame: #D2691E; --flame-line: #E8A87C;
  --grid-off: #EDEDEF; --grid-off-ink: #5C6270;
}
:root[data-theme="dark"] {
  --flame-bg: #3A2A1C; --flame-ink: #F0A868; --flame: #F0A868; --flame-line: #7A4E2B;
  --grid-off: #2C3037; --grid-off-ink: #A2A8B4;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --flame-bg: #3A2A1C; --flame-ink: #F0A868; --flame: #F0A868; --flame-line: #7A4E2B;
    --grid-off: #2C3037; --grid-off-ink: #A2A8B4;
  }
}

/* --- the chip -------------------------------------------------------------- */
.streak {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  background: var(--flame-bg); color: var(--flame-ink);
  border-radius: var(--r-pill); padding: 3px 9px; border: 1.5px solid transparent;
  font-size: 12px; font-weight: 800; line-height: 1.3; white-space: nowrap;
}
.streak .icon--flame { width: 11px; height: 13px; color: var(--flame); }
/* the chip as the way into the history: a divider and a word after the count */
.streak--btn { cursor: pointer; padding: 5px 11px 5px 9px; font-size: 13px; }
.streak--btn:hover { border-color: var(--accent-line); }
.streak__rule { width: 1px; height: 14px; background: var(--accent-line); margin: 0 3px; }
.streak__trail { color: var(--accent); font-weight: 700; }
@media (pointer: coarse) { .streak--btn { min-height: 44px; } }
.streak--togo { border-color: var(--flame-line); }
.streak--paused, .streak--fresh { background: var(--pill); color: var(--muted-2); }
.streak--paused .icon--flame, .streak--fresh .icon--flame { color: var(--dash); }
.streak--best { background: var(--ok-soft); color: var(--ok); }
.streak--best .icon--flame { color: var(--ok); }
/* a one-line card's High: a dot, so the title keeps its width */
.card__prio { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; display: inline-block; }
/* one row for every badge a card can carry: High, a streak, a quest */
.card__badges { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; min-width: 0; max-width: 100%; }
.card__badges .card__quest { align-self: auto; min-width: 0; flex: 0 1 auto; }
.card__streakline { font-size: 12px; color: var(--muted-2); }
.card--habit .card__top .streak { margin-left: auto; }

/* --- the Mon–Sun grid ------------------------------------------------------- */
.wgrid { display: flex; gap: 5px; }
.wgrid__cell {
  flex: 1; min-width: 0; height: 24px; border: 1.5px solid transparent; border-radius: 7px;
  transition: background .18s, color .18s, transform .12s;
  background: var(--grid-off); color: var(--grid-off-ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 800; padding: 0; font-family: inherit;
}
.wgrid__cell.is-done { background: var(--area, var(--accent)); color: #fff; }
/* today: a dashed outline in the area colour over a tint of it */
.wgrid__cell.is-today:not(.is-done) {
  border-style: dashed; border-color: var(--area, var(--accent));
  background: color-mix(in srgb, var(--area, var(--accent)) 18%, var(--card));
  color: color-mix(in srgb, var(--area, var(--accent)) 75%, var(--ink));
}
.wgrid__cell.is-today.is-done { border-color: color-mix(in srgb, var(--area, var(--accent)) 60%, var(--ink)); border-style: dashed; }
.wgrid__cell.is-future { opacity: .55; }
button.wgrid__cell { cursor: pointer; }
button.wgrid__cell:disabled { cursor: default; }
button.wgrid__cell:not(:disabled):hover { filter: brightness(.95); }
button.wgrid__cell:not(:disabled):active { transform: scale(.92); }
.wgrid__long { display: none; }
.wgrid--lg { gap: 6px; }
.wgrid--lg .wgrid__cell { height: 34px; border-radius: 9px; font-size: 12.5px; }
.wgrid--lg .wgrid__long { display: inline; }
.wgrid--lg .wgrid__short { display: none; }
.streak__line { font-size: 12px; color: var(--muted-2); }

/* --- Keeping it up ------------------------------------------------------------ */
.section--solid {
  border: 1px solid var(--line-soft); border-style: solid; background: var(--card);
  box-shadow: var(--shadow-card);
}
.keep { display: flex; flex-direction: column; gap: 10px; }
.keep__row { display: flex; flex-direction: column; gap: 7px; }
.keep__head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 0; background: none; padding: 0; text-align: left; font: inherit; color: inherit;
  border-radius: 6px;
}
.keep__head:hover .keep__name { color: var(--accent-ink); }
.keep__row.is-selected .keep__head { outline: 3px solid var(--accent); outline-offset: 3px; }
.keep__swatch { width: 9px; height: 9px; border-radius: 3px; background: var(--area, var(--none)); flex: none; }
.keep__name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.keep__off { font-size: 11.5px; font-weight: 700; color: var(--faint); }
.keep__rule { border: 0; border-top: 1px solid var(--line-faint); margin: 0; }
.keep__empty { font-size: 12.5px; color: var(--muted-2); }
.keep__foot { padding-top: 2px; }
.keep__track { color: var(--accent-ink); }
.keep--compact .keep__name { font-size: 14px; }

/* the picker */
.tracklist { display: flex; flex-direction: column; gap: 6px; }
.tracklist__row {
  display: flex; align-items: center; gap: 10px; background: var(--field); border: 1px solid var(--line);
  border-radius: var(--r-field); padding: 8px 10px 8px 12px;
}
.tracklist__name { flex: 1; min-width: 0; font-weight: 800; font-size: 14px; }
.tracklist__meta { font-size: 12.5px; color: var(--muted); }

/* --- the suggestion's reason ------------------------------------------------ */
.suggest__why, .m-suggest__why { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 12px; color: var(--muted-2); }

/* --- the habit sheet ---------------------------------------------------------- */
.sheet__titlerow { display: flex; align-items: center; gap: 14px; }
.sheet__titlerow .sheet__title { flex: 1; min-width: 0; }
.sheet__titlerow .streak { padding: 5px 12px; font-size: 13px; }
.streakpanel {
  background: var(--field); border: 1px solid var(--line); border-radius: var(--r-panel);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 12px;
}
.streakpanel__head { display: flex; align-items: center; gap: 16px; }
.streakpanel__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.streakpanel__title { font-size: 16px; font-weight: 800; }
.streakpanel__sub { font-size: 13px; color: var(--muted); text-wrap: pretty; margin: 0; }
.streakpanel__week { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: -4px; }
.streakpanel__eyebrow { font-size: 12px; font-weight: 800; letter-spacing: .05em; color: var(--faint); text-transform: uppercase; }
.streakpanel__tip { font-size: 12.5px; color: var(--faint); }
.streakpanel .streak__line { font-size: 13px; color: var(--muted); }
.streakpanel__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.histbtn-in {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  background: var(--card); border: 1px solid var(--accent-line); border-radius: 10px; padding: 8px 13px;
  font-size: 13px; font-weight: 800; color: var(--accent);
}
.histbtn-in .icon--cal { width: 15px; height: 15px; }
.histbtn-in:hover { background: var(--accent-soft); }

/* ==========================================================================
   All logged days & streaks
   ========================================================================== */

.sheet--history { width: min(740px, calc(100% - 24px)); padding: 0; gap: 0; max-height: 92vh; }
.hist__head { display: flex; align-items: flex-start; gap: 18px; padding: 22px 28px 18px; border-bottom: 1px solid var(--line-faint); }
.hist__titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.hist__eyebrow { font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.hist__title { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.hist__close {
  flex: none; width: 34px; height: 34px; border: 0; border-radius: var(--r-pill); background: var(--pill); color: var(--ink-2);
  font-size: 15px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.hist__stats { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 1px; background: var(--line-faint); border-bottom: 1px solid var(--line-faint); }
.hist__stat { background: var(--card); padding: 14px 20px; display: flex; flex-direction: column; gap: 3px; }
.hist__stat__label { font-size: 12px; font-weight: 700; color: var(--faint); }
.hist__stat__value { font-size: 19px; font-weight: 800; }
.hist__nav { display: flex; align-items: center; gap: 12px; padding: 18px 28px 0; }
.hist__nav .field { flex: none; width: auto; padding: 7px 12px; font-size: 13px; font-weight: 700; border-radius: var(--r-pill); }
.hist__grow { flex: 1; }
.hist__arrow {
  width: 34px; height: 34px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--card); color: var(--ink-2);
  font-size: 16px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.hist__arrow:disabled { color: var(--faint-2); border-color: var(--line); cursor: default; }
.hist__month { font-size: 18px; font-weight: 800; min-width: 170px; }
.hist__cal { padding: 16px 28px 4px; display: flex; flex-direction: column; gap: 8px; }
.hist__row { display: grid; grid-template-columns: 14px repeat(7, 1fr) 96px; gap: 8px; align-items: center; }
.hist__cal--plain .hist__row { grid-template-columns: 14px repeat(7, 1fr); }
.hist__row--head { margin-bottom: -2px; }
.hist__dow { font-size: 11.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); text-align: center; }
.hist__dow.is-wknd { color: var(--faint-2); }
.hist__dow--week { text-align: right; }
.hist__rail { width: 5px; height: 44px; border-radius: 3px; justify-self: center; }
.hist__rail.is-current { background: var(--accent); }
.hist__rail.is-past { background: var(--accent-line); }
/* rails on neighbouring weeks read as one bar */
.hist__row + .hist__row .hist__rail.is-current, .hist__row + .hist__row .hist__rail.is-past { height: calc(44px + 8px); margin-top: -8px; }
.hist__day {
  height: 44px; min-width: 0; border: 0; border-radius: 10px; padding: 0; background: var(--pill); color: var(--faint);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 14px; font-weight: 700; box-sizing: border-box;
}
.hist__day__tag { font-size: 9px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; opacity: .8; }
button.hist__day:hover { background: var(--hover); color: var(--ink); }
.hist__day.is-done { background: var(--accent); color: var(--on-accent); }
button.hist__day.is-done:hover { filter: brightness(1.08); background: var(--accent); color: var(--on-accent); }
.hist__day.is-today { background: var(--accent-soft); color: var(--accent); border: 2px dashed var(--accent); }
.hist__day.is-today.is-done { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.hist__day.is-future { background: var(--card); border: 1px dashed var(--line); color: var(--faint-2); }
.hist__day:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.hist__week { display: flex; align-items: center; justify-content: flex-end; gap: 6px; font-size: 13px; font-weight: 700; color: var(--faint); }
.hist__week.is-met { color: var(--accent); font-weight: 800; }
.hist__week.is-future { color: var(--faint-2); }
.hist__week .icon--flame { width: 11px; height: 13px; color: var(--flame); }
.hist__row--note { margin: -4px 0 0; }
.hist__runnote { grid-column: 2 / span 7; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 10px; padding: 8px 13px; font-size: 12.5px; }
.hist__runnote b { color: var(--accent); font-weight: 800; }
.hist__runnote span { color: var(--muted); }
.hist__empty { font-size: 13px; color: var(--faint); padding: 6px 0 0; }
.hist__toast { margin: 14px 28px 0; background: var(--ink); color: var(--on-ink); border-radius: 12px; padding: 12px 16px; display: flex; align-items: center; gap: 14px; }
.hist__toast__text { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; }
.hist__toast__text b { font-size: 13.5px; }
.hist__toast__text span { opacity: .75; }
.hist__toast .btn { border-color: color-mix(in srgb, var(--on-ink) 30%, transparent); background: none; color: var(--on-ink); }
.hist__legend { display: flex; flex-wrap: wrap; gap: 16px; padding: 18px 28px 0; }
.hist__legend__item { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); }
.hist__legend .icon--flame { width: 11px; height: 13px; color: var(--flame); }
.hist__swatch { width: 16px; height: 16px; border-radius: 5px; background: var(--pill); }
.hist__swatch.is-done { background: var(--accent); }
.hist__swatch.is-rail { width: 5px; border-radius: 3px; background: var(--accent); }
.hist__year { padding: 18px 28px 20px; }
.hist__year__head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.hist__year__rule { flex: 1; height: 1px; background: var(--line-faint); }
.hist__year__tip { font-size: 12px; color: var(--faint); }
.hist__ticks { display: flex; gap: 3px; align-items: flex-end; height: 30px; }
.hist__tick { flex: 1; min-width: 0; border: 0; padding: 0; border-radius: 2px; height: 10px; background: var(--line-faint); cursor: pointer; }
.hist__tick.is-met { height: 22px; background: var(--accent-line); }
.hist__tick.is-current { height: 22px; background: var(--accent); }
.hist__tick.is-future { height: 4px; background: transparent; border: 1px dashed var(--line); }
.hist__tick:hover { filter: brightness(.9); }
.hist__year__scale { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; color: var(--faint-2); font-weight: 700; }
.hist__foot { display: flex; align-items: center; gap: 18px; padding: 16px 28px 18px; border-top: 1px solid var(--line-faint); }
.hist__note { flex: 1; font-size: 13px; color: var(--muted); }

@media (max-width: 720px) {
  /* Full screen; the week count moves under each row as a caption. */
  .sheet--history { top: 0; bottom: 0; max-height: none; border-radius: 0; width: 100%; padding: 0; transform: none; }
  .hist__head { padding: calc(14px + env(safe-area-inset-top)) 16px 12px; }
  .hist__title { font-size: 19px; }
  .hist__stat { padding: 10px 12px; }
  .hist__stat__value { font-size: 16px; }
  .hist__nav { padding: 14px 16px 0; gap: 8px; flex-wrap: wrap; }
  .hist__month { min-width: 0; flex: none; white-space: nowrap; font-size: 16px; }
  .hist__cal { padding: 12px 12px 4px; gap: 10px; }
  .hist__row { grid-template-columns: 8px repeat(7, 1fr); gap: 4px; }
  .hist__cal--plain .hist__row { grid-template-columns: 8px repeat(7, 1fr); }
  .hist__dow--week { display: none; }
  .hist__rail { width: 4px; }
  .hist__day { height: 44px; font-size: 13px; border-radius: 8px; }
  .hist__week { grid-column: 2 / span 7; justify-content: flex-start; font-size: 12px; margin-top: -4px; }
  .hist__row + .hist__row .hist__rail.is-current, .hist__row + .hist__row .hist__rail.is-past { height: 44px; margin-top: 0; }
  .hist__legend, .hist__year { margin-left: 16px; margin-right: 16px; padding-left: 0; padding-right: 0; }
  .hist__toast { margin: 14px 16px 0; }
  .hist__legend { padding-top: 14px; }
  .hist__year { padding: 14px 0 16px; }
  .hist__foot { padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); position: sticky; bottom: 0; background: var(--card); }
}
.btn--quiet { font-weight: 800; color: var(--muted); text-decoration: none; }
.btn--quiet:hover { color: var(--ink); }

/* --- the switch ---------------------------------------------------------------- */
.switch {
  flex: none; width: 50px; height: 28px; border: 0; border-radius: var(--r-pill);
  background: var(--dash); padding: 3px; display: flex; align-items: center; justify-content: flex-start;
  transition: background .15s;
}
.switch__knob { width: 22px; height: 22px; border-radius: var(--r-pill); background: var(--card); transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch[aria-checked="true"] { background: var(--ok); }
.switch[aria-checked="true"] .switch__knob { transform: translateX(22px); background: var(--on-ink); }
.switch--sm { width: 36px; height: 20px; padding: 2px; }
.switch--sm .switch__knob { width: 16px; height: 16px; }
.switch--sm[aria-checked="true"] .switch__knob { transform: translateX(16px); }

@media (max-width: 720px) {
  .sheet__titlerow { align-items: flex-start; gap: 10px; }
  .sheet__titlerow .streak { margin-top: 4px; }
  .streakpanel { padding: 12px 12px; gap: 10px; }
  .streakpanel__title { font-size: 15px; }
  .wgrid--lg .wgrid__cell { height: 32px; }
}
@media (max-width: 360px) {
  .wgrid--lg .wgrid__long { display: none; }
  .wgrid--lg .wgrid__short { display: inline; }
}

/* ==========================================================================
   Weeks
   ========================================================================== */

.weeknav { display: flex; align-items: center; gap: 8px; min-width: 0; }
.weeknav__arrow {
  width: 28px; height: 28px; border: 0; border-radius: 8px; background: var(--pill); color: var(--ink-2);
  font-size: 16px; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0; flex: none;
}
.weeknav__arrow { transition: background .18s, transform .12s; }
.weeknav__arrow:hover { background: var(--hover); }
.weeknav__arrow:active { transform: scale(.92); }
.weeknav__label { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.weeknav__label h2 { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.weeknav__range { font-size: 13.5px; color: var(--muted); }
.weeknav .btn--chip { margin-left: 4px; color: var(--accent-ink); }
/* a week that has gone is a record; one still ahead is a plan, with no today in it */
.week--past .day { opacity: .82; }
.week--past .day.is-past { opacity: .82; }
.week--future .day { background: var(--today-bg); }
.btn--leftover { color: var(--accent-ink); border-color: var(--accent-line); }

@media (max-width: 720px) {
  .m-weekrow { display: flex; align-items: center; gap: 8px; }
  .m-weekrow__arrow {
    width: 34px; height: 34px; border: 0; border-radius: 10px; background: var(--card); color: var(--ink-2);
    font-size: 17px; font-weight: 800; flex: none; box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  }
  .m-weekrow__label {
    flex: 1; min-width: 0; border: 0; background: none; padding: 4px 0; font: inherit; color: inherit;
    display: flex; flex-direction: column; align-items: center; gap: 1px; line-height: 1.2;
  }
  .m-weekrow__label b { font-size: 15px; font-weight: 800; }
  .m-weekrow__label span { font-size: 12px; color: var(--muted); }
}

/* ==========================================================================
   Integrations
   ========================================================================== */

.intlist { display: flex; flex-direction: column; gap: 8px; }
.introw {
  display: flex; align-items: center; gap: 14px;
  background: var(--field); border: 1px solid var(--line); border-radius: var(--r-field); padding: 12px 14px;
}
.introw__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
/* the row that takes a new address: a field and its button, level */
.introw--add { align-items: center; gap: 10px; }
.introw--add .field { flex: 1; min-width: 0; }
.introw__text textarea.field { min-height: 5.5em; margin-top: 4px; }
.introw__text .introw__acts { margin-top: 6px; }
.introw__acts { flex: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.introw__name { font-size: 15px; font-weight: 800; }
.introw__blurb { font-size: 13px; color: var(--muted); text-wrap: pretty; }
.introw__state { font-size: 12.5px; color: var(--ok); font-weight: 700; }
.introw__state.is-off { color: var(--muted); font-weight: 400; }
.introw__state.is-bad { color: var(--warn-ink); font-weight: 700; }
/* No room beside the text on a phone: the controls go under it. */
@media (max-width: 720px) {
  .introw { flex-direction: column; align-items: stretch; gap: 10px; }
  .introw__acts { justify-content: flex-start; }
}
a.btn { text-decoration: none; display: inline-block; }
a.btn.is-disabled { opacity: .5; cursor: default; }
.qnums__source { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qnums__source .field { flex: 1; min-width: 160px; }
.qnums__source .qnums__sub { flex-basis: 100%; }
