/* LifeOS — dark mission control. No external fonts, system stack only. */

:root {
  --bg: #0a0e14;
  --bg-2: #0d121b;
  --card: #101620;
  --card-2: #141c2b;       /* slightly darker for cleaner contrast */
  --line: #2d3b50;         /* much lighter line border color for high contrast */
  --accent: #a3ff3b;       /* electric lime, slightly tweaked for brightness */
  --accent-dim: rgba(163, 255, 59, 0.4);
  --accent-faint: rgba(163, 255, 59, 0.12);
  --warm: #ffbe6a;         /* brighter warm orange */
  --warm-dim: rgba(255, 190, 106, 0.4);
  --text: #ffffff;         /* pure white text for maximum legibility */
  --muted: #cbd5e1;        /* slate 200 for extremely clear and readable secondary text */
  --danger: #ff6d7b;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "Cascadia Mono", Consolas, Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sidebar-w: 220px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  background:
    /* subtle grid */
    linear-gradient(rgba(157,255,46,.025) 1px, transparent 1px) 0 0 / 100% 36px,
    linear-gradient(90deg, rgba(157,255,46,.02) 1px, transparent 1px) 0 0 / 36px 100%,
    radial-gradient(1200px 600px at 70% -10%, #101a28 0%, var(--bg) 60%);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

/* scanline texture overlay */
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.012) 0 1px, transparent 1px 3px);
  z-index: 999;
}

/* ============ app shell ============ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; align-self: flex-start;
  width: var(--sidebar-w); height: 100vh; flex: none;
  display: flex; flex-direction: column;
  background: rgba(10, 14, 20, .92);
  border-right: 1px solid var(--line);
  padding: 14px 10px;
  z-index: 60;
}

.side-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px 16px;
  font-family: var(--mono); font-size: 19px; font-weight: 700; letter-spacing: 1px;
  text-shadow: 0 0 18px var(--accent-dim);
}
.side-logo .icon { width: 20px; height: 20px; }
.wordmark-text b { color: var(--accent); font-weight: 700; }

.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side-bottom { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%; text-align: left;
  font-family: var(--mono); font-size: 13.5px;
  background: transparent; color: var(--muted);
  border: 1px solid transparent; border-radius: 9px;
  padding: 10px 12px; cursor: pointer;
  transition: color .15s, background .15s, border-color .15s, box-shadow .15s;
}
.nav-item .icon { width: 17px; height: 17px; }
.nav-item:hover { color: var(--text); background: var(--accent-faint); }
.nav-item.active {
  color: var(--accent);
  background: var(--accent-faint);
  border-color: var(--accent-dim);
  box-shadow: 0 0 14px var(--accent-faint);
}

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ============ header ============ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 10px 24px;
  background: rgba(10, 14, 20, .88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.chip {
  font-family: var(--mono); font-size: 11px;
  padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--muted);
  white-space: nowrap;
}
.chip-accent {
  color: var(--accent); border-color: var(--accent-dim);
  box-shadow: 0 0 10px var(--accent-faint) inset, 0 0 8px var(--accent-faint);
}

.header-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.model-status { font-family: var(--mono); font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.dot.thinking { background: var(--warm); box-shadow: 0 0 8px var(--warm); animation: blink .7s 8; }
.dot.error { background: #e5534b; box-shadow: 0 0 8px #e5534b; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ============ layout / cards ============ */
main { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 24px 40px; flex: 1; }

.panel { display: none; gap: 18px; padding-top: 20px; grid-template-columns: 1fr 1fr; }
.panel.active { display: grid; }
#panel-chat.active { grid-template-columns: 1fr; }
#panel-health.active { grid-template-columns: 1fr 1fr; }

.card {
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 0 0 1px rgba(157,255,46,.04), 0 8px 30px rgba(0,0,0,.45);
  transition: border-color .2s, box-shadow .2s;
}
.card:hover { border-color: #28354a; }

.card h2 {
  margin: 0 0 14px;
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0 0 8px var(--accent-dim);
}

.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin: 10px 0; }
.muted { color: var(--muted); }
.empty-hint { color: var(--muted); font-size: 13px; font-style: italic; margin: 8px 0; }
.mono-inline { font-family: var(--mono); font-size: .92em; color: var(--accent); }

/* ============ buttons / inputs ============ */
.btn {
  font-family: var(--mono); font-size: 13px;
  padding: 8px 16px; border-radius: 8px; cursor: pointer;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line);
  transition: all .15s;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover:not(:disabled) { border-color: var(--accent-dim); color: var(--accent); box-shadow: 0 0 12px var(--accent-faint); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: var(--accent-faint); color: var(--accent);
  border-color: var(--accent-dim);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 0 18px var(--accent-dim); }
.btn-ghost { background: transparent; }
.btn-warn { color: var(--warm); border-color: var(--warm-dim); background: rgba(255,180,84,.06); }
.btn-warn:hover:not(:disabled) { box-shadow: 0 0 14px var(--warm-dim); color: var(--warm); border-color: var(--warm); }

/* spinner injected by JS into busy buttons */
.spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin .7s linear 40; /* finite on purpose — no infinite animations */
}
@keyframes spin { to { transform: rotate(360deg); } }

textarea, input[type="text"], input[type="number"], input[type="date"],
input[type="time"], input[type="month"], select {
  width: 100%;
  font-family: var(--mono); font-size: 13px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px;
  transition: border-color .15s, box-shadow .15s;
}
textarea:focus, input:focus, select:focus {
  outline: none; border-color: var(--accent-dim);
  box-shadow: 0 0 0 2px var(--accent-faint);
}
textarea { resize: vertical; }
input[type="date"], input[type="time"], input[type="month"] { color-scheme: dark; }

label { font-family: var(--mono); font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }

.form-row label { flex: 1; min-width: 130px; }
.form-row input[type="number"] { width: 110px; }

/* ============ dropzones ============ */
.dropzone {
  border: 1.5px dashed var(--line); border-radius: 10px;
  padding: 22px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
  margin-bottom: 10px;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent-dim); background: var(--accent-faint);
}
.dz-icon { font-size: 26px; }
.dz-inner p { margin: 6px 0 0; font-size: 13px; }

.or-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 12px 0; color: var(--muted);
  font-family: var(--mono); font-size: 11px;
}
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ============ deal chips ============ */
.deal-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.deal-chip {
  font-family: var(--mono); font-size: 12px;
  padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--accent-dim);
  background: var(--accent-faint); color: var(--text);
  animation: pop .2s ease-out;
}
.deal-chip b { color: var(--accent); font-weight: 600; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

/* ============ results / markdown ============ */
.result {
  margin-top: 12px; padding: 14px 16px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  min-height: 60px; font-size: 14px;
  overflow-wrap: break-word;
}
.md { line-height: 1.62; }
.md h1, .md h2, .md h3 { font-family: var(--mono); color: var(--accent); margin: 16px 0 7px; text-shadow: 0 0 8px var(--accent-dim); text-transform: none; letter-spacing: 0; }
.md h1 { font-size: 18px; } .md h2 { font-size: 16px; } .md h3 { font-size: 14px; }
.md h4.md-section {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--accent); margin: 15px 0 6px; padding-bottom: 4px;
  border-bottom: 1px solid var(--accent-faint); text-shadow: 0 0 8px var(--accent-dim);
}
.md h4.md-section:first-child { margin-top: 2px; }
.md > :first-child { margin-top: 2px; }
.md > :last-child { margin-bottom: 2px; }
.md p { margin: 9px 0; }
.md ul, .md ol { margin: 9px 0; padding-left: 24px; }
.md li { margin: 4px 0; }
.md li::marker { color: var(--accent); }
.md code {
  font-family: var(--mono); font-size: 12.5px;
  background: var(--card-2); border: 1px solid var(--line);
  padding: 1px 5px; border-radius: 4px; color: var(--warm);
}
.md pre.codeblock {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; overflow-x: auto; margin: 10px 0;
}
.md pre.codeblock code { background: none; border: none; padding: 0; color: var(--text); font-size: 12.5px; line-height: 1.55; }
.md blockquote {
  margin: 10px 0; padding: 8px 14px;
  border-left: 3px solid var(--accent-dim);
  background: var(--accent-faint); border-radius: 0 8px 8px 0;
  color: var(--text); font-style: italic;
}
.md hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.md strong { color: var(--accent); font-weight: 650; text-shadow: 0 0 8px var(--accent-dim); }
.md em { color: var(--warm); }
.md table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13px; }
.md th, .md td { border: 1px solid var(--line); padding: 7px 11px; text-align: left; }
.md th { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); background: var(--card-2); }
.md tbody tr:nth-child(even) { background: rgba(255,255,255,.025); }
.md details {
  margin: 8px 0; border: 1px dashed var(--line); border-radius: 8px; padding: 6px 10px;
  color: var(--muted); font-size: 13px;
}
.md details summary { cursor: pointer; font-family: var(--mono); font-size: 11px; color: var(--warm); }

/* streaming caret */
.streaming::after {
  content: "_"; color: var(--accent);
  animation: blink .8s 12;
}

/* ============ week strip ============ */
.week-strip { display: flex; gap: 8px; }
.day-box {
  flex: 1; aspect-ratio: 1 / 1.15; max-width: 86px;
  border: 1px solid var(--line); border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  background: var(--bg);
  transition: all .2s;
}
.day-box .abbr { font-size: 14px; font-weight: 700; }
.day-box.filled {
  border-color: var(--accent-dim); background: var(--accent-faint);
  color: var(--accent); box-shadow: 0 0 10px var(--accent-faint);
}
.day-box.today { border-style: solid; border-width: 2px; }
.legend { font-family: var(--mono); font-size: 11px; margin-top: 10px; }

/* ============ subscriptions table ============ */
.subs-table { border-collapse: collapse; width: 100%; margin-top: 12px; font-family: var(--mono); font-size: 12.5px; }
.subs-table th, .subs-table td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.subs-table th { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); background: var(--card-2); }
.subs-table td.num { color: var(--warm); text-align: right; }

/* ============ chat ============ */
.chat-card { display: flex; flex-direction: column; min-height: 70vh; }
.chat-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 6px 2px; max-height: 62vh; }

.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg.user { justify-content: flex-end; }
.msg .avatar {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-faint); border: 1px solid var(--accent-dim);
  color: var(--accent); box-shadow: 0 0 10px var(--accent-faint);
  margin-top: 2px;
}
.msg .avatar .icon { width: 15px; height: 15px; }

.bubble {
  max-width: 72ch; padding: 11px 15px; border-radius: 12px;
  font-size: 14px; animation: pop .15s ease-out;
  overflow-wrap: break-word; min-width: 0;
}
.bubble.user {
  max-width: 60%;
  background: var(--accent-faint); border: 1px solid var(--accent-dim);
  border-bottom-right-radius: 3px;
  white-space: pre-wrap;
}
.bubble.assistant {
  background: var(--card-2); border: 1px solid var(--line);
  border-bottom-left-radius: 3px;
}
.msg-refs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.msg-ref {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .5px;
  padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--accent-dim); color: var(--accent); background: rgba(157,255,46,.12);
}

/* greeting */
.chat-greeting { margin: auto; text-align: center; padding: 40px 12px; }
.greet-hello {
  font-size: 38px; font-weight: 700; letter-spacing: -.5px;
  background: linear-gradient(120deg, var(--accent), #5ecbff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 22px var(--accent-faint));
}
.greet-sub { color: var(--muted); font-size: 14px; margin-top: 8px; }

.example-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 8px; }
.chip-btn { cursor: pointer; transition: all .15s; }
.chip-btn:hover { color: var(--accent); border-color: var(--accent-dim); }
.chat-input-row { display: flex; gap: 10px; }
.chat-input-row input { flex: 1; }

/* domain ref chips */
.ref-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 10px; }
.ref-label { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.ref-chip {
  font-family: var(--mono); font-size: 12px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; cursor: pointer;
  background: var(--bg-2); color: var(--muted); border: 1px solid var(--line);
  transition: all .15s;
}
.ref-chip:hover { color: var(--text); border-color: var(--accent-dim); }
.ref-chip[aria-pressed="true"] {
  color: var(--accent); border-color: var(--accent-dim); background: var(--accent-faint);
  box-shadow: 0 0 10px var(--accent-faint);
}

/* ============ goals ============ */
.goals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.goal-card {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
  transition: border-color .2s, box-shadow .2s;
}
.goal-card:hover { border-color: var(--accent-dim); box-shadow: 0 0 14px var(--accent-faint); }
.goal-actions { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.goal-actions .btn { padding: 6px 11px; font-size: 12px; }

.goal-bar-wrap { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; height: 10px; overflow: hidden; margin: 8px 0; }
.goal-bar { height: 100%; background: var(--accent); box-shadow: 0 0 10px var(--accent-dim); border-radius: 999px; transition: width .3s; }
.goal-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.goal-title { font-family: var(--mono); font-size: 13px; color: var(--accent); }
.chat-list.mini { max-height: 280px; min-height: 110px; margin: 12px 0; }
.chat-list.mini .bubble { font-size: 13px; padding: 8px 12px; }
.chat-list.mini .avatar { width: 24px; height: 24px; }

/* ============ footer ============ */
footer {
  border-top: 1px solid var(--line);
  padding: 16px 24px; text-align: center;
}
footer .muted { font-size: 12px; font-family: var(--mono); margin: 0; }

/* ============ toasts ============ */
.toast-stack { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  font-family: var(--mono); font-size: 13px;
  padding: 10px 18px; border-radius: 8px;
  background: var(--card); border: 1px solid var(--danger);
  color: var(--danger); box-shadow: 0 8px 30px rgba(0,0,0,.5);
  animation: pop .2s ease-out;
}
.toast.ok { border-color: var(--accent-dim); color: var(--accent); }

/* ============ icons ============ */
.icon { width: 16px; height: 16px; vertical-align: -3px; flex: none; }
.icon-accent { color: var(--accent); }
.dz-icon { width: 28px; height: 28px; color: var(--muted); }

/* finite, accessible focus ring */
.btn:focus-visible, .nav-item:focus-visible, .toggle:focus-visible, .day-chip:focus-visible,
.seg:focus-visible, .ref-chip:focus-visible, .chip-btn:focus-visible,
textarea:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent-dim); outline-offset: 2px;
}

.span-2 { grid-column: 1 / -1; }

/* ============ chat toggles ============ */
.chat-toggles { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.toggle {
  font-family: var(--mono); font-size: 12px;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  background: var(--bg-2); color: var(--muted); border: 1px solid var(--line);
  transition: all .15s;
}
.toggle:hover { color: var(--text); }
.toggle .toggle-state { font-weight: 700; text-transform: uppercase; font-size: 10px; }
.toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent-dim); background: var(--accent-faint); }
.toggle-warn[aria-pressed="true"] { color: var(--warm); border-color: var(--warm-dim); background: rgba(255,180,84,.08); }
.toggle-note { font-size: 10px; color: var(--warm); opacity: .8; }
.mic-btn { padding: 8px 12px; }
.mic-btn.listening { color: var(--danger); border-color: var(--danger); box-shadow: 0 0 12px rgba(255,93,108,.3); }

/* ============ day chips (schedule) ============ */
.day-chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.day-chip {
  font-family: var(--mono); font-size: 12px; cursor: pointer;
  padding: 7px 12px; border-radius: 8px;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line);
  transition: all .15s;
}
.day-chip:hover { color: var(--text); border-color: var(--accent-dim); }
.day-chip.on { color: var(--accent); border-color: var(--accent-dim); background: var(--accent-faint); }

/* ============ calendar strip + events ============ */
.cal-strip { display: flex; gap: 8px; margin-bottom: 12px; }
.cal-day {
  flex: 1; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  padding: 8px 6px; text-align: center;
  font-family: var(--mono); font-size: 11px; color: var(--muted);
}
.cal-day.today { border-color: var(--accent-dim); }
.cal-day .cal-count { display: block; font-size: 15px; font-weight: 700; color: var(--text); }
.cal-day.has-events .cal-count { color: var(--accent); }
.event-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.event-row {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  padding: 7px 12px; font-size: 13px;
}
.event-row .ev-when { font-family: var(--mono); font-size: 11px; color: var(--warm); white-space: nowrap; }
.event-row .ev-title { flex: 1; }
.event-row .ev-kind { font-family: var(--mono); font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.event-row .btn { padding: 4px 8px; }

/* ============ workout log ============ */
.workout-log { display: flex; flex-direction: column; gap: 6px; }
.workout-log.scroll { max-height: 320px; overflow-y: auto; }
#workout-history-btn { margin-top: 10px; font-size: 12px; }
.workout-row {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  padding: 6px 12px; font-size: 13px;
}
.workout-row .wl-date { font-family: var(--mono); font-size: 11px; color: var(--warm); white-space: nowrap; }
.workout-row .wl-type { flex: 1; text-transform: capitalize; }
.workout-row .wl-dur { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.workout-row.head {
  background: var(--card-2); border-style: dashed;
  padding: 5px 12px;
}
.workout-row.head span { font-family: var(--mono); font-size: 10px; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; }

/* plain-language legend under data tables */
.table-legend { font-size: 11px; margin: 6px 2px 0; line-height: 1.5; }

/* ============ card head + calendar modal ============ */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h2 { margin: 0; }

.modal-overlay {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); padding: 24px;
}
.modal-overlay[hidden] { display: none !important; }
.modal {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.4); display: flex; flex-direction: column;
  max-height: 90vh; width: 100%;
}
.cal-modal { max-width: 960px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; }

.cal-grid { overflow: auto; padding: 0 0 12px; }
.calg-head { display: grid; grid-template-columns: 56px repeat(7, 1fr); position: sticky; top: 0; background: var(--card); z-index: 2; }
.calg-corner { border-bottom: 1px solid var(--line); }
.calg-dayhead {
  text-align: center; padding: 8px 2px; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 2px;
}
.calg-dayhead b { color: var(--text); font-size: 14px; }
.calg-dayhead.today { color: var(--warm); }
.calg-dayhead.today b { color: var(--warm); }
.calg-body { display: flex; }
.calg-gutter { width: 56px; flex: none; }
.calg-hour { font-family: var(--mono); font-size: 10px; color: var(--muted); text-align: right; padding-right: 6px; box-sizing: border-box; border-top: 1px solid transparent; }
.calg-cols { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); }
.calg-col { position: relative; border-left: 1px solid var(--line); }
.calg-slot { border-top: 1px solid var(--line); box-sizing: border-box; }
.calg-event {
  position: absolute; left: 3px; right: 3px; border-radius: 6px; border-left: 3px solid var(--warm);
  padding: 3px 6px; overflow: hidden; font-size: 11px; line-height: 1.25;
}
.calg-event b { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calg-event span { font-family: var(--mono); font-size: 9px; color: var(--muted); }

/* ============ free slots ============ */
.slot-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.slot-chip {
  font-family: var(--mono); font-size: 12px; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--warm-dim); background: rgba(255,180,84,.06); color: var(--warm);
}

/* ============ payments editor ============ */
.pay-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.pay-row input { flex: 1; }
.pay-row input.pay-amount, .pay-row input.pay-due { flex: 0 0 90px; }
.pay-row .btn { padding: 6px 9px; }
.pay-head {
  display: flex; gap: 8px; margin-bottom: 7px; padding: 0 2px;
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted);
}
.pay-head .ph-name { flex: 1; }
.pay-head .ph-amount, .pay-head .ph-due { flex: 0 0 90px; }
.pay-head .ph-del { flex: 0 0 33px; }
#pay-impact { margin-top: 12px; }

/* ============ profile ============ */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.online-note {
  font-family: var(--mono); font-size: 11px; color: var(--warm);
  display: flex; align-items: center; gap: 6px; margin: 6px 0 0;
}

/* ============ memory section ============ */
.seg-row { display: inline-flex; gap: 0; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; margin-bottom: 16px; }
.seg {
  font-family: var(--mono); font-size: 12.5px; cursor: pointer;
  padding: 8px 18px; background: var(--bg-2); color: var(--muted); border: none;
  transition: all .15s;
}
.seg + .seg { border-left: 1px solid var(--line); }
.seg:hover { color: var(--text); }
.seg.active { color: var(--accent); background: var(--accent-faint); }

.mem-rows { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.mem-row { display: flex; gap: 8px; align-items: center; }
.mem-row input { flex: 0 0 130px; }
.mem-row input.grow { flex: 1 1 160px; }
.mem-row input[type="number"] { flex: 0 0 95px; }
.mem-row input[type="time"] { flex: 0 0 100px; }
.mem-row .btn { padding: 6px 9px; flex: none; }

.notes-list { display: flex; flex-direction: column; gap: 10px; }
.note-row {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  padding: 11px 14px;
}
.note-kind {
  flex: none; font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  padding: 2px 9px; border-radius: 999px; margin-top: 2px;
  border: 1px solid var(--line); color: var(--muted);
}
.note-kind.kind-fact { color: var(--accent); border-color: var(--accent-dim); background: var(--accent-faint); }
.note-kind.kind-preference { color: var(--warm); border-color: var(--warm-dim); background: rgba(255,180,84,.07); }
.note-kind.kind-event { color: #5ecbff; border-color: rgba(94,203,255,.35); background: rgba(94,203,255,.07); }
.note-body { flex: 1; min-width: 0; }
.note-text { font-size: 13.5px; overflow-wrap: break-word; }
.note-edit { width: 100%; }
.note-actions { display: flex; gap: 6px; flex: none; }
.note-actions .btn { padding: 5px 8px; }

.danger-card { border-color: var(--warm-dim); }
.danger-card h2 { color: var(--warm); }

/* ============ settings ============ */
.settings-rows { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }

/* ============ ocr snippet ============ */
.ocr-label {
  font-family: var(--mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; margin: 10px 0 -2px;
}
.ocr-snippet {
  font-family: var(--mono); font-size: 12px; color: var(--text);
  background: var(--bg); border: 1px dashed var(--line); border-radius: 8px;
  padding: 10px 12px; margin: 10px 0; max-height: 160px; overflow: auto; white-space: pre-wrap;
}
.ocr-snippet ul { margin: 0; padding-left: 18px; list-style: disc; }
.ocr-snippet li { margin: 2px 0; }
.ocr-snippet p { margin: 0 0 4px; }
.ocr-snippet strong { color: var(--accent); }

/* ============ feature banner ============ */
.feature-banner {
  border: 1px dashed var(--warm-dim); border-radius: 8px; background: rgba(255,180,84,.05);
  color: var(--warm); font-family: var(--mono); font-size: 12px;
  padding: 9px 12px; margin: 8px 0;
}

/* ============ responsive ============ */
@media (max-width: 900px) {
  :root { --sidebar-w: 60px; }
  .sidebar { padding: 14px 8px; }
  .side-label { display: none; }
  .side-logo { justify-content: center; padding: 6px 0 16px; }
  .nav-item { justify-content: center; padding: 11px 0; }
  .panel.active, #panel-health.active { grid-template-columns: 1fr; }
  .header-right { margin-left: 0; }
  .bubble.user { max-width: 85%; }
}

@media (max-width: 560px) {
  main { padding: 0 12px 32px; }
  .topbar { padding: 8px 12px; }
  .mem-row { flex-wrap: wrap; }
}

/* ============ light mode overrides ============ */
body.light-mode {
  --bg: #f8fafc;
  --bg-2: #f1f5f9;
  --card: #ffffff;
  --card-2: #f8fafc;
  --line: #cbd5e1;
  --accent: #4f46e5;       /* indigo 600 */
  --accent-dim: rgba(79, 70, 229, 0.35);
  --accent-faint: rgba(79, 70, 229, 0.08);
  --warm: #d97706;         /* amber 600 */
  --warm-dim: rgba(217, 119, 6, 0.35);
  --text: #0f172a;         /* slate 900 */
  --muted: #475569;        /* slate 600 */
  --danger: #dc2626;       /* red 600 */
  
  background:
    linear-gradient(rgba(79, 70, 229, 0.02) 1px, transparent 1px) 0 0 / 100% 36px,
    linear-gradient(90deg, rgba(79, 70, 229, 0.015) 1px, transparent 1px) 0 0 / 36px 100%,
    radial-gradient(1200px 600px at 70% -10%, #e0e7ff 0%, var(--bg) 60%);
}

body.light-mode::after {
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.008) 0 1px, transparent 1px 3px);
}

body.light-mode .sidebar {
  background: rgba(255, 255, 255, .92);
}

body.light-mode .topbar {
  background: rgba(255, 255, 255, .88);
}

body.light-mode input[type="date"],
body.light-mode input[type="time"],
body.light-mode input[type="month"] {
  color-scheme: light;
}

body.light-mode .md tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, .025);
}

body.light-mode .card {
  box-shadow: 0 0 0 1px rgba(0,0,0,.03), 0 8px 30px rgba(0,0,0,.08);
}

body.light-mode .card:hover {
  border-color: var(--accent-dim);
}

body.light-mode .side-logo {
  text-shadow: 0 0 18px var(--accent-dim);
}

body.light-mode .greet-hello {
  background: linear-gradient(120deg, var(--accent), #2563eb);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 22px var(--accent-faint));
}

body.light-mode .card h2,
body.light-mode .md h1,
body.light-mode .md h2,
body.light-mode .md h3,
body.light-mode .md strong {
  text-shadow: none;
}
