/* ==========================================================================
   AI Operations Portal - application styles
   Layout: the sidebar sits on the grey canvas; every page lives in one white
   rounded panel with its own top bar. On phones the panel goes full-bleed and
   the sidebar becomes a drawer.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

img { max-width: 100%; }
[hidden] { display: none !important; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

::selection { background: var(--accent-soft); color: var(--text); }

.ico { flex: 0 0 auto; display: block; }

/* Scrollbars ------------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-full);
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-dim); background-clip: content-box; }

/* ==========================================================================
   Boot / auth screens
   ========================================================================== */

.boot {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-4);
  padding: var(--s-6);
  background: var(--bg);
  text-align: center;
  z-index: 100;
}
.boot__spinner {
  width: 30px; height: 30px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.boot__icon { font-size: 38px; }
.boot__title { font-size: var(--fs-lg); font-weight: 650; letter-spacing: -0.01em; }
.boot__text { color: var(--text-muted); max-width: 380px; font-size: var(--fs-base); }
.boot__form { display: flex; gap: var(--s-2); width: 100%; max-width: 360px; }

/* ==========================================================================
   Shell
   ========================================================================== */

.app {
  height: 100%;
  display: flex;
  padding-top: env(safe-area-inset-top, 0px);
}

/* Sidebar ---------------------------------------------------------------- */

.sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  padding: var(--s-4) var(--s-3) var(--s-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
  transition: width var(--t-base), flex-basis var(--t-base);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 2px var(--s-2) var(--s-4);
  min-width: 0;
}
.brand__mark {
  width: 32px; height: 32px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(140deg, #ff8a3d 0%, var(--accent) 55%, #d63c06 100%);
  box-shadow: 0 4px 12px -4px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.brand__text { flex: 1; min-width: 0; }
.brand__name {
  font-weight: 700;
  font-size: var(--fs-base);
  line-height: 1.2;
  letter-spacing: -0.02em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.brand__sub { font-size: var(--fs-xs); color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand__collapse { flex: 0 0 auto; }

.ask-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  margin: 0 0 var(--s-3);
  padding: 10px var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface-1);
  box-shadow: var(--shadow-md);
  font-weight: 600;
  font-size: var(--fs-base);
  color: var(--text);
  transition: box-shadow var(--t-fast), transform var(--t-fast), border-color var(--t-fast);
}
.ask-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.ask-btn .ico { color: var(--accent); }
.ask-btn.is-active { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-md); }

.sidebar__label {
  font-size: var(--fs-xs);
  font-weight: 550;
  color: var(--text-dim);
  padding: var(--s-4) var(--s-3) 6px;
  white-space: nowrap;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: 7px var(--s-3);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-base);
  font-weight: 500;
  text-align: left;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.nav-item .ico { opacity: 0.85; }
.nav-item:hover { background: rgba(90, 75, 55, 0.07); color: var(--text); }
.nav-item.is-active {
  background: var(--surface-1);
  border-color: var(--border);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.nav-item.is-active .ico { color: var(--accent); opacity: 1; }
.nav-item__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-item__badge {
  min-width: 19px; height: 19px;
  padding: 0 6px;
  display: grid; place-items: center;
  border-radius: var(--r-full);
  background: var(--bad);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  flex: 0 0 auto;
}
.nav-item__badge--warn { background: var(--warn); }

.sidebar__footer { margin-top: auto; padding-top: var(--s-4); }

.side-card {
  padding: var(--s-3);
  border-radius: var(--r-md);
  background: var(--surface-1);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
.side-card__title {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: var(--s-2);
}
.conn-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 6px var(--s-2); }
.conn-row { display: flex; align-items: center; gap: 7px; font-size: var(--fs-sm); color: var(--text-muted); min-width: 0; }
.conn-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; background: var(--text-dim); }
.conn-dot.is-on { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.conn-dot.is-off { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.conn-row__name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-card__version { margin-top: var(--s-2); font-size: var(--fs-xs); color: var(--text-dim); }

/* Collapsed sidebar (desktop): icons only ---------------------------------- */

.app--collapsed .sidebar { flex-basis: 76px; width: 76px; }
.app--collapsed .brand { justify-content: center; padding-inline: 0; flex-direction: column; }
.app--collapsed .brand__text,
.app--collapsed .nav-item__label,
.app--collapsed .ask-btn__label,
.app--collapsed .sidebar__label,
.app--collapsed .side-card { display: none; }
.app--collapsed .sidebar__label + .nav-item { margin-top: var(--s-3); }
.app--collapsed .nav-item { justify-content: center; padding-inline: 0; }
.app--collapsed .nav-item__badge { position: absolute; top: 1px; right: 8px; min-width: 16px; height: 16px; font-size: 9px; padding: 0 4px; }
.app--collapsed .ask-btn { padding-inline: 0; width: 44px; height: 44px; margin-inline: auto; }

/* The white working panel -------------------------------------------------- */

.frame {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin: var(--frame-gap) var(--frame-gap) var(--frame-gap) 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}

.topbar {
  flex: 0 0 auto;
  height: var(--header-h);
  padding: 0 var(--s-5) 0 var(--s-6);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  border-bottom: 1px solid var(--border);
}
.icon-btn.topbar__menu { display: none; }

.crumbs { display: flex; align-items: center; gap: var(--s-2); min-width: 0; font-size: var(--fs-sm); color: var(--text-dim); }
.crumbs__home { display: flex; align-items: center; gap: 6px; color: var(--text-dim); border: 0; background: none; padding: 0; }
.crumbs__home:hover { color: var(--text); }
.crumbs__sep { opacity: 0.6; }
.crumbs__here { color: var(--text); font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: var(--s-2); }

.search-pill {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 240px;
  padding: 7px 8px 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface-1);
  color: var(--text-dim);
  font-size: var(--fs-sm);
  text-align: left;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.search-pill:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.search-pill__text { flex: 1; }
kbd, .kbd {
  font-family: var(--font);
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
}

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface-1);
  color: var(--text-muted);
  font-size: 15px;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }
.icon-btn--bare { border-color: transparent; background: transparent; }

.theme-toggle,
.lang-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface-2);
}
.theme-toggle button,
.lang-btn {
  height: 26px;
  min-width: 28px;
  padding: 0 8px;
  display: grid; place-items: center;
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--text-dim);
  font-size: var(--fs-xs);
  font-weight: 650;
  transition: all var(--t-fast);
}
.theme-toggle button { padding: 0; width: 28px; }
.theme-toggle button:hover, .lang-btn:hover { color: var(--text); }
.theme-toggle button.is-active,
.lang-btn.is-active { background: var(--surface-1); color: var(--text); box-shadow: var(--shadow-sm); }

.avatar {
  width: 34px; height: 34px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: var(--fs-sm);
  color: #fff;
  background: linear-gradient(135deg, #3b3f4a, #16181d);
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px var(--border);
}

/* Main ------------------------------------------------------------------- */

.main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--s-7) var(--s-7) calc(var(--s-8) + env(safe-area-inset-bottom, 0px));
}
.main--flush { padding: 0; overflow: hidden; }

.view { max-width: var(--content-max); margin: 0 auto; animation: fadeUp var(--t-slow) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   Page furniture
   ========================================================================== */

.page-head,
.view__head {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2) var(--s-4);
  flex-wrap: wrap;
  margin-bottom: var(--s-7);
}
.page-head__text { flex: 1; min-width: 200px; }
.page-title,
.view__title {
  margin: 0;
  font-size: var(--fs-2xl);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: var(--lh-tight);
}
.view__title { flex: 1 1 auto; min-width: 200px; }
.page-sub { margin: var(--s-2) 0 0; color: var(--text-muted); font-size: var(--fs-base); max-width: 720px; }
.view__sub {
  flex-basis: 100%;
  order: 2;
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-base);
}
.view__head > .btn,
.view__head > .btn-row { order: 1; }
.page-head__actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

.section { margin-bottom: var(--s-8); }
.section__head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.section__title { margin: 0; font-size: var(--fs-md); font-weight: 650; letter-spacing: -0.015em; }
.section__spacer { flex: 1; }

.btn-row { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface-1);
  color: var(--text);
  font-size: var(--fs-base);
  font-weight: 550;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), opacity var(--t-fast), box-shadow var(--t-fast);
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn--primary { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }
.btn--primary:hover { background: var(--ink-hover); border-color: var(--ink-hover); }

.btn--accent { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn--accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn--danger { background: var(--bad-soft); border-color: var(--bad-border); color: var(--bad); box-shadow: none; }
.btn--danger:hover { background: var(--bad); border-color: var(--bad); color: #fff; }

.btn--good { background: var(--good-soft); border-color: var(--good-border); color: var(--good); box-shadow: none; }
.btn--good:hover { background: var(--good); border-color: var(--good); color: #fff; }

.btn--ghost { background: transparent; border-color: transparent; color: var(--text-muted); box-shadow: none; }
.btn--ghost:hover { background: var(--surface-hover); color: var(--text); }

.btn--sm { padding: 5px 12px; font-size: var(--fs-sm); }
.btn--lg { padding: 11px 22px; font-size: var(--fs-md); }
.btn--block { width: 100%; }

.btn__spinner {
  width: 13px; height: 13px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}
.card__head {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
}
.card__title { font-weight: 650; font-size: var(--fs-base); letter-spacing: -0.01em; }
.card__body { padding: var(--s-5); }
.card__body--tight { padding: var(--s-3); }
.card__foot {
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  display: flex; gap: var(--s-2); flex-wrap: wrap;
}

.grid { display: grid; gap: var(--s-4); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* ==========================================================================
   Stat tiles
   ========================================================================== */

.stat {
  padding: var(--s-5);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.stat--clickable { cursor: pointer; }
.stat--clickable:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat__label { font-size: var(--fs-sm); font-weight: 550; color: var(--text-muted); }
.stat__value {
  margin-top: var(--s-2);
  font-size: var(--fs-2xl);
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}
.stat__meta { margin-top: var(--s-1); font-size: var(--fs-sm); color: var(--text-dim); }
.stat--good .stat__value { color: var(--good); }
.stat--warn .stat__value { color: var(--warn); }
.stat--bad  .stat__value { color: var(--bad); }

/* Students page: the Google databases and SchoolUp, side by side, never summed. */
.ov { margin-bottom: var(--s-4); }
.ov__head { display: flex; align-items: center; gap: 6px; }
.ov__rows {
  display: grid; grid-template-columns: 1fr auto; gap: 4px var(--s-3);
  margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--border);
  font-size: var(--fs-sm); color: var(--text-muted);
}
.ov__num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.ov__note { display: flex; gap: 6px; align-items: flex-start; margin: var(--s-2) 0 0; }

/* ==========================================================================
   Alerts
   ========================================================================== */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-4);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface-1);
  box-shadow: var(--shadow-sm);
}
.alert + .alert { margin-top: var(--s-2); }
.alert__icon {
  width: 32px; height: 32px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
}
.alert--critical .alert__icon { background: var(--bad-soft); color: var(--bad); }
.alert--warning  .alert__icon { background: var(--warn-soft); color: var(--warn); }
.alert--info     .alert__icon { background: var(--info-soft); color: var(--info); }
.alert--good     .alert__icon { background: var(--good-soft); color: var(--good); }
/* A note inside a page (not an alert): quieter still. */
.alert--note { background: var(--surface-2); box-shadow: none; }
.alert__body { flex: 1; min-width: 0; padding-top: 5px; }
.alert__title { font-weight: 620; font-size: var(--fs-base); line-height: 1.35; }
.alert__detail { margin-top: 3px; color: var(--text-muted); font-size: var(--fs-sm); line-height: 1.5; overflow-wrap: anywhere; }
.alert__action { flex: 0 0 auto; align-self: center; }

/* ==========================================================================
   Badges / pills
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  white-space: nowrap;
}
.badge--good { background: var(--good-soft); color: var(--good); border-color: var(--good-border); }
.badge--warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.badge--bad  { background: var(--bad-soft);  color: var(--bad);  border-color: var(--bad-border); }
.badge--info { background: var(--info-soft); color: var(--info); border-color: var(--info-border); }
.badge--accent { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent-border); }
.badge--neutral { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  box-shadow: var(--shadow-sm);
}
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
.table th {
  text-align: left;
  padding: 11px var(--s-4);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.table td {
  padding: 11px var(--s-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--surface-hover); }
.table__num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table__name { font-weight: 560; }
.table td.table__cell-actions { text-align: right; white-space: nowrap; }
.table__actions { display: flex; gap: var(--s-1); justify-content: flex-end; align-items: center; }

/* ==========================================================================
   Forms
   ========================================================================== */

.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field__label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }
.field__hint { font-size: var(--fs-xs); color: var(--text-dim); }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-1);
  color: var(--text);
  font-size: var(--fs-base);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input::placeholder, .textarea::placeholder { color: var(--text-dim); }
.textarea { resize: vertical; min-height: 78px; line-height: var(--lh-normal); }

.search { position: relative; flex: 1; min-width: 180px; }
.search .input { padding-left: 34px; border-radius: var(--r-full); }
.search__icon {
  position: absolute;
  left: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 12px;
  pointer-events: none;
}

.toolbar { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; margin-bottom: var(--s-4); }

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
}
.segmented__btn {
  border: 0;
  background: transparent;
  padding: 5px 12px;
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: 560;
  color: var(--text-muted);
  transition: all var(--t-fast);
  white-space: nowrap;
}
.segmented__btn:hover { color: var(--text); }
.segmented__btn.is-active { background: var(--surface-1); color: var(--text); box-shadow: var(--shadow-sm); }

/* ==========================================================================
   The orb - the assistant's face
   ========================================================================== */

.orb {
  --size: 150px;
  position: relative;
  width: var(--size);
  height: var(--size);
  flex: 0 0 auto;
  border-radius: 50%;
  isolation: isolate;
  background:
    radial-gradient(circle at 32% 28%, var(--orb-4) 0%, transparent 34%),
    radial-gradient(circle at 70% 30%, var(--orb-2) 0%, transparent 55%),
    radial-gradient(circle at 30% 75%, var(--orb-1) 0%, transparent 58%),
    radial-gradient(circle at 75% 80%, var(--orb-3) 0%, transparent 60%),
    linear-gradient(135deg, var(--orb-1), var(--orb-2));
  box-shadow:
    inset -10px -14px 30px rgba(90, 70, 190, 0.25),
    inset 8px 10px 24px rgba(255, 255, 255, 0.55),
    0 20px 50px -18px rgba(140, 110, 230, 0.55);
  animation: orbFloat 7s ease-in-out infinite;
}
.orb::before {
  /* Slowly turning colour field under the glass. */
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--orb-1), var(--orb-2), var(--orb-3), var(--orb-4), var(--orb-1));
  filter: blur(14px);
  opacity: 0.55;
  mix-blend-mode: soft-light;
  animation: spin 14s linear infinite;
  z-index: -1;
}
.orb::after {
  /* Specular highlight. */
  content: "";
  position: absolute;
  top: 12%; left: 20%;
  width: 38%; height: 26%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.85), transparent 70%);
  filter: blur(4px);
  transform: rotate(-24deg);
}
@keyframes orbFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-6px) scale(1.015); }
}
.orb.orb--sm { --size: 28px; animation: none; box-shadow: inset -3px -4px 8px rgba(90, 70, 190, 0.25), inset 2px 3px 6px rgba(255, 255, 255, 0.55); }
.orb--sm::before { filter: blur(4px); }
.orb--sm::after { filter: blur(1.5px); }
.orb--thinking { animation: orbPulse 1.4s ease-in-out infinite; }
@keyframes orbPulse { 0%, 100% { transform: scale(0.92); opacity: 0.85; } 50% { transform: scale(1.06); opacity: 1; } }

/* ==========================================================================
   Chat
   ========================================================================== */

.chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

.chat-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  gap: var(--s-4);
  padding: var(--s-6) var(--s-7) var(--s-3);
}
.chat-head__text { flex: 1; min-width: 0; }
.chat-head__title {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: var(--lh-tight);
}
.chat-head__title span { color: var(--text-dim); font-weight: 500; }
.chat-head__sub { margin-top: 4px; font-size: var(--fs-sm); color: var(--text-muted); }

.chat__scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-4) var(--s-7) var(--s-6);
}
.chat__inner { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--s-6); }

/* Empty state: orb, greeting, big composer, cards ---------------------- */

.hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: var(--s-2); animation: fadeUp var(--t-slow) both; }
.hero__greet {
  margin: var(--s-6) 0 var(--s-7);
  font-size: clamp(28px, 4.2vw, var(--fs-3xl));
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.1;
}
.hero__greet span { color: var(--text-dim); font-weight: 500; }
.hero__composer { width: 100%; max-width: 820px; }

.explore { width: 100%; max-width: 980px; margin-top: var(--s-8); text-align: left; }
.explore__bar { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.tabs { scrollbar-width: none; display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-full); background: var(--surface-2); border: 1px solid var(--border); overflow-x: auto; max-width: 100%; }
.tabs__btn {
  border: 0; background: transparent;
  padding: 6px 14px;
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: 560;
  color: var(--text-muted);
  white-space: nowrap;
  transition: all var(--t-fast);
}
.tabs__btn:hover { color: var(--text); }
.tabs__btn.is-active { background: var(--surface-1); color: var(--text); box-shadow: var(--shadow-sm); }

.idea-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--s-3); }
.idea {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-4);
  min-height: 150px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  animation: fadeUp var(--t-slow) both;
}
.idea:hover { background: var(--surface-1); border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.idea__icon {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.idea:hover .idea__icon { color: var(--accent); }
.idea__title { margin-top: var(--s-2); font-weight: 620; font-size: var(--fs-base); letter-spacing: -0.01em; }
.idea__text {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.idea__foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; color: var(--text-dim); font-size: var(--fs-xs); }
.idea__foot .ico { transition: transform var(--t-fast); }
.idea:hover .idea__foot .ico { transform: translateX(3px); color: var(--accent); }

/* Composer ------------------------------------------------------------- */

.composer {
  width: 100%;
  padding: 6px;
  border-radius: var(--r-2xl);
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-align: left;
}
.composer__box {
  display: flex;
  gap: var(--s-3);
  align-items: flex-start;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: calc(var(--r-2xl) - 6px);
  background: var(--surface-1);
  box-shadow: var(--shadow-md);
  transition: border-color var(--t-base), box-shadow var(--t-base);
}
.composer__box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow), var(--shadow-md); }
.composer__spark { color: var(--accent); margin-top: 3px; }
.composer__input {
  flex: 1;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  min-height: 24px;
  max-height: 200px;
  padding: 0;
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--text);
}
.composer__input::placeholder { color: var(--text-dim); }
.hero .composer__input { min-height: 84px; }

.composer__bar { display: flex; align-items: center; gap: 4px; padding: 8px 6px 2px 8px; }
.composer__chips { display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; flex: 0 1 auto; }
.composer__chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; white-space: nowrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border: 1px solid transparent;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 550;
  transition: all var(--t-fast);
}
.chip:hover { background: var(--surface-1); border-color: var(--border); color: var(--text); box-shadow: var(--shadow-sm); }
.composer__hint { flex: 1; min-width: 0; text-align: right; font-size: var(--fs-xs); color: var(--text-dim); padding-right: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer__send {
  width: 38px; height: 38px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 6px 16px -6px var(--accent);
  transition: background var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
}
.composer__send:hover { background: var(--accent-hover); transform: translateY(-1px); }
.composer__send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.chat__dock { flex: 0 0 auto; padding: var(--s-2) var(--s-7) calc(var(--s-5) + env(safe-area-inset-bottom, 0px)); }
.chat__dock .composer { max-width: 820px; margin: 0 auto; }
.chat__dock:empty { display: none; }

/* A file or photo waiting to go with the next message. */
.composer__file {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
  margin: 0 0 var(--s-2); padding: 6px 6px 6px 12px;
  border: 1px solid var(--border); border-radius: var(--r-full);
  background: var(--surface-2); color: var(--text); font-size: var(--fs-sm);
  max-width: 100%;
}
.composer__file[hidden] { display: none; }
.composer__file-name { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.composer__file-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer__file-x {
  flex: 0 0 auto; width: 28px; height: 28px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--text-muted);
}
.composer__file-x:hover { background: var(--surface-1); color: var(--text); }
.composer__attach { padding: 6px 9px; }

/* Messages -------------------------------------------------------------- */

.msg { display: flex; gap: var(--s-3); animation: fadeUp var(--t-base) both; min-width: 0; }
.msg--user { justify-content: flex-end; }
.msg__avatar { flex: 0 0 auto; margin-top: 2px; }
.msg__bubble { min-width: 0; overflow-wrap: anywhere; }
.msg--assistant .msg__bubble { flex: 1; padding-top: 3px; }
.msg--user .msg__bubble {
  max-width: min(80%, 600px);
  padding: 11px 16px;
  border-radius: 20px 20px 6px 20px;
  background: var(--surface-3);
  color: var(--text);
}
.msg__meta { margin-top: var(--s-2); font-size: var(--fs-xs); color: var(--text-dim); display: flex; gap: var(--s-2); flex-wrap: wrap; }
.msg__upload {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  margin-bottom: 6px; font-size: var(--fs-sm); color: var(--text-muted);
}
.msg__upload span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg__upload:last-child { margin-bottom: 0; }
.msg__tools { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-3); }
.msg__tools[hidden] { display: none; }
.msg__note { display: flex; align-items: center; gap: 6px; margin-top: var(--s-3); font-size: var(--fs-xs); color: var(--text-dim); }
.voice:empty { display: none; }
.voice { margin-top: var(--s-3); max-width: 640px; }
.voice .thinking { gap: var(--s-2); }
.voice__player { display: block; width: 100%; height: 40px; }
.msg__bubble .prose > *:first-child { margin-top: 0; }
.msg__bubble .prose > *:last-child { margin-bottom: 0; }

.thinking { display: flex; align-items: center; gap: var(--s-3); color: var(--text-muted); font-size: var(--fs-sm); }
.thinking__text {
  background: linear-gradient(90deg, var(--text-dim) 0%, var(--text) 50%, var(--text-dim) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 1.8s linear infinite;
}

/* Legacy task-detail bubbles */
.typing { display: flex; gap: 4px; padding: 4px 0; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim); animation: bounce 1.3s infinite; }
.typing span:nth-child(2) { animation-delay: 0.16s; }
.typing span:nth-child(3) { animation-delay: 0.32s; }
@keyframes bounce { 0%, 62%, 100% { transform: translateY(0); opacity: 0.4; } 31% { transform: translateY(-4px); opacity: 1; } }

.msg--in .msg__bubble,
.msg--out .msg__bubble {
  max-width: min(84%, 620px);
  padding: 10px 14px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface-1);
  overflow-wrap: anywhere;
}
.msg--out { flex-direction: row-reverse; }
.msg--out .msg__bubble { background: var(--surface-3); border-color: transparent; }
.msg--in .msg__avatar, .msg--out .msg__avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
}

/* Plan approval card ------------------------------------------------------ */

.plan {
  margin-top: var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.plan__head {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  background: var(--accent-soft);
  border-bottom: 1px solid var(--accent-border);
  font-weight: 620;
  font-size: var(--fs-sm);
  color: var(--accent-ink);
}
.plan__body { padding: var(--s-3) var(--s-4); display: flex; flex-direction: column; gap: var(--s-2); max-height: 420px; overflow-y: auto; }
.plan__target { padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); }
.plan__target-head { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.plan__who { font-weight: 620; font-size: var(--fs-sm); }
.plan__msg {
  margin-top: var(--s-2);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding-left: var(--s-3);
  border-left: 2px solid var(--border-strong);
}
.plan__foot { padding: var(--s-3) var(--s-4); border-top: 1px solid var(--border); display: flex; gap: var(--s-2); flex-wrap: wrap; }
.plan__choices { display: flex; flex-wrap: wrap; gap: var(--s-2); }
/* A card that asks the director to decide: the question and its choices, above the buttons */
.plan__decide { padding: var(--s-3) var(--s-4); border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--s-2); }
.plan__decide .plan__note { margin-top: 0; align-items: flex-start; }
.plan__decide .plan__note svg { flex-shrink: 0; margin-top: 2px; }

/* Files the assistant hands over ------------------------------------------ */

.file-card {
  margin-top: var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  max-width: 640px;
}
.file-card__head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4); }
.file-card__icon {
  width: 42px; height: 42px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text-muted);
}
.tone-sheet { background: var(--f-sheet-soft); color: var(--f-sheet); }
.tone-doc { background: var(--f-doc-soft); color: var(--f-doc); }
.tone-pdf { background: var(--f-pdf-soft); color: var(--f-pdf); }
.tone-media { background: var(--f-media-soft); color: var(--f-media); }
.file-card__text { flex: 1; min-width: 0; }
.file-card__name { font-weight: 620; font-size: var(--fs-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-card__meta { font-size: var(--fs-xs); color: var(--text-dim); margin-top: 1px; }
.file-card__actions { display: flex; gap: 6px; flex: 0 0 auto; }
.file-card--missing { box-shadow: none; background: var(--surface-2); }

.peek { position: relative; border-top: 1px solid var(--border); background: var(--surface-2); }
.peek__table { overflow: hidden; max-height: 220px; }
.peek table { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); }
.peek th, .peek td { padding: 6px 10px; text-align: left; white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; border-bottom: 1px solid var(--border); }
.peek th { font-weight: 650; color: var(--text); background: var(--surface-1); }
.peek td { color: var(--text-muted); }
.peek__fade {
  position: absolute; left: 0; right: 0; bottom: 0; height: 70px;
  background: linear-gradient(to bottom, transparent, var(--surface-2) 85%);
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 10px;
}
.peek__doc { padding: var(--s-3) var(--s-4); font-size: var(--fs-sm); color: var(--text-muted); max-height: 180px; overflow: hidden; }
.peek__doc h4 { margin: 0 0 4px; color: var(--text); font-size: var(--fs-base); }
.peek__doc p { margin: 0 0 6px; }
.peek__media { padding: var(--s-3); display: grid; place-items: center; }
.peek__media img { max-height: 260px; border-radius: var(--r-sm); }
.peek__media audio { width: 100%; }
.peek__loading { padding: var(--s-4); }

/* Full-screen file viewer --------------------------------------------------- */

.viewer-backdrop {
  position: fixed; inset: 0;
  z-index: 220;
  display: grid; place-items: center;
  padding: var(--s-5);
  background: rgba(12, 14, 20, 0.5);
  backdrop-filter: blur(6px);
  animation: fadeIn var(--t-fast) both;
}
.viewer {
  width: min(1180px, 100%);
  height: min(860px, 100%);
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: popIn var(--t-base) both;
}
.viewer__head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-4) var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); }
.viewer__title { flex: 1; min-width: 0; }
.viewer__tools { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.viewer__tools .search { max-width: 280px; }
.viewer__body { flex: 1; min-height: 0; overflow: auto; background: var(--surface-2); }
.viewer__foot { padding: var(--s-2) var(--s-5); font-size: var(--fs-xs); color: var(--text-dim); border-top: 1px solid var(--border); }

.sheet { border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); min-width: 100%; background: var(--surface-1); }
.sheet th, .sheet td { padding: 8px 12px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); white-space: nowrap; max-width: 360px; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.sheet thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); font-weight: 650; color: var(--text); }
.sheet .sheet__n { position: sticky; left: 0; z-index: 1; background: var(--surface-2); color: var(--text-dim); text-align: right; font-variant-numeric: tabular-nums; font-size: var(--fs-xs); min-width: 44px; }
.sheet thead .sheet__n { z-index: 3; }
.sheet tbody tr:hover td { background: var(--accent-soft); }
.sheet mark { background: var(--accent-border); color: inherit; border-radius: 3px; padding: 0 1px; }

.doc-page {
  max-width: 800px;
  margin: var(--s-6) auto;
  padding: var(--s-8) var(--s-8);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  line-height: var(--lh-loose);
}
.doc-page h1, .doc-page h2, .doc-page h3 { letter-spacing: -0.02em; line-height: var(--lh-tight); margin: var(--s-5) 0 var(--s-3); }
.doc-page h1:first-child, .doc-page h2:first-child { margin-top: 0; }
.doc-page p { margin: 0 0 var(--s-3); }
.doc-page table { border-collapse: collapse; width: 100%; margin: var(--s-4) 0; font-size: var(--fs-sm); }
.doc-page td { border: 1px solid var(--border); padding: 6px 10px; }
.doc-page tr:first-child td { background: var(--surface-2); font-weight: 600; }
.viewer__frame { width: 100%; height: 100%; border: 0; background: var(--surface-2); }
.viewer__media { height: 100%; display: grid; place-items: center; padding: var(--s-5); }
.viewer__media img, .viewer__media video { max-width: 100%; max-height: 100%; border-radius: var(--r-md); box-shadow: var(--shadow-lg); }
.viewer__text { margin: 0; padding: var(--s-5); font-family: var(--font-mono); font-size: var(--fs-sm); white-space: pre-wrap; }

/* ==========================================================================
   Command palette
   ========================================================================== */

.palette-backdrop {
  position: fixed; inset: 0;
  z-index: 240;
  display: flex; justify-content: center; align-items: flex-start;
  padding: 12vh var(--s-4) var(--s-4);
  background: rgba(12, 14, 20, 0.35);
  backdrop-filter: blur(4px);
  animation: fadeIn var(--t-fast) both;
}
.palette {
  width: min(600px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: popIn var(--t-base) both;
}
.palette__input-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); color: var(--text-dim); }
.palette__input { flex: 1; border: 0; outline: none; background: transparent; font-size: var(--fs-md); color: var(--text); }
.palette__list { max-height: 380px; overflow-y: auto; padding: var(--s-2); }
.palette__group { padding: var(--s-2) var(--s-3) 4px; font-size: var(--fs-xs); color: var(--text-dim); font-weight: 600; }
.palette__item {
  width: 100%;
  display: flex; align-items: center; gap: var(--s-3);
  padding: 9px var(--s-3);
  border: 0; border-radius: var(--r-sm);
  background: transparent;
  text-align: left;
  font-size: var(--fs-base);
  color: var(--text);
}
.palette__item .ico { color: var(--text-muted); }
.palette__item.is-active { background: var(--surface-3); }
.palette__item.is-active .ico { color: var(--accent); }
.palette__item span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette__empty { padding: var(--s-5); text-align: center; color: var(--text-dim); }

/* ==========================================================================
   Prose (AI-generated markdown)
   ========================================================================== */

.prose { font-size: var(--fs-base); line-height: var(--lh-loose); overflow-wrap: anywhere; }
.msg--assistant .prose { font-size: 14.5px; }
.prose h1, .prose h2, .prose h3 { margin: var(--s-5) 0 var(--s-3); font-weight: 650; letter-spacing: -0.02em; line-height: var(--lh-tight); }
.prose h1 { font-size: var(--fs-xl); }
.prose h2 { font-size: var(--fs-lg); }
.prose h3 { font-size: var(--fs-md); }
.prose > h1:first-child, .prose > h2:first-child, .prose > h3:first-child { margin-top: 0; }
.prose p { margin: 0 0 var(--s-3); }
.prose ul, .prose ol { margin: 0 0 var(--s-3); padding-left: var(--s-5); }
.prose li { margin-bottom: var(--s-1); }
.prose li::marker { color: var(--text-dim); }
.prose strong { font-weight: 650; color: var(--text); }
.prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 1.5px 6px;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.prose hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-5) 0; }
.prose blockquote { margin: 0 0 var(--s-3); padding-left: var(--s-4); border-left: 2px solid var(--border-strong); color: var(--text-muted); }

/* ==========================================================================
   Empty / loading states
   ========================================================================== */

.empty { text-align: center; padding: var(--s-8) var(--s-4); color: var(--text-muted); }
.empty__icon { font-size: 30px; margin-bottom: var(--s-3); opacity: 0.55; }
.empty__title { font-weight: 640; color: var(--text); font-size: var(--fs-md); }
.empty__text { margin-top: var(--s-2); font-size: var(--fs-base); max-width: 440px; margin-inline: auto; }
.empty__actions { margin-top: var(--s-5); display: flex; gap: var(--s-2); justify-content: center; flex-wrap: wrap; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skeleton--text, .skeleton--line { height: 12px; margin-bottom: var(--s-2); }
.skeleton--line:last-child { width: 62%; }
.skeleton--card { height: 88px; border-radius: var(--r-lg); }

/* Setup guidance (Instagram / Hikvision not configured) -------------------- */

.setup { border: 1px dashed var(--border-strong); border-radius: var(--r-lg); padding: var(--s-6); background: var(--surface-2); }
.setup__title { font-weight: 650; font-size: var(--fs-md); }
.setup__text { color: var(--text-muted); margin-top: var(--s-2); }
.setup__steps { margin: var(--s-4) 0 0; padding-left: var(--s-5); color: var(--text-muted); }
.setup__steps li { margin-bottom: var(--s-2); }
.setup__missing { margin-top: var(--s-4); display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ==========================================================================
   Media / cameras
   ========================================================================== */

.media-frame {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface-sunken);
  display: grid;
  place-items: center;
  min-height: 220px;
}
.media-frame img, .media-frame video { width: 100%; display: block; }

.cam-grid { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.cam-tile {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-1);
  padding: var(--s-3) var(--s-4);
  text-align: left;
  transition: all var(--t-fast);
}
.cam-tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.cam-tile.is-active { border-color: var(--accent); background: var(--accent-soft); }
.cam-tile__name { font-weight: 620; font-size: var(--fs-sm); }
.cam-tile__id { font-size: var(--fs-xs); color: var(--text-dim); font-family: var(--font-mono); }

/* ==========================================================================
   Instagram
   ========================================================================== */

.ig-post { display: flex; gap: var(--s-3); padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-1); }
.ig-post__thumb { width: 56px; height: 56px; flex: 0 0 auto; border-radius: var(--r-sm); object-fit: cover; background: var(--surface-3); }
.ig-post__body { flex: 1; min-width: 0; }
.ig-post__caption { font-size: var(--fs-sm); color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ig-post__stats { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-3); margin-top: var(--s-2); font-size: var(--fs-xs); color: var(--text-dim); }

/* Recommendations and the competitor comparison */
.ig-head-btn { margin-left: auto; flex: 0 0 auto; }
.ig-advice__meta { margin: calc(-1 * var(--s-3)) 0 var(--s-4); }
.ig-advice__summary { padding: var(--s-4); border: 1px solid var(--accent-border); border-radius: var(--r-md); background: var(--accent-soft); color: var(--text); line-height: 1.55; }
.ig-advice__sub { font-size: var(--fs-base); font-weight: 650; margin: var(--s-6) 0 var(--s-3); }
.ig-advice__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-4); }
.ig-advice__item { line-height: 1.55; font-size: var(--fs-sm); }
.ig-idea { padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-1); min-width: 0; }
.ig-idea__head { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.ig-idea__n { width: 22px; height: 22px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--surface-3); font-size: var(--fs-xs); font-weight: 650; }
.ig-idea__title { font-weight: 650; overflow-wrap: anywhere; }
.ig-idea__text { margin-top: var(--s-2); font-size: var(--fs-sm); line-height: 1.55; color: var(--text); }
.ig-idea__hook { margin-top: var(--s-2); font-size: var(--fs-sm); line-height: 1.5; color: var(--text-muted); }
.ig-idea__label { font-size: var(--fs-xs); font-weight: 650; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; }
.ig-refs { display: flex; flex-direction: column; gap: var(--s-2); margin-top: var(--s-2); }
.ig-ref { display: block; padding: var(--s-2) var(--s-3); border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2); color: inherit; text-decoration: none; min-width: 0; }
.ig-ref:hover { border-color: var(--border-strong); }
.ig-ref__head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--s-2); font-size: var(--fs-xs); color: var(--text-muted); }
.ig-ref__nums { display: inline-flex; align-items: center; gap: var(--s-2); margin-left: auto; color: var(--text-dim); }
.ig-ref__caption { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; font-size: var(--fs-xs); color: var(--text-dim); overflow-wrap: anywhere; }

/* ==========================================================================
   Modal
   ========================================================================== */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(12, 14, 20, 0.45);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: var(--s-4);
  z-index: 200;
  animation: fadeIn var(--t-fast) both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop);
  animation: popIn var(--t-base) both;
}
@keyframes popIn { from { opacity: 0; transform: scale(0.97) translateY(8px); } to { opacity: 1; transform: none; } }
.modal--wide { max-width: 760px; }
.modal__head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-5) var(--s-5) var(--s-4); border-bottom: 1px solid var(--border); }
.modal__title { font-weight: 650; font-size: var(--fs-md); flex: 1; letter-spacing: -0.015em; }
.modal__body { padding: var(--s-5); overflow-y: auto; flex: 1; }
.modal__foot { padding: var(--s-4) var(--s-5); border-top: 1px solid var(--border); display: flex; gap: var(--s-2); justify-content: flex-end; flex-wrap: wrap; }

/* ==========================================================================
   Toasts
   ========================================================================== */

.toasts {
  position: fixed;
  bottom: calc(var(--s-5) + env(safe-area-inset-bottom, 0px));
  right: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  z-index: 300;
  pointer-events: none;
  max-width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: slideIn var(--t-base) both;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.toast__body { flex: 1; min-width: 0; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.toast__title { font-weight: 640; }
.toast__close { border: 0; background: transparent; color: var(--text-dim); line-height: 1; padding: 2px; }
.toast__icon { flex: 0 0 auto; margin-top: 1px; }
.toast--good .toast__icon { color: var(--good); }
.toast--bad .toast__icon { color: var(--bad); }
.toast--warn .toast__icon { color: var(--warn); }
.toast--info .toast__icon { color: var(--info); }

/* ==========================================================================
   Task list rows, key/value lists, progress
   ========================================================================== */

.task-row {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  margin-bottom: var(--s-2);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.task-row:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.task-row__main { flex: 1; min-width: 0; }
.task-row__title { font-weight: 620; font-size: var(--fs-base); letter-spacing: -0.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row__meta { margin-top: 3px; font-size: var(--fs-sm); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row__side { flex: 0 0 auto; display: flex; align-items: center; gap: var(--s-2); }

.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: var(--s-2) var(--s-4); align-items: baseline; }
.kv__k { font-size: var(--fs-sm); font-weight: 600; color: var(--text-dim); }
.kv__v { font-size: var(--fs-base); overflow-wrap: anywhere; }

.progress { height: 6px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.progress > * { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width var(--t-slow); }

/* ==========================================================================
   Utilities
   ========================================================================== */

.row { display: flex; gap: var(--s-2); align-items: center; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: var(--s-3); }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.mono { font-family: var(--font-mono); font-size: 0.93em; }
.nowrap { white-space: nowrap; }
.tabnum { font-variant-numeric: tabular-nums; }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.mt-2 { margin-top: var(--s-2); }
.mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); }
.mt-5 { margin-top: var(--s-5); }
.mb-0 { margin-bottom: 0; }
.hide { display: none !important; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1100px) {
  .search-pill { width: auto; }
  .search-pill__text, .search-pill kbd { display: none; }
  .composer__hint { visibility: hidden; }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 272px; }

  .icon-btn.topbar__menu { display: grid; }
  .topbar { padding-inline: var(--s-3) var(--s-3); }
  .brand__collapse { display: none; }

  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 40;
    padding-top: calc(var(--s-4) + env(safe-area-inset-top, 0px));
    transform: translateX(-100%);
    transition: transform var(--t-base);
    box-shadow: var(--shadow-pop);
  }
  .sidebar.is-open { transform: none; }
  .app--collapsed .sidebar { width: var(--sidebar-w); }

  .scrim {
    position: fixed;
    inset: 0;
    background: rgba(12, 14, 20, 0.4);
    z-index: 35;
    animation: fadeIn var(--t-fast) both;
  }

  .frame { margin: 0; border-radius: 0; border: 0; box-shadow: none; }
  .main { padding: var(--s-5) var(--s-4) calc(var(--s-8) + env(safe-area-inset-bottom, 0px)); }
  .chat-head { padding: var(--s-4) var(--s-4) var(--s-2); }
  .chat__scroll { padding: var(--s-3) var(--s-4) var(--s-5); }
  .chat__dock { padding-inline: var(--s-3); }
  .page-title, .view__title { font-size: var(--fs-xl); }
  .toasts { right: var(--s-3); left: var(--s-3); max-width: none; }
  .viewer-backdrop { padding: 0; }
  .viewer { border-radius: 0; height: 100%; }
}

@media (max-width: 560px) {
  .lang-switch, .theme-toggle { display: none; }
  .crumbs__home span { display: none; }
  .page-head__actions { width: 100%; }
  .page-head__actions .btn { flex: 1; }
  .stat__value { font-size: var(--fs-xl); }
  .msg--user .msg__bubble { max-width: 88%; }
  .modal { max-height: 92vh; }
  .table th, .table td { padding: var(--s-3); }
  .orb { --size: 108px; }
  .hero__greet { margin: var(--s-5) 0 var(--s-5); }
  .composer__hint { display: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .chat-head { padding-block: var(--s-3) var(--s-1); align-items: center; }
  .chat-head__sub { display: none; }
  .chat-head .btn__label { display: none; }
  .chat-head .btn { width: 40px; height: 40px; padding: 0; }
  .idea-grid { grid-template-columns: 1fr 1fr; }
  .idea { min-height: 0; }
  .idea__text { -webkit-line-clamp: 2; }
  .file-card__head { flex-wrap: wrap; }
  .file-card__actions { width: 100%; }
  .file-card__actions .btn { flex: 1; }
  .doc-page { margin: 0; padding: var(--s-5); border-radius: 0; }
}

/* Mobile-only language/theme controls live in the drawer. */
.side-prefs { display: none; gap: var(--s-2); margin-top: var(--s-3); }
@media (max-width: 560px) {
  .side-prefs { display: flex; }
  .side-prefs .lang-switch, .side-prefs .theme-toggle { display: flex; }
}

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

/* Dashboard quick links reuse the assistant's idea cards, shorter. */
.idea--compact { min-height: 0; flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: var(--s-3); animation: none; }
.idea--compact .idea__title { margin-top: 0; flex: 1; }
.idea--compact .idea__text { flex-basis: 100%; }


/* ==========================================================================
   Shared pieces for the task, system and content pages
   ========================================================================== */

:focus:not(:focus-visible) { outline: none; }

.badge--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge .ico { margin: 0 -1px; }

.card + .card { margin-top: var(--s-4); }
.card__head .badge, .card__head .btn { margin-left: auto; }
.card__head .card__title + .badge { margin-left: 0; }
.card__text { color: var(--text-muted); font-size: var(--fs-sm); line-height: 1.6; margin: 0; }

.back-link {
  display: inline-flex; align-items: center; gap: 4px;
  margin-bottom: var(--s-3);
  padding: 4px 10px 4px 4px;
  border: 0; border-radius: var(--r-full);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-sm); font-weight: 550;
}
.back-link:hover { background: var(--surface-2); color: var(--text); }
.meta-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--text-dim); font-size: var(--fs-sm); }
.meta-line code { font-family: var(--font-mono); font-size: 11.5px; }

/* The one question a task is waiting on. */
.decision {
  padding: var(--s-5);
  margin-bottom: var(--s-4);
  border: 1px solid var(--warn-border);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, var(--warn-soft), var(--surface-1) 140%);
}
.decision__head { display: flex; align-items: center; gap: var(--s-2); color: var(--warn); font-weight: 650; font-size: var(--fs-sm); }
.decision__who { margin-left: auto; color: var(--text-muted); font-weight: 550; }
.decision__q { margin: var(--s-3) 0 var(--s-4); font-size: var(--fs-md); line-height: 1.55; color: var(--text); }
.decision__label { font-size: var(--fs-xs); color: var(--text-dim); font-weight: 600; margin-bottom: var(--s-2); }
.decision__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.decision__actions .btn { white-space: normal; text-align: left; justify-content: flex-start; }

/* People a task talks to, with the last message each way. */
.contact { padding: var(--s-4) var(--s-5); border-top: 1px solid var(--border); }
.contact:first-child { border-top: 0; }
.contact__head { display: flex; align-items: flex-start; gap: var(--s-3); }
.contact__name { font-weight: 620; }
.contact__sub { font-size: var(--fs-xs); color: var(--text-dim); margin-top: 1px; }
.contact__head .badge { margin-left: auto; }
.contact__note { margin-top: var(--s-2); font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.5; }
.thread { margin-top: var(--s-3); display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 88%; padding: 9px 13px; border-radius: 16px; font-size: var(--fs-sm); line-height: 1.5; overflow-wrap: anywhere; }
.bubble__who { display: block; font-size: 10.5px; font-weight: 600; opacity: 0.65; margin-bottom: 2px; }
.bubble--out { align-self: flex-end; background: var(--surface-3); border-bottom-right-radius: 5px; }
.bubble--in { align-self: flex-start; background: var(--surface-1); border: 1px solid var(--border); border-bottom-left-radius: 5px; }

.list-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: 12px var(--s-5); border-top: 1px solid var(--border); font-size: var(--fs-base); }
.list-row:first-child { border-top: 0; }
.list-row__v { color: var(--text-muted); font-size: var(--fs-sm); text-align: right; min-width: 0; overflow-wrap: anywhere; }

.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: var(--s-3); }
.steps li { counter-increment: step; display: flex; gap: var(--s-3); font-size: var(--fs-base); color: var(--text-muted); line-height: 1.5; }
.steps li::before {
  content: counter(step);
  flex: 0 0 auto; width: 24px; height: 24px; margin-top: -1px;
  display: grid; place-items: center;
  border-radius: 50%; background: var(--surface-3); color: var(--text); font-size: 12px; font-weight: 650;
}
.checks { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--s-2); }
.checks li { display: flex; gap: var(--s-2); color: var(--text-muted); font-size: var(--fs-base); line-height: 1.5; }
.checks li .ico { color: var(--good); margin-top: 2px; }

.qa { padding: var(--s-4) var(--s-5); border-top: 1px solid var(--border); }
.qa:first-child { border-top: 0; }
.qa__t { font-weight: 620; font-size: var(--fs-sm); margin-bottom: 3px; }
.qa__q { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.6; }

.chip-row { display: flex; gap: var(--s-2); overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin-bottom: var(--s-4); }
.chip-row::-webkit-scrollbar { display: none; }
.pill {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface-1);
  color: var(--text-muted);
  font-size: var(--fs-sm); font-weight: 560;
  white-space: nowrap;
  transition: all var(--t-fast);
}
.pill:hover { color: var(--text); border-color: var(--border-strong); }
.pill.is-active { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }

.tpl { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-top: 1px solid var(--border); }
.tpl:first-child { border-top: 0; }
.tpl__text { flex: 1; min-width: 0; font-size: var(--fs-base); line-height: 1.5; }

.range { width: 100%; accent-color: var(--accent); }
.field__row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }

/* ==========================================================================
   Top bar title / slot and the phone tab bar
   ========================================================================== */

.topbar__title { display: none; font-weight: 650; font-size: 17px; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar__slot { display: flex; align-items: center; gap: var(--s-2); }
.topbar__slot:empty { display: none; }
.tabbar { display: none; }

@media (max-width: 560px) {
  :root { --header-h: 54px; }

  .topbar { padding: 0 var(--s-3) 0 var(--s-4); gap: var(--s-2); }
  .crumbs, .avatar, .icon-btn.topbar__menu { display: none !important; }
  .topbar__title { display: block; flex: 1; }
  .topbar__spacer { display: none; }
  .search-pill { width: 36px; height: 36px; padding: 0; justify-content: center; }
  .topbar__slot .btn__label { display: none; }
  .topbar__slot .btn { width: 36px; height: 36px; padding: 0; border-radius: 50%; }

  .tabbar {
    display: flex;
    flex: 0 0 auto;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
    background: var(--panel);
  }
  .tabbar__btn {
    flex: 1;
    min-width: 0;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 4px 2px;
    border: 0; background: transparent;
    color: var(--text-dim);
    font-size: 10.5px; font-weight: 560;
  }
  .tabbar__icon { position: relative; display: grid; place-items: center; width: 44px; height: 28px; border-radius: var(--r-full); transition: background var(--t-fast); }
  .tabbar__btn.is-active { color: var(--text); }
  .tabbar__btn.is-active .tabbar__icon { background: var(--accent-soft); color: var(--accent-ink); }
  .tabbar__label { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tabbar__badge {
    position: absolute; top: -2px; right: 4px;
    min-width: 16px; height: 16px; padding: 0 4px;
    display: grid; place-items: center;
    border-radius: var(--r-full);
    background: var(--bad); color: #fff;
    font-size: 9.5px; font-weight: 700;
    box-shadow: 0 0 0 2px var(--panel);
  }

  /* The top bar names the page, so the big in-page title would say it twice. */
  .page-title,
  .view__head > .view__title:first-child,
  .view__head > div > .view__title:first-child { display: none; }
  .page-head, .view__head { margin-bottom: var(--s-4); gap: var(--s-3); }
  .page-sub, .view__sub { font-size: var(--fs-sm); margin-top: 0; }
  .page-head__actions { width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .page-head__actions::-webkit-scrollbar { display: none; }
  .page-head__actions .btn { flex: 0 0 auto; padding: 7px 13px; font-size: var(--fs-sm); }

  .main { padding: var(--s-4) var(--s-4) var(--s-6); }
  .section { margin-bottom: var(--s-6); }
  .section__head { margin-bottom: var(--s-3); }
  .section__title { font-size: var(--fs-base); }
  .grid { gap: var(--s-2); }
  .grid--4, .grid--3 { grid-template-columns: 1fr 1fr; }
  .grid--2 { grid-template-columns: 1fr; gap: var(--s-3); }
  .stat { padding: var(--s-3) var(--s-4); border-radius: var(--r-md); box-shadow: var(--shadow-sm); }
  .stat__label { font-size: var(--fs-xs); }
  .stat__value { font-size: 22px; margin-top: 4px; }
  .stat__meta { font-size: 11px; }
  .card { border-radius: var(--r-md); box-shadow: var(--shadow-sm); }
  .card__head { padding: var(--s-3) var(--s-4); }
  .card__body { padding: var(--s-4); }
  .card__foot { padding: var(--s-3) var(--s-4); }
  .card__foot .btn { flex: 1; }

  .alert { padding: var(--s-3); flex-wrap: wrap; border-radius: var(--r-md); }
  .alert__icon { width: 30px; height: 30px; }
  .alert__action { width: 100%; padding-left: 42px; }
  .alert__action .btn { width: 100%; }

  .toolbar { gap: var(--s-2); }
  .toolbar .search { flex-basis: 100%; }
  .toolbar .segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .toolbar .spacer { display: none; }

  .task-row { padding: var(--s-3) var(--s-4); gap: var(--s-3); border-radius: var(--r-md); }
  .task-row__side .badge { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }

  .decision { padding: var(--s-4); }
  .decision__actions { flex-direction: column; }
  .decision__actions .btn { width: 100%; justify-content: center; text-align: center; }
  .contact { padding: var(--s-3) var(--s-4); }
  .list-row, .qa, .tpl { padding-inline: var(--s-4); }
  .tpl { flex-direction: column; }
  .tpl .btn { width: 100%; }

  /* Tables become one card per row: the first cell is the title, the rest are
     labelled lines under it. */
  .table-wrap:has(.table--stack) { overflow: visible; border: 0; background: none; box-shadow: none; }
  .table--stack thead { display: none; }
  .table--stack, .table--stack tbody { display: block; }
  .table--stack tr {
    display: grid; grid-template-columns: 1fr auto; gap: 6px var(--s-3);
    padding: var(--s-3) var(--s-4);
    margin-bottom: var(--s-2);
    border: 1px solid var(--border); border-radius: var(--r-md);
    background: var(--surface-1);
  }
  .table--stack tbody tr:hover { background: var(--surface-1); }
  .table--stack td {
    grid-column: 1 / -1;
    display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3);
    padding: 0; border: 0; text-align: right; font-size: var(--fs-sm);
  }
  .table--stack td::before { content: attr(data-label); flex: 0 0 auto; color: var(--text-dim); font-size: var(--fs-xs); text-align: left; }
  .table--stack td.cell-main { grid-column: 1; grid-row: 1; display: block; text-align: left; font-size: var(--fs-base); }
  .table--stack td.cell-act { grid-column: 2; grid-row: 1; align-self: start; }
  .table--stack td.cell-main::before, .table--stack td.cell-act::before { content: none; }
  .table--stack td.cell-block { display: block; text-align: left; }
  .table--stack td.cell-block::before { display: block; margin-bottom: 2px; }

  /* Dialogs rise from the bottom like a native sheet. */
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { max-width: none; max-height: 88vh; border-radius: var(--r-xl) var(--r-xl) 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); animation: sheetUp var(--t-base) both; }
  .modal__foot .btn { flex: 1; }
  .toasts { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }

  .chat-head { display: none; }
  .chat__dock { padding-bottom: var(--s-3); }
  .orb { --size: 96px; }
  .hero__greet { font-size: 27px; margin: var(--s-4) 0 var(--s-5); }
  .hero .composer__input { min-height: 56px; }
  .explore { margin-top: var(--s-6); }
  .idea { padding: var(--s-3); gap: 4px; border-radius: var(--r-md); }
  .idea__icon { width: 30px; height: 30px; }
  .idea__title { font-size: var(--fs-sm); margin-top: 6px; }
  .idea__text { font-size: 11.5px; }
  .idea__foot { display: none; }
}
@keyframes sheetUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--text-dim); vertical-align: 1px; }
.status-dot.is-on { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.status-dot.is-bad { background: var(--bad); }
.grid + .card, .card + .grid, .grid + .section { margin-top: var(--s-4); }
.ig-post__stats span { display: inline-flex; align-items: center; gap: 4px; }
.plan__head .ico { flex: 0 0 auto; }
.plan__note { display: flex; align-items: center; gap: 6px; margin-top: var(--s-2); font-size: var(--fs-xs); color: var(--text-dim); }
.boot__icon { color: var(--text-muted); }
.card__head + .list-row, .card__head + .contact, .card__head + .qa, .card__head + .tpl { border-top: 0; }
@media (max-width: 560px) {
  .view__head > .view__title.view__title--keep { display: block; font-size: var(--fs-xl); }
  .card__body .btn-row .btn { flex: 1 1 auto; }
}
@media (max-width: 560px) {
  .table--stack td.cell-minor { display: none; }
  .chat__dock .composer__chips { display: none; }
  .chat__dock .composer { display: flex; align-items: flex-end; gap: 6px; padding: 5px; }
  .chat__dock .composer__box { flex: 1; min-width: 0; padding: 11px 14px; }
  .chat__dock .composer__spark { display: none; }
  .chat__dock .composer__bar { padding: 0 1px 1px 0; }
  .chat__dock .composer__hint { display: none; }
}
