/* ==========================================================================
   Nura design system
   Tokens first. Every component below composes these - no ad-hoc values.
   ========================================================================== */

@font-face {
  font-family: "Excalifont";
  src: url("https://cdn.jsdelivr.net/npm/@excalidraw/excalidraw@0.18.0/dist/prod/fonts/Excalifont/Excalifont-Regular-a88b72a24fb54c9f94e3b5fdaa7481c9.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  /* --- surface --------------------------------------------------------
     Neutral, not ivory. The warmth belongs to the drawing surface and to
     the serif; everywhere else it turned the chrome cream, which reads as
     a theme rather than as a workspace. Panels are white, the page behind
     them is one step of neutral grey, and separation is a hairline. */
  --paper: #f7f7f8;
  --surface: #ffffff;
  --surface-sunken: #f3f3f5;
  --surface-hover: #f0f0f2;
  --line: #eaeaed;
  --line-strong: #dddde1;
  --line-heavy: #cdcdd3;

  /* --- ink ------------------------------------------------------------ */
  --ink: #1a1a1d;
  --ink-soft: #46464d;
  --muted: #6e6e78;
  --faint: #9a9aa4;

  /* --- accent ---------------------------------------------------------
     One accent, and a quiet one. A saturated violet reads as an AI demo;
     this is deep enough to carry intent and dull enough to sit beside ivory
     without becoming the loudest thing on screen. */
  --accent: #4b4f96;
  --accent-hover: #3f4383;
  --accent-ink: #343767;
  --accent-wash: #eeeef5;
  --accent-line: #d8d9e8;
  --on-accent: #ffffff;

  /* --- status (muted on purpose) -------------------------------------- */
  --ok: #3f8f68;
  --ok-wash: #e9f3ee;
  --warn: #a8722c;
  --warn-wash: #f6efe3;
  --danger: #b4483f;
  --danger-wash: #f8ecea;

  /* --- type ----------------------------------------------------------- */
  --font-ui: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Instrument Serif", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --t-micro: 11px;
  --t-tiny: 12px;
  --t-small: 13px;
  --t-base: 14px;
  --t-lead: 16px;
  --t-title: 20px;
  --t-page: 26px;
  --t-display: 34px;

  /* --- space ---------------------------------------------------------- */
  --s1: 4px;
  --s2: 6px;
  --s3: 8px;
  --s4: 12px;
  --s5: 16px;
  --s6: 20px;
  --s7: 24px;
  --s8: 32px;
  --s9: 40px;
  --s10: 56px;

  /* --- shape ---------------------------------------------------------- */
  --r-control: 6px;
  --r-card: 10px;
  --r-panel: 14px;
  --r-handle: 9px;
  --r-pill: 999px;

  --h-sm: 26px;
  --h-md: 32px;
  --h-lg: 38px;

  /* --- elevation (deliberately almost nothing) ------------------------ */
  --shadow-1: 0 1px 2px rgba(21, 21, 26, 0.05);
  --shadow-2: 0 1px 2px rgba(21, 21, 26, 0.05), 0 6px 20px rgba(21, 21, 26, 0.06);

  /* --- motion --------------------------------------------------------- */
  --fast: 110ms cubic-bezier(0.2, 0, 0.1, 1);
  --base: 180ms cubic-bezier(0.2, 0, 0.1, 1);
  --slow: 300ms cubic-bezier(0.2, 0, 0.1, 1);

  /* --- layout --------------------------------------------------------- */
  --w-sidebar: 232px;
  --w-assistant: 344px;
  --vv-offset: 0px;
  --app-height: 100vh;
  --app-height: 100dvh;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--t-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-control);
}

::selection {
  background: var(--accent-wash);
}

/* ==========================================================================
   App shell
   ========================================================================== */

.app {
  display: grid;
  grid-template-columns: var(--w-sidebar) minmax(0, 1fr) var(--w-assistant);
  height: var(--app-height);
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
  transition: grid-template-columns var(--base);
}

.app.nav-collapsed {
  --w-sidebar: 0px;
}

.app.assistant-collapsed {
  --w-assistant: 0px;
}

.app:fullscreen {
  /* Fullscreen hides browser chrome only. Panel width is owned by
     .nav-collapsed / .assistant-collapsed so edge-toggle restore still works. */
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  width: var(--w-sidebar);
  min-width: var(--w-sidebar);
  height: 100%;
  padding: var(--s5) var(--s4) var(--s4);
  opacity: 1;
  transition: opacity var(--fast);
}

.app.nav-collapsed .sidebar-inner {
  opacity: 0;
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s3);
  height: var(--h-lg);
  padding: 0 var(--s3);
  margin-bottom: var(--s6);
}

.brand-mark {
  flex: none;
  color: var(--accent);
  display: inline-flex;
}

.brand-name {
  font-size: var(--t-lead);
  font-weight: 600;
  letter-spacing: -0.018em;
  margin: 0;
}

.brand-collapse {
  margin-left: auto;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s4);
  height: var(--h-md);
  padding: 0 var(--s3);
  border: 0;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--ink-soft);
  font-size: var(--t-small);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--fast), color var(--fast);
}

.nav-item .icon {
  color: var(--faint);
  transition: color var(--fast);
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.nav-item[aria-current="page"] {
  background: var(--accent-wash);
  color: var(--accent-ink);
  font-weight: 600;
}

.nav-item[aria-current="page"] .icon {
  color: var(--accent);
}

/* The project group. Ownership is carried by a label, indentation and space -
   not by a card, a border or a colour. It exists only while a project is open. */
.nav-project {
  margin-top: var(--s6);
}

.nav-project-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 0 var(--s2) 0 var(--s3);
  margin-bottom: var(--s2);
}

.nav-project-name {
  min-width: 0;
  flex: 1;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: color var(--fast);
}

.nav-project-name:hover {
  color: var(--ink);
}

.nav-project-full {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-project-initial {
  display: none;
}

/* The indent is the hierarchy. The hairline keeps it readable at a glance
   without adding a container. */
.nav-item-child {
  margin-left: var(--s4);
  padding-left: var(--s4);
  border-left: 1px solid var(--line);
  border-radius: 0 var(--r-control) var(--r-control) 0;
}

.nav-divider {
  height: 1px;
  background: var(--line);
  margin: var(--s5) var(--s3);
}

.sidebar-foot {
  margin-top: auto;
  padding-top: var(--s4);
}

.account {
  display: flex;
  align-items: center;
  gap: var(--s4);
  width: 100%;
  padding: var(--s3);
  border: 0;
  border-radius: var(--r-control);
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background var(--fast);
}

.account:hover {
  background: var(--surface-hover);
}

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-control);
  background: var(--accent-wash);
  color: var(--accent-ink);
  font-size: var(--t-tiny);
  font-weight: 600;
}

.account-text {
  min-width: 0;
}

.account-name {
  display: block;
  font-size: var(--t-small);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account[aria-current="page"] {
  background: var(--accent-wash);
  color: var(--accent-ink);
}

/* --- settings and workspace screens ---------------------------------------
   Two destinations built entirely out of existing tokens: a disclosure row for
   a setting that has an editor, and a plain figure for a count. */

.setting {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  overflow: hidden;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: var(--s4);
  width: 100%;
  padding: var(--s4) var(--s5);
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background var(--fast);
}

.setting-row:hover {
  background: var(--surface-hover);
}

.setting-label {
  font-size: var(--t-base);
  color: var(--ink);
}

.setting-value {
  margin-left: auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--t-small);
  color: var(--muted);
}

.setting-chevron {
  flex: none;
  display: inline-flex;
  color: var(--faint);
  transition: transform var(--fast);
}

.setting-row[aria-expanded="true"] .setting-chevron {
  transform: rotate(90deg);
}

.setting-editor {
  padding: var(--s5);
  border-top: 1px solid var(--line);
  background: var(--surface-sunken);
}

.setting-note {
  margin: var(--s3) 0 0;
  font-size: var(--t-small);
  color: var(--muted);
}

.setting-static {
  margin: 0;
  font-size: var(--t-lead);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s4);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  padding: var(--s5);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--fast);
}

.stat:hover {
  border-color: var(--line-heavy);
}

.stat-value {
  font-family: var(--font-display);
  font-size: var(--t-display);
  line-height: 1.1;
}

.stat-label {
  font-size: var(--t-small);
  color: var(--muted);
}

@media (max-width: 760px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ==========================================================================
   Primitives
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  height: var(--h-md);
  padding: 0 var(--s4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--t-small);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: background var(--fast), border-color var(--fast), color var(--fast);
}

.btn:hover:not(:disabled) {
  background: var(--surface-hover);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--ink-soft);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--ink);
}

.btn-danger {
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-wash);
  border-color: var(--danger);
}

.btn-lg {
  height: var(--h-lg);
  padding: 0 var(--s5);
  font-size: var(--t-base);
}

.btn-sm {
  height: var(--h-sm);
  padding: 0 var(--s3);
  font-size: var(--t-tiny);
}

.btn-block {
  width: 100%;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--h-md);
  height: var(--h-md);
  padding: 0;
  border: 0;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--fast), color var(--fast);
}

.icon-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--ink);
}

.icon-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.icon-btn-sm {
  width: var(--h-sm);
  height: var(--h-sm);
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  height: 20px;
  padding: 0 var(--s2);
  border-radius: var(--r-control);
  background: var(--surface-sunken);
  color: var(--muted);
  font-size: var(--t-micro);
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge-ok {
  background: var(--ok-wash);
  color: var(--ok);
}

.badge-warn {
  background: var(--warn-wash);
  color: var(--warn);
}

.badge-accent {
  background: var(--accent-wash);
  color: var(--accent-ink);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
  flex: none;
}

.dot.active {
  background: var(--accent);
}

.dot.error {
  background: var(--danger);
}

.tabs {
  display: flex;
  gap: var(--s5);
  border-bottom: 1px solid var(--line);
}

.tab {
  position: relative;
  height: var(--h-lg);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--t-small);
  font-weight: 500;
  cursor: pointer;
  transition: color var(--fast);
}

.tab:hover {
  color: var(--ink);
}

.tab[aria-selected="true"] {
  color: var(--ink);
}

.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
}

/* ==========================================================================
   Page scaffolding (Home, Projects, Sources, Recordings, Library)
   ========================================================================== */

.page {
  min-width: 0;
  height: var(--app-height);
  overflow-y: auto;
  background: var(--paper);
  -webkit-overflow-scrolling: touch;
}

.page-inner {
  max-width: 940px;
  margin: 0 auto;
  padding: var(--s10) var(--s8) var(--s9);
}

.page-header {
  margin-bottom: var(--s8);
}

.page-eyebrow {
  font-size: var(--t-tiny);
  font-weight: 500;
  color: var(--faint);
  letter-spacing: 0.02em;
  margin: 0 0 var(--s2);
}

.page-title {
  font-family: var(--font-display);
  font-size: var(--t-page);
  font-weight: 400;
  letter-spacing: -0.01em;
  margin: 0;
}

.page-sub {
  margin: var(--s2) 0 0;
  color: var(--muted);
  font-size: var(--t-small);
  max-width: 58ch;
}

.page-header-row {
  display: flex;
  align-items: flex-start;
  gap: var(--s5);
}

.page-actions {
  margin-left: auto;
  display: flex;
  gap: var(--s3);
  padding-top: var(--s1);
}

.section {
  margin-top: var(--s9);
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: var(--s4);
  margin-bottom: var(--s5);
}

.section-title {
  font-size: var(--t-small);
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
}

.section-note {
  font-size: var(--t-tiny);
  color: var(--faint);
}

.section-head .btn {
  margin-left: auto;
}

.grid {
  display: grid;
  gap: var(--s4);
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.rows {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: var(--s4);
  width: 100%;
  padding: var(--s4) var(--s5);
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background var(--fast);
}

/* A row that states something rather than leading somewhere. */
.row-static {
  cursor: default;
}

.row:first-child {
  border-top: 0;
}

.row:hover {
  background: var(--surface-hover);
}

.row.row-static:hover {
  background: transparent;
}

.row-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-control);
  background: var(--surface-sunken);
  color: var(--muted);
}

.row-body {
  min-width: 0;
  flex: 1;
}

.row-title {
  display: block;
  font-size: var(--t-small);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-meta {
  display: block;
  font-size: var(--t-tiny);
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-trail {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s3);
  color: var(--faint);
  font-size: var(--t-tiny);
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s4);
  padding: var(--s8) var(--s7);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-card);
  background: var(--surface);
}

.empty-title {
  margin: 0;
  font-size: var(--t-base);
  font-weight: 600;
}

.empty-text {
  margin: 0;
  color: var(--muted);
  font-size: var(--t-small);
  max-width: 52ch;
}

.empty-actions {
  display: flex;
  gap: var(--s3);
}

/* An empty state is an invitation, not a page's primary action - and where the
   page does have one it already sits in the header. Quieting the fill here is
   what keeps any single screen from showing two competing primaries; it uses
   the same quiet-accent language as the assistant's mic control. */
.empty-actions .btn-primary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--accent-ink);
  box-shadow: var(--shadow-1);
}

.empty-actions .btn-primary:hover:not(:disabled) {
  background: var(--accent-wash);
  border-color: var(--accent-line);
}

/* --- home ------------------------------------------------------------- */

.home-greeting {
  font-family: var(--font-display);
  font-size: var(--t-display);
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin: 0 0 var(--s2);
}

.home-prompt {
  display: flex;
  align-items: center;
  gap: var(--s4);
  width: 100%;
  margin-top: var(--s6);
  padding: 0 var(--s3) 0 var(--s5);
  height: 52px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--faint);
  font-size: var(--t-base);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: border-color var(--fast), box-shadow var(--fast);
}

.home-prompt:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.home-prompt-mic {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: var(--h-lg);
  height: var(--h-lg);
  border-radius: var(--r-control);
  background: var(--accent);
  color: var(--on-accent);
}

/* The first-run explanation. Three lines of type on a hairline - the point is
   to say what happens when you talk, not to dress it up as three cards. */
.home-first {
  margin-top: var(--s9);
}

.home-flow {
  margin: 0 0 var(--s7);
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
  max-width: 60ch;
}

.home-flow li {
  display: flex;
  gap: var(--s5);
  align-items: baseline;
  padding: var(--s4) 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--t-small);
}

.home-flow-step {
  flex: none;
  width: 6ch;
  font-family: var(--font-display);
  font-size: var(--t-base);
  color: var(--ink);
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  margin-top: var(--s5);
}

/* ==========================================================================
   Canvas screen
   ========================================================================== */

/* The canvas stays mounted across routes so a trip to Home never discards
   scene state; other screens render in the same cell. */
.center {
  position: relative;
  min-width: 0;
  height: var(--app-height);
  overflow: hidden;
}

.canvas-screen {
  position: relative;
  min-width: 0;
  height: var(--app-height);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow: hidden;
}

.canvas-topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s4);
  height: 46px;
  padding: 0 var(--s4);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.crumbs {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-width: 0;
  font-size: var(--t-small);
  color: var(--muted);
}

.crumb-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: color var(--fast);
}

.crumb-link:hover {
  color: var(--ink);
}

.crumb-sep {
  color: var(--faint);
}

.crumb-current {
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--s3);
}

.segmented {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--surface-sunken);
}

.segmented button {
  height: 24px;
  padding: 0 var(--s3);
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: var(--t-tiny);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--fast), color var(--fast), box-shadow var(--fast);
}

.segmented button:hover:not(:disabled):not(.active) {
  color: var(--ink);
}

.segmented button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}

.segmented button:disabled {
  opacity: 0.5;
  cursor: default;
}

.canvas-stage {
  position: relative;
  flex: 1;
  min-height: 0;
}

.canvas-stage .excalidraw-wrapper,
.canvas-stage .excalidraw {
  height: 100%;
}

/* Excalidraw visual refinement - surfaces only, no mechanics touched. */
.excalidraw {
  --color-primary: var(--accent);
  --color-primary-darker: var(--accent-hover);
  --color-primary-darkest: var(--accent-ink);
  --color-primary-light: var(--accent-wash);
  --island-bg-color: var(--surface);
  --default-border-color: var(--line);
  --color-surface-low: var(--surface-sunken);
  --color-surface-mid: var(--surface-sunken);
  --color-surface-high: var(--surface);
  --border-radius-lg: var(--r-card);
  --border-radius-md: var(--r-control);
  --ui-font: var(--font-ui);
}

.excalidraw .Island {
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  border-radius: var(--r-card);
}

.excalidraw .App-toolbar {
  padding: var(--s1);
}

/* Excalidraw ships its own shape library. Nura owns Library in the
   workspace nav, so the in-canvas entry point would be a second, conflicting
   one. Everything else in the toolbar stays. */
.excalidraw .layer-ui__wrapper__top-right {
  display: none;
}

/* --- the drawing tools -------------------------------------------------
   Excalidraw's own chrome is a drawing app's chrome: numbered shortcuts on
   every tool, a hand-tool hint under the toolbar, a help launcher in the
   corner. Inside Nura the canvas is the workspace, not the application,
   so the furniture goes and the tools stay. Surfaces only - no mechanics. */

.excalidraw .ToolIcon__keybinding {
  display: none;
}

.excalidraw .HintViewer {
  display: none;
}

.excalidraw .help-icon {
  display: none;
}

.excalidraw .ToolIcon__icon {
  color: var(--ink-soft);
  border-radius: var(--r-control);
  transition: background var(--fast), color var(--fast);
}

.excalidraw .ToolIcon:hover .ToolIcon__icon {
  background: var(--surface-hover);
  color: var(--ink);
}

/* The selected tool is washed, not flooded. A solid accent block in the
   middle of the canvas pulls the eye away from the work. */
.excalidraw .ToolIcon_type_radio:checked + .ToolIcon__icon {
  background: var(--accent-wash);
  color: var(--accent-ink);
}

.excalidraw .App-toolbar__divider {
  background: var(--line);
}

/* Zoom and undo/redo are reference controls: present, never prominent. */
.excalidraw .App-bottom-bar .Island,
.excalidraw .zoom-actions .Island,
.excalidraw .undo-redo-buttons .Island {
  border-radius: var(--r-control);
  box-shadow: var(--shadow-1);
}

.excalidraw .zoom-actions,
.excalidraw .undo-redo-buttons {
  color: var(--muted);
}

.excalidraw .zoom-actions:hover,
.excalidraw .undo-redo-buttons:hover {
  color: var(--ink-soft);
}

/* --- the empty state --------------------------------------------------- */

.canvas-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--s8);
  z-index: 4;
  pointer-events: none;
  animation: rise var(--slow) both;
}

.canvas-empty-inner {
  pointer-events: auto;
  max-width: 470px;
  text-align: center;
}

.canvas-empty-mark {
  color: var(--accent);
  opacity: 0.85;
  margin-bottom: var(--s5);
}

.canvas-empty h2 {
  font-family: var(--font-display);
  font-size: var(--t-display);
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin: 0 0 var(--s4);
}

.canvas-empty p {
  margin: 0 auto var(--s6);
  max-width: 42ch;
  color: var(--muted);
  font-size: var(--t-small);
}

.canvas-empty-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--s3);
}

.canvas-empty-hint {
  margin: var(--s5) auto 0;
  color: var(--faint);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* --- the signature: voice line + voice bar ----------------------------- */

.voice-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  z-index: 6;
  overflow: hidden;
  pointer-events: none;
}

.voice-line::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 28%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transform: translateX(-40%);
  transition: opacity var(--base);
}

.voice-line.is-listening::after {
  opacity: 0.5;
  animation: sweep 2.6s linear infinite;
}

.voice-line.is-thinking::after {
  opacity: 0.85;
  animation: sweep 1.1s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.voice-line.is-done::after {
  opacity: 0.5;
  width: 100%;
  transform: none;
  animation: settle 900ms ease-out forwards;
}

@keyframes sweep {
  from {
    transform: translateX(-40%);
  }
  to {
    transform: translateX(400%);
  }
}

@keyframes settle {
  from {
    opacity: 0.5;
  }
  to {
    opacity: 0;
  }
}

.voice-bar {
  position: absolute;
  left: 50%;
  bottom: var(--s7);
  transform: translate(-50%, 8px);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: var(--s4);
  max-width: min(640px, 78%);
  padding: var(--s2) var(--s5) var(--s2) var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--base), transform var(--base);
}

.voice-bar.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.focus-talk-strip {
  position: absolute;
  left: 50%;
  bottom: 28px;
  z-index: 7;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  width: min(560px, calc(100% - 48px));
  transform: translateX(-50%);
  padding: var(--s2) var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: var(--shadow-2);
}

.focus-talk-coachmark {
  margin: 0;
  font-size: var(--t-tiny);
  color: var(--muted);
}

.focus-talk-row {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.focus-talk-mic {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  flex: none;
  height: var(--h-md);
  padding: 0 var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--t-tiny);
  font-weight: 500;
  cursor: pointer;
}

.focus-talk-mic.recording {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.focus-talk-input {
  flex: 1;
  min-width: 0;
  height: var(--h-md);
  padding: 0 var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--surface-sunken);
}

.canvas-switch-confirm {
  position: absolute;
  left: 50%;
  top: 28px;
  z-index: 8;
  transform: translateX(-50%);
  max-width: min(420px, calc(100% - 48px));
  padding: var(--s4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: var(--shadow-2);
}

.canvas-switch-confirm p {
  margin: 0 0 var(--s3);
}

.canvas-switch-actions {
  display: flex;
  gap: var(--s2);
  justify-content: flex-end;
}

.voice-state {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  flex: none;
  height: var(--h-sm);
  font-size: var(--t-tiny);
  font-weight: 600;
  color: var(--accent-ink);
  letter-spacing: 0.01em;
}

.voice-state .pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.voice-bar.is-listening .pulse {
  animation: breathe 1.8s ease-in-out infinite;
}

@keyframes breathe {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(0.78);
  }
}

.voice-transcript {
  min-width: 0;
  flex: 1;
  font-size: var(--t-small);
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.waveform-canvas {
  flex: none;
  width: 64px;
  height: 18px;
  opacity: 0;
  transition: opacity var(--base);
}

.voice-bar.is-listening .waveform-canvas {
  opacity: 1;
}

/* ==========================================================================
   Assistant panel
   ========================================================================== */

.assistant {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border-left: 1px solid var(--line);
}

.assistant-inner {
  display: flex;
  flex-direction: column;
  width: var(--w-assistant);
  min-width: var(--w-assistant);
  height: 100%;
  opacity: 1;
  transition: opacity var(--fast);
}

.app.assistant-collapsed .assistant-inner {
  opacity: 0;
  pointer-events: none;
}

.assistant-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s3);
  height: 46px;
  padding: 0 var(--s4) 0 var(--s5);
  border-bottom: 1px solid var(--line);
}

.assistant-head h2 {
  font-size: var(--t-small);
  font-weight: 600;
  margin: 0;
}

.assistant-head-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--s1);
}

/* Where the assistant is working. A line of type, deliberately quieter than
   the conversation it sits above. */
.assistant-context {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: var(--s2);
  margin: 0;
  padding: var(--s3) var(--s5);
  border-bottom: 1px solid var(--line);
  font-size: var(--t-micro);
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
}

.assistant-context > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.assistant-context-project {
  flex: none;
  max-width: 45%;
  color: var(--muted);
  font-weight: 500;
}

.assistant-context-sep {
  flex: none;
  color: var(--line-strong);
}

/* A running session is the one case where this line is a live fact rather
   than a description of what you have open. */
.assistant-context.is-live .assistant-context-project {
  color: var(--accent-ink);
}

.assistant-context-live-dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
}

.assistant-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.assistant-lede {
  padding: var(--s2) 0;
}

.assistant-lede p {
  margin: 0;
  font-size: var(--t-small);
  color: var(--muted);
  max-width: 34ch;
}

/* The phase line settles rather than pulses - the wait is already long, and a
   pulsing indicator makes it feel longer. */
.turn-phase {
  color: var(--muted);
  animation: phase-in var(--base) both;
}

.turn-phase.phase-updated {
  color: var(--ok);
}

@keyframes phase-in {
  from {
    opacity: 0;
    transform: translateY(2px);
  }
}

.assistant-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.assistant-steps li {
  display: flex;
  gap: var(--s3);
  font-size: var(--t-small);
  color: var(--muted);
}

.assistant-steps .icon {
  flex: none;
  margin-top: 2px;
  color: var(--accent);
}

.turn {
  display: flex;
  flex-direction: column;
  animation: rise var(--base) both;
}

.turn-you {
  align-self: flex-end;
  max-width: 88%;
  padding: var(--s3) var(--s4);
  border-radius: var(--r-card);
  background: var(--accent-wash);
  color: var(--accent-ink);
  font-size: var(--t-small);
}

.turn-assistant {
  display: flex;
  align-items: baseline;
  gap: var(--s3);
  font-size: var(--t-small);
  color: var(--ink-soft);
}

.turn-assistant .icon {
  flex: none;
  color: var(--accent);
  transform: translateY(2px);
}

.assistant-foot {
  /* Shrinkable, not fixed: opening assistant settings has to take space from
     the conversation above rather than run off the bottom of the panel. */
  flex: 0 1 auto;
  min-height: 0;
  border-top: 1px solid var(--line);
  padding: var(--s4) var(--s5) 0;
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: var(--s2);
  padding: var(--s2) var(--s2) var(--s2) var(--s4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-card);
  /* White on a white panel: the border and one step of elevation are what keep
     this legible as an input rather than as a piece of the panel. */
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: border-color var(--fast), box-shadow var(--fast);
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.composer textarea {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-size: var(--t-small);
  line-height: 1.45;
  padding: var(--s2) 0;
  max-height: 120px;
}

.composer textarea::placeholder {
  color: var(--faint);
}

.composer-send {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--h-md);
  height: var(--h-md);
  border: 0;
  border-radius: var(--r-control);
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  transition: background var(--fast);
}

.composer-send:disabled {
  background: var(--surface-sunken);
  color: var(--faint);
  cursor: default;
}

.mic-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  width: 100%;
  height: var(--h-lg);
  /* Persistent affordance, not a page primary. Filling this competes with the
     one real call to action on whatever screen is open. */
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--accent-ink);
  font-size: var(--t-base);
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: background var(--fast), color var(--fast), border-color var(--fast);
}

.mic-cta:hover:not(:disabled) {
  background: var(--accent-wash);
  border-color: var(--accent-line);
}

.mic-cta:disabled {
  opacity: 0.55;
  cursor: default;
}

/* Once a session is actually running, this is the loudest control in the app
   on purpose - it is the one thing you need to be able to hit without looking. */
.mic-cta.recording {
  border-color: transparent;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: none;
}

.mic-cta.recording:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: transparent;
}

.mic-hint {
  margin: 0;
  text-align: center;
  font-size: var(--t-tiny);
  color: var(--faint);
}

.session-end {
  margin: calc(var(--s2) * -1) 0 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--t-tiny);
  cursor: pointer;
  align-self: center;
  padding: var(--s1) var(--s3);
  border-radius: var(--r-control);
  transition: color var(--fast), background var(--fast);
}

.session-end:hover {
  color: var(--ink);
  background: var(--surface-hover);
}

/* --- advanced disclosure ----------------------------------------------- */

.advanced {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-top: 1px solid var(--line);
  margin: 0 calc(var(--s5) * -1) 0;
  padding: 0 var(--s5);
}

.advanced-toggle {
  flex: none;
}

.advanced-toggle {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  height: var(--h-lg);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--t-tiny);
  font-weight: 500;
  cursor: pointer;
  transition: color var(--fast);
}

.advanced-toggle:hover {
  color: var(--ink);
}

.advanced-toggle .chevron {
  margin-left: auto;
  transition: transform var(--base);
}

.advanced-toggle[aria-expanded="true"] .chevron {
  transform: rotate(90deg);
}

.advanced-body {
  min-height: 0;
  overflow-y: auto;
  padding-bottom: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  animation: rise var(--base) both;
}

.advanced-note {
  margin: 0;
  font-size: var(--t-micro);
  color: var(--faint);
}

/* --- status rows (advanced) -------------------------------------------- */

.status-card {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  overflow: hidden;
}

.status-row-wrap + .status-row-wrap {
  border-top: 1px solid var(--line);
}

.status-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  min-height: var(--h-md);
}

.status-row.clickable {
  cursor: pointer;
}

.status-row.clickable:hover {
  background: var(--surface-hover);
}

.status-row .label {
  font-size: var(--t-tiny);
  font-weight: 500;
  color: var(--ink-soft);
}

.status-row .value {
  margin-left: auto;
  font-size: var(--t-tiny);
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 55%;
}

.status-row .chevron {
  flex: none;
  color: var(--faint);
  font-size: var(--t-base);
  line-height: 1;
  transition: transform var(--base);
}

.status-row.open .chevron {
  transform: rotate(90deg);
}

.editor {
  padding: var(--s4);
  border-top: 1px solid var(--line);
  background: var(--surface-sunken);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.editor-grid {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.field-label {
  font-size: var(--t-micro);
  font-weight: 500;
  color: var(--muted);
}

.editor select,
.editor input[type="text"],
.editor input[type="password"] {
  height: var(--h-md);
  padding: 0 var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  font-size: var(--t-small);
  outline: 0;
  transition: border-color var(--fast), box-shadow var(--fast);
}

.editor select:focus,
.editor input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.editor-hint {
  margin: 0;
  font-size: var(--t-micro);
  color: var(--faint);
}

.editor-error {
  margin: 0;
  font-size: var(--t-micro);
  color: var(--danger);
}

.editor-actions {
  display: flex;
  gap: var(--s3);
  justify-content: flex-end;
}

.editor-actions button {
  height: var(--h-sm);
  padding: 0 var(--s4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  font-size: var(--t-tiny);
  font-weight: 500;
  cursor: pointer;
}

.editor-actions button:first-child {
  border-color: transparent;
  background: var(--accent);
  color: var(--on-accent);
}

/* --- assistant instructions (advanced) --------------------------------- */

.instructions-input {
  width: 100%;
  padding: var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  font-family: inherit;
  font-size: var(--t-small);
  line-height: 1.45;
  resize: vertical;
  outline: 0;
  transition: border-color var(--fast), box-shadow var(--fast);
}

.instructions-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.instructions-input::placeholder {
  color: var(--faint);
}

/* --- session cost (advanced) -------------------------------------------- */

.cost-card {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  padding: var(--s4);
}

.cost-card-header {
  display: flex;
  align-items: baseline;
  gap: var(--s3);
  margin-bottom: var(--s3);
}

.cost-card-title {
  font-size: var(--t-tiny);
  font-weight: 600;
}

.cost-card-total {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--t-tiny);
  font-variant-numeric: tabular-nums;
}

.cost-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) 0;
}

.cost-row-left {
  display: flex;
  flex-direction: column;
}

.cost-row-label {
  font-size: var(--t-tiny);
  color: var(--ink-soft);
}

.cost-row-sub {
  font-size: var(--t-micro);
  color: var(--faint);
}

.cost-row-value {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Misc
   ========================================================================== */

.error-toast {
  position: absolute;
  left: 50%;
  bottom: var(--s10);
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--danger);
  border-radius: var(--r-control);
  background: var(--danger-wash);
  color: var(--danger);
  font-size: var(--t-small);
  box-shadow: var(--shadow-2);
  animation: rise var(--base) both;
}

/* Same slot and motion as .error-toast, calm rather than alarmed: for a
   quiet system confirmation (e.g. "Created a new project and canvas..."),
   never a failure. */
.canvas-notice {
  position: absolute;
  left: 50%;
  bottom: var(--s10);
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--ok-wash);
  color: var(--ink);
  font-size: var(--t-small);
  box-shadow: var(--shadow-2);
  animation: rise var(--base) both;
}

/* The only way back to a collapsed panel, so it has to read as a handle
   rather than as a hairline. Wide enough to hit, quiet enough to ignore. */
.edge-toggle {
  position: absolute;
  top: 50%;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Bigger than the visible chevron: this is the one control that reopens a
     hidden panel, so it gets a larger hit area and stronger at-rest contrast
     than a typical icon button - a bare hairline here reads as decoration,
     not as "there is more here". (Bounds pinned by
     test/design-system.test.js: width 24-30px, height 44-52px.) */
  width: 30px;
  height: 52px;
  padding: 0;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transform: translateY(-50%);
  box-shadow: var(--shadow-1);
  transition: color var(--fast), background var(--fast), border-color var(--fast);
}

.edge-toggle:hover {
  background: var(--surface-hover);
  border-color: var(--line-heavy);
  color: var(--ink);
}

.edge-toggle:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
  color: var(--accent-ink);
}

.edge-toggle-left {
  left: 0;
  border-left: 0;
  border-radius: 0 var(--r-handle) var(--r-handle) 0;
}

.edge-toggle-right {
  right: 0;
  border-right: 0;
  border-radius: var(--r-handle) 0 0 var(--r-handle);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

@media (max-width: 1200px) {
  :root {
    --w-assistant: 312px;
  }
}

@media (max-width: 1040px) {
  :root {
    --w-sidebar: 62px;
  }

  .brand-name,
  .nav-label,
  .account-text {
    display: none;
  }

  .nav-item,
  .brand,
  .account {
    justify-content: center;
  }

  /* The rail drops labels, but not the answer to "which project is this?".
     The name gives way to its initial; the group and its indent stay. */
  .brand {
    flex-direction: column;
    height: auto;
    gap: var(--s2);
  }

  .brand-collapse {
    margin-left: 0;
  }

  .nav-project-head {
    justify-content: center;
    flex-direction: column;
    padding: 0;
  }

  .nav-project-name {
    flex: none;
    text-align: center;
  }

  .nav-project-full {
    display: none;
  }

  .nav-project-initial {
    display: block;
    font-size: var(--t-tiny);
    letter-spacing: 0;
  }

  .nav-item-child {
    margin-left: var(--s2);
    padding-left: 0;
  }
}

/* ==========================================================================
   Workspace lists (projects, canvases)
   Composed from the existing row/card tokens - no new visual language.
   ========================================================================== */

.entity-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding-right: var(--s4);
  border-top: 1px solid var(--line);
  transition: background var(--fast);
}

.entity-row:first-child {
  border-top: 0;
}

.entity-row:hover {
  background: var(--surface-hover);
}

.entity-row-active {
  box-shadow: inset 2px 0 0 var(--accent);
}

.entity-open {
  display: flex;
  align-items: center;
  gap: var(--s4);
  flex: 1;
  min-width: 0;
  padding: var(--s4) var(--s5);
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.entity-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s2);
  opacity: 1;
  transition: opacity var(--fast);
}

@media (hover: hover) and (pointer: fine) {
  .entity-actions {
    opacity: 0;
  }

  .entity-row:hover .entity-actions,
  .entity-row:focus-within .entity-actions {
    opacity: 1;
  }
}

.entity-row-editing {
  padding: var(--s4) var(--s5);
}

.inline-form {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex-wrap: wrap;
  width: 100%;
}

.inline-input {
  flex: 1 1 200px;
  min-width: 0;
  height: var(--h-md);
  padding: 0 var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  font: inherit;
  font-size: var(--t-small);
  color: var(--ink);
  outline: 0;
  transition: border-color var(--fast), box-shadow var(--fast);
}

.inline-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.inline-form-actions {
  flex: none;
  display: flex;
  gap: var(--s2);
}

.create-card {
  padding: var(--s5);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
}

.page-error {
  margin: 0 0 var(--s5);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--danger-wash);
  color: var(--danger);
  font-size: var(--t-small);
}

/* Same shape as .page-error, calm rather than alarmed: for explaining a
   redirect or an automatic action, not reporting a failure. */
.page-notice {
  margin: 0 0 var(--s5);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--accent-wash);
  color: var(--accent-ink);
  font-size: var(--t-small);
}

.page-actions-group {
  display: flex;
  gap: var(--s3);
}

.back-link {
  display: inline-flex;
  align-items: center;
  margin-bottom: var(--s5);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: var(--t-tiny);
  cursor: pointer;
}

.back-link:hover {
  color: var(--ink);
}

/* ==========================================================================
   Project sources
   ========================================================================== */

.entity-trail {
  flex: none;
  margin-left: auto;
  padding-left: var(--s4);
}

.source-status {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: 0 var(--s3);
  height: 20px;
  border-radius: var(--r-pill);
  font-size: var(--t-micro);
  font-weight: 500;
  white-space: nowrap;
}

.source-status.is-ready {
  background: var(--ok-wash);
  color: var(--ok);
}

.source-status.is-processing {
  background: var(--surface-sunken);
  color: var(--muted);
}

.source-status.is-failed {
  background: var(--danger-wash);
  color: var(--danger);
}

.source-details {
  padding: var(--s5);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
}

.source-details-head {
  display: flex;
  align-items: center;
  gap: var(--s4);
  margin-bottom: var(--s4);
}

.source-details-title {
  margin: 0;
  font-size: var(--t-base);
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-details-head .btn {
  margin-left: auto;
}

.source-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s2) var(--s5);
  margin: 0;
  font-size: var(--t-tiny);
}

.source-facts dt {
  color: var(--faint);
}

.source-facts dd {
  margin: 0;
  color: var(--ink-soft);
}

.source-error {
  margin: var(--s4) 0 0;
  font-size: var(--t-tiny);
  color: var(--danger);
}

.folder-estimate {
  margin-bottom: var(--s5);
}

.folder-estimate-note {
  margin: var(--s4) 0 0;
  font-size: var(--t-tiny);
  color: var(--ink-soft);
}

.folder-estimate-ignored {
  list-style: none;
  margin: var(--s4) 0 0;
  padding: 0;
  font-size: var(--t-tiny);
  color: var(--ink-soft);
}

.folder-estimate-ignored li {
  display: flex;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s1) 0;
}

.folder-estimate-actions {
  display: flex;
  gap: var(--s3);
  margin-top: var(--s5);
}

.memory-group {
  margin-top: var(--s6);
}

.memory-group:first-child {
  margin-top: 0;
}

.memory-item-text {
  margin: var(--s4) 0 0;
  font-size: var(--t-tiny);
  line-height: 1.6;
  color: var(--ink-soft);
}

.source-preview {
  margin-top: var(--s5);
  padding-top: var(--s5);
  border-top: 1px solid var(--line);
}

.source-preview-label {
  margin: 0 0 var(--s3);
  font-size: var(--t-micro);
  font-weight: 500;
  color: var(--muted);
}

.source-preview-chunk {
  margin-bottom: var(--s4);
}

.source-preview-chunk p {
  margin: var(--s1) 0 0;
  font-size: var(--t-tiny);
  line-height: 1.6;
  color: var(--ink-soft);
  white-space: pre-wrap;
}

.source-preview-loc {
  font-size: var(--t-micro);
  color: var(--faint);
}

/* A recording, read back. Composed from the same tokens as the assistant
   panel so a transcript reads the same wherever it appears. */
.recording-transcript {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.recording-turn p {
  margin: var(--s1) 0 0;
  font-size: var(--t-small);
  line-height: 1.6;
  color: var(--ink-soft);
  white-space: pre-wrap;
}

.recording-turn.is-assistant p {
  color: var(--muted);
}

.recording-speaker {
  font-size: var(--t-micro);
  font-weight: 500;
  color: var(--faint);
}

.recording-audio {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  margin: 0 0 var(--s5);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface-sunken);
}

.recording-audio audio {
  display: none;
}

.recording-audio-toggle {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--h-sm);
  height: var(--h-sm);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--accent-ink);
  cursor: pointer;
  transition: background var(--fast), border-color var(--fast);
}

.recording-audio-toggle:hover {
  background: var(--accent-wash);
  border-color: var(--accent-line);
}

.recording-audio-progress {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
}

.recording-audio-time {
  flex: none;
  font-size: var(--t-micro);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Citations under an assistant reply. */
.turn-sources {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin: var(--s2) 0 0 var(--s6);
}

.turn-source {
  padding: 1px var(--s2);
  border-radius: var(--r-control);
  background: var(--surface-sunken);
  color: var(--muted);
  font-size: var(--t-micro);
}

/* --- folder sources --------------------------------------------------- */

.source-preview-head {
  display: flex;
  align-items: center;
  gap: var(--s4);
  margin-bottom: var(--s3);
}

.source-preview-head .source-preview-label {
  margin: 0;
}

.source-preview-head .btn {
  margin-left: auto;
}

.tree {
  max-height: 320px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  line-height: 1.9;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  padding: var(--s3) var(--s4);
  background: var(--surface-sunken);
}

.tree-row {
  display: flex;
  align-items: baseline;
  gap: var(--s3);
  white-space: nowrap;
}

.tree-row.is-muted .tree-name {
  color: var(--faint);
}

.tree-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-note {
  color: var(--faint);
  font-size: 10px;
}

/* --- account -------------------------------------------------------------
   The identity block in the sidebar foot, the menu it opens, and the two
   screens behind that menu. Composed from the tokens above: no new colours,
   no new radii, one hairline and one existing shadow. */

.account-wrap {
  position: relative;
}

.account-sub {
  display: block;
  font-size: var(--t-tiny);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The menu opens upward: the identity block sits at the bottom of the
   sidebar, so there is no room below it. */
.profile-menu {
  position: absolute;
  bottom: calc(100% + var(--s2));
  left: 0;
  right: 0;
  min-width: 168px;
  padding: var(--s1);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-2);
  z-index: 20;
}

.profile-menu-item {
  display: block;
  width: 100%;
  padding: var(--s2) var(--s3);
  border: 0;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: var(--t-small);
  text-align: left;
  cursor: pointer;
  transition: background var(--fast);
}

.profile-menu-item:hover {
  background: var(--surface-hover);
}

.profile-menu-item[aria-current="page"] {
  color: var(--accent-ink);
  font-weight: 500;
}

.profile-menu-divider {
  height: 1px;
  margin: var(--s1) var(--s3);
  background: var(--line);
}

/* In the icon rail there is no room for a name, so the avatar carries the
   identity on its own - the same trick the project monogram uses. */
.nav-collapsed .account-sub {
  display: none;
}

/* --- account screens ----------------------------------------------------- */

.account-identity {
  display: flex;
  align-items: center;
  gap: var(--s5);
  margin-bottom: var(--s6);
}

.avatar-lg {
  width: 44px;
  height: 44px;
  font-size: var(--t-small);
}

img.avatar {
  object-fit: cover;
}

.account-identity-name {
  margin: 0;
  font-weight: 500;
}

.account-identity-email {
  margin: 0;
  color: var(--muted);
  font-size: var(--t-small);
}

.field-block {
  display: block;
  margin-bottom: var(--s5);
  max-width: 420px;
}

.field-label {
  display: block;
  margin-bottom: var(--s2);
  font-size: var(--t-small);
  font-weight: 500;
  color: var(--ink-soft);
}

.field-input {
  width: 100%;
  max-width: 100%;
  padding: var(--s2) var(--s3);
  font: inherit;
  font-size: var(--t-small);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  transition: border-color var(--fast), box-shadow var(--fast);
}

.field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.field-actions {
  display: flex;
  align-items: center;
  gap: var(--s4);
}

.field-note {
  font-size: var(--t-small);
  color: var(--muted);
}

.field-error {
  margin: 0 0 var(--s4);
  font-size: var(--t-small);
  color: var(--danger);
}

/* --- expired session -----------------------------------------------------
   A strip across the top of the shell. It interrupts, but it does not take
   the canvas away: the work on screen stays until the person chooses. */

.session-expired {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s4);
  padding: var(--s3) var(--s5);
  background: var(--warn-wash);
  border-bottom: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: var(--t-small);
}

.session-expired-action {
  padding: var(--s1) var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--t-small);
  font-weight: 500;
  cursor: pointer;
}

.session-expired-action:hover {
  border-color: var(--accent-line);
}

/* The banner takes its own room rather than sitting over the canvas topbar:
   interrupting is the point, hiding the controls is not. */
.app.session-interrupted {
  padding-top: 37px;
}

/* Calm, non-modal connection status. A toast at the shell root - never a
   dialog - because a dropped transport is not a decision the user needs to
   make, only something they need to be told about while it self-heals. */
.ws-status-banner {
  position: fixed;
  left: 50%;
  bottom: var(--s5);
  transform: translateX(-50%);
  z-index: 70;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s4);
  border-radius: var(--r-control);
  border: 1px solid var(--line-strong);
  background: var(--warn-wash);
  color: var(--ink);
  font-size: var(--t-small);
  box-shadow: var(--shadow-1);
}

.ws-status-banner-ok {
  background: var(--ok-wash);
  border-color: var(--line-strong);
}

.ws-status-retry {
  padding: var(--s1) var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--t-small);
  font-weight: 500;
  cursor: pointer;
}

.ws-status-retry:hover {
  border-color: var(--accent-line);
}

/* Organization chart: a 2-tier hierarchy derived from existing roles
   (owner/admin -> reports), not a stored reporting relationship. Connector
   lines are drawn by measuring real card positions (see the OrgChart
   component), so they hold up regardless of roster size or wrapping. */
.org-chart-total {
  margin: 0 0 var(--s5);
  font-size: var(--t-small);
  color: var(--muted);
}
.org-chart-total strong { color: var(--ink); }

.org-chart-canvas {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s7);
  padding: var(--s5) 0;
}

.org-chart-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.org-chart-lines line {
  stroke: var(--line-heavy);
  stroke-width: 1.5;
}

.org-chart-tier {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s4);
  width: 100%;
}

.org-chart-card {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-width: 220px;
  max-width: 260px;
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.org-chart-card-root {
  border-color: var(--accent-line);
  background: var(--accent-wash);
}

.org-chart-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--on-accent);
  font-size: var(--t-tiny);
  font-weight: 650;
}
.org-chart-card-root .org-chart-avatar { background: var(--accent); }

.org-chart-card-body {
  min-width: 0;
  flex: 1;
}
.org-chart-card-body strong {
  display: block;
  overflow-wrap: anywhere;
}
.org-chart-card-body .row-meta {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  text-transform: capitalize;
}

.org-chart-details {
  flex: none;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: var(--t-tiny);
  font-weight: 500;
  cursor: pointer;
}
.org-chart-details:hover { text-decoration: underline; }

@media (max-width: 720px) {
  .org-chart-card { min-width: 0; max-width: 100%; width: 100%; }
}

.organization-grid,
.organization-list {
  display: grid;
  gap: var(--s3);
}

.organization-member,
.organization-relation {
  padding: var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
}

.organization-member-head,
.organization-relation,
.organization-identity,
.organization-identity form {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}

/* Same fix as .connected-app-meta: a flex/grid child's default min-width is
   auto, not 0, so a long display name or email would refuse to shrink and
   push the role control out past the card instead of wrapping. */
.organization-member-identity { min-width: 0; overflow-wrap: anywhere; }
.organization-role { width: 130px; }
.organization-access { display: grid; gap: var(--s2); margin: var(--s4) 0; }
.organization-access label { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); font-size: var(--t-small); }
.organization-access select,
.organization-relation select { padding: var(--s1) var(--s2); border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--surface); }
.workspace-picker { max-width: 520px; }
.invite-ready,
.pending-invite,
.shared-project,
.connection-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
}
.invite-ready {
  margin-top: var(--s4);
  max-width: 680px;
  padding: var(--s3) var(--s4);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-card);
  background: var(--accent-wash);
}
.invite-ready .setting-note { margin: var(--s1) 0 0; }

/* Billing plans — public pricing story, mirrored inside the account screen. */
.billing-status {
  display: grid;
  gap: var(--s2);
}

.billing-plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s4);
}

.billing-plan-card {
  display: grid;
  gap: var(--s3);
  align-content: start;
  padding: var(--s5);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--paper);
}

.billing-plan-card-featured {
  border-color: var(--accent-line);
  background: var(--accent-wash);
}

.billing-plan-card.is-current {
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.billing-plan-eyebrow {
  margin: 0;
  color: var(--faint);
  font-size: var(--t-tiny);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.billing-plan-card h3 {
  margin: 0;
  font-size: var(--t-title);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.billing-intro {
  margin: calc(var(--s4) * -1) 0 var(--s6);
  max-width: 62ch;
}

.billing-plan-tagline {
  margin: 0;
  color: var(--muted);
  font-size: var(--t-small);
  line-height: 1.45;
}

.billing-plan-price {
  margin: 0;
  color: var(--ink);
  font-size: var(--t-small);
  font-weight: 600;
}

.billing-plan-footnote {
  margin: 0;
}

.billing-plan-list {
  display: grid;
  gap: var(--s2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.billing-plan-list li {
  position: relative;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: var(--t-small);
}

.billing-plan-list li::before {
  content: "";
  position: absolute;
  top: 0.55em;
  left: 0;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--accent);
}

.billing-plan-card .btn,
.billing-plan-card .setting-note,
.billing-plan-card .field-error {
  margin-top: var(--s2);
}

@media (max-width: 800px) {
  .billing-plan-grid {
    grid-template-columns: 1fr;
  }
}
.pending-invites { display: grid; gap: var(--s2); margin-top: var(--s4); max-width: 680px; }
.pending-invite,
.shared-project { padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.shared-project-list { display: grid; margin-bottom: var(--s4); }

.connected-app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 360px));
  gap: var(--s4);
}
.connected-app-card {
  display: grid;
  align-content: start;
  gap: var(--s4);
  min-height: 0;
  max-width: 360px;
  padding: var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
}
.connected-app-card.is-connected { border-color: var(--accent-line); }
.connected-app-card.is-reconnect { border-color: var(--warn); }
.connected-app-card.is-error { border-color: var(--danger); }
.connected-app-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: var(--s3);
}
/* A grid track's default min-width is auto, not 0 - it refuses to shrink
   below its content's intrinsic width. For a long, unbroken provider
   description that meant the text never wrapped and ran straight off the
   edge of the card instead. */
.connected-app-meta { min-width: 0; }
/* .row-meta is a single-line-ellipsis style built for list rows; a card has
   the vertical room to show what a provider actually does, so let it wrap
   across a couple of lines here instead of truncating mid-sentence. */
.connected-app-head .row-meta {
  margin-top: var(--s1);
  line-height: 1.45;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
.provider-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-control);
  background: var(--ink);
  color: var(--surface);
  font-weight: 650;
}
.provider-slack,
.provider-notion { background: var(--ink); }
.provider-google_drive,
.provider-gmail,
.provider-google_calendar { background: var(--accent); }
.connected-app-actions { display: flex; gap: var(--s2); margin-top: auto; }
.connection-status { margin-top: auto; padding-top: var(--s3); border-top: 1px solid var(--line); flex-wrap: wrap; }
.connection-status p { margin: var(--s1) 0 0; font-size: var(--t-small); }

.connection-next-step {
  flex-basis: 100%;
  margin: var(--s3) 0 0;
  padding: var(--s2) var(--s3);
  border-radius: var(--r-control);
  background: var(--accent-wash);
  color: var(--accent-ink);
  font-size: var(--t-small);
}

.inline-link-btn {
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: var(--t-small);
  font-weight: 500;
  text-decoration: underline;
  cursor: pointer;
}

.manual-resource-bind {
  display: flex;
  gap: var(--s2);
  align-items: center;
}
.manual-resource-bind .field-input { flex: 1; }

.external-binding { align-items: flex-start; flex-wrap: wrap; }
.external-action-triggers { display: flex; flex-direction: column; gap: var(--s2); }
.external-action-trigger form { flex-direction: row; gap: var(--s2); }
.external-action-confirm,
.external-action-receipt {
  margin-top: var(--s4);
  max-width: 680px;
  padding: var(--s3) var(--s4);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-card);
  background: var(--accent-wash);
}
.external-action-confirm p { margin: var(--s1) 0 var(--s3); }
.external-action-receipt.is-failed { border-color: var(--danger); background: var(--surface); }
.external-action-receipt p { margin: 0 0 var(--s1); }

@media (max-width: 720px) {
  .invite-ready,
  .pending-invite,
  .shared-project,
  .connection-status { align-items: flex-start; flex-direction: column; }
  .connected-app-grid { grid-template-columns: 1fr; }
}

/* Guest (anonymous account) limit-reached overlay - public/ui/guest-limit.js.
   Sits above the still-visible canvas; never replaces it. */
.guest-limit-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 24px;
  background: rgba(21, 21, 26, 0.28);
}

.guest-limit-card {
  width: 100%;
  max-width: 420px;
  margin-bottom: 24px;
  padding: 20px;
  box-shadow: var(--shadow-2);
}

.guest-limit-eyebrow {
  margin: 0 0 6px;
  font-weight: 650;
  color: var(--ink);
}

.guest-limit-text {
  margin: 0 0 16px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.5;
}

.guest-limit-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feedback-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(21, 21, 26, 0.28);
}

.feedback-dialog-card {
  width: 100%;
  max-width: 440px;
  padding: 20px;
  box-shadow: var(--shadow-2);
}

.feedback-dialog-eyebrow {
  margin: 0 0 6px;
  font-weight: 650;
  color: var(--ink);
}

.feedback-dialog-text {
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.5;
}

.feedback-dialog-error {
  margin: 0 0 12px;
  color: var(--danger, #9c3a34);
  font-size: 13px;
}

.feedback-dialog-textarea {
  width: 100%;
  margin-top: 12px;
  resize: vertical;
}

.feedback-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

/* ==========================================================================
   Mobile layout (≤767px)
   Deliberate phone composition around the shared shell — not scaled desktop.
   Desktop rules above stay intact; this section only reorganizes presentation.
   ========================================================================== */

.mobile-page-bar,
.mobile-canvas-toolbar,
.canvas-topbar-mobile .topbar-overflow,
.mobile-drawer-scrim {
  display: none;
}

.topbar-overflow-wrap {
  position: relative;
}

.topbar-overflow {
  position: absolute;
  top: calc(100% + var(--s2));
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  padding: var(--s2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: var(--shadow-2);
}

.topbar-overflow-item {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--s4);
  border: 0;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: var(--t-small);
  text-align: left;
  cursor: pointer;
}

.topbar-overflow-item:hover:not(:disabled),
.topbar-overflow-item:focus-visible {
  background: var(--surface-hover);
}

.topbar-overflow-item:disabled {
  opacity: 0.5;
  cursor: default;
}

.topbar-overflow-item.active {
  color: var(--accent-ink);
  font-weight: 600;
}

.topbar-overflow-sep {
  height: 1px;
  margin: var(--s1) var(--s2);
  background: var(--line);
}

/* Desktop preview frame when /app?mobile=1 is used on a wide screen. */
html.force-mobile-layout {
  background: #ececee;
}

html.force-mobile-layout body {
  display: flex;
  justify-content: center;
  background: #ececee;
}

html.force-mobile-layout .app.is-mobile-layout {
  width: 100%;
  max-width: 430px;
  box-shadow: var(--shadow-2);
  border-inline: 1px solid var(--line);
}

.mobile-preview-banner {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s2) var(--s4);
  border-bottom: 1px solid var(--accent-line);
  background: var(--accent-wash);
  color: var(--accent-ink);
  font-size: var(--t-tiny);
}

.mobile-preview-banner a {
  color: inherit;
  font-weight: 600;
}

/* Mobile layout — keyed off .app.is-mobile-layout (matchMedia or ?mobile=1), not viewport alone. */

  .app.is-mobile-layout {
    --t-display: 26px;
    --t-page: 22px;
    --t-title: 18px;
    grid-template-columns: minmax(0, 1fr);
    padding-top: env(safe-area-inset-top);
  }

  .app.is-mobile-layout .center {
    display: flex;
    flex-direction: column;
  }

  .app.is-mobile-layout .canvas-screen {
    flex: 1;
    min-height: 0;
    height: auto;
  }

  .app.is-mobile-layout .page {
    flex: 1;
    min-height: 0;
    height: auto;
  }

  .app.is-mobile-layout .sidebar,
  .app.is-mobile-layout .assistant {
    position: fixed;
    z-index: 40;
    height: var(--app-height);
    max-height: var(--app-height);
    background: var(--surface);
    transition: transform var(--base), opacity var(--fast);
  }

  .app.is-mobile-layout .sidebar {
    top: 0;
    left: 0;
    width: min(320px, calc(100vw - 48px));
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow-2);
    transform: translateX(0);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .app.is-mobile-layout.nav-collapsed .sidebar {
    transform: translateX(-105%);
    pointer-events: none;
    visibility: hidden;
  }

  .app.is-mobile-layout .sidebar-inner {
    width: 100%;
    min-width: 0;
    opacity: 1;
    pointer-events: auto;
  }

  /* Drawer is a full labeled nav, not the ≤1040 icon rail. */
  .app.is-mobile-layout .brand-name,
  .app.is-mobile-layout .nav-label,
  .app.is-mobile-layout .account-text,
  .app.is-mobile-layout .nav-project-full {
    display: initial;
  }

  .app.is-mobile-layout .nav-project-initial {
    display: none;
  }

  .app.is-mobile-layout .brand,
  .app.is-mobile-layout .nav-item,
  .app.is-mobile-layout .account,
  .app.is-mobile-layout .nav-project-head {
    justify-content: flex-start;
    flex-direction: row;
  }

  .app.is-mobile-layout .brand-collapse {
    margin-left: auto;
  }

  .app.is-mobile-layout .nav-item-child {
    margin-left: var(--s5);
    padding-left: var(--s3);
  }

  .app.is-mobile-layout .assistant {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: min(72dvh, 640px);
    max-height: calc(var(--app-height) - 72px);
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: var(--r-panel) var(--r-panel) 0 0;
    box-shadow: var(--shadow-2);
    transform: translateY(0);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .app.is-mobile-layout.assistant-collapsed .assistant {
    transform: translateY(105%);
    pointer-events: none;
    visibility: hidden;
  }

  .app.is-mobile-layout .assistant-inner {
    width: 100%;
    min-width: 0;
    opacity: 1;
    pointer-events: auto;
  }

  /* Canvas owns talk on mobile; the sheet is for transcript / context. */
  .app.is-mobile-layout .assistant .mic-cta,
  .app.is-mobile-layout .assistant .mic-hint,
  .app.is-mobile-layout .assistant .composer,
  .app.is-mobile-layout .assistant .session-end {
    display: none;
  }

  .app.is-mobile-layout .mobile-drawer-scrim {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 35;
    border: 0;
    margin: 0;
    padding: 0;
    background: rgba(21, 21, 26, 0.28);
    cursor: pointer;
  }

  .app.is-mobile-layout .edge-toggle {
    display: none;
  }

  .app.is-mobile-layout .canvas-topbar {
    height: auto;
    min-height: 48px;
    padding: var(--s2) var(--s3);
    padding-left: max(var(--s3), env(safe-area-inset-left));
    padding-right: max(var(--s3), env(safe-area-inset-right));
    gap: var(--s2);
  }

  .app.is-mobile-layout .canvas-topbar-mobile {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--s2);
  }

  .app.is-mobile-layout .mobile-topbar-context {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
  }

  .app.is-mobile-layout .mobile-project-name {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: var(--t-small);
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
  }

  .app.is-mobile-layout .mobile-canvas-name {
    color: var(--muted);
    font-size: var(--t-tiny);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .app.is-mobile-layout .mobile-topbar-actions {
    display: flex;
    align-items: center;
    gap: var(--s1);
    flex: none;
  }

  .app.is-mobile-layout .canvas-topbar-mobile .segmented button {
    min-width: 44px;
    min-height: 32px;
    padding: 0 var(--s3);
  }

  .app.is-mobile-layout .mobile-focus-btn {
    min-height: 44px;
    padding-inline: var(--s3);
  }

  .app.is-mobile-layout .canvas-topbar-mobile .icon-btn {
    width: 44px;
    height: 44px;
  }

  .app.is-mobile-layout .canvas-topbar-mobile .topbar-overflow {
    display: flex;
  }

  .app.is-mobile-layout .mobile-page-bar {
    display: flex;
    align-items: center;
    gap: var(--s3);
    flex: none;
    min-height: 48px;
    padding: var(--s2) var(--s3);
    padding-left: max(var(--s3), env(safe-area-inset-left));
    padding-right: max(var(--s3), env(safe-area-inset-right));
    border-bottom: 1px solid var(--line);
    background: var(--surface);
  }

  .app.is-mobile-layout .mobile-page-bar .icon-btn {
    width: 44px;
    height: 44px;
  }

  .app.is-mobile-layout .mobile-page-bar-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: var(--t-small);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .app.is-mobile-layout .mobile-page-bar-spacer {
    width: 44px;
    flex: none;
  }

  .app.is-mobile-layout .page-inner {
    padding: var(--s6) var(--s5) calc(var(--s8) + env(safe-area-inset-bottom));
  }

  .app.is-mobile-layout .page-header {
    margin-bottom: var(--s6);
  }

  .app.is-mobile-layout .page-header-row {
    flex-direction: column;
    align-items: stretch;
    gap: var(--s4);
  }

  .app.is-mobile-layout .page-actions {
    margin-left: 0;
    flex-wrap: wrap;
  }

  .app.is-mobile-layout .section {
    margin-top: var(--s7);
  }

  .app.is-mobile-layout .canvas-empty {
    place-items: start center;
    padding: var(--s7) var(--s5) 120px;
    align-content: start;
  }

  .app.is-mobile-layout .canvas-empty-compact .canvas-empty-inner {
    max-width: 320px;
  }

  .app.is-mobile-layout .canvas-empty-compact h2 {
    font-size: var(--t-title);
    margin-bottom: var(--s2);
  }

  .app.is-mobile-layout .canvas-empty-compact p {
    margin-bottom: var(--s4);
    font-size: var(--t-small);
  }

  .app.is-mobile-layout .canvas-empty-actions .btn {
    min-height: 44px;
  }

  .app.is-mobile-layout .mobile-canvas-name.is-live {
    color: var(--accent-ink);
    font-weight: 600;
  }

  /* Tools stay collapsed until opened from ••• — canvas stays clear. */
  .app.is-mobile-layout .mobile-canvas-toolbar {
    display: flex;
    flex-direction: column;
    gap: var(--s3);
    position: absolute;
    left: max(var(--s4), env(safe-area-inset-left));
    right: max(var(--s4), env(safe-area-inset-right));
    bottom: calc(72px + env(safe-area-inset-bottom) + var(--vv-offset));
    z-index: 8;
    padding: var(--s3);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-card);
    background: var(--surface);
    box-shadow: var(--shadow-2);
  }

  .app.is-mobile-layout .mobile-tool-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s3);
    font-size: var(--t-small);
    font-weight: 600;
  }

  .app.is-mobile-layout .mobile-tool-sheet-close {
    min-height: 36px;
    padding: 0 var(--s3);
    border: 0;
    border-radius: var(--r-control);
    background: var(--accent-wash);
    color: var(--accent-ink);
    font: inherit;
    font-size: var(--t-tiny);
    font-weight: 600;
    cursor: pointer;
  }

  .app.is-mobile-layout .mobile-tool-row {
    display: flex;
    gap: var(--s2);
  }

  .app.is-mobile-layout .mobile-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 44px;
    padding: 0 var(--s4);
    border: 1px solid var(--line);
    border-radius: var(--r-control);
    background: var(--surface);
    color: var(--ink-soft);
    font: inherit;
    font-size: var(--t-small);
    font-weight: 560;
    cursor: pointer;
  }

  .app.is-mobile-layout .mobile-tool-btn.active {
    border-color: var(--accent-line);
    background: var(--accent-wash);
    color: var(--accent-ink);
  }

  .app.is-mobile-layout .mobile-tool-sheet {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s1);
  }

  .app.is-mobile-layout .mobile-tool-sheet-item {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 var(--s4);
    border: 0;
    border-radius: var(--r-control);
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: var(--t-small);
    text-align: left;
    cursor: pointer;
  }

  .app.is-mobile-layout .mobile-tool-sheet-item.active,
  .app.is-mobile-layout .mobile-tool-sheet-item:hover {
    background: var(--surface-hover);
  }

  .app.is-mobile-layout .mobile-tool-sheet-sep {
    grid-column: 1 / -1;
    height: 1px;
    margin: var(--s1) 0;
    background: var(--line);
  }

  /* Progressive disclosure: hide Excalidraw's full desktop/mobile chrome on phones. */
  .app.is-mobile-layout .excalidraw .App-toolbar,
  .app.is-mobile-layout .excalidraw .App-toolbar-container,
  .app.is-mobile-layout .excalidraw .App-top-bar,
  .app.is-mobile-layout .excalidraw .FixedSideContainer,
  .app.is-mobile-layout .excalidraw .main-menu-trigger,
  .app.is-mobile-layout .excalidraw .HelpDialog__trigger,
  .app.is-mobile-layout .excalidraw .help-icon,
  .app.is-mobile-layout .excalidraw .ToolIcon__lock,
  .app.is-mobile-layout .excalidraw .mobile-misc-tools-container {
    display: none !important;
  }

  .app.is-mobile-layout .excalidraw .App-bottom-bar {
    bottom: calc(72px + env(safe-area-inset-bottom) + var(--vv-offset));
  }

  .app.is-mobile-layout .canvas-stage .excalidraw {
    touch-action: none;
  }

  .app.is-mobile-layout .focus-talk-strip {
    left: max(var(--s4), env(safe-area-inset-left));
    right: max(var(--s4), env(safe-area-inset-right));
    bottom: calc(12px + env(safe-area-inset-bottom) + var(--vv-offset));
    width: auto;
    max-width: none;
    transform: none;
    padding: var(--s2);
    border-radius: var(--r-card);
  }

  .app.is-mobile-layout .focus-talk-strip-compact {
    padding: var(--s1) var(--s2);
    box-shadow: var(--shadow-1);
  }

  .app.is-mobile-layout .focus-talk-strip-compact .focus-talk-row {
    gap: var(--s2);
  }

  .app.is-mobile-layout .focus-talk-mic-icon {
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
  }

  .app.is-mobile-layout .focus-talk-strip-compact .focus-talk-input {
    height: 44px;
    border: 0;
    background: transparent;
    font-size: var(--t-base);
  }

  .app.is-mobile-layout .focus-talk-strip-compact .composer-send {
    width: 44px;
    height: 44px;
  }

  .app.is-mobile-layout .focus-talk-row-listening {
    justify-content: space-between;
    min-height: 44px;
  }

  .app.is-mobile-layout .focus-talk-listening-label {
    display: inline-flex;
    align-items: center;
    gap: var(--s3);
    color: var(--accent-ink);
    font-size: var(--t-small);
    font-weight: 600;
  }

  .app.is-mobile-layout .focus-talk-stop {
    min-height: 44px;
    padding: 0 var(--s4);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-control);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: var(--t-small);
    font-weight: 500;
    cursor: pointer;
  }

  .app.is-mobile-layout .voice-bar {
    bottom: calc(76px + env(safe-area-inset-bottom) + var(--vv-offset));
    max-width: calc(100% - 32px);
  }

  .app.is-mobile-layout .canvas-notice,
  .app.is-mobile-layout .error-toast {
    bottom: calc(84px + env(safe-area-inset-bottom) + var(--vv-offset));
    max-width: calc(100% - 32px);
  }

  .app.is-mobile-layout .connected-app-grid {
    grid-template-columns: 1fr;
  }

  .app.is-mobile-layout .connected-app-card {
    max-width: none;
  }

  .app.is-mobile-layout .billing-plan-grid {
    grid-template-columns: 1fr;
  }

  .app.is-mobile-layout .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app.is-mobile-layout .entity-actions {
    opacity: 1;
  }

  .app.is-mobile-layout .guest-limit-overlay {
    align-items: stretch;
    padding: 0;
  }

  .app.is-mobile-layout .guest-limit-card {
    max-width: none;
    margin: 0;
    border-radius: var(--r-panel) var(--r-panel) 0 0;
    padding: var(--s6) var(--s5) calc(var(--s6) + env(safe-area-inset-bottom));
  }

  .app.is-mobile-layout .invite-ready,
  .app.is-mobile-layout .pending-invite,
  .app.is-mobile-layout .shared-project,
  .app.is-mobile-layout .connection-status {
    align-items: flex-start;
    flex-direction: column;
  }

  .app.is-mobile-layout .source-details-head {
    flex-wrap: wrap;
  }

  .app.is-mobile-layout .source-details-title {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .app.is-mobile-layout .source-facts {
    grid-template-columns: 1fr;
    gap: var(--s1);
  }

  .app.is-mobile-layout .folder-estimate-actions,
  .app.is-mobile-layout .external-action-trigger form,
  .app.is-mobile-layout .manual-resource-bind {
    flex-direction: column;
    align-items: stretch;
  }

  .app.is-mobile-layout .folder-estimate-actions .btn,
  .app.is-mobile-layout .external-action-trigger form .btn,
  .app.is-mobile-layout .manual-resource-bind .btn {
    width: 100%;
    min-height: 44px;
  }


/* Tablet: keep panels usable without the phone drawer treatment. */
@media (min-width: 768px) and (max-width: 1023px) {
  :root {
    --w-assistant: 300px;
  }

  .page-inner {
    padding: var(--s8) var(--s6) var(--s8);
  }

  .canvas-topbar {
    gap: var(--s3);
  }

  .topbar-right {
    gap: var(--s2);
  }
}
