/* Prime Focus — quiet paper and ink. The timer is the one bold element; everything else stays plain.
   Mode colours: focus = pine, break = water, time is up = amber, chaos = brick, meditation = night. */
@font-face { font-family: "Onest"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(/static/fonts/onest-cyrillic.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(/static/fonts/onest-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --paper: #f2f4f0;
  --surface: #fbfcfa;
  --ink: #18201c;
  --muted: #5e6a63;
  --line: #dce1da;
  --pine: #2f6a55;
  --water: #31709a;
  --amber: #925708;
  --brick: #b0462f;
  --accent: var(--pine);
  --on-accent: #fff;
  --ground: var(--paper);
  --r-sm: 10px;
  --r: 14px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121614; --surface: #1a201d; --ink: #e6ebe7; --muted: #9aa69f; --line: #2b332f;
    --pine: #7cc3a6; --water: #8cc0e3; --amber: #e3a84b; --brick: #ec8b70; --on-accent: #0f1311;
  }
}
body[data-mode="work"] { --accent: var(--pine); --ground: color-mix(in srgb, var(--pine) 7%, var(--paper)); }
body[data-mode="break"] { --accent: var(--water); --ground: color-mix(in srgb, var(--water) 9%, var(--paper)); }
body[data-mode="break"].over { --accent: var(--amber); --ground: color-mix(in srgb, var(--amber) 9%, var(--paper)); }
body[data-mode="chaos"] { --accent: var(--brick); --ground: color-mix(in srgb, var(--brick) 7%, var(--paper)); }
body[data-mode="meditation"] { --ground: #141a2c; --ink: #e9ecf7; --muted: #a9b1cf; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; font: 400 16px/1.45 var(--font); color: var(--ink); background: var(--ground);
  transition: background-color .9s ease, color .6s ease; -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.app { width: min(100% - 32px, 560px); margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; gap: 28px;
  padding: max(14px, env(safe-area-inset-top)) 0 max(28px, env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 1rem; }
.brand img { width: 26px; height: 26px; border-radius: 8px; }
.top-actions { display: flex; gap: 4px; }
.icon-btn { width: 44px; height: 44px; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--muted);
  display: grid; place-items: center; transition: background .2s, color .2s; }
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink); }

/* ---------- stage ---------- */
.stage { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; }
.state { margin: 0; font-size: 1.05rem; font-weight: 500; color: var(--muted); max-width: 100%; overflow-wrap: anywhere; }
.state.strong { color: var(--accent); }
.dial { position: relative; width: min(72vw, 300px); aspect-ratio: 1; display: grid; place-items: center; margin: 4px 0; }
.dial > svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); pointer-events: none; }
.ring-track { fill: none; stroke: var(--line); stroke-width: 3; }
.ring { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset .3s linear, stroke .6s; }
body.over .ring { animation: breathe-ring 4s ease-in-out infinite; }
@keyframes breathe-ring { 50% { opacity: .35; } }
.digits { position: relative; z-index: 1; font-size: clamp(3.4rem, 16vw, 5.2rem); font-weight: 250; letter-spacing: -.035em;
  font-variant-numeric: tabular-nums; line-height: 1; color: var(--ink); background: none; border: 0; padding: 8px 12px; border-radius: var(--r); }
.digits.long { font-size: clamp(2.8rem, 13vw, 4.2rem); }
.digits.longer { font-size: clamp(2.3rem, 10.5vw, 3.4rem); }
body.over .digits { color: var(--amber); }
.ready .ring { opacity: 0; }
button.digits { cursor: text; transition: background .2s; }
button.digits:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
button.digits .pen { position: absolute; left: 50%; bottom: -22px; transform: translateX(-50%); display: grid; color: var(--muted); }
button.digits:hover .pen, button.digits:focus-visible .pen { color: var(--accent); }
.digit-edit { position: relative; z-index: 1; display: flex; align-items: baseline; gap: 6px; }
.digit-input { width: 3.1ch; font-size: clamp(3.4rem, 16vw, 5.2rem); font-weight: 250; letter-spacing: -.035em; text-align: center;
  border: 0; border-bottom: 2px solid var(--accent); background: transparent; outline: none; padding: 0; font-variant-numeric: tabular-nums; color: var(--ink); }
.digit-unit { font-size: 1.1rem; color: var(--muted); }
.big-result { font-size: clamp(3rem, 14vw, 4.4rem); font-weight: 250; letter-spacing: -.03em; line-height: 1.05; margin: 10px 0 2px; }
.sub { margin: 0; color: var(--muted); min-height: 1.45em; }
.sub b { color: var(--ink); font-weight: 600; }
.sub.alert { color: var(--brick); font-weight: 500; }

.actions { display: flex; flex-direction: column; align-items: stretch; gap: 10px; width: min(100%, 360px); margin-top: 8px; }
.row { display: flex; gap: 10px; }
.row > .btn { flex: 1 1 0; }

/* ---------- buttons: primary (one per screen) / secondary / quiet ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border-radius: var(--r); border: 1px solid transparent; font-weight: 500; font-size: 1rem; text-decoration: none;
  transition: background .2s, border-color .2s, color .2s, transform .1s; }
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--accent); color: var(--on-accent); min-height: 56px; font-size: 1.06rem; font-weight: 600; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.btn.secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn.secondary:hover { border-color: color-mix(in srgb, var(--ink) 30%, var(--line)); }
.btn.quiet { background: transparent; color: var(--muted); min-height: 44px; }
.btn.quiet:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 5%, transparent); }
.btn.warn { background: var(--surface); border-color: var(--brick); color: var(--brick); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn.sm { min-height: 44px; padding: 0 14px; }

/* ---------- tasks ---------- */
.tasks { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px 14px 14px; }
.tasks-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 6px 6px; }
.tasks-head h2 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.tasks-head span { color: var(--muted); font-size: .92rem; font-variant-numeric: tabular-nums; }
.group { margin: 12px 6px 2px; font-size: .9rem; color: var(--muted); }
.task-list { list-style: none; margin: 0; padding: 0; }
.task { display: flex; align-items: center; gap: 6px; border-radius: var(--r-sm); padding: 0 2px 0 6px; transition: background .15s; }
.task:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.task label { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; min-height: 48px; padding: 6px 0; cursor: pointer; }
.task .t { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.35; }
.task.done .t { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.task.off .t { color: var(--muted); }
.chk { appearance: none; -webkit-appearance: none; flex: none; width: 24px; height: 24px; margin: 0; border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--ink) 35%, transparent); display: grid; place-items: center; cursor: pointer; transition: background .2s, border-color .2s; }
.chk::after { content: ""; width: 10px; height: 5px; border-left: 2px solid var(--on-accent); border-bottom: 2px solid var(--on-accent);
  transform: rotate(-45deg) scale(0) translate(1px, -1px); transition: transform .2s var(--ease); }
.chk:checked { background: var(--accent); border-color: var(--accent); }
.chk:checked::after { transform: rotate(-45deg) scale(1) translate(1px, -1px); }
.chk:hover { border-color: var(--accent); }
.pick { flex: none; min-height: 32px; padding: 0 10px; border-radius: 999px; font-size: .86rem; font-weight: 500;
  border: 1px solid var(--line); background: transparent; color: var(--muted); transition: background .2s, color .2s, border-color .2s; }
.pick[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 12%, transparent); border-color: transparent; color: var(--accent); }
.pick:hover { border-color: var(--accent); }
.x { flex: none; width: 40px; height: 40px; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--muted);
  display: grid; place-items: center; opacity: 0; transition: opacity .15s, background .15s, color .15s; }
.task:hover .x, .task:focus-within .x { opacity: 1; }
.x:hover { color: var(--brick); background: color-mix(in srgb, var(--brick) 9%, transparent); }
@media (hover: none) { .x { opacity: .6; } }
.empty { margin: 6px 6px 4px; color: var(--muted); }
.add { display: flex; gap: 8px; margin-top: 8px; }
.add input { flex: 1; min-width: 0; height: 48px; border-radius: var(--r); border: 1px solid var(--line); background: var(--paper); padding: 0 14px; transition: border-color .2s; }
.add input::placeholder { color: var(--muted); }
.add input:focus { outline: none; border-color: var(--accent); }
.add button { flex: none; width: 48px; height: 48px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  display: grid; place-items: center; transition: border-color .2s, background .2s; }
.add button:hover { border-color: var(--accent); color: var(--accent); }
.done-box { margin-top: 10px; }
.done-box summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 8px;
  border-radius: var(--r-sm); color: var(--muted); font-size: .94rem; }
.done-box summary::-webkit-details-marker { display: none; }
.done-box summary svg { transition: transform .2s var(--ease); }
.done-box[open] summary svg { transform: rotate(90deg); }
.done-box summary:hover { color: var(--ink); }

.today { margin: auto 0 0; text-align: center; color: var(--muted); font-size: .92rem; }

/* ---------- inline chaos form ---------- */
.chaos-form { display: grid; gap: 10px; width: min(100%, 360px); margin-top: 8px; }
.text-in, select.text-in { width: 100%; min-width: 0; height: 48px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); padding: 0 14px; transition: border-color .2s; }
.text-in:focus { outline: none; border-color: var(--accent); }

/* ---------- meditation ---------- */
.med { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; align-content: center; gap: 28px; text-align: center; padding: 24px;
  background: #141a2c; color: #e9ecf7; animation: fadein 1.2s ease both; }
@keyframes fadein { from { opacity: 0; } }
.breath { width: min(56vw, 240px); aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #c9d5ff, #6f86d6 60%, #3b4a8c);
  opacity: .9; animation: breathe 10s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(.66); } 40%, 50% { transform: scale(1); } }
.med .prompt { font-size: clamp(1.6rem, 6vw, 2.1rem); font-weight: 300; min-height: 1.3em; }
.med .left { color: #a9b1cf; font-variant-numeric: tabular-nums; }
.med .btn.quiet { color: #a9b1cf; }
.med .btn.quiet:hover { color: #fff; background: rgba(255, 255, 255, .08); }
body.meditating .app { visibility: hidden; }

/* ---------- dialogs ---------- */
dialog { border: 0; padding: 0; background: transparent; color: var(--ink); max-width: 100vw; max-height: 100dvh; overflow: visible; }
dialog::backdrop { background: rgba(10, 14, 12, .38); }
.sheet { width: min(100vw - 24px, 540px); max-height: min(88dvh, 820px); overflow: auto; overscroll-behavior: contain; padding: 20px 22px 18px;
  border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .35); animation: pop .25s var(--ease) both; }
@keyframes pop { from { opacity: 0; transform: translateY(12px); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.sheet-head h2 { margin: 0; font-size: 1.3rem; font-weight: 600; }
.sec { padding: 14px 0; border-top: 1px solid var(--line); }
.sec:first-of-type { border-top: 0; }
.sec h3 { margin: 0 0 10px; font-size: 1rem; font-weight: 600; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 52px; }
.field > span, .field > label { font-weight: 450; }
.stack { display: grid; gap: 8px; }
.stack + .stack { margin-top: 12px; }
.stack > label { font-size: .94rem; color: var(--muted); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.stepper button { width: 44px; height: 44px; border: 0; background: transparent; display: grid; place-items: center; }
.stepper button:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.stepper input { width: 4ch; text-align: center; border: 0; background: transparent; font-weight: 600; font-size: 1.05rem; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
.stepper input:focus { outline: none; }
.stepper:focus-within { border-color: var(--accent); }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.switch { appearance: none; -webkit-appearance: none; flex: none; margin: 0; width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s var(--ease); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
input[type=range] { width: 100%; accent-color: var(--accent); height: 32px; }
.note { color: var(--muted); font-size: .92rem; margin: 4px 0 0; }
.status { min-height: 1.3em; font-size: .92rem; margin: 6px 0 0; }
.status.ok { color: var(--pine); } .status.bad { color: var(--brick); }
.sheet-foot { display: flex; gap: 10px; justify-content: flex-end; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.sheet-foot .spacer { margin-right: auto; }
.row.start { justify-content: flex-start; flex-wrap: wrap; }
.row.start > .btn { flex: 0 0 auto; }

/* history */
.day { padding: 14px 0; border-top: 1px solid var(--line); }
.day:first-child { border-top: 0; }
.day h3 { margin: 0 0 2px; font-size: 1rem; font-weight: 600; }
.day h3::first-letter { text-transform: uppercase; }
.facts { margin: 0; color: var(--muted); font-size: .92rem; }
.win-btn { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; text-align: left; margin-top: 8px; padding: 10px 12px;
  border-radius: var(--r); border: 1px solid var(--line); background: var(--paper); transition: border-color .2s; }
.win-btn:hover { border-color: color-mix(in srgb, var(--ink) 30%, var(--line)); }
.win-btn small { display: block; color: var(--muted); font-size: .88rem; }
.timeline { list-style: none; margin: 14px 0 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); display: grid; gap: 12px; }
.tl { position: relative; }
.tl::before { content: ""; position: absolute; left: -25px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); border: 2px solid var(--surface); }
.tl.work::before { background: var(--pine); } .tl.break::before { background: var(--water); } .tl.chaos::before { background: var(--brick); } .tl.meditation::before { background: #6f86d6; }
.tl b { font-weight: 600; } .tl small { display: block; color: var(--muted); font-size: .9rem; }
.tl ul { list-style: none; margin: 4px 0 0; padding-left: 0; color: var(--muted); font-size: .92rem; }
.tl li.ok { color: var(--ink); }
.badge { display: inline-block; font-size: .78rem; padding: 1px 8px; border-radius: 99px; background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--muted); margin-left: 6px; vertical-align: 1px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--muted); padding: 6px 0; min-height: 40px; }
.back-link:hover { color: var(--ink); }
.plain-list { list-style: none; margin: 0; padding-left: 0; display: grid; gap: 4px; }
.plain-list.muted { color: var(--muted); }

/* toasts */
.toasts { position: fixed; left: 0; right: 0; bottom: max(18px, env(safe-area-inset-bottom)); display: grid; justify-items: center; gap: 8px; z-index: 50; pointer-events: none; padding: 0 14px; }
.toast { background: var(--ink); color: var(--paper); padding: 11px 16px; border-radius: var(--r); box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .4); animation: pop .25s var(--ease) both; max-width: 520px; }
.toast.bad { background: var(--brick); color: #fff; }
.toast.out { opacity: 0; transition: opacity .3s; }

/* login */
.hero { margin: auto; text-align: center; display: grid; gap: 16px; justify-items: center; padding: 20px; }
.hero img { width: 64px; height: 64px; border-radius: 18px; }
.hero h1 { margin: 0; font-size: clamp(2rem, 8vw, 2.8rem); font-weight: 500; letter-spacing: -.02em; }
.hero p { margin: 0; color: var(--muted); max-width: 32ch; }
.hero .btn { min-width: 200px; }

@media (max-width: 480px) {
  .app { gap: 22px; }
  .sheet { padding: 18px 16px 16px; }
  .tasks { padding: 12px 8px 10px; border-radius: 16px; }
}
@media (min-width: 900px) { .app { padding-top: 28px; gap: 34px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .breath { transform: scale(.85); }
}
.x.show { opacity: 1; }
.mt { margin-top: 10px; }
