/* ==========================================================================
   Q's planner, web client. Redesign round 1 (Q, 2026-09-22, app msg 6352):
   "so sleek... not every thing needs to be visible at the same time... good
   use of space... clean modern tech design, slick animations... optimized for
   design aesthetic without being complex visually."

   The system, in one screen:
   - SURFACES. Near-black canvas, then two lifted layers (--surface, --surface-2)
     separated by 1px hairlines rather than by fill alone. Popovers and modals
     get the only real shadows.
   - TYPE. Geist for everything, Geist Mono for numbers, times and code. Three
     ink levels: --text, --text-2, --text-3. Sizes come from one short scale.
   - ACCENT. One indigo accent for "active / primary / yours". Amber only for
     "needs you". Red only for destructive or failing. Teal only in data marks.
   - MOTION. Short (140-320ms), eased out, and never on something Q is reading.
     Everything is switched off under prefers-reduced-motion.
   - DENSITY. Power-user layout: the rail is icons, the thread list collapses,
     secondary controls appear on hover, details live behind a click.
   ========================================================================== */

@font-face { font-family: 'Geist'; src: url('/web/static/fonts/Geist-Variable.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Geist Mono'; src: url('/web/static/fonts/GeistMono-Variable.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }

:root {
  color-scheme: dark;
  --bg: #09090b;
  --bg-2: #0d0d10;
  --surface: #131317;
  --surface-2: #1a1a20;
  --surface-3: #22222a;
  --sunken: #070709;
  --line: rgba(255, 255, 255, 0.065);
  --line-2: rgba(255, 255, 255, 0.11);
  --line-3: rgba(255, 255, 255, 0.18);
  --text: #ececf1;
  --text-2: #a0a0ab;
  --text-3: #686873;
  --accent: #8b8eff;
  --accent-2: #a9abff;
  --accent-soft: rgba(139, 142, 255, 0.14);
  --accent-line: rgba(139, 142, 255, 0.38);
  --teal: #5eead4;
  --warn: #f5b64a;
  --warn-soft: rgba(245, 182, 74, 0.13);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.12);
  --ok: #4ade80;

  --radius-sm: 7px;
  --radius: 11px;
  --radius-lg: 16px;
  --shadow-pop: 0 24px 64px -16px rgba(0, 0, 0, 0.7), 0 0 0 1px var(--line-2);
  --ease: cubic-bezier(0.22, 0.9, 0.24, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.5, 1);

  --fs-xs: 11px;
  --fs-sm: 12.5px;
  --fs: 14px;
  --fs-md: 15px;
  --fs-lg: 20px;
  --fs-xl: 28px;

  --rail-w: 60px;
  --sidebar-w: 268px;
  --font: 'Geist', ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Aliases read by terminal.js (xterm theme) and older inline styles. */
  --paper: var(--bg);
  --ink: var(--text);
  --coral: var(--accent);
  --muted: var(--text-2);
  --hairline: var(--line-2);
}

/* ------------------------------------------------------------------ base -- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
::selection { background: rgba(139, 142, 255, 0.32); }
.hidden, [hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
.muted { color: var(--text-2); }
.mono { font-family: var(--mono); }
a { color: var(--accent-2); }

* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.12) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.2); }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:disabled { cursor: default; opacity: 0.5; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: 2px;
}
input, select, textarea { font: inherit; color: inherit; }

.ic {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ------------------------------------------------------------- primitives -- */
.icon-btn {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  color: var(--text-2);
  transition: background 0.16s var(--ease), color 0.16s var(--ease), transform 0.16s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn-sm { width: 26px; height: 26px; }
.icon-btn-sm .ic { width: 15px; height: 15px; }

.chip-btn, button.linklike {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: var(--fs-sm);
  color: var(--text-2);
  border: 1px solid var(--line);
  background: transparent;
  transition: background 0.16s var(--ease), color 0.16s var(--ease), border-color 0.16s var(--ease);
  white-space: nowrap;
}
.chip-btn .ic { width: 14px; height: 14px; }
.chip-btn:hover, button.linklike:hover { color: var(--text); background: var(--surface-2); border-color: var(--line-2); }
button.linklike[aria-pressed="true"] { color: var(--accent-2); border-color: var(--accent-line); background: var(--accent-soft); }

.btn-primary, .task-actions button, .reading-actions button, #reading-note-submit {
  height: 34px;
  padding: 0 14px;
  border-radius: 9px;
  background: var(--text);
  color: #0b0b0e;
  font-weight: 560;
  font-size: var(--fs-sm);
  transition: transform 0.14s var(--ease), background 0.16s var(--ease), opacity 0.16s;
}
.btn-primary:hover, .task-actions button:hover, .reading-actions button:hover, #reading-note-submit:hover { background: #fff; }
.btn-primary:active, .task-actions button:active, .reading-actions button:active, #reading-note-submit:active { transform: scale(0.97); }
.btn-secondary, .task-actions button.secondary, #clean-btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  color: var(--text);
  font-weight: 500;
  font-size: var(--fs-sm);
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease), transform 0.14s var(--ease);
}
.btn-secondary:hover, .task-actions button.secondary:hover, #clean-btn:hover { background: var(--surface-3); border-color: var(--line-3); }
.task-actions button.task-remove { color: var(--danger); background: transparent; border-color: transparent; margin-left: auto; }
.task-actions button.task-remove:hover { background: var(--danger-soft); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-title { font-size: var(--fs-sm); font-weight: 560; color: var(--text-2); letter-spacing: 0; }
.card-count { font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-3); }

.tag-chip {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  font-size: var(--fs-sm);
  color: var(--text-2);
  transition: all 0.16s var(--ease);
}
.tag-chip:hover { color: var(--text); border-color: var(--line-3); }
.tag-chip.picked { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-2); }

.filter-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.filter-btn {
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: var(--fs-sm);
  color: var(--text-2);
  border: 1px solid transparent;
  transition: all 0.16s var(--ease);
}
.filter-btn:hover { color: var(--text); background: var(--surface-2); }
.filter-btn.active { color: var(--text); background: var(--surface-2); border-color: var(--line-2); }

/* Segmented control with a gliding thumb (positioned by app.js). */
.segmented {
  position: relative;
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 0;
}
.segmented .filter-btn {
  position: relative;
  z-index: 1;
  height: 28px;
  border-radius: 7px;
  border: 0;
  background: none;
  padding: 0 13px;
}
.segmented .filter-btn.active { background: none; }
.seg-glider {
  position: absolute;
  z-index: 0;
  top: 3px;
  bottom: 3px;
  left: 0;
  width: 0;
  border-radius: 7px;
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--line-2), 0 1px 2px rgba(0, 0, 0, 0.4);
  transition: transform 0.28s var(--ease), width 0.28s var(--ease);
}

.task-check {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  flex: none;
  margin: 2px 0 0;
  border-radius: 5px;
  border: 1.5px solid var(--line-3);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.18s var(--ease-spring);
}
.task-check:hover { border-color: var(--text-2); }
.task-check::after {
  content: '';
  width: 8px;
  height: 4px;
  border-left: 2px solid #0b0b0e;
  border-bottom: 2px solid #0b0b0e;
  transform: translateY(-1px) rotate(-45deg) scale(0);
  transition: transform 0.2s var(--ease-spring);
}
.task-check:checked { background: var(--accent); border-color: var(--accent); }
.task-check:checked::after { transform: translateY(-1px) rotate(-45deg) scale(1); }
.task-check:active { transform: scale(0.88); }

/* ------------------------------------------------------------- brand mark -- */
/* The app icon (golden thread on dark grey), same as iOS and the favicon. */
.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: #1b1b1d url('icon-mark.svg?v=38') center / cover no-repeat;
}
.brand-mark-lg { width: 44px; height: 44px; border-radius: 13px; }

/* ------------------------------------------------------------------ login -- */
#login-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  overflow: hidden;
}
.login-glow {
  position: absolute;
  width: 720px;
  height: 720px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(139, 142, 255, 0.16), rgba(94, 234, 212, 0.05) 55%, transparent 72%);
  filter: blur(20px);
  animation: breathe 8s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { transform: scale(0.94); opacity: 0.8; } 50% { transform: scale(1.04); opacity: 1; } }
#login-form {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  animation: rise 0.6s var(--ease) both;
}
.login-field {
  display: flex;
  align-items: center;
  width: min(340px, 84vw);
  height: 48px;
  padding: 0 6px 0 16px;
  background: rgba(19, 19, 23, 0.8);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  backdrop-filter: blur(12px);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.login-field:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 4px rgba(139, 142, 255, 0.1); }
#login-password {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: none;
  border: 0;
  outline: none;
  font-size: var(--fs-md);
  letter-spacing: 0.12em;
}
#login-password::placeholder { letter-spacing: 0.02em; color: var(--text-3); }
#login-submit {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--text);
  color: #0b0b0e;
  transition: transform 0.16s var(--ease), background 0.16s;
}
#login-submit:hover { background: #fff; transform: translateX(1px); }
#login-form.shake .login-field { animation: shake 0.42s var(--ease); border-color: rgba(255, 107, 107, 0.5); }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ shell -- */
#app-shell { display: none; }
#app-shell.active {
  display: grid;
  grid-template-columns: var(--rail-w) auto minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  animation: fadeIn 0.4s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* The rail */
nav.tabs {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 0 12px;
  background: var(--bg);
  border-right: 1px solid var(--line);
  z-index: 20;
}
nav.tabs .brand-mark { margin-bottom: 14px; }
nav.tabs > button {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: var(--text-3);
  transition: color 0.18s var(--ease), background 0.18s var(--ease);
}
nav.tabs > button .ic { width: 19px; height: 19px; transition: transform 0.24s var(--ease-spring); }
nav.tabs > button:hover { color: var(--text); background: var(--surface); }
nav.tabs > button:active .ic { transform: scale(0.9); }
nav.tabs > button.active { color: var(--text); background: var(--surface-2); }
nav.tabs > button[data-tab]::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  width: 3px;
  height: 18px;
  margin-top: -9px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  transform: scaleY(0);
  transition: transform 0.26s var(--ease);
}
nav.tabs > button[data-tab].active::before { transform: scaleY(1); }
/* Hover label: a small flyout, not a tooltip-for-beginners, just the name. */
nav.tabs > button::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translate(-4px, -50%);
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.14s var(--ease), transform 0.14s var(--ease);
  transition-delay: 0s;
}
nav.tabs > button:hover::after { opacity: 1; transform: translate(0, -50%); transition-delay: 0.35s; }
.rail-spacer { flex: 1; }
.rail-util { color: var(--text-3); }

/* Threads sidebar */
#conv-sidebar {
  grid-column: 2;
  width: var(--sidebar-w);
  overflow: hidden;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transition: width 0.3s var(--ease), opacity 0.2s var(--ease);
}
#app-shell:not([data-tab="chat"]) #conv-sidebar { width: 0; opacity: 0; border-right-width: 0; }
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 10px 0 18px;
  flex: none;
  min-width: var(--sidebar-w);
}
.sidebar-title { font-size: var(--fs-sm); font-weight: 560; color: var(--text-2); }
#conv-rail {
  flex: 1;
  min-width: var(--sidebar-w);
  overflow-y: auto;
  padding: 2px 8px 16px;
}
.conv-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border-radius: 9px;
  text-align: left;
  color: var(--text-2);
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.conv-row:hover { background: var(--surface); color: var(--text); }
.conv-row.active { background: var(--surface-2); color: var(--text); }
.conv-row.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.conv-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs); }
.conv-time { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); flex: none; }
.conv-dot {
  position: relative;
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--line-2);
  transition: background 0.2s var(--ease);
}
.conv-dot.unread { background: var(--accent); box-shadow: 0 0 10px rgba(139, 142, 255, 0.6); }
.conv-dot.working { background: var(--teal); box-shadow: none; }
.conv-dot.working::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px solid var(--teal);
  animation: ping 1.6s var(--ease) infinite;
}
.conv-dot.needs-input { background: var(--warn); box-shadow: 0 0 12px rgba(245, 182, 74, 0.7); }
.conv-row.needs-input .conv-name { color: var(--text); }
.conv-reason {
  margin: -4px 0 4px 27px;
  font-size: var(--fs-xs);
  color: var(--warn);
  font-weight: 500;
}
@keyframes ping { 0% { transform: scale(0.6); opacity: 0.9; } 100% { transform: scale(1.7); opacity: 0; } }
@keyframes rowIn { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: none; } }
#drawer-scrim { display: none; }

/* Main view + panel transitions */
main.view {
  grid-column: 3;
  position: relative;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}
.view-panel {
  display: none;
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 28px clamp(20px, 3.4vw, 48px) 48px;
}
.view-panel.active { display: block; animation: panelIn 0.34s var(--ease) both; }
@keyframes panelIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 4px 0 22px;
}
.panel-eyebrow {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 4px;
  min-height: 16px;
}
.panel-title { font-size: var(--fs-xl); font-weight: 620; letter-spacing: -0.03em; line-height: 1.1; }
.panel-tools { display: flex; align-items: center; gap: 10px; }

/* ------------------------------------------------------------ approval ---- */
#approval-banner {
  /* Just under the 56px top bars, so it never sits on their controls. */
  position: fixed;
  top: 66px;
  left: 50%;
  z-index: 80;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(760px, calc(100vw - 32px));
  padding: 8px 8px 8px 14px;
  background: rgba(28, 24, 16, 0.92);
  border: 1px solid rgba(245, 182, 74, 0.35);
  border-radius: 14px;
  box-shadow: 0 16px 48px -12px rgba(0, 0, 0, 0.7), 0 0 30px -10px rgba(245, 182, 74, 0.35);
  backdrop-filter: blur(14px);
  animation: dropIn 0.42s var(--ease-spring) both;
}
@keyframes riseIn { from { opacity: 0; transform: translate(-50%, 16px) scale(0.97); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes dropIn { from { opacity: 0; transform: translate(-50%, -16px) scale(0.97); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
.approval-banner-icon { color: var(--warn); }
#approval-banner-text {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: var(--fs-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.approval-banner-actions { display: flex; gap: 6px; flex: none; }
.approval-btn {
  height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: var(--fs-sm);
  font-weight: 560;
  transition: background 0.16s, transform 0.14s var(--ease);
}
.approval-btn:active { transform: scale(0.96); }
.approval-btn-approve { background: var(--warn); color: #1a1205; }
.approval-btn-approve:hover { background: #ffc766; }
.approval-btn-always { background: rgba(245, 182, 74, 0.14); color: var(--warn); }
.approval-btn-always:hover { background: rgba(245, 182, 74, 0.22); }
.approval-btn-deny { color: var(--text-2); }
.approval-btn-deny:hover { background: var(--surface-2); color: var(--text); }

/* ================================================================== CHAT == */
#chat-panel { padding: 0; }
#chat-panel.active { display: flex; flex-direction: column; }
#chat-panel::before {
  /* A faint top glow: gives the canvas depth without adding a surface. */
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 320px;
  background: radial-gradient(ellipse 60% 100% at 50% 0%, rgba(139, 142, 255, 0.06), transparent 70%);
  pointer-events: none;
}
.chat-topbar {
  position: relative;
  z-index: 2;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 14px 0 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 9, 11, 0.72);
  backdrop-filter: blur(14px);
}
.chat-heading { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.chat-title {
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: titleIn 0.3s var(--ease);
}
@keyframes titleIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.topbar-tools { display: flex; align-items: center; gap: 6px; }

#chat-log, #reading-chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 28px max(20px, calc((100% - 780px) / 2)) 20px;
  scroll-behavior: auto;
}
#load-older, #reading-load-older {
  display: block;
  margin: 0 auto 22px;
  height: 28px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  font-size: var(--fs-xs);
  color: var(--text-2);
  transition: all 0.16s var(--ease);
}
#load-older:hover, #reading-load-older:hover { color: var(--text); background: var(--surface); }

.msg {
  position: relative;
  margin: 0 0 22px;
  animation: msgIn 0.36s var(--ease) both;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg.user {
  margin-left: auto;
  width: fit-content;
  max-width: min(78%, 620px);
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 18px 18px 6px 18px;
}
.msg.assistant {
  padding-left: 22px;
  color: #dcdce3;
}
.msg.assistant::before {
  /* The agent's mark: a small gradient pip where an avatar would be. */
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 3px;
  background: linear-gradient(135deg, #a5a8ff, #5eead4);
  opacity: 0.85;
}
.msg .ts {
  position: absolute;
  bottom: -17px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-3);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
  white-space: nowrap;
}
.msg.user .ts { right: 6px; }
.msg.assistant .ts { left: 22px; }
.msg:hover .ts { opacity: 1; }

.msg-text { font-size: var(--fs); line-height: 1.62; overflow-wrap: anywhere; }
.msg-text > *:first-child { margin-top: 0; }
.msg-text > *:last-child { margin-bottom: 0; }
.msg-text p { margin: 0 0 0.7em; }
.msg-text h1, .msg-text h2, .msg-text h3, .msg-text h4, .msg-text h5, .msg-text h6 { margin: 1.1em 0 0.45em; line-height: 1.3; letter-spacing: -0.01em; }
.msg-text h1 { font-size: 1.3em; }
.msg-text h2 { font-size: 1.15em; }
.msg-text h3 { font-size: 1.04em; }
.msg-text h4, .msg-text h5, .msg-text h6 { font-size: 1em; color: var(--text-2); }
.msg-text ul, .msg-text ol { margin: 0 0 0.7em; padding-left: 1.3em; }
.msg-text li { margin: 0.2em 0; }
.msg-text li::marker { color: var(--text-3); }
.msg-text li > ul, .msg-text li > ol { margin: 0.2em 0 0; }
.msg-text a { color: var(--accent-2); text-decoration: none; border-bottom: 1px solid var(--accent-line); transition: border-color 0.16s; }
.msg-text a:hover { border-bottom-color: var(--accent-2); }
.msg-text strong { color: var(--text); font-weight: 620; }
.msg-text code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 0.12em 0.4em;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
}
.msg-text pre {
  margin: 0.4em 0 0.9em;
  padding: 12px 14px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
}
.msg-text pre code { padding: 0; background: none; border: 0; font-size: 12.5px; line-height: 1.55; }
.msg-text blockquote { margin: 0 0 0.7em; padding: 2px 0 2px 14px; border-left: 2px solid var(--line-3); color: var(--text-2); }
.msg-text hr { border: 0; border-top: 1px solid var(--line-2); margin: 1.2em 0; }
.msg-text table { border-collapse: collapse; margin: 0.4em 0 0.9em; font-size: 0.93em; display: block; overflow-x: auto; }
.msg-text th, .msg-text td { border: 1px solid var(--line-2); padding: 6px 10px; text-align: left; vertical-align: top; }
.msg-text th { background: var(--surface); font-weight: 580; }
.msg-text img { max-width: 100%; border-radius: 8px; }
.msg-attachment {
  display: block;
  max-width: min(360px, 66vw);
  max-height: 360px;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin-bottom: 8px;
}
.msg-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  color: var(--text);
  text-decoration: none;
  font-size: var(--fs-sm);
  transition: border-color 0.16s;
}
.msg-file:hover { border-color: var(--accent-line); }
/* Several files on one message (task queue #65): photos tile, files wrap. */
.msg-attachments { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin-bottom: 8px; max-width: min(560px, 80vw); }
.msg.user .msg-attachments { justify-content: flex-end; }
.msg-attachments .msg-attachment { margin-bottom: 0; max-width: 176px; max-height: 176px; object-fit: cover; }
.msg-attachments .msg-file { margin-bottom: 0; }
.msg-file .ic { width: 15px; height: 15px; color: var(--accent-2); }
.attach-chip-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 7px; background: var(--surface-2); color: var(--accent-2); }

/* The composer dock: indicator, attachment + voice status, then the box. */
.composer-dock {
  position: relative;
  z-index: 2;
  flex: none;
  padding: 0 max(16px, calc((100% - 812px) / 2)) 18px;
}
#thinking-indicator, #reading-thinking {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 10px 6px;
  font-size: var(--fs-sm);
  color: var(--text-2);
  animation: rise 0.3s var(--ease) both;
}
.working-dot {
  position: relative;
  width: 14px;
  height: 14px;
  flex: none;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 25%, var(--teal) 60%, var(--accent) 100%);
  -webkit-mask: radial-gradient(circle, transparent 3.5px, #000 4px);
  mask: radial-gradient(circle, transparent 3.5px, #000 4px);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#thinking-text, #reading-thinking-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: linear-gradient(90deg, var(--text-2) 0%, var(--text) 50%, var(--text-2) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 2.2s linear infinite;
}
#thinking-indicator.has-note #thinking-text, #reading-thinking.has-note #reading-thinking-text { font-family: var(--mono); font-size: 12px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

#voice-status {
  margin: 0 0 10px 6px;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--teal);
  animation: rise 0.3s var(--ease) both;
}
#reading-chat-error { margin: 0 0 10px 6px; font-size: var(--fs-sm); color: var(--danger); }

#attach-preview { margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 8px; }
#attach-preview.sending .attach-chip { opacity: 0.55; }
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 6px 6px 6px 8px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  font-size: var(--fs-sm);
  animation: popIn 0.28s var(--ease-spring) both;
}
.attach-chip img { width: 36px; height: 36px; object-fit: cover; border-radius: 7px; }
.attach-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip-remove {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1;
}
.attach-chip-remove:hover { background: var(--surface-3); color: var(--text); }
@keyframes popIn { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }

#chat-compose, #reading-compose {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 40px -16px rgba(0, 0, 0, 0.7);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s;
}
#chat-compose:focus-within, #reading-compose:focus-within {
  border-color: var(--line-3);
  box-shadow: 0 10px 40px -16px rgba(0, 0, 0, 0.7), 0 0 0 4px rgba(139, 142, 255, 0.07);
}
#chat-compose textarea, #reading-compose textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  max-height: 40vh;
  resize: none;
  padding: 14px 16px 4px;
  background: none;
  border: 0;
  outline: none;
  font-size: var(--fs);
  line-height: 1.55;
}
#chat-compose textarea::placeholder, #reading-compose textarea::placeholder { color: var(--text-3); }
.compose-row { display: flex; align-items: center; gap: 2px; padding: 4px 8px 8px; }
.compose-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--text-3);
  transition: color 0.16s, background 0.16s, transform 0.14s var(--ease);
}
.compose-btn:hover { color: var(--text); background: var(--surface-2); }
.compose-btn:active { transform: scale(0.92); }
.compose-spacer { flex: 1; }
#chat-send, #reading-chat-send {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--text-3);
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.16s var(--ease), box-shadow 0.2s;
}
#chat-send .ic, #reading-chat-send .ic { width: 17px; height: 17px; stroke-width: 2; }
/* The send button wakes up once there is something to send. */
#chat-compose:has(#chat-input:not(:placeholder-shown)) #chat-send,
#chat-panel:has(#attach-preview:not(.hidden)) #chat-send,
#reading-compose:has(#reading-chat-input:not(:placeholder-shown)) #reading-chat-send {
  background: var(--accent);
  color: #0b0b12;
  box-shadow: 0 4px 16px -4px rgba(139, 142, 255, 0.6);
}
#chat-send:hover, #reading-chat-send:hover { transform: translateY(-1px); }
#chat-send:active, #reading-chat-send:active { transform: scale(0.92); }
#chat-send:disabled, #reading-chat-send:disabled { opacity: 0.5; }

#voice-btn.voice-live {
  color: #0b0b12;
  background: var(--teal);
  box-shadow: 0 0 0 0 rgba(94, 234, 212, 0.5);
  animation: livePulse 1.8s var(--ease) infinite;
}
@keyframes livePulse { 0% { box-shadow: 0 0 0 0 rgba(94, 234, 212, 0.45); } 100% { box-shadow: 0 0 0 10px rgba(94, 234, 212, 0); } }
#voice-mute-btn .mute-slash { opacity: 0; transition: opacity 0.16s; }
#voice-mute-btn.voice-muted { color: var(--danger); }
#voice-mute-btn.voice-muted .mute-slash { opacity: 1; }

#chat-panel.dragover::after {
  content: 'Drop to attach';
  position: absolute;
  inset: 12px;
  z-index: 10;
  display: grid;
  place-items: center;
  border: 1.5px dashed var(--accent-line);
  border-radius: var(--radius-lg);
  background: rgba(139, 142, 255, 0.06);
  backdrop-filter: blur(4px);
  color: var(--accent-2);
  font-weight: 560;
  animation: fadeIn 0.18s var(--ease);
}

/* ------------------------------------------------------------ usage chip -- */
.usage-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 30px;
  padding: 0 10px 0 8px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(19, 19, 23, 0.7);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-2);
  white-space: nowrap;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease), color 0.18s;
}
.usage-chip:hover, .usage-chip[aria-expanded="true"] { border-color: var(--line-3); background: var(--surface-2); color: var(--text); }
.usage-chip:empty { width: 86px; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.6s linear infinite; }
.usage-acct {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  color: #0b0b12;
  background: linear-gradient(135deg, #a5a8ff, #5eead4);
}
.usage-acct.acct-secondary { background: linear-gradient(135deg, #f5b64a, #ff8a65); }
.usage-acct.acct-tertiary { background: linear-gradient(135deg, #5eead4, #4ade80); }
.usage-pct { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.usage-reset { color: var(--text-2); font-variant-numeric: tabular-nums; }
.usage-bar {
  display: block;
  width: 46px;
  height: 5px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
}
.usage-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--teal));
  transition: width 0.5s var(--ease);
}
.usage-bar-lg { width: 100%; height: 8px; }
.usage-stale .usage-pct { color: var(--text-2); }
.usage-stale .usage-bar-fill { opacity: 0.5; }

#usage-pop {
  position: fixed;
  z-index: 90;
  width: 340px;
  padding: 14px;
  background: rgba(22, 22, 28, 0.96);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  backdrop-filter: blur(16px);
  font-size: var(--fs-sm);
  transform-origin: top right;
  animation: popDown 0.22s var(--ease) both;
}
@keyframes popDown { from { opacity: 0; transform: translateY(-6px) scale(0.97); } to { opacity: 1; transform: none; } }
.up-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.up-title { font-weight: 600; font-size: var(--fs); }
.up-acct { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-2); }
.up-bar-row { margin: 14px 0; }
.up-bar-row:first-of-type { margin-top: 4px; }
.up-bar-label { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; font-size: var(--fs-sm); color: var(--text-2); }
.up-bar-pct { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text); font-weight: 500; }
.up-foot { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 10.5px; color: var(--text-3); font-family: var(--mono); line-height: 1.5; }
.up-acct-head { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-2); margin-bottom: 6px; }
.up-acct-head.up-acct-active { color: var(--text); font-weight: 600; }
.up-divider { border: none; border-top: 1px solid var(--line); margin: 14px 0; }

/* ------------------------------------------------------------- palette ---- */
#palette {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 14vh;
  background: rgba(4, 4, 6, 0.5);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.16s var(--ease);
}
.palette-card {
  width: min(620px, calc(100vw - 32px));
  background: rgba(20, 20, 25, 0.97);
  border-radius: 16px;
  box-shadow: var(--shadow-pop), 0 0 80px -20px rgba(139, 142, 255, 0.25);
  overflow: hidden;
  animation: paletteIn 0.24s var(--ease) both;
}
@keyframes paletteIn { from { opacity: 0; transform: translateY(-8px) scale(0.98); } to { opacity: 1; transform: none; } }
.palette-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text-3);
}
#palette-input { flex: 1; height: 100%; background: none; border: 0; outline: none; font-size: var(--fs-md); color: var(--text); }
#palette-input::placeholder { color: var(--text-3); }
kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--line-2);
  color: var(--text-3);
  background: var(--surface);
}
#palette-list { max-height: min(420px, 56vh); overflow-y: auto; padding: 6px; }
.pal-group { padding: 10px 10px 4px; font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); }
.pal-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border-radius: 9px;
  text-align: left;
  color: var(--text-2);
}
.pal-item .ic { width: 16px; height: 16px; color: var(--text-3); }
.pal-item .pal-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-item.sel { background: var(--surface-2); color: var(--text); }
.pal-item.sel .ic { color: var(--accent-2); }
.pal-item kbd { background: none; }
.pal-empty { padding: 22px; text-align: center; color: var(--text-3); font-size: var(--fs-sm); }

/* ================================================================ TODAY == */
#dash-sections {
  animation: rise 0.4s var(--ease) both;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  grid-template-areas: "cal side" "news news" "tasks tasks";
  gap: 16px;
  align-items: start;
}
#dash-schedule { grid-area: cal; padding: 14px 16px 16px; }
/* Suggested matches the calendar card's height exactly: contain:size takes
   its own content out of the row's height, stretch then sizes it to the row
   the calendar sets, and its list scrolls inside. */
#dash-suggested { grid-area: side; align-self: stretch; contain: size; display: flex; flex-direction: column; }
#dash-suggested .dash-section-list { flex: 1; min-height: 0; }
/* Domain cards pack as a masonry (layoutTaskMasonry in app.js places each
   card in the shortest column), so one long card beside two collapsed ones
   leaves no holes. */
#dash-task-cards { grid-area: tasks; display: flex; gap: 12px; align-items: flex-start; }
.masonry-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.dash-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  min-height: 28px;
}
.dash-section-title { font-size: var(--fs-md); font-weight: 600; }
.dash-section-count { font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-3); }
.dash-section-tools { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.ops-when { font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; }
.ops-cat {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}
.dash-section-list { overflow-y: auto; margin: 0 -8px; padding: 0 8px; }
.dash-empty { padding: 14px 2px; font-size: var(--fs-sm); color: var(--text-3); }
#suggested-refresh .ic, #usage-refresh .ic { transition: transform 0.5s var(--ease); }
#suggested-refresh:hover .ic, #usage-refresh:hover .ic { transform: rotate(90deg); }
#suggested-refresh.spinning .ic, #usage-refresh.spinning .ic { animation: spin 0.9s linear infinite; }

.suggested-meter { height: 3px; border-radius: 3px; background: var(--surface-3); margin: 0 0 10px; overflow: hidden; }
.suggested-meter span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #8b8eff, #5eead4);
  transition: width 0.6s var(--ease);
}

.dash-row { display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left; }
.dash-row-main { flex: 1; min-width: 0; }
.dash-row-title { font-size: var(--fs); line-height: 1.4; color: var(--text); }
.dash-row-body { font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-row-body .ops-cat { margin-right: 6px; color: var(--accent-2); opacity: 0.8; }

.suggested-row-wrap {
  position: relative;
  display: flex;
  align-items: flex-start;
  border-radius: 9px;
  transition: background 0.16s var(--ease);
}
.suggested-row-wrap:hover { background: var(--surface-2); }
.suggested-row { padding: 9px 8px; cursor: pointer; }
.suggested-row .dash-row-title { transition: color 0.3s var(--ease); }
.suggested-done .dash-row-title {
  color: var(--text-3);
  text-decoration: line-through;
  text-decoration-color: var(--text-3);
}
.row-x, .row-mini {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--text-3);
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.16s, background 0.16s, color 0.16s;
}
.row-x { margin: 7px 6px 0 0; font-size: 17px; }
.suggested-row-wrap:hover .row-x, .row-x:focus-visible,
.checklist-row:hover .row-mini, .row-mini:focus-visible { opacity: 1; }
.row-x:hover, .row-mini:hover { background: var(--surface-3); color: var(--text); }
@media (hover: none) { .row-x, .row-mini { opacity: 0.7; } }

/* The calendar (FullCalendar 6, themed through its own CSS variables). */
#dash-calendar {
  --fc-border-color: var(--line);
  --fc-page-bg-color: transparent;
  --fc-neutral-bg-color: var(--surface-2);
  --fc-neutral-text-color: var(--text-2);
  --fc-list-event-hover-bg-color: var(--surface-2);
  --fc-today-bg-color: rgba(139, 142, 255, 0.045);
  --fc-event-bg-color: rgba(139, 142, 255, 0.16);
  --fc-event-border-color: rgba(139, 142, 255, 0.45);
  --fc-event-text-color: var(--text);
  --fc-now-indicator-color: var(--teal);
  --fc-highlight-color: rgba(139, 142, 255, 0.14);
  --fc-small-font-size: 11px;
  font-size: var(--fs-sm);
}
#dash-calendar .fc-header-toolbar { margin-bottom: 12px; gap: 8px; }
#dash-calendar .fc-toolbar-title { font-size: var(--fs); font-weight: 600; letter-spacing: -0.01em; }
#dash-calendar .fc-button {
  height: 28px;
  padding: 0 10px;
  font-size: var(--fs-sm);
  font-weight: 500;
  text-transform: none;
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--text-2);
  border-radius: 8px;
  box-shadow: none !important;
  transition: background 0.16s, color 0.16s;
}
#dash-calendar .fc-button .fc-icon { font-size: 1.1em; vertical-align: -1px; }
#dash-calendar .fc-button:hover { background: var(--surface-2); color: var(--text); }
#dash-calendar .fc-button-group > .fc-button { border-radius: 0; }
#dash-calendar .fc-button-group > .fc-button:first-child { border-radius: 8px 0 0 8px; }
#dash-calendar .fc-button-group > .fc-button:last-child { border-radius: 0 8px 8px 0; }
#dash-calendar .fc-button-primary:not(:disabled).fc-button-active,
#dash-calendar .fc-button-primary:not(:disabled):active { background: var(--surface-3); color: var(--text); border-color: var(--line-3); }
#dash-calendar .fc-button:disabled { opacity: 0.35; }
#dash-calendar .fc-scrollgrid { border-radius: 10px; overflow: hidden; }
#dash-calendar th .fc-col-header-cell-cushion { padding: 8px 4px; font-weight: 500; color: var(--text-2); text-decoration: none; }
#dash-calendar .fc-day-today .fc-col-header-cell-cushion { color: var(--accent-2); }
#dash-calendar .fc-timegrid-slot { height: 22px; }
#dash-calendar .fc-timegrid-slot-minor { border-top-style: none; }
#dash-calendar .fc-timegrid-slot-label-cushion, #dash-calendar .fc-timegrid-axis-cushion { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); }
#dash-calendar .fc-daygrid-day-number { color: var(--text-2); text-decoration: none; font-family: var(--mono); font-size: 11px; padding: 6px 8px; }
#dash-calendar .fc-day-today .fc-daygrid-day-number { color: var(--accent-2); font-weight: 600; }
#dash-calendar .fc-event {
  border-radius: 6px;
  border-width: 0 0 0 2px;
  padding: 1px 2px;
  box-shadow: none;
  cursor: pointer;
  transition: filter 0.16s, transform 0.16s var(--ease);
}
#dash-calendar .fc-v-event { background: var(--fc-event-bg-color); border-left-color: var(--accent); }
#dash-calendar .fc-event:hover { filter: brightness(1.25); }
#dash-calendar .fc-event-title, #dash-calendar .fc-event-time { font-size: 11px; line-height: 1.3; }
#dash-calendar .fc-event-time { font-family: var(--mono); font-size: 10px; opacity: 0.75; }
#dash-calendar .fc-daygrid-event-dot { border-color: var(--accent); }
#dash-calendar .fc-event.fc-event-past:not(.fc-event-mirror) { opacity: 0.55; }
#dash-calendar .fc-event.ev-ed { background: rgba(255, 255, 255, 0.035); border-left-color: var(--text-3); opacity: 0.6; }
#dash-calendar .fc-event.ev-ed .fc-event-main { color: var(--text-2); }
#dash-calendar .fc-timegrid-now-indicator-line { border-width: 1.5px 0 0; box-shadow: 0 0 8px var(--teal); }
#dash-calendar .fc-timegrid-now-indicator-arrow { border-color: var(--teal); border-top-color: transparent; border-bottom-color: transparent; }
#dash-calendar .fc-more-link { color: var(--accent-2); }
#dash-calendar .fc-popover { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow-pop); }
#dash-calendar .fc-popover-header { background: var(--surface-3); border-radius: 10px 10px 0 0; }
#dash-calendar-error { font-size: var(--fs-sm); color: var(--danger); margin-top: 8px; }
#dash-calendar-error:empty { display: none; }

/* Domain task cards */
.task-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.2s var(--ease);
}
.task-card:hover { border-color: var(--line-2); }
button.task-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 16px;
  text-align: left;
  transition: background 0.16s;
}
button.task-card-head:hover { background: rgba(255, 255, 255, 0.015); }
.task-card-caret {
  font-size: 0;
  width: 14px;
  height: 14px;
  flex: none;
  position: relative;
}
.task-card-caret::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text-3);
  border-bottom: 1.5px solid var(--text-3);
  transform: rotate(45deg);
  transition: transform 0.24s var(--ease);
}
.task-card.collapsed .task-card-caret::before { transform: rotate(-45deg) translate(-1px, 1px); }
.task-card-title { font-size: var(--fs); font-weight: 600; }
.task-card-summary { margin-left: auto; font-size: var(--fs-xs); color: var(--text-3); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-card-summary .late { color: var(--warn); }
.task-card-filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.task-card-filters .tag-chip { height: 24px; font-size: var(--fs-xs); }
.task-card-list { padding: 0 8px 4px; border-top: 1px solid var(--line); }
.task-card-foot { display: flex; justify-content: flex-end; gap: 6px; padding: 8px 12px 12px; }
.task-card-foot .linklike { height: 26px; font-size: var(--fs-xs); border-color: transparent; }

.task-row-wrap { border-radius: 9px; transition: background 0.16s var(--ease); margin: 2px 0; }
.task-row-wrap.open { background: var(--surface-2); margin: 6px 0; }
.task-row-head { display: flex; align-items: center; }
button.dash-row-tap { flex: 1; min-width: 0; align-items: center; padding: 8px 8px; border-radius: 9px; transition: background 0.16s; }
button.dash-row-tap:hover { background: var(--surface-2); }
.task-row-wrap.open button.dash-row-tap:hover { background: var(--surface-3); }
.task-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--fs); }
.prio-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line-3); }
.prio-dot.p-urgent { background: var(--danger); box-shadow: 0 0 8px rgba(255, 107, 107, 0.6); }
.prio-dot.p-high { background: var(--warn); box-shadow: none; }
.prio-dot.p-medium { background: var(--accent); box-shadow: none; }
.prio-dot.p-low { background: var(--text-3); box-shadow: none; }
.task-row-head .ops-when { font-size: 10.5px; }
.due-late { color: var(--warn); }
.task-expand {
  flex: none;
  width: 28px;
  height: 28px;
  margin-right: 2px;
  border-radius: 7px;
  font-size: 0;
  position: relative;
  color: var(--text-3);
  transition: background 0.16s;
}
.task-expand::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 10px;
  width: 5px;
  height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.24s var(--ease);
}
.task-expand[aria-expanded="true"]::before { transform: translate(0, -1px) rotate(45deg); }
.task-expand:hover { background: var(--surface-3); color: var(--text); }
.task-checklist { padding: 0 10px 10px 25px; animation: rise 0.26s var(--ease) both; }
.task-props { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); margin: 0 0 6px; }
.checklist-row { display: flex; align-items: center; gap: 2px; border-radius: 7px; }
.checklist-row:hover { background: rgba(255, 255, 255, 0.025); }
.checklist-item { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 9px; padding: 5px 4px; font-size: var(--fs-sm); cursor: pointer; color: var(--text); }
.checklist-done > span { color: var(--text-3); text-decoration: line-through; }
.checklist-note { font-size: var(--fs-sm); padding: 4px 0; color: var(--text-3); }
.checklist-foot { padding: 4px 0 0; }
.checklist-add-btn { height: 24px !important; font-size: var(--fs-xs) !important; border-color: transparent !important; padding: 0 6px !important; }
.task-input, .checklist-input, .checklist-rename {
  width: 100%;
  height: 34px;
  padding: 0 11px;
  background: var(--sunken);
  border: 1px solid var(--line-2);
  border-radius: 9px;
  outline: none;
  font-size: var(--fs-sm);
  transition: border-color 0.16s, box-shadow 0.16s;
}
.task-input:focus, .checklist-input:focus, .checklist-rename:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px rgba(139, 142, 255, 0.1); }
.checklist-input, .checklist-rename { height: 30px; }
select.task-input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
input[type="date"].task-input, input[type="datetime-local"].task-input { color-scheme: dark; }
textarea.task-input { height: auto; padding: 9px 11px; resize: vertical; }

/* The digest (card + page) — only shown if something writes a digest again. */
.digest-card {
  display: block;
  width: 100%;
  margin-bottom: 16px;
  padding: 16px 18px;
  text-align: left;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(139, 142, 255, 0.1), rgba(94, 234, 212, 0.04));
  border: 1px solid var(--accent-line);
  transition: transform 0.2s var(--ease);
}
.digest-card:hover { transform: translateY(-1px); }
.digest-card-top { display: flex; justify-content: space-between; margin-bottom: 6px; }
.digest-card-title { font-size: var(--fs-md); font-weight: 600; }
.digest-card-summary { color: var(--text-2); font-size: var(--fs-sm); margin-top: 4px; }
.digest-card-cta { margin-top: 10px; font-size: var(--fs-sm); color: var(--accent-2); }
.digest-back { margin-bottom: 16px; }
.digest-page-header h2 { font-size: var(--fs-lg); margin: 4px 0; }
.digest-block { margin-top: 18px; }
.digest-block h3 { font-size: var(--fs-sm); color: var(--text-2); margin-bottom: 6px; }
.digest-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }

/* Task + event sheets */
.modal {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 4, 6, 0.55);
  backdrop-filter: blur(5px);
  animation: fadeIn 0.18s var(--ease);
}
.modal-card {
  width: min(520px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 18px 20px 20px;
  background: rgba(20, 20, 25, 0.98);
  border-radius: 18px;
  box-shadow: var(--shadow-pop);
  animation: sheetIn 0.3s var(--ease) both;
}
@keyframes sheetIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-header h2 { font-size: var(--fs-sm); font-weight: 560; color: var(--text-2); }
.task-detail-title { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.02em; line-height: 1.3; margin-bottom: 16px; }
.task-title-input { height: 42px; font-size: var(--fs-md); font-weight: 500; margin-bottom: 14px; }
.task-fields { display: flex; flex-direction: column; gap: 8px; }
.task-field { display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; gap: 12px; }
.task-field-label { font-size: var(--fs-sm); color: var(--text-3); }
.task-field-value { font-size: var(--fs-sm); }
.task-field .task-check { margin: 0; }
.task-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.task-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: var(--fs-sm); }
.task-notion-link { color: var(--text-2); text-decoration: none; border-bottom: 1px solid var(--line-3); }
.task-notion-link:hover { color: var(--text); }
.task-error { color: var(--danger) !important; }
.event-notes { min-height: 70px; }

/* ============================================================= BUSINESS == */
.counts-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.counts-row .stat {
  position: relative;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: rise 0.36s var(--ease) both;
}
.counts-row .stat:nth-child(2) { animation-delay: 0.05s; }
.counts-row .stat:nth-child(3) { animation-delay: 0.1s; }
.counts-row .stat::after {
  content: '';
  position: absolute;
  right: -30px;
  top: -30px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(139, 142, 255, 0.12), transparent);
}
.counts-row .stat .n { font-size: 34px; font-weight: 560; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.counts-row .stat .l { font-size: var(--fs-sm); color: var(--text-2); margin-top: 6px; }
.biz-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.task-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
}
.task-row:first-child { border-top: 0; }
.task-row span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row .due { font-family: var(--mono); color: var(--text-2); font-variant-numeric: tabular-nums; }
#business-note { margin-top: 12px; font-size: var(--fs-xs); font-family: var(--mono); color: var(--text-3); }

/* ============================================================== READING == */
#reading-panel.active { display: flex; flex-direction: column; }
#reading-panel .panel-head { flex: none; }
#reading-panel:not(.chat-mode) .usage-chip { display: none; }
#reading-list, #reading-notes-section, #reading-graph-section { animation: rise 0.3s var(--ease) both; }
#reading-list { display: grid; gap: 8px; max-width: 980px; }
.reading-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.reading-card:hover { border-color: var(--line-2); }
.reading-card.open { border-color: var(--line-2); background: var(--surface); }
.reading-head { display: flex; align-items: flex-start; gap: 14px; width: 100%; padding: 14px 16px; text-align: left; }
.reading-head-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.reading-title { font-size: var(--fs-md); font-weight: 580; letter-spacing: -0.01em; line-height: 1.35; }
.reading-author { font-size: var(--fs-sm); color: var(--text-2); }
.reading-teaser { font-size: var(--fs-sm); color: var(--text-3); margin-top: 4px; line-height: 1.5; }
.reading-tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10.5px;
  white-space: nowrap;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  flex: none;
}
.reading-tag.to-read { color: var(--text-2); }
.reading-tag.reading { color: var(--teal); border-color: rgba(94, 234, 212, 0.3); background: rgba(94, 234, 212, 0.07); }
.reading-tag.done { color: var(--accent-2); border-color: var(--accent-line); background: var(--accent-soft); }
.reading-tag.untagged { color: var(--text-3); }
.reading-folder { border-radius: 14px; border: 1px solid var(--line); background: var(--bg-2); overflow: hidden; }
.reading-folder-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 16px; text-align: left; transition: background 0.16s; }
.reading-folder-head:hover { background: var(--surface); }
.reading-folder-arrow { font-size: 0; width: 14px; height: 14px; position: relative; flex: none; }
.reading-folder-arrow::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text-3);
  border-bottom: 1.5px solid var(--text-3);
  transform: rotate(-45deg) translate(-1px, 1px);
  transition: transform 0.24s var(--ease);
}
.reading-folder.open .reading-folder-arrow::before { transform: rotate(45deg); }
.reading-folder-name { font-weight: 580; }
.reading-folder-count { font-family: var(--mono); font-size: var(--fs-xs); margin-left: auto; }
.reading-folder-items { display: grid; gap: 8px; padding: 0 10px 10px; animation: rise 0.26s var(--ease) both; }
.reading-detail { padding: 0 16px 16px; animation: rise 0.26s var(--ease) both; }
.reading-body { margin: 0 0 12px; font-size: var(--fs); line-height: 1.62; color: #d6d6dd; white-space: pre-wrap; }
.reading-why { padding: 12px 14px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); margin-bottom: 12px; }
.reading-why .ops-cat { margin-bottom: 6px; color: var(--accent-2); }
.reading-why .reading-body { margin: 0; color: var(--text-2); }
.reading-link { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); color: var(--accent-2); text-decoration: none; margin-bottom: 14px; }
.reading-link::after { content: '↗'; }
.reading-response-label { display: block; margin-bottom: 6px; }
.reading-response, #reading-note-text {
  width: 100%;
  padding: 11px 13px;
  background: var(--sunken);
  border: 1px solid var(--line-2);
  border-radius: 11px;
  outline: none;
  resize: vertical;
  font-size: var(--fs);
  line-height: 1.55;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.reading-response:focus, #reading-note-text:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px rgba(139, 142, 255, 0.1); }
.reading-actions { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.reading-error { font-size: var(--fs-sm); color: var(--danger) !important; }

#reading-notes-section { max-width: 980px; }
#reading-note-form { margin-bottom: 16px; }
#reading-note-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 12px; }
#reading-note-form-row { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
#reading-notes { columns: 2 300px; column-gap: 12px; }
.note-card {
  break-inside: avoid;
  margin: 0 0 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  transition: border-color 0.2s;
}
.note-card:hover { border-color: var(--line-2); }
.note-card .reading-body { margin: 0; white-space: pre-wrap; font-size: var(--fs-sm); }
.note-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-bottom: 8px; }
.note-date { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); margin-left: 4px; }
.note-delete { margin-left: auto; width: 22px; height: 22px; border-radius: 6px; color: var(--text-3); font-size: 15px; line-height: 1; opacity: 0; transition: opacity 0.16s, background 0.16s; }
.note-card:hover .note-delete { opacity: 1; }
.note-delete:hover { background: var(--danger-soft); color: var(--danger); }

.graph-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 12px; align-items: start; }
#reading-graph-wrap { position: relative; padding: 0; overflow: hidden; height: min(68vh, 640px); background: radial-gradient(ellipse at center, rgba(139, 142, 255, 0.05), transparent 70%), var(--surface); }
#reading-graph-svg { display: block; width: 100%; height: 100%; cursor: grab; }
#reading-graph-svg:active { cursor: grabbing; }
#reading-graph-zoom { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: rgba(20, 20, 25, 0.9); border: 1px solid var(--line-2); backdrop-filter: blur(8px); }
#reading-graph-zoom button { min-width: 28px; height: 26px; padding: 0 8px; border-radius: 7px; color: var(--text-2); font-size: var(--fs-sm); }
#reading-graph-zoom button:hover { background: var(--surface-3); color: var(--text); }
#reading-graph-status { position: absolute; inset: 0; display: grid; place-items: center; font-size: var(--fs-sm); }
.graph-link { stroke: rgba(255, 255, 255, 0.12); transition: stroke 0.2s, opacity 0.2s; }
.graph-link.lit { stroke: var(--accent); }
.graph-link.dim { opacity: 0.25; }
.graph-node { cursor: pointer; transition: opacity 0.2s; }
.graph-node circle { fill: var(--surface-3); stroke: rgba(139, 142, 255, 0.55); stroke-width: 1.5; transition: fill 0.2s, stroke 0.2s; }
.graph-node text { fill: var(--text-2); font-size: 11px; font-family: var(--font); pointer-events: none; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.graph-node:hover circle, .graph-node:focus circle { fill: rgba(139, 142, 255, 0.3); stroke: var(--accent-2); }
.graph-node:focus { outline: none; }
.graph-node.selected circle { fill: var(--accent); stroke: #fff; }
.graph-node.selected text { fill: var(--text); font-weight: 600; }
.graph-node.dim { opacity: 0.22; }
#reading-graph-detail > .muted { padding: 14px; font-size: var(--fs-sm); border: 1px dashed var(--line-2); border-radius: 14px; color: var(--text-3); }
.graph-detail-card { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; animation: rise 0.26s var(--ease) both; max-height: min(68vh, 640px); overflow-y: auto; }
.graph-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.graph-detail-name { font-size: var(--fs-md); font-weight: 600; }
.graph-field { margin-bottom: 12px; }
.graph-field .ops-cat { margin-bottom: 4px; }
.graph-field .reading-body { font-size: var(--fs-sm); margin: 0; }
.graph-list { margin: 0; padding-left: 1.1em; font-size: var(--fs-sm); color: var(--text-2); }
.graph-list li { margin: 2px 0; }
.graph-list a { color: var(--accent-2); word-break: break-all; }
.graph-conns { display: flex; flex-wrap: wrap; gap: 5px; }
.graph-conn { height: 24px; padding: 0 9px; border-radius: 999px; border: 1px solid var(--line-2); font-size: var(--fs-xs); color: var(--text-2); transition: all 0.16s; }
.graph-conn:hover { border-color: var(--accent-line); color: var(--accent-2); }

#reading-panel.chat-mode { padding-bottom: 0; }
#reading-chat { flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 0 calc(-1 * clamp(20px, 3.4vw, 48px)); border-top: 1px solid var(--line); animation: fadeIn 0.3s var(--ease); }
#reading-chat-log { padding-top: 22px; }

/* =============================================================== SYSTEM == */
#system-status { text-transform: none; letter-spacing: 0.02em; }
#system-status .st-ok { color: var(--ok); }
#system-status .st-bad { color: var(--danger); }
.sys-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}
.sys-host { grid-column: span 5; }
.sys-account { grid-column: span 4; }
.sys-clean { grid-column: span 3; }
.sys-activity { grid-column: span 5; }
.sys-jobs { grid-column: span 7; grid-row: span 2; }
.sys-files { grid-column: span 5; }
.gauges { display: flex; gap: 18px; flex-wrap: wrap; }
.gauge { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.gauge svg { transform: rotate(-90deg); }
.gauge-track { fill: none; stroke: var(--surface-3); stroke-width: 5; }
.gauge-fill { fill: none; stroke-width: 5; stroke-linecap: round; transition: stroke-dashoffset 0.9s var(--ease); animation: gaugeIn 1s var(--ease) both; }
@keyframes gaugeIn { from { stroke-dashoffset: 163.4; } }
.gauge-num { fill: var(--text); font-family: var(--mono); font-size: 12px; font-weight: 500; transform: rotate(90deg); transform-origin: 32px 32px; }
.gauge .l { font-size: var(--fs-xs); color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; font-family: var(--mono); }
.gauge-sub { font-size: 10px; color: var(--text-3); font-family: var(--mono); text-align: center; max-width: 130px; }
/* Two machines on one ring (Q, app msg 7073): the droplet (outer, orange)
   and the Air (inner, blue) -- bg-run-remote.sh means real work now runs on
   both, so a capacity glance needs both numbers, not just this box's own. */
.gauge-linux { stroke: #f5b64a; }
.gauge-mac { stroke: #5eaaff; animation: gaugeInMac 1s var(--ease) both; }
@keyframes gaugeInMac { from { stroke-dashoffset: 113.1; } }
.gauge-legend { font-size: 9px; font-family: var(--mono); color: var(--text-3); display: flex; align-items: center; gap: 3px; flex-wrap: wrap; justify-content: center; }
.gauge-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-left: 4px; }
.gauge-dot:first-child { margin-left: 0; }
.gauge-dot-linux { background: #f5b64a; }
.gauge-dot-mac { background: #5eaaff; }
#system-extra { margin-top: 12px; font-size: var(--fs-xs); font-family: var(--mono); color: var(--text-3); line-height: 1.7; }
.account-row { display: flex; gap: 4px; padding: 3px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; }
.account-row button { flex: 1; height: 32px; border-radius: 7px; font-size: var(--fs-sm); color: var(--text-2); transition: all 0.2s var(--ease); }
.account-row button:hover { color: var(--text); }
.account-row button.active-account { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.account-row button.active-account::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); margin-right: 7px; vertical-align: 1px; box-shadow: 0 0 8px var(--ok); }
#account-note { font-size: var(--fs-xs); font-family: var(--mono); color: var(--text-3); }
.activity-card { padding: 10px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); margin-bottom: 8px; }
.activity-card.stuck { border-color: rgba(245, 182, 74, 0.35); }
.activity-head { display: flex; align-items: center; gap: 8px; }
.activity-title { font-weight: 560; font-size: var(--fs-sm); }
.activity-flag { font-family: var(--mono); font-size: 10px; color: var(--warn); text-transform: uppercase; }
.activity-detail { font-size: var(--fs-sm); color: var(--text-2); margin: 4px 0; }
.activity-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--fs-xs); }
.activity-actions { display: flex; gap: 4px; }
.activity-actions .linklike { height: 24px; font-size: var(--fs-xs); }
#system-activity > .muted { font-size: var(--fs-sm); color: var(--text-3); }
#system-jobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); column-gap: 18px; }
.job-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); min-width: 0; }
.job-row::before { content: ''; width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--ok); opacity: 0.8; }
.job-row.job-fail::before { background: var(--danger); box-shadow: 0 0 8px var(--danger); opacity: 1; }
.job-row > span:first-of-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-row > span:last-child { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); white-space: nowrap; }
.job-row.job-fail > span:last-child { color: var(--danger); }
#files-crumb { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-3); margin-bottom: 8px; }
#files-crumb button { padding: 2px 6px; border-radius: 5px; color: var(--text-2); }
#files-crumb button:hover { background: var(--surface-2); color: var(--text); }
.files-body { max-height: 420px; overflow-y: auto; margin: 0 -8px; padding: 0 8px; }
.file-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 8px; margin: 0 -8px; border-radius: 7px; font-size: var(--fs-sm); cursor: pointer; transition: background 0.14s; }
.file-row:hover { background: var(--surface-2); }
.file-row > span:first-child { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.file-row .ic { width: 15px; height: 15px; color: var(--text-3); }
.file-row.is-dir .ic { color: var(--accent-2); }
.file-row.restricted { opacity: 0.5; }
.file-row .size { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); }
#file-preview { margin: 0; padding: 12px; background: var(--sunken); border: 1px solid var(--line); border-radius: 10px; font-size: 11.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; color: var(--text-2); }
#clean-result { margin-top: 10px; font-size: var(--fs-xs); color: var(--text-3); white-space: pre-wrap; }
#clean-result:empty { display: none; }

/* ============================================================= TERMINAL == */
#terminal-panel { padding: 0; }
#terminal-panel.active { display: flex; flex-direction: column; background: var(--bg); }
.term-topbar { display: flex; align-items: center; gap: 12px; height: 48px; padding: 0 14px; border-bottom: 1px solid var(--line); flex: none; }
.term-title { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: var(--fs-sm); color: var(--text-2); }
.term-title .ic { width: 15px; height: 15px; color: var(--accent-2); }
.term-status { font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-3); margin-right: auto; display: inline-flex; align-items: center; gap: 6px; }
.term-status:not(:empty)::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.term-status.connected::before { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
/* The padding sits on .xterm, not the container: FitAddon subtracts the
   terminal element's own padding but measures the parent's border-box, so
   container padding made it size one row too many. */
#term-container { flex: 1; min-height: 0; overflow: hidden; }
#term-container .xterm { height: 100%; padding: 10px 6px 6px 14px; }
#term-container .xterm-viewport { background: transparent !important; }

/* ============================================================ RESPONSIVE == */
@media (max-width: 1180px) {
  #dash-sections { grid-template-columns: minmax(0, 1fr); grid-template-areas: "side" "cal" "news" "tasks"; }
  #dash-suggested { contain: none; max-height: 460px; }
  .sys-host, .sys-account, .sys-clean, .sys-activity, .sys-jobs, .sys-files { grid-column: span 12; grid-row: auto; }
  .graph-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1180px) and (min-width: 761px) {
  .sys-host, .sys-activity, .sys-files { grid-column: span 6; }
  .sys-account, .sys-clean { grid-column: span 6; }
}
@media (max-width: 760px) {
  :root { --fs-xl: 24px; }
  #app-shell.active { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  main.view { grid-column: 1; grid-row: 1; }
  nav.tabs {
    grid-column: 1;
    grid-row: 2;
    flex-direction: row;
    justify-content: space-around;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--line);
    background: rgba(9, 9, 11, 0.92);
    backdrop-filter: blur(14px);
  }
  nav.tabs .brand-mark, .rail-spacer { display: none; }
  nav.tabs > button::after { display: none; }
  nav.tabs > button[data-tab]::before { left: 50%; top: -6px; width: 18px; height: 2px; margin: 0 0 0 -9px; border-radius: 0 0 2px 2px; transform: scaleX(0); }
  nav.tabs > button[data-tab].active::before { transform: scaleX(1); }
  #conv-sidebar {
    position: fixed;
    z-index: 60;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(300px, 84vw) !important;
    opacity: 1 !important;
    transform: translateX(-102%);
    transition: transform 0.32s var(--ease);
    box-shadow: 20px 0 60px -20px rgba(0, 0, 0, 0.8);
  }
  #app-shell.drawer-open #conv-sidebar { transform: none; }
  #app-shell.drawer-open #drawer-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, 0.5); animation: fadeIn 0.2s var(--ease); }
  .sidebar-head, #conv-rail { min-width: 0; }
  .view-panel { padding: 18px 16px 32px; }
  .msg.user { max-width: 88%; }
  #reading-chat { margin: 0 -16px; }
  .panel-tools { width: 100%; justify-content: space-between; }
  #reading-notes { columns: 1; }
  .task-field { grid-template-columns: 76px minmax(0, 1fr); }
  #approval-banner { flex-wrap: wrap; top: auto; bottom: calc(66px + env(safe-area-inset-bottom)); animation-name: riseIn; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
