  :root {
    --bg: #f6f5f1; --surface: #ffffff; --surface-2: #efeee9; --line: #e4e2dc;
    --ink: #1a1c21; --muted: #6c707a; --faint: #a3a6ad;
    --accent: #d8920f; --accent-ink: #1a1405; --danger: #d0453f; --good: #1f9d55;
    --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 4px 16px rgba(20, 20, 30, .05);
    --radius: 18px;
    color-scheme: light;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #131519; --surface: #1c1f25; --surface-2: #252932; --line: #2c3039;
      --ink: #eef0f3; --muted: #8e94a0; --faint: #5d626d;
      --accent: #f2b33d; --accent-ink: #1a1405; --danger: #ef6a63; --good: #4cc38a;
      --shadow: none;
      color-scheme: dark;
    }
  }
  :root[data-theme="dark"] {
      --bg: #131519; --surface: #1c1f25; --surface-2: #252932; --line: #2c3039;
      --ink: #eef0f3; --muted: #8e94a0; --faint: #5d626d;
      --accent: #f2b33d; --accent-ink: #1a1405; --danger: #ef6a63; --good: #4cc38a;
      --shadow: none;
      color-scheme: dark;
  }
  /* no double-tap zoom on iPhone (quick taps on buttons were zooming the app); pinch-to-zoom still works */
  * { box-sizing: border-box; touch-action: manipulation; }
  html, body { margin: 0; background: var(--bg); color: var(--ink);
    font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
  button, input { font: inherit; color: inherit; }
  button { border: 0; background: none; cursor: pointer; padding: 0; }
  button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .num { font-variant-numeric: tabular-nums; }
  svg { display: block; }

  /* shell */
  .top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; }
  .top-in { max-width: 560px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
  .brand .mark { width: 28px; height: 28px; border-radius: 9px; background: var(--accent); color: var(--accent-ink);
    display: grid; place-items: center; }
  .avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); overflow: hidden;
    display: grid; place-items: center; font-weight: 700; color: var(--muted); }
  .avatar img { width: 100%; height: 100%; object-fit: cover; }
  main { max-width: 560px; margin: 0 auto; padding: 8px 16px calc(96px + env(safe-area-inset-bottom)); }
  h2.section { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
    margin: 26px 4px 10px; display: flex; justify-content: space-between; }
  h2.section span:last-child { text-transform: none; letter-spacing: 0; font-weight: 500; }

  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: var(--surface);
    border-top: 1px solid var(--line); padding: 6px 12px calc(6px + env(safe-area-inset-bottom)); }
  .tabs-in { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
  .tabs button { display: grid; justify-items: center; gap: 2px; padding: 6px 0; color: var(--faint); font-size: 12px; font-weight: 600; }
  .tabs button[aria-current="page"] { color: var(--ink); }
  .tabs button[aria-current="page"] svg { color: var(--accent); }
  body.out .tabs, body.out .avatar { display: none; }

  /* hero */
  .hero { position: relative; overflow: hidden; border-radius: 24px; padding: 20px; background: var(--surface);
    box-shadow: var(--shadow); min-height: 168px; display: flex; flex-direction: column; justify-content: space-between; }
  .hero.on { background: color-mix(in srgb, var(--c) 16%, var(--surface)); }
  .hero .label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; font-weight: 600; }
  .hero .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--c); animation: pulse 1.6s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: .35; } }
  .hero .name { font-size: 22px; font-weight: 700; margin-top: 2px; letter-spacing: -.01em; overflow-wrap: anywhere; }
  .hero .row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 18px; flex-wrap: wrap; row-gap: 12px; }
  .hero .clock { font-size: clamp(44px, 14vw, 60px); font-weight: 750; letter-spacing: -.03em; line-height: 1; }
  .hero .since { color: var(--muted); font-size: 13px; margin-top: 6px; }
  .btn-stop { display: inline-flex; align-items: center; gap: 8px; background: var(--ink); color: var(--bg);
    padding: 14px 20px; border-radius: 999px; font-weight: 700; flex-shrink: 0; }
  .btn-stop:active { transform: scale(.97); }
  .goal { margin-top: 18px; padding-top: 14px; border-top: 1px solid color-mix(in srgb, var(--c) 25%, transparent); }
  .goal .gl1 { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; }
  .goal .streak { flex-shrink: 0; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 99px;
    background: color-mix(in srgb, var(--c) 22%, transparent); }
  .goal .gbar { position: relative; height: 8px; border-radius: 99px; margin: 10px 0 8px;
    background: color-mix(in srgb, var(--c) 18%, var(--surface)); }
  .goal .gfill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: var(--c); }
  .goal .gmark { position: absolute; top: -3px; bottom: -3px; width: 2px; border-radius: 2px; background: var(--ink); opacity: .55; }
  .goal .gsub { color: var(--muted); font-size: 13px; }
  .goal.live:empty { display: none; }
  .goal.live .gl1 span { display: inline-flex; align-items: center; gap: 6px; }
  .goal.live .gl1 span.muted { color: var(--muted); font-weight: 500; font-size: 14px; }
  .goal .gbar.over .gfill { background: var(--danger); }
  .goal .gl1.rec span:first-child { color: var(--c); }
  .goal .gl1.warn span:first-child { color: var(--danger); display: inline-flex; align-items: center; gap: 6px; }
  .kindtag { font-size: 11px; font-weight: 700; color: var(--muted); background: var(--surface-2); padding: 2px 7px; border-radius: 99px;
    margin-left: 8px; vertical-align: middle; }
  .tile .top-l { display: flex; align-items: center; }
  .chip { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 7px 12px; border-radius: 99px;
    font-size: 13px; font-weight: 600; color: var(--muted); background: var(--surface-2); }
  .chip[aria-pressed="true"] { color: var(--ink); }
  /* checkbox look: empty square when off, filled with a tick when on */
  .chip .box { width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--faint); flex-shrink: 0; position: relative; }
  .chip[aria-pressed="true"] .box { background: var(--ink); border-color: var(--ink); }
  .chip[aria-pressed="true"] .box::after { content: ""; position: absolute; left: 3px; top: 0; width: 4px; height: 7px;
    border: solid var(--surface); border-width: 0 2px 2px 0; transform: rotate(45deg); }



  .hero.idle { min-height: 0; gap: 14px; justify-content: flex-start; }
  .resume { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px; border-radius: 16px;
    background: color-mix(in srgb, var(--c) 12%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 30%, transparent); }
  .resume:active { transform: scale(.98); }
  .resume .rplay { width: 40px; height: 40px; border-radius: 50%; background: var(--c); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
  .resume b { display: block; font-size: 17px; overflow-wrap: anywhere; }
  .resume small { color: var(--muted); font-size: 13px; }
  .glist { display: grid; gap: 10px; }
  .glist .label { margin-bottom: -2px; }
  .grow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: baseline; font-size: 14px; }
  .grow .gname { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .grow .gname i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
  .grow .gval { color: var(--muted); font-size: 13px; }
  .grow .gval.done { color: var(--ink); }
  .grow .gval.warn { color: var(--danger); font-weight: 600; }
  .grow .gtrack { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
  .grow .gtrack span { display: block; height: 100%; border-radius: 99px; background: var(--c); }
  .grow .gtrack.over span { background: var(--danger); }
  .setgoals { justify-self: start; }
  .hbtns { display: flex; align-items: center; gap: 8px; flex-shrink: 0; margin-left: auto; }
  .btn-pause { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
    background: color-mix(in srgb, var(--ink) 10%, transparent); color: var(--ink); }
  .btn-pause:active { transform: scale(.95); }
  .hero.paused { background: color-mix(in srgb, var(--c) 8%, var(--surface)); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 35%, transparent); }
  .hero.paused .pulse { background: var(--c); }
  .hero .endbreak { margin-top: 12px; justify-self: start; align-self: flex-start; color: var(--muted); }
  .pchoices { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; }
  .pchoice { padding: 14px 0; border-radius: 12px; background: var(--surface-2); font-weight: 700; }
  .pchoice:active { transform: scale(.97); }
  .streakl { display: flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--c); }













  .daybar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--surface-2); margin-top: 16px; gap: 2px; }
  .daybar span { background: var(--c); min-width: 3px; }

  /* activity tiles */
  .grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { position: relative; text-align: left; padding: 16px; border-radius: var(--radius); background: var(--surface);
    box-shadow: var(--shadow); min-height: 104px; display: flex; flex-direction: column; justify-content: space-between;
    transition: transform .12s ease, background .2s ease; }
  .tile:active { transform: scale(.97); }
  .tile .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
  .tile .nm { font-weight: 650; font-size: 16px; margin-top: 14px; overflow-wrap: anywhere; line-height: 1.25; }
  .tile .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
  .tile.on { background: color-mix(in srgb, var(--c) 18%, var(--surface)); box-shadow: inset 0 0 0 2px var(--c); }
  .tile.on .sub { color: var(--ink); font-weight: 600; }
  .tile .play { position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; border-radius: 50%;
    display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
  .tile.on .play { background: var(--c); color: #fff; }

  .empty { text-align: center; padding: 36px 20px; color: var(--muted); background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow); }
  .empty b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }
  .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent);
    color: var(--accent-ink); padding: 12px 18px; border-radius: 12px; font-weight: 700; margin-top: 14px; }
  .btn:disabled { opacity: .45; cursor: default; }

  /* cards / lists */
  .card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
  .card + .card { margin-top: 10px; }
  .rowi { display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; align-items: center; padding: 13px 14px; }
  .rowi + .rowi { border-top: 1px solid var(--line); }
  .rowi .bar { width: 4px; height: 32px; border-radius: 4px; background: var(--c); justify-self: center; }
  .rowi .t { color: var(--muted); font-size: 13px; }
  .rowi .d { font-weight: 650; }
  .rowi .right { display: flex; align-items: center; gap: 4px; }
  .icon-btn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--faint); }
  .icon-btn:hover { background: var(--surface-2); color: var(--ink); }
  .icon-btn.danger:hover { color: var(--danger); }
  .icon-btn:disabled { opacity: .3; pointer-events: none; }

  .wk { padding: 14px; display: grid; gap: 12px; }
  .wk .l { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
  .wk .l span:last-child { color: var(--muted); }
  .wk .track { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
  .wk .fill { height: 100%; background: var(--c); border-radius: 99px; }

  /* edit */
  .field { width: 100%; background: var(--surface-2); border: 1px solid transparent; border-radius: 12px;
    padding: 12px 14px; font-size: 16px; min-width: 0; }
  .field:focus { outline: none; border-color: var(--accent); background: var(--surface); }



  .swatches { display: grid; grid-template-columns: repeat(8, minmax(0, 32px)); justify-content: space-between; gap: 10px 6px; margin-top: 12px; }
  .sw { width: 100%; aspect-ratio: 1; height: auto; max-width: 32px; }
  .sw { width: 30px; height: 30px; border-radius: 50%; background: var(--c); position: relative; }
  .sw[aria-pressed="true"]::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--c); }






  .hint { color: var(--muted); font-size: 13px; margin: 10px 4px 0; }

  /* history */
  .day { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 4px 8px; }
  .day b { font-size: 15px; }
  .day span { color: var(--muted); font-size: 14px; }

  /* login */
  .login { min-height: calc(100vh - 140px); display: grid; align-content: center; justify-items: center; text-align: center; gap: 16px; padding: 24px 0; }
  .login .mark { width: 64px; height: 64px; border-radius: 20px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
  .login h1 { margin: 6px 0 0; font-size: 32px; letter-spacing: -.02em; }
  .login p { margin: 0; color: var(--muted); max-width: 300px; }
  .login .demo { display: grid; gap: 8px; width: 100%; max-width: 300px; margin: 12px 0; }
  .login .demo div { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); font-weight: 600; font-size: 15px; }
  .login .demo i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
  .login .demo em { margin-left: auto; font-style: normal; color: var(--muted); font-weight: 500; }
  .login .fine { font-size: 12px; color: var(--faint); }
  .login a { color: inherit; }
  #gbtn { min-height: 44px; }

  /* sheet */
  dialog { border: 0; padding: 0; background: var(--surface); color: var(--ink); border-radius: 24px 24px 0 0;
    width: 100%; max-width: min(560px, 100vw); max-height: 92dvh; overflow-y: auto; overflow-x: hidden;
    margin: auto auto 0; box-shadow: 0 -8px 40px rgba(0,0,0,.25); }
  dialog::backdrop { background: rgba(10, 12, 16, .45); }
  .sheet { padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); }
  .sheet .grab { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 14px; }
  .sheet .who { display: flex; align-items: center; gap: 12px; padding: 4px 4px 14px; }
  .sheet .who .avatar { width: 44px; height: 44px; }
  .sheet .who div div:last-child { color: var(--muted); font-size: 14px; }
  .menu button, .menu a { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 8px; border-radius: 12px;
    text-align: left; color: var(--ink); text-decoration: none; font-weight: 550; }
  .menu button:hover, .menu a:hover { background: var(--surface-2); }
  .menu svg { color: var(--muted); }
  .menu .danger, .menu .danger svg { color: var(--danger); }
  .menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

  /* daily chart */
  .chart { position: relative; padding: 16px 14px 12px; overflow: visible; }
  .plot { position: relative; margin: 6px 0 44px 30px; }
  .gl { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
  .gl span { position: absolute; right: 100%; transform: translateY(-50%); padding-right: 6px; font-size: 11px; color: var(--faint); }
  .cols { position: absolute; left: 0; right: 0; bottom: -34px; top: 0; display: grid; grid-template-columns: repeat(14, 1fr); gap: 3px; }
  .col { display: flex; flex-direction: column; align-items: center; min-width: 0; border-radius: 6px; }
  .col .stack { width: 100%; display: flex; align-items: flex-end; justify-content: center; border-radius: 6px; }
  .col .segs { width: min(100%, 18px); display: flex; flex-direction: column-reverse; gap: 2px; border-radius: 4px 4px 0 0; overflow: hidden; }
  .col .segs span { background: var(--c); min-height: 2px; flex-shrink: 0; }
  .col .xl { display: grid; justify-items: center; margin-top: 6px; font-size: 10px; line-height: 1.25; color: var(--faint); }
  .col .xl b { font-weight: 600; color: var(--muted); }
  .col.today .xl, .col.today .xl b { color: var(--ink); }
  .col.sel .stack { background: color-mix(in srgb, var(--ink) 7%, transparent); }
  .seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; margin-bottom: 14px; }
  .seg button { padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
  .seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
  .tl { display: grid; gap: 5px; margin-bottom: 14px; }
  .tl-row { display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 6px; }
  .tl-d { font-size: 11px; color: var(--faint); white-space: nowrap; }
  .tl-row.today .tl-d { color: var(--ink); font-weight: 700; }
  .tl-track { position: relative; height: 16px; border-radius: 4px; background-color: color-mix(in srgb, var(--surface-2) 60%, transparent);
    background-image: linear-gradient(to right, var(--line) 1px, transparent 1px); background-size: 25% 100%; }
  .blk { position: absolute; top: 0; bottom: 0; min-width: 3px; border-radius: 3px; background: var(--c); box-shadow: 0 0 0 1px var(--surface); }
  .blk:hover { filter: brightness(1.1); }
  .tl-now { position: absolute; top: -3px; bottom: -3px; width: 2px; border-radius: 2px; background: var(--ink); }
  .tl-axis { position: relative; height: 14px; }
  .tl-axis span { position: absolute; transform: translateX(-50%); font-size: 11px; color: var(--faint); }
  .tl-axis span:first-child { transform: none; }
  .tl-axis span:last-child { transform: translateX(-100%); }
  .legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
  .lg { display: inline-flex; align-items: center; gap: 6px; }
  .lg i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
  .tip { position: absolute; top: 8px; z-index: 3; min-width: 170px; max-width: 240px; background: var(--surface); color: var(--ink);
    border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; box-shadow: 0 8px 24px rgba(0,0,0,.18); font-size: 13px; pointer-events: none; }
  .tip .th { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; color: var(--muted); }
  .tip .th b { color: var(--ink); }
  .tip .tr { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; padding: 2px 0; }
  .tip .tr i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
  .tip .tr.muted { display: block; color: var(--muted); }

  /* entry rows + editor */
  button.rowi { width: 100%; text-align: left; }
  @media (hover: hover) { button.rowi:hover { background: color-mix(in srgb, var(--ink) 4%, var(--surface)); } }
  .rowi .chev { color: var(--faint); width: 28px; display: grid; place-items: center; }
  .sheet h3 { margin: 0 4px 14px; font-size: 18px; }
  .dt { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 8px; }
  .dt legend { padding: 0; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
  .eform .dt .field { color: var(--ink); font-weight: 500; min-height: 48px; }
  .eform .dt input[type=time] { font-size: 18px; font-weight: 650; }
  /* iPhone gives date/time inputs a fixed native width that overflows a narrow grid; let them shrink */
  .eform .field, .eform select, .eform textarea { min-width: 0; max-width: 100%; box-sizing: border-box; }
  .eform input[type=date], .eform input[type=time] { -webkit-appearance: none; appearance: none; display: block; width: 100%; min-width: 0; }
  .eform input::-webkit-date-and-time-value { text-align: left; margin: 0; }
  .eform label, .eform fieldset { min-width: 0; }
  @media (max-width: 360px) {
    .dt { grid-template-columns: 1fr; }
    .eactions { grid-template-columns: 1fr 1fr; }
    .eactions > span { display: none; }
  }
  /* sheets focus their heading on open (so no dropdown or date picker pops up); it needs no focus ring */
  .sheet h3:focus { outline: none; }
  .eform { display: grid; gap: 12px; }
  .eform label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
  .eform .field { color: var(--ink); font-weight: 500; min-height: 48px; }
  .eform select.field { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
  .edur { margin: 0 4px; color: var(--muted); font-size: 14px; }
  .edur.bad { color: var(--danger); }
  .eactions { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; margin-top: 4px; }
  .eactions .btn { margin-top: 0; }
  .btn.ghost { background: var(--surface-2); color: var(--ink); }
  .btn.ghost.danger { color: var(--danger); }

  /* goals */
  .tile { overflow: hidden; }
  .tbar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: color-mix(in srgb, var(--c) 18%, transparent); }
  .tbar i { display: block; height: 100%; background: var(--c); }
  .tbar.over i { background: var(--danger); }
  .tile .sub.warn { color: var(--danger); font-weight: 600; }
  .chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 4px 10px; }




  .goalrow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .goalrow[hidden] { display: none; }
  .eform .seg { justify-self: start; margin: 0; }

  /* history extras */
  .wk .track { position: relative; overflow: visible; }
  .wk .prev { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 2px; background: var(--ink); opacity: .45; }
  .wk .delta { font-size: 12px; color: var(--muted); margin-top: 5px; }
  .wk .delta.better { color: var(--good); }
  .wk .delta.worse { color: var(--danger); }
  .linkbtn { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 700; font-size: 13px;
    text-transform: none; letter-spacing: 0; }
  .search { position: relative; margin-bottom: 4px; }
  .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
  .search .field { padding-left: 40px; background: var(--surface); box-shadow: var(--shadow); }
  .rowi .note { font-size: 13px; color: var(--muted); margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  textarea.field { resize: vertical; min-height: 64px; font: inherit; line-height: 1.4; }

  /* notifications sheet */
  .nstatus { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; margin: 0 4px; color: var(--muted); }
  .nstatus::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--faint); }
  .nstatus.on { color: var(--ink); }
  .nstatus.on::before { background: var(--good); }
  .nprefs { display: grid; gap: 4px; }
  .nrow { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; text-align: left; padding: 10px 8px; border-radius: 12px; }
  .nrow:hover { background: var(--surface-2); }
  .nrow b { display: block; font-weight: 600; }
  .nrow small { color: var(--muted); font-size: 13px; }
  .nrow .box { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--faint); position: relative; }
  .nrow[aria-pressed="true"] .box { background: var(--ink); border-color: var(--ink); }
  .nrow[aria-pressed="true"] .box::after { content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px;
    border: solid var(--surface); border-width: 0 2px 2px 0; transform: rotate(45deg); }
  .steps { margin: 0; padding-left: 22px; display: grid; gap: 6px; }

  /* appearance + install guide */
  .appearance { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 12px; font-weight: 550; }
  .appearance .seg { margin: 0; }
  .ipreview { display: flex; gap: 14px; align-items: center; padding: 12px; border-radius: 16px; background: var(--surface-2); }
  .ipreview img { border-radius: 13px; flex-shrink: 0; }
  .ipreview small { display: block; color: var(--muted); font-size: 13px; }
  .isteps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; counter-reset: st; }
  .isteps li { display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: center; font-size: 15px; }
  .isteps .sico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--ink); }
  #doinstall { justify-self: start; }
  .ibenefit { margin: 0 4px; font-size: 15px; line-height: 1.45; }

  /* focus */
  .hero.focus .rounds { display: flex; align-items: center; gap: 6px; margin-top: 14px; font-size: 12px; color: var(--muted); }
  .hero.focus .rounds i { width: 22px; height: 6px; border-radius: 99px; background: color-mix(in srgb, var(--c) 25%, transparent); }
  .hero.focus .rounds i.done { background: var(--c); }
  .hero.focus .rounds i.now { background: linear-gradient(90deg, var(--c) 50%, color-mix(in srgb, var(--c) 25%, transparent) 50%); }
  .hero.focus .rounds span { margin-left: 6px; }
  #startfocus { margin-top: 2px; }
  .goalrow.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  /* starter */
  .starter { padding: 18px 16px; display: grid; gap: 10px; margin-top: 4px; }
  .starter h2 { margin: 0; font-size: 20px; }
  .starter .label { color: var(--muted); font-size: 13px; font-weight: 600; margin-top: 6px; }
  .starter .nprefs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .starter .nrow { padding: 8px 6px; }
  .starter .btn { margin-top: 6px; }
  .starter .linkbtn { justify-self: center; }

  /* weekly review */
  .reviewcard { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; margin-top: 8px; padding: 14px 16px;
    border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); color: var(--ink); }
  .reviewcard > svg { color: var(--accent); flex-shrink: 0; }
  .reviewcard span { flex: 1; }
  .reviewcard small { display: block; color: var(--muted); font-size: 13px; }
  .reviewcard .chev { flex: 0; font-size: 22px; color: var(--faint); }
  .rvhead { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; margin-bottom: 8px; }
  .rvhead h3 { margin: 0; text-align: center; }
  .rvhead h3 small { display: block; font-size: 13px; font-weight: 500; color: var(--muted); }
  #rvprev svg { transform: rotate(-90deg); } #rvnext svg { transform: rotate(-90deg); }
  .rvtotal { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
  .rvtotal b { font-size: 36px; letter-spacing: -.02em; }
  .review .delta { font-size: 13px; color: var(--muted); }
  .review .delta.better, .review .better { color: var(--good); }
  .review .delta.worse, .review .worse { color: var(--danger); }
  .rvdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 76px; }
  .rvdays span { display: grid; justify-items: center; align-content: end; gap: 4px; height: 100%; }
  .rvdays i { width: 60%; max-width: 22px; border-radius: 4px 4px 0 0; background: var(--accent); }
  .rvdays small { font-size: 11px; color: var(--muted); }
  .rvfacts { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
  .rvfacts b { color: var(--ink); }
  .review .label { color: var(--muted); font-size: 13px; font-weight: 600; margin-top: 4px; }
  .rvrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 2px; border-bottom: 1px solid var(--line); font-size: 15px; }
  .rvname { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
  .rvname i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
  .rvname small { color: var(--muted); font-size: 12px; width: 100%; padding-left: 17px; margin-top: -2px; }
  .rvval { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }

  /* heatmap */
  .heat { padding: 14px; --cell: 12px; }
  .hchips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; }
  .hchip { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; padding: 5px 10px; border-radius: 99px; font-size: 13px;
    font-weight: 600; color: var(--muted); background: var(--surface-2); }
  .hchip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
  .hchip[aria-pressed="true"] { color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
  .hscroll { overflow-x: auto; scrollbar-width: thin; padding-bottom: 8px; }
  .hwrap { display: flex; gap: 4px; width: max-content; }
  .hdays { display: grid; grid-template-rows: 16px repeat(7, var(--cell)); gap: 3px; font-size: 10px; color: var(--faint); }
  .hdays span { line-height: var(--cell); }
  .hmonths { display: grid; gap: 3px; height: 16px; font-size: 10px; color: var(--faint); }
  .hmonths span { white-space: nowrap; overflow: visible; }
  .hgrid { display: grid; grid-template-rows: repeat(7, var(--cell)); grid-auto-flow: column; grid-auto-columns: var(--cell); gap: 3px; margin-top: 3px; }
  .hgrid i, .hlegend i { display: block; width: var(--cell); height: var(--cell); border-radius: 3px; }
  .hgrid i.pad { visibility: hidden; }
  .l0 { background: var(--surface-2); }
  .l1 { background: color-mix(in srgb, var(--c) 30%, var(--surface-2)); }
  .l2 { background: color-mix(in srgb, var(--c) 55%, var(--surface-2)); }
  .l3 { background: color-mix(in srgb, var(--c) 78%, var(--surface-2)); }
  .l4 { background: var(--c); }
  .hgrid i.sel { outline: 2px solid var(--ink); outline-offset: 1px; }
  .hfoot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--muted); }
  .hlegend { display: inline-flex; align-items: center; gap: 3px; --cell: 10px; }

  /* live screen */
  .hero { position: relative; }
  .lvopen { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
    color: var(--ink); background: color-mix(in srgb, var(--ink) 8%, transparent); z-index: 1; }
  .hero .clock { cursor: pointer; }
  dialog.livedlg { width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; box-shadow: none;
    background: color-mix(in srgb, var(--c) 9%, var(--bg)); overflow-y: auto; }
  dialog.livedlg::backdrop { background: var(--bg); }
  .lv { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; gap: 12px;
    padding: calc(env(safe-area-inset-top) + 10px) 16px 12px; }
  .lvtop { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; }
  .lvname { display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; font-size: 17px; min-width: 0; }
  .lvname .pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--c); animation: pulse 1.6s ease-in-out infinite; flex-shrink: 0; }
  .lvwake { color: var(--faint); }
  .lvwake.on { color: var(--accent); }
  .lvhero { display: grid; justify-items: center; gap: 10px; text-align: center; }
  .lvclockwrap { position: relative; width: min(74vw, 320px, 34dvh); aspect-ratio: 1; }
  .lvring { width: 100%; height: 100%; transform: rotate(-90deg); }
  .lvring circle { fill: none; stroke-width: 7; }
  .lvring .track { stroke: color-mix(in srgb, var(--c) 16%, var(--surface-2)); }
  .lvring .prog { stroke-linecap: round; transition: stroke-dashoffset .9s linear; }
  .lvclock { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 2px; }
  .lvclock small { color: var(--muted); font-size: 14px; font-weight: 600; }
  .lvclock b { font-size: clamp(40px, min(15vw, 8dvh), 78px); font-weight: 750; letter-spacing: -.03em; line-height: 1.05; }
  .lvclock span { color: var(--muted); font-size: 13px; }
  .lvmsg { margin: 0; font-size: 20px; font-weight: 650; line-height: 1.3; max-width: 440px; display: flex; gap: 8px; align-items: center; justify-content: center; }
  .lvmsg.good { color: var(--good); }
  .lvmsg.bad { color: var(--danger); }
  .lvfacts { margin: 0; color: var(--muted); font-size: 13px; }
  .lvcards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .lvcard { background: var(--surface); border-radius: 16px; padding: 10px 12px; display: grid; gap: 4px; box-shadow: var(--shadow); align-content: start; }
  .lvcard small { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
  .lvcard b { font-size: 20px; letter-spacing: -.01em; }
  .lvcard b em { font-style: normal; font-size: 15px; color: var(--muted); font-weight: 600; }
  .lvcard > span { font-size: 13px; color: var(--muted); }
  .lvcard .delta { font-weight: 700; white-space: nowrap; }
  .lvcard .delta.better { color: var(--good); } .lvcard .delta.worse { color: var(--danger); }
  .lvcard .linkbtn { justify-self: start; }
  .lvbar { display: block; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
  .lvbar > i { display: block; height: 100%; background: var(--c); border-radius: 99px; }
  .lvbar.over > i { background: var(--danger); }
  .lvrank { background: var(--surface); border-radius: 16px; padding: 12px 14px; display: grid; gap: 8px; box-shadow: var(--shadow); }
  .lvrank small { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
  .lvrrow { display: grid; grid-template-columns: minmax(0, 7em) 1fr auto; gap: 10px; align-items: center; font-size: 14px; color: var(--muted); }
  .lvrrow span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lvrrow > i { display: block; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
  .lvrrow > i > i { display: block; height: 100%; border-radius: 99px; background: color-mix(in srgb, var(--c) 45%, var(--surface-2)); }
  .lvrrow.me { color: var(--ink); font-weight: 700; }
  .lvrrow.me > i > i { background: var(--c); }
  /* buttons stay reachable at the bottom even when the stats need scrolling */
  .lvactions { display: flex; gap: 10px; margin-top: auto; position: sticky; bottom: 0; z-index: 2;
    padding: 10px 0 calc(env(safe-area-inset-bottom) + 4px);
    background: linear-gradient(transparent, color-mix(in srgb, var(--c) 9%, var(--bg)) 30%); }
  .lvbtn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 10px; border-radius: 16px;
    background: var(--surface); box-shadow: var(--shadow); font-weight: 700; }
  .lvbtn.stop { background: var(--ink); color: var(--bg); }
  .lvbtn:active { transform: scale(.97); }
  .lvauto { display: flex; align-items: center; gap: 8px; justify-content: center; font-size: 13px; color: var(--muted); }
  @media (min-height: 760px) { .lvmsg { font-size: 22px; } }

  /* habits */
  .hcheck { padding: 12px 14px; display: grid; gap: 4px; }
  .hcheck.empty-h { padding: 18px 16px; }
  .hdaynav { display: grid; grid-template-columns: auto 1fr auto; align-items: center; text-align: center; margin-bottom: 4px; }
  #hprev svg, #hnext svg { transform: rotate(-90deg); }
  .hrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
  .hq { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
  .hq > i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
  .yn { display: flex; gap: 6px; flex-shrink: 0; }
  .yn button { min-width: 58px; padding: 9px 12px; border-radius: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
  .yn button.good[aria-pressed="true"] { background: var(--c); color: #fff; }
  .yn button.bad[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
  .habitcard + .habitcard { margin-top: 10px; }
  .hrow.count { flex-wrap: wrap; row-gap: 8px; }
  .hrow.count .hq { flex-wrap: wrap; }
  .hrow.count .hq small { color: var(--muted); font-weight: 500; font-size: 13px; width: 100%; padding-left: 18px; margin-top: -2px; }
  .cnt { display: grid; grid-template-columns: 52px minmax(64px, 1fr) 58px 58px; gap: 6px; width: 100%; }
  .cnt button { padding: 10px 0; border-radius: 12px; font-weight: 700; background: var(--surface-2); color: var(--ink); }
  .cnt button:disabled { opacity: .4; }
  .cnt button.plus { background: color-mix(in srgb, var(--c) 22%, var(--surface-2)); }
  .cnt button:active { transform: scale(.95); }
  .cnt .cval { font-size: 20px; background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
  .cbar { display: block; width: 100%; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
  .cbar i { display: block; height: 100%; background: var(--c); border-radius: 99px; }
  .bigfield { font-size: 28px !important; font-weight: 700; text-align: center; }
  .hgrid i[data-cday] { cursor: pointer; }
  .eform .seg { flex-wrap: wrap; }
  .hhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -4px -4px 4px 0; }
  .hstats { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
  .hstats b { color: var(--ink); }
  .hk-none { background: var(--surface-2); }
  .hk-ok { background: var(--c); }
  /* a neutral dark for slipped days: distinct from every habit colour, including reds and pinks */
  .hk-bad { background: color-mix(in srgb, var(--ink) 42%, var(--surface-2)); }
  .hgrid i.today { outline: 2px solid var(--ink); outline-offset: 1px; }
  .hgrid i[data-hday] { cursor: pointer; }
  .tabs button { font-size: 11px; }

  /* press-and-hold, activity sheet, insights, offline */
  .tile, .hrow, .habitcard { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  .tile.holding, .hrow.holding, .habitcard.holding { transform: scale(.98); transition: transform .45s ease; }
  .holdhint { text-align: center; margin: 10px 0 0; font-size: 12px; }
  .actmore { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .actmore .btn { margin: 0; }
  .movebtns { display: flex; gap: 4px; }
  #actform .chip, #habitform .chip { justify-self: start; margin-top: 0; }
  .ntime { display: flex !important; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px 0 40px; }
  .ntime .field { width: auto; min-height: 40px; padding: 6px 10px; }
  .insights { padding: 4px 14px; }
  .ins { padding: 10px 0; border-left: 3px solid var(--c); padding-left: 10px; margin: 8px 0; }
  .ins p { margin: 0; font-size: 15px; line-height: 1.35; }
  .ins small { color: var(--muted); font-size: 12px; }
  .ins .better { color: var(--good); } .ins .worse { color: var(--danger); }
  .empty.small { padding: 18px; font-size: 14px; }
  #offline { position: fixed; top: calc(env(safe-area-inset-top) + 8px); left: 50%; transform: translateX(-50%); z-index: 30;
    background: var(--ink); color: var(--bg); padding: 6px 14px; border-radius: 99px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); }

  #toast { position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 20;
    max-width: 420px; margin: 0 auto; background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px;
    font-weight: 550; text-align: center; opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; }
  #toast.show { opacity: 1; transform: none; }
  #toast.act { display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left; padding: 8px 8px 8px 16px; }
  #toast.act.show { pointer-events: auto; }
  #toast button { color: var(--accent); font-weight: 800; padding: 8px 12px; border-radius: 10px; }

  /* swipe an entry sideways to delete it */
  .swipe { position: relative; overflow: hidden; }
  .swipe + .swipe { border-top: 1px solid var(--line); }
  .swipe .rowi { position: relative; background: var(--surface); touch-action: pan-y; }
  .swipe .rowi.moving { transition: none; }
  .swipe .rowi.settle { transition: transform .2s ease; }
  .swipe .rowi + .rowi, .swipe + .swipe .rowi { border-top: 0; }
  .swipe-bg { position: absolute; inset: 0; background: var(--danger); color: #fff; display: none; align-items: center;
    justify-content: space-between; padding: 0 20px; font-weight: 700; font-size: 14px; }
  .swipe-bg span { display: inline-flex; align-items: center; gap: 6px; opacity: .5; transition: opacity .15s; }
  .swipe-bg.ready span { opacity: 1; }
  .swipe.swiping .swipe-bg { display: flex; }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    .tile:active, .btn-stop:active { transform: none; }
  }

/* habits page: day switcher on its own card */
.daybar-nav { padding: 6px 8px; margin-bottom: 4px; }
/* counter charts */
.counterchart { padding: 14px; margin-top: 10px; }
.counterchart .hhead { flex-wrap: wrap; gap: 8px; }
.seg.small { margin: 0; padding: 2px; }
.seg.small button { padding: 4px 10px; font-size: 12px; }
.cchart { width: 100%; height: auto; display: block; touch-action: pan-y; }
.cgrid { stroke: var(--line); stroke-width: 1; }
.clab { fill: var(--faint); font-size: 9px; font-family: inherit; }
.ctarget { stroke: var(--ink); stroke-width: 1.2; stroke-dasharray: 4 3; opacity: .55; }
.cbarr { fill: var(--c); }
.cbarr.under { fill: color-mix(in srgb, var(--c) 45%, var(--surface-2)); }
.cbarr.today { stroke: var(--ink); stroke-width: 1.2; }
.cdaily { fill: none; stroke: var(--c); stroke-width: 1.2; opacity: .4; stroke-linejoin: round; }
.cavg { fill: none; stroke: var(--c); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.ccross { stroke: var(--ink); stroke-width: 1; opacity: .35; }
.chit { fill: transparent; cursor: pointer; }
.cinfo .linkbtn { margin-left: 6px; font-size: 12px; }
.clegend { display: inline-flex; flex-wrap: wrap; gap: 4px 10px; }
.clg { display: inline-flex; align-items: center; gap: 4px; }
.clg i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; background: var(--c); }
.clg i.ld { opacity: .4; height: 2px; }
.clg i.lb { height: 8px; width: 8px; }
.clg i.lu { height: 8px; width: 8px; background: color-mix(in srgb, var(--c) 45%, var(--surface-2)); }
.clg i.lt { background: none; border-top: 2px dashed var(--ink); opacity: .55; height: 0; }
.hcheck .hrow:first-child { border-top: 0; }
