/* ==========================================================================
   Personal agent: design tokens
   Reusable tokens (for page stylesheets): --s-1..--s-8 spacing (8px grid),
   --fs-xs..--fs-xl type scale, --shadow-xs/-sm/-md/-lg elevation, --ring focus
   ring, --ok/--ok-soft/--danger-soft/--warn-soft semantic tints,
   --dur/--ease motion, --surface-2 (recessed surface), --line-strong.
   ========================================================================== */
:root {
  --bg: #f6f8fd;
  --panel: #ffffff;
  --surface-2: #f1f5fc;
  --text: #0a1f44;
  --muted: #566787;
  --line: #dde6f5;
  --line-strong: #c3d1ec;
  --accent: #1f5eff;
  --accent-hover: #1749d1;
  --accent-text: #ffffff;
  --accent-soft: #e6eeff;
  --side: #0f2f8f;
  --side-text: #e8efff;
  --side-muted: #a3b8f4;
  --side-hover: rgba(255, 255, 255, 0.1);
  --danger: #c4311f;
  --danger-soft: #fdeceb;
  --warn: #8f5a00;
  --warn-soft: #fff3dc;
  --ok: #17724a;
  --ok-soft: #e2f5ec;
  --chip: #e8effc;
  --shadow-xs: 0 1px 1px rgba(15, 47, 143, 0.05);
  --shadow-sm: 0 1px 2px rgba(15, 47, 143, 0.06), 0 1px 1px rgba(15, 47, 143, 0.04);
  --shadow-md: 0 2px 4px rgba(15, 47, 143, 0.05), 0 8px 20px rgba(15, 47, 143, 0.07);
  --shadow-lg: 0 8px 16px rgba(10, 31, 68, 0.1), 0 24px 56px rgba(10, 31, 68, 0.22);
  --shadow: var(--shadow-sm);
  --ring: 0 0 0 3px rgba(31, 94, 255, 0.28);
  --radius: 12px;
  --radius-sm: 8px;
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-md: 0.9375rem;
  --fs-lg: 1.0625rem;
  --fs-xl: 1.5rem;
  --dur: 140ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --nav-w: 232px;
  --drawer-w: 390px;
  --font: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #070f20;
    --panel: #0e1b36;
    --surface-2: #0a1630;
    --text: #e6edff;
    --muted: #93a5cc;
    --line: #1f3260;
    --line-strong: #2d437a;
    --accent: #5b94ff;
    --accent-hover: #7aa8ff;
    --accent-text: #06132e;
    --accent-soft: #162a55;
    --side: #0a1634;
    --side-text: #e6edff;
    --side-muted: #8aa0d1;
    --side-hover: rgba(255, 255, 255, 0.07);
    --danger: #ff8f80;
    --danger-soft: #3a1a1c;
    --warn: #e7b84a;
    --warn-soft: #36290e;
    --ok: #5ed39b;
    --ok-soft: #123626;
    --chip: #172a52;
    --shadow-xs: none;
    --shadow-sm: 0 1px 0 rgba(255, 255, 255, 0.02);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6);
    --ring: 0 0 0 3px rgba(91, 148, 255, 0.35);
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: var(--fs-md)/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { margin: 0 0 var(--s-2); line-height: 1.25; letter-spacing: -0.015em; font-weight: 650; }
h1 { font-size: var(--fs-xl); letter-spacing: -0.022em; }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p { margin: 0 0 var(--s-3); }
a { color: var(--accent); text-underline-offset: 2px; }
code { background: var(--chip); padding: 0.1em 0.4em; border-radius: 5px; font-size: 0.88em; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; font-size: var(--fs-sm); }
.small { font-size: var(--fs-sm); }
[hidden] { display: none !important; }

.skip-link {
  position: fixed; left: var(--s-3); top: var(--s-3); z-index: 100;
  background: var(--accent); color: var(--accent-text); padding: var(--s-2) var(--s-3);
  border-radius: var(--radius-sm); text-decoration: none; font-weight: 600;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* ---------- buttons & inputs ---------- */
button, input, select, textarea {
  font: inherit;
  font-size: var(--fs-md);
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  min-height: 2.25rem;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
input, select, textarea { box-shadow: var(--shadow-xs); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }
input:hover, select:hover, textarea:hover { border-color: var(--side-muted); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
select { padding-right: 0.5rem; }
textarea { width: 100%; min-height: 4.5rem; resize: vertical; line-height: 1.5; }
input[type="checkbox"], input[type="radio"] { min-height: 0; accent-color: var(--accent); }

button { cursor: pointer; font-weight: 550; box-shadow: var(--shadow-xs); }
button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
button:active:not(:disabled) { transform: translateY(1px); }
button.primary, a.button.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
button.primary:hover, a.button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
button.danger { color: var(--danger); }
button.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
button.small { min-height: 1.875rem; padding: 0.15rem 0.65rem; font-size: var(--fs-sm); }
button:disabled { opacity: 0.5; cursor: default; box-shadow: none; }
button:disabled:hover { border-color: var(--line-strong); color: inherit; background: var(--panel); }
button.primary:disabled:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.icon { padding: 0.3rem 0.7rem; }
button.ghost { background: transparent; border-color: transparent; box-shadow: none; }
button.ghost:hover { background: var(--accent-soft); border-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:focus-visible, a.button:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--accent); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

.button {
  display: inline-block; text-align: center; text-decoration: none; font-weight: 550;
  padding: 0.55rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

/* ---------- login: the one bold surface, with the sidebar ---------- */
.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: var(--s-3);
  padding: var(--s-4);
  background:
    radial-gradient(60rem 30rem at 15% -10%, rgba(91, 148, 255, 0.35), transparent 60%),
    radial-gradient(40rem 30rem at 110% 110%, rgba(31, 94, 255, 0.35), transparent 60%),
    var(--side);
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-5);
  box-shadow: var(--shadow-md);
}
.login .card { width: min(25rem, 100%); display: grid; gap: var(--s-3); border-color: transparent; box-shadow: var(--shadow-lg); }
.login h1 { font-size: 1.375rem; margin: 0; }
.login h2 { font-size: var(--fs-md); margin: 0; }
.login .card p { margin: 0; }
.login .login-sub { margin-top: calc(var(--s-1) * -2); }
.login h1::before {
  content: "";
  display: block;
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: var(--s-4);
  border-radius: 10px;
  background: var(--accent) url("/favicon.svg") center / 1.5rem no-repeat;
  box-shadow: 0 4px 12px rgba(31, 94, 255, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.login .button { padding: 0.65rem 1rem; font-weight: 600; }
.login .card:not(.login-head) { gap: var(--s-2); }
.login label { font-size: var(--fs-sm); font-weight: 550; color: var(--muted); margin-top: var(--s-1); }
.login button.primary { margin-top: var(--s-2); min-height: 2.5rem; }
.login #login-error:empty { display: none; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: 100%; }
.shell.with-drawer { grid-template-columns: var(--nav-w) minmax(0, 1fr) var(--drawer-w); }
.topbar {
  display: none;
  grid-column: 1 / -1;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  background: var(--side);
  color: var(--side-text);
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
}
.topbar strong { flex: 1; font-size: var(--fs-md); letter-spacing: -0.01em; }
.topbar button { background: transparent; color: var(--side-text); border-color: rgba(255, 255, 255, 0.25); box-shadow: none; min-height: 2.25rem; }
.topbar button:hover { background: var(--side-hover); border-color: rgba(255, 255, 255, 0.45); color: #fff; }
.topbar .muted { color: var(--side-muted); font-size: var(--fs-xs); }

/* The sidebar is the one saturated surface; everything else stays white. */
.nav {
  background: var(--side);
  padding: var(--s-4) var(--s-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}
.nav::before {
  content: "Personal agent";
  display: block;
  padding: 6px var(--s-3) var(--s-4) calc(var(--s-3) + 32px);
  margin-bottom: var(--s-2);
  position: relative;
  color: #fff;
  font-weight: 700;
  font-size: var(--fs-md);
  letter-spacing: -0.01em;
  line-height: 24px;
  background: url("/favicon.svg") left var(--s-3) top 6px / 24px 24px no-repeat;
}
.nav a {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  color: var(--side-text);
  text-decoration: none;
  padding: 7px var(--s-3);
  border-radius: var(--radius-sm);
  font-size: var(--fs-md);
  font-weight: 500;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav a:hover { background: var(--side-hover); }
.nav a:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--side), 0 0 0 4px #fff; }
.nav .nav-icon { width: 18px; height: 18px; flex: none; color: var(--side-muted); transition: color var(--dur) var(--ease); }
.nav a:hover .nav-icon { color: var(--side-text); }
.nav a[aria-current="page"] { background: #fff; color: var(--side); font-weight: 650; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }
.nav a[aria-current="page"] .nav-icon { color: var(--accent); }
@media (prefers-color-scheme: dark) {
  .nav a[aria-current="page"] { background: var(--accent-soft); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
  .nav a[aria-current="page"] .nav-icon { color: var(--accent); }
}
.nav .sep { height: 1px; background: rgba(255, 255, 255, 0.14); margin: var(--s-3) var(--s-2); }
.nav .sep { margin-top: auto; }
.main { padding: var(--s-6) var(--s-6) var(--s-8); min-width: 0; max-width: 78rem; width: 100%; }
.main:focus { outline: none; }
.main > h1 { margin-bottom: var(--s-5); }
.drawer {
  background: var(--panel);
  border-left: 1px solid var(--line);
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ---------- primitives ---------- */
.section { margin-bottom: var(--s-6); }
.section > h2 { margin-bottom: var(--s-3); font-size: var(--fs-lg); }
.row { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.row.spread { justify-content: space-between; }
.grow { flex: 1 1 12rem; min-width: 0; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-3) var(--s-4);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  align-items: center;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.item:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.item .title { flex: 1 1 14rem; min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.item.closed .title { text-decoration: line-through; color: var(--muted); }
.chip { display: inline-flex; align-items: center; background: var(--chip); color: var(--accent); border-radius: 999px; padding: 1px 10px; font-size: var(--fs-xs); font-weight: 600; line-height: 1.6; white-space: nowrap; }
.chip.warn { color: var(--warn); background: var(--warn-soft); }
.chip.danger { color: var(--danger); background: var(--danger-soft); }
.chip.ok { color: var(--ok); background: var(--ok-soft); }
.badge { display: inline-flex; font-size: var(--fs-xs); color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; line-height: 1.6; background: var(--surface-2); }
.empty { color: var(--muted); padding: var(--s-5) var(--s-4); text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface-2); font-size: var(--fs-sm); }
.tree { list-style: none; margin: var(--s-1) 0 0 var(--s-4); padding: 0; display: grid; gap: var(--s-2); }
details > summary { cursor: pointer; padding: var(--s-1) 0; border-radius: 4px; }
details > summary:hover { color: var(--accent); }
.goal-tasks { margin: var(--s-1) 0 0 var(--s-4); padding: 0; list-style: none; }

.stack { display: grid; gap: var(--s-4); max-width: 36rem; }
.connection { display: grid; gap: var(--s-2); }
.connection h2 { margin: 0; }
.connection p { margin: 0; overflow-wrap: anywhere; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow-sm); }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); }
th, td { text-align: left; padding: 10px var(--s-3); border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background-color var(--dur) var(--ease); }
tbody tr:hover td { background: var(--accent-soft); }
th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
  font-size: var(--fs-xs);
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
th:hover { color: var(--accent); }
td.cell { max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.cell.editable:hover { outline: 1px dashed var(--accent); outline-offset: -2px; cursor: text; }
td.null { color: var(--muted); }
tr.deleted td { opacity: 0.55; text-decoration: line-through; }
td.actions { white-space: nowrap; }
.pager { display: flex; gap: var(--s-2); align-items: center; margin-top: var(--s-3); flex-wrap: wrap; }
.tabs { display: flex; gap: var(--s-2); flex-wrap: wrap; margin-bottom: var(--s-4); }

/* skeleton / loading primitive: <div class="skeleton"> (height via the page's own class) */
.skeleton { display: block; min-height: 1rem; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--chip) 25%, var(--surface-2) 50%, var(--chip) 75%); background-size: 200% 100%; animation: shell-shimmer 1.4s linear infinite; }
@keyframes shell-shimmer { to { background-position: -200% 0; } }

/* ---------- dialog ---------- */
.dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  padding: var(--s-5);
  width: min(34rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.dialog[open] { animation: shell-pop 160ms var(--ease); }
.dialog::backdrop { background: rgba(8, 18, 38, 0.5); backdrop-filter: blur(2px); }
.dialog[open]::backdrop { animation: shell-fade 160ms var(--ease); }
.dialog h2 { margin-bottom: var(--s-4); }
.dialog-message { margin: 0 0 var(--s-5); font-size: var(--fs-md); }
.dialog-actions { margin-top: var(--s-2); }
.dialog .dialog-actions { flex-direction: row-reverse; justify-content: flex-start; }
@keyframes shell-pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes shell-fade { from { opacity: 0; } }
.form { display: grid; gap: var(--s-4); }
.field { display: grid; gap: 6px; }
.field label { font-size: var(--fs-sm); color: var(--muted); font-weight: 550; }
.field .hint { font-size: var(--fs-xs); color: var(--muted); min-height: 1em; }
.field .hint:empty { display: none; }
.field .hint.bad { color: var(--danger); }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: var(--s-4); left: 50%; transform: translateX(-50%); display: grid; gap: var(--s-2); z-index: 20; width: min(28rem, calc(100vw - 2rem)); pointer-events: none; }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: var(--s-3);
  background: var(--side); color: #fff; border-radius: var(--radius-sm);
  padding: 10px var(--s-4); font-size: var(--fs-sm); font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-lg);
  animation: shell-toast 200ms var(--ease);
}
.toast::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: #6fe3a7; }
.toast.bad { background: #8f1f12; border-color: rgba(255, 255, 255, 0.15); }
.toast.bad::before { background: #ffc2b8; }
@media (prefers-color-scheme: dark) { .toast { background: #17295a; } .toast.bad { background: #7a2418; } }
@keyframes shell-toast { from { opacity: 0; transform: translateY(8px); } }

/* ---------- chat (visual only; owned by the Chat page agent) ---------- */
.chat { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.chat-head { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: var(--s-2); }
.chat-head strong { flex: 1; }
.chat-log { flex: 1; overflow-y: auto; padding: var(--s-4); display: grid; gap: var(--s-2); align-content: start; min-height: 12rem; background: var(--bg); }
.msg { max-width: 92%; padding: var(--s-2) var(--s-3); border-radius: 14px 14px 14px 4px; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--panel); border: 1px solid var(--line); }
.msg.user { justify-self: end; border-radius: 14px 14px 4px 14px; background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.msg time { display: block; font-size: 0.7rem; opacity: 0.7; }
.tools { justify-self: start; font-size: var(--fs-sm); color: var(--muted); max-width: 92%; }
.tools pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0.2rem 0; font-size: 0.78rem; }
.confirm { border: 1px solid var(--warn); border-radius: var(--radius); padding: var(--s-3); display: grid; gap: var(--s-2); background: var(--panel); }
.chat-form { display: flex; gap: var(--s-2); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--line); background: var(--panel); }
.chat-form textarea { flex: 1; min-height: 2.4rem; height: 2.4rem; }
.page-chat { height: calc(100vh - 8rem); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; box-shadow: var(--shadow-sm); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .shell, .shell.with-drawer { grid-template-columns: minmax(0, 1fr); }
  .topbar { display: flex; }
  .nav { position: fixed; z-index: 10; left: 0; top: 0; width: min(17rem, 85vw); transform: translateX(-100%);
    transition: transform 0.18s var(--ease); box-shadow: var(--shadow-lg); visibility: hidden; }
  .nav.open { transform: none; visibility: visible; }
  .drawer { position: fixed; z-index: 9; right: 0; top: 0; width: min(26rem, 100vw); box-shadow: var(--shadow-lg); }
  .main { padding: var(--s-4) var(--s-4) var(--s-8); }
  .main > h1 { margin-bottom: var(--s-4); }
  h1 { font-size: 1.375rem; }
  .item { padding: var(--s-3); }
  .dialog { padding: var(--s-4); }
  .page-chat { height: calc(100vh - 9rem); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---- page: today ---- */
/* Today page. Everything is scoped under .page-today. */
.page-today { max-width: 70rem; display: grid; gap: 1.5rem; }
.page-today .today-icon { flex: none; }

/* Header: the one confident element is the date, set large and tight. */
.page-today .today-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
.page-today .today-hello { margin: 0 0 0.25rem; color: var(--accent); font-weight: 600; font-size: 0.95rem; }
.page-today .today-title { margin: 0; font-size: clamp(1.9rem, 4.5vw, 2.75rem); line-height: 1.05; letter-spacing: -0.03em; font-weight: 700; }
.page-today .today-summary { margin: 0.6rem 0 0; color: var(--muted); font-size: 1rem; max-width: 40rem; }
.page-today .today-quick { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.page-today .today-add { display: inline-flex; align-items: center; gap: 0.4rem; }
.page-today .today-add.primary { box-shadow: 0 1px 2px rgba(15, 47, 143, 0.25); }

.page-today .today-clear { display: flex; align-items: center; gap: 0.65rem; padding: 0.85rem 1rem; border-radius: var(--radius); background: var(--accent-soft); color: var(--text); }
.page-today .today-clear .today-icon { color: var(--accent); width: 20px; height: 20px; }

/* Layout: agenda leads, tasks beside it. */
.page-today .today-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.page-today .today-col { display: grid; gap: 1.5rem; min-width: 0; }

/* Panels are quiet: one border, one shadow level. */
.page-today .today-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1.25rem 1rem; min-width: 0; }
.page-today .today-panelhead { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.page-today .today-panelhead h2 { margin: 0; font-size: 1.05rem; }
.page-today .today-count { min-width: 1.4rem; padding: 0 0.45rem; text-align: center; font-size: 0.78rem; font-weight: 600; line-height: 1.4rem; border-radius: 999px; background: var(--chip); color: var(--muted); }
.page-today .today-foot { margin: 0.9rem 0 0; font-size: 0.8rem; color: var(--muted); }

/* Generic rows */
.page-today .today-list { list-style: none; margin: 0; padding: 0; }
.page-today .today-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 0.5rem; margin: 0 -0.5rem; border-radius: var(--radius-sm); transition: background-color 0.12s; }
.page-today .today-row + .today-row { box-shadow: 0 -1px 0 var(--line); }
.page-today .today-row:hover { background: var(--accent-soft); box-shadow: none; }
.page-today .today-row:hover + .today-row { box-shadow: none; }
.page-today .today-rowmain { flex: 1 1 auto; min-width: 0; display: grid; gap: 0.2rem; }
.page-today .today-rowtitle { overflow-wrap: anywhere; font-weight: 500; }
.page-today .today-row.is-closed .today-rowtitle { text-decoration: line-through; color: var(--muted); }
.page-today .today-meta { display: flex; flex-wrap: wrap; gap: 0.35rem 0.5rem; align-items: center; font-size: 0.82rem; color: var(--muted); }
.page-today .today-meta:empty { display: none; }
.page-today .today-when { color: var(--muted); font-size: 0.82rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.page-today .is-danger { color: var(--danger); }
.page-today .today-time { flex: none; width: 4.25rem; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 0.88rem; color: var(--accent); }

/* Actions appear on hover/focus on pointer devices, always on touch */
.page-today .today-actions { display: flex; gap: 0.25rem; align-items: center; flex: none; }
.page-today .today-actions select.small { min-height: 1.85rem; padding: 0.1rem 0.4rem; font-size: 0.82rem; max-width: 8.5rem; }
.page-today .today-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.page-today .today-ghost:hover { background: var(--panel); border-color: var(--line); color: var(--accent); }
.page-today .today-donebtn { color: var(--accent); }
@media (hover: hover) and (min-width: 861px) {
  .page-today .today-actions { opacity: 0; transition: opacity 0.12s; }
  .page-today .today-row:hover .today-actions, .page-today .today-row:focus-within .today-actions { opacity: 1; }
}

/* Task check circle */
.page-today .today-check { flex: none; width: 1.4rem; height: 1.4rem; min-height: 0; padding: 0; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid var(--side-muted); background: var(--panel); color: transparent; transition: background-color 0.12s, border-color 0.12s, color 0.12s; }
.page-today button.today-check:hover { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.page-today .today-check-on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.page-today .today-check .today-icon { width: 14px; height: 14px; }
.page-today .today-row.is-overdue .today-check { border-color: var(--danger); }
.page-today .today-group + .today-group { margin-top: 1rem; }
.page-today .today-grouptitle { margin: 0 0 0.15rem; font-size: 0.85rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.page-today .today-group.is-danger .today-grouptitle { color: var(--danger); }
.page-today .today-goal .today-rowtitle { font-weight: 450; }

/* Agenda timeline: the rail is the memorable part. */
.page-today .today-timeline { list-style: none; margin: 0; padding: 0; }
.page-today .today-event { position: relative; display: grid; grid-template-columns: 4.25rem minmax(0, 1fr); gap: 0 1.1rem; padding: 0.65rem 0 0.9rem; }
.page-today .today-event::before { content: ""; position: absolute; left: 4.9rem; top: 1.3rem; bottom: -0.3rem; width: 2px; background: var(--line); }
.page-today .today-event:last-child::before { display: none; }
.page-today .today-event::after { content: ""; position: absolute; left: calc(4.9rem - 4px); top: 0.85rem; width: 10px; height: 10px; border-radius: 50%; background: var(--panel); border: 2px solid var(--side-muted); }
.page-today .today-evtime { display: grid; align-content: start; gap: 0.1rem; font-variant-numeric: tabular-nums; }
.page-today .today-evstart { font-weight: 650; font-size: 0.92rem; }
.page-today .today-evend { color: var(--muted); font-size: 0.8rem; }
.page-today .today-evbody { padding-left: 0.9rem; padding-top: 0.05rem; min-width: 0; }
.page-today .today-evtitle { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-weight: 600; overflow-wrap: anywhere; }
.page-today .today-evmeta { display: inline-flex; align-items: center; gap: 0.3rem; }
.page-today .today-evmeta .today-icon { width: 13px; height: 13px; }
.page-today .today-event .today-meta { margin-top: 0.25rem; gap: 0.25rem 0.9rem; }
.page-today .today-event.is-past { opacity: 0.55; }
.page-today .today-event.is-past::after { background: var(--line); border-color: var(--line); }
.page-today .today-event.is-next::after, .page-today .today-event.is-now::after { border-color: var(--accent); }
.page-today .today-event.is-now::after { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.page-today .today-event.is-now .today-evbody, .page-today .today-event.is-next .today-evbody { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 0.55rem 0.8rem; margin-top: -0.2rem; }
.page-today .today-event.is-now .today-evstart, .page-today .today-event.is-next .today-evstart { color: var(--accent); }
.page-today .today-flag { font-size: 0.72rem; font-weight: 650; padding: 0.05rem 0.5rem; border-radius: 999px; background: var(--accent); color: var(--accent-text); }

/* Empty states and notices */
.page-today .today-empty { display: grid; justify-items: start; gap: 0.2rem; padding: 0.75rem 0 0.5rem; }
.page-today .today-emptyicon { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 10px; background: var(--chip); color: var(--accent); margin-bottom: 0.5rem; }
.page-today .today-emptytitle { margin: 0; font-weight: 600; }
.page-today .today-emptyhint { margin: 0 0 0.6rem; color: var(--muted); font-size: 0.9rem; max-width: 26rem; }
.page-today .today-notice { display: grid; gap: 0.15rem; padding: 0.75rem 0.9rem; border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: var(--radius-sm); background: var(--bg); color: var(--muted); font-size: 0.9rem; }
.page-today .today-notice strong { color: var(--text); }

/* Skeleton */
.page-today .today-skeleton { display: grid; gap: 1.5rem; }
.page-today .today-skhead { display: grid; gap: 0.7rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
.page-today .today-sk { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--chip) 25%, var(--accent-soft) 50%, var(--chip) 75%); background-size: 200% 100%; animation: today-shimmer 1.4s linear infinite; }
.page-today .sk-s { width: 7rem; height: 0.9rem; }
.page-today .sk-xl { width: min(20rem, 70%); height: 2.4rem; }
.page-today .sk-m { width: min(26rem, 90%); height: 1rem; }
.page-today .today-skrows { display: grid; gap: 1rem; }
.page-today .today-skrow { display: flex; align-items: center; gap: 0.75rem; }
.page-today .sk-dot { width: 1.4rem; height: 1.4rem; border-radius: 50%; }
.page-today .sk-line { flex: 1; height: 1rem; }
@keyframes today-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .page-today .today-sk { animation: none; } }

@media (max-width: 960px) {
  .page-today .today-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .page-today { gap: 1.25rem; }
  .page-today .today-panel { padding: 1rem 1rem 0.75rem; }
  .page-today .today-quick { width: 100%; }
  .page-today .today-quick .today-add { flex: 1; justify-content: center; }
  .page-today .today-row { flex-wrap: wrap; }
  .page-today .today-rowmain { flex-basis: calc(100% - 3rem); }
  .page-today .today-actions { flex-basis: 100%; flex-wrap: wrap; padding-left: 2.15rem; }
  .page-today .today-reminder .today-actions { padding-left: 0; }
  .page-today .today-event { grid-template-columns: 3.6rem minmax(0, 1fr); gap: 0 0.9rem; }
  .page-today .today-event::before { left: 4.2rem; }
  .page-today .today-event::after { left: calc(4.2rem - 4px); }
}

/* ---- page: tasks ---- */
/* Tasks page. Everything scoped under .page-tasks. */
.page-tasks { max-width: 56rem; }
.page-tasks .tasks-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-tasks h1 { margin: 0; font-size: 1.5rem; letter-spacing: -0.02em; }
.page-tasks .tasks-sub { margin: 2px 0 0; color: var(--muted); font-size: 0.875rem; }
.page-tasks .tasks-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.page-tasks .tasks-segs { display: inline-flex; padding: 2px; gap: 2px; background: var(--chip); border-radius: var(--radius-sm); }
.page-tasks .tasks-seg { border: 0; background: transparent; min-height: 28px; padding: 2px 12px; font-size: 0.8125rem; color: var(--muted); border-radius: 6px; }
.page-tasks .tasks-seg:hover { color: var(--text); border: 0; }
.page-tasks .tasks-seg.is-on { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(15, 47, 143, 0.14); }

/* Quick add: the one bold element, a large focused capture field */
.page-tasks .tasks-quick { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; margin-bottom: 32px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); transition: border-color 0.12s, box-shadow 0.12s; }
.page-tasks .tasks-quick:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.page-tasks .tasks-plus { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; }
.page-tasks .tasks-quick-input { flex: 1; min-width: 0; border: 0; box-shadow: none; background: transparent; font-size: 1rem; min-height: 40px; padding: 0 4px; }
.page-tasks .tasks-quick-input:hover, .page-tasks .tasks-quick-input:focus { border: 0; box-shadow: none; }
.page-tasks .tasks-more { border: 0; background: transparent; color: var(--muted); font-size: 0.8125rem; min-height: 32px; }
.page-tasks .tasks-more:hover { background: var(--chip); color: var(--accent); border: 0; }

.page-tasks .tasks-group { margin-bottom: 24px; }
.page-tasks .tasks-group > summary { display: flex; align-items: center; gap: 8px; padding: 4px 8px; margin: 0 0 4px; cursor: pointer; list-style: none; border-radius: 6px; color: var(--text); }
.page-tasks .tasks-group > summary::-webkit-details-marker { display: none; }
.page-tasks .tasks-group > summary:hover { background: var(--chip); }
.page-tasks .tasks-caret { width: 14px; height: 14px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.12s; }
.page-tasks .tasks-group[open] .tasks-caret { transform: rotate(90deg); }
.page-tasks .tasks-gname { font-weight: 650; font-size: 0.875rem; }
.page-tasks .tasks-count { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; background: var(--chip); border-radius: 999px; padding: 0 8px; }
.page-tasks .tasks-none, .page-tasks .tasks-hidden { color: var(--muted); font-size: 0.8125rem; padding: 8px 12px; }

.page-tasks .tasks-list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.page-tasks .tasks-row { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto auto auto; align-items: center; gap: 12px; padding: 8px 12px; min-height: 48px; border-top: 1px solid var(--line); transition: background-color 0.12s; }
.page-tasks .tasks-row:first-child { border-top: 0; }
.page-tasks .tasks-row:hover, .page-tasks .tasks-row:focus-within { background: var(--accent-soft); }
.page-tasks .tasks-main { min-width: 0; display: grid; gap: 2px; }
.page-tasks .tasks-title { overflow-wrap: anywhere; line-height: 1.35; }
.page-tasks .tasks-row.is-closed .tasks-title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.page-tasks .tasks-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 0.75rem; color: var(--muted); }
.page-tasks .tasks-meta:empty { display: none; }
.page-tasks .tasks-tag { border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; background: var(--panel); }
.page-tasks .tasks-link { color: var(--accent); }

.page-tasks .tasks-check { width: 20px; height: 20px; min-height: 20px; padding: 0; border: 1.5px solid var(--muted); border-radius: 50%; background: transparent; display: grid; place-items: center; transition: background-color 0.12s, border-color 0.12s; }
.page-tasks .tasks-check .tasks-tick { width: 14px; height: 14px; fill: none; stroke: var(--accent-text); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: opacity 0.12s; }
.page-tasks .tasks-check:hover { border-color: var(--accent); background: var(--accent-soft); }
.page-tasks .tasks-check:hover .tasks-tick { stroke: var(--accent); opacity: 1; }
.page-tasks .tasks-check.is-done { background: var(--accent); border-color: var(--accent); }
.page-tasks .tasks-check.is-done .tasks-tick { opacity: 1; stroke: var(--accent-text); }
.page-tasks .tasks-repeat { width: 20px; height: 20px; display: grid; place-items: center; }
.page-tasks .tasks-repeat svg { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

.page-tasks .tasks-due { font-size: 0.75rem; font-weight: 550; padding: 2px 8px; border-radius: 999px; background: var(--chip); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.page-tasks .tasks-due.is-today { background: var(--accent-soft); color: var(--accent); }
.page-tasks .tasks-due.is-overdue { background: transparent; color: var(--danger); border: 1px solid currentColor; padding: 1px 8px; }
.page-tasks .tasks-status { min-height: 28px; font-size: 0.8125rem; padding: 0 8px; color: var(--muted); border-color: transparent; background: transparent; max-width: 9rem; }
.page-tasks .tasks-row:hover .tasks-status, .page-tasks .tasks-status:focus { border-color: var(--line); background: var(--panel); color: var(--text); }
.page-tasks .tasks-edit { min-height: 28px; padding: 0 8px; font-size: 0.8125rem; border-color: transparent; background: transparent; color: var(--muted); opacity: 0; transition: opacity 0.12s; }
.page-tasks .tasks-row:hover .tasks-edit, .page-tasks .tasks-edit:focus-visible { opacity: 1; }
.page-tasks .tasks-edit:hover { background: var(--panel); border-color: var(--line); }

.page-tasks .tasks-empty { text-align: center; padding: 56px 24px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--panel); display: grid; justify-items: center; gap: 8px; }
.page-tasks .tasks-empty h2 { margin: 8px 0 0; }
.page-tasks .tasks-empty p { margin: 0 0 8px; color: var(--muted); max-width: 26rem; }
.page-tasks .tasks-empty-mark { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); display: grid; place-items: center; }
.page-tasks .tasks-empty-mark svg { width: 20px; height: 20px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.page-tasks .tasks-skeleton { display: grid; gap: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.page-tasks .tasks-skel { display: flex; align-items: center; gap: 12px; padding: 14px 12px; border-top: 1px solid var(--line); }
.page-tasks .tasks-skel:first-child { border-top: 0; }
.page-tasks .tasks-skel-dot { width: 20px; height: 20px; border-radius: 50%; background: var(--chip); }
.page-tasks .tasks-skel-bar { height: 10px; border-radius: 4px; background: var(--chip); animation: tasks-pulse 1.2s ease-in-out infinite; }
.page-tasks .tasks-skel-dot { animation: tasks-pulse 1.2s ease-in-out infinite; }
.page-tasks .w-35 { width: 35%; } .page-tasks .w-45 { width: 45%; } .page-tasks .w-55 { width: 55%; } .page-tasks .w-60 { width: 60%; } .page-tasks .w-75 { width: 75%; }
@keyframes tasks-pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .page-tasks .tasks-skel-bar, .page-tasks .tasks-skel-dot { animation: none; } }

@media (max-width: 640px) {
  .page-tasks .tasks-head { align-items: stretch; }
  .page-tasks .tasks-row { grid-template-columns: 20px minmax(0, 1fr) auto; row-gap: 4px; }
  .page-tasks .tasks-due { grid-column: 2; grid-row: 2; justify-self: start; }
  .page-tasks .tasks-status { grid-column: 2; grid-row: 3; justify-self: start; margin-left: -8px; }
  .page-tasks .tasks-edit { grid-column: 3; grid-row: 1; opacity: 1; }
  .page-tasks .tasks-more { display: none; }
}
@media (hover: none) { .page-tasks .tasks-edit { opacity: 1; } }

/* ---- page: goals ---- */
/* Goals page. Everything scoped under .page-goals. */
.page-goals { max-width: 60rem; }
.page-goals .goals-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-goals .goals-top h1 { margin: 0; font-size: 1.75rem; }
.page-goals .goals-sub { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.9rem; }

.page-goals .goals-groups { display: grid; gap: 2rem; }
.page-goals .goals-group-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.6rem; padding: 0 0.25rem; }
.page-goals .goals-group-head h2 { margin: 0; font-size: 1.05rem; text-transform: capitalize; }
.page-goals .goals-group-n { background: var(--chip); color: var(--muted); font-size: 0.75rem; font-weight: 600; border-radius: 999px; padding: 0 0.5rem; line-height: 1.25rem; }

.page-goals ul { list-style: none; margin: 0; padding: 0; }
.page-goals .goals-tree {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.page-goals .goals-tree > .goals-node + .goals-node { border-top: 1px solid var(--line); }

/* Goal row: chevron | title | status | date | progress | edit */
.page-goals .goals-head {
  display: grid;
  grid-template-columns: 1rem minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: 0.75rem;
  padding: 0.75rem 1rem;
  list-style: none;
  cursor: default;
  min-height: 3.25rem;
  transition: background-color 0.12s;
}
.page-goals summary.goals-head { cursor: pointer; }
.page-goals summary.goals-head::-webkit-details-marker { display: none; }
.page-goals .goals-head:hover { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.page-goals .goals-head:focus-visible { outline-offset: -2px; border-radius: var(--radius-sm); }
.page-goals .goals-d0 > details > .goals-head, .page-goals .goals-d0 > .goals-head { padding-block: 0.9rem; }
.page-goals .goals-d0 > details > summary .goals-title, .page-goals .goals-d0 > .goals-head .goals-title { font-weight: 650; font-size: 1rem; }
.page-goals .goals-title { overflow-wrap: anywhere; font-weight: 550; }
.page-goals .goals-spacer { width: 1rem; }
.page-goals .goals-icon { color: var(--muted); transition: transform 0.15s; flex: none; }
.page-goals details[open] > summary .goals-icon-chevron { transform: rotate(90deg); }

.page-goals .goals-date { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.page-goals .goals-date.is-overdue { color: var(--danger); font-weight: 600; }
.page-goals .goals-none { color: var(--muted); opacity: 0.7; font-size: 0.85rem; }

.page-goals .goals-pill {
  justify-self: start;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25rem;
  padding: 0 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
  text-transform: capitalize;
}
.page-goals .goals-active { background: var(--accent-soft); color: var(--accent); }
.page-goals .goals-achieved { background: var(--accent); color: var(--accent-text); }
.page-goals .goals-paused { background: transparent; color: var(--warn); border-color: currentColor; }
.page-goals .goals-dropped { background: transparent; color: var(--muted); border-color: var(--line); }
.page-goals .goals-s-dropped > details > summary .goals-title,
.page-goals .goals-s-dropped > .goals-head .goals-title { color: var(--muted); text-decoration: line-through; }

.page-goals .goals-progress { display: flex; align-items: center; gap: 0.5rem; }
.page-goals .goals-bar {
  appearance: none;
  -webkit-appearance: none;
  flex: 1;
  min-width: 0;
  height: 6px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--chip);
  overflow: hidden;
}
.page-goals .goals-bar::-webkit-progress-bar { background: var(--chip); border-radius: 999px; }
.page-goals .goals-bar::-webkit-progress-value { background: var(--accent); border-radius: 999px; transition: width 0.3s; }
.page-goals .goals-bar::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.page-goals .goals-frac { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; min-width: 2.2rem; text-align: right; }
.page-goals .goals-s-dropped .goals-bar::-webkit-progress-value { background: var(--muted); }
.page-goals .goals-s-dropped .goals-bar::-moz-progress-bar { background: var(--muted); }

.page-goals .goals-edit { opacity: 0; transition: opacity 0.12s, border-color 0.12s, color 0.12s; }
.page-goals .goals-head:hover .goals-edit, .page-goals .goals-edit:focus-visible { opacity: 1; }

/* Nesting: a guide line hangs from the parent's chevron column. */
.page-goals .goals-body { padding: 0 0 0.5rem; }
.page-goals .goals-children { margin-left: 1.5rem; padding-left: 0.5rem; border-left: 1px solid var(--line); }
.page-goals .goals-children > .goals-node > details > .goals-head,
.page-goals .goals-children > .goals-node > .goals-head { min-height: 2.75rem; padding-block: 0.5rem; }
.page-goals .goals-children .goals-title { font-size: 0.95rem; }

.page-goals .goals-tasks { margin: 0 0 0.25rem 2.75rem; padding-right: 1rem; }
.page-goals .goals-children .goals-tasks { margin-left: 2.25rem; }
.page-goals .goals-task { display: flex; align-items: center; gap: 0.6rem; padding: 0.3rem 0; font-size: 0.9rem; }
.page-goals .goals-check {
  flex: none;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  display: inline-grid;
  place-items: center;
  color: var(--accent-text);
}
.page-goals .goals-check .goals-icon { width: 0.75rem; height: 0.75rem; color: inherit; }
.page-goals .goals-task.is-closed .goals-check { background: var(--accent); border-color: var(--accent); }
.page-goals .goals-task-title { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.page-goals .goals-task.is-closed .goals-task-title { color: var(--muted); text-decoration: line-through; }
.page-goals .goals-task-status { color: var(--muted); font-size: 0.78rem; border: 1px solid var(--line); border-radius: 5px; padding: 0 0.4rem; }

/* Empty state */
.page-goals .goals-empty {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 0.5rem;
  padding: 3.5rem 1.5rem;
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.page-goals .goals-empty-mark { width: 2.75rem; height: 2.75rem; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.page-goals .goals-empty-mark .goals-icon { width: 1.4rem; height: 1.4rem; color: inherit; }
.page-goals .goals-empty h2 { margin: 0.5rem 0 0; }
.page-goals .goals-empty p { margin: 0 0 0.75rem; max-width: 26rem; color: var(--muted); }

/* Loading skeleton */
.page-goals .goals-skel-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.page-goals .goals-skel-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.05rem 1rem; }
.page-goals .goals-skel-row + .goals-skel-row { border-top: 1px solid var(--line); }
.page-goals .goals-skel { display: block; height: 0.75rem; border-radius: 999px; background: var(--chip); animation: goals-pulse 1.4s ease-in-out infinite; }
.page-goals .goals-skel-a { width: 40%; }
.page-goals .goals-skel-b { width: 20%; }
@keyframes goals-pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .page-goals .goals-skel { animation: none; } }

.page-goals .goals-meta { display: flex; align-items: center; gap: 0.75rem; }
.page-goals .goals-meta .goals-pill { width: 5rem; text-align: center; }
.page-goals .goals-meta .goals-date { width: 7rem; }
.page-goals .goals-meta .goals-progress { width: 9.5rem; }

/* Narrow screens: title on its own line, meta below. */
@media (max-width: 760px) {
  .page-goals .goals-head {
    grid-template-columns: 1rem minmax(0, 1fr) auto;
    grid-template-areas: "chev title edit" ". meta meta";
    row-gap: 0.4rem;
    padding: 0.7rem 0.75rem;
  }
  .page-goals .goals-head > :nth-child(1) { grid-area: chev; }
  .page-goals .goals-head > .goals-title { grid-area: title; }
  .page-goals .goals-head > .goals-meta { grid-area: meta; flex-wrap: wrap; gap: 0.5rem 0.75rem; }
  .page-goals .goals-head > .goals-edit { grid-area: edit; opacity: 1; }
  .page-goals .goals-meta .goals-pill { width: auto; }
  .page-goals .goals-meta .goals-date { width: auto; }
  .page-goals .goals-meta .goals-progress { width: 8rem; }
  .page-goals .goals-children { margin-left: 0.6rem; padding-left: 0.25rem; }
  .page-goals .goals-tasks { margin-left: 1.9rem; padding-right: 0.5rem; }
  .page-goals .goals-top h1 { font-size: 1.45rem; }
}

/* ---- page: people ---- */
.page-people {
  --pe-av-0: #dbe7ff; --pe-av-0t: #1749d1;
  --pe-av-1: #cfe0ff; --pe-av-1t: #123aa6;
  --pe-av-2: #e1ebfc; --pe-av-2t: #27489a;
  --pe-av-3: #d3e6fb; --pe-av-3t: #0f4f8f;
  --pe-av-4: #dfe2ff; --pe-av-4t: #3a3fb3;
  --pe-av-5: #c8dafc; --pe-av-5t: #0f2f8f;
  max-width: 56rem;
}
@media (prefers-color-scheme: dark) {
  .page-people {
    --pe-av-0: #1d3566; --pe-av-0t: #a9c7ff;
    --pe-av-1: #223d78; --pe-av-1t: #bcd3ff;
    --pe-av-2: #1a2f5c; --pe-av-2t: #9db8f2;
    --pe-av-3: #17375e; --pe-av-3t: #9fcdf5;
    --pe-av-4: #2a2f75; --pe-av-4t: #b9bdff;
    --pe-av-5: #213f80; --pe-av-5t: #c4d8ff;
  }
}
.page-people .people-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-people .people-top h1 { margin: 0; font-size: 1.75rem; }
.page-people .people-count { display: block; margin-top: 4px; font-size: 0.85rem; color: var(--muted); min-height: 1.3em; }
.page-people .people-add { display: inline-flex; align-items: center; gap: 8px; padding: 0 16px; min-height: 40px; box-shadow: 0 1px 2px rgba(15, 47, 143, 0.25); }

.page-people .people-search { position: relative; margin-bottom: 16px; }
.page-people .people-search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; pointer-events: none; }
.page-people .people-search-input { width: 100%; min-height: 44px; padding: 0 16px 0 40px; border-radius: 10px; box-shadow: 0 1px 2px rgba(15, 47, 143, 0.05); }

.page-people .people-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.page-people .people-filters:empty { display: none; }
.page-people .people-filter { min-height: 32px; padding: 0 14px; border-radius: 999px; font-size: 0.85rem; background: var(--panel); color: var(--muted); }
.page-people .people-filter:hover { color: var(--accent); border-color: var(--accent); }
.page-people .people-filter.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.page-people .people-card { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.page-people .people-row { border-bottom: 1px solid var(--line); transition: background-color 0.12s; }
.page-people .people-row:last-child { border-bottom: none; }
.page-people .people-row.open { background: color-mix(in srgb, var(--accent-soft) 35%, var(--panel)); }
.page-people .people-head {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) 120px 148px 16px; align-items: center; gap: 16px;
  width: 100%; min-height: 64px; padding: 12px 20px; border: 0; border-radius: 0; background: transparent; text-align: left; font-weight: 400;
}
.page-people .people-head:hover { background: var(--accent-soft); color: inherit; border-color: transparent; }
.page-people .people-head:focus-visible { outline-offset: -2px; }
.page-people .people-avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 0.85rem; font-weight: 650; letter-spacing: 0.02em; }
.page-people .people-av-0 { background: var(--pe-av-0); color: var(--pe-av-0t); }
.page-people .people-av-1 { background: var(--pe-av-1); color: var(--pe-av-1t); }
.page-people .people-av-2 { background: var(--pe-av-2); color: var(--pe-av-2t); }
.page-people .people-av-3 { background: var(--pe-av-3); color: var(--pe-av-3t); }
.page-people .people-av-4 { background: var(--pe-av-4); color: var(--pe-av-4t); }
.page-people .people-av-5 { background: var(--pe-av-5); color: var(--pe-av-5t); }
.page-people .people-id { display: grid; min-width: 0; gap: 2px; }
.page-people .people-name { font-weight: 600; font-size: 0.95rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-people .people-sub { font-size: 0.85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-people .people-rel { justify-self: start; }
.page-people .people-recent { display: inline-flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.page-people .people-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.page-people .people-fresh { color: var(--text); }
.page-people .people-fresh .people-dot { background: var(--accent); }
.page-people .people-ok .people-dot { background: var(--side-muted); }
.page-people .people-stale { color: var(--warn); }
.page-people .people-stale .people-dot { background: var(--warn); }
.page-people .people-chev { color: var(--muted); display: flex; transition: transform 0.15s; }
.page-people .people-row.open .people-chev { transform: rotate(90deg); color: var(--accent); }

.page-people .people-detail { padding: 4px 20px 20px 76px; display: grid; gap: 16px; }
.page-people .people-fields { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px 24px; }
.page-people .people-field dt { font-size: 0.8rem; color: var(--muted); margin-bottom: 2px; }
.page-people .people-field dd { margin: 0; overflow-wrap: anywhere; }
.page-people .people-field a { color: var(--accent); text-decoration: none; }
.page-people .people-field a:hover { text-decoration: underline; }
.page-people .people-notes { margin: 0; padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); white-space: pre-wrap; overflow-wrap: anywhere; max-width: 60ch; }
.page-people .people-tasks h3 { font-size: 0.85rem; color: var(--muted); font-weight: 600; margin: 0 0 8px; }
.page-people .people-tasks ul { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); }
.page-people .people-tasks li { display: flex; justify-content: space-between; gap: 16px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.page-people .people-tasks li:last-child { border-bottom: none; }
.page-people .people-tasks li.closed span:first-child { text-decoration: line-through; color: var(--muted); }
.page-people .people-tasks p { margin: 0; }
.page-people .people-due { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.page-people .people-due.late { color: var(--danger); }

.page-people .people-empty { text-align: center; padding: 64px 24px; background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); display: grid; justify-items: center; gap: 8px; }
.page-people .people-empty strong { font-size: 1.05rem; }
.page-people .people-empty p { margin: 0 0 8px; max-width: 40ch; }

.page-people .people-skel { display: grid; grid-template-columns: 40px 1fr 120px; gap: 16px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--line); min-height: 64px; }
.page-people .people-skel:last-child { border-bottom: none; }
.page-people .people-skel-av, .page-people .people-skel-line { background: var(--chip); border-radius: 6px; animation: people-pulse 1.4s ease-in-out infinite; }
.page-people .people-skel-av { width: 40px; height: 40px; border-radius: 50%; }
.page-people .people-skel-line { height: 12px; }
.page-people .people-skel-line.short { width: 80px; justify-self: end; }
@keyframes people-pulse { 50% { opacity: 0.45; } }

@media (max-width: 720px) {
  .page-people .people-head { grid-template-columns: 40px minmax(0, 1fr) 16px; gap: 8px 12px; padding: 12px 16px; }
  .page-people .people-avatar { grid-row: 1 / span 3; }
  .page-people .people-id { grid-column: 2; grid-row: 1; }
  .page-people .people-rel { grid-column: 2; grid-row: 2; }
  .page-people .people-rel:empty { display: none; }
  .page-people .people-recent { grid-column: 2; grid-row: 3; }
  .page-people .people-chev { grid-column: 3; grid-row: 1; }
  .page-people .people-detail { padding: 4px 16px 16px; }
  .page-people .people-top h1 { font-size: 1.4rem; }
}
@media (prefers-reduced-motion: reduce) {
  .page-people .people-skel-av, .page-people .people-skel-line { animation: none; }
}

/* ---- page: reminders ---- */
/* Reminders page. Everything scoped under .page-reminders. */
.page-reminders { max-width: 46rem; }
.page-reminders .reminders-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.75rem;
}
.page-reminders .reminders-title h1 { margin: 0; font-size: 1.75rem; letter-spacing: -0.02em; }
.page-reminders .reminders-summary { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.9rem; }
.page-reminders .reminders-summary.has-overdue { color: var(--danger); }
.page-reminders .reminders-tools { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.page-reminders .reminders-toggle { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.875rem; cursor: pointer; }
.page-reminders .reminders-toggle input { min-height: 0; width: 1rem; height: 1rem; padding: 0; accent-color: var(--accent); }
.page-reminders .reminders-add { display: inline-flex; align-items: center; gap: 0.4rem; padding-left: 0.8rem; }

.page-reminders .reminders-group { margin-bottom: 1.75rem; }
.page-reminders .reminders-group-title {
  display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.5rem 0.25rem;
  font-size: 0.8125rem; font-weight: 600; color: var(--muted); letter-spacing: 0;
}
.page-reminders .reminders-group.is-overdue .reminders-group-title { color: var(--danger); }
.page-reminders .reminders-group.is-today .reminders-group-title { color: var(--text); }
.page-reminders .reminders-count { font-weight: 550; font-size: 0.75rem; background: var(--chip); color: var(--muted); border-radius: 999px; padding: 0 0.5rem; }
.page-reminders .reminders-group.is-overdue .reminders-count { background: transparent; border: 1px solid currentColor; }

/* One surface per group, rows divided by hairlines: a notification center, not a card grid. */
.page-reminders .reminders-list {
  list-style: none; margin: 0; padding: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.page-reminders .reminders-item {
  position: relative; display: flex; align-items: center; gap: 0.85rem;
  padding: 0.8rem 1rem; transition: background-color 0.12s;
}
.page-reminders .reminders-item + .reminders-item { border-top: 1px solid var(--line); }
.page-reminders .reminders-item:hover { background: var(--accent-soft); }
.page-reminders .reminders-item.is-overdue::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--danger);
}

.page-reminders .reminders-check {
  flex: none; display: grid; place-items: center; width: 1.5rem; height: 1.5rem; min-height: 0; padding: 0;
  border-radius: 50%; border: 1.5px solid var(--side-muted); background: var(--panel); color: transparent;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s, transform 0.12s;
}
.page-reminders .reminders-check svg { width: 0.8rem; height: 0.8rem; stroke-width: 3; }
.page-reminders button.reminders-check:hover { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.page-reminders button.reminders-check:active { transform: scale(0.92); }
.page-reminders .reminders-check.is-done { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.page-reminders .is-overdue .reminders-check { border-color: var(--danger); }
.page-reminders .is-overdue button.reminders-check:hover { background: var(--danger); border-color: var(--danger); }

.page-reminders .reminders-body { flex: 1 1 auto; min-width: 0; }
.page-reminders .reminders-text { font-weight: 550; overflow-wrap: anywhere; line-height: 1.35; }
.page-reminders .is-closed .reminders-text { color: var(--muted); font-weight: 450; text-decoration: line-through; }
.page-reminders .reminders-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem 0.6rem; margin-top: 0.15rem; font-size: 0.8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.page-reminders .reminders-rel { color: var(--accent); font-weight: 550; }
.page-reminders .is-overdue .reminders-rel { color: var(--danger); }
.page-reminders .reminders-state { border: 1px solid var(--line); border-radius: 999px; padding: 0 0.5rem; font-size: 0.75rem; font-weight: 550; }
.page-reminders .reminders-state.is-snoozed { color: var(--warn); border-color: currentColor; }
.page-reminders .reminders-state.is-fired { color: var(--accent); border-color: currentColor; }
.page-reminders .reminders-task { background: var(--chip); color: var(--accent); border-radius: 999px; padding: 0 0.55rem; font-size: 0.75rem; font-weight: 550; }

.page-reminders .reminders-actions { flex: none; display: flex; gap: 0.25rem; }
.page-reminders .reminders-act {
  min-height: 1.85rem; padding: 0.1rem 0.6rem; font-size: 0.8125rem; font-weight: 550;
  background: transparent; border-color: transparent; color: var(--muted);
}
.page-reminders .reminders-act:hover { background: var(--panel); border-color: var(--line); color: var(--accent); }
@media (hover: hover) {
  .page-reminders .reminders-actions { opacity: 0.6; transition: opacity 0.12s; }
  .page-reminders .reminders-item:hover .reminders-actions,
  .page-reminders .reminders-item:focus-within .reminders-actions { opacity: 1; }
}

.page-reminders .reminders-clear {
  display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1.5rem; padding: 0.7rem 1rem;
  background: var(--accent-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--text); font-size: 0.9rem;
}
.page-reminders .reminders-clear-icon { display: grid; place-items: center; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: var(--accent); color: var(--accent-text); }
.page-reminders .reminders-clear-icon svg { width: 0.8rem; height: 0.8rem; stroke-width: 3; }

.page-reminders .reminders-empty {
  display: grid; justify-items: center; text-align: center; gap: 0.5rem;
  padding: 3.5rem 1.5rem; background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius);
}
.page-reminders .reminders-empty h2 { margin: 0.5rem 0 0; font-size: 1.1rem; }
.page-reminders .reminders-empty p { margin: 0 0 0.75rem; max-width: 24rem; color: var(--muted); }
.page-reminders .reminders-empty-icon { display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 14px; background: var(--accent-soft); color: var(--accent); }
.page-reminders .reminders-empty-icon svg { width: 1.4rem; height: 1.4rem; }

.page-reminders .reminders-skel { pointer-events: none; }
.page-reminders .reminders-skel-dot, .page-reminders .reminders-skel-line { background: var(--chip); animation: reminders-pulse 1.2s ease-in-out infinite; }
.page-reminders .reminders-skel-dot { width: 1.5rem; height: 1.5rem; border-radius: 50%; flex: none; }
.page-reminders .reminders-skel-line { display: block; height: 0.75rem; border-radius: 4px; width: 60%; margin: 0.25rem 0; }
.page-reminders .reminders-skel-line.short { width: 30%; }
@keyframes reminders-pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .page-reminders .reminders-skel-dot, .page-reminders .reminders-skel-line { animation: none; } }

@media (max-width: 600px) {
  .page-reminders .reminders-item { flex-wrap: wrap; padding: 0.75rem 0.85rem; }
  .page-reminders .reminders-body { flex: 1 1 calc(100% - 3rem); }
  .page-reminders .reminders-actions { flex: 1 1 100%; padding-left: 2.35rem; opacity: 1; }
  .page-reminders .reminders-act { border-color: var(--line); background: var(--panel); }
  .page-reminders .reminders-tools { width: 100%; justify-content: space-between; }
}

/* ---- page: preferences ---- */
/* Preferences page. Everything scoped under .page-preferences. */
.page-preferences { max-width: 46rem; display: grid; gap: 1.5rem; }
.page-preferences .preferences-header h1 { font-size: 1.75rem; margin: 0 0 0.35rem; }
.page-preferences .preferences-lead { margin: 0; color: var(--muted); max-width: 38rem; }

/* Composer: the one prominent element. */
.page-preferences .preferences-composer {
  display: flex; gap: 0.5rem; padding: 0.5rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.page-preferences .preferences-composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.page-preferences .preferences-input {
  flex: 1; min-width: 0; border: 0; background: transparent; box-shadow: none;
  min-height: 2.5rem; padding: 0.4rem 0.6rem; font-size: 1rem;
}
.page-preferences .preferences-input:hover,
.page-preferences .preferences-input:focus { border: 0; box-shadow: none; }
.page-preferences .preferences-input::placeholder { color: var(--muted); opacity: 0.85; }
.page-preferences .preferences-add { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 2.5rem; padding: 0.4rem 1rem; }
.page-preferences .preferences-add:active { transform: translateY(1px); }
.page-preferences .preferences-icon { flex: none; }

.page-preferences .preferences-body { display: grid; gap: 1.5rem; }

/* Groups: one bordered panel, rows separated by hairlines. */
.page-preferences .preferences-group {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.page-preferences .preferences-group-head,
.page-preferences .preferences-group > summary {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.15rem 0.6rem;
  padding: 0.85rem 1rem; border-bottom: 1px solid var(--line);
}
.page-preferences .preferences-group > summary { cursor: pointer; list-style: none; border-bottom: 0; transition: background-color 0.12s; }
.page-preferences .preferences-group > summary::-webkit-details-marker { display: none; }
.page-preferences .preferences-group > summary:hover { background: var(--accent-soft); }
.page-preferences .preferences-group > summary::before {
  content: ""; width: 0.45rem; height: 0.45rem; align-self: center;
  border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted);
  transform: rotate(-45deg); transition: transform 0.15s;
}
.page-preferences .preferences-group[open] > summary { border-bottom: 1px solid var(--line); }
.page-preferences .preferences-group[open] > summary::before { transform: rotate(45deg); }
.page-preferences .preferences-group h2 { margin: 0; font-size: 1rem; }
.page-preferences .preferences-count {
  font-size: 0.75rem; font-weight: 600; color: var(--muted); background: var(--chip);
  border-radius: 999px; padding: 0 0.5rem; min-width: 1.4rem; text-align: center;
}
.page-preferences .preferences-hint { flex-basis: 100%; margin: 0; font-size: 0.85rem; color: var(--muted); }
.page-preferences summary .preferences-hint { flex-basis: auto; }

.page-preferences .is-proposed-group { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.page-preferences .is-proposed-group .preferences-group-head { background: var(--accent-soft); border-bottom-color: transparent; }
.page-preferences .is-proposed-group .preferences-count { background: var(--panel); color: var(--accent); }

.page-preferences .preferences-list { gap: 0; }
.page-preferences .preferences-row {
  border: 0; border-radius: 0; box-shadow: none; background: transparent;
  border-top: 1px solid var(--line); padding: 0.8rem 1rem; gap: 0.5rem 1rem; flex-wrap: nowrap; align-items: center;
  transition: background-color 0.12s;
}
.page-preferences .preferences-list > .preferences-row:first-child { border-top: 0; }
.page-preferences .is-proposed-group .preferences-list > .preferences-row:first-child { border-top: 1px solid var(--line); }
.page-preferences .preferences-row:hover { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.page-preferences .preferences-main { flex: 1 1 auto; min-width: 0; display: grid; gap: 0.3rem; }
.page-preferences .preferences-rule { flex: none; font-size: 0.97rem; line-height: 1.4; }
.page-preferences .preferences-row.is-rejected .preferences-rule { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.page-preferences .preferences-origin { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; color: var(--muted); }

.page-preferences .preferences-pill {
  display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.72rem; font-weight: 600;
  border-radius: 999px; padding: 0.05rem 0.55rem 0.05rem 0.45rem; background: var(--chip); color: var(--muted);
}
.page-preferences .preferences-pill::before { content: ""; width: 0.4rem; height: 0.4rem; border-radius: 50%; background: currentColor; }
.page-preferences .preferences-pill.is-active { color: var(--accent); }
.page-preferences .preferences-pill.is-proposed { background: var(--accent); color: var(--accent-text); }
.page-preferences .preferences-pill.is-rejected { background: transparent; border: 1px solid var(--line); }

.page-preferences .preferences-actions { display: flex; align-items: center; gap: 0.35rem; flex: none; }
.page-preferences .preferences-actions button { display: inline-flex; align-items: center; gap: 0.3rem; }
.page-preferences .preferences-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.page-preferences .preferences-quiet:hover { background: var(--chip); border-color: transparent; color: var(--accent); }
.page-preferences .preferences-quiet.danger:hover { color: var(--danger); background: transparent; text-decoration: underline; }
.page-preferences .preferences-row:not(:hover):not(:focus-within) .preferences-quiet { opacity: 0.55; }
.page-preferences .preferences-note { margin: 0; color: var(--muted); }

/* Empty state */
.page-preferences .preferences-empty {
  background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 2rem 1.5rem; display: grid; justify-items: start; gap: 0.5rem;
}
.page-preferences .preferences-empty-mark {
  width: 2.5rem; height: 2.5rem; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); margin-bottom: 0.25rem;
}
.page-preferences .preferences-empty h2 { margin: 0; }
.page-preferences .preferences-empty p { margin: 0; color: var(--muted); max-width: 36rem; }
.page-preferences .preferences-try { margin-top: 0.75rem !important; font-size: 0.85rem; font-weight: 600; color: var(--text) !important; }
.page-preferences .preferences-examples { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.page-preferences .preferences-example { font-weight: 450; border-radius: 999px; text-align: left; }

/* Skeleton */
.page-preferences .preferences-skeleton {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.page-preferences .preferences-skel-row { display: grid; gap: 0.5rem; padding: 1rem; border-top: 1px solid var(--line); }
.page-preferences .preferences-skel-row:first-child { border-top: 0; }
.page-preferences .preferences-skel-bar {
  display: block; height: 0.75rem; border-radius: 6px;
  background: linear-gradient(90deg, var(--chip) 25%, var(--accent-soft) 50%, var(--chip) 75%);
  background-size: 200% 100%; animation: preferences-shimmer 1.4s linear infinite;
}
.page-preferences .preferences-skel-bar.w-lg { width: 70%; height: 0.9rem; }
.page-preferences .preferences-skel-bar.w-sm { width: 30%; }
@keyframes preferences-shimmer { to { background-position: -200% 0; } }

@media (max-width: 640px) {
  .page-preferences { gap: 1.25rem; }
  .page-preferences .preferences-composer { flex-direction: column; }
  .page-preferences .preferences-add { justify-content: center; }
  .page-preferences .preferences-row { flex-wrap: wrap; }
  .page-preferences .preferences-actions { flex: 1 1 100%; flex-wrap: wrap; }
  .page-preferences .preferences-row .preferences-quiet { opacity: 1 !important; }
}
@media (prefers-reduced-motion: reduce) {
  .page-preferences .preferences-skel-bar { animation: none; }
}

/* ---- page: tables ---- */
/* ===== Page: Tables (index + row grid). Everything scoped under .page-tables ===== */
.page-tables {
  --tables-hover: color-mix(in srgb, var(--accent-soft) 55%, var(--panel));
  --tables-row-h: 2.75rem;
  max-width: 100%;
}
.page-tables .tables-icon { width: 1rem; height: 1rem; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Header */
.page-tables .tables-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.75rem 1rem; margin-bottom: 1.25rem; }
.page-tables .tables-titles { min-width: 0; }
.page-tables .tables-head h1 { margin: 0; font-size: 1.6rem; overflow-wrap: anywhere; }
.page-tables .tables-sub { margin: 0.25rem 0 0; max-width: 40rem; }
.page-tables .tables-crumbs { display: flex; align-items: center; gap: 0.25rem; margin-bottom: 0.25rem; font-size: 0.85rem; }
.page-tables .tables-crumbs a { color: var(--muted); text-decoration: none; border-radius: 4px; }
.page-tables .tables-crumbs a:hover { color: var(--accent); }
.page-tables .tables-crumbs .tables-icon { width: 0.8rem; height: 0.8rem; color: var(--muted); }
.page-tables .tables-meta { display: flex; align-items: center; gap: 0.5rem; padding-bottom: 0.2rem; }
.page-tables .tables-protected { display: inline-flex; align-items: center; gap: 0.25rem; color: var(--warn); border-color: currentColor; background: transparent; padding: 0.05rem 0.45rem; }
.page-tables .tables-protected .tables-icon { width: 0.75rem; height: 0.75rem; }
.page-tables .tables-note { margin: 0 0 0.75rem; padding: 0.6rem 0.85rem; border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: var(--radius-sm); background: var(--panel); }

/* Toolbar */
.page-tables .tables-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.page-tables .tables-toolbar[hidden] { display: none; }
.page-tables .tables-search { position: relative; display: block; flex: 1 1 14rem; max-width: 24rem; }
.page-tables .tables-search .tables-icon { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.page-tables .tables-search-input { width: 100%; padding-left: 2.25rem; background: var(--panel); }
.page-tables .tables-toolbar-note { margin-left: auto; }
.page-tables .tables-add { display: inline-flex; align-items: center; gap: 0.4rem; margin-left: auto; padding-left: 0.85rem; padding-right: 1rem; }
.page-tables .tables-add[hidden] { display: none !important; }
.page-tables .tables-switch { display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; user-select: none; color: var(--muted); font-size: 0.9rem; }
.page-tables .tables-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; padding: 0; }
.page-tables .tables-switch-track { position: relative; width: 2rem; height: 1.15rem; border-radius: 999px; background: var(--line); transition: background-color 0.15s; flex: none; }
.page-tables .tables-switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: calc(1.15rem - 4px); height: calc(1.15rem - 4px); border-radius: 50%; background: var(--panel); box-shadow: 0 1px 2px rgba(15, 47, 143, 0.35); transition: transform 0.15s; }
.page-tables .tables-switch input:checked + .tables-switch-track { background: var(--accent); }
.page-tables .tables-switch input:checked + .tables-switch-track::after { transform: translateX(0.85rem); }
.page-tables .tables-switch input:checked ~ span:last-child { color: var(--text); }
.page-tables .tables-switch input:focus-visible + .tables-switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Index */
.page-tables .tables-group { margin-bottom: 1.75rem; }
.page-tables .tables-group-title { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.6rem; font-size: 0.9rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.page-tables .tables-group-n { font-size: 0.75rem; font-weight: 550; color: var(--muted); background: var(--chip); border-radius: 999px; padding: 0 0.5rem; }
.page-tables .tables-list { gap: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.page-tables .tables-entry { display: block; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.page-tables .tables-entry + .tables-entry { border-top: 1px solid var(--line); }
.page-tables .tables-link { display: flex; align-items: center; gap: 0.75rem; padding: 0.85rem 1rem; color: inherit; text-decoration: none; transition: background-color 0.12s; }
.page-tables .tables-link:hover { background: var(--tables-hover); }
.page-tables .tables-link:focus-visible { outline-offset: -2px; }
.page-tables .tables-entry-main { flex: 1 1 auto; min-width: 0; display: grid; gap: 0.1rem; }
.page-tables .tables-entry-name { display: inline-flex; align-items: center; gap: 0.45rem; font-weight: 600; overflow-wrap: anywhere; }
.page-tables .tables-entry-name .tables-icon { color: var(--warn); width: 0.85rem; height: 0.85rem; }
.page-tables .tables-link:hover .tables-entry-name { color: var(--accent); }
.page-tables .tables-entry-reason { overflow-wrap: anywhere; }
.page-tables .tables-entry-tags { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
.page-tables .tables-count { min-width: 4.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.page-tables .tables-link > .tables-icon { color: var(--muted); transition: transform 0.15s, color 0.15s; }
.page-tables .tables-link:hover > .tables-icon { color: var(--accent); transform: translateX(2px); }

/* Grid card */
.page-tables .tables-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.page-tables .tables-wrap { border: 0; border-radius: 0; box-shadow: none; max-height: calc(100vh - 18rem); min-height: 6rem; overflow: auto; }
.page-tables .tables-holder { transition: opacity 0.15s; }
.page-tables .tables-holder.is-loading { opacity: 0.55; pointer-events: none; }
.page-tables .tables-grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.9rem; }
.page-tables .tables-grid th,
.page-tables .tables-grid td { padding: 0 0.9rem; height: var(--tables-row-h); vertical-align: middle; border-bottom: 1px solid var(--line); text-align: left; }
.page-tables .tables-grid tbody tr:last-child td { border-bottom: 0; }
.page-tables .tables-grid th.is-num,
.page-tables .tables-grid td.is-num { text-align: right; font-variant-numeric: tabular-nums; }
.page-tables .tables-grid th { position: sticky; top: 0; z-index: 2; height: 2.5rem; padding: 0; background: var(--panel); color: var(--muted); font-size: 0.8rem; font-weight: 600; cursor: default; box-shadow: inset 0 -1px 0 var(--line); border-bottom: 0; }
.page-tables .tables-grid th:hover { color: var(--muted); }
.page-tables .tables-grid th.is-sorted { color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 40%, var(--panel)); }
.page-tables .tables-sort { display: flex; align-items: center; gap: 0.35rem; width: 100%; height: 100%; min-height: 2.5rem; padding: 0 0.9rem; border: 0; border-radius: 0; background: transparent; color: inherit; font: inherit; font-weight: 600; white-space: nowrap; text-align: left; cursor: pointer; }
.page-tables .tables-grid th.is-num .tables-sort { justify-content: flex-end; }
.page-tables .tables-sort:hover { color: var(--accent); background: var(--tables-hover); border-color: transparent; }
.page-tables .tables-sort:focus-visible { outline-offset: -2px; }
.page-tables .tables-sort .tables-icon { width: 0.85rem; height: 0.85rem; }
.page-tables .tables-grid td.cell { max-width: 24rem; padding-top: 0; padding-bottom: 0; white-space: nowrap; overflow: hidden; text-overflow: clip; background: var(--panel); transition: background-color 0.1s; }
.page-tables .tables-cell-in { max-width: 24rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-tables .tables-grid td.is-id { color: var(--muted); font-variant-numeric: tabular-nums; width: 1%; }
.page-tables .tables-grid tbody tr:hover td { background: var(--tables-hover); }
.page-tables .tables-grid td.cell.editable { cursor: cell; }
.page-tables .tables-grid td.cell.editable:hover { outline: 0; box-shadow: inset 0 0 0 1px var(--accent); }
.page-tables .tables-grid td.cell.editable:focus-visible { outline: 0; box-shadow: inset 0 0 0 2px var(--accent); background: var(--panel); }
.page-tables .tables-grid td.null { color: var(--muted); }
.page-tables .tables-null { color: var(--muted); opacity: 0.7; font-size: 0.82em; font-style: italic; }
.page-tables .tables-tag,
.page-tables .tables-ref { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; border-radius: 6px; padding: 0.05rem 0.5rem; font-size: 0.82rem; font-weight: 550; }
.page-tables .tables-tag { background: var(--chip); color: var(--text); }
.page-tables .tables-ref { background: var(--accent-soft); color: var(--accent); }
.page-tables .tables-bool { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; }
.page-tables .tables-bool::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--line); }
.page-tables .tables-bool.is-yes::before { background: var(--accent); }
.page-tables .tables-bool.is-no { color: var(--muted); }

/* Deleted rows */
.page-tables .tables-grid tr.deleted td { opacity: 1; text-decoration: none; color: var(--muted); background: color-mix(in srgb, var(--danger) 5%, var(--panel)); }
.page-tables .tables-grid tr.deleted .tables-cell-in { text-decoration: line-through; opacity: 0.65; }
.page-tables .tables-grid tr.deleted td.actions { opacity: 1; }

/* Row actions: pinned to the right, shown on hover/focus */
.page-tables .tables-actions-h { right: 0; z-index: 3; width: 1%; }
.page-tables .tables-grid td.actions { position: sticky; right: 0; z-index: 1; width: 1%; padding: 0 0.6rem; white-space: nowrap; background: var(--panel); }
.page-tables .tables-acts { display: flex; justify-content: flex-end; gap: 0.35rem; opacity: 0; transition: opacity 0.12s; }
.page-tables .tables-grid tr:hover .tables-acts,
.page-tables .tables-grid tr:focus-within .tables-acts,
.page-tables .tables-grid tr.deleted .tables-acts { opacity: 1; }
.page-tables .tables-acts button.small { min-height: 1.75rem; border-color: transparent; background: transparent; }
.page-tables .tables-acts button.small:hover { border-color: var(--line); background: var(--panel); }
.page-tables .tables-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Footer */
.page-tables .tables-pager { display: flex; align-items: center; gap: 0.5rem; margin: 0; padding: 0.6rem 0.9rem; border-top: 1px solid var(--line); background: var(--panel); font-size: 0.88rem; }
.page-tables .tables-range { margin-right: auto; font-variant-numeric: tabular-nums; }
.page-tables .tables-pager select { min-height: 1.85rem; padding: 0.1rem 0.5rem; font-size: 0.85rem; }
.page-tables .tables-tip { margin: 0.6rem 0 0; }

/* Empty */
.page-tables .tables-empty { display: grid; justify-items: center; gap: 0.35rem; padding: 3rem 1rem; text-align: center; }
.page-tables .tables-empty-mark { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; margin-bottom: 0.4rem; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.page-tables .tables-empty-mark .tables-icon { width: 1.3rem; height: 1.3rem; }
.page-tables .tables-empty-title { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.page-tables .tables-empty-hint { max-width: 26rem; }
.page-tables .tables-empty-actions { margin-top: 0.6rem; display: flex; gap: 0.5rem; }

/* Loading skeleton */
.page-tables .tables-skeleton { display: grid; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.page-tables .tables-sk-row { display: flex; align-items: center; gap: 1.25rem; height: var(--tables-row-h); padding: 0 1rem; border-bottom: 1px solid var(--line); }
.page-tables .tables-sk-row:last-child { border-bottom: 0; }
.page-tables .tables-sk { height: 0.7rem; border-radius: 4px; background: linear-gradient(90deg, var(--chip) 25%, var(--accent-soft) 50%, var(--chip) 75%); background-size: 200% 100%; animation: tables-shimmer 1.4s linear infinite; }
.page-tables .tables-sk-w0 { width: 4rem; }
.page-tables .tables-sk-w1 { width: 9rem; }
.page-tables .tables-sk-w2 { width: 6rem; }
.page-tables .tables-sk-w3 { width: 12rem; }
@keyframes tables-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (hover: none) {
  .page-tables .tables-acts { opacity: 1; }
}
@media (max-width: 860px) {
  .page-tables .tables-head h1 { font-size: 1.4rem; }
  .page-tables .tables-search { flex-basis: 100%; max-width: none; }
  .page-tables .tables-add { margin-left: 0; flex: 1 1 auto; justify-content: center; }
  .page-tables .tables-toolbar-note { margin-left: 0; }
  .page-tables .tables-wrap { max-height: calc(100vh - 20rem); }
  .page-tables .tables-link { flex-wrap: wrap; padding: 0.8rem; }
  .page-tables .tables-entry-tags { order: 3; flex-basis: 100%; justify-content: flex-start; }
  .page-tables .tables-pager-mid { display: none; }
  .page-tables .tables-range { flex-basis: 100%; }
  .page-tables .tables-sk-row .tables-sk:nth-child(n+4) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .page-tables .tables-sk { animation: none; }
}

/* ---- page: chat ---- */
/* ===== Chat page + drawer. Everything is scoped under .chat / .page-chat / .drawer. ===== */

.page-chat { height: calc(100vh - 6.5rem); min-height: 24rem; border-radius: 16px; box-shadow: var(--shadow); }
.drawer .chat { height: 100%; }

.chat { --chat-gutter: 1rem; --chat-col: 100%; background: var(--panel); position: relative; }
.page-chat .chat { --chat-gutter: max(1.5rem, calc((100% - 46rem) / 2)); }
.page-chat .chat-head { display: none; }

.chat-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chat .chat-icon { display: block; flex: none; }

/* Header (drawer) */
.chat .chat-head { padding: 0.75rem 0.75rem 0.75rem 1rem; gap: 0.6rem; min-height: 3.25rem; }
.chat .chat-head strong { font-size: 0.95rem; font-weight: 650; letter-spacing: -0.01em; }
.chat .chat-head strong::before {
  content: ""; display: inline-block; width: 0.5rem; height: 0.5rem; margin-right: 0.55rem; border-radius: 50%;
  background: var(--accent); vertical-align: 0.05em; box-shadow: 0 0 0 3px var(--accent-soft);
}
.chat .chat-close { width: 2rem; min-height: 2rem; height: 2rem; padding: 0; display: grid; place-items: center; border-color: transparent; background: transparent; color: var(--muted); border-radius: var(--radius-sm); }
.chat .chat-close:hover { background: var(--chip); color: var(--text); border-color: transparent; }

/* Log */
.chat .chat-body { position: relative; flex: 1; min-height: 0; display: flex; }
.chat .chat-log {
  flex: 1; min-width: 0; min-height: 0; overflow-y: auto; align-content: start; gap: 0.25rem;
  padding: 1.25rem var(--chat-gutter) 1rem; background: var(--bg); scroll-behavior: smooth;
}
.chat.is-empty .chat-log { visibility: hidden; }

.chat .msg { display: grid; max-width: 88%; padding: 0; background: none; border: 0; border-radius: 0; color: inherit; white-space: normal; gap: 0.15rem; margin-top: 0.6rem; justify-items: start; }
.chat .msg.user { justify-self: end; justify-items: end; background: none; border: 0; color: inherit; }
.chat .msg-body {
  padding: 0.6rem 0.9rem; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; max-width: 68ch;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px;
  box-shadow: 0 1px 1px rgba(15, 47, 143, 0.04);
}
.chat .msg.user .msg-body {
  background: var(--accent); border-color: var(--accent); color: var(--accent-text);
  border-radius: 16px 16px 4px 16px; box-shadow: 0 1px 2px rgba(31, 94, 255, 0.25);
}
.chat .msg time { font-size: 0.72rem; color: var(--muted); opacity: 0; padding: 0 0.25rem; transition: opacity 0.15s; line-height: 1.2; }
.chat .msg:hover time, .chat .msg:focus-within time { opacity: 1; }
@media (hover: none) { .chat .msg time { opacity: 0.8; } }

/* Working indicator */
.chat .msg.typing .msg-body { display: flex; gap: 0.3rem; align-items: center; padding: 0.85rem 1rem; }
.chat .chat-dot { width: 0.4rem; height: 0.4rem; border-radius: 50%; background: var(--accent); opacity: 0.35; animation: chat-pulse 1.1s ease-in-out infinite; }
.chat .chat-dot:nth-of-type(2) { animation-delay: 0.15s; }
.chat .chat-dot:nth-of-type(3) { animation-delay: 0.3s; }
@keyframes chat-pulse { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* Steps taken */
.chat .tools { justify-self: start; max-width: min(88%, 40rem); width: auto; margin-top: 0.6rem; font-size: 0.85rem; color: var(--muted); }
.chat .tools > summary {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.6rem 0.2rem 0.4rem; list-style: none; cursor: pointer;
  border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-weight: 550; user-select: none; transition: border-color 0.12s, color 0.12s;
}
.chat .tools > summary::-webkit-details-marker { display: none; }
.chat .tools > summary:hover { border-color: var(--accent); color: var(--accent); }
.chat .tools > summary .chat-icon { width: 14px; height: 14px; transition: transform 0.15s; }
.chat .tools[open] > summary .chat-icon { transform: rotate(90deg); }
.chat .chat-steps { list-style: none; margin: 0.5rem 0 0 0.7rem; padding: 0 0 0 0.9rem; border-left: 2px solid var(--line); display: grid; gap: 0.6rem; }
.chat .chat-step-name { display: flex; align-items: center; gap: 0.5rem; color: var(--text); }
.chat .chat-step-name strong { font-weight: 600; font-size: 0.82rem; background: var(--chip); color: var(--accent); padding: 0.05rem 0.5rem; border-radius: 6px; }
.chat .chat-step.failed .chat-step-name strong { color: var(--danger); }
.chat .chat-step-flag { color: var(--danger); font-size: 0.78rem; font-weight: 600; }
.chat .tools pre {
  margin: 0.3rem 0 0; padding: 0.5rem 0.65rem; max-height: 11rem; overflow: auto; border-radius: var(--radius-sm);
  background: var(--chip); color: var(--text); font: 0.76rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere;
}

/* Confirmation card: the one loud thing in the log */
.chat .confirm {
  justify-self: start; width: min(100%, 30rem); margin: 0.75rem 0; padding: 0.9rem 1rem 1rem; display: grid; gap: 0.4rem;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 14px;
  box-shadow: 0 0 0 4px var(--accent-soft), 0 6px 18px rgba(31, 94, 255, 0.12);
}
.chat .chat-confirm-head { display: flex; align-items: center; gap: 0.5rem; color: var(--accent); font-weight: 650; font-size: 0.85rem; }
.chat .chat-confirm-head .chat-icon { width: 18px; height: 18px; padding: 0; }
.chat .chat-confirm-text { margin: 0; font-size: 1rem; line-height: 1.5; font-weight: 500; overflow-wrap: anywhere; }
.chat .chat-confirm-notify { margin: 0; color: var(--muted); font-size: 0.85rem; }
.chat .chat-confirm-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.chat .chat-confirm-actions button { min-width: 6rem; justify-content: center; }
.chat .confirm.preference { box-shadow: 0 0 0 4px var(--accent-soft); }

/* Empty state */
.chat .chat-empty { display: none; position: absolute; inset: 0; flex-direction: column; align-items: center; justify-content: center; gap: 0.5rem; padding: 1.5rem var(--chat-gutter); text-align: center; background: var(--bg); }
.chat.is-empty .chat-empty { display: flex; }
.chat .chat-empty h2 { margin: 0.25rem 0 0; font-size: 1.35rem; letter-spacing: -0.02em; }
.chat .chat-empty p { margin: 0; max-width: 28rem; }
.chat .chat-empty-mark { width: 3rem; height: 3rem; display: grid; place-items: center; border-radius: 14px; background: var(--accent); color: var(--accent-text); box-shadow: 0 6px 18px rgba(31, 94, 255, 0.3); }
.chat .chat-empty-mark .chat-icon { width: 22px; height: 22px; }
.chat .chat-suggest { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; margin-top: 1rem; max-width: 34rem; }
.chat .chat-chip { background: var(--panel); border-radius: 999px; padding: 0.4rem 0.9rem; font-weight: 500; font-size: 0.9rem; box-shadow: 0 1px 1px rgba(15, 47, 143, 0.04); }
.chat .chat-chip:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chat .chat-chip:active { transform: translateY(1px); }

/* Composer */
.chat .chat-form { display: block; padding: 0.75rem var(--chat-gutter) 0.6rem; background: var(--bg); border-top: 0; }
.chat .chat-composer {
  display: flex; align-items: flex-end; gap: 0.5rem; padding: 0.4rem 0.4rem 0.4rem 0.9rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.chat .chat-composer:hover { border-color: var(--side-muted); }
.chat .chat-composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat .chat-input {
  flex: 1; min-width: 0; width: auto; min-height: 2.25rem; height: auto; max-height: 9rem; resize: none; padding: 0.45rem 0; line-height: 1.5;
  border: 0; background: transparent; box-shadow: none; border-radius: 0; field-sizing: content; overflow-y: auto;
}
.chat .chat-input:hover, .chat .chat-input:focus { border: 0; box-shadow: none; outline: none; }
.chat .chat-send { flex: none; width: 2.25rem; min-height: 2.25rem; height: 2.25rem; padding: 0; display: grid; place-items: center; border-radius: 12px; }
.chat .chat-send:active:not(:disabled) { transform: scale(0.94); }
.chat.is-busy .chat-send { opacity: 0.45; }
.chat .chat-hint { margin: 0.4rem 0.25rem 0; color: var(--muted); font-size: 0.75rem; text-align: center; }
.drawer .chat-hint { display: none; }
@media (hover: none) { .chat .chat-hint { display: none; } }

/* Narrow screens */
@media (max-width: 860px) {
  .page-chat { height: calc(100vh - 9.25rem); height: calc(100dvh - 9.25rem); border-radius: 12px; }
  .page-chat .chat { --chat-gutter: 0.85rem; }
  .chat .msg, .chat .tools { max-width: 94%; }
  .chat .chat-input { font-size: 16px; }
  .chat .chat-confirm-actions button { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .chat .chat-dot { animation: none; opacity: 0.7; }
  .chat .chat-log { scroll-behavior: auto; }
}

/* ---- chat images: attach, paste, drop ---- */
.chat .chatimg-tray { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 0.5rem; padding: 0; }
.chat .chatimg-tray[hidden] { display: none; }
.chat .chatimg-item { position: relative; width: 4.25rem; height: 4.25rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); overflow: hidden; box-shadow: var(--shadow-sm); }
.chat .chatimg-thumb { display: block; width: 100%; height: 100%; object-fit: cover; }
.chat .chatimg-wait .chatimg-thumb { opacity: 0.45; }
.chat .chatimg-wait::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--accent); opacity: 0.7; animation: chatimg-load 1s ease-in-out infinite alternate; transform-origin: left; }
@keyframes chatimg-load { from { transform: scaleX(0.15); } to { transform: scaleX(1); } }
.chat .chatimg-bad { border-color: var(--danger); }
.chat .chatimg-bad .chatimg-thumb { opacity: 0.35; }
.chat .chatimg-x { position: absolute; top: 3px; right: 3px; width: 1.3rem; min-height: 1.3rem; height: 1.3rem; padding: 0; display: grid; place-items: center; font-size: 0.8rem; line-height: 1; border-radius: 50%; border: 0; background: rgba(10, 20, 40, 0.78); color: #fff; cursor: pointer; }
.chat .chatimg-x:hover { background: rgba(10, 20, 40, 0.95); }
.chat .chatimg-x:focus-visible, .chat .chatimg-attach:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chat .chatimg-attach { flex: none; width: 2.25rem; min-height: 2.25rem; height: 2.25rem; margin-left: -0.5rem; padding: 0; display: grid; place-items: center; border-color: transparent; background: transparent; color: var(--muted); border-radius: 12px; }
.chat .chatimg-attach:hover { background: var(--chip); color: var(--accent); border-color: transparent; }
.chat .chatimg-file { display: none; }
.chat .chatimg-row { display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: flex-start; }
.chat .msg.user .chatimg-row { justify-content: flex-end; }
.chat .chatimg-row a { display: block; line-height: 0; border-radius: var(--radius-sm); }
.chat .chatimg-pic { display: block; max-width: min(11rem, 100%); max-height: 11rem; object-fit: cover; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); }
.drawer .chat .chatimg-pic { max-width: min(8.5rem, 100%); max-height: 8.5rem; }
.chat.chatimg-drop::after { content: ""; position: absolute; inset: 6px; border: 2px dashed var(--accent); border-radius: 14px; background: var(--accent-soft); opacity: 0.6; pointer-events: none; z-index: 5; }
@media (prefers-reduced-motion: reduce) { .chat .chatimg-wait::after { animation: none; } }
