/* Ren PWA — dark, touch-first, safe-area aware. Icons are inline SVG (currentColor), no emoji in the chrome.
   Layout (SPEC3): phone (<900px) = header + view + bottom tab bar; wide (>=900px) = left rail 220px + header + view.

   Design tokens:
     bg layers   --bg0 (deep base) / --bg1 (raised) / --bg2 (higher) ; hairlines --line/--line2 (8%/5% white)
     accent      electric blue family (--acc, --acc2, --acc-grad) ; semantic --ok / --warn / --danger
     radius      10 / 14 / 20 (--r1/--r2/--r3)   spacing 4/8/12/16/24   type 11/13/15/17/22
     shadows     raised elements only (--sh1 subtle, --sh2 floating) */
:root {
  --bg0: #0a0e14;
  --bg1: #10161f;
  --bg2: #171f2b;
  --bg3: #1e2836;              /* pressed / hover on bg2 */
  --line: rgba(255,255,255,.08);
  --line2: rgba(255,255,255,.05);
  --text: #e9eef5;
  --text2: #9aa7b8;
  --muted: #64718a;
  --acc: #3f8cff;
  --acc2: #78b0ff;             /* links, on-dark accent text */
  --acc-grad: linear-gradient(135deg, #2a67f4 0%, #3f8cff 55%, #57a0ff 100%);
  --acc-dim: rgba(63,140,255,.14);
  --ok: #34d399;
  --warn: #f5a623;
  --danger: #f26b5e;
  --danger-text: #ffb4ab;
  --chipbg: rgba(255,255,255,.06);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --r1: 10px; --r2: 14px; --r3: 20px;
  --sh1: 0 1px 2px rgba(0,0,0,.35);
  --sh2: 0 10px 30px rgba(0,0,0,.5), 0 2px 8px rgba(0,0,0,.35);
  --tabh: 60px;                /* bottom tab bar (0 on wide) */
  --dur1: 130ms; --dur2: 180ms;
  --ease: cubic-bezier(.2,.7,.3,1);
}
* { box-sizing: border-box; min-width: 0; }
html, body { height: 100%; margin: 0; background: var(--bg0); color: var(--text); overflow-x: hidden; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.45;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  font-variant-numeric: tabular-nums;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
button:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.wide-only { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Icons */
.ic { width: 24px; height: 24px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; pointer-events: none; }
.ic.sm { width: 20px; height: 20px; }
.ic.xs { width: 16px; height: 16px; stroke-width: 2; }

/* ---------- App shell ---------- */
#app {
  height: 100%; height: 100dvh;   /* 100% (not 100vh): pre-dvh Chromium/Samsung Internet sizes 100vh to the URL-bar-hidden viewport and clips the composer */
  display: flex; flex-direction: row;
  padding-left: var(--sal); padding-right: var(--sar);
  overflow: hidden;
  background: var(--bg0);
}
#rail { display: none; }
#main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; height: 100%; }
#views { flex: 1 1 auto; min-height: 0; position: relative; display: flex; flex-direction: column; }
.view { display: none; }
.view.on { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; position: relative; animation: viewin var(--dur2) var(--ease); }
@keyframes viewin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Header: 56px + status-bar inset; busy shimmer line lives on its bottom edge */
#hdr {
  flex: 0 0 auto;
  height: calc(56px + var(--sat));
  padding: var(--sat) 8px 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg1); border-bottom: 1px solid var(--line);
  position: relative; z-index: 5;
}
#busybar {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; z-index: 6;
  background: linear-gradient(90deg, transparent 0%, var(--acc) 35%, #9cc5ff 50%, var(--acc) 65%, transparent 100%);
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
  opacity: 0; pointer-events: none; transition: opacity var(--dur2);
}
body.busy #busybar { opacity: 1; }
@keyframes shimmer { from { background-position: 210% 0; } to { background-position: -110% 0; } }
.hdr-left { display: flex; align-items: center; gap: 9px; min-width: 0; }
.hdr-right { display: flex; align-items: center; gap: 0; position: relative; }
.title { font-weight: 650; font-size: 17px; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.dot.connected { background: var(--ok); box-shadow: 0 0 0 3px rgba(52,211,153,.15); }
.dot.busy { background: var(--warn); box-shadow: 0 0 0 3px rgba(245,166,35,.15); animation: blink 1.1s ease-in-out infinite; }
.dot.offline { background: var(--danger); box-shadow: 0 0 0 3px rgba(242,107,94,.15); }
.hf { font-size: 11px; font-weight: 600; color: var(--ok); background: rgba(52,211,153,.12); border: 1px solid rgba(52,211,153,.35); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
body:not([data-view="chat"]) .chat-only { display: none !important; }

.ib {
  width: 44px; height: 44px; border-radius: var(--r1); color: var(--text2);
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1; user-select: none; -webkit-user-select: none; flex: 0 0 auto;
  transition: background var(--dur1), color var(--dur1), transform var(--dur1);
}
.ib:active { background: var(--bg2); transform: scale(.94); }
#btnSpeak .ic-on { display: none; }
#btnSpeak[aria-pressed="true"] { color: var(--acc); }
#btnSpeak[aria-pressed="true"] .ic-on { display: block; }
#btnSpeak[aria-pressed="true"] .ic-off { display: none; }
#btnStop { color: var(--danger); }
#btnStop .ic { fill: currentColor; }

/* Bottom tab bar (phone): active tab = filled pill behind the icon */
#tabbar {
  flex: 0 0 auto; height: calc(var(--tabh) + var(--sab)); padding-bottom: var(--sab);
  display: flex; align-items: stretch;
  background: color-mix(in srgb, var(--bg1) 88%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); z-index: 6;
}
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) { #tabbar { background: var(--bg1); } }
.tab {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11px; font-weight: 550; position: relative; -webkit-user-select: none; user-select: none; min-width: 0;
  transition: color var(--dur1);
}
.tab .ic { width: 23px; height: 23px; position: relative; z-index: 1; }
.tab span { white-space: nowrap; position: relative; z-index: 1; }
.tab::before {   /* pill behind the icon */
  content: ""; position: absolute; top: 6px; left: 50%; transform: translateX(-50%) scaleX(.6);
  width: 52px; height: 30px; border-radius: 999px; background: transparent; opacity: 0;
  transition: opacity var(--dur1), transform var(--dur2) var(--ease), background var(--dur1);
}
.tab.on { color: var(--acc2); }
.tab.on .ic { color: var(--acc2); stroke-width: 2.1; }
.tab.on::before { background: var(--acc-dim); opacity: 1; transform: translateX(-50%) scaleX(1); }
.tab:active .ic { transform: scale(.9); }
.tab:active::before { opacity: 1; background: var(--bg2); transform: translateX(-50%) scaleX(1); }
.nbadge {
  position: absolute; top: 3px; left: calc(50% + 8px);
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--acc-grad); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; font-style: normal;
  box-shadow: 0 0 0 2px var(--bg1);
  pointer-events: none; z-index: 2;
}

/* Left rail (wide): same pill language */
.rail-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; padding: calc(18px + var(--sat)) 22px 14px; letter-spacing: .2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin: 2px 12px; border-radius: 999px;
  color: var(--text2); font-size: 14px; font-weight: 550; position: relative;
  transition: background var(--dur1), color var(--dur1);
}
.nav-item .ic { width: 21px; height: 21px; }
.nav-item:hover { background: var(--bg2); color: var(--text); }
.nav-item:active { transform: scale(.98); }
.nav-item.on { background: var(--acc-dim); color: var(--text); }
.nav-item.on .ic { color: var(--acc2); }
.nav-item .nbadge { position: static; margin-left: auto; box-shadow: none; }

/* ---------- Chat view ---------- */
#msgs {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  padding: 14px 14px 10px;
  display: flex; flex-direction: column;
  overscroll-behavior: contain;
  scroll-behavior: auto;
}
.msg { display: flex; flex-direction: column; max-width: 86%; min-width: 0; margin-top: 14px; position: relative; }
.msg:first-child { margin-top: 0; }
.msg.cont { margin-top: 2px; }          /* same-role continuation: tight rhythm */
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; align-items: flex-start; }

/* day separators */
.daysep { align-self: center; margin: 18px 0 4px; display: flex; align-items: center; gap: 10px; max-width: 100%; }
.daysep:first-child { margin-top: 2px; }
.daysep span {
  font-size: 11px; font-weight: 650; letter-spacing: .8px; text-transform: uppercase; color: var(--muted);
  background: var(--bg2); border: 1px solid var(--line2); border-radius: 999px; padding: 3px 12px; white-space: nowrap;
}

.bubble {
  max-width: 100%;
  padding: 9px 14px; border-radius: var(--r3); word-wrap: break-word; overflow-wrap: anywhere;
  white-space: pre-wrap; font-size: 15px; line-height: 1.5;
}
.msg.user .bubble { background: var(--acc-grad); color: #fff; border-bottom-right-radius: 7px; box-shadow: var(--sh1); }
.msg.user.grp .bubble { border-bottom-right-radius: var(--r3); }
.msg.user.cont .bubble { border-top-right-radius: 7px; }
.msg.user.cont.grp .bubble { border-top-right-radius: 7px; border-bottom-right-radius: 7px; }
.msg.assistant .bubble { background: var(--bg2); border-bottom-left-radius: 7px; }
.msg.assistant.grp .bubble { border-bottom-left-radius: var(--r3); }
.msg.assistant.cont .bubble { border-top-left-radius: 7px; }
.msg.assistant.cont.grp .bubble { border-top-left-radius: 7px; border-bottom-left-radius: 7px; }
.msg.error .bubble { background: rgba(242,107,94,.08); border: 1px solid rgba(242,107,94,.4); color: var(--danger-text); }
.msg.pending .bubble { opacity: .65; }
.meta { font-size: 11px; color: var(--text2); margin: 4px 6px 0; }
.msg.grp .meta { display: none; }        /* timestamp only on the last message of a group */
.tag { font-size: 10px; font-weight: 650; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin: 0 6px 3px; }
.msg.cont .tag { display: none; }

.bubble pre {
  background: #070b10; border: 1px solid var(--line2); border-radius: var(--r1);
  padding: 9px 11px; margin: 8px 0; overflow-x: auto; white-space: pre; max-width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.4;
}
.msg.user .bubble pre { background: rgba(0,0,0,.28); border-color: rgba(255,255,255,.12); }
.bubble code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; background: rgba(255,255,255,.07); padding: 1px 5px; border-radius: 5px; }
.msg.user .bubble code { background: rgba(0,0,0,.25); }
.bubble pre code { background: none; padding: 0; font-size: inherit; }
.bubble a { color: var(--acc2); text-decoration: underline; text-underline-offset: 2px; }
.msg.user .bubble a { color: #d6e6ff; }
.bubble .li { display: block; padding-left: 1.1em; text-indent: -1.1em; }
.bubble b { font-weight: 650; }
.cursor::after { content: ""; display: inline-block; width: 8px; height: 15px; margin-left: 2px; border-radius: 2px; background: var(--acc); vertical-align: -2px; animation: caret 1s var(--ease) infinite; }
@keyframes caret { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

/* copy on hover (desktop) / long-press (touch, handled in JS) */
.cpy {
  position: absolute; top: -10px; width: 28px; height: 28px; border-radius: 8px;
  background: var(--bg3); border: 1px solid var(--line); color: var(--text2);
  display: inline-flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity var(--dur1); z-index: 2; box-shadow: var(--sh1);
}
.cpy .ic { width: 14px; height: 14px; stroke-width: 2; }
.msg.user .cpy { left: -8px; }
.msg.assistant .cpy { right: -8px; }
@media (hover: hover) {
  .msg:hover .cpy { opacity: 1; pointer-events: auto; }
  .cpy:hover { color: var(--text); background: var(--bg2); }
}

/* Tool activity strip: slim single-line rows, gear pulses while the turn is live */
.tools {
  display: flex; flex-direction: column; gap: 0; margin: 0 0 4px; align-self: flex-start; width: auto; max-width: 100%; min-width: 0;
  background: var(--bg1); border: 1px solid var(--line2); border-radius: var(--r2); padding: 4px 2px; overflow: hidden;
}
.chip {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; line-height: 1.3; color: var(--muted);
  padding: 3px 8px; max-width: 100%; min-width: 0; overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.chip .ic { width: 12px; height: 12px; stroke-width: 2; color: var(--muted); }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.msg.run .tools .chip:last-child { color: var(--text2); }
.msg.run .tools .chip:last-child .ic { color: var(--acc); animation: gearspin 1.6s linear infinite; }
@keyframes gearspin { to { transform: rotate(360deg); } }

.pill {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 92px;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--acc-grad); color: #fff; font-size: 13px; font-weight: 650;
  padding: 8px 14px 8px 10px; border-radius: 999px; box-shadow: var(--sh2); z-index: 8;
}
.pill .ic { width: 17px; height: 17px; stroke-width: 2.2; }
.pill:active { transform: translateX(-50%) scale(.97); }

/* Composer: floating raised pill, mic + send inside */
#composer {
  flex: 0 0 auto;
  display: flex; align-items: flex-end; gap: 2px;
  margin: 6px 10px 10px;
  padding: 5px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 26px;
  box-shadow: var(--sh2);
  transition: border-color var(--dur1);
}
#composer:focus-within { border-color: rgba(63,140,255,.5); }
#ta {
  flex: 1 1 auto; min-width: 0; resize: none;
  font: inherit; font-size: 16px; line-height: 1.35;
  color: var(--text); background: none;
  border: 0; border-radius: 18px;
  padding: 10px 6px; min-height: 42px; max-height: 40vh; overflow-y: auto;
}
#ta:focus { outline: none; }
#ta::placeholder { color: var(--muted); }
#ta.listening { caret-color: var(--danger); }
.mic { color: var(--text2); border-radius: 50%; width: 42px; height: 42px; }
.mic.live { color: #fff; background: var(--danger); animation: pulse 1.2s ease-in-out infinite; }
.mic.hf { box-shadow: 0 0 0 2px var(--ok); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(242,107,94,.55); } 50% { box-shadow: 0 0 0 10px rgba(242,107,94,0); } }
.send { color: #fff; border-radius: 50%; width: 42px; height: 42px; position: relative; z-index: 0; }
.send::before { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--acc-grad); z-index: -1; transition: opacity var(--dur1); }
.send .ic { width: 19px; height: 19px; margin: 1px 0 0 -2px; }
.send:disabled { color: var(--muted); }
.send:disabled::before { opacity: 0; }
.send:not(:disabled):active { transform: scale(.92); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(96px + var(--tabh) + var(--sab));
  max-width: min(92vw, 520px);
  background: var(--bg3); color: var(--text); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 999px; font-size: 13.5px; z-index: 50;
  box-shadow: var(--sh2);
  animation: toastin var(--dur2) var(--ease);
}
@keyframes toastin { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%); } }

/* Notices: centered pill with an icon */
.msg.notice { align-self: center; align-items: center; max-width: 92%; margin-top: 14px; }
.msg.notice .bubble {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg1); border: 1px solid var(--line); color: var(--text2);
  font-size: 13px; text-align: left; border-radius: 999px; padding: 7px 14px 7px 11px; white-space: normal;
}
.msg.notice .bubble .ic { width: 17px; height: 17px; flex: 0 0 auto; }
.msg.notice.reminder .bubble, .msg.notice.event .bubble { color: var(--text); background: rgba(245,166,35,.08); border-color: rgba(245,166,35,.4); }
.msg.notice.reminder .bubble .ic, .msg.notice.event .bubble .ic { color: var(--warn); }
.msg.notice .meta { margin-top: 4px; }
.msg.user.schedule .bubble { background: rgba(245,166,35,.08); border: 1px solid rgba(245,166,35,.4); color: var(--text); box-shadow: none; }

/* chat empty state */
.empty {
  color: var(--text2); font-size: 14px; text-align: center; padding: 36px 24px; line-height: 1.55; white-space: pre-line;
  display: flex; flex-direction: column; align-items: center; gap: 4px; margin: auto 0;
}
.empty.small { padding: 12px; margin: 0; }
.empty .eglyph {
  width: 64px; height: 64px; border-radius: 22px; margin-bottom: 10px;
  background: var(--acc-dim); color: var(--acc2);
  display: inline-flex; align-items: center; justify-content: center;
}
.empty .eglyph .ic { width: 30px; height: 30px; stroke-width: 1.6; }
.empty .etitle { font-size: 16px; font-weight: 650; color: var(--text); }
.empty .ehint { max-width: 340px; }
.empty .etry {
  margin-top: 10px; font-size: 13px; color: var(--acc2);
  background: var(--acc-dim); border: 1px solid rgba(63,140,255,.25); border-radius: 999px; padding: 6px 14px;
}

/* ---------- Generic view content ---------- */
.vwrap { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 12px 14px calc(24px + var(--sab)); width: 100%; max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; }
.vbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 10px; flex: 0 0 auto; }
.vhint { font-size: 13px; color: var(--text2); }
.vlist { display: flex; flex-direction: column; gap: 2px; }
.vwrap > .vlist:only-child, .vwrap .vlist .empty { margin-top: 0; }
.vsec { margin: 4px 0 10px; }
.vsec-t { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); padding: 12px 8px 6px; }
.vsec.over .vsec-t { color: var(--danger); }

/* Text buttons */
.tbtn { display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; height: 36px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); font-size: 13.5px; font-weight: 600; white-space: nowrap; color: var(--text); transition: background var(--dur1), transform var(--dur1); }
.tbtn:active { background: var(--bg3); transform: scale(.97); }
.tbtn.primary { background: var(--acc-grad); border-color: transparent; color: #fff; box-shadow: var(--sh1); }
.tbtn.danger { color: var(--danger-text); border-color: rgba(242,107,94,.4); background: rgba(242,107,94,.08); }
.tbtn.mini { height: 30px; padding: 0 11px; font-size: 12.5px; }
.tbtn.run { color: var(--acc2); }
.tbtn.run .ic { fill: currentColor; }
.tbtn:disabled { opacity: .5; }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; }

/* Quick add: pill input + accent round button */
.padd { display: flex; align-items: center; gap: 6px; margin: 2px 0 10px; width: 100%; flex: 0 0 auto; }
.padd input {
  flex: 1 1 auto; min-width: 0; height: 44px; font: inherit; font-size: 16px; color: var(--text); background: var(--bg1);
  border: 1px solid var(--line); border-radius: 22px; padding: 0 18px;
  transition: border-color var(--dur1), background var(--dur1);
}
.padd input:focus { border-color: rgba(63,140,255,.5); background: var(--bg2); outline: none; }
.padd input::placeholder { color: var(--muted); }
.padd .add { color: #fff; border-radius: 50%; position: relative; z-index: 0; }
.padd .add::before { content: ""; position: absolute; width: 38px; height: 38px; border-radius: 50%; background: var(--acc-grad); box-shadow: var(--sh1); z-index: -1; }
.padd .add .ic { width: 20px; height: 20px; stroke-width: 2.2; }
.padd .add:active { transform: scale(.92); }

/* Rows: [toggle] [content flex:1 min-width:0] [actions] — raised cards */
.row {
  display: flex; align-items: center; gap: 12px; padding: 10px 6px 10px 10px; border-radius: var(--r2); min-height: 56px;
  background: var(--bg1); border: 1px solid var(--line2); margin-top: 6px;
}
.vsec .row:first-of-type, .vlist > .row:first-child { margin-top: 0; }
.row + .row, details.donebox .row { margin-top: 6px; }
.row.off { opacity: .55; }
.row.off .racts { opacity: 1; }
.rmain { flex: 1 1 auto; min-width: 0; }
.rmain.tap { cursor: pointer; }
.rmain.tap:active { opacity: .7; }
.rtext { font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rtext .rt { min-width: 0; }
.rtext.done { text-decoration: line-through; color: var(--muted); }
.rsub { font-size: 12px; color: var(--text2); margin-top: 3px; display: flex; align-items: center; gap: 4px; min-width: 0; }
.rsub > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rsub .ic { width: 14px; height: 14px; stroke-width: 2.2; transition: transform var(--dur1); }
.row.open .rsub .ic { transform: rotate(180deg); }
.rsub.over { color: var(--danger-text); font-weight: 600; }
.rsub.wrap > span { white-space: normal; overflow-wrap: anywhere; }
.rsub .nw { white-space: nowrap; }
.rsched { color: var(--text2); }
.rr .rsub > span { white-space: normal; }
.ract { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.tbtn.ghost { background: none; border-color: transparent; color: var(--muted); padding-left: 6px; }
.tbtn.ghost .ic { transition: transform var(--dur1); }
.row.open .tbtn.ghost .ic { transform: rotate(180deg); }
.rr .rfull { margin-top: 8px; }
.rr.open { align-items: flex-start; }
.rr.open .tog { margin-top: 10px; }
.duechip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text2); background: var(--chipbg); border-radius: 999px; padding: 2px 9px 2px 7px; max-width: 100%; min-width: 0; }
.duechip .dtxt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.duechip .ic { width: 13px; height: 13px; }
.duechip.over { color: var(--danger-text); background: rgba(242,107,94,.14); font-weight: 600; }
.rfull { display: none; font-size: 13px; color: var(--text2); line-height: 1.5; margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; border-left: 2px solid var(--line); padding-left: 10px; }
.rfull-acts { margin-top: 8px; }
.row.open .rfull { display: block; }
.row.open { align-items: flex-start; }
.row.open .tog { margin-top: 10px; }
.row.open .racts { margin-top: 4px; }
.racts { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.rb { width: 36px; height: 36px; border-radius: var(--r1); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; position: relative; transition: background var(--dur1), color var(--dur1), transform var(--dur1); }
.rb::before { content: ""; position: absolute; inset: -4px; }   /* 44px touch target */
.rb .ic { width: 19px; height: 19px; }
.rb:active { background: var(--bg2); color: var(--text); transform: scale(.92); }
.rb.on { color: var(--warn); }
.rb.on .ic { fill: currentColor; }
.tog { appearance: none; -webkit-appearance: none; width: 42px; height: 25px; border-radius: 999px; background: var(--bg3); border: 1px solid var(--line); position: relative; flex: 0 0 auto; margin: 0; cursor: pointer; transition: background var(--dur2), border-color var(--dur2); }
.tog::before, .chk::before { content: ""; position: absolute; inset: -12px; }   /* 44px+ touch target without changing the visual size */
.tog::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: var(--text2); transition: left var(--dur2) var(--ease), background var(--dur1); }
.tog:checked { background: var(--acc); border-color: var(--acc); }
.tog:checked::after { left: 20px; background: #fff; }
.chk { appearance: none; -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--muted); flex: 0 0 auto; margin: 0 6px; cursor: pointer; position: relative; transition: background var(--dur1), border-color var(--dur1); }
.chk:checked { background: var(--ok); border-color: var(--ok); }
.chk:checked::after { content: ""; position: absolute; left: 6px; top: 2px; width: 6px; height: 11px; border: solid #052e16; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.hcirc { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--line); background: var(--bg2); flex: 0 0 auto; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; margin: 0 2px; position: relative; transition: background var(--dur1), border-color var(--dur1), transform var(--dur1); }
.hcirc::before { content: ""; position: absolute; inset: -6px; }
.hcirc .ic { width: 19px; height: 19px; stroke-width: 2.4; display: none; }
.hcirc.on { background: var(--ok); border-color: var(--ok); color: #052e16; }
.hcirc.on .ic { display: block; }
.hcirc:active { transform: scale(.9); }
.streak { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--warn); font-weight: 650; flex: 0 0 auto; background: rgba(245,166,35,.1); border-radius: 999px; padding: 1px 8px 1px 5px; }
.streak .ic { width: 13px; height: 13px; stroke-width: 2; }
.dots { display: flex; gap: 5px; margin-top: 6px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--bg3); border: 1px solid var(--line); display: block; }
.dots i.on { background: var(--ok); border-color: var(--ok); }
.dots i.skip { opacity: .35; }
.dots i.today { box-shadow: 0 0 0 1.5px var(--text2); }
details.donebox { margin-top: 12px; }
details.donebox summary { color: var(--muted); font-size: 13px; font-weight: 600; padding: 8px 8px; cursor: pointer; user-select: none; }
details.donebox summary:hover { color: var(--text2); }

/* Habits today strip */
.hstrip { display: flex; gap: 8px; overflow-x: auto; padding: 0 0 10px; margin: 0 0 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none; align-items: flex-start; flex-wrap: wrap; flex: 0 0 auto; }
.hstrip::-webkit-scrollbar { display: none; }
.hstrip .vsec-t { flex: 1 0 100%; padding-top: 4px; }
.hcell { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 86px; padding: 10px 4px 8px; border-radius: var(--r2); background: var(--bg1); border: 1px solid var(--line2); flex: 0 0 auto; color: var(--text); transition: background var(--dur1), transform var(--dur1); }
.hcell:active { background: var(--bg2); transform: scale(.96); }
.hcell.off .hcirc { opacity: .5; }
.row.notdue .hcirc { opacity: .5; }
.hcell .hcirc { width: 40px; height: 40px; }
.hcell.on { border-color: rgba(52,211,153,.35); }
.hcell .hname { font-size: 11.5px; line-height: 1.2; text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text2); }
.hcell.on .hname { color: var(--text); }

/* ---------- Sheets (bottom on phone / centered card on wide) ---------- */
.sheetbg { position: fixed; inset: 0; background: rgba(4,6,10,.55); z-index: 30; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fadein var(--dur2); }
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) { .sheetbg { background: rgba(4,6,10,.72); } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; max-height: min(88%, calc(100% - var(--sat) - 40px));
  background: var(--bg1); border-top: 1px solid var(--line); border-radius: var(--r3) var(--r3) 0 0;
  z-index: 31; display: flex; flex-direction: column;
  padding-bottom: var(--sab); box-shadow: var(--sh2);
  overflow: hidden;
  animation: sheetup var(--dur2) var(--ease);
}
@keyframes sheetup { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet::before {   /* grab handle */
  content: ""; position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
  width: 36px; height: 4px; border-radius: 2px; background: var(--line);
}
.sh-hdr { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 16px 8px 4px 20px; }
.sh-title { font-weight: 700; font-size: 17px; }
.sh-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 4px 18px 20px; }
.more { display: flex; flex-direction: column; gap: 6px; }
.more-row { display: flex; align-items: center; gap: 14px; padding: 13px 12px; border-radius: var(--r2); color: var(--text); background: var(--bg2); border: 1px solid var(--line2); transition: background var(--dur1); }
.more-row:active { background: var(--bg3); }
.more-row > .ic { color: var(--acc2); }
.more-row > .ic.sm { color: var(--muted); margin-left: auto; }
.more-t { min-width: 0; flex: 1 1 auto; }
.more-l { font-size: 15px; font-weight: 650; }
.more-s { font-size: 12.5px; color: var(--text2); }
.more-v { font-size: 12px; color: var(--muted); text-align: center; padding: 12px 0 2px; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.fld { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1 1 auto; }
.flbl { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .7px; }
.fhint { font-size: 12px; color: var(--text2); line-height: 1.45; }
.form input[type=text], .form input[type=url], .form input[type=password], .form input[type=date], .form input[type=time], .form input[type=number], .form select, .form textarea, .frow select {
  width: 100%; min-height: 44px; font: inherit; font-size: 16px; color: var(--text); background: var(--bg0);
  border: 1px solid var(--line); border-radius: var(--r1); padding: 8px 12px; color-scheme: dark;
  transition: border-color var(--dur1);
}
.form textarea { resize: vertical; line-height: 1.4; }
.form input:focus, .form select:focus, .form textarea:focus { border-color: var(--acc); outline: none; }
.form input[type=color] { width: 56px; height: 44px; padding: 3px; border: 1px solid var(--line); border-radius: var(--r1); background: var(--bg0); }
.frow { display: flex; gap: 10px; align-items: flex-start; }
.frow > * { flex: 1 1 0; }
.togf { flex: 0 0 auto; }
.togf .tog { margin: 10px 0; }
.dim { opacity: .45; }
.daypick { display: flex; flex-wrap: wrap; gap: 6px; }
.dp { display: inline-flex; align-items: center; gap: 5px; padding: 7px 11px; border-radius: 999px; background: var(--bg0); border: 1px solid var(--line); font-size: 13px; cursor: pointer; transition: border-color var(--dur1), background var(--dur1); }
.dp input { margin: 0; accent-color: var(--acc); }
.dp:has(input:checked) { border-color: var(--acc); background: var(--acc-dim); }
.facts { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.facts .tbtn { height: 40px; }
.togl { display: inline-flex; align-items: center; gap: 8px; margin-right: auto; font-size: 14px; color: var(--text2); }
.form.inline { margin-top: 12px; }

/* Event sheet */
.evs { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.evs-head { display: flex; align-items: flex-start; gap: 12px; }
.evs-head h3 { margin: 0; font-size: 19px; line-height: 1.3; font-weight: 700; overflow-wrap: anywhere; }
.evs-bar { width: 5px; align-self: stretch; border-radius: 3px; flex: 0 0 auto; min-height: 24px; }
.evs-line { display: flex; align-items: flex-start; gap: 10px; font-size: 14.5px; color: var(--text); overflow-wrap: anywhere; }
.evs-line .ic { color: var(--muted); margin-top: 1px; }
.evs-notes { font-size: 14px; color: var(--text2); white-space: pre-wrap; overflow-wrap: anywhere; border-left: 2px solid var(--line); padding-left: 10px; line-height: 1.5; }

/* ---------- Settings ---------- */
.set { margin: 0 0 16px; background: var(--bg1); border: 1px solid var(--line2); border-radius: var(--r2); padding: 8px 14px 14px; flex: 0 0 auto; }
.set h2 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 8px 2px 6px; }
.sdesc { font-size: 13px; color: var(--text2); margin: 0 2px 8px; line-height: 1.5; }
.srow { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding: 11px 2px; border-top: 1px solid var(--line2); }
.srow > .rmain { flex: 1 1 200px; }
.srow:first-of-type { border-top: 0; }
.srow.col { align-items: flex-start; }
.slbl { font-size: 15px; font-weight: 600; }
.ssub { font-size: 12.5px; color: var(--text2); line-height: 1.5; margin-top: 2px; overflow-wrap: anywhere; }
.ssub.ver { margin-top: 10px; padding: 0 2px; color: var(--muted); }
.srow > .tbtn, .srow > .tog, .srow > .rb { flex: 0 0 auto; }
code.topic { display: inline-block; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13.5px; background: var(--bg0); border: 1px solid var(--line2); padding: 6px 11px; border-radius: 8px; margin: 6px 0; overflow-wrap: anywhere; user-select: all; }
.rangewrap { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.range { width: 130px; accent-color: var(--acc); }
.rval { font-size: 13px; color: var(--text2); min-width: 44px; text-align: right; }
.cdot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; margin: 0 6px; }
.notice-box { display: flex; gap: 12px; align-items: flex-start; background: rgba(245,166,35,.08); border: 1px solid rgba(245,166,35,.4); border-radius: var(--r2); padding: 12px; margin: 0 0 16px; font-size: 14px; flex: 0 0 auto; }
.notice-box > .ic { color: var(--warn); flex: 0 0 auto; margin-top: 2px; }
.notice-box ol { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--text2); line-height: 1.5; }
.notice-box li { margin: 4px 0; overflow-wrap: anywhere; }
#setVoice { max-width: 100%; }
.srow .frow { flex: 1 1 auto; align-items: center; }
.srow .frow > select { flex: 1 1 auto; min-height: 40px; }
.srow .frow > .tbtn { flex: 0 0 auto; }

/* Google account (SPEC4) */
ol.gsteps { margin: 6px 0 10px; padding-left: 20px; font-size: 13px; color: var(--text2); line-height: 1.55; }
.gsteps li { margin: 5px 0; overflow-wrap: anywhere; }
.gsteps b { color: var(--text); font-weight: 600; }
code.cmd { display: inline-block; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; background: var(--bg0); border: 1px solid var(--line2); padding: 6px 11px; border-radius: 8px; margin: 4px 0 2px; overflow-wrap: anywhere; user-select: all; }
.gcals { display: flex; flex-direction: column; margin-top: 2px; }
.gcal { display: flex; align-items: center; gap: 8px; padding: 7px 0; min-height: 44px; cursor: pointer; }
.gcal + .gcal { border-top: 1px solid var(--line2); }
.gcal .chk { margin: 0 2px 0 0; border-radius: 7px; }
.gcal .chk:checked::after { left: 7px; top: 3px; }
.gcal .cdot { margin: 0 2px; }
.gcal .gname { flex: 1 1 auto; min-width: 0; font-size: 14.5px; overflow-wrap: anywhere; }
.gcal .gtag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; flex: 0 0 auto; }
.slbl.ico { display: flex; align-items: center; gap: 7px; }
.slbl.ico .ic { color: var(--muted); }
.ssub.gwarn { color: var(--warn); }

/* ---------- Calendar ---------- */
.cal-top { flex: 0 0 auto; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); background: var(--bg1); }
.cal-nav { display: flex; align-items: center; gap: 2px; }
.cal-nav .ib { width: 40px; height: 40px; }
.cal-title { font-size: 17px; font-weight: 700; padding: 0 6px; height: 40px; border-radius: var(--r1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; letter-spacing: .2px; }
.cal-nav .sp { flex: 1 1 auto; }
.seg { display: flex; margin: 10px 2px 0; background: var(--bg0); border: 1px solid var(--line2); border-radius: 999px; padding: 3px; }
.seg button { flex: 1 1 0; height: 32px; border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--muted); transition: color var(--dur1), background var(--dur1); }
.seg button.on { background: var(--bg3); color: var(--text); box-shadow: var(--sh1); }
.cal-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; position: relative; }
.fab {
  position: absolute; right: 16px; bottom: calc(16px + var(--sab)); width: 56px; height: 56px; border-radius: 19px;
  background: var(--acc-grad); color: #fff; display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--sh2); z-index: 7; transition: transform var(--dur1);
}
.fab .ic { width: 26px; height: 26px; stroke-width: 2.2; }
.fab:active { transform: scale(.93); }
.cal-body.month .fab { width: 48px; height: 48px; border-radius: 16px; right: 12px; bottom: 12px; }
.cal-body.month .fab .ic { width: 24px; height: 24px; }
.cal-body.month .mo-grid { padding-bottom: 60px; }   /* keep the FAB off the last-row Saturday cell (phone) */

/* Month */
.mo { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.mo-grid { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: 26px repeat(6, minmax(0, 1fr)); }
.mo-dh { font-size: 10.5px; font-weight: 700; color: var(--muted); text-align: center; line-height: 26px; text-transform: uppercase; letter-spacing: .6px; }
.mo-cell { border-top: 1px solid var(--line2); padding: 3px 3px 2px; display: flex; flex-direction: column; gap: 2px; overflow: hidden; min-height: 0; cursor: pointer; position: relative; }
.mo-cell.other { color: var(--muted); }
.mo-cell.other .mo-dn span { opacity: .5; }
.mo-cell.other .mchip { opacity: .45; }
.mo-cell.sel { background: var(--acc-dim); border-radius: var(--r1); }
.mo-cell.sel::after { content: ""; position: absolute; inset: 0; border: 1px solid rgba(63,140,255,.45); border-radius: var(--r1); pointer-events: none; }
.mo-cell:active { background: var(--bg2); }
.mo-dn { font-size: 12px; font-weight: 600; line-height: 22px; height: 22px; padding-left: 1px; display: flex; align-items: center; flex: 0 0 auto; }
.mo-dn span { display: inline-block; min-width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 11px; padding: 0 3px; white-space: nowrap; color: var(--text); }
.mo-cell.other .mo-dn span { color: var(--text2); }
.mo-cell.today .mo-dn span { background: var(--acc-grad); color: #fff; font-weight: 700; box-shadow: var(--sh1); }
.mchip {
  display: flex; align-items: center; gap: 3px; font-size: 10.5px; line-height: 16px; height: 16px; padding: 0 4px 0 5px; border-radius: 4px;
  border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 14%, var(--bg1)); color: var(--text); overflow: hidden; white-space: nowrap; flex: 0 0 auto; cursor: pointer;
}
@supports not (background: color-mix(in srgb, red 20%, blue)) { .mchip { background: var(--bg2); } }
.mchip.ad { background: var(--c); border-left-color: var(--c); color: #fff; }
.mchip.rem { border-left-style: dotted; }
.mchip.off { opacity: .45; }
.mchip .ic { width: 10px; height: 10px; stroke-width: 2.6; }
.mchip .mt { color: var(--muted); display: none; flex: 0 0 auto; }
.mchip.ad .mt { color: rgba(255,255,255,.85); }
.mchip .mtitle { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mo-more { font-size: 10px; color: var(--text2); padding-left: 5px; line-height: 13px; white-space: nowrap; overflow: hidden; font-weight: 600; }
.mo-morew { display: none; }
.mo-side { display: none; }

/* Week */
.wk { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.wk-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; position: relative; }
.wk-grid { display: grid; grid-template-columns: 46px repeat(7, minmax(96px, 1fr)); grid-template-rows: 42px auto calc(var(--hpx) * var(--hours)); min-width: 718px; position: relative; }
.wk-corner { position: sticky; top: 0; left: 0; z-index: 5; background: var(--bg0); border-bottom: 1px solid var(--line); }
.wk-dh { position: sticky; top: 0; z-index: 4; background: var(--bg0); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: center; gap: 5px; font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.wk-dh .wk-dd { display: inline-flex; align-items: center; justify-content: center; min-width: 25px; height: 25px; border-radius: 999px; font-size: 14px; color: var(--text); padding: 0 3px; }
.wk-dh.today .wk-dn { color: var(--acc2); }
.wk-dh.today .wk-dd { background: var(--acc-grad); color: #fff; font-weight: 700; }
.wk-adl { position: sticky; top: 42px; left: 0; z-index: 5; background: var(--bg0); font-size: 10px; color: var(--muted); padding: 4px 5px; border-bottom: 1px solid var(--line2); text-align: right; }
.wk-adc { position: sticky; top: 42px; z-index: 4; background: var(--bg0); border-left: 1px solid var(--line2); border-bottom: 1px solid var(--line2); padding: 2px; display: flex; flex-direction: column; gap: 1px; min-height: 23px; }
.wk-adc .mchip { height: 17px; line-height: 17px; }
.wk-hours { position: sticky; left: 0; z-index: 3; background: var(--bg0); border-right: 1px solid var(--line2); }
.wk-hl { position: absolute; right: 6px; transform: translateY(-50%); font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.wk-hl:first-child { transform: translateY(2px); }
.wk-col { position: relative; border-left: 1px solid var(--line2); background-image: repeating-linear-gradient(to bottom, var(--line2) 0, var(--line2) 1px, transparent 1px, transparent var(--hpx)); background-position: 0 -1px; }
.wk-col.today { background-color: rgba(63,140,255,.045); }
.wk-ev {
  position: absolute; border-radius: 7px; padding: 3px 5px 3px 7px; overflow: hidden; cursor: pointer; z-index: 1;
  background: color-mix(in srgb, var(--c) 24%, var(--bg1)); border-left: 3px solid var(--c); color: var(--text); box-shadow: var(--sh1);
  display: flex; flex-direction: column; gap: 0; line-height: 1.25;
}
@supports not (background: color-mix(in srgb, red 20%, blue)) { .wk-ev { background: var(--bg2); } }
.wk-ev:active { filter: brightness(1.15); }
.wk-ev.off { opacity: .45; }
.wk-ev.ct { border-top: 2px dashed var(--c); border-top-left-radius: 0; }
.wk-ev.cb { border-bottom: 2px dashed var(--c); }
.wk-et { font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 3px; min-width: 0; }
.wk-et span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-etime { font-size: 10.5px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wk-ev.tiny { padding-top: 1px; padding-bottom: 1px; }
.wk-ev.tiny .wk-etime { display: none; }
.wk-ev.tiny .wk-et { font-size: 11.5px; }
.wk-ev.rem .wk-et .ic { color: var(--warn); }
.wk-now { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--danger); z-index: 2; pointer-events: none; }
.wk-now::before { content: ""; position: absolute; left: -5px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.wk-nowdot { position: absolute; right: 0; width: 5px; height: 2px; background: var(--danger); transform: translateY(-1px); }

/* Agenda */
.ag { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 4px 10px calc(88px + var(--sab)); width: 100%; max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; }
.ag-day { margin: 0 0 8px; }
.ag-dh {
  position: sticky; top: 0; z-index: 2; background: var(--bg0); font-size: 12px; font-weight: 700; color: var(--muted);
  padding: 12px 8px 6px; text-transform: uppercase; letter-spacing: .6px;
}
.ag-day.today .ag-dh { color: var(--acc2); }
.ag-empty { font-size: 13px; color: var(--muted); padding: 6px 10px 8px; }
.ag-row { display: flex; align-items: stretch; gap: 10px; padding: 9px 10px; border-radius: var(--r2); cursor: pointer; min-height: 50px; background: var(--bg1); border: 1px solid var(--line2); margin-top: 5px; transition: background var(--dur1); }
.ag-row:first-of-type { margin-top: 0; }
.ag-row:active { background: var(--bg2); }
.ag-row.off { opacity: .5; }
.ag-time { flex: 0 0 76px; font-size: 13px; color: var(--text); display: flex; flex-direction: column; justify-content: center; gap: 1px; line-height: 1.3; font-variant-numeric: tabular-nums; }
.ag-time .ic { color: var(--warn); }
.ag-time .ag-end, .ag-time .ad { font-size: 11px; color: var(--muted); }
.ag-bar { width: 4px; border-radius: 2px; flex: 0 0 auto; }
.ag-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.ag-title { font-size: 15px; font-weight: 550; overflow-wrap: anywhere; }
.ag-sub { font-size: 12.5px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }

@media (max-width: 559px) { .mo-cell .mchip .ic { display: none; } }
@media (min-width: 560px) { .mchip .mt { display: inline; } .mo-morew { display: inline; } }
@media (min-width: 700px) {
  .msg { max-width: 76%; }
  #msgs { padding: 16px 24px 12px; }
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: 480px; max-width: calc(100vw - 32px); max-height: 85vh; border-radius: var(--r3); border: 1px solid var(--line); padding-bottom: 0; animation: cardin var(--dur2) var(--ease); }
  .sheet::before { display: none; }
  .sh-hdr { padding-top: 10px; }
}

/* ---------- Wide (>=900px): rail + full-width content ---------- */
@media (min-width: 900px) {
  :root { --tabh: 0px; }
  .wide-only { display: inline-flex !important; }
  #tabbar { display: none; }
  #rail { display: flex; flex-direction: column; width: 224px; flex: 0 0 224px; background: var(--bg1); border-right: 1px solid var(--line); padding-bottom: 12px; overflow-y: auto; }
  #hdr { padding-left: 20px; }
  #msgs { padding-left: max(24px, calc((100% - 820px) / 2)); padding-right: max(24px, calc((100% - 820px) / 2)); }
  #composer { margin-left: max(12px, calc((100% - 780px) / 2)); margin-right: max(12px, calc((100% - 780px) / 2)); margin-bottom: 14px; }
  .fab { display: none; }
  .vwrap { padding: 16px 24px 32px; }
  .cal-top { padding: 8px 16px 10px; display: flex; align-items: center; gap: 16px; }
  .cal-nav { flex: 1 1 auto; }
  .seg { margin: 0; width: 320px; flex: 0 0 auto; }
  .mo { flex-direction: row; }
  .cal-body.month .mo-grid { padding-bottom: 0; }
  .mo-side { display: flex; flex-direction: column; width: 300px; flex: 0 0 300px; border-left: 1px solid var(--line); overflow-y: auto; padding: 4px 12px 16px; }
  .mo-side .ag-dh { background: none; }
  .mo-cell { padding: 5px 5px 3px; }
  .mchip { font-size: 12px; height: 19px; line-height: 19px; }
  .mo-dn { font-size: 13px; }
  .wk-grid { min-width: 100%; }
  .ag { padding: 8px 24px 32px; }
  .toast { bottom: 40px; }
}
@keyframes cardin { from { transform: translate(-50%, -50%) scale(.97); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

/* ================= SPEC5: Finance / Focus / Goals / Notes / Journal / Health ================= */

/* badge dots (finance bill-soon, focus running) */
.bdot { position: absolute; top: 6px; left: calc(50% + 10px); width: 8px; height: 8px; border-radius: 50%; background: var(--acc); box-shadow: 0 0 0 2px var(--bg1); pointer-events: none; z-index: 2; }
.bdot.warn { background: var(--warn); }
.nav-item .bdot { position: static; margin-left: auto; box-shadow: none; }
.nav-item .nbadge + .bdot, .nav-item .bdot + .nbadge { margin-left: 6px; }

/* More sheet: 2-col grid of icon cards */
.moregrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.more-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 13px 14px 12px; min-height: 84px;
  border-radius: var(--r2); color: var(--text); background: var(--bg2); border: 1px solid var(--line2); position: relative;
  transition: background var(--dur1), transform var(--dur1);
}
.more-card:active { background: var(--bg3); transform: scale(.97); }
.more-card .mcic { width: 36px; height: 36px; border-radius: 12px; background: var(--acc-dim); color: var(--acc2); display: inline-flex; align-items: center; justify-content: center; }
.more-card .mcic .ic { width: 20px; height: 20px; }
.more-card .mclbl { font-size: 14px; font-weight: 650; }
.more-card .bdot { top: 12px; left: auto; right: 12px; box-shadow: none; }

/* generic bits */
.tagchip { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; color: var(--acc2); background: var(--acc-dim); border-radius: 999px; padding: 1px 8px; flex: 0 0 auto; }
.tagchip.auto { color: var(--ok); background: rgba(52,211,153,.12); }
.trendchip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650; border-radius: 999px; padding: 3px 10px; background: var(--chipbg); color: var(--text2); white-space: nowrap; flex: 0 0 auto; }
.trendchip.up { color: var(--ok); background: rgba(52,211,153,.12); }
.trendchip.down { color: var(--danger-text); background: rgba(242,107,94,.12); }
.catdot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.catdot.big { width: 12px; height: 12px; margin: 0 0 0 4px; }
.amt { font-weight: 650; font-size: 14.5px; white-space: nowrap; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.amt.neg { color: var(--danger-text); }
.amt.pos { color: var(--ok); }
.amt.bill { color: var(--text); margin-right: 8px; }
.pbar { height: 6px; border-radius: 3px; background: var(--bg3); overflow: hidden; margin-top: 8px; }
.pbar i { display: block; height: 100%; border-radius: 3px; background: var(--ok); transition: width var(--dur2) var(--ease); }
.pbar.warn i { background: var(--warn); }
.pbar.over i { background: var(--danger); }

/* Finance */
.fincards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 2px 0 10px; flex: 0 0 auto; }
.fincard { background: var(--bg1); border: 1px solid var(--line2); border-radius: var(--r2); padding: 10px 12px 11px; min-width: 0; }
.fclbl { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fcval { font-size: 18px; font-weight: 700; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.fcval.pos { color: var(--ok); }
.fcval.neg { color: var(--danger-text); }
.finquick { display: flex; flex-direction: column; gap: 8px; margin: 0 0 12px; padding: 10px; background: var(--bg1); border: 1px solid var(--line2); border-radius: var(--r2); flex: 0 0 auto; }
.finquick .padd { margin: 0; }
.finquick .padd input { background: var(--bg0); }
.fq-cats { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 2px; }
.fq-cats::-webkit-scrollbar { display: none; }
.catchip { flex: 0 0 auto; padding: 6px 13px; border-radius: 999px; background: var(--bg0); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--text2); transition: background var(--dur1), color var(--dur1), border-color var(--dur1); }
.catchip.on { background: var(--acc-dim); border-color: rgba(63,140,255,.45); color: var(--acc2); }
.catchip:active { transform: scale(.96); }
.brow { padding-top: 12px; padding-bottom: 13px; }
.bhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.bname { display: inline-flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bname .ic { color: var(--muted); }
.bnum { font-size: 12px; color: var(--text2); white-space: nowrap; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.bnum.over { color: var(--danger-text); font-weight: 650; }
.txrow { padding-left: 12px; }

/* Focus */
.focuswrap { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 10px 0 6px; flex: 0 0 auto; }
.ringwrap { position: relative; width: 224px; height: 224px; }
.ringwrap svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.ring-bg { fill: none; stroke: var(--bg3); stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--acc); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .45s linear; }
.ringwrap.live .ring-fg { filter: drop-shadow(0 0 6px rgba(63,140,255,.55)); }
.ringmid { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 0 30px; text-align: center; }
.ringtime { font-size: 46px; font-weight: 700; letter-spacing: .5px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.ringlbl { font-size: 13px; color: var(--text2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.focusstats { font-size: 13px; color: var(--text2); }
.presets { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; }
.preset { padding: 0 16px; height: 38px; border-radius: 999px; background: var(--bg1); border: 1px solid var(--line); font-size: 14px; font-weight: 600; color: var(--text2); transition: background var(--dur1), color var(--dur1), border-color var(--dur1); }
.preset.on { background: var(--acc-dim); border-color: rgba(63,140,255,.45); color: var(--acc2); }
.preset:active { transform: scale(.96); }
.fcustom { width: 86px; height: 38px; font: inherit; font-size: 14px; text-align: center; color: var(--text); background: var(--bg1); border: 1px solid var(--line); border-radius: 999px; padding: 0 10px; }
.fcustom:focus { border-color: var(--acc); outline: none; }
.focusform { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 340px; }
.focusform input[type=text] { width: 100%; min-height: 44px; font: inherit; font-size: 15px; color: var(--text); background: var(--bg1); border: 1px solid var(--line); border-radius: var(--r1); padding: 8px 14px; }
.focusform input[type=text]:focus { border-color: var(--acc); outline: none; }
.tbtn.big { height: 46px; font-size: 15px; justify-content: center; }
.focusstop { min-width: 160px; justify-content: center; height: 44px; }
.fmark { width: 30px; height: 30px; border-radius: 50%; background: var(--bg3); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; margin-left: 4px; }
.fmark.ok { background: rgba(52,211,153,.15); color: var(--ok); }
.frow2 { min-height: 52px; }

/* Goals */
.goal .rmain { padding: 2px 4px 2px 2px; }
.goalbar.full i { background: var(--acc); }
.goal.gdone { opacity: .6; }
.goal.gdone .goalbar i { background: var(--ok); }
.msteps { margin-top: 10px; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line2); padding-top: 8px; }
.mstep { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-radius: var(--r1); text-align: left; min-height: 42px; transition: background var(--dur1); }
.mstep:active { background: var(--bg2); }
.mcirc { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--muted); background: none; color: transparent; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; position: relative; transition: background var(--dur1), border-color var(--dur1); }
.mcirc::before { content: ""; position: absolute; inset: -8px; }
.mcirc .ic { width: 14px; height: 14px; stroke-width: 3; }
.mcirc.on { background: var(--ok); border-color: var(--ok); color: #052e16; }
.mstep .mtext { font-size: 14.5px; min-width: 0; overflow-wrap: anywhere; }
.mstep .mtext.done { color: var(--muted); text-decoration: line-through; }
.stepadd { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.stepadd input { flex: 1 1 auto; min-width: 0; height: 40px; font: inherit; font-size: 14px; color: var(--text); background: var(--bg0); border: 1px solid var(--line); border-radius: 20px; padding: 0 14px; }
.stepadd input:focus { border-color: var(--acc); outline: none; }
.stepadd .add { width: 38px; height: 38px; color: var(--acc2); background: var(--acc-dim); border-radius: 50%; }
.stepadd .add .ic { width: 18px; height: 18px; stroke-width: 2.2; }

/* Notes */
.nsearch { gap: 8px; }
.searchwrap { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; height: 40px; background: var(--bg1); border: 1px solid var(--line); border-radius: 20px; padding: 0 8px 0 12px; transition: border-color var(--dur1); }
.searchwrap:focus-within { border-color: rgba(63,140,255,.5); }
.searchwrap .ic { color: var(--muted); width: 18px; height: 18px; }
.searchwrap input { flex: 1 1 auto; min-width: 0; border: 0; background: none; color: var(--text); font: inherit; font-size: 15px; height: 100%; }
.searchwrap input:focus { outline: none; }
.searchwrap input::placeholder { color: var(--muted); }
.nrow { padding-top: 11px; padding-bottom: 11px; }
.npre { font-size: 13px; color: var(--text2); line-height: 1.4; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.ntags { gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.ntags .nago { color: var(--muted); font-size: 11.5px; margin-left: auto; flex: 0 0 auto; }
.noteed textarea { min-height: 160px; }
.noteed > input[type=text] { font-weight: 650; }
.autosave { margin: 0; padding: 0; align-self: center; margin-right: auto; font-size: 12px; color: var(--muted); }
.facts .autosave { margin-right: auto; }

/* Journal */
.jcard { background: var(--bg1); border: 1px solid var(--line2); border-radius: var(--r2); padding: 14px; display: flex; flex-direction: column; gap: 12px; flex: 0 0 auto; margin-bottom: 6px; }
.jdate { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.moods { display: flex; gap: 6px; justify-content: space-between; max-width: 330px; }
.mood { width: 50px; height: 50px; border-radius: 50%; background: var(--bg2); border: 1.5px solid var(--line); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; transition: background var(--dur1), color var(--dur1), border-color var(--dur1), transform var(--dur1); }
.mood .ic { width: 30px; height: 30px; stroke-width: 1.7; }
.mood:active { transform: scale(.92); }
.mood.on { color: var(--m, var(--acc2)); border-color: var(--m, var(--acc)); background: var(--bg0); box-shadow: 0 0 0 3px color-mix(in srgb, var(--m, var(--acc)) 18%, transparent); }
@supports not (background: color-mix(in srgb, red 20%, blue)) { .mood.on { box-shadow: 0 0 0 3px rgba(63,140,255,.2); } }
.jta { width: 100%; min-height: 74px; resize: vertical; font: inherit; font-size: 15px; line-height: 1.45; color: var(--text); background: var(--bg0); border: 1px solid var(--line); border-radius: var(--r1); padding: 10px 12px; }
.jta:focus { border-color: var(--acc); outline: none; }
.jcard .facts { margin: 0; }
.mooddot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; margin: 4px 2px 0 6px; align-self: flex-start; }
.mooddot.none { background: var(--bg3); border: 1px solid var(--line); }
.jrow { align-items: flex-start; padding-top: 11px; padding-bottom: 12px; }
.jdate2 { margin-top: 0; }
.jtext { font-size: 14px; line-height: 1.45; margin-top: 4px; overflow-wrap: anywhere; white-space: pre-wrap; }

/* Health */
.hq { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 2px 0 10px; flex: 0 0 auto; }
.hqb { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 12px 4px 10px; background: var(--bg1); border: 1px solid var(--line2); border-radius: var(--r2); color: var(--text2); font-size: 12px; font-weight: 600; transition: background var(--dur1), transform var(--dur1); }
.hqb:active { background: var(--bg2); transform: scale(.96); }
.hqic { width: 34px; height: 34px; border-radius: 11px; background: var(--acc-dim); color: var(--acc2); display: inline-flex; align-items: center; justify-content: center; pointer-events: none; }
.hqic .ic { width: 19px; height: 19px; }
.hqb span { pointer-events: none; }
.hcard { background: var(--bg1); border: 1px solid var(--line2); border-radius: var(--r2); padding: 12px 14px; margin: 0 0 8px; flex: 0 0 auto; }
.hcard .rsub { margin-top: 4px; }
.wnum { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.wnum b { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.spark { width: 100%; height: 52px; margin-top: 8px; display: block; }
.spark-line { fill: none; stroke: var(--acc); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark-fill { fill: rgba(63,140,255,.12); stroke: none; }
.spark-dot { fill: var(--acc); stroke: var(--bg1); stroke-width: 2; }
.medrow { display: flex; flex-direction: column; gap: 7px; padding: 10px 0 4px; }
.medrow + .medrow { border-top: 1px solid var(--line2); }
.medname { font-size: 14.5px; font-weight: 600; }
.medtimes { display: flex; gap: 8px; flex-wrap: wrap; }
.mt-slot { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px 5px 6px; border-radius: 999px; background: var(--bg0); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--text2); transition: border-color var(--dur1), background var(--dur1); }
.mt-slot .mcirc { width: 21px; height: 21px; border-width: 2px; }
.mt-slot .mcirc .ic { width: 12px; height: 12px; }
.mt-slot.on { border-color: rgba(52,211,153,.4); color: var(--text); }
.mt-slot:active { background: var(--bg2); }
.hlic { width: 32px; height: 32px; border-radius: 10px; background: var(--bg2); color: var(--text2); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; margin-left: 4px; }
.hlic.t-weight { color: var(--acc2); background: var(--acc-dim); }
.hlic.t-water { color: #22d3ee; background: rgba(34,211,238,.12); }
.hlic.t-sleep { color: #c084fc; background: rgba(192,132,252,.12); }
.hlic.t-meal { color: var(--warn); background: rgba(245,166,35,.1); }
.hlic.t-med { color: var(--ok); background: rgba(52,211,153,.12); }
.hlrow { min-height: 52px; }

@media (max-width: 379px) { .ringwrap { width: 200px; height: 200px; } .ringtime { font-size: 40px; } }
@media (min-width: 900px) {
  .fincards { gap: 10px; }
  .fcval { font-size: 21px; }
  .focuswrap { padding-top: 24px; gap: 16px; }
  .ringwrap { width: 260px; height: 260px; }
  .moregrid { grid-template-columns: 1fr 1fr 1fr 1fr; }
}

/* ---------- lock screen (password login) ---------- */
.lock { position: fixed; inset: 0; z-index: 300; background: var(--bg0); display: flex; align-items: center; justify-content: center; padding: 24px calc(16px + var(--sal)) calc(24px + var(--sab)) calc(16px + var(--sar)); }
.lock-card { width: 100%; max-width: 340px; background: var(--bg1); border: 1px solid var(--line); border-radius: var(--r3); padding: 30px 24px 24px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--sh2); }
.lock-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 21px; font-weight: 700; letter-spacing: .2px; margin-bottom: 4px; }
.lock-card input { width: 100%; min-height: 46px; font: inherit; font-size: 16px; color: var(--text); background: var(--bg0); border: 1px solid var(--line); border-radius: var(--r1); padding: 8px 14px; color-scheme: dark; transition: border-color var(--dur1); }
.lock-card input:focus { outline: none; border-color: var(--acc); }
.lock-card .tbtn.primary { justify-content: center; height: 44px; font-size: 14.5px; }
.lock-err { min-height: 17px; font-size: 13px; text-align: center; color: var(--danger-text); }
.lock-card.shake { animation: lockshake .4s var(--ease); }
@keyframes lockshake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-9px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
.frow .tbtn { flex: 0 0 auto; min-height: 44px; }
