/* Life -- one stylesheet, system fonts, no external requests (the unit denies them). */

/* ---------------------------------------------------------------- palette: named tokens */
:root {
  color-scheme: light dark;
  --paper: #f7f5f1; --surface: #ffffff; --ink-1: #1f2126; --ink-2: #686b73; --hairline: #e7e3dc;
  --brand: #3f5f7f; --brand-soft: #e3ebf3; --pill: #d9e5f1; --blush: #f4e6da; --on-brand: #ffffff;
  --sun: #fff4d6; --sun-line: #e9cf85; --danger: #9b2c2c;
  --shadow: 0 1px 2px rgba(31, 33, 38, .04), 0 6px 18px rgba(31, 33, 38, .05);
  --bar: rgba(255, 255, 255, .86);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --display: 2.35rem;
  --radius: 16px; --tap: 48px;
  /* v1 names: every existing rule keeps working */
  --bg: var(--paper); --card: var(--surface); --ink: var(--ink-1); --muted: var(--ink-2); --line: var(--hairline);
  --accent: var(--brand); --accent-ink: var(--on-brand); --warn: var(--sun); --warn-line: var(--sun-line); --err: var(--danger);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15161a; --surface: #1f2025; --ink-1: #ecebe8; --ink-2: #a2a3a8; --hairline: #32333a;
    --brand: #8fb0d1; --brand-soft: #1e2935; --pill: #2c3d50; --blush: #2a2124; --on-brand: #13202c;
    --sun: #3a3220; --sun-line: #6b5a2c; --danger: #f19999;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --bar: rgba(31, 32, 37, .86);
  }
}

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
       font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
       padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
main { max-width: 640px; margin: 0 auto;
       padding: 4px calc(16px + env(safe-area-inset-right)) 16px calc(16px + env(safe-area-inset-left)); }
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1rem; margin: 0 0 8px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .88rem; }

/* ---------------------------------------------------------------- shell: header */
.top { position: relative; z-index: 6;
       background-color: var(--brand-soft);
       background-image: radial-gradient(120% 170% at 100% 100%, var(--blush) 0%, transparent 58%),
                         linear-gradient(180deg, var(--brand-soft) 0%, var(--brand-soft) 100%);
       border-radius: 0 0 24px 24px; margin-bottom: 10px;
       padding: calc(14px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 18px
                calc(16px + env(safe-area-inset-left)); }
.top-in { max-width: 640px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--brand); text-decoration: none; }
.mark { width: 30px; height: 30px; flex: none; }
.mark rect { fill: var(--brand); }
.mark circle, .mark path { fill: none; stroke: var(--on-brand); stroke-width: 40; stroke-linecap: round; stroke-linejoin: round; }
.wordmark { font-size: 1.4rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.greet { margin: 0; display: flex; flex-direction: column; align-items: flex-end; text-align: right; line-height: 1.25; min-width: 0; }
.greet-hi { font-weight: 650; font-size: .95rem; }
.greet-date { color: var(--muted); font-size: .84rem; }

.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 6px 0 16px; }
.page-title { font-size: var(--display); line-height: 1.08; font-weight: 750; letter-spacing: -.03em; }

/* ---------------------------------------------------------------- cards, forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
        margin-bottom: 14px; box-shadow: var(--shadow); }
.card.narrow { max-width: 420px; margin: 10vh auto 0; }
details.card > summary { cursor: pointer; font-weight: 600; min-height: 28px; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > input { flex: 1 1 130px; }
input, select, button { font: inherit; color: inherit; }
input, select { min-height: var(--tap); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px;
                background: var(--bg); width: 100%; }
input:focus-visible, select:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
select { width: auto; }
button { min-height: var(--tap); padding: 0 18px; border-radius: 12px; border: 0; background: var(--accent);
         color: var(--accent-ink); font-weight: 600; cursor: pointer; }
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button.link { background: none; color: var(--accent); padding: 0 6px; min-height: 36px; font-weight: 500; text-decoration: underline; }
form.inline { display: inline; }
.add { display: flex; gap: 8px; }
.add input { flex: 1; }
.add.wrap { flex-wrap: wrap; }
.add.wrap input { flex: 1 1 100%; }
.add.wrap select { flex: 1 1 auto; }
@media (min-width: 520px) { .add.wrap input { flex: 1 1 0; } .add.wrap select { flex: 0 0 auto; } }

/* ---------------------------------------------------------------- lists + the check control */
.list { list-style: none; margin: 12px 0 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; min-height: 52px; border-top: 1px solid var(--line);
           transition: height .3s var(--ease), min-height .3s var(--ease), opacity .22s ease,
                       transform .3s var(--ease), border-color .3s ease; }
.list li:first-child { border-top: 0; }
/* a ticked row collapses: app.js pins its height first, then this takes it to zero */
.list li.gone { opacity: 0; transform: translateX(18px); height: 0 !important; min-height: 0; overflow: hidden;
                border-top-color: transparent; }
.list .item { flex: 1; overflow-wrap: anywhere; }
.list.done .item { color: var(--muted); }
.check { width: 30px; height: 30px; min-height: 30px; padding: 0; border-radius: 50%; background: transparent;
         border: 2px solid var(--accent); flex: none; display: grid; place-items: center; color: var(--on-brand);
         transition: background-color .2s var(--ease), transform .2s var(--ease); }
.check svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round;
             stroke-linejoin: round; }
.check path { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset .3s var(--ease) .05s; }
.check:active, .check.on { background: var(--accent); }
.check.on { transform: scale(1.08); }
.check.on path { stroke-dashoffset: 0; }
.tick { display: flex; align-items: center; min-width: var(--tap); min-height: var(--tap); justify-content: center; }
.tag { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.empty { text-align: center; padding: 10px 0; }
.toast { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--card);
         border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 14px; margin: 0 0 14px; }
.error { color: var(--err); }
.foot { text-align: center; }

/* ---------------------------------------------------------------- reminder band */
.due { position: sticky; top: env(safe-area-inset-top); z-index: 5; background: var(--warn);
       border-bottom: 1px solid var(--warn-line); }
.due.enter { animation: due-in .42s var(--ease) both; }
@keyframes due-in { from { transform: translateY(-100%); opacity: 0; } to { transform: none; opacity: 1; } }
.due-item { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 8px;
            padding: 8px calc(16px + env(safe-area-inset-right)) 8px calc(16px + env(safe-area-inset-left)); }
.due-text { flex: 1; display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- calendar, chips */
.events { list-style: none; margin: 0; padding: 0; }
.events li { display: flex; align-items: baseline; gap: 10px; padding: 6px 0; }
.ev-time { color: var(--muted); font-size: .9rem; min-width: 7.5em; flex: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; display: inline-block; }
.weeknav { display: flex; justify-content: space-between; margin-bottom: 12px; }
.weeknav a { padding: 10px 4px; }
.cal { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.cal input[type=checkbox] { width: 22px; min-height: 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: transparent; color: var(--ink); border: 1px solid var(--line); min-height: 40px; font-weight: 500; }
.card.day p.muted { margin: 0; }

/* ---------------------------------------------------------------- shell: tab bar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
        background: var(--card); background: var(--bar);
        -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);
        border-top: 1px solid var(--line);
        padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.tabs-in { position: relative; display: flex; max-width: 640px; margin: 0 auto; }
.tabs a { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px;
          padding: 12px 4px 9px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .75rem;
          letter-spacing: .01em; -webkit-tap-highlight-color: transparent; transition: color .2s ease; }
.tabs .ico { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round;
             stroke-linejoin: round; }
.tabs a.on { color: var(--brand); font-weight: 750; }
.tabs a.on .ico { stroke-width: 2.2; }
/* the sliding pill: one element, positioned by the active tab's index */
.pill { position: absolute; top: 0; left: 0; width: 25%; height: 100%; pointer-events: none;
        transition: transform .34s var(--ease); }
.pill::before { content: ""; position: absolute; top: 8px; left: 50%; width: 60px; height: 32px; margin-left: -30px;
                border-radius: 16px; background: var(--pill); }
.tabs[data-on="1"] .pill { transform: translateX(100%); }
.tabs[data-on="2"] .pill { transform: translateX(200%); }
.tabs[data-on="3"] .pill { transform: translateX(300%); }
.tabs[data-on="none"] .pill { display: none; }
.tabs.still .pill { transition: none; }

[hidden] { display: none !important; }

/* ---------------------------------------------------------------- tab switches: cross-document View Transitions.
   Browsers without them ignore these rules; app.js slides the pill instead. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}
.top { view-transition-name: top; }
.pill { view-transition-name: tab-pill; }
.tabs a:nth-of-type(1) { view-transition-name: tab-1; }
.tabs a:nth-of-type(2) { view-transition-name: tab-2; }
.tabs a:nth-of-type(3) { view-transition-name: tab-3; }
.tabs a:nth-of-type(4) { view-transition-name: tab-4; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .22s; }
::view-transition-group(tab-pill) { animation-duration: .34s; animation-timing-function: cubic-bezier(.2, .7, .2, 1); }

/* ---------------------------------------------------------------- motion off, all of it */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; animation-delay: 0s !important;
                           transition-duration: 0s !important; transition-delay: 0s !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
