:root {
  --bg: #FAF9F7;
  --surface: #FFFFFF;
  --surface-soft: #F3F0EA;
  --surface-hover: #ECE8DF;
  --border: #E8E3D9;
  --border-strong: #D6CFC3;
  --text: #1B1A18;
  --text-2: #4A4741;
  --muted: #7C776E;
  --ink: #1B1A18;
  --ink-text: #FAF9F7;
  --danger-bg: #FDECE9;
  --danger-fg: #C03E2E;
  --warn-bg: #FDF4E3;
  --warn-fg: #A86B14;
  --ok-bg: #E7F5EC;
  --ok-fg: #217847;
  --info-bg: #EAF1FC;
  --info-fg: #2B5CA8;
  --shadow-sm: 0 1px 2px rgba(27, 26, 24, 0.04);
  --shadow-md: 0 8px 28px rgba(27, 26, 24, 0.06);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: "Instrument Serif", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

[data-theme="dark"] {
  --bg: #0D0F14;
  --surface: #151821;
  --surface-soft: #1C202C;
  --surface-hover: #242938;
  --border: #252A38;
  --border-strong: #363D50;
  --text: #F2F0EB;
  --text-2: #C7C4BC;
  --muted: #8C90A1;
  --ink: #F2F0EB;
  --ink-text: #0D0F14;
  --danger-bg: #2E1818;
  --danger-fg: #F59489;
  --warn-bg: #2C2314;
  --warn-fg: #F2C36B;
  --ok-bg: #15291E;
  --ok-fg: #75D49B;
  --info-bg: #172336;
  --info-fg: #85B3FA;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 14px 36px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.mb-16 { margin-bottom: 16px; }
.serif-title { font-family: var(--font-serif); font-weight: 400; font-size: 2.15rem; line-height: 1.1; letter-spacing: -0.01em; }
.serif-h2 { font-family: var(--font-serif); font-weight: 400; font-size: 1.75rem; line-height: 1.15; }

/* Buttons & Inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-pill); border: 1px solid transparent;
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all 0.16s ease; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--ink); color: var(--ink-text); }
.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-soft { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-soft:hover { background: var(--surface-soft); border-color: var(--border-strong); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; padding: 11px 18px; }
.btn-link { background: none; border: none; color: var(--muted); font-weight: 600; font-size: 12.5px; cursor: pointer; }
.btn-link:hover { color: var(--text); }
.btn-icon {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; font-size: 15px; transition: all 0.15s ease;
}
.btn-icon:hover { background: var(--surface-soft); }
.icon-btn-xs {
  background: transparent; border: none; color: var(--text); cursor: pointer;
  padding: 3px 6px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
}
.icon-btn-xs:hover { background: var(--surface-hover); }

input, select, textarea {
  font-family: inherit; font-size: 13.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px; outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--border-strong); box-shadow: 0 0 0 3px rgba(27,26,24,0.06); }
.select-input { padding: 7px 11px; border-radius: var(--radius-pill); font-size: 12.5px; }
.select-sm { width: 100%; border-radius: 10px; }
.search-input { min-width: 220px; border-radius: var(--radius-pill); padding: 7px 14px; }
.textarea-input { width: 100%; resize: vertical; }

/* Login Screen */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(circle at 20% 20%, rgba(232,184,109,0.12), transparent 45%),
              radial-gradient(circle at 80% 80%, rgba(133,177,250,0.12), transparent 45%), var(--bg);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px; padding: 32px; box-shadow: var(--shadow-md);
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.brand-logo { width: 48px; height: 48px; border-radius: 14px; }
.brand-logo-sm { width: 34px; height: 34px; border-radius: 10px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.profile-pills { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pill-choice {
  padding: 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-soft);
  color: var(--text-2); font-weight: 600; cursor: pointer; transition: all 0.15s ease;
}
.pill-choice.active { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.form-error { padding: 9px 12px; border-radius: 10px; background: var(--danger-bg); color: var(--danger-fg); font-size: 12.5px; font-weight: 500; }
.login-footnote { margin-top: 18px; text-align: center; font-size: 12px; color: var(--muted); }

/* App Shell */
.app-shell {
  display: grid;
  grid-template-columns: 215px minmax(0, 1fr) 365px;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; justify-content: space-between;
}
.brand-row { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11.5px; color: var(--muted); }
.nav-list { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px;
  border-radius: 12px; border: none; background: transparent; color: var(--text-2);
  font-family: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; text-align: left;
  transition: all 0.14s ease;
}
.nav-item:hover { background: var(--surface-soft); color: var(--text); }
.nav-item.active { background: var(--surface-soft); color: var(--text); font-weight: 600; }
.nav-ico { width: 18px; text-align: center; opacity: 0.85; }
.nav-badge {
  margin-left: auto; background: var(--danger-bg); color: var(--danger-fg);
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: var(--radius-pill);
}
.nav-count { margin-left: auto; font-size: 11.5px; color: var(--muted); font-family: var(--font-mono); }
.sidebar-bottom { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--border); padding-top: 12px; }
.nav-logout { color: var(--muted); }
.mobile-chat-nav { display: none; }

/* Main Area */
.main-area { padding: 22px 26px 40px; min-width: 0; position: relative; }

.topbar {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 20px;
}
.briefing-pill {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 6px;
  padding: 5px 12px; border-radius: var(--radius-pill); background: var(--surface);
  border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); box-shadow: var(--shadow-sm);
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-ok { background: #2EA05E; }
.dot-warn { background: #D98A1B; }
.dot-err { background: #D64536; }

.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.focus-widget {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px;
  border-radius: var(--radius-pill); background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); font-size: 13px;
}
.focus-widget.running { border-color: #2E7D4F; background: var(--ok-bg); }

.music-popover {
  position: absolute; right: 26px; top: 78px; z-index: 50; width: 255px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 12px; box-shadow: var(--shadow-md); display: flex; flex-direction: column; gap: 6px;
}
.popover-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 2px 6px 4px; }
.music-link {
  text-decoration: none; color: var(--text); font-size: 13px; padding: 8px 10px;
  border-radius: 10px; transition: background 0.14s ease;
}
.music-link:hover { background: var(--surface-soft); }

/* KPI Strip */
.kpi-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; transition: transform 0.15s ease, border-color 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.kpi-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi-val { font-size: 1.65rem; font-weight: 600; margin-top: 4px; }
.kpi-urgent .kpi-val { color: var(--danger-fg); }
.kpi-week .kpi-val { color: var(--warn-fg); }
.kpi-exam .kpi-val { color: var(--info-fg); }
.kpi-files .kpi-val { color: var(--ok-fg); }

/* Bento Grid */
.bento-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 16px;
}
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.sub-head { font-size: 12.5px; font-weight: 700; color: var(--text-2); margin-bottom: 10px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* Chips */
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  padding: 5px 12px; border-radius: var(--radius-pill); border: 1px solid var(--border);
  background: var(--surface-soft); color: var(--text-2); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all 0.14s ease;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }

/* Task & Radar Items */
.item-stack, .file-stack, .task-list-full { display: flex; flex-direction: column; gap: 10px; }
.task-item {
  border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px;
  background: var(--bg); transition: border-color 0.14s ease, transform 0.14s ease;
}
.task-item:hover { border-color: var(--border-strong); }
.task-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.subj-tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px;
  border-radius: var(--radius-pill); font-size: 11.5px; font-weight: 600;
}
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 700;
}
.badge-critical { background: var(--danger-bg); color: var(--danger-fg); }
.badge-week { background: var(--warn-bg); color: var(--warn-fg); }
.badge-upcoming { background: var(--ok-bg); color: var(--ok-fg); }
.badge-exam { background: var(--info-bg); color: var(--info-fg); }
.badge-info { background: var(--surface-soft); color: var(--muted); }
.task-title { font-weight: 600; font-size: 13.5px; color: var(--text); margin-bottom: 4px; }
.task-excerpt { font-size: 12.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.status-pill {
  padding: 4px 10px; border-radius: var(--radius-pill); border: 1px solid var(--border);
  background: var(--surface); font-size: 11.5px; font-weight: 600; cursor: pointer; color: var(--text-2);
}
.status-pill[data-st="in_progress"] { background: var(--warn-bg); color: var(--warn-fg); border-color: transparent; }
.status-pill[data-st="reviewed"] { background: var(--info-bg); color: var(--info-fg); border-color: transparent; }
.status-pill[data-st="ready"] { background: var(--ok-bg); color: var(--ok-fg); border-color: transparent; }
.mini-act {
  font-size: 11.5px; font-weight: 600; color: var(--text-2); text-decoration: none;
  padding: 4px 9px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
}
.mini-act:hover { background: var(--surface-soft); color: var(--text); }

/* Subjects Mini Grid */
.subjects-mini-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.subj-mini-card {
  border-radius: 14px; padding: 11px 12px; cursor: pointer;
  border: 1px solid transparent; transition: transform 0.14s ease, box-shadow 0.14s ease;
  display: flex; flex-direction: column; justify-content: space-between; gap: 6px;
}
.subj-mini-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.subj-mini-name { font-weight: 700; font-size: 12.5px; line-height: 1.25; }
.subj-mini-prof { font-size: 11px; opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subj-mini-foot { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 600; opacity: 0.9; }

/* Subjects Full Directory */
.subjects-full-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.subj-full-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm); display: flex; flex-direction: column;
}
.subj-full-banner { padding: 14px 16px; }
.subj-full-title { font-weight: 700; font-size: 15px; }
.subj-full-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.prof-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.subj-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.subj-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }

/* Week Timeline */
.week-timeline { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.day-col {
  border: 1px solid var(--border); border-radius: 12px; padding: 8px 6px;
  text-align: center; background: var(--bg); min-height: 92px; display: flex; flex-direction: column; gap: 5px;
}
.day-col.today { border-color: var(--ink); background: var(--surface); }
.day-dow { font-size: 10.5px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.day-num { font-size: 15px; font-weight: 700; font-family: var(--font-mono); }
.day-dot-item {
  font-size: 10px; padding: 2px 4px; border-radius: 6px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; font-weight: 600; cursor: pointer;
}

/* PDF Files */
.file-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--border); border-radius: 13px; padding: 10px 12px; background: var(--bg);
}
.file-info { min-width: 0; }
.file-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 11.5px; color: var(--muted); }
.file-btns { display: flex; gap: 6px; flex-shrink: 0; }
.files-full-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.file-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow-sm);
}

/* Toolbar */
.section-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.toolbar-right { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Docked Chat Panel */
.chat-dock {
  position: sticky; top: 0; height: 100vh;
  background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.chat-widget { display: flex; flex-direction: column; height: 100%; }
.chat-head {
  padding: 16px 18px 12px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.chat-title { font-weight: 700; font-size: 15px; }
.chat-sub { font-size: 11.5px; color: var(--muted); }
.chat-controls { padding: 10px 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.mode-pills { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--surface-soft); padding: 3px; border-radius: 10px; }
.mode-pill {
  border: none; background: transparent; color: var(--muted); font-size: 11.5px; font-weight: 600;
  padding: 5px 4px; border-radius: 8px; cursor: pointer; transition: all 0.14s ease;
}
.mode-pill.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.attached-pill {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 5px 10px; border-radius: 10px; background: var(--info-bg); color: var(--info-fg);
  font-size: 11.5px; font-weight: 600;
}
.attached-pill button { background: none; border: none; color: inherit; font-size: 15px; cursor: pointer; }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px;
}
.msg-bubble {
  max-width: 92%; padding: 10px 13px; border-radius: 16px; font-size: 13px; line-height: 1.5;
  word-wrap: break-word;
}
.msg-user { align-self: flex-end; background: var(--ink); color: var(--ink-text); border-bottom-right-radius: 4px; }
.msg-bot { align-self: flex-start; background: var(--surface-soft); color: var(--text); border-bottom-left-radius: 4px; }
.msg-bot p { margin-bottom: 6px; }
.msg-bot p:last-child { margin-bottom: 0; }
.msg-bot ul, .msg-bot ol { padding-left: 18px; margin: 6px 0; }
.msg-bot code { font-family: var(--font-mono); font-size: 12px; background: var(--surface); padding: 1px 5px; border-radius: 5px; }
.msg-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.msg-link-btn {
  font-size: 11px; font-weight: 600; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); padding: 4px 8px;
  border-radius: 8px; cursor: pointer;
}
.msg-link-btn:hover { border-color: var(--border-strong); }

.chat-suggestions { padding: 6px 14px; display: flex; gap: 6px; overflow-x: auto; }
.sug-chip {
  flex-shrink: 0; font-size: 11.5px; font-weight: 500; padding: 5px 10px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--bg); color: var(--text-2); cursor: pointer;
}
.sug-chip:hover { background: var(--surface-soft); color: var(--text); }

.chat-input-bar {
  padding: 10px 12px 14px; border-top: 1px solid var(--border);
  display: flex; align-items: flex-end; gap: 8px;
}
.chat-input-bar textarea {
  flex: 1; border-radius: 14px; padding: 9px 12px; max-height: 110px; resize: none;
  background: var(--bg);
}
.btn-send {
  width: 36px; height: 36px; border-radius: 50%; border: none; background: var(--ink);
  color: var(--ink-text); font-size: 16px; font-weight: 700; cursor: pointer; flex-shrink: 0;
}
.btn-send:disabled { opacity: 0.4; cursor: default; }

/* Family & System */
.family-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.tg-quick-templates { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tg-form { display: flex; flex-direction: column; gap: 10px; }
.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tg-history, .crons-list, .runs-list { display: flex; flex-direction: column; gap: 8px; }
.sys-metrics-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.sys-box {
  background: var(--bg); border: 1px solid var(--border); border-radius: 13px; padding: 11px 13px;
}
.sys-box-lbl { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.sys-box-val { font-size: 15px; font-weight: 700; margin-top: 3px; font-family: var(--font-mono); }
.mini-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); font-size: 12px;
}

/* Modals */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(13, 15, 20, 0.58); backdrop-filter: blur(4px); }
.modal-panel {
  position: relative; z-index: 1; background: var(--surface); border: 1px solid var(--border);
  border-radius: 22px; box-shadow: var(--shadow-md); display: flex; flex-direction: column;
  max-height: 90vh; width: 100%; overflow: hidden;
}
.modal-sm { max-width: 440px; }
.modal-xl { max-width: 1020px; height: 86vh; }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.modal-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.modal-title { font-size: 15.5px; font-weight: 700; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.pdf-modal-body { padding: 0; flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.pdf-iframe { width: 100%; flex: 1; border: none; background: #2b2d30; }
.pdf-text-view {
  flex: 1; overflow-y: auto; padding: 20px; font-family: var(--font-sans);
  font-size: 13.5px; line-height: 1.65; white-space: pre-wrap; color: var(--text);
}

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: var(--ink); color: var(--ink-text); padding: 10px 18px; border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow-md);
}

/* Spinning Sync */
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.spinning { display: inline-block; animation: spin 1s linear infinite; }

/* Responsive */
.mobile-bottom-nav { display: none; }
.chat-full-mount { height: calc(100vh - 150px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

@media (max-width: 1220px) {
  .app-shell { grid-template-columns: 200px minmax(0, 1fr); }
  .chat-dock { display: none; }
  .mobile-chat-nav { display: flex; }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; padding-bottom: 72px; }
  .sidebar { display: none; }
  .main-area { padding: 16px 14px 24px; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .bento-grid, .family-grid { grid-template-columns: 1fr; }
  .week-timeline { grid-template-columns: repeat(7, minmax(44px, 1fr)); overflow-x: auto; }
  .mobile-bottom-nav {
    display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px env(safe-area-inset-bottom);
    z-index: 80;
  }
  .mnav-btn {
    display: flex; flex-direction: column; align-items: center; gap: 2px; border: none;
    background: none; color: var(--muted); padding: 4px 2px; cursor: pointer; font-size: 15px;
  }
  .mnav-btn small { font-size: 10px; font-weight: 600; }
  .mnav-btn.active { color: var(--text); }
}
