/* Personal AI Companion — design system.
   Tokens → base → layout (sidebar shell) → components → pages → utilities.
   No inline styles anywhere (CSP style-src 'self'); widths for progress bars use data-pct classes. */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --surface-3: #f1efea;
  --border: #e7e4dd;
  --border-strong: #d8d4ca;
  --text: #1c2321;
  --text-2: #565f5b;
  --text-3: #858c88;
  --accent: #1f6f64;
  --accent-hover: #195b52;
  --accent-soft: #e5f0ed;
  --accent-ink: #ffffff;
  --ok: #1d7a4c;
  --ok-soft: #e5f3ea;
  --warn: #93600a;
  --warn-soft: #fbf1df;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --info: #2c5f9e;
  --info-soft: #e9f0f9;
  --focus: #1f6f64;
  --radius-lg: 14px;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(28, 35, 33, 0.05);
  --shadow: 0 1px 2px rgba(28, 35, 33, 0.04), 0 2px 8px rgba(28, 35, 33, 0.04);
  --shadow-lg: 0 12px 32px rgba(28, 35, 33, 0.14);
  --sidebar-w: 248px;
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121514;
    --surface: #1a1e1c;
    --surface-2: #1f2421;
    --surface-3: #262c29;
    --border: #2c3330;
    --border-strong: #3a423e;
    --text: #e7ebe9;
    --text-2: #aab3ae;
    --text-3: #7f8984;
    --accent: #5fb3a3;
    --accent-hover: #74c2b3;
    --accent-soft: #1d3530;
    --accent-ink: #0d1412;
    --ok: #6cc596;
    --ok-soft: #173326;
    --warn: #e5b45b;
    --warn-soft: #3a2e15;
    --bad: #f28b82;
    --bad-soft: #3d1f1d;
    --info: #8db4e8;
    --info-soft: #1b2a3d;
    --focus: #74c2b3;
    --shadow-sm: none;
    --shadow: none;
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--text); }
h1 { font-size: 26px; font-weight: 650; letter-spacing: -0.015em; }
h2 { font-size: 16px; font-weight: 620; }
h3 { font-size: 14px; font-weight: 620; }
h4 { font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; }
p { margin: 0 0 8px; }
p:last-child { margin-bottom: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--surface-3); padding: 1px 6px; border-radius: 5px; }
ul, ol { margin: 0; padding-left: 20px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
svg.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
svg.icon.sm { width: 15px; height: 15px; }
svg.icon.lg { width: 22px; height: 22px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }

/* ------------------------------------------------------------------ shell */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh;
  /* the sidebar column keeps its tint for the full page height */
  background: linear-gradient(to right, var(--surface-2) calc(var(--sidebar-w) - 1px), var(--border) calc(var(--sidebar-w) - 1px),
    var(--border) var(--sidebar-w), transparent var(--sidebar-w)); }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface-2); border-right: 1px solid var(--border);
  padding: 20px 12px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 10px 18px; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
}
.brand-mark svg.icon { width: 19px; height: 19px; }
.brand-text { font-size: 13px; line-height: 1.2; color: var(--text-2); }
.brand-text strong { display: block; font-size: 15px; color: var(--text); font-weight: 650; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3);
  padding: 14px 12px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 8px 12px; border-radius: 9px;
  color: var(--text-2); font-weight: 500; text-decoration: none;
}
.nav-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-link span.label { flex: 1; }
.nav-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: 11.5px; font-weight: 650;
}
.nav-badge.warn { background: var(--warn); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 12px 6px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 0 6px; }
.me-text { min-width: 0; }
.me-name { font-weight: 600; font-size: 13px; }
.me-email { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.main { width: 100%; max-width: 1240px; margin: 0 auto; padding: 32px 36px 48px; flex: 1; }
.foot { max-width: 1240px; margin: 0 auto; width: 100%; padding: 0 36px 28px; color: var(--text-3); font-size: 12px; display: flex;
  gap: 8px; align-items: center; }
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.scrim { display: none; }

/* ------------------------------------------------------------------ page header */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-header .subtitle { color: var(--text-2); margin-top: 6px; max-width: 70ch; }
.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.eyebrow { font-size: 12.5px; color: var(--text-3); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-weight: 500; margin-bottom: 10px; }
.back svg { transform: rotate(180deg); }

/* ------------------------------------------------------------------ layout helpers */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.top { align-items: flex-start; }
.row > select, .actions select { width: auto; min-width: 160px; }
.grid.align-start { align-items: start; }
.spacer { flex: 1; }
.section { margin-top: 28px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 20px; }
.mb-2 { margin-bottom: 12px; }
.hidden { display: none !important; }

/* ------------------------------------------------------------------ cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); min-width: 0;
}
.card-pad { padding: 20px 22px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px;
  border-bottom: 1px solid var(--border); }
.card-header h2 { display: flex; align-items: center; gap: 8px; }
.card-header .link { font-size: 13px; font-weight: 550; }
.card-body { padding: 18px 22px; }
.card-body.flush { padding: 0; }
.card-footer { padding: 12px 22px; border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card + .card { margin-top: 16px; }
.grid > .card + .card, .stack > .card + .card, .stack-lg > .card + .card { margin-top: 0; }

/* ------------------------------------------------------------------ stat tiles */
.stat { padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; }
a.stat:hover { text-decoration: none; border-color: var(--border-strong); }
.stat-top { display: flex; align-items: center; gap: 12px; }
.stat-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.stat-icon.teal { background: var(--accent-soft); color: var(--accent); }
.stat-icon.blue { background: var(--info-soft); color: var(--info); }
.stat-icon.amber { background: var(--warn-soft); color: var(--warn); }
.stat-icon.rose { background: var(--bad-soft); color: var(--bad); }
.stat-value { font-size: 28px; font-weight: 680; letter-spacing: -0.02em; line-height: 1.1; }
.stat-label { color: var(--text-2); font-weight: 500; }
.stat-sub { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }
.stat-sub.warn { color: var(--warn); }
.stat-sub.accent { color: var(--accent); }
.stat .progress { margin-top: 8px; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font: 550 13.5px/1 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn.icon-only { width: 36px; padding: 0; }
.btn.small.icon-only { width: 30px; }
.btn svg.icon { width: 16px; height: 16px; }
form.inline { display: inline-flex; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ------------------------------------------------------------------ badges & chips */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 550; white-space: nowrap; background: var(--surface-3); color: var(--text-2);
}
.badge svg.icon { width: 13px; height: 13px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.outline { background: transparent; border: 1px solid var(--border-strong); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--text-3); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.dot.live { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); }

/* ------------------------------------------------------------------ avatars */
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-size: 13px; font-weight: 650; letter-spacing: 0.02em; background: var(--accent-soft); color: var(--accent);
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.avatar.square { border-radius: 10px; }
.av-1 { background: #e8eefb; color: #2c5f9e; } .av-2 { background: #fbeee2; color: #9a5412; }
.av-3 { background: #f3e8f7; color: #7a3f93; } .av-4 { background: #e6f3ea; color: #1d7a4c; }
.av-5 { background: #fbe9e9; color: #a83a3a; }
@media (prefers-color-scheme: dark) {
  .av-1 { background: #1b2a3d; color: #8db4e8; } .av-2 { background: #3a2a17; color: #e8b27a; }
  .av-3 { background: #2f2238; color: #cfa2e4; } .av-4 { background: #173326; color: #6cc596; }
  .av-5 { background: #3d1f1f; color: #f0a0a0; }
}

/* ------------------------------------------------------------------ lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 14px 22px; border-top: 1px solid var(--border); }
.list > li:first-child { border-top: 0; }
.item { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.item-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.item-title { font-weight: 600; min-width: 0; }
.item-sub { font-weight: 550; color: var(--text); min-width: 0; }
.item-text { color: var(--text-2); font-size: 13px; min-width: 0; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; }
.item-meta { margin-left: auto; color: var(--text-3); font-size: 12.5px; white-space: nowrap; }
.item-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex: none; }
.item .summary { font-size: 13px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; margin-top: 4px; display: flex; gap: 8px; }
.item .summary svg { color: var(--accent); margin-top: 2px; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--info); flex: none; margin-top: 7px; }

/* ------------------------------------------------------------------ progress */
.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; position: relative; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); width: 0; transition: width 0.4s ease; }
.progress.sm { height: 6px; }
.progress.done > span { background: var(--ok); }
.progress.indeterminate > span {
  width: 35%; position: absolute; animation: slide 1.4s ease-in-out infinite;
}
@keyframes slide { 0% { left: -35%; } 100% { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .progress.indeterminate > span { animation: none; left: 0; width: 100%; opacity: 0.35; } }
/* widths in 5% steps so markup never needs inline styles */
.p-0 > span { width: 0; } .p-5 > span { width: 5%; } .p-10 > span { width: 10%; } .p-15 > span { width: 15%; }
.p-20 > span { width: 20%; } .p-25 > span { width: 25%; } .p-30 > span { width: 30%; } .p-35 > span { width: 35%; }
.p-40 > span { width: 40%; } .p-45 > span { width: 45%; } .p-50 > span { width: 50%; } .p-55 > span { width: 55%; }
.p-60 > span { width: 60%; } .p-65 > span { width: 65%; } .p-70 > span { width: 70%; } .p-75 > span { width: 75%; }
.p-80 > span { width: 80%; } .p-85 > span { width: 85%; } .p-90 > span { width: 90%; } .p-95 > span { width: 95%; }
.p-100 > span { width: 100%; }

/* ------------------------------------------------------------------ notices, flash, empty */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius);
  background: var(--info-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--info) 22%, transparent); }
.notice > svg { color: var(--info); margin-top: 1px; }
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.notice.warn > svg { color: var(--warn); }
.notice.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.notice.bad > svg { color: var(--bad); }
.notice.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.notice.ok > svg { color: var(--ok); }
.notice .notice-body { flex: 1; min-width: 0; }
.notice .notice-title { font-weight: 600; margin-bottom: 2px; }
.notices { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.flash { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px;
  font-weight: 500; border: 1px solid; }
.flash-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash-error { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.flash .flash-text { flex: 1; color: var(--text); }
.empty { text-align: center; padding: 34px 24px; color: var(--text-2); }
.empty .empty-icon { width: 44px; height: 44px; border-radius: 12px; display: inline-grid; place-items: center;
  background: var(--surface-3); color: var(--text-3); margin-bottom: 10px; }
.empty .empty-title { color: var(--text); font-weight: 600; font-size: 14.5px; margin-bottom: 4px; }
.empty p { max-width: 52ch; margin: 0 auto 4px; }
.empty .actions { justify-content: center; margin-top: 12px; }
.empty.compact { padding: 22px 18px; }

/* ------------------------------------------------------------------ skeleton (loading) */
.skeleton { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3));
  background-size: 200% 100%; animation: shimmer 1.3s infinite linear; }
.skeleton.w-40 { width: 40%; } .skeleton.w-60 { width: 60%; } .skeleton.w-80 { width: 80%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------------------------------------------ tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { display: inline-flex; align-items: center; gap: 7px; padding: 10px 12px; color: var(--text-2); font-weight: 550;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .count { font-size: 11.5px; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.tabs a[aria-selected="true"] .count { background: var(--accent-soft); color: var(--accent); }
.segmented { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 10px; gap: 2px; flex-wrap: wrap; }
.segmented a { padding: 6px 12px; border-radius: 8px; color: var(--text-2); font-weight: 550; font-size: 13px; text-decoration: none; }
.segmented a[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ------------------------------------------------------------------ forms */
label { font-weight: 550; font-size: 13px; color: var(--text); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field .help { font-weight: 400; color: var(--text-3); font-size: 12.5px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="time"],
input[type="search"], select, textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: 400 14px var(--font);
}
textarea { height: auto; padding: 10px 12px; line-height: 1.5; resize: vertical; }
select { padding-right: 30px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 450; color: var(--text); }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.check .help { display: block; color: var(--text-3); font-size: 12.5px; }
.switch-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 14px 0;
  border-top: 1px solid var(--border); }
.switch-row:first-child { border-top: 0; padding-top: 0; }
.switch-row .switch-text { flex: 1; min-width: 0; }
.switch-row .switch-title { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.switch-row .switch-desc { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.switch { position: relative; width: 40px; height: 23px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background 0.15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(17px); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch input:disabled + span { opacity: 0.5; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding-top: 6px; }
.form-note { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.days label { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border-strong);
  border-radius: 8px; font-weight: 500; cursor: pointer; }
.days input { accent-color: var(--accent); }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.disclosure { border-top: 1px solid var(--border); }
.disclosure > summary { display: flex; align-items: center; gap: 8px; padding: 13px 22px; font-weight: 550; color: var(--text-2); }
.disclosure > summary:hover { color: var(--text); }
.disclosure > summary svg.chev { margin-left: auto; transition: transform 0.15s; }
.disclosure[open] > summary svg.chev { transform: rotate(90deg); }
.disclosure > .disclosure-body { padding: 4px 22px 18px; }

/* ------------------------------------------------------------------ tables & key-value */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase;
  letter-spacing: 0.04em; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { justify-content: flex-end; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 18px; margin: 0; }
.kv dt { color: var(--text-3); font-weight: 500; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin: 0; font-size: 13px; line-height: 1.6; }
.email-body { font-family: var(--font); font-size: 14px; }
blockquote { margin: 0; padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 8px 8px 0; }

/* ------------------------------------------------------------------ calendar (agenda lists) */
.agenda { list-style: none; margin: 0; padding: 0; }
.agenda-day { padding: 10px 22px 4px; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); }
.event { display: grid; grid-template-columns: 92px 4px minmax(0, 1fr); gap: 12px; align-items: start; padding: 9px 22px; }
.event-time { color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.event-bar { width: 4px; border-radius: 2px; background: var(--accent); align-self: stretch; min-height: 22px; }
.event-bar.c1 { background: #4a7fc1; } .event-bar.c2 { background: #c9822d; } .event-bar.c3 { background: #8c5aa8; }
.event-title { font-weight: 600; }
.event-meta { color: var(--text-3); font-size: 12.5px; }

/* ------------------------------------------------------------------ accounts & sync */
.account-card .account-head { display: flex; align-items: center; gap: 14px; padding: 18px 22px; flex-wrap: wrap; }
.account-head .who { flex: 1; min-width: 200px; }
.account-head .who h2 { font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.account-body { display: grid; grid-template-columns: minmax(170px, 0.9fr) minmax(200px, 1.1fr) minmax(220px, 1.2fr); gap: 22px;
  padding: 4px 22px 18px; }
.service { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.service .name { font-weight: 550; flex: 1; }
.big-number { font-size: 26px; font-weight: 680; letter-spacing: -0.02em; line-height: 1.1; }
.phase-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 9px; }
.phase-list li { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.phase-list .phase-name { flex: 1; color: var(--text-2); }
.phase-list .phase-state { color: var(--text-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.phase-icon { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface-3);
  color: var(--text-3); }
.phase-icon svg.icon { width: 13px; height: 13px; stroke-width: 2.2; }
.phase-icon.done { background: var(--ok-soft); color: var(--ok); }
.phase-icon.active { background: var(--accent-soft); color: var(--accent); }
.phase-icon.wait { background: var(--warn-soft); color: var(--warn); }
.phase { padding: 16px 22px; border-top: 1px solid var(--border); display: grid; grid-template-columns: minmax(150px, 0.8fr) minmax(0, 2fr);
  gap: 18px; align-items: center; }
.phase .phase-label { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.phase .phase-detail { display: flex; flex-direction: column; gap: 6px; }
.phase .phase-numbers { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
.meta-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; padding: 4px 22px 18px; }
.meta-grid .meta-label { font-size: 12px; color: var(--text-3); }
.meta-grid .meta-value { font-weight: 600; margin-top: 2px; }

/* ------------------------------------------------------------------ writing profiles */
.profile-card .profile-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.profile-card .profile-stats .meta-label { font-size: 12px; color: var(--text-3); }
.profile-card .profile-stats .meta-value { font-weight: 550; }
.steps { display: flex; gap: 8px; flex-wrap: wrap; counter-reset: step; }
.steps li { list-style: none; display: flex; align-items: center; gap: 8px; color: var(--text-3); font-weight: 550; font-size: 13px; }
.steps li::before { counter-increment: step; content: counter(step); width: 22px; height: 22px; border-radius: 50%; display: grid;
  place-items: center; background: var(--surface-3); font-size: 12px; }
.steps li.on { color: var(--text); }
.steps li.on::before { background: var(--accent); color: var(--accent-ink); }
.steps li + li::after { content: none; }

/* ------------------------------------------------------------------ calendar grid
   Placement classes (.rN row, .sN span, .lI-N lanes, .hN hours, .dcN/.dcsN/.arN all-day) come from
   /assets/calendar-grid.css, generated by the server; everything visual lives here. */
.cal-c-teal   { --ev-bg: #e3f1ee; --ev-fg: #0e3a34; --ev-bar: #1f6f64; }
.cal-c-blue   { --ev-bg: #e4eefb; --ev-fg: #13345c; --ev-bar: #2f6fb5; }
.cal-c-purple { --ev-bg: #efe8f8; --ev-fg: #3b1f5e; --ev-bar: #7b4bb0; }
.cal-c-amber  { --ev-bg: #fbf0dc; --ev-fg: #553600; --ev-bar: #b06d00; }
.cal-c-rose   { --ev-bg: #fbe7ed; --ev-fg: #5a1a2c; --ev-bar: #b23a5b; }
.cal-c-green  { --ev-bg: #e6f3e7; --ev-fg: #173e19; --ev-bar: #2e7d32; }
.cal-c-slate  { --ev-bg: #eaeef2; --ev-fg: #1f2830; --ev-bar: #4a5a6a; }
.cal-c-orange { --ev-bg: #fdeae0; --ev-fg: #5b290d; --ev-bar: #c0571f; }
@media (prefers-color-scheme: dark) {
  .cal-c-teal   { --ev-bg: #173430; --ev-fg: #cdeee7; --ev-bar: #5fb3a3; }
  .cal-c-blue   { --ev-bg: #182a40; --ev-fg: #d3e4fa; --ev-bar: #79a8e3; }
  .cal-c-purple { --ev-bg: #2a1f3a; --ev-fg: #e6d8f7; --ev-bar: #b493dc; }
  .cal-c-amber  { --ev-bg: #3a2c12; --ev-fg: #f7e2b8; --ev-bar: #e0a948; }
  .cal-c-rose   { --ev-bg: #3a1c26; --ev-fg: #f7d3de; --ev-bar: #e07c9a; }
  .cal-c-green  { --ev-bg: #173019; --ev-fg: #d2eed4; --ev-bar: #74c27a; }
  .cal-c-slate  { --ev-bg: #232b33; --ev-fg: #dce3ea; --ev-bar: #93a4b5; }
  .cal-c-orange { --ev-bg: #3b2216; --ev-fg: #f8dccd; --ev-bar: #ea8a55; }
}
.cal-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--ev-bar); display: inline-block; flex: none; }
.cal-source { display: inline-flex; align-items: center; gap: 7px; }
.flip svg { transform: rotate(180deg); }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-left: -1px; }

.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px; margin-bottom: 14px; }
.cal-toolbar-left, .cal-toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cal-range { font-size: 17px; font-weight: 640; margin-left: 4px; }
.cal-goto { display: flex; gap: 6px; align-items: center; }
.cal-goto input[type="date"] { width: auto; height: 34px; }
.cal-legend { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-legend-list { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-2); }
.cal-legend-actions { display: flex; align-items: center; gap: 10px; }
.cal-filter { position: relative; }
.cal-filter > summary .count { font-size: 11.5px; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.cal-filter-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: min(340px, 86vw); max-height: 60vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }
.cal-filter-panel fieldset { display: flex; flex-direction: column; gap: 8px; }
.cal-filter-panel legend { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.cal-view-wrap { position: relative; }
.cal-view-wrap[aria-busy="true"]::before { content: ""; position: absolute; left: 0; right: 0; top: -8px; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 50% 100%; background-repeat: no-repeat;
  animation: cal-load 1.1s linear infinite; }
@keyframes cal-load { from { background-position: -50% 0; } to { background-position: 150% 0; } }

.cal-grid { --slot: 4px; --gutter: 58px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); overflow: hidden; }
.cal-grid.is-day { --slot: 5px; }
.cols-1 { --cols: 1; } .cols-7 { --cols: 7; }
.cal-head, .cal-allday, .cal-body { display: grid; grid-template-columns: var(--gutter) repeat(var(--cols), minmax(0, 1fr)); }
.cal-head { border-bottom: 1px solid var(--border); background: var(--surface); }
.cal-gutter { display: flex; align-items: flex-end; justify-content: center; padding: 6px 4px; text-align: center; }
.cal-dayhead { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px 8px; color: var(--text-2);
  border-left: 1px solid var(--border); text-decoration: none; }
.cal-dayhead:hover { background: var(--surface-2); text-decoration: none; }
.cal-dayhead .dow { font-size: 12px; font-weight: 550; }
.cal-dayhead .num { font-size: 19px; font-weight: 650; color: var(--text); width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; }
.cal-dayhead.today .dow { color: var(--accent); }
.cal-dayhead.today .num { background: var(--accent); color: var(--accent-ink); }
.cal-allday { border-bottom: 1px solid var(--border); background: var(--surface-2); }
.cal-allday .cal-gutter { align-items: center; }
.cal-allday-grid { grid-column: 2 / -1; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-auto-rows: 24px;
  gap: 3px 0; padding: 5px 0; }
.ev-allday { margin: 0 3px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600; line-height: 24px; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis; background: var(--ev-bg); color: var(--ev-fg); border-left: 3px solid var(--ev-bar); text-decoration: none; }
.ev-allday:hover { text-decoration: none; filter: brightness(0.97); }
.ev-allday.cont-before { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: 0; }
.ev-allday.cont-after { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: 0; }
.ev-multi { font-weight: 500; opacity: 0.75; }
.cal-body { position: relative; }
.cal-hours { display: grid; }
.cal-hour { position: relative; }
.cal-hour span { position: absolute; top: -8px; right: 8px; font-size: 11px; color: var(--text-3); white-space: nowrap; }
.cal-hour:first-child span { top: 2px; }
.cal-day { display: grid; position: relative; border-left: 1px solid var(--border);
  background-image: linear-gradient(to bottom, var(--border) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--border) 45%, transparent) 1px, transparent 1px);
  background-size: 100% calc(var(--slot) * 12), 100% calc(var(--slot) * 12);
  background-position: 0 0, 0 calc(var(--slot) * 6); }
.cal-day.weekend { background-color: var(--surface-2); }
.cal-day.today { background-color: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
.ev { position: absolute; top: 1px; bottom: 1px; grid-column: 1; z-index: 1; overflow: hidden; display: flex; flex-direction: column;
  gap: 1px; padding: 3px 6px; border-radius: 6px; font-size: 12px; line-height: 1.3; text-decoration: none;
  background: var(--ev-bg); color: var(--ev-fg); border-left: 3px solid var(--ev-bar); box-shadow: 0 0 0 1px var(--surface); }
.ev:hover, .ev:focus-visible { z-index: 3; text-decoration: none; box-shadow: 0 0 0 1px var(--surface), var(--shadow-lg); }
.ev .ev-title { font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 3px; }
.ev .ev-time, .ev .ev-loc { opacity: 0.85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev.short { padding: 1px 6px; flex-direction: row; gap: 6px; align-items: center; }
.ev.short .ev-time { display: none; }
.ev.dense { padding: 2px 4px; font-size: 11px; border-left-width: 2px; }
.ev.dense .ev-time, .ev.dense .ev-loc, .ev.dense .ev-title svg { display: none; }
.ev.dense .ev-title { white-space: normal; overflow-wrap: break-word; hyphens: auto; line-height: 1.2; }
.cal-conflicts > summary { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.cal-conflicts > summary svg.icon:first-child { color: var(--bad); }
.cal-conflicts > summary .chev { margin-left: auto; transition: transform 0.15s; }
.cal-conflicts[open] > summary .chev { transform: rotate(90deg); }
.cal-conflicts .cal-conflicts-body { padding: 8px 0 0 28px; }
details.notice { display: block; }
.ev.cont-before { border-top-left-radius: 0; border-top-right-radius: 0; }
.ev.cont-after { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
/* free / transparent events don't block time: outlined, not filled */
.ev.av-free, .ev-allday.av-free, .mchip.av-free { background: var(--surface); border: 1px dashed var(--ev-bar); border-left: 3px solid var(--ev-bar); }
.ev.av-tentative { background: repeating-linear-gradient(135deg, var(--ev-bg) 0 8px, color-mix(in srgb, var(--ev-bg) 55%, var(--surface)) 8px 16px); }
.ev.av-declined, .mchip.av-declined, .cal-agenda-item.av-declined { opacity: 0.55; }
.ev.av-declined .ev-title, .mchip.av-declined .mchip-title, .cal-agenda-item.av-declined .cal-agenda-title { text-decoration: line-through; }
.ev.conflict { box-shadow: 0 0 0 1px var(--surface), 0 0 0 3px var(--bad); }
.ev.conflict .ev-title svg, .cal-agenda-title svg { color: var(--bad); }
.cal-now { position: absolute; left: 0; right: 0; top: -1px; height: 2px; grid-column: 1; background: var(--bad); z-index: 2; pointer-events: none; }
.cal-now::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); }
.cal-more { position: absolute; top: 2px; right: 4px; z-index: 4; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border-strong); }
.cal-mobile { display: none; }

.cal-month { overflow: hidden; }
.cal-month-head, .cal-month-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-month-head div { padding: 9px 10px; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border); }
.cal-cell { min-height: 116px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex;
  flex-direction: column; gap: 3px; min-width: 0; }
.cal-month-week .cal-cell:last-child { border-right: 0; }
.cal-month-week:last-child .cal-cell { border-bottom: 0; }
.cal-cell.out { background: var(--surface-2); }
.cal-cell.out .cal-cell-num { color: var(--text-3); }
.cal-cell-num { align-self: flex-start; font-size: 13px; font-weight: 600; color: var(--text); width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; text-decoration: none; }
.cal-cell-num:hover { background: var(--surface-3); text-decoration: none; }
.cal-cell.today .cal-cell-num { background: var(--accent); color: var(--accent-ink); }
.cal-cell-events { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-cell-dots { display: none; gap: 3px; }
.cal-cell-more { font-size: 11.5px; font-weight: 600; color: var(--text-2); padding-left: 4px; }
.mchip { display: flex; align-items: center; gap: 5px; padding: 1px 6px; border-radius: 5px; font-size: 12px; line-height: 20px; min-width: 0;
  color: var(--text); text-decoration: none; }
.mchip:hover { background: var(--surface-3); text-decoration: none; }
.mchip.av-allday { background: var(--ev-bg); color: var(--ev-fg); font-weight: 600; }
.mchip.conflict .mchip-dot { box-shadow: 0 0 0 2px var(--bad-soft), 0 0 0 3px var(--bad); }
.mchip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ev-bar); flex: none; }
.mchip-time { color: var(--text-3); font-variant-numeric: tabular-nums; flex: none; }
.mchip-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cal-agenda { list-style: none; margin: 0; padding: 0 0 6px; }
.cal-agenda .agenda-day { padding: 14px 22px 6px; }
.cal-agenda .agenda-day a { color: inherit; text-decoration: none; }
.cal-agenda .agenda-day.today a { color: var(--accent); }
.cal-agenda-item { display: grid; grid-template-columns: 132px 4px minmax(0, 1fr); gap: 12px; padding: 8px 22px; color: var(--text); text-decoration: none; }
.cal-agenda-item:hover { background: var(--surface-2); text-decoration: none; }
.cal-agenda-time { color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.cal-agenda-bar { border-radius: 2px; background: var(--ev-bar); min-height: 20px; }
.cal-agenda-item.av-free .cal-agenda-bar { background: repeating-linear-gradient(to bottom, var(--ev-bar) 0 4px, transparent 4px 7px); }
.cal-agenda-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cal-agenda-title { font-weight: 600; display: flex; gap: 5px; align-items: center; }
.cal-agenda-meta { color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-agenda-none { padding: 2px 22px 6px; }

.cal-skeleton { padding: 16px; }
.cal-skel-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.cal-skel-body { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 14px; height: 340px; margin-bottom: 10px; }
.cal-skel-col { display: flex; flex-direction: column; gap: 10px; padding-top: 20px; }
.cal-skel-col .sk-a { height: 60px; } .cal-skel-col .sk-b { height: 34px; margin-top: 40px; } .cal-skel-col .sk-c { height: 90px; }

.cal-scrim { position: fixed; inset: 0; z-index: 45; background: rgba(15, 20, 18, 0.25); }
.cal-scrim[hidden], .cal-panel[hidden] { display: none; }
.cal-panel { position: fixed; z-index: 50; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: var(--surface);
  border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; }
.cal-panel-top { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 10px 22px; border-bottom: 1px solid var(--border); }
.cal-panel-body { overflow-y: auto; padding: 20px 22px 28px; }
.cal-detail { display: flex; flex-direction: column; gap: 16px; }
.cal-detail-head { display: flex; gap: 12px; align-items: flex-start; }
.cal-swatch { width: 14px; height: 14px; border-radius: 4px; background: var(--ev-bar); margin-top: 6px; flex: none; }
.cal-detail h2 { font-size: 19px; line-height: 1.3; }
.cal-desc { max-height: 260px; overflow: auto; font-family: var(--font); }

/* ------------------------------------------------------------------ auth */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; padding: 30px 28px; }
.auth-card .brand { padding: 0 0 18px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .account-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-body > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 920px) {
  .app { grid-template-columns: minmax(0, 1fr); background: none; }
  .sidebar {
    position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: min(84vw, 290px); transform: translateX(-102%);
    transition: transform 0.2s ease; box-shadow: var(--shadow-lg); background: var(--surface);
  }
  .nav-toggle:checked ~ .app .sidebar { transform: none; }
  .nav-toggle:checked ~ .app .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(15, 20, 18, 0.35); }
  .nav-toggle:focus-visible ~ .app .menu-btn { outline: 2px solid var(--focus); outline-offset: 2px; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; height: 56px; padding: 0 12px;
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
  }
  .topbar .brand { padding: 0; }
  .topbar .brand-mark { width: 30px; height: 30px; border-radius: 9px; }
  .topbar-title { font-weight: 650; }
  .topbar .spacer { flex: 1; }
  .main { padding: 22px 20px 40px; }
  .foot { padding: 0 20px 24px; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  body { font-size: 14px; }
  h1 { font-size: 22px; }
  .main { padding: 18px 16px 36px; }
  .foot { padding: 0 16px 20px; }
  .grid-2, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .grid-4.keep-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { gap: 14px; }
  .card-header, .card-body, .list > li, .disclosure > summary, .disclosure > .disclosure-body { padding-left: 16px; padding-right: 16px; }
  .card-pad { padding: 16px; }
  .card-footer { padding: 12px 16px; }
  .account-body { grid-template-columns: minmax(0, 1fr); padding: 4px 16px 16px; }
  .account-card .account-head { padding: 16px; }
  .phase { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 14px 16px; }
  .meta-grid { padding: 4px 16px 16px; }
  .event { grid-template-columns: 70px 4px minmax(0, 1fr); padding: 9px 16px; }
  .agenda-day { padding: 10px 16px 4px; }
  .stat { padding: 14px 16px; }
  .stat-value { font-size: 24px; }
  .stat-icon { width: 34px; height: 34px; }
  .page-header { margin-bottom: 18px; }
  .item-meta { margin-left: 0; }
  .item-top { flex-wrap: wrap; row-gap: 0; }
  .item-side { display: none; }
  .table.stack-mobile thead { display: none; }
  .table.stack-mobile tr { display: block; border-bottom: 1px solid var(--border); padding: 8px 0; }
  .table.stack-mobile td { display: block; border: 0; padding: 4px 16px; }
  .table.stack-mobile .actions { justify-content: flex-start; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .profile-card .profile-stats { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 920px) {
  .cal-grid { --gutter: 46px; }
}
@media (max-width: 640px) {
  /* Phones: the week becomes a compact agenda; day view keeps its grid; month shows dots. */
  .cal-grid.is-week { display: none; }
  .cal-mobile { display: block; }
  .cal-empty-note { display: none; }
  .cal-toolbar { padding: 10px; gap: 8px; }
  .cal-toolbar-right { width: 100%; justify-content: space-between; }
  .cal-goto { display: none; }
  .cal-range { font-size: 15px; }
  .cal-legend-list { display: none; }
  .cal-agenda .agenda-day { padding: 12px 16px 4px; }
  .cal-agenda-item { grid-template-columns: 86px 4px minmax(0, 1fr); padding: 8px 16px; gap: 10px; }
  .cal-agenda-time { font-size: 12px; }
  .cal-agenda-none { padding: 0 16px 6px; }
  .cal-cell { min-height: 58px; padding: 4px 2px; align-items: center; }
  .cal-cell-events { display: none; }
  .cal-cell-dots { display: flex; flex-wrap: wrap; justify-content: center; max-width: 100%; }
  .cal-cell-dots .cal-dot { width: 6px; height: 6px; border-radius: 50%; }
  .cal-month-head div { padding: 8px 2px; text-align: center; font-size: 11px; }
  .cal-panel { top: auto; left: 0; width: 100%; max-height: 86vh; border-left: 0; border-top: 1px solid var(--border); border-radius: 16px 16px 0 0; }
  .cal-skel-head, .cal-skel-body { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* ------------------------------------------------------------------ overview (command center) */
.page-overview .main { max-width: 1480px; padding-top: 26px; }
.page-overview .foot { max-width: 1480px; }
.ohead { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.ohead-main { display: flex; align-items: center; gap: 14px; min-width: 0; }
.ohead-icon { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--warn-soft); color: var(--warn); flex: none; }
.ohead-icon svg.icon { width: 26px; height: 26px; }
.ohead h1 { font-size: 26px; }
.ohead .subtitle { color: var(--text-2); margin: 4px 0 0; }
.ohead-side { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ohead-date { font-size: 15px; font-weight: 600; margin-right: 6px; }
.ostats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.ostat { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 14px 30px 14px 14px; color: inherit; text-decoration: none;
  min-height: 92px; transition: border-color 0.12s, box-shadow 0.12s; }
a.ostat:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.ostat-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.ostat-icon.teal { background: var(--accent-soft); color: var(--accent); }
.ostat-icon.blue { background: var(--info-soft); color: var(--info); }
.ostat-icon.green { background: var(--ok-soft); color: var(--ok); }
.ostat-icon.purple { background: #efe8f8; color: #6b3fa0; }
.ostat-icon.amber { background: var(--warn-soft); color: var(--warn); }
.ostat-icon.rose { background: var(--bad-soft); color: var(--bad); }
.ostat-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; align-items: flex-start; }
.ostat-value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.05; }
.ostat-label { color: var(--text-2); font-size: 13px; font-weight: 500; }
.ostat-label.strong { color: var(--text); font-weight: 620; font-size: 13.5px; }
.ostat-sub { font-size: 12px; color: var(--text-3); }
.ostat-sub.bad { color: var(--bad); font-weight: 600; }
.ostat-go { position: absolute; right: 10px; top: 14px; color: var(--text-3); }
.ogrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.osec { display: flex; flex-direction: column; min-width: 0; }
.osec .card-header { padding: 14px 18px; }
.osec .card-header h2 { font-size: 15.5px; }
.osec .empty.compact { padding: 22px 16px; }
.olist { list-style: none; margin: 0; padding: 0; }
.oitem { display: flex; gap: 12px; align-items: flex-start; padding: 12px 18px; border-top: 1px solid var(--border); min-width: 0; }
.olist > .oitem:first-child, .olist > li:first-child { border-top: 0; }
.oitem-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.oitem-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.oitem-title { font-weight: 620; min-width: 0; }
.oitem-time { margin-left: auto; color: var(--text-3); font-size: 12px; white-space: nowrap; }
.oitem-sub { color: var(--text); font-weight: 500; font-size: 13.5px; }
.oitem-text { color: var(--text-2); font-size: 13px; }
.clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.oitem-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 3px; align-items: center; }
.oitem-tags .chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oitem-meta-line { color: var(--text-3); font-size: 12.5px; }
.oitem-side { display: flex; flex-direction: column; gap: 0; flex: none; opacity: 0.55; transition: opacity 0.12s; }
.oitem-side .btn.small.icon-only { height: 26px; width: 26px; }
.oitem:hover .oitem-side, .oitem:focus-within .oitem-side { opacity: 1; }
.oitem-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.oitem-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-2); }
.oitem-icon.warn, .oitem-icon.tone-warn { background: var(--warn-soft); color: var(--warn); }
.oitem-icon.tone-bad { background: var(--bad-soft); color: var(--bad); }
.oitem-icon.tone-accent { background: var(--accent-soft); color: var(--accent); }
.oitem-icon.tone-info { background: var(--info-soft); color: var(--info); }
.oitem-icon.tone-ok { background: var(--ok-soft); color: var(--ok); }
.ai-label { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--info);
  background: var(--info-soft); border-radius: 4px; padding: 0 5px; margin-right: 2px; vertical-align: 1px; }
.ai-note { display: flex; gap: 6px; font-size: 13px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 9px; margin-top: 4px; }
.ai-note > svg { color: var(--info); margin-top: 2px; }
.orec-sources { font-size: 12.5px; color: var(--text-3); }
.card-note { display: flex; gap: 6px; align-items: flex-start; font-size: 12px; color: var(--text-3); padding: 10px 18px 14px; margin: 0;
  border-top: 1px solid var(--border); }
.ocal { padding: 12px 18px 16px; display: flex; flex-direction: column; gap: 10px; }
.ocal-date { margin: 0; font-weight: 600; }
.otimeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ot-item { position: relative; display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; padding-bottom: 6px; }
.ot-item::before { content: ""; position: absolute; left: 5px; top: 16px; bottom: -2px; width: 2px; background: var(--border); }
.ot-item:last-child::before { display: none; }
.ot-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 12px; border: 2px solid var(--ev-bar); background: var(--surface); z-index: 1; }
.ot-body { display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; border-radius: 8px; border-left: 3px solid var(--ev-bar); background: var(--ev-bg);
  color: var(--ev-fg); text-decoration: none; min-width: 0; }
.ot-body:hover { text-decoration: none; filter: brightness(0.98); }
.ot-time { font-size: 12.5px; font-variant-numeric: tabular-nums; opacity: 0.9; }
.ot-title { font-weight: 620; }
.ot-meta { font-size: 12.5px; opacity: 0.85; display: flex; flex-wrap: wrap; align-items: center; gap: 3px; min-width: 0; }
.ot-body .badge { align-self: flex-start; margin-top: 3px; }
.ot-item.is-conflict .ot-body { box-shadow: 0 0 0 2px var(--bad); }
.ot-item.is-free .ot-body { background: var(--surface); border: 1px dashed var(--ev-bar); border-left: 3px solid var(--ev-bar); }
.btn.block { width: 100%; }
.oacct { display: flex; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--border); }
.oacct-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--bad-soft); color: var(--bad); }
.oacct-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.oacct-main .badge { margin-left: auto; }
.oacct-stats { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; margin-top: 4px; }
.oacct-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.obg { display: flex; gap: 12px; align-items: flex-start; margin: 4px 14px 14px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--info-soft); border: 1px solid color-mix(in srgb, var(--info) 18%, transparent); flex-wrap: wrap; }
.obg-icon { color: var(--info); margin-top: 2px; }
.obg-icon.spinning svg { animation: spin 2.4s linear infinite; }
@media (prefers-reduced-motion: reduce) { .obg-icon.spinning svg { animation: none; } }
.obg-main { flex: 1; min-width: 180px; }
.obg-main p { margin: 2px 0 0; }
.obg .btn { align-self: flex-end; background: var(--surface); }
.oprog { display: flex; flex-direction: column; }
.oprog-row { display: grid; grid-template-columns: minmax(170px, 1.3fr) repeat(4, minmax(0, 1fr)) minmax(140px, 1fr); gap: 14px; align-items: center;
  padding: 12px 18px; border-top: 1px solid var(--border); }
.oprog-row:first-child { border-top: 0; }
.oprog-acct { display: flex; align-items: center; gap: 10px; min-width: 0; }
.oprog-phase { display: flex; align-items: center; gap: 8px; min-width: 0; }
.oprog-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.oprog-label { font-size: 12.5px; font-weight: 550; }
.oprog-total { display: flex; flex-direction: column; gap: 5px; }
@media (prefers-color-scheme: dark) {
  .ostat-icon.purple { background: #2a1f3a; color: #cfa2e4; }
}
@media (max-width: 1320px) {
  .ostats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ogrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .oprog-row { grid-template-columns: minmax(150px, 1fr) repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 920px) {
  .ohead h1 { font-size: 22px; }
  .ostats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .page-overview .main { padding-top: 16px; }
  .ohead { margin-bottom: 12px; gap: 10px; }
  .ohead-icon { display: none; }
  .ohead h1 { font-size: 21px; }
  .ohead .subtitle { font-size: 13px; }
  .ohead-side { width: 100%; }
  .ohead-date { margin-right: auto; font-size: 14px; }
  .ostats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
  .ostat { flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 10px 4px; min-height: 0; }
  .ostat-body { align-items: center; }
  .ostat-icon { width: 34px; height: 34px; }
  .ostat-value { font-size: 20px; }
  .ostat-label { font-size: 11px; line-height: 1.2; }
  .ostat-sub, .ostat-go { display: none; }
  .ostat-writing, .ostat-organize { display: none; }
  .ogrid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .osec-calendar { order: 1; } .osec-emails { order: 2; } .osec-insights { order: 3; } .osec-accounts { order: 4; }
  .osec-drafts { order: 5; } .osec-relationships { order: 6; }
  .oitem, .oacct { padding: 12px 14px; }
  .oitem-side { opacity: 1; flex-direction: row; position: absolute; right: 8px; bottom: 6px; }
  .olist .oitem { position: relative; padding-bottom: 40px; }
  .osec-emails .oitem-tags .chip { display: none; }
  .ocal { padding: 10px 14px 14px; }
  .oprog-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 12px 14px; }
  .oprog-acct, .oprog-total { grid-column: 1 / -1; }
}

.prompt-edit { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--border); padding-top: 14px; }
.prompt-edit:first-of-type { border-top: 0; padding-top: 0; }
.prompt-edit legend { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }

/* ------------------------------------------------------------------ inbox organization */
.org-mode { display: flex; gap: 6px; align-items: center; color: var(--text-2); margin: -8px 0 16px; }
.org-item { display: flex; gap: 12px; align-items: flex-start; padding: 14px 22px; border-top: 1px solid var(--border); min-width: 0; }
.list > .org-item:first-child { border-top: 0; }
.org-item.no-border { border-top: 0; padding: 0; }
.org-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.org-main .item-top { flex-wrap: wrap; }
.org-side { flex: none; }
.cat-chip { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.why { margin-top: 4px; }
.why > summary { display: inline-flex; gap: 5px; align-items: center; font-size: 12.5px; color: var(--text-2); }
.why > summary:hover { color: var(--text); }
.why-body { margin-top: 6px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
.why-body ul { margin: 2px 0 8px; }
.why-body p { margin: 0 0 4px; }
.org-panel { width: 320px; }
.org-menu .menu-panel { max-height: 70vh; overflow-y: auto; }
.cat-pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 10px; }
.cat-pick .check { font-size: 13px; }
.org-quick { display: flex; flex-wrap: wrap; gap: 2px; border-top: 1px solid var(--border); padding-top: 8px; }
.org-review { padding: 16px 22px; border-top: 1px solid var(--border); }
.list > .org-review:first-child { border-top: 0; }
.org-review-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0 48px; align-items: center; }
.org-rule { padding: 14px 22px; border-top: 1px solid var(--border); }
.list > .org-rule:first-child { border-top: 0; }
.org-rule .actions { flex: none; }
.org-rule .actions form { align-items: center; gap: 6px; }
.org-edit { margin-top: 8px; border-top: 0; }
.org-edit > summary { padding: 4px 0; font-size: 13px; }
.org-edit > .disclosure-body { padding: 8px 0 0; align-items: end; }
.dryrun { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.dist { list-style: none; margin: 0; padding: 14px 22px; display: flex; flex-direction: column; gap: 9px; }
.dist li { display: grid; grid-template-columns: 150px minmax(0, 1fr) 44px; gap: 12px; align-items: center; }
.dist-name { font-weight: 550; color: var(--text); }
.dist-n { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.org-cleanup { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; flex: none; }
.checklist { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.checklist li { display: flex; gap: 8px; align-items: center; color: var(--text-2); }
.checklist li.ok { color: var(--ok); }
.org-modes fieldset { display: flex; flex-direction: column; gap: 8px; }
.org-modes legend { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mode-opt { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.mode-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.mode-opt:has(input:disabled) { opacity: 0.6; }
.mode-opt .help { display: block; }
.cat-name { max-width: 240px; }
.meta-grid.flush { padding: 0; }
.org-filters select { width: auto; min-width: 180px; }
@media (max-width: 640px) {
  .org-item, .org-review, .org-rule { padding: 12px 14px; }
  .org-item { flex-wrap: wrap; }
  .org-side { width: 100%; padding-left: 48px; }
  .org-review-actions { margin-left: 0; }
  .org-panel { width: min(320px, 86vw); left: 0; right: auto; }
  .dist { padding: 12px 14px; }
  .dist li { grid-template-columns: 110px minmax(0, 1fr) 36px; }
  .org-cleanup { justify-content: flex-start; width: 100%; }
  .org-cleanup-item { flex-wrap: wrap; }
  .org-cleanup-item .item-main { flex-basis: calc(100% - 52px); }
  .card-header { flex-wrap: wrap; row-gap: 4px; }
  .org-rule .row.between { flex-direction: column; }
}

/* ------------------------------------------------------------------ phone tab bar */
.tabbar { display: none; }
@media (max-width: 640px) {
  .tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px; border-radius: 10px; color: var(--text-3);
    font-size: 11px; font-weight: 550; text-decoration: none; min-height: 48px; justify-content: center; }
  .tab:hover { text-decoration: none; color: var(--text); }
  .tab[aria-current="page"] { color: var(--accent); }
  .tab-icon { position: relative; display: grid; place-items: center; }
  .tab-icon svg.icon { width: 22px; height: 22px; }
  .tab-badge { position: absolute; top: -5px; right: -10px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px;
    background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; }
  body:not(.auth) .main-col { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
}

/* ------------------------------------------------------------------ assistant */
.main.main-chat { max-width: none; padding: 0; display: flex; min-height: 0; }
.page-assistant .main-col { height: 100vh; height: 100dvh; }
.history-toggle { position: absolute; opacity: 0; pointer-events: none; }
.chat-shell { flex: 1; display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 0; height: 100%; }
.chat-history { border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.chat-history-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 12px; }
.chat-history-head h2 { font-size: 14px; }
.conv-list { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; flex: 1; }
.conv-link { display: flex; flex-direction: column; gap: 1px; padding: 9px 10px; border-radius: 9px; color: var(--text); text-decoration: none; }
.conv-link:hover { background: var(--surface-3); text-decoration: none; }
.conv-link[aria-current="page"] { background: var(--accent-soft); }
.conv-title { font-weight: 550; font-size: 13.5px; }
.conv-meta { font-size: 12px; color: var(--text-3); }
.conv-empty { padding: 10px; color: var(--text-3); font-size: 13px; }
.chat-history-note { display: flex; gap: 6px; align-items: flex-start; padding: 12px 16px 16px; margin: 0; font-size: 12px; color: var(--text-3);
  border-top: 1px solid var(--border); }
.history-scrim { display: none; }
.history-btn { display: none; }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; }
.chat-header { display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--surface); }
.chat-mark { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.chat-heading { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-heading h1 { font-size: 16px; font-weight: 650; letter-spacing: 0; }
.model-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); }
.model-badge.ok svg { color: var(--ok); }
.model-badge.bad { color: var(--bad); }
.chat-header-actions { display: flex; align-items: center; gap: 4px; }
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 260px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.chat-scroll { flex: 1; overflow-y: auto; min-height: 0; padding: 24px 24px 12px; background: var(--bg); }
.chat-log { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.chat-welcome { max-width: 760px; margin: 0 auto; text-align: center; padding: 28px 0 8px; }
.welcome-icon { width: 52px; height: 52px; border-radius: 14px; display: inline-grid; place-items: center; background: var(--surface);
  border: 1px solid var(--border); color: var(--accent); margin-bottom: 14px; }
.welcome-icon svg.icon { width: 26px; height: 26px; }
.chat-welcome h2 { font-size: 22px; font-weight: 650; margin-bottom: 6px; }
.prompt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 24px; text-align: left; }
.prompt-form { display: flex; margin: 0; }
.prompt-card { flex: 1; position: relative; display: grid; grid-template-rows: auto auto 1fr; gap: 4px; padding: 16px 16px 14px; min-height: 108px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); color: var(--text); text-align: left;
  font: inherit; cursor: pointer; box-shadow: var(--shadow-sm); transition: border-color 0.12s, box-shadow 0.12s; }
.prompt-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.prompt-card:disabled { opacity: 0.6; cursor: progress; }
.prompt-icon { color: var(--text-2); margin-bottom: 6px; }
.prompt-title { font-weight: 620; }
.prompt-sub { color: var(--text-2); font-size: 13px; }
.prompt-go { position: absolute; right: 14px; bottom: 12px; color: var(--text-3); }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble { max-width: min(78%, 620px); background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: 16px 16px 4px 16px;
  white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.assistant { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; align-items: start; }
.msg-avatar { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.msg-avatar svg.icon { width: 17px; height: 17px; }
.msg-body { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.tool-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tool-chips[hidden] { display: none; }
.tool-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; background: var(--surface);
  border: 1px solid var(--border); color: var(--text-2); max-width: 100%; }
.tool-chip .tool-label { font-weight: 550; color: var(--text); white-space: nowrap; }
.tool-chip .tool-sum { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-chip.ok svg { color: var(--ok); }
.tool-chip.err { border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.tool-chip.err svg, .tool-chip.err .tool-sum { color: var(--bad); }
.tool-chip.running::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--accent); border-right-color: transparent;
  animation: spin 0.8s linear infinite; flex: none; }
.tool-chip.ok::before { content: "✓"; color: var(--ok); font-weight: 700; font-size: 12px; }
.tool-chip.ok:has(svg)::before { content: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.thinking { display: inline-flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 13px; margin: 0; }
.thinking[hidden] { display: none; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots i, .tool-chip.running::before { animation: none; } }
.md { background: var(--surface); border: 1px solid var(--border); border-radius: 4px 16px 16px 16px; padding: 12px 16px; line-height: 1.6; overflow-wrap: anywhere; }
.md:empty { display: none; }
.md p { margin: 0 0 8px; }
.md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 4px 0 8px; padding-left: 22px; }
.md li { margin: 2px 0; }
.md h3, .md h4 { margin: 10px 0 6px; font-size: 14px; text-transform: none; letter-spacing: 0; color: var(--text); }
.md pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 10px 0; }
.md-table-wrap { overflow-x: auto; margin: 6px 0; }
.md-table { border-collapse: collapse; font-size: 13px; }
.md-table th, .md-table td { border: 1px solid var(--border); padding: 5px 9px; text-align: left; vertical-align: top; }
.md-table th { background: var(--surface-2); font-weight: 600; }
.msg.is-error .md, .msg.is-cancelled .md { border-style: dashed; }
.msg-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--text-3); }
.msg-foot:empty { display: none; }
.msg-foot span { display: inline-flex; align-items: center; gap: 5px; }
.chat-sources { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2); padding: 10px; }
.chat-sources[hidden] { display: none; }
.sources-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-2); padding: 2px 4px 8px; flex-wrap: wrap; }
.sources-head .subtle { font-weight: 450; }
.sources-head svg { color: var(--ok); }
.ccards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 8px; }
.ccard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column;
  gap: 8px; min-width: 0; }
.ccard.draft-card, .ccard.schedule-card, .ccard-notice { grid-column: 1 / -1; }
.ccard.is-conflict { border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.ccard-top { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.ccard-main { flex: 1; min-width: 0; }
.ccard-title { font-weight: 600; }
.ccard-sub { color: var(--text-2); font-size: 13px; }
.ccard-time { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.ccard-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex: none; }
.ccard-icon.warn { background: var(--warn-soft); color: var(--warn); }
.ccard-text { margin: 0; color: var(--text-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ccard-text.full { display: block; -webkit-line-clamp: unset; }
.ccard-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ccard-meta .badge { white-space: normal; height: auto; min-height: 22px; padding: 2px 9px; line-height: 1.35; max-width: 100%; }
.ccard-link { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 550; margin-left: auto; }
.ccard-list { margin: 0; padding-left: 20px; font-size: 13px; }
.ccard-list.plain { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.draft-kv { font-size: 13px; }
.warn-text { color: var(--warn); margin: 0; }
.sched-day { padding: 8px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.sched-day:first-child { border-top: 0; padding-top: 0; }
.sched-head { display: flex; align-items: center; gap: 8px; }
.sched-events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.sched-events li { display: grid; grid-template-columns: 130px minmax(0, 1fr) minmax(0, 160px); gap: 10px; }
.sched-time { color: var(--text-2); font-variant-numeric: tabular-nums; }
.sched-acct { color: var(--text-3); font-size: 12px; text-align: right; }
.sched-conflict { color: var(--bad); margin: 0; }
.review-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.review-grid > div { display: flex; flex-direction: column; }
.review-grid .meta-label { font-size: 12px; color: var(--text-3); }
.review-grid .meta-value { font-size: 18px; font-weight: 650; }
.table.compact td, .table.compact th { padding: 6px 10px; }
.chat-busy { display: flex; gap: 6px; align-items: center; }
.composer { max-width: 820px; width: calc(100% - 48px); margin: 8px auto 0; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 16px; box-shadow: var(--shadow); padding: 10px 12px 8px; display: flex; flex-direction: column; gap: 6px; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea { border: 0; box-shadow: none; padding: 4px 4px; min-height: 28px; max-height: 200px; resize: none; background: transparent; }
.composer textarea:focus { box-shadow: none; }
.composer-bar { display: flex; align-items: center; gap: 8px; }
.scope-select { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 500; }
.scope-select select { height: 30px; width: auto; min-width: 0; max-width: 240px; border: 0; background: var(--surface-3); border-radius: 8px; padding: 0 26px 0 8px;
  font-size: 12.5px; color: var(--text); }
.composer-hint { flex: 1; text-align: right; font-size: 12px; color: var(--text-3); }
.send-btn, .stop-btn { border-radius: 50%; width: 34px; height: 34px; flex: none; }
.send-btn[hidden], .stop-btn[hidden] { display: none; }
.chat-disclaimer { display: flex; justify-content: center; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); margin: 6px 16px 12px;
  text-align: center; }
@media (max-width: 1180px) {
  .chat-shell { grid-template-columns: 236px minmax(0, 1fr); }
}
@media (max-width: 920px) {
  .main.main-chat { height: calc(100dvh - 56px); }
  .chat-shell { grid-template-columns: minmax(0, 1fr); position: relative; }
  .chat-history { position: fixed; z-index: 45; top: 0; bottom: 0; right: 0; width: min(86vw, 320px); transform: translateX(102%);
    transition: transform 0.2s ease; box-shadow: var(--shadow-lg); border-left: 1px solid var(--border); border-right: 0; }
  .history-toggle:checked ~ .chat-shell .chat-history { transform: none; }
  .history-toggle:checked ~ .chat-shell .history-scrim { display: block; position: fixed; inset: 0; z-index: 44; background: rgba(15, 20, 18, 0.35); }
  .history-toggle:focus-visible ~ .chat-shell .history-btn { outline: 2px solid var(--focus); outline-offset: 2px; }
  .history-btn { display: inline-flex; }
  .chat-header { padding: 10px 14px; }
  .chat-scroll { padding: 16px 14px 8px; }
  .composer { width: calc(100% - 24px); }
}
@media (max-width: 640px) {
  .page-assistant .main-col { padding-bottom: 0; }
  .main.main-chat { height: calc(100dvh - 56px - 68px - env(safe-area-inset-bottom)); }
  .prompt-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; margin-top: 18px; }
  .prompt-card { min-height: 0; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 12px; padding: 12px 40px 12px 14px; }
  .prompt-icon { grid-row: 1 / span 2; margin: 2px 0 0; }
  .chat-welcome { padding-top: 8px; }
  .chat-welcome h2 { font-size: 19px; }
  .composer-hint { display: none; }
  .scope-select { margin-right: auto; min-width: 0; }
  .scope-select select { max-width: 200px; }
  .chat-disclaimer { display: none; }
  .composer { margin-bottom: 8px; }
  .msg.assistant { grid-template-columns: minmax(0, 1fr); }
  .msg-avatar { display: none; }
  .msg.user .bubble { max-width: 88%; }
  .sched-events li { grid-template-columns: 104px minmax(0, 1fr); }
  .sched-acct { display: none; }
  .review-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media print { .sidebar, .topbar, .foot, .actions, form { display: none !important; } .app { display: block; } }
