/* shell.css — Ink Fortress unified shell.
   Adds a slim top tab bar above the four canvases. Each canvas keeps
   its own 64px topbar; this shell strip is intentionally compact so it
   doesn't fight them visually. */

:root {
  /* Space reserved so Character wizard / sticky panels sit above the fixed Coauthor dock */
  --if-ai-dock-clearance: 124px;
  --if-shell-height: 40px;
  --if-shell-bg: #f6f4ef;        /* matches --paper-2 in styles.css */
  --if-shell-rule: rgba(42, 36, 25, 0.16);
  --if-shell-text: #29261b;
  --if-shell-muted: #7a7568;
  --if-shell-accent: #a8423d;
}

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

.if-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.if-shell-nav {
  flex: 0 0 var(--if-shell-height);
  height: var(--if-shell-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--if-shell-bg);
  border-bottom: 0.5px solid var(--if-shell-rule);
  font-family: "DM Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 13px;
  color: var(--if-shell-text);
  position: relative;
  z-index: 50;
}

.if-shell-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--if-shell-text);
  padding-right: 16px;
  border-right: 0.5px solid var(--if-shell-rule);
  min-width: 0;
  cursor: pointer;
}
.if-shell-brand-mark {
  /* Inline SVG logo. Sized to fit the 40px shell nav with a little breathing room. */
  width: 28px;
  height: 28px;
  display: block;
  flex: 0 0 28px;
  color: var(--if-shell-text);    /* castle uses currentColor */
  overflow: visible;
}
.if-logo-castle { fill: currentColor; }
.if-logo-cutout { fill: var(--if-shell-bg); }
.if-logo-quill  { fill: #c95a3e; }
.if-logo-shaft  { stroke: #7a2f23; }
.if-logo-tip    { fill: var(--if-shell-accent); }

.if-shell-wordmark {
  font-family: "EB Garamond", "Iowan Old Style", Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: 19px;
  letter-spacing: 0.005em;
  color: var(--if-shell-text);
  line-height: 1;
  white-space: nowrap;
}

.if-shell-series-wrap {
  position: relative;
  margin-left: 4px;
  min-width: 0;
}
.if-shell-series-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 0.5px solid var(--if-shell-rule);
  background: rgba(255, 255, 255, 0.55);
  font: inherit;
  font-size: 12px;
  color: var(--if-shell-text);
  cursor: pointer;
  transition: background 120ms ease;
}
.if-shell-series-chip:hover {
  background: #fff;
}
.if-shell-series-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.if-shell-series-caret {
  flex-shrink: 0;
  font-size: 10px;
  opacity: 0.65;
}
.if-shell-series-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  max-width: 320px;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: #fff;
  border: 0.5px solid var(--if-shell-rule);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(42, 36, 25, 0.12);
  z-index: 200;
}
.if-shell-series-opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  color: var(--if-shell-text);
}
.if-shell-series-opt:hover {
  background: rgba(42, 36, 25, 0.06);
}
.if-shell-series-opt.is-active {
  font-weight: 600;
  background: rgba(201, 90, 62, 0.08);
}

.if-saved {
  font-size: 13px;
  color: var(--if-shell-muted, #6b6458);
}
.if-saved em {
  font-style: italic;
  color: var(--if-shell-text, #2a2419);
}
.if-saved-muted { opacity: 0.75; }
.if-saved-busy { color: #8a6a2a; }
.if-saved-err { color: #a83232; }

.if-shell-tabs {
  display: flex;
  gap: 2px;
  flex: 0 0 auto;
  min-width: 0;
}

.if-shell-tab {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 6px 12px;
  border-radius: 6px;
  font: inherit;
  color: var(--if-shell-muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
  letter-spacing: 0.01em;
}
.if-shell-tab:hover {
  background: rgba(42, 36, 25, 0.05);
  color: var(--if-shell-text);
}
.if-shell-tab.is-active {
  background: #fff;
  color: var(--if-shell-text);
  box-shadow: 0 0 0 0.5px var(--if-shell-rule);
}
.if-shell-tab.is-active::after {
  /* Subtle indicator dot in the brand colour */
  content: "";
  display: inline-block;
  width: 5px; height: 5px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--if-shell-accent);
  vertical-align: middle;
}

/* Global search lives in the shell nav so every canvas shares the same
   input. The active canvas listens for `inkfortress-search` events and
   copies the value into its own searchQuery state. */
.if-shell-search {
  flex: 1 1 320px;
  max-width: 420px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 10px;
  margin: 0 8px 0 14px;
  background: #fff;
  border: 0.5px solid var(--if-shell-rule);
  border-radius: 6px;
  color: var(--if-shell-muted);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.if-shell-search:focus-within {
  border-color: var(--if-shell-text);
  box-shadow: 0 0 0 3px rgba(42, 36, 25, 0.05);
}
.if-shell-search svg { flex-shrink: 0; }
.if-shell-search input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  font: inherit;
  font-size: 12.5px;
  color: var(--if-shell-text);
  padding: 0;
}
.if-shell-search input::placeholder { color: var(--if-shell-muted); }
.if-shell-search kbd {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  color: var(--if-shell-muted);
  background: rgba(42, 36, 25, 0.05);
  border: 0.5px solid var(--if-shell-rule);
  border-radius: 3px;
  padding: 1px 5px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.if-shell-aux {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--if-shell-muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
}
.if-shell-aux .if-shell-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #c4bfa9;
  display: inline-block;
  margin-right: 4px;
}
.if-shell-aux.is-online .if-shell-dot { background: #6aa46a; }
.if-shell-aux.is-offline .if-shell-dot { background: #c47373; }

.if-shell-main {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

/* Each canvas lives in its own slot, kept mounted but visually swapped. */
.if-canvas-slot {
  position: absolute;
  inset: 0;
  min-height: 0;
  overflow: hidden;
}
.if-canvas-slot.is-hidden {
  /* Keep the React tree alive but pull it from layout + a11y entirely. */
  visibility: hidden;
  pointer-events: none;
}
.if-canvas-slot > * {
  height: 100%;
  min-height: 0;
}

.if-shell-placeholder {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--if-shell-muted);
  font-family: "EB Garamond", Georgia, serif;
  font-style: italic;
  font-size: 18px;
}

/* The four canvases now share the same topbar shape: .story-title in the
   centre, .topbar-right (search + actions) on the right. No per-canvas
   overrides are needed; everything below is intentionally empty so we
   notice if a canvas regresses. */

/* ─── Global AI Dock ─────────────────────────────────────────────────── */
.if-shell-ai-dock {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, calc(100vw - 80px));
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none; /* Let clicks pass through outside the container */
}

/* Aimee (developmental editor) mode — same dock slot, different editorial context */
.if-shell-ai-dock.if-ai-dock--aimee .if-send-line {
  border-color: rgba(163, 123, 42, 0.45);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(163, 123, 42, 0.2);
}
.if-shell-ai-dock.if-ai-dock--aimee .if-send-mark {
  color: #c9a227;
}

.if-ai-container {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.if-ai-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 4px;
}

.if-ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(42, 36, 25, 0.85);
  color: #faf7f0;
  font-size: 11px;
  font-family: var(--sans, sans-serif);
  border: 1px solid rgba(250, 247, 240, 0.1);
  backdrop-filter: blur(4px);
}

.if-ai-chip-x {
  cursor: pointer;
  opacity: 0.7;
  font-size: 14px;
  line-height: 1;
}

.if-ai-chip-x:hover {
  opacity: 1;
}

.if-send-line {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(42, 36, 25, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(250, 247, 240, 0.15);
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.if-send-line:focus-within {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.25), 0 0 0 1px rgba(250,247,240,0.2);
}

.if-send-mark {
  color: #d4c8a9;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.if-send-input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  font-family: var(--sans, sans-serif);
  font-size: 14px;
  color: #faf7f0;
  padding: 4px 0;
}

.if-send-input::placeholder {
  color: rgba(250, 247, 240, 0.4);
}

.if-send-btn {
  appearance: none;
  background: var(--if-shell-accent);
  color: #fff;
  border: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: bold;
  font-size: 16px;
  transition: transform 0.1s ease, filter 0.1s ease;
}

.if-send-btn:hover:not(:disabled) {
  filter: brightness(1.1);
  transform: scale(1.05);
}

.if-send-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.if-send-btn:disabled {
  background: rgba(250, 247, 240, 0.1);
  color: rgba(250, 247, 240, 0.3);
  cursor: default;
}

/* ─── Coauthor reply overlay (global) ─────────────────────────────────── */
.if-co-veil {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(10, 8, 6, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(3px);
}

.if-co-panel {
  width: min(720px, calc(100vw - 32px));
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
  background: #faf7f0;
  color: #2a2419;
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(42, 36, 25, 0.12);
  overflow: hidden;
}

.if-co-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(42, 36, 25, 0.08);
}

.if-co-title {
  margin: 0;
  font-family: var(--serif, "EB Garamond", Georgia, serif);
  font-size: 22px;
  font-weight: 500;
  font-style: italic;
}

.if-co-close {
  appearance: none;
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-3, #6b6456);
  padding: 4px 8px;
  border-radius: 6px;
}

.if-co-close:hover {
  background: rgba(42, 36, 25, 0.06);
  color: #2a2419;
}

.if-co-meta {
  padding: 0 16px 8px;
  font-family: var(--mono, "JetBrains Mono", monospace);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8a8270;
}

.if-co-body {
  padding: 12px 16px 18px;
  overflow: auto;
  min-height: 120px;
}

.if-co-text,
.if-co-err {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--sans, "DM Sans", system-ui, sans-serif);
  font-size: 14px;
  line-height: 1.55;
}

.if-co-err {
  color: #8b3a32;
}

/* Writer → Story Graph delta (subtle status toasts) */
.inkfortress-graph-toast {
  position: fixed;
  bottom: calc(var(--if-ai-dock-clearance, 124px) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  z-index: 12000;
  max-width: min(420px, 92vw);
  padding: 10px 16px;
  border-radius: 10px;
  font: 500 13px/1.35 "DM Sans", ui-sans-serif, system-ui, sans-serif;
  color: #2a2419;
  background: rgba(250, 247, 240, 0.96);
  border: 0.5px solid rgba(42, 36, 25, 0.14);
  box-shadow: 0 6px 24px rgba(42, 36, 25, 0.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.inkfortress-graph-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.inkfortress-graph-toast.is-ok {
  border-color: rgba(58, 122, 114, 0.35);
}
.inkfortress-graph-toast.is-error {
  border-color: rgba(168, 66, 61, 0.45);
  color: #6b2c28;
}



/* Quota exceeded modal */
.if-quota-veil {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(28, 24, 18, 0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.if-quota-modal {
  position: relative;
  max-width: 480px;
  width: 100%;
  border-radius: 14px;
  padding: 22px 24px 20px;
  background: #fdfbf7;
  border: 0.5px solid rgba(42, 36, 25, 0.18);
  box-shadow: 0 18px 48px rgba(20, 16, 10, 0.2);
}

.if-quota-body {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.5;
  color: #3a3428;
}

.if-quota-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}



/* ─── UserChip (bottom-left identity + account menu) ───────────────────── */
.if-uc {
  position: fixed;
  bottom: 18px;
  left: 18px;
  z-index: 210;
  font-family: var(--sans, system-ui, sans-serif);
}

.if-uc-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: rgba(42, 36, 25, 0.92);
  color: #faf7f0;
  border: 1px solid rgba(250, 247, 240, 0.12);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(6px);
  transition: background 0.12s ease, transform 0.12s ease;
  max-width: min(280px, 30vw);
}

.if-uc-audio-dot {
  position: absolute;
  top: 2px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #f3c97c;
  box-shadow: 0 0 0 2px rgba(42, 36, 25, 0.92);
}

.if-uc-chip:hover,
.if-uc-chip.is-open {
  background: rgba(42, 36, 25, 1);
  transform: translateY(-1px);
}

.if-uc-avatar {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #a37b2a, #5c6b7a);
  color: #faf7f0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.if-uc-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.if-uc-name {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.if-uc-plan {
  font-size: 10px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  opacity: 0.75;
}

.if-uc-plan-pro  { color: #f3c97c; }
.if-uc-plan-plus { color: #cdb4ff; }
.if-uc-plan-free { color: #d8cfb6; }

/* Popover menu — opens upward from the chip */
.if-uc-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 240px;
  background: rgba(28, 22, 14, 0.96);
  color: #faf7f0;
  border: 1px solid rgba(250, 247, 240, 0.12);
  border-radius: 10px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.32);
  padding: 8px;
  backdrop-filter: blur(8px);
  animation: if-uc-menu-in 0.12s ease;
}

@keyframes if-uc-menu-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.if-uc-menu-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid rgba(250, 247, 240, 0.08);
  margin-bottom: 6px;
}

.if-uc-menu-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.if-uc-menu-email {
  font-size: 11px;
  opacity: 0.62;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.if-uc-menu-plan {
  align-self: flex-start;
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(250, 247, 240, 0.08);
}

.if-uc-menu-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  text-align: left;
  border-radius: 6px;
  cursor: pointer;
}

.if-uc-menu-row:hover {
  background: rgba(250, 247, 240, 0.06);
}

.if-uc-audio-warn-menu {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid rgba(243, 201, 124, 0.22);
  background: rgba(243, 201, 124, 0.1);
  color: #f5dfad;
  font: inherit;
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
  border-radius: 7px;
  cursor: pointer;
  margin: 4px 0;
}

.if-uc-audio-warn-menu span:last-child {
  color: #faf7f0;
  font-size: 11px;
  opacity: 0.86;
}

.if-uc-audio-warn-menu:hover {
  background: rgba(243, 201, 124, 0.15);
}

.if-uc-menu-row.is-danger {
  color: #f3a6a6;
}

.if-uc-menu-row.is-danger:hover {
  background: rgba(243, 166, 166, 0.08);
}

.if-uc-menu-glyph {
  display: inline-flex;
  width: 18px;
  justify-content: center;
  opacity: 0.7;
  font-size: 13px;
}

.if-uc-menu-sep {
  height: 1px;
  background: rgba(250, 247, 240, 0.08);
  margin: 6px 4px;
}

/* Don't fight the AI dock — when both are visible, AI dock is centered
   bottom and the user chip sits in the corner without overlap. */
@media (max-width: 720px) {
  .if-uc-chip .if-uc-text { display: none; }
  .if-uc-chip { padding: 4px; }
}

/* ─── Story Graph audit dock (completion sprint) ───────────────────────── */
.if-shell--audit .if-shell-main {
  padding-right: 380px;
  box-sizing: border-box;
  transition: padding-right 0.2s ease;
}
.if-shell--audit.if-shell--audit-collapsed .if-shell-main {
  padding-right: 56px;
}

.if-audit-panel {
  position: fixed;
  top: var(--if-shell-height);
  right: 0;
  bottom: 0;
  z-index: 45;
  display: flex;
  flex-direction: column;
  background: #faf8f3;
  border-left: 1px solid var(--if-shell-rule, rgba(42, 36, 25, 0.16));
  box-shadow: -4px 0 24px rgba(42, 36, 25, 0.06);
  font-family: "DM Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  color: #29261b;
  min-height: 0;
}
.if-audit-panel.is-collapsed {
  align-items: center;
  padding-top: 10px;
}
.if-audit-panel.is-collapsed .if-audit-head {
  flex-direction: column;
  width: 100%;
  align-items: center;
  gap: 8px;
}

.if-audit-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--if-shell-rule, rgba(42, 36, 25, 0.12));
  background: rgba(255, 255, 255, 0.5);
}
.if-audit-head-text { min-width: 0; }
.if-audit-title {
  font-family: "EB Garamond", Georgia, serif;
  font-size: 16px;
  font-style: italic;
  line-height: 1.25;
  margin-bottom: 8px;
}
.if-audit-chips-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.if-audit-pill {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(168, 66, 61, 0.12);
  color: #7a2f23;
}
.if-audit-pill-btn {
  border: none;
  cursor: pointer;
  font: inherit;
}
.if-audit-pill-btn:hover { background: rgba(168, 66, 61, 0.2); }
.if-audit-candor {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #5c574c;
}
.if-audit-candor select {
  font: inherit;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(42, 36, 25, 0.2);
  background: #fff;
}
.if-audit-head-actions { display: flex; gap: 4px; flex-shrink: 0; }
.if-audit-icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: #5c574c;
  padding: 2px 6px;
  border-radius: 4px;
}
.if-audit-icon-btn:hover { background: rgba(42, 36, 25, 0.06); }

.if-audit-body-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 12px 14px 20px;
}
.if-audit-sec { margin-bottom: 18px; }
.if-audit-sec h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7a7568;
  margin: 0 0 8px;
}
.if-audit-sec p,
.if-audit-sec li {
  margin: 0 0 8px;
  line-height: 1.45;
}
.if-audit-muted { color: #7a7568; font-size: 12px; }
.if-audit-banner {
  background: rgba(168, 130, 45, 0.12);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 13px;
}
.if-audit-strength {
  border: 1px solid rgba(42, 36, 25, 0.1);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #fff;
}
.if-audit-strength h4 { margin: 0 0 6px; font-size: 14px; }
.if-audit-finding {
  border: 1px solid rgba(42, 36, 25, 0.12);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #fff;
}
.if-audit-finding.is-marked { border-color: rgba(168, 66, 61, 0.35); }
.if-audit-finding-head { margin: 0 0 6px; font-size: 14px; }
.if-audit-finding-status { font-size: 12px; color: #3f7d4a; margin: 0 0 6px; }
.if-audit-finding-meta { font-size: 12px; color: #5c574c; }
.if-audit-finding-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.if-audit-chip {
  font: inherit;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(42, 36, 25, 0.2);
  background: #faf8f3;
  cursor: pointer;
}
.if-audit-chip:disabled { opacity: 0.45; cursor: not-allowed; }
.if-audit-chip:hover:not(:disabled) { background: rgba(168, 66, 61, 0.08); }
.if-audit-drawer { margin-top: 8px; }
.if-audit-drawer summary { cursor: pointer; font-size: 13px; color: #5c574c; }
.if-audit-transparency { font-size: 12px; color: #5c574c; }
.if-audit-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(42, 36, 25, 0.1);
}
.if-audit-aimee-thread {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(42, 36, 25, 0.1);
}
.if-audit-aimee-msgs {
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 10px;
}
.if-audit-aimee-msg { margin-bottom: 12px; }
.if-audit-aimee-byline {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #7a7568;
  margin-bottom: 4px;
}
.if-audit-aimee-bubble {
  font-size: 13px;
  line-height: 1.45;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(42, 36, 25, 0.04);
  border: 1px solid rgba(42, 36, 25, 0.08);
  white-space: pre-wrap;
}
.if-audit-aimee-msg.user .if-audit-aimee-bubble {
  background: rgba(90, 118, 168, 0.12);
  border-color: rgba(90, 118, 168, 0.25);
}
.if-audit-aimee-msg.assistant .if-audit-aimee-bubble {
  background: rgba(163, 123, 42, 0.08);
  border-color: rgba(163, 123, 42, 0.22);
}
.if-audit-aimee-bubble.thinking {
  font-style: italic;
  color: #7a7568;
}
.if-audit-btn-ghost {
  background: transparent;
  border: 1px dashed rgba(42, 36, 25, 0.2);
  margin-top: 4px;
}
.if-audit-btn-ghost:hover:not(:disabled) {
  background: rgba(42, 36, 25, 0.04);
}
.if-audit-btn {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(42, 36, 25, 0.2);
  background: #fff;
  cursor: pointer;
}
.if-audit-btn-primary {
  background: #a8423d;
  color: #fff;
  border-color: #8e3834;
}
.if-audit-btn-primary:hover { filter: brightness(1.05); }

.if-audit-loading {
  padding: 14px 14px 20px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.if-audit-loading-lead {
  font-family: "EB Garamond", Georgia, serif;
  font-style: italic;
  font-size: 16px;
  margin: 0 0 14px;
  line-height: 1.35;
}
.if-audit-phases { list-style: none; margin: 0; padding: 0; }
.if-audit-phases li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 0;
  font-size: 12px;
  color: #7a7568;
}
.if-audit-phases li.is-done { color: #29261b; }
.if-audit-phase-check { flex: 0 0 1.2em; font-size: 12px; }

.if-audit-error { padding: 14px; color: #8e3834; }
.if-audit-error .if-audit-btn { margin-top: 8px; }

.if-audit-veil {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(20, 18, 14, 0.35);
  display: grid;
  place-items: center;
  padding: 24px;
}
.if-audit-modal {
  max-width: 420px;
  width: 100%;
  background: #faf8f3;
  border-radius: 10px;
  padding: 22px 24px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(42, 36, 25, 0.12);
}
.if-audit-modal-title {
  margin: 0 0 12px;
  font-family: "EB Garamond", Georgia, serif;
  font-size: 22px;
  font-weight: 500;
}
.if-audit-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.if-audit-onb-lead,
.if-audit-onb-sub,
.if-audit-body {
  line-height: 1.45;
  margin: 0 0 10px;
}
.if-audit-onb-list {
  margin: 0 0 16px 16px;
  padding: 0;
  line-height: 1.45;
}
.if-audit-genre {
  padding: 10px 12px 12px;
  border-bottom: 1px solid rgba(42, 36, 25, 0.1);
  background: rgba(255, 255, 255, 0.4);
}
.if-audit-genre-q { margin: 0 0 10px; font-size: 13px; }
.if-audit-genre-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.if-audit-genre-chip {
  font: inherit;
  font-size: 11px;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid rgba(42, 36, 25, 0.18);
  background: #fff;
  cursor: pointer;
}
.if-audit-genre-chip:hover { background: rgba(168, 66, 61, 0.08); }
