:root, .light {
  --bg: #FBFAF6; --ink: #161B33; --mute: #555B73; --acc: #3342C4;
  --on: #FFFFFF; --line: #D9D9E0; --dim: rgba(22, 27, 51, .35); --hl: #DFE0EF;
}
.dark {
  --bg: #0A0C12; --ink: #ECEDF4; --mute: #A3A8BE; --acc: #9AA7FF;
  --on: #0A0C12; --line: #2C3040; --dim: rgba(10, 12, 18, .45); --hl: #212538;
}
:root {
  --font-serif: "Iowan Old Style", "Charter", "Georgia", serif;
  --font-sans: system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
  --fs-title: 40px; --fs-sub: 18px; --fs-item: 19px; --fs-time: 16px;
  --fs-small: 14px; --fs-part: 14px;
  --row-min: 52px; --tap: 44px; --check: 26px; --check-zone-w: 44px;
  --check-radius: 6px; --page-x: 20px;
}
*, *::before, *::after { box-sizing: border-box; }
html, body {
  background: var(--bg); color: var(--ink); margin: 0;
  font-family: var(--font-serif);
}
button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0;
  cursor: pointer; text-align: inherit;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
main { padding: 28px 20px 20px; }
main.has-bar { padding-bottom: 104px; }
h1 { font-size: 40px; font-weight: 700; line-height: 1; letter-spacing: -.02em; margin: 0; }
.sub {
  font-size: var(--fs-sub); font-style: italic; color: var(--mute);
  margin: 6px 0 10px; padding-bottom: 14px; border-bottom: 2px solid var(--ink);
}
h2 {
  font-family: var(--font-sans); font-size: var(--fs-part); font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--acc); margin: 22px 0 2px;
}
.row { display: flex; align-items: center; min-height: var(--row-min); border-bottom: 1px solid var(--line);
  transition: background-color 600ms ease-out, box-shadow 600ms ease-out; }
.row.added, .r.added { background: var(--hl); box-shadow: -12px 0 0 var(--hl), 12px 0 0 var(--hl); transition: none; }

.chk { flex: none; width: 44px; height: 52px; display: grid; place-items: center; margin-left: -8px; }
.chk i {
  width: var(--check); height: var(--check); border: 2px solid var(--ink); border-radius: var(--check-radius);
  display: grid; place-items: center; font-style: normal; font-size: 16px; font-weight: 700; color: var(--on);
  transition: background-color 120ms ease-out, border-color 120ms ease-out, color 120ms ease-out;
}
.done .chk i { background: var(--acc); border-color: var(--acc); }
.txt {
  flex: 1; min-width: 0; font-size: var(--fs-item); line-height: 1.25; padding: 8px 0 8px 6px;
  overflow-wrap: anywhere; transition: color 120ms ease-out;
}
.done .txt { color: var(--mute); text-decoration: line-through; }
.time {
  font-family: var(--font-mono); font-size: var(--fs-time); font-weight: 600; color: var(--acc); margin-right: 6px;
}
.txt small {
  display: block; font-family: var(--font-sans); font-size: var(--fs-small); color: var(--mute); text-decoration: none;
}
.more {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center;
  color: var(--mute); font-family: var(--font-sans); font-size: 22px; text-align: center;
}
/* поле «добавить дело» */
.field { margin-top: 18px; min-height: 56px; display: flex; align-items: center; gap: 8px;
  padding-bottom: 6px; border-bottom: 2px solid var(--ink); }
.field.on, .field:focus-within { border-bottom-color: var(--acc); }
.field:has(.in.busy) { border-bottom-color: var(--ink); }
.field .in { flex: 1; min-width: 0; font: inherit; font-size: var(--fs-item); line-height: 1.25;
  color: var(--ink); caret-color: var(--acc); background: none; border: 0; border-radius: 0;
  padding: 8px 0; margin: 0; resize: none; overflow-wrap: anywhere; outline: none; max-height: 9.5em; }
.field .in::placeholder { font-style: italic; color: var(--mute); opacity: 1; }
.field .in.busy { color: var(--mute); }
.send { flex: none; width: var(--tap); height: var(--tap); border-radius: 50%; display: grid; place-items: center;
  font-family: var(--font-sans); font-size: 24px; font-weight: 700; background: var(--acc); color: var(--on); }
.send[disabled] { background: transparent; border: 2px solid var(--line); color: var(--mute); cursor: default; }
.state { display: flex; align-items: center; gap: 12px; font-family: var(--font-sans);
  font-size: 16px; color: var(--mute); }
.state:not(:empty) { min-height: 44px; }
.state span { flex: 1; }
.state .btn { margin-top: 0; min-height: 44px; padding: 0 18px; }
.state.to { flex-wrap: wrap; gap: 6px 10px; padding-top: 2px; }
.state.to span { flex: 1 0 100%; }
.state.to .btn { min-width: var(--tap); min-height: 48px; padding: 0 20px; }
.state.to .btn.q { border-color: var(--line); }
.state.to .btn[disabled] { border-color: var(--line); color: var(--mute); font-weight: 400; }
.center { margin-top: 120px; }
.center p { font-size: 22px; font-weight: 700; line-height: 1.25; margin: 0; }
.center small { display: block; font-size: 16px; color: var(--mute); margin-top: 10px; line-height: 1.35; }
.btn {
  margin-top: 22px; min-height: 48px; min-width: 44px; padding: 0 22px; border: 2px solid var(--ink);
  border-radius: 6px; display: inline-grid; place-items: center;
  font-family: var(--font-sans); font-size: 16px; font-weight: 700; text-align: center;
}
.btn[disabled] { color: var(--mute); border-color: var(--line); cursor: default; }
.sk { height: 52px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; }
.sk i { width: 26px; height: 26px; border: 2px solid var(--line); border-radius: 6px; }
.sk u { height: 12px; background: var(--line); border-radius: 6px; display: block; }

/* лист меню */
.dim {
  position: fixed; inset: 0; background: var(--dim); z-index: 10;
  opacity: 0; transition: opacity 180ms ease-out;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; background: var(--bg);
  border-top: 2px solid var(--ink);
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  max-height: 90vh; overflow: auto; overscroll-behavior: contain;
  transform: translateY(100%); transition: transform 180ms ease-out;
}
.in .dim { opacity: 1; }
.in .sheet { transform: translateY(0); }
.out .dim { opacity: 0; transition-duration: 140ms; }
.out .sheet { transform: translateY(100%); transition-duration: 140ms; }
.sheet .ttl {
  font-size: 18px; font-style: italic; color: var(--mute); padding: 10px 0 8px;
  border-bottom: 1px solid var(--line); overflow-wrap: anywhere;
}
.sheet .back {
  display: flex; align-items: center;
  min-height: 44px; min-width: 44px; padding: 0;
  font-family: var(--font-sans); font-size: 16px; font-weight: 700; color: var(--acc);
}
.sheet .it {
  width: 100%; min-height: 52px; display: flex; align-items: center; font-size: var(--fs-item);
  border-bottom: 1px solid var(--line); text-align: left;
}
.sheet .it:last-child { border-bottom: 0; }
.sheet .it.x { color: var(--mute); }
.sheet .fld {
  display: block; width: 100%; min-height: 52px; margin-top: 14px; padding: 0 12px;
  font: inherit; font-size: var(--fs-item); color: var(--ink); background: var(--bg);
  border: 2px solid var(--ink); border-radius: 6px;
}
.sheet .btn { margin-top: 14px; }
.sheet .quick { display: flex; flex-wrap: nowrap; gap: 8px; margin-top: 14px; }
.sheet .chip {
  flex: 0 0 calc((100% - 24px) / 4); box-sizing: border-box; min-height: 48px; min-width: 44px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--acc); border-radius: 6px; background: none; box-shadow: none;
  font-family: var(--font-mono); font-size: 17px; font-weight: 700; color: var(--acc);
}
.sheet .chip:focus-visible { outline: 2px solid var(--acc); outline-offset: 3px; }

/* плашка «Вернуть» */
.bar {
  position: fixed; left: 12px; right: 12px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 9;
  min-height: 56px; background: var(--ink); color: var(--bg); display: flex; align-items: center;
  padding: 0 4px 0 16px; border-radius: 6px; font-size: 16px;
  opacity: 0; transform: translateY(8px); transition: opacity 120ms ease-out, transform 120ms ease-out;
}
.bar.in { opacity: 1; transform: translateY(0); transition-duration: 160ms; }
.bar span { flex: 1; overflow-wrap: anywhere; padding: 6px 0; }
.bar button {
  min-width: 44px; height: 44px; padding: 0 14px; display: grid; place-items: center;
  font-family: var(--font-sans); font-size: 16px; font-weight: 700; color: var(--bg); text-decoration: underline;
}
.bar button:focus-visible { outline-color: var(--bg); }
/* экран «Вечер» */
main.ev { padding-bottom: 96px; }
main.ev.has-bar { padding-bottom: 104px; }
.center.tight { margin-top: 90px; }
.seg {
  display: flex; border: 2px solid var(--ink); border-radius: 6px; margin: 2px 0 14px; overflow: hidden;
}
.seg button {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 2px; display: grid; place-items: center; text-align: center;
  font-family: var(--font-sans); font-size: 14px; font-weight: 600; line-height: 1.15;
  border-left: 1px solid var(--line); color: var(--ink);
}
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--acc); color: var(--on); font-weight: 700; }
.seg button:focus-visible { outline-offset: -4px; }
.task { border-bottom: 1px solid var(--line); }
.task .ttl2 { font-size: var(--fs-item); line-height: 1.25; padding: 12px 0 8px; overflow-wrap: anywhere; }
.task.dn .ttl2 { color: var(--mute); text-decoration: line-through; }
h3 {
  font-size: 28px; font-weight: 700; line-height: 1.1; letter-spacing: -.01em; margin: 34px 0 0;
}
.sub2 {
  font-size: var(--fs-sub); font-style: italic; color: var(--mute);
  margin: 6px 0 0; padding-bottom: 12px; border-bottom: 2px solid var(--ink);
}
.sub2 + section { padding-top: 4px; }
.sub + .quiet { margin-top: 32px; }
.go {
  width: 100%; margin-top: 28px; min-height: 56px; border-radius: 6px; background: var(--acc); color: var(--on);
  display: grid; place-items: center; text-align: center;
  font-family: var(--font-sans); font-size: 18px; font-weight: 700;
}
.go:focus-visible { outline-color: var(--ink); }
.note {
  margin-top: 12px; font-family: var(--font-sans); font-size: var(--fs-small); color: var(--mute); text-align: center;
}
.quiet { margin-top: 22px; font-size: var(--fs-item); line-height: 1.3; }
.lost { margin-top: 22px; padding: 2px 0 2px 14px; border-left: 3px solid var(--acc); }
.lost .cap { font-family: var(--font-sans); font-size: var(--fs-small); font-weight: 700; color: var(--mute); }
.lost .tx {
  font-size: var(--fs-item); line-height: 1.3; margin-top: 6px; white-space: pre-wrap;
  user-select: text; -webkit-user-select: text; overflow-wrap: anywhere;
}
.lost .btn { margin-top: 12px; min-height: 48px; }
.quiet small {
  display: block; font-family: var(--font-sans); font-size: var(--fs-small); color: var(--mute); margin-top: 6px;
}
/* строка заголовка и переход «Сегодня» ↔ «Неделя» */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.top + .sub { margin-top: 2px; }
.nav {
  flex: none; min-height: var(--tap); min-width: var(--tap); display: flex; align-items: center; justify-content: flex-end;
  font-family: var(--font-sans); font-size: 16px; font-weight: 700; color: var(--acc); text-decoration: none;
  margin-right: -4px; padding: 0 4px;
}
/* экран «Неделя» */
main.wk h2 { line-height: 20px; }
main.wk h2.today { align-self: flex-start; display: table; background: var(--acc); color: var(--on); padding: 2px 8px; border-radius: 6px; }
main.wk .sub + section h2 { margin-top: 32px; }
main.wk .center { margin-top: 100px; }
main.wk .txt { padding-left: 0; }
main.wk .row:has(.more) { cursor: pointer; }
main.wk .more { margin-right: -10px; }
main.wk .sub.bare { height: 16px; padding: 0; margin-bottom: 4px; }
/* вход «История» в строке с подписью недели */
.sub.wk { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-bottom: 0; margin-bottom: 10px; }
.hlink {
  flex: none; min-height: 44px; min-width: 44px; display: flex; align-items: center; justify-content: flex-end;
  font-family: var(--font-sans); font-size: 16px; font-weight: 700; font-style: normal; color: var(--acc);
  margin-right: -4px; padding: 0 4px;
}
.empty {
  min-height: var(--tap); display: flex; align-items: center; font-size: 18px; font-style: italic; color: var(--mute);
  border-bottom: 1px solid var(--line);
}
.skh { height: 12px; width: 45%; background: var(--line); border-radius: 6px; margin: 26px 0 8px; }
/* экран «Повторы» и ряд ссылок под датой «Сегодня» */
.sub:has(+ .links) { margin-bottom: 0; }
.links { display: flex; flex-wrap: wrap; column-gap: 24px; border-bottom: 1px solid var(--line); }
.links button {
  min-height: 44px; min-width: 44px; display: flex; align-items: center;
  font-family: var(--font-sans); font-size: 16px; font-weight: 700; color: var(--acc);
}
main.rp .sub.bare { height: 16px; padding: 0; margin-bottom: 0; }
main.rp { padding-bottom: 96px; }
main.rp.has-bar { padding-bottom: 104px; }
main.rp .center { margin-top: 60px; }
main.rp .sk { height: 60px; flex-direction: column; align-items: stretch; justify-content: center; gap: 8px; }
.r { display: flex; align-items: center; min-height: 60px; border-bottom: 1px solid var(--line); }
.r .txt { padding: 10px 0; min-width: 0; }
.rm {
  flex: none; min-width: 64px; height: 44px; margin-right: -8px; padding: 0 8px; display: grid; place-items: center;
  font-family: var(--font-sans); font-size: 15px; font-weight: 700; color: var(--mute); text-decoration: underline;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important; animation: none !important;
  }
}
/* экран «Рамка дня» и его лист правки */
main.fm { padding-bottom: 96px; }
main.fm.has-bar { padding-bottom: 104px; }
.fm .sub.bare { height: 16px; padding: 0; margin-bottom: 0; }
.fm .center { margin-top: 56px; }
.fm .center.err { margin-top: 90px; }
.fm .sk { height: 60px; }
.fr {
  display: flex; align-items: center; width: 100%; min-height: 56px; border-bottom: 1px solid var(--line);
  text-align: left; transition: background-color 600ms ease-out, box-shadow 600ms ease-out;
}
.fr.added { background: var(--hl); box-shadow: -12px 0 0 var(--hl), 12px 0 0 var(--hl); transition: none; }
.fl {
  flex: 1; min-width: 0; font-size: var(--fs-item); line-height: 1.25; padding: 10px 0; overflow-wrap: anywhere;
}
.fc {
  flex: none; width: 44px; height: 44px; margin-right: -8px; display: grid; place-items: center;
  color: var(--mute); font-family: var(--font-sans); font-size: 26px;
}
.sh-back {
  display: flex; align-items: center; min-height: 44px; min-width: 44px; padding: 0;
  font-family: var(--font-sans); font-size: 16px; font-weight: 700; color: var(--acc);
}
.sh-title {
  margin: 0; padding: 6px 0 8px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere;
  font-family: var(--font-serif); font-size: 18px; font-weight: 400; font-style: italic; letter-spacing: 0;
  text-transform: none; color: var(--mute);
}
.sh-fields { display: flex; gap: 16px; margin-top: 6px; }
.tf { flex: 1; min-width: 0; display: block; }
.tf span {
  display: block; padding-top: 8px; font-family: var(--font-sans); font-size: 14px; color: var(--mute);
}
.tf.empty { min-height: 0; display: block; font-size: inherit; font-style: normal; color: inherit; border-bottom: 0; }
.tm {
  display: block; width: 100%; min-height: 52px; margin: 0; padding: 0; border: 0; border-bottom: 1px solid var(--line);
  border-radius: 0; background: none; color: var(--ink); font: inherit; font-size: var(--fs-item);
  font-variant-numeric: tabular-nums; appearance: none; -webkit-appearance: none; text-align: left;
}
.tf.empty .tm { color: var(--mute); }
.dark .tm { color-scheme: dark; } /* значок часов и окно выбора времени — светлые на тёмном */
.sh-days { display: flex; gap: 4px; margin: 14px -8px 0; }
.dy {
  flex: 1; min-width: 44px; height: 48px; border: 2px solid var(--line); border-radius: 6px; display: grid;
  place-items: center; text-align: center; color: var(--ink);
  font-family: var(--font-sans); font-size: 16px; font-weight: 700;
}
.dy[aria-pressed="true"] { background: var(--acc); border-color: var(--acc); color: var(--on); }
.sh-fields:has(~ .sh-hint) .tm { border-bottom: 2px solid var(--ink); }
.sh-hint { margin: 0; padding: 8px 0 0; font-family: var(--font-sans); font-size: 14px; color: var(--mute); }
.sheet [data-done] { width: 100%; min-height: 48px; }
.sh-links { display: flex; column-gap: 24px; margin-top: 2px; }
.lnk {
  min-height: 44px; min-width: 44px; display: flex; align-items: center;
  font-family: var(--font-sans); font-size: 15px; font-weight: 700; color: var(--mute); text-decoration: underline;
}
/* экран «Напоминания»: строки, переключатель, тихие часы */
main.rmn { padding-bottom: 96px; }
main.rmn.has-bar { padding-bottom: 104px; }
h1.long { font-size: 32px; }
.sub.rem { font-size: 18px; margin-bottom: 0; }
.rmn .center { margin-top: 56px; }
.rmn .center.err { margin-top: 90px; }
.rmn .sk { height: 60px; }
.rr { display: flex; align-items: center; min-height: 60px; border-bottom: 1px solid var(--line); }
.rr .nm { flex: 1; min-width: 0; padding: 8px 0; }
.rr .nm b { display: block; font-weight: 400; font-size: var(--fs-item); line-height: 1.25; overflow-wrap: anywhere; }
.rr .nm small { display: block; font-family: var(--font-sans); font-size: 14px; color: var(--mute); margin-top: 2px; }
.rr.off .nm b { color: var(--mute); }
.rmn .rr .tm {
  flex: none; display: flex; align-items: center; width: auto; min-width: 44px; min-height: 44px; padding: 0 8px;
  border-bottom: 0; font-family: var(--font-mono); font-size: var(--fs-time); font-weight: 600; color: var(--acc);
  text-decoration: underline; text-underline-offset: 4px; text-align: center;
}
.rmn .rr.off .tm { color: var(--mute); }
.rmn .rr .tm.none { color: var(--mute); text-decoration: none; }
.sw { flex: none; width: 52px; height: 48px; margin-right: -4px; display: grid; place-items: center; }
.sw i {
  width: 46px; height: 28px; border: 2px solid var(--mute); border-radius: 14px; display: block; position: relative;
  transition: background-color 120ms ease-out, border-color 120ms ease-out;
}
.sw i::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--mute); transition: left 120ms ease-out, background-color 120ms ease-out;
}
.sw[aria-checked="true"] i { background: var(--acc); border-color: var(--acc); }
.sw[aria-checked="true"] i::after { left: 21px; background: var(--on); }
.qr {
  display: flex; align-items: center; width: 100%; min-height: 60px; margin-top: 10px; text-align: left;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.qr b { flex: 1; font-weight: 400; font-size: var(--fs-item); }
.rmn .qr .tm {
  flex: none; display: flex; align-items: center; width: auto; min-height: 44px; padding: 0; border-bottom: 0;
  font-family: var(--font-mono); font-size: var(--fs-time); font-weight: 600; color: var(--acc);
  text-decoration: underline; text-underline-offset: 4px;
}
.rmn .qr .go {
  flex: none; display: grid; place-items: center; width: 44px; min-height: 44px; margin: 0 -8px 0 0;
  background: none; color: var(--mute); font-family: var(--font-sans); font-size: 22px; font-weight: 400;
}
.ex {
  min-height: 52px; display: flex; align-items: center; margin: 0; padding: 8px 0; font-family: var(--font-sans);
  font-size: 16px; line-height: 1.35; color: var(--mute); border-bottom: 1px solid var(--line);
}
.btn.quiet { font-size: 16px; color: var(--mute); border-color: var(--line); }
/* экран «История»: листание, строка недели, исходы дел */
.sub.hw { margin-bottom: 0; }
.pager { display: flex; border-bottom: 1px solid var(--line); }
.pg {
  min-height: 44px; min-width: 44px; display: flex; align-items: center;
  font-family: var(--font-sans); font-size: 16px; font-weight: 700; color: var(--acc);
}
.pg.next { margin-left: auto; justify-content: flex-end; }
.wline {
  min-height: 52px; display: flex; align-items: center; padding: 8px 0; font-size: 17px; line-height: 1.25;
  text-wrap: balance; border-bottom: 1px solid var(--line);
}
.hist section h2 { margin-top: 22px; line-height: 20px; }
.ev { font-family: var(--font-sans); font-size: 14px; line-height: 20px; color: var(--mute); }
.hist .sub.bare { height: 16px; padding: 0; margin-bottom: 0; }
.hist .center { margin-top: 100px; }
.hist .center.tight { margin-top: 90px; }
.hrow { display: flex; align-items: center; min-height: var(--row-min); border-bottom: 1px solid var(--line); }
.hrow .txt {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; padding: 8px 0;
  font-size: var(--fs-item); line-height: 1.25;
}
.hrow .time { grid-column: 1; font-family: var(--font-mono); font-size: var(--fs-time); font-weight: 600; color: var(--acc); text-decoration: none; }
.hrow .t {
  grid-column: 2; min-width: 0; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical;
  -webkit-line-clamp: 3; overflow: hidden;
}
.hrow small { grid-column: 1 / -1; font-size: 14px; line-height: 1.35; color: var(--mute); margin-top: 2px; }
.hrow.o-done .t { color: var(--mute); text-decoration: line-through; }
.hrow.o-cancelled .t, .hrow.o-dropped .t { color: var(--mute); }
