/* Design tokens mirror the iOS app's Theme.swift: brand blue 0x66A2D7,
   spacing 4/8/16/24/32, radius 20 (card) and 14 (control). Glass is a web
   approximation of the iOS 26 glassEffect, not the native material.
   Nested radii are concentric: outer 20 = inner 14 + 6px padding. */
:root {
  --brand: #66a2d7;
  --accent-fill: #2f6da3;
  --on-accent: #fff;
  --bg: #f2f2f7;
  --fg: #111114;
  --muted: #5f6370;
  --faint: #666a78;
  --glass: rgb(255 255 255 / .62);
  --glass-edge: rgb(255 255 255 / .75);
  --glass-shadow: 0 1px 1px rgb(0 0 0 / .04), 0 8px 24px rgb(0 0 0 / .08), 0 24px 48px -16px rgb(0 0 0 / .10);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .08), 0 2px 8px rgb(0 0 0 / .05);
  --field: rgb(255 255 255 / .7);
  --card: rgb(255 255 255 / .92);
  --line: rgb(60 70 90 / .12);
  --good: #167c3d;
  --on-good: #fff;
  --bad: #d3342b;
  --ring: 0 0 0 3px rgb(102 162 215 / .4);
  --sp-xs: 4px; --sp-sm: 8px; --sp-md: 16px; --sp-lg: 24px; --sp-xl: 32px;
  --r-card: 20px; --r-control: 14px;
  /* Custom curves: the built-in easings are too weak */
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-in-out: cubic-bezier(.77, 0, .175, 1);
  --ease-drawer: cubic-bezier(.32, .72, 0, 1);
  --ease: var(--ease-out);
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent-fill: #66a2d7;
    --on-accent: #0a1a2a;
    --bg: #0a0b10;
    --fg: #f2f3f7;
    --muted: #a3a7b4;
    --faint: #9a9eae;
    --glass: rgb(40 44 58 / .55);
    --glass-edge: rgb(255 255 255 / .14);
    --glass-shadow: 0 1px 1px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .35), 0 24px 48px -16px rgb(0 0 0 / .5);
    --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
    --field: rgb(255 255 255 / .07);
    --card: rgb(255 255 255 / .075);
    --line: rgb(255 255 255 / .1);
    --good: #34c76f;
    --on-good: #06210f;
    --bad: #ff6a5f;
    --ring: 0 0 0 3px rgb(102 162 215 / .45);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); color-scheme: light dark; accent-color: var(--brand); scrollbar-color: var(--faint) transparent; scrollbar-width: thin; }
::selection { background: rgb(102 162 215 / .38); color: inherit; }
input, select { caret-color: var(--brand); }
body {
  margin: 0; min-height: 100dvh; color: var(--fg);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", system-ui, sans-serif;
  font-feature-settings: "cv11", "ss01";
  background:
    radial-gradient(60vmax 40vmax at 10% -10%, rgb(102 162 215 / .32), transparent 60%),
    radial-gradient(50vmax 40vmax at 100% 20%, rgb(102 162 215 / .18), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 560px; margin: 0 auto;
  padding: max(var(--sp-lg), env(safe-area-inset-top)) max(var(--sp-md), env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) max(var(--sp-md), env(safe-area-inset-left));
}
i.ph, i.ph-fill { font-size: 1.15em; vertical-align: -.15em; }
h1, h2, h3 { text-wrap: balance; }

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: var(--r-card);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .4), var(--glass-shadow);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
}
@media (prefers-reduced-transparency: reduce) {
  .glass { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* Focus: visible for keyboard users, never removed without a replacement */
button, a, input, select, [tabindex] { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.field:focus-visible { outline: none; border-color: var(--brand); box-shadow: var(--ring); }

/* Buttons are capsules, like the app's glass buttons */
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-sm);
  min-height: 44px; padding: 0 var(--sp-lg); border-radius: 999px; font-weight: 600; white-space: nowrap;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent-fill) 88%, #fff), var(--accent-fill));
  color: var(--on-accent);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .28), 0 1px 2px rgb(0 0 0 / .25), 0 4px 10px -4px rgb(0 0 0 / .3);
  transition: transform 160ms var(--ease-out), opacity 160ms, filter 160ms;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 999px; color: var(--muted); transition: background-color 160ms, color 160ms, transform 160ms var(--ease-out); }
.icon-btn:active { transform: scale(.92); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { filter: brightness(1.06); }
  .icon-btn:hover { background: var(--line); color: var(--fg); }
  .icon-btn.danger:hover { color: var(--bad); }
}

/* Header */
.top { display: flex; align-items: center; gap: var(--sp-sm); margin-bottom: var(--sp-md); }
.top h1 { flex: 1; margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -.028em; line-height: 1.1; }

/* Segmented control. The .sliding variant has one indicator that glides between tabs. */
.seg { position: relative; display: flex; gap: var(--sp-xs); padding: var(--sp-xs); border-radius: 999px; margin-bottom: var(--sp-md); overflow-x: auto; scrollbar-width: none; }
.seg button { position: relative; flex: 1 0 auto; min-height: 36px; padding: 0 var(--sp-md); border-radius: 999px; font-size: 15px; font-weight: 600; color: var(--muted); transition: background-color 200ms var(--ease-out), color 200ms var(--ease-out), transform 160ms var(--ease-out); }
.seg button:active { transform: scale(.97); }
.seg button.on { background: var(--accent-fill); color: var(--on-accent); box-shadow: inset 0 1px 0 rgb(255 255 255 / .22), 0 1px 3px rgb(0 0 0 / .22); }
.seg button:focus-visible { outline-offset: -2px; }
@media (hover: hover) and (pointer: fine) { .seg button:not(.on):hover { color: var(--fg); } }
.seg.sliding::before { content: ""; position: absolute; top: var(--sp-xs); bottom: var(--sp-xs); left: 0; width: var(--ind-w, 0); border-radius: 999px; background: var(--accent-fill); box-shadow: inset 0 1px 0 rgb(255 255 255 / .22), 0 1px 3px rgb(0 0 0 / .22); transform: translateX(var(--ind-x, 0)); opacity: var(--ind-o, 0); }
.seg.sliding.ready::before { transition: transform 300ms var(--ease-drawer); }
.seg.sliding button.on { background: transparent; box-shadow: none; }

/* Composer */
.composer { padding: 6px; margin-bottom: var(--sp-lg); display: grid; gap: var(--sp-sm); }
.composer .line { display: flex; gap: 6px; align-items: center; }
.field {
  flex: 1; min-width: 0; min-height: 44px; padding: 0 var(--sp-md);
  font: inherit; color: var(--fg); background-color: var(--field);
  border: 1px solid var(--line); border-radius: var(--r-control);
  transition: border-color 160ms, box-shadow 160ms;
}
.field::placeholder { color: var(--faint); }
select.field { color: var(--fg); background-color: var(--field); }
select.field option { color: var(--fg); background-color: var(--bg); }
.send { flex: none; width: 44px; height: 44px; padding: 0; font-size: 20px; }
.due-field { display: flex; align-items: center; gap: var(--sp-sm); color: var(--muted); font-size: 14px; padding: 0 var(--sp-sm) var(--sp-xs); }
.due-field .field { flex: 0 1 auto; min-height: 36px; font-size: 14px; }
.hint { color: var(--bad); font-size: 14px; padding: 0 var(--sp-sm); }
.hint:empty { display: none; }

/* Sections */
.label { display: flex; align-items: center; justify-content: space-between; margin: var(--sp-lg) var(--sp-sm) var(--sp-sm); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
button.label { width: calc(100% - 2 * var(--sp-sm)); text-align: left; }
button.label i { transition: transform 200ms var(--ease-out); }
.list { margin: 0 0 var(--sp-md); padding: 4px var(--sp-md); list-style: none; }
.list:empty { display: none; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.item + .item { border-top: 1px solid var(--line); }
.item .body { flex: 1; min-width: 0; }
.item .title { overflow-wrap: anywhere; }
.item.done .title { text-decoration: line-through; color: var(--muted); }
.item .meta { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.item .meta.over { color: var(--bad); }
.check { flex: none; width: 28px; height: 28px; display: grid; place-items: center; font-size: 26px; color: var(--faint); border-radius: 999px; transition: transform 160ms var(--ease-out), color 160ms; }
.check:active { transform: scale(.85); }
.check.on { color: var(--good); }
@media (hover: hover) and (pointer: fine) { .check:not(.on):hover { color: var(--brand); } }
.static-dot { flex: none; width: 28px; display: grid; place-items: center; font-size: 22px; color: var(--faint); }

/* Empty and loading states */
.empty { display: grid; justify-items: center; gap: var(--sp-sm); padding: var(--sp-xl) var(--sp-md); text-align: center; color: var(--muted); margin-bottom: var(--sp-md); }
.empty i { display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: var(--sp-xs); border-radius: 50%; background: rgb(102 162 215 / .16); font-size: 30px; color: var(--brand); }
.empty strong { color: var(--fg); font-size: 17px; font-weight: 650; }
.empty span { font-size: 15px; max-width: 32ch; text-wrap: balance; }
.skeleton { display: grid; gap: 14px; padding: var(--sp-md); margin-bottom: var(--sp-md); }
.skeleton div { height: 18px; border-radius: 9px; background: linear-gradient(90deg, var(--line), transparent, var(--line)); background-size: 200% 100%; }
@media (prefers-reduced-motion: no-preference) { .skeleton div { animation: shimmer 1.4s linear infinite; } }

/* iOS-style switch: the knob stretches while pressed */
.switch { position: relative; flex: none; width: 51px; height: 31px; border-radius: 999px; background: var(--line); transition: background-color 250ms var(--ease-out); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 999px; background: #fff; box-shadow: 0 2px 4px rgb(0 0 0 / .25); transition: transform 300ms var(--ease-out); transform-origin: left center; }
.switch[aria-checked="true"] { background: var(--good); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.switch:active::after { transform: scaleX(1.22); }
.switch[aria-checked="true"]::after { transform-origin: right center; }
.switch[aria-checked="true"]:active::after { transform: translateX(20px) scaleX(1.22); }
.person { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 50%; background: rgb(102 162 215 / .22); color: var(--accent-fill); font-weight: 700; }
.share-note { margin: var(--sp-sm) var(--sp-sm) 0; font-size: 13px; color: var(--muted); text-wrap: pretty; }

/* Sign in */
.auth { max-width: 380px; margin: 10dvh auto 0; display: grid; gap: var(--sp-md); text-align: center; }
.auth img { width: 88px; height: 88px; border-radius: 22%; margin: 0 auto; box-shadow: var(--glass-shadow); }
.auth h1 { margin: 0; font-size: 32px; font-weight: 700; letter-spacing: -.028em; }
.auth p { margin: calc(-1 * var(--sp-sm)) 0 var(--sp-sm); color: var(--muted); }
.auth form { display: grid; gap: var(--sp-sm); padding: var(--sp-md); text-align: left; }
.auth label { font-size: 13px; font-weight: 600; color: var(--muted); }
.auth .btn { width: 100%; margin-top: var(--sp-sm); }
#err { color: var(--bad); font-size: 14px; }
#err:empty { display: none; }

/* Panels fade up when switched to. Short, ease-out, never blocks interaction. */
#personal:not([hidden]), #settings:not([hidden]), #boards:not([hidden]) { animation: panel-in 200ms var(--ease-out) both; }
@keyframes panel-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Reduced motion: keep the fades, drop the movement */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { transition-duration: 1ms !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
  #personal:not([hidden]), #settings:not([hidden]), #boards:not([hidden]) { animation: fade-only 150ms ease both !important; }
  @keyframes fade-only { from { opacity: 0; } }
}

/* Skip link: off-screen until keyboard focus */
.skip { position: absolute; left: var(--sp-md); top: -64px; z-index: 20; padding: 10px 18px; border-radius: 999px; background: var(--accent-fill); color: var(--on-accent); font-weight: 600; text-decoration: none; transition: top 160ms var(--ease-out); }
.skip:focus-visible { top: var(--sp-md); }

/* Touch screens: 44px hit areas, same visuals */
@media (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; }
  .check { width: 44px; height: 44px; margin: -8px; }
  .seg button { min-height: 40px; }
  .btn.small { min-height: 40px; }
  .add-card { min-height: 44px; }
}

/* Small icon link back to the PWAPP home page */
.home-link { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 999px; color: var(--muted); font-size: 20px; text-decoration: none; transition: background-color 160ms, color 160ms, transform 160ms var(--ease-out); }
.home-link:active { transform: scale(.92); }
@media (hover: hover) and (pointer: fine) { .home-link:hover { background: var(--line); color: var(--fg); } }
