/* ==========================================================================
   Daily Rhythm — stylesheet
   Tokens → base → layout → components → views → focus
   ========================================================================== */

/* ---- Tokens: Light · Fjord (default) ------------------------------------ */

:root {
  --desk:        #E9F1F4;   /* pale sea, the surface the sheets rest on */
  --sheet:       #FFFFFF;
  --sheet-tint:  #F5F9FA;
  --ink:         #1D292E;
  --ink-soft:    #4A585E;
  --muted:       #85949A;
  --rule:        #DFE8EB;
  --rule-strong: #C3D2D8;

  --accent:      #2C6C8A;   /* fjord blue */
  --accent-mid:  #6FA3BD;
  --accent-soft: #E0EEF4;
  --on-accent:   #FFFFFF;

  --sky:         #A6CBDD;
  --sky-mid:     #CBE0EA;
  --sky-soft:    #E4F0F6;
  --sky-deep:    #3F7895;

  --pine:        #5E8676;
  --hill:        #DCE9E4;
  --water:       #D3E6EF;
  --cabin:       #A35846;
  --cabin-roof:  #5C3A33;
  --sun:         #FFFFFF;

  --knit-base:        #2C6C8A;
  --knit-motif:       #F7F4EC;
  --knit-ghost:       rgba(44, 108, 138, .09);
  --knit-ghost-motif: rgba(44, 108, 138, .2);
  --knit-needle:      #A88B63;

  --warn:   #A0614A;
  --shadow: 0 1px 2px rgba(29, 41, 46, .04), 0 6px 20px rgba(29, 41, 46, .045);

  --serif: "EB Garamond", "Garamond", "Times New Roman", serif;
  --sans:  "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  --measure: 840px;
  --gutter: 16px;
  --radius: 8px;

  color-scheme: light;
}

/* ---- Tokens: Dark · Forest ---------------------------------------------- */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --desk:        #131A18;
    --sheet:       #1A2220;
    --sheet-tint:  #1E2724;
    --ink:         #E3E9E5;
    --ink-soft:    #B2BDB8;
    --muted:       #7D8A85;
    --rule:        #2A3430;
    --rule-strong: #3C4843;
    --accent:      #8FC2A2;
    --accent-mid:  #5F8C72;
    --accent-soft: #22332D;
    --on-accent:   #131A18;
    --sky:         #4F7891;
    --sky-mid:     #24384A;
    --sky-soft:    #1B2830;
    --sky-deep:    #93BCD4;
    --pine:        #3F6656;
    --hill:        #1F2E29;
    --water:       #182630;
    --cabin:       #8A4A3A;
    --cabin-roof:  #3A2622;
    --sun:         #7F938A;
    --knit-base:        #3E6E58;
    --knit-motif:       #E9E4D8;
    --knit-ghost:       rgba(143, 194, 162, .08);
    --knit-ghost-motif: rgba(143, 194, 162, .18);
    --knit-needle:      #B59B74;
    --warn:   #D19C84;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --desk:        #131A18;
  --sheet:       #1A2220;
  --sheet-tint:  #1E2724;
  --ink:         #E3E9E5;
  --ink-soft:    #B2BDB8;
  --muted:       #7D8A85;
  --rule:        #2A3430;
  --rule-strong: #3C4843;
  --accent:      #8FC2A2;
  --accent-mid:  #5F8C72;
  --accent-soft: #22332D;
  --on-accent:   #131A18;
  --sky:         #4F7891;
  --sky-mid:     #24384A;
  --sky-soft:    #1B2830;
  --sky-deep:    #93BCD4;
  --pine:        #3F6656;
  --hill:        #1F2E29;
  --water:       #182630;
  --cabin:       #8A4A3A;
  --cabin-roof:  #3A2622;
  --sun:         #7F938A;
  --knit-base:        #3E6E58;
  --knit-motif:       #E9E4D8;
  --knit-ghost:       rgba(143, 194, 162, .08);
  --knit-ghost-motif: rgba(143, 194, 162, .18);
  --knit-needle:      #B59B74;
  --warn:   #D19C84;
  --shadow: none;
  color-scheme: dark;
}

/* ---- Base -------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;   /* no rubber-band bounce at the top and bottom */
}

body {
  margin: 0;
  overscroll-behavior: none;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .3s;
}

body.is-focusing { overflow: hidden; }

.scroller::-webkit-scrollbar,
.focus::-webkit-scrollbar { display: none; }
.focus { scrollbar-width: none; }

/* On touch screens the page scrolls inside .scroller so the scroll indicator can be hidden. */
@media (pointer: coarse) {
  html, body { height: 100%; overflow: hidden; }
  .scroller {
    height: 100%;
    overflow-y: auto;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
}

a { color: inherit; text-decoration: none; }

input, button, select, textarea { font: inherit; color: inherit; }

button { background: none; border: 0; padding: 0; cursor: pointer; }

[hidden] { display: none !important; }

:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  font-family: var(--sans);
  font-size: 12px;
  text-align: center;
  color: var(--ink-soft);
  background: var(--sheet-tint);
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
}

/* ---- Page & sheets ----------------------------------------------------- */

.page {
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--s4) var(--gutter) var(--s7);
  padding-top: max(var(--s4), env(safe-area-inset-top));
  padding-bottom: max(var(--s7), calc(env(safe-area-inset-bottom) + var(--s5)));
}

@media (min-width: 720px) {
  .page { padding: var(--s7) var(--s6) var(--s8); }
}

.sheet {
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---- Buttons & fields -------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 40px;
  padding: 0 var(--s4);
  font-size: 14px;
  border-radius: 999px;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--primary:hover { filter: brightness(1.06); }
.btn--quiet { color: var(--ink-soft); border: 1px solid var(--rule-strong); }
.btn--quiet:hover { color: var(--accent); border-color: var(--accent-mid); }
.btn--small { min-height: 32px; padding: 0 var(--s3); font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s4); }
.field__label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.field__input {
  width: 100%;
  min-width: 0;
  padding: 10px var(--s3);
  background: var(--sheet-tint);
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-size: 16px;
}
.field__input:focus { outline: none; border-color: var(--accent-mid); background: var(--sheet); }
.field__input--large { font-family: var(--serif); font-size: 20px; padding: 10px var(--s4); }
.field__input--num { width: 84px; }
.field__inline { display: inline-flex; align-items: center; gap: var(--s2); color: var(--ink-soft); font-size: 15px; }

.field--row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s3) 0;
  margin: 0;
  border-bottom: 1px solid var(--rule);
}
.field--row:last-child { border-bottom: 0; }
.field--row .field__label {
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}

.switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 42px !important;
  height: 24px !important;
  margin: 0;
  background: var(--rule-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color .2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--sheet);
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
  transition: transform .2s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }

.link { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent-mid); text-underline-offset: 2px; }
.link:hover { text-decoration-color: currentColor; }
.field--row select.field__input { width: auto; flex-shrink: 0; }
.field--check input { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--accent); }
.field__hint { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
.field__input:disabled { opacity: .5; }


.is-invalid { box-shadow: inset 0 -1px 0 var(--warn) !important; }
.is-invalid::placeholder { color: var(--warn) !important; }

/* ---- Hero / masthead --------------------------------------------------- */

.hero { position: relative; overflow: hidden; }

.horizon { display: block; width: 100%; height: 100px; }
@media (min-width: 720px) { .horizon { height: 136px; } }

.sky-top    { stop-color: var(--sky-soft); }
.sky-bottom { stop-color: var(--sheet); }
.sun        { fill: var(--sun); opacity: .9; }
.ridge-far  { fill: var(--sky-mid); }
.ridge-near { fill: var(--hill); }
.water      { fill: var(--water); }
.ripples    { stroke: var(--sheet); stroke-width: 1.2; stroke-linecap: round; opacity: .8; fill: none; }
.pines      { fill: var(--pine); }
.cabin__wall { fill: var(--cabin); }
.cabin__roof { fill: var(--cabin-roof); }

.hero__top {
  position: absolute;
  top: var(--s3);
  right: var(--s3);
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.hero__icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--sheet) 70%, transparent);
  border-radius: 50%;
  backdrop-filter: blur(4px);
  transition: color .15s, background-color .15s;
}
.hero__icon:hover { color: var(--accent); background: var(--sheet); }
.hero__icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; }
.hero__icon .knob { fill: var(--sheet); }
.hero__icon:hover .knob { fill: var(--sheet); }
.hero__icon .icon-close { display: none; }
body[data-view="settings"] .hero__icon .icon-settings { display: none; }
body[data-view="settings"] .hero__icon .icon-close { display: block; }

.sync {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  font-size: 11px;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--sheet) 70%, transparent);
  border-radius: 999px;
  backdrop-filter: blur(4px);
}
.sync__dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent-mid); }
.sync[data-state="failed"] { color: var(--warn); }
.sync[data-state="failed"] .sync__dot { background: var(--warn); }
.sync[data-state="saving"] .sync__dot,
.sync[data-state="syncing"] .sync__dot { background: var(--sky); animation: breathe 1.4s ease-in-out infinite; }
.sync[data-state="offline"] .sync__dot,
.sync[data-state="local"] .sync__dot { background: var(--rule-strong); }

@keyframes breathe { 50% { opacity: .3; } }

.hero__body {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--s4);
  padding: var(--s2) var(--s5) var(--s4);
}

body:not([data-view="today"]) .hero__body--day,
body:not([data-view="today"]) .epigraph,
body[data-view="today"] .hero__body--page { display: none; }

.hero__date { display: flex; align-items: flex-end; gap: var(--s4); min-width: 0; }

.hero__numeral {
  font-family: var(--serif);
  font-size: 84px;
  line-height: .8;
  color: var(--accent);
  font-variant-numeric: lining-nums;
  margin-bottom: 2px;
}
@media (min-width: 720px) { .hero__numeral { font-size: 112px; } }

.hero__meta { min-width: 0; }

.hero__weekday {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--sky-deep);
}

.hero__month {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 26px;
  line-height: 1.15;
}
@media (min-width: 720px) { .hero__month { font-size: 34px; } }

.hero__count {
  margin: var(--s1) 0 0;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.hero__aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--s3);
  flex-shrink: 0;
}

.daynav { display: flex; align-items: center; gap: 2px; }

.daynav__btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  border-radius: 50%;
  transition: color .15s, border-color .15s;
}
.daynav__btn:hover { color: var(--accent); border-color: var(--accent-mid); }

.daynav__today { font-size: 13px; color: var(--ink-soft); padding: 0 var(--s2); }
.daynav__today:hover { color: var(--accent); }
.daynav__today[aria-current] { color: var(--muted); pointer-events: none; }

/* The focus button: the one invitation on the page */
.focus-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  height: 40px;
  padding: 0 var(--s4) 0 var(--s3);
  font-size: 14px;
  color: var(--on-accent);
  background: var(--accent);
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 4px 14px color-mix(in srgb, var(--accent) 28%, transparent);
  transition: transform .2s, box-shadow .2s;
}
.focus-btn:hover { transform: translateY(-1px); box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 8px 22px color-mix(in srgb, var(--accent) 34%, transparent); }
.focus-btn svg {
  width: 20px; height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
}

/* Epigraph */
.epigraph {
  margin: 0;
  padding: var(--s4) var(--s5) var(--s5);
  border-top: 1px solid var(--rule);
  background: var(--sheet-tint);
}
.epigraph blockquote {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 19px;
  line-height: 1.4;
  text-wrap: pretty;
}
.epigraph blockquote::before { content: "“"; color: var(--sky); margin-right: 1px; }
.epigraph blockquote::after  { content: "”"; color: var(--sky); margin-left: 1px; }
.epigraph figcaption {
  margin-top: var(--s2);
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--muted);
}

@media (max-width: 520px) {
  .hero__body { padding: var(--s2) var(--s4) var(--s4); flex-wrap: wrap; }
  .hero__body--day .hero__aside {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }
  .epigraph { padding: var(--s4); }
  .epigraph blockquote { font-size: 17px; }
}

/* ---- Week strip -------------------------------------------------------- */

.weekstrip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin: var(--s4) 0;
}

.weekstrip__day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: var(--s2) 0;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--ink-soft);
  transition: border-color .15s;
}
.weekstrip__day:hover { border-color: var(--sky); }

.weekstrip__dow {
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.weekstrip__num {
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.1;
  font-variant-numeric: lining-nums;
}

.weekstrip__dots { display: flex; gap: 3px; min-height: 4px; flex-wrap: wrap; justify-content: center; max-width: 80%; }
.weekstrip__dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--rule-strong); }
.weekstrip__dots i.on { background: var(--accent-mid); }

.weekstrip__hrs {
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.weekstrip__day.is-today .weekstrip__num { text-decoration: underline; text-decoration-color: var(--sky); text-underline-offset: 4px; }

.weekstrip__day.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.weekstrip__day.is-current .weekstrip__dow,
.weekstrip__day.is-current .weekstrip__hrs { color: color-mix(in srgb, var(--on-accent) 75%, transparent); }
.weekstrip__day.is-current .weekstrip__dots i { background: color-mix(in srgb, var(--on-accent) 30%, transparent); }
.weekstrip__day.is-current .weekstrip__dots i.on { background: var(--on-accent); }
.weekstrip__day.is-current .weekstrip__num { color: var(--on-accent); text-decoration: none; }

.weekstrip__day.is-future:not(.is-current) { background: transparent; border-style: dashed; }
.weekstrip__day.is-future:not(.is-current) .weekstrip__num { color: var(--muted); }

/* ---- Grid -------------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s4);
}
.grid > * { min-width: 0; }

@media (min-width: 720px) {
  .grid {
    grid-template-columns: repeat(12, 1fr);
    grid-template-areas:
      "three three three three three three three habits  habits  habits  habits  habits"
      "work  work  work  work  work  work  work  evening evening evening evening evening";
  }
  .block--three   { grid-area: three; }
  .block--habits  { grid-area: habits; }
  .block--work    { grid-area: work; }
  .block--evening { grid-area: evening; align-self: start; }
}

.slide-next { animation: slide-next .28s ease-out; }
.slide-prev { animation: slide-prev .28s ease-out; }
@keyframes slide-next { from { opacity: .4; transform: translateX(10px); } }
@keyframes slide-prev { from { opacity: .4; transform: translateX(-10px); } }
@media (prefers-reduced-motion: reduce) {
  .slide-next, .slide-prev { animation: none; }
}

/* ---- Block chrome ------------------------------------------------------ */

.block { padding: var(--s5) var(--s5) var(--s4); }
@media (max-width: 520px) { .block { padding: var(--s4); } }

.block__head { display: flex; align-items: baseline; gap: var(--s3); margin-bottom: var(--s4); }

.block__no { font-family: var(--serif); font-size: 13px; color: var(--sky-deep); min-width: 18px; }

.block__title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: .005em;
}

.block__aside {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.block__foot {
  margin: var(--s4) 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--muted);
}

/* ---- Today's three ----------------------------------------------------- */

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

.three__item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 28px;
  align-items: start;
  gap: var(--s2);
  min-height: 52px;
  border-bottom: 1px solid var(--rule);
}
.three__item:first-child { border-top: 1px solid var(--rule); }

.three__num { font-family: var(--serif); font-style: italic; font-size: 16px; color: var(--sky-deep); line-height: 24px; padding-top: 13px; }
.three__item .check { margin-top: 11px; }

.three__text {
  display: block;
  width: 100%;
  min-width: 0;
  border: 0;
  padding: 12px 0;
  overflow: hidden;
  resize: none;
  background: transparent;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.3;
}
.three__text::placeholder { color: var(--muted); font-style: italic; opacity: .7; }
.three__text:focus { outline: none; }
.three__item:focus-within { border-bottom-color: var(--accent-mid); }

.three__item:has(.check input:checked) .three__text {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--accent-mid);
}

.check { position: relative; display: grid; place-items: center; width: 28px; height: 28px; cursor: pointer; }
.check input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.check__mark {
  width: 18px; height: 18px;
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  transition: background-color .2s, border-color .2s;
}
.check:hover .check__mark { border-color: var(--accent-mid); }
.check input:checked + .check__mark {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 3px var(--sheet);
}
.check input:focus-visible + .check__mark { outline: 1px solid var(--accent); outline-offset: 3px; }

/* ---- Habits ------------------------------------------------------------ */

.habits {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s2);
}
@media (min-width: 720px), (max-width: 359px) { .habits { grid-template-columns: 1fr; } }

.habits__empty {
  grid-column: 1 / -1;
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
}

.habit {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 44px;
  padding: 0 var(--s3);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  transition: background-color .2s, border-color .2s;
}
.habit:hover { border-color: var(--accent-mid); }
.habit input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.habit__dot { width: 10px; height: 10px; border: 1px solid var(--rule-strong); border-radius: 50%; flex-shrink: 0; }
.habit__label { font-size: 15px; color: var(--ink-soft); }

.habit:has(input:checked) { background: var(--accent-soft); border-color: var(--accent-soft); }
.habit input:checked ~ .habit__dot { background: var(--accent); border-color: var(--accent); }
.habit input:checked ~ .habit__label { color: var(--accent); }
.habit:has(input:focus-visible) { outline: 1px solid var(--accent); outline-offset: 2px; }

/* ---- Work -------------------------------------------------------------- */

.enough { margin-bottom: var(--s4); }
.enough__track { height: 6px; border-radius: 3px; background: var(--sky-soft); overflow: hidden; }
.enough__fill {
  height: 100%;
  width: calc(var(--p, 0) * 100%);
  border-radius: 3px;
  background: linear-gradient(90deg, var(--sky), var(--accent-mid));
  transition: width .5s ease;
}
.enough.is-full .enough__fill { background: var(--accent); }
.enough__scale {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--muted);
}

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

.work__row {
  display: grid;
  grid-template-columns: 64px 1fr 24px;
  align-items: baseline;
  gap: var(--s3);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--rule);
}
.work__row:first-child { border-top: 1px solid var(--rule); }

.work__time {
  font-family: var(--serif);
  font-size: 19px;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--accent);
}
.work__subject { font-size: 15px; display: flex; align-items: center; gap: var(--s2); }

/* A tiny knitted swatch: marks work finished in a focus session */
.work__knit {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background:
    repeating-linear-gradient(90deg, transparent 0 2px, color-mix(in srgb, var(--knit-motif) 55%, transparent) 2px 3px),
    repeating-linear-gradient(0deg, var(--knit-base) 0 2px, color-mix(in srgb, var(--knit-base) 75%, var(--knit-motif)) 2px 3px);
  flex-shrink: 0;
}

.work__remove {
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  opacity: 0;
  transition: opacity .15s, color .15s;
}
.work__row:hover .work__remove,
.work__remove:focus-visible { opacity: 1; }
.work__remove:hover { color: var(--warn); }
@media (hover: none) { .work__remove { opacity: .6; } }

.work__add {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: var(--s3);
  align-items: center;
  margin-top: var(--s3);
  padding: 6px 6px 6px var(--s3);
  background: var(--sheet-tint);
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius);
}
.work__add:focus-within { border-style: solid; border-color: var(--sky); }

/* Fields stay at 16px or larger: iOS zooms into anything smaller. */
.work__in { width: 100%; min-width: 0; border: 0; padding: var(--s1) 0; background: transparent; font-size: 16px; }
.work__in--time { font-family: var(--serif); font-size: 18px; }
.work__in::placeholder { color: var(--muted); opacity: .8; }
.work__in:focus { outline: none; }

/* ---- Evening ----------------------------------------------------------- */

.note__wrap {
  background-image: linear-gradient(var(--sky-mid) 1px, transparent 1px);
  background-size: 100% 36px;
  background-position: 0 35px;
  padding-bottom: 2px;
}
.note {
  display: block;
  width: 100%;
  min-height: 36px;
  border: 0;
  padding: 0;
  overflow: hidden;
  resize: none;
  background: transparent;
  font-family: var(--serif);
  font-style: italic;
  font-size: 19px;
  line-height: 36px;
}
.note::placeholder { color: var(--muted); opacity: .8; }
.note:focus { outline: none; }
.note__wrap:focus-within { background-image: linear-gradient(var(--accent-mid) 1px, transparent 1px); }

/* ---- Week view --------------------------------------------------------- */

.view--week, .view--settings { margin-top: var(--s4); }

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

.wrow {
  display: grid;
  grid-template-columns: 56px 1fr auto 72px;
  grid-template-areas:
    "date habits three hrs"
    "date note   note  note";
  align-items: center;
  column-gap: var(--s4);
  row-gap: 2px;
  padding: var(--s3) var(--s2);
  border-bottom: 1px solid var(--rule);
  border-radius: 4px;
  transition: background-color .15s;
}
.week__list li:nth-child(2) .wrow { border-top: 1px solid var(--rule); }
.wrow--head { display: none; }
@media (min-width: 720px) {
  .wrow--head {
    display: grid;
    padding-top: 0;
    padding-bottom: var(--s2);
    border-bottom: 0;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .wrow--head:hover { background: none; }
  .wrow--head span { font: inherit; color: inherit; letter-spacing: inherit; }
}
.wrow:hover { background: var(--sheet-tint); }

@media (min-width: 720px) {
  .wrow {
    grid-template-columns: 64px 120px 56px 84px 1fr;
    grid-template-areas: "date habits three hrs note";
    padding: var(--s3) var(--s3);
  }
}

.wrow__date { grid-area: date; display: flex; align-items: baseline; gap: 6px; }
.wrow__dow { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); width: 18px; }
.wrow__num { font-family: var(--serif); font-size: 22px; font-variant-numeric: lining-nums; }
.wrow.is-today .wrow__num { color: var(--accent); }
.wrow.is-future { opacity: .55; }

.wrow__habits { grid-area: habits; display: flex; gap: 5px; flex-wrap: wrap; }
.wrow__habits i { width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--rule-strong); }
.wrow__habits i.on { background: var(--accent-mid); border-color: var(--accent-mid); }

.wrow__three { grid-area: three; display: flex; gap: 3px; }
.wrow__three i { width: 10px; height: 2px; background: var(--rule); }
.wrow__three i.set { background: var(--rule-strong); }
.wrow__three i.on { background: var(--accent); }

.wrow__hrs {
  grid-area: hrs;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  font-family: var(--serif);
  font-size: 17px;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--accent);
  white-space: nowrap;
}
.wrow__hrs .work__knit:first-of-type { margin-left: 4px; }
@media (min-width: 720px) { .wrow__hrs { justify-content: flex-start; } }

.wrow__note {
  grid-area: note;
  min-width: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.week__sum {
  margin: var(--s4) 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--muted);
  text-align: center;
}

/* ---- Settings ---------------------------------------------------------- */

.view--settings { display: grid; gap: var(--s4); }
.view--settings[hidden] { display: none; }

.settings__help { margin: calc(-1 * var(--s2)) 0 var(--s4); font-size: 14px; color: var(--muted); }
.settings__actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.settings__status { margin: var(--s3) 0 0; font-size: 13px; color: var(--muted); min-height: 1.5em; }
.settings__status[data-state="failed"] { color: var(--warn); }
.settings__status[data-state="synced"] { color: var(--accent); }

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 3px;
  gap: 3px;
  background: var(--sheet-tint);
  border: 1px solid var(--rule);
  border-radius: 999px;
}
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: block; padding: 6px var(--s4); font-size: 14px; color: var(--ink-soft); border-radius: 999px; transition: background-color .15s, color .15s; }
.segmented input:checked + span { background: var(--accent); color: var(--on-accent); }
.segmented input:focus-visible + span { outline: 1px solid var(--accent); outline-offset: 2px; }

.habit-edit { list-style: none; margin: 0 0 var(--s3); padding: 0; }
.habit-edit__row {
  display: grid;
  grid-template-columns: 1fr auto 24px;
  gap: var(--s3);
  align-items: center;
  padding: var(--s2) 0;
  border-bottom: 1px solid var(--rule);
}
.habit-edit__name { background: transparent; border-color: transparent; padding: 6px var(--s2); }
.habit-edit__name:hover { border-color: var(--rule); }
.habit-edit__rm { opacity: .6; }
@media (max-width: 520px) {
  .habit-edit__row { grid-template-columns: 1fr 24px; }
  .habit-edit__row .daypick { grid-column: 1 / -1; grid-row: 2; }
}

.daypick { display: flex; gap: 3px; }
.daypick__d {
  width: 28px; height: 28px;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 50%;
  transition: background-color .15s, color .15s, border-color .15s;
}
.daypick__d:hover { border-color: var(--accent-mid); }
.daypick__d[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent); font-weight: 500; }

.habit-add { display: flex; gap: var(--s2); }

.keys { margin: var(--s4) 0 0; display: grid; gap: var(--s2); }
.keys div { display: flex; gap: var(--s3); align-items: center; }
.keys dt { min-width: 84px; }
.keys dd { margin: 0; font-size: 14px; color: var(--ink-soft); }

/* ---- Colophon ---------------------------------------------------------- */

.colophon {
  display: flex;
  align-items: center;
  gap: var(--s4);
  margin-top: var(--s6);
  font-size: 13px;
  color: var(--ink-soft);
}
.colophon__nav { display: flex; gap: var(--s4); }
.colophon__nav a { padding: var(--s1) 0; border-bottom: 1px solid transparent; }
.colophon__nav a:hover { color: var(--accent); }
.colophon__nav a[aria-current] { color: var(--ink); border-bottom-color: var(--accent-mid); }
.colophon__rule { flex: 1; height: 1px; background: var(--rule-strong); }
.colophon__mark { font-family: var(--serif); font-style: italic; color: var(--muted); }

/* ==========================================================================
   Focus session
   ========================================================================== */

.focus {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow-y: auto;
  background:
    radial-gradient(120% 60% at 50% 0%, var(--sky-soft), transparent 70%),
    var(--desk);
  overscroll-behavior: none;
  animation: focus-in .35s ease-out;
}
@keyframes focus-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .focus, .focus[data-state="done"] .knit { animation: none; } }

.focus__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 420px;
  min-height: 100%;
  margin: 0 auto;
  padding: max(var(--s6), env(safe-area-inset-top)) var(--gutter) max(var(--s6), env(safe-area-inset-bottom));
  justify-content: center;
}

.focus__eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--sky-deep);
  text-align: center;
}

.focus__time {
  margin: var(--s1) 0 var(--s5);
  font-family: var(--serif);
  font-size: 64px;
  line-height: 1;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: .01em;
  color: var(--ink);
}
@media (min-width: 720px) { .focus__time { font-size: 76px; } }

.focus__setup { width: 100%; margin-bottom: var(--s4); }
.focus:not([data-state="setup"]) .focus__setup { display: none; }

.dial { position: relative; }

.dial__track {
  --tick: 14px;
  display: flex;
  height: 66px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent);
  border-radius: var(--radius);
}
.dial__track::-webkit-scrollbar { display: none; }
.dial__track::before,
.dial__track::after { content: ""; flex: 0 0 calc(50% - var(--tick) / 2); }
.dial__track:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; }

.dial__tick {
  position: relative;
  flex: 0 0 var(--tick);
  height: 100%;
  scroll-snap-align: center;
  cursor: pointer;
}
.dial__tick::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 12px;
  width: 1px;
  height: 12px;
  background: var(--rule-strong);
  transform: translateX(-50%);
  transition: height .15s, background-color .15s;
}
.dial__tick--major::before { height: 20px; background: var(--muted); }
.dial__tick span {
  position: absolute;
  left: 50%;
  top: 38px;
  transform: translateX(-50%);
  font-family: var(--serif);
  font-size: 15px;
  font-variant-numeric: lining-nums;
  color: var(--muted);
  white-space: nowrap;
  transition: color .15s;
}
.dial__tick.is-selected::before { width: 2px; height: 24px; background: var(--accent); }
.dial__tick.is-selected span { color: var(--accent); }

.dial__needle {
  position: absolute;
  left: 50%;
  top: 0;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 1px;
  transform: translate(-50%, -1px) rotate(45deg);
  pointer-events: none;
}

.knit {
  width: 100%;
  max-width: 340px;
  padding: var(--s4) var(--s4) var(--s3);
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: opacity .4s;
}
.knit canvas { display: block; width: 100%; }
.focus[data-state="setup"] .knit { max-width: 220px; padding: var(--s3); opacity: .9; }
.focus[data-state="done"] .knit { animation: settle .8s ease-out; }
@keyframes settle { 40% { transform: translateY(-3px); } }

.focus__msg {
  margin: var(--s5) 0 var(--s4);
  max-width: 340px;
  min-height: 1.4em;
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink-soft);
  text-align: center;
  text-wrap: pretty;
}
.focus[data-state="broken"] .focus__msg { color: var(--warn); }

.focus__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s2); }
