/* Playbook UI — design tokens */
:root {
  color-scheme: light;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e3e8ef;
  --border-strong: #cbd5e1;

  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --accent: #007dbc;
  --accent-strong: #007dbc;
  --accent-soft: #e5f4fb;
  --accent-border: #b8def0;
  --brand: var(--accent);
  --secondary: #7ac943;
  --secondary-strong: #7ac943;

  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --warn-text: #92400e;

  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --error-text: #b91c1c;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --app-header-height: 60px;
  --document-anchor-offset: 88px;

  --shadow-sm: 0 1px 2px rgb(15 23 42 / 5%);
  --shadow: 0 1px 3px rgb(15 23 42 / 8%), 0 1px 2px rgb(15 23 42 / 4%);
  --shadow-lg: 0 10px 30px rgb(15 23 42 / 12%), 0 2px 8px rgb(15 23 42 / 6%);

  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #191a1c;
  --surface: #232427;
  --surface-muted: #2a2b2f;
  --border: #35363a;
  --border-strong: #4a4b50;

  --text: #f2f3f5;
  --text-secondary: #b6b8bd;
  --text-muted: #8b8d93;

  --accent: #007dbc;
  --accent-strong: #2aa4da;
  --accent-soft: rgb(0 125 188 / 18%);
  --accent-border: rgb(0 125 188 / 42%);
  --brand: var(--text);
  --secondary: #7ac943;
  --secondary-strong: #93d966;

  --warn-bg: rgb(251 191 36 / 10%);
  --warn-border: rgb(251 191 36 / 35%);
  --warn-text: #fbbf24;

  --error-bg: rgb(248 113 113 / 10%);
  --error-border: rgb(248 113 113 / 35%);
  --error-text: #f87171;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-lg: 0 10px 30px rgb(0 0 0 / 50%);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #191a1c;
    --surface: #232427;
    --surface-muted: #2a2b2f;
    --border: #35363a;
    --border-strong: #4a4b50;

    --text: #f2f3f5;
    --text-secondary: #b6b8bd;
    --text-muted: #8b8d93;

    --accent: #007dbc;
    --accent-strong: #2aa4da;
    --accent-soft: rgb(0 125 188 / 18%);
    --accent-border: rgb(0 125 188 / 42%);
    --brand: var(--text);
    --secondary: #7ac943;
    --secondary-strong: #93d966;

    --warn-bg: rgb(251 191 36 / 10%);
    --warn-border: rgb(251 191 36 / 35%);
    --warn-text: #fbbf24;

    --error-bg: rgb(248 113 113 / 10%);
    --error-border: rgb(248 113 113 / 35%);
    --error-text: #f87171;

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-lg: 0 10px 30px rgb(0 0 0 / 50%);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

html {
  scroll-behavior: smooth;
}

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

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

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

:is(button, input, select, textarea, a, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Inputs */
input,
select,
textarea,
.global-search input,
.section-search input,
.login-form input,
.login-form select {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  padding: 8px 10px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #94a3b8;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

input[type="checkbox"] {
  accent-color: var(--accent);
  height: 15px;
  width: 15px;
}

textarea {
  min-height: 220px;
  resize: vertical;
  width: 100%;
  line-height: 1.6;
}

/* Buttons: neutral by default, primary on form submits */
button,
.actions a,
.session-actions a {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font-size: 14px;
  font-weight: 500;
  gap: 6px;
  justify-content: center;
  padding: 7px 14px;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 60ms ease;
}

button:hover,
.actions a:hover,
.session-actions a:hover {
  background: var(--surface-muted);
  border-color: #94a3b8;
  color: var(--text);
  text-decoration: none;
}

button:active {
  transform: translateY(1px);
}

button[type="submit"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

button[type="submit"]:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

html[data-theme="dark"] button[type="submit"] {
  background: #f2f3f5;
  border-color: #f2f3f5;
  color: #191a1c;
}

html[data-theme="dark"] button[type="submit"]:hover {
  background: #d7d8dc;
  border-color: #d7d8dc;
  color: #191a1c;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) button[type="submit"] {
    background: #f2f3f5;
    border-color: #f2f3f5;
    color: #191a1c;
  }

  html:not([data-theme="light"]) button[type="submit"]:hover {
    background: #d7d8dc;
    border-color: #d7d8dc;
    color: #191a1c;
  }
}

button:disabled {
  cursor: default;
  opacity: 0.55;
  transform: none;
}

button.is-pending {
  cursor: wait;
  opacity: 0.8;
}

.button-spinner {
  animation: button-spin 700ms linear infinite;
  border: 2px solid currentColor;
  border-radius: 999px;
  border-right-color: transparent;
  display: inline-block;
  flex: 0 0 auto;
  height: 12px;
  width: 12px;
}

@keyframes button-spin {
  to {
    transform: rotate(360deg);
  }
}

button.primary-action {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

button.primary-action:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #ffffff;
}

.visually-hidden {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

/* Login / standalone panel pages */
.shell {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 48px 24px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  width: min(720px, 100%);
}

/* App shell */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Wrapping flex rather than a fixed grid: at high zoom or with many
   centers, nav pills wrap onto extra rows and the search/account zones
   shrink or flow to a new line instead of overlapping. */
.app-header {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  min-height: 60px;
  padding: 10px 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  align-items: center;
  color: var(--brand);
  display: inline-flex;
  font-size: 19px;
  font-weight: 700;
  min-height: 40px;
  text-decoration: none;
}

.brand:hover {
  color: var(--brand);
  text-decoration: none;
}

.brand.is-branding-loading {
  visibility: hidden;
}

.brand-logo {
  display: block;
  max-height: 36px;
  max-width: 180px;
  object-fit: contain;
}

.header-brand-group {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  min-width: 0;
}

/* Top navigation */
.top-nav {
  align-items: center;
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 40px;
  min-width: 0;
}

.nav-item {
  display: flex;
  position: relative;
}

.nav-item > button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  padding: 7px 12px;
  white-space: nowrap;
}

.nav-item > button:hover {
  background: var(--surface-muted);
  border-color: transparent;
  color: var(--text);
}

.nav-item:hover > button,
.nav-item.is-keyboard-open > button {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.nav-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: none;
  left: 0;
  max-width: calc(100vw - 48px);
  min-width: 280px;
  padding: 10px;
  position: absolute;
  top: calc(100% + 6px);
  z-index: 70;
}

/* Invisible bridge across the 6px gap so moving the cursor from the center
   tab to the menu doesn't cross a dead zone and close the dropdown. */
.nav-menu::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 0;
  right: 0;
  height: 6px;
}

.nav-item:hover .nav-menu,
.nav-item.is-keyboard-open .nav-menu {
  display: grid;
  gap: 2px;
}

.nav-menu a {
  border-radius: var(--radius-sm);
  color: var(--text);
  display: block;
  padding: 7px 10px;
}

.nav-menu a:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
  text-decoration: none;
}

.dropdown-group {
  position: relative;
}

.dropdown-flyout {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: none;
  left: calc(100% + 4px);
  list-style: none;
  margin: 0;
  max-height: min(70vh, 640px);
  max-height: min(70dvh, 640px);
  min-width: 230px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 8px;
  position: absolute;
  scrollbar-gutter: stable;
  top: -8px;
}

/* Keep the flyout's hover bridge outside its clipped scrolling element. */
.dropdown-flyout-bridge {
  bottom: 0;
  left: 100%;
  position: absolute;
  top: 0;
  width: 4px;
}

.dropdown-group:hover .dropdown-flyout,
.dropdown-group.is-pointer-open .dropdown-flyout,
.dropdown-group.is-keyboard-open .dropdown-flyout {
  display: block;
}

.dropdown-flyout li {
  margin: 0;
}

.dropdown-flyout a {
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  display: block;
  font-size: 14px;
  padding: 6px 10px;
}

.dropdown-flyout a:hover {
  background: var(--surface-muted);
  color: var(--text);
  text-decoration: none;
}

.section-link {
  color: var(--text);
  font-weight: 600;
}

/* Header search */
.global-search {
  align-items: center;
  display: grid;
  flex: 0 1 320px;
  gap: 8px;
  grid-template-columns: 1fr auto;
  min-width: 190px;
}

.global-search label {
  display: grid;
  gap: 4px;
}

.global-search span {
  display: none;
}

.global-search input {
  border-radius: 999px;
  padding: 8px 16px;
}

.global-search button {
  border-radius: 999px;
}

@media (min-width: 900px) {
  .global-search button {
    display: none;
  }
}

.section-search {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(200px, 420px) auto;
  margin: 20px 0 0;
}

.section-search label {
  display: grid;
  gap: 4px;
}

.section-search span,
.login-form span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Account area */
.account {
  align-items: center;
  display: flex;
  flex: 0 1 auto;
  gap: 6px;
  justify-content: flex-end;
  margin-left: auto;
  min-width: 0;
  position: relative;
}

.current-user {
  align-items: center;
  display: flex;
  gap: 8px;
  text-align: right;
}

.account-trigger {
  align-items: center;
  background: transparent;
  border-color: transparent;
  color: var(--text);
  display: inline-flex;
  gap: 8px;
  max-width: min(280px, 100vw - 48px);
  padding: 4px 6px;
  text-align: right;
}

.account-trigger:hover,
.account-trigger[aria-expanded="true"] {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--text);
}

.account-header-action {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  display: inline-flex;
  flex: 0 0 auto;
  height: 34px;
  justify-content: center;
  padding: 0;
  position: relative;
  text-decoration: none;
  width: 34px;
}

.account-header-action:hover {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--text);
  text-decoration: none;
}

.account-header-action:active {
  transform: none;
}

.account-review-action .suggestion-review-icon {
  height: 17px;
  width: 17px;
}

.account-feedback-icon {
  height: 17px;
  width: 17px;
}

.quick-access {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  position: relative;
}

.quick-access-trigger {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  display: inline-flex;
  flex: 0 0 auto;
  height: 34px;
  justify-content: center;
  padding: 0;
  width: 34px;
}

.quick-access-trigger:hover,
.quick-access-trigger[aria-expanded="true"] {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--text);
}

.quick-access-trigger:active {
  transform: none;
}

.quick-access-clock-icon {
  height: 18px;
  width: 18px;
}

.account-review-action .suggestion-review-badge {
  min-width: 17px;
  padding: 3px 5px;
  position: absolute;
  right: -4px;
  top: -4px;
}

.avatar {
  align-items: center;
  background: #d9f99d;
  border-radius: 999px;
  color: #1a2e05;
  display: inline-flex;
  flex: 0 0 28px;
  font-size: 11px;
  font-weight: 700;
  height: 28px;
  justify-content: center;
  line-height: 1;
  width: 28px;
}

.user-details {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.user-name {
  font-weight: 600;
  line-height: 1.25;
}

.user-meta,
.muted {
  color: var(--text-muted);
  font-size: 12px;
}

.user-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.session-actions.account-menu {
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: 2px;
  justify-content: stretch;
  min-width: 220px;
  padding: 8px;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 80;
}

.session-actions.account-menu[hidden] {
  display: none;
}

.quick-access-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: 3px;
  max-height: min(620px, calc(100vh - var(--app-header-height, 60px) - 32px));
  min-width: min(360px, calc(100vw - 32px));
  overflow-y: auto;
  padding: 10px;
  position: absolute;
  left: 0;
  right: auto;
  top: calc(100% + 8px);
  width: 360px;
  z-index: 81;
}

.quick-access-menu[hidden] {
  display: none;
}

.quick-access-section-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  min-height: 32px;
  padding: 2px 4px;
}

.quick-access-section-header:not(:first-of-type) {
  border-top: 1px solid var(--border);
  margin-top: 5px;
  padding-top: 9px;
}

.quick-access-section-title {
  font-size: 12px;
  letter-spacing: 0.05em;
  margin: 0;
  text-transform: uppercase;
}

.quick-access-section-action {
  background: transparent;
  border: 0;
  color: var(--accent-strong);
  font-size: 12px;
  min-height: 28px;
  padding: 3px 6px;
}

.quick-access-row {
  align-items: center;
  border-radius: var(--radius-sm);
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 38px;
  padding: 2px 3px 2px 9px;
}

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

.quick-access-row[draggable="true"] {
  cursor: grab;
}

.quick-access-document-link {
  color: var(--text);
  font-size: 13px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-access-row-actions {
  align-items: center;
  display: flex;
  gap: 1px;
}

.quick-access-row-action {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: inline-flex;
  font-size: 16px;
  height: 30px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  width: 30px;
}

.quick-access-row-action:hover {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.quick-access-row-action:disabled {
  opacity: 0.35;
}

.quick-access-empty,
.quick-access-status {
  color: var(--text-muted);
  font-size: 12px;
  margin: 0;
  padding: 5px 10px 8px;
}

.quick-access-status {
  align-items: center;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius-sm);
  color: var(--warn-text);
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.quick-access-retry {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  flex: 0 0 auto;
  font-size: 12px;
  min-height: 28px;
  padding: 3px 8px;
}

.session-actions a,
.session-actions button {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 5px 9px;
}

.session-actions.account-menu a,
.session-actions.account-menu button {
  border-radius: var(--radius-sm);
  justify-content: flex-start;
  min-height: 34px;
  padding: 7px 10px;
  width: 100%;
}

.account-menu-item-label {
  min-width: 0;
}

.account-menu-item-suffix {
  color: var(--text-muted);
  margin-left: auto;
}

.session-actions.account-menu .account-menu-heading {
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 600;
  justify-content: flex-start;
  min-height: 38px;
  padding: 7px 10px;
  width: 100%;
}

.account-menu-back-arrow {
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
}

.session-actions a:hover,
.session-actions button:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.session-actions .suggestion-review-link {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.account-menu-separator {
  background: var(--border);
  height: 1px;
  margin: 5px 2px;
}

.suggestion-review-icon {
  flex: 0 0 auto;
  height: 14px;
  width: 14px;
}

.suggestion-review-badge {
  align-items: center;
  background: var(--error-text);
  border-radius: 999px;
  color: var(--surface);
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  justify-content: center;
  line-height: 1;
  min-width: 18px;
  padding: 3px 5px;
}

.theme-toggle {
  min-width: 30px;
}

#theme-toggle-static {
  position: fixed;
  right: 16px;
  top: 16px;
  z-index: 20;
}

/* Main content */
.main-content {
  margin: 28px auto;
  max-width: 960px;
  padding: 0 24px 64px;
  width: 100%;
}

.main-content.has-document-layout {
  max-width: 1064px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1 {
  border-bottom: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 8px;
  padding-bottom: 0;
}

h2 {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0;
}

h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.lede {
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.6;
  margin: 10px 0 28px;
  max-width: 65ch;
}

/* Cards and lists */
.section-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  margin-top: 24px;
}

.section-card,
.document-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.section-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  transition: box-shadow 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.section-card:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.section-card p {
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 0;
}

.stack {
  display: grid;
  gap: 8px;
}

.document-list {
  display: grid;
  gap: 0;
  margin-top: 24px;
  padding: 8px 20px;
}

.document-row {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.document-row:last-child {
  border-bottom: 0;
}

.document-row p {
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 6px 0 0;
}

.search-results {
  margin-top: 8px;
}

.empty-note {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
  padding: 10px 0;
}

/* Ask Playbook */
.assistant-main {
  max-width: 920px;
}

/* Ask Playbook chat */
.main-content.has-chat-layout {
  margin: 0;
  max-width: none;
  padding: 0;
  flex: 1;
  min-height: 0;
  display: flex;
}

#home-chat,
#assistant-chat {
  flex: 1;
  min-height: 0;
  display: flex;
}

.app-shell.is-pwa-mode {
  background: var(--bg);
  min-height: 100dvh;
}

.app-shell.is-pwa-mode .app-header {
  display: none;
}

.app-shell.is-pwa-mode #app-status {
  left: max(12px, env(safe-area-inset-left));
  margin: 0;
  max-width: calc(100% - 24px);
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  top: max(10px, env(safe-area-inset-top));
  z-index: 90;
}

.pwa-main {
  min-height: 100dvh;
}

.pwa-chat-shell {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 100dvh;
  min-width: 0;
}

.pwa-chat-header {
  align-items: center;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 8px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  min-height: 58px;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
  position: sticky;
  top: 0;
  z-index: 20;
}

.pwa-title-block {
  display: grid;
  gap: 1px;
  justify-items: center;
  min-width: 0;
  text-align: center;
}

.pwa-app-name {
  font-size: 15px;
  font-weight: 700;
}

.pwa-tenant-name {
  color: var(--text-muted);
  font-size: 12px;
}

.pwa-icon-button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  display: inline-flex;
  height: 40px;
  justify-content: center;
  padding: 0;
  width: 40px;
}

.pwa-icon-button:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.is-pwa-chat .chat-layout {
  grid-template-columns: minmax(0, 1fr);
  height: calc(100dvh - 58px);
}

/* In PWA mode the sidebar becomes a ChatGPT-style drawer sliding in from
   the left; a backdrop dims the chat and closes the drawer on tap. */
.is-pwa-chat .chat-sidebar {
  bottom: 0;
  box-shadow: var(--shadow-lg);
  display: flex;
  left: 0;
  max-width: calc(100vw - 56px);
  overflow: hidden;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  position: fixed;
  top: 0;
  transform: translateX(-105%);
  transition: transform 220ms ease, visibility 220ms;
  visibility: hidden;
  width: 320px;
  z-index: 70;
}

.is-pwa-chat .chat-sidebar.is-open {
  transform: none;
  visibility: visible;
}

.is-pwa-chat .chat-history {
  flex: 1;
}

.chat-drawer-backdrop {
  background: rgb(0 0 0 / 45%);
  inset: 0;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  transition: opacity 220ms ease;
  z-index: 65;
}

.chat-drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.chat-drawer-top {
  align-items: center;
  display: flex;
  justify-content: space-between;
  padding-left: 8px;
}

.chat-drawer-brand {
  font-size: 15px;
  font-weight: 700;
}

.chat-drawer-footer {
  border-top: 1px solid var(--border);
  display: grid;
  gap: 2px;
  padding-top: 10px;
}

.chat-drawer-action {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  display: flex;
  font-size: 14px;
  font-weight: 500;
  justify-content: flex-start;
  padding: 9px 10px;
  text-align: left;
  width: 100%;
}

.chat-drawer-action:hover {
  background: var(--surface-muted);
  color: var(--text);
  text-decoration: none;
}

.chat-drawer-user {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-top: 6px;
  padding: 8px 10px 0;
}

@media (prefers-reduced-motion: reduce) {
  .is-pwa-chat .chat-sidebar,
  .chat-drawer-backdrop {
    transition: none;
  }
}

.is-pwa-chat .chat-transcript {
  gap: 22px;
  padding: 22px 0 8px;
}

.is-pwa-chat .chat-message,
.is-pwa-chat .chat-intro {
  width: min(720px, calc(100% - 28px));
}

.is-pwa-chat .chat-composer {
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.chat-layout {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  height: calc(100vh - 61px);
}

.chat-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 16px 12px;
}

.chat-new {
  gap: 8px;
  justify-content: flex-start;
  width: 100%;
}

.chat-history {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
}

.chat-history-group {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin: 16px 8px 4px;
  text-transform: uppercase;
}

.chat-history-row {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  min-height: 36px;
}

.chat-history-item {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: block;
  font-size: 14px;
  overflow: hidden;
  padding: 8px 4px 8px 10px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.chat-history-delete {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: inline-flex;
  height: 28px;
  justify-content: center;
  opacity: 0;
  padding: 0;
  width: 28px;
}

.chat-history-row:hover,
.chat-history-row:focus-within {
  background: var(--surface-muted);
  color: var(--text);
}

.chat-history-row:hover .chat-history-delete,
.chat-history-row:focus-within .chat-history-delete {
  opacity: 1;
}

.chat-history-delete:hover {
  color: var(--error-text);
}

.chat-history-row.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.chat-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.chat-transcript {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 28px;
  overflow-y: auto;
  padding: 30px 0 8px;
}

.chat-layout.is-empty .chat-transcript {
  align-items: center;
  justify-content: center;
}

.chat-message,
.chat-intro {
  margin: 0 auto;
  width: min(720px, 92%);
}

.chat-intro {
  color: var(--text-secondary);
  text-align: center;
}

.chat-intro h1 {
  font-size: 26px;
  margin-bottom: 8px;
}

.chat-message.is-user {
  display: flex;
  justify-content: flex-end;
}

.chat-bubble {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 16px;
  color: var(--text);
  max-width: 80%;
  padding: 10px 16px;
}

.chat-answer {
  line-height: 1.7;
}

.chat-answer.is-provisional {
  color: var(--text-secondary);
}

.chat-answer > :first-child {
  margin-top: 0;
}

.chat-answer h2 {
  font-size: 17px;
  margin: 22px 0 8px;
}

.chat-answer h3,
.chat-answer h4,
.chat-answer h5 {
  font-size: 15px;
  margin: 18px 0 6px;
}

.chat-answer p {
  margin: 0 0 12px;
}

.chat-answer .document-markdown-list {
  margin: 0 0 12px;
  padding-left: 24px;
}

.chat-answer code {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 1px 5px;
}

.chat-answer .document-blockquote {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent-border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
  margin: 0 0 12px;
  padding: 8px 14px;
}

.chat-answer .document-table-wrap {
  margin: 0 0 12px;
  overflow-x: auto;
}

.chat-answer .document-table {
  border-collapse: collapse;
  width: 100%;
}

.chat-answer .document-table th,
.chat-answer .document-table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}

.chat-refusal {
  color: var(--warn-text);
  font-size: 13px;
  margin: 8px 0 0;
}

.chat-citations {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chat-citation {
  align-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  display: inline-flex;
  font-size: 13px;
  gap: 6px;
  padding: 5px 12px;
}

.chat-citation:hover {
  border-color: var(--accent-border);
  color: var(--text);
  text-decoration: none;
}

.chat-citation-icon {
  color: var(--text-muted);
  display: inline-flex;
}

.chat-citation-type {
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chat-citation-ref {
  align-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  display: inline-flex;
  justify-content: center;
  margin: 0 2px;
  padding: 1px 4px;
  vertical-align: baseline;
}

.chat-citation-ref:hover {
  border-color: var(--accent-border);
  color: var(--text);
  text-decoration: none;
}

.chat-citation-ref-icon {
  display: inline-flex;
}

.chat-citation-ref-icon svg {
  height: 12px;
  width: 12px;
}

.chat-actions {
  display: flex;
  gap: 4px;
  margin-top: 10px;
}

.chat-thinking {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
}

.chat-run-progress {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 10px;
}

.chat-run-progress > .chat-activity-icon {
  margin-right: 8px;
}

.chat-activity-list {
  display: grid;
  gap: 3px;
  list-style: none;
  margin: 9px 0 0;
  padding: 0;
}

.chat-activity-list li::before {
  content: "○";
  display: inline-block;
  margin-right: 8px;
}

.chat-activity-list li.is-completed::before {
  color: var(--secondary-strong);
  content: "✓";
}

.chat-run-failure,
.chat-run-cancelled {
  color: var(--text-secondary);
  margin: 8px 0 0;
}

.chat-run-failure {
  color: var(--error-text);
}

.chat-thinking-label {
  font-size: 14px;
}

.chat-activity-icon {
  display: inline-flex;
  vertical-align: -3px;
}

.chat-activity-icon svg {
  display: block;
  height: 16px;
  width: 16px;
}

.pbs-glass {
  animation: pbs-sweep 1.9s cubic-bezier(.45, 0, .55, 1) infinite;
}

@keyframes pbs-sweep {
  0%,
  100% { transform: translate(0, 0); }
  50% { transform: translate(7.5px, 2px); }
}

.pbs-l {
  animation: pbs-blip 1.9s ease-in-out infinite;
}

.pbs-l2 { animation-delay: .24s; }
.pbs-l3 { animation-delay: .48s; }

@keyframes pbs-blip {
  0%,
  100% { opacity: .18; }
  45% { opacity: .7; }
}

.pbr-l {
  animation: pbr-wave 1.7s ease-in-out infinite;
}

.pbr-l2 { animation-delay: .19s; }
.pbr-l3 { animation-delay: .38s; }

@keyframes pbr-wave {
  0%,
  100% { opacity: .22; }
  35% { opacity: 1; }
}

.pbt-l {
  animation: pbt-gather 1.8s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.pbt-l2 { animation-delay: .2s; }
.pbt-l3 { animation-delay: .4s; }

.pbt-core {
  animation: pbt-pulse 1.8s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

@keyframes pbt-gather {
  0%,
  100% {
    opacity: .2;
    transform: scale(.78);
  }

  45% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pbt-pulse {
  0%,
  100% {
    opacity: .55;
    transform: scale(.82);
  }

  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pbs-glass,
  .pbs-l,
  .pbr-l,
  .pbt-l,
  .pbt-core { animation: none; }

  .pbs-l,
  .pbr-l,
  .pbt-l { opacity: .5; }
}

.source-viewer {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  inset: 0;
  min-height: 100dvh;
  position: fixed;
  z-index: 80;
}

.source-viewer[hidden] {
  display: none;
}

.source-viewer-header {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 12px max(14px, env(safe-area-inset-left));
}

.source-viewer-title {
  min-width: 0;
}

.source-viewer-title h2 {
  font-size: 17px;
  margin: 0;
}

.source-viewer-meta {
  color: var(--text-muted);
  font-size: 12px;
  margin: 2px 0 0;
}

.source-viewer-close {
  flex: 0 0 auto;
}

.source-viewer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px max(16px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.source-viewer-body .document-body,
.source-excerpt {
  margin: 0 auto;
  max-width: 760px;
}

.source-excerpt {
  background: var(--surface);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  padding: 14px 16px;
}

.source-excerpt p:last-child {
  margin-bottom: 0;
}

.offline-page {
  display: grid;
  min-height: 100dvh;
  padding: 24px;
  place-items: center;
}

.offline-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 460px;
  padding: 28px;
}

.offline-panel h1 {
  margin-top: 0;
}

.chat-action {
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
}

.chat-action:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.chat-action:disabled {
  cursor: default;
  opacity: 0.45;
}

.chat-action.is-done {
  color: var(--accent);
}

.chat-composer {
  padding: 12px 0 18px;
}

.chat-input-wrap {
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  gap: 8px;
  margin: 0 auto;
  padding: 6px 6px 6px 18px;
  width: min(720px, 92%);
}

.chat-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.chat-input {
  background: transparent;
  border: 0;
  box-shadow: none;
  flex: 1;
  /* 16px minimum: anything smaller makes iOS Safari auto-zoom on focus */
  font-size: 16px;
  line-height: 1.5;
  max-height: 200px;
  min-height: 0;
  outline: none;
  padding: 8px 0;
  resize: none;
}

.chat-input:hover,
.chat-input:focus {
  border: 0;
  box-shadow: none;
}

/* The wrap shows the focus ring; suppress the inner outline */
.chat-input:focus-visible {
  outline: none;
}

.chat-voice,
.chat-send {
  border-radius: 50%;
  flex: none;
  height: 34px;
  padding: 0;
  width: 34px;
}

.chat-voice {
  background: transparent;
  color: var(--text-muted);
}

.chat-voice:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.chat-voice.is-listening {
  background: var(--accent-soft);
  color: var(--accent);
}

.chat-footnote {
  color: var(--text-muted);
  font-size: 12px;
  margin: 10px 0 0;
  text-align: center;
}

@media (max-width: 820px) {
  .chat-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 61px);
  }

  .chat-sidebar {
    display: none;
  }
}

/* Document page */
/* Document pages break out of the centered container: the TOC rail sits at
   the far left, separated from the content by a border and its own surface. */
.app-shell:has(.doc-layout) .main-content {
  margin: 0;
  max-width: none;
  padding: 0 0 64px;
}

.doc-layout {
  align-items: stretch;
  display: grid;
  gap: 0;
  grid-template-columns: 260px minmax(0, 1fr);
  justify-content: start;
  min-height: calc(100vh - var(--app-header-height));
}

.document-column {
  min-width: 0;
  max-width: 820px;
  padding: 28px 40px 0;
  scroll-behavior: smooth;
}

.toc {
  align-self: start;
  background: var(--surface);
  border-right: 1px solid var(--border);
  color: var(--text-muted);
  height: calc(100vh - var(--app-header-height));
  overflow-y: auto;
  padding: 28px 20px 28px 24px;
  position: sticky;
  top: var(--app-header-height);
}

.toc-inner {
  position: static;
}

.toc-eyebrow {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0 0 10px;
}

.toc nav {
  display: grid;
  gap: 2px;
  position: relative;
}

.toc-position-indicator {
  background: var(--accent);
  border-radius: 999px;
  left: 0;
  min-height: 4px;
  pointer-events: none;
  position: absolute;
  top: 0;
  transition:
    transform 180ms ease,
    height 180ms ease;
  width: 2px;
}

.toc a {
  color: var(--text-muted);
  display: block;
  font-size: 13px;
  line-height: 1.35;
  padding: 5px 0 5px 10px;
}

.toc a:hover {
  color: var(--text);
  text-decoration: none;
}

.toc a.is-active {
  color: var(--text);
  font-weight: 600;
}

.toc a.toc-level-3 {
  padding-left: 22px;
}

.breadcrumbs {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 6px;
  margin: 0 0 12px;
}

.breadcrumbs a {
  color: var(--text-muted);
}

.breadcrumbs a:hover {
  color: var(--accent);
}

.document-title-row {
  align-items: start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.document-title-row h1 {
  margin-bottom: 0;
  min-width: 0;
}

.document-meta {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 6px 14px;
  margin: 10px 0 18px;
}

.document-meta span {
  border-right: 0;
  padding-right: 0;
}

.document-meta .content-type-badge {
  flex: 0 0 auto;
  margin: 0;
  padding-inline: 16px;
}

.document-meta-item,
.meta-separator {
  color: var(--text-muted);
}

.content-type-badge {
  align-items: center;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  box-sizing: border-box;
  color: var(--accent-strong);
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  justify-content: center;
  letter-spacing: 0;
  line-height: 1;
  margin: 4px 0 6px;
  min-height: 22px;
  padding: 0 16px;
  white-space: nowrap;
}

.document-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin: 0;
}

.document-actions a {
  font-size: 13px;
  padding: 6px 10px;
  white-space: nowrap;
}

.document-actions button {
  font-size: 13px;
  padding: 6px 10px;
  white-space: nowrap;
}

.document-actions .document-favorite-button {
  align-items: center;
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
  display: inline-flex;
  font-size: 19px;
  justify-content: center;
  line-height: 1;
  min-width: 36px;
  padding: 5px 8px;
}

.document-actions .document-favorite-button:hover,
.document-actions .document-favorite-button.is-favorite {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-strong);
}

.danger-action {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-text);
}

.danger-action .button-icon {
  color: currentColor;
}

.button-icon {
  color: var(--accent-strong);
  font-weight: 700;
  line-height: 1;
}

.doc-tabs {
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 18px;
  margin: 0 0 18px;
  overflow-x: auto;
}

.doc-tabs button {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--text-muted);
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: -1px;
  padding: 0 0 10px;
}

.doc-tabs button:hover {
  background: transparent;
  border-bottom-color: var(--accent-border);
  color: var(--text);
}

.doc-tabs button.is-active {
  border-bottom-color: var(--accent);
  color: var(--text);
}

.tab-chip {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  min-width: 20px;
  padding: 3px 6px;
  text-align: center;
}

.doc-tab-panels {
  min-width: 0;
}

.tab-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.tab-row {
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
  padding: 13px 16px;
}

.tab-row:last-child {
  border-bottom: 0;
}

.suggestion-row {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.suggestion-row > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.suggestion-row strong {
  color: var(--text);
}

.document-content {
  line-height: 1.7;
  padding: 4px 0 0;
}

.document-content h2,
.document-content h3,
.document-content h4 {
  border-bottom: 1px solid var(--border);
  margin: 26px 0 10px;
  padding-bottom: 6px;
  scroll-margin-top: var(--document-anchor-offset);
}

.document-content h2:first-child,
.document-content h3:first-child,
.document-content h4:first-child {
  margin-top: 0;
}

.document-content p {
  margin: 0 0 14px;
}

.document-image {
  display: block;
  height: auto;
  margin: 16px 0;
  max-width: 100%;
}

.document-markdown-list {
  margin: 0 0 14px;
  padding-left: 26px;
}

.document-content hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.document-content code {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 1px 5px;
}

.document-code-block {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 0 0 16px;
  overflow-x: auto;
  padding: 12px 14px;
}

.document-code-block code {
  background: transparent;
  border: 0;
  border-radius: 0;
  display: block;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  padding: 0;
  white-space: pre;
}

.document-blockquote {
  border-left: 3px solid var(--accent-border);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
  margin: 0 0 14px;
  padding: 10px 16px;
}

.document-blockquote p {
  margin: 0 0 6px;
}

.document-blockquote p:last-child {
  margin-bottom: 0;
}

.document-table-wrap {
  margin: 0 0 16px;
  overflow-x: auto;
}

.document-table {
  border-collapse: collapse;
  width: 100%;
}

.document-table th,
.document-table td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}

.document-table th {
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 650;
}

/* Document authoring */
.document-editor-form {
  margin: 0;
}

.document-editor-sidebar-inner {
  display: grid;
  gap: 12px;
}

.document-editor-sidebar label,
.document-title-field,
.document-body-field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.document-editor-sidebar label > span,
.document-title-field > span,
.document-body-field > span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.document-editor-sidebar input,
.document-editor-sidebar select,
.document-editor-sidebar textarea {
  max-width: 100%;
  min-width: 0;
  width: 100%;
}

.document-editor-sidebar textarea {
  min-height: 100px;
}

.document-editor-sidebar .checkbox-field {
  align-items: center;
  display: flex;
  gap: 8px;
}

.document-editor-sidebar .checkbox-field input {
  flex: 0 0 auto;
  width: 15px;
}

.document-editor-sidebar .checkbox-field span {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

.document-editor-title-row {
  align-items: end;
  margin-bottom: 0;
}

.document-title-field {
  flex: 1 1 auto;
}

.document-title-field input {
  background: transparent;
  border-color: transparent transparent var(--border-strong);
  border-radius: 0;
  box-shadow: none;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
  min-width: 0;
  padding: 2px 0 7px;
  width: 100%;
}

.document-title-field input:hover,
.document-title-field input:focus {
  background: transparent;
  border-color: transparent transparent var(--accent);
  box-shadow: none;
}

.document-body-field {
  margin-top: 14px;
}

.document-body-field textarea {
  min-height: 420px;
}

.document-body-field .playbook-editor {
  margin-top: 3px;
  /* A scrolling ancestor prevents the toolbar from sticking to the viewport. */
  overflow: visible;
}

.document-body-field .editor-modebar {
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
}

.document-body-field .editor-toolbar {
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: var(--app-header-height);
  z-index: 10;
}

.document-body-field .editor-surface,
.document-body-field .editor-surface .ProseMirror {
  min-height: 420px;
}

/* Generic action rows */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Login */
.auth-panel {
  display: grid;
  gap: 16px;
  padding: 36px;
}

.auth-panel h1 {
  letter-spacing: 0;
  line-height: 1.16;
  margin: 0;
}

.auth-panel .lede {
  margin: 0;
  max-width: 620px;
}

.auth-primary-actions {
  margin-top: 8px;
}

.auth-footer-actions {
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 18px;
}

.auth-footer-actions button {
  color: var(--text-secondary);
}

.login-form {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

.login-form label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.login-form input,
.login-form select {
  max-width: 100%;
  min-width: 0;
  width: 100%;
}

.tenant-picker {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.auth-primary-actions[hidden],
.tenant-picker[hidden],
.auth-footer-actions[hidden] {
  display: none;
}

.tenant-option {
  align-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 3px;
  justify-items: start;
  padding: 14px 16px;
  text-align: left;
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
  width: 100%;
}

.tenant-option:hover {
  background: var(--surface);
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tenant-option-label {
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
}

.tenant-option-meta {
  color: var(--text-muted);
  font-size: 13px;
}

/* Notices and findings */
.notice {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  color: var(--warn-text);
  line-height: 1.5;
  margin: 16px auto;
  max-width: 960px;
  padding: 10px 14px;
}

.notice.is-error {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-text);
}

.notice[hidden] {
  display: none;
}

.suggestion-conflict-action {
  margin-left: 0.5rem;
}

.validation-findings {
  margin-left: 0;
  margin-right: 0;
}

.validation-findings h3 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.03em;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.validation-findings ul {
  margin: 0;
  padding-left: 20px;
}

.validation-finding {
  margin: 4px 0;
}

/* Admin lists */
.users-admin-main,
.suggestions-admin-main {
  max-width: 1440px;
}

.users-page-header {
  align-items: flex-end;
  display: flex;
  gap: 24px;
  justify-content: space-between;
}

.users-page-header .lede {
  margin-bottom: 0;
}

.users-page-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.users-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-top: 24px;
  overflow-x: auto;
}

.users-table {
  border-collapse: collapse;
  min-width: 1120px;
  width: 100%;
}

.users-table th,
.users-table td {
  border-bottom: 1px solid var(--border);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
}

.users-table th {
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.users-table th:first-child,
.users-table td:first-child {
  min-width: 220px;
  padding-left: 16px;
}

.users-table th:last-child,
.users-table td:last-child {
  min-width: 210px;
  padding-right: 16px;
}

.users-table th[data-permission],
.users-table .permission-cell {
  min-width: 76px;
  text-align: center;
}

.users-table tbody tr:last-child td {
  border-bottom: 0;
}

.users-table tbody tr:hover {
  background: color-mix(in srgb, var(--surface-muted) 65%, transparent);
}

.users-table tr.is-muted {
  color: var(--text-muted);
  opacity: 0.72;
}

.users-table-identity {
  align-items: center;
  display: flex;
  gap: 9px;
  min-width: 0;
}

.user-status {
  border: 1px solid var(--border);
  border-radius: 999px;
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 3px 8px;
  text-transform: capitalize;
}

.user-status-active {
  background: #dcfce7;
  border-color: #bbf7d0;
  color: #166534;
}

.user-status-invited {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-text);
}

.user-status-disabled {
  background: var(--surface-muted);
  color: var(--text-muted);
}

.permission-granted {
  color: var(--accent-strong);
  font-size: 16px;
  font-weight: 800;
}

.permission-not-granted {
  color: var(--border-strong);
}

.users-table-actions {
  display: flex;
  gap: 5px;
  justify-content: flex-end;
  white-space: nowrap;
}

.users-table-actions button {
  font-size: 12px;
  padding: 5px 9px;
}

.users-table-wrap > .empty-note {
  padding: 24px;
  text-align: center;
}

.access-rollout-panel {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  display: grid;
  gap: 8px;
  margin-top: 24px;
  padding: 18px 20px;
}

.access-rollout-panel[hidden],
.access-admin-tabs[hidden],
.access-admin-tab[hidden],
.access-admin-panel[hidden],
.access-group-form[hidden] {
  display: none;
}

.access-rollout-panel .muted {
  margin: 0;
}

.access-rollout-actions {
  margin-top: 4px;
}

.access-admin-tabs {
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 6px;
  margin-top: 28px;
}

.access-admin-tab {
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  color: var(--text-secondary);
  font-weight: 650;
  margin-bottom: -1px;
  padding: 11px 16px;
}

.access-admin-tab:hover {
  background: var(--surface-muted);
  border-color: transparent;
  color: var(--text);
}

.access-admin-tab[aria-selected="true"],
.access-admin-tab[aria-selected="true"]:hover {
  background: transparent;
  border-bottom-color: var(--accent);
  color: var(--accent-strong);
}

.access-admin-tab:focus-visible {
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.access-admin-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-top: 18px;
  padding: 24px;
}

.access-admin-panel > .users-page-header {
  align-items: start;
}

.access-admin-panel > .users-page-header .muted {
  margin-bottom: 0;
}

.access-policy-mode {
  display: grid;
  gap: 5px;
  margin-top: 22px;
  max-width: 280px;
}

.access-policy-mode > span,
.access-explain-controls label > span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.access-explain-controls {
  align-items: end;
  margin-top: 14px;
}

.access-explain-controls label {
  display: grid;
  gap: 5px;
}

.access-group-form {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 20px;
  padding: 18px;
}

.access-group-form-fields {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
}

.access-group-form-fields label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.access-group-form-fields input,
.access-group-form-fields select {
  max-width: none;
  min-width: 0;
  width: 100%;
}

.access-group-members {
  grid-column: 1 / -1;
}

.access-group-members select {
  min-height: 150px;
}

.access-group-form .field-hint {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
}

.access-group-form > .actions {
  justify-content: flex-end;
  width: 100%;
}

.access-group-list {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.access-group-card {
  align-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: grid;
  gap: 4px 16px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 14px 16px;
}

.access-group-card .muted {
  margin: 0;
}

.access-group-card-actions {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.access-group-list > .empty-note {
  background: var(--surface-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
}

.access-rollout-actions[hidden] {
  display: none;
}

.access-rollout-actions > [hidden] {
  display: none;
}

.access-policy-table-wrap {
  overflow-x: hidden;
}

.access-policy-table {
  min-width: 0;
  table-layout: fixed;
}

.access-policy-table th:first-child,
.access-policy-table td:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
  width: 40%;
}

.access-policy-table th:last-child,
.access-policy-table td:last-child {
  min-width: 0;
}

.access-policy-table th:not(:first-child),
.access-policy-table td:not(:first-child) {
  text-align: center;
}

.access-policy-table th:not(:first-child) {
  white-space: normal;
}

@media (max-width: 720px) {
  .access-admin-panel {
    padding: 18px;
  }

  .access-admin-tab {
    flex: 1 1 0;
    padding-left: 8px;
    padding-right: 8px;
  }

  .access-group-form-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .access-group-members {
    grid-column: auto;
  }

  .access-group-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .access-group-card-actions {
    grid-column: 1;
    grid-row: auto;
    margin-top: 8px;
  }
}

.admin-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.admin-row {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  padding: 12px 16px;
  position: relative;
}

.admin-row.is-dragging,
.taxonomy-tree-row.is-dragging {
  opacity: 0.55;
}

.admin-row.is-drop-before::before,
.admin-row.is-drop-after::after,
.taxonomy-tree-row.is-drop-before::before,
.taxonomy-tree-row.is-drop-after::after {
  background: var(--accent);
  border-radius: 999px;
  content: "";
  height: 3px;
  left: 12px;
  position: absolute;
  right: 12px;
}

.admin-row.is-drop-before::before {
  top: -7px;
}

.admin-row.is-drop-after::after,
.taxonomy-tree-row.is-drop-after::after {
  bottom: -7px;
}

.taxonomy-tree-row.is-drop-before::before {
  top: -2px;
}

.admin-drag-handle {
  align-items: center;
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  cursor: grab;
  display: inline-flex;
  flex: 0 0 auto;
  height: 30px;
  justify-content: center;
  padding: 0;
  touch-action: none;
  user-select: none;
  width: 30px;
}

.admin-drag-handle::before {
  background-image: radial-gradient(circle, currentColor 1.4px, transparent 1.5px);
  background-size: 6px 6px;
  content: "";
  height: 18px;
  opacity: 0.7;
  width: 14px;
}

.admin-drag-handle:hover,
.admin-drag-handle:focus-visible {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--text-secondary);
}

.admin-drag-handle:active {
  cursor: grabbing;
}

.admin-drag-handle-spacer {
  flex: 0 0 30px;
  width: 30px;
}

.admin-row-info {
  display: grid;
  flex: 1 1 220px;
  gap: 2px;
  min-width: 0;
}

.admin-row-label {
  font-weight: 600;
}

.admin-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.admin-row-actions button {
  font-size: 13px;
  padding: 5px 11px;
}

.admin-detail {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 4px 0 4px 20px;
  padding: 14px 16px;
  width: 100%;
}

.taxonomy-tree-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 12px;
}

.taxonomy-tree-toolbar .primary-action {
  margin-left: auto;
}

.taxonomy-create-panel {
  background: var(--surface);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  padding: 16px;
}

.taxonomy-create-panel h2 {
  font-size: 16px;
  margin: 0;
}

.taxonomy-tree {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-top: 12px;
  min-height: 72px;
  padding: 6px 0;
}

.taxonomy-tree-node {
  position: relative;
}

.taxonomy-tree-row {
  align-items: center;
  display: flex;
  gap: 7px;
  min-height: 46px;
  padding: 6px 10px;
  position: relative;
}

.taxonomy-tree-row:hover,
.taxonomy-tree-row:focus-within {
  background: var(--surface-muted);
}

.taxonomy-tree-center-row {
  font-weight: 650;
}

.taxonomy-tree-section-row {
  min-height: 43px;
}

.taxonomy-tree-document-row {
  min-height: 40px;
}

.taxonomy-tree-row.is-document-drop-target {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.taxonomy-tree-children {
  margin-left: 24px;
  padding-left: 18px;
  position: relative;
}

.taxonomy-tree-children::before {
  background: var(--border);
  bottom: 6px;
  content: "";
  left: 7px;
  position: absolute;
  top: 0;
  width: 1px;
}

.taxonomy-tree-toggle,
.taxonomy-tree-toggle-spacer {
  align-items: center;
  display: inline-flex;
  flex: 0 0 26px;
  height: 26px;
  justify-content: center;
  width: 26px;
}

.taxonomy-tree-toggle {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  padding: 0;
}

.taxonomy-tree-toggle:hover {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-strong);
}

.taxonomy-node-icon {
  display: inline-block;
  flex: 0 0 18px;
  height: 16px;
  position: relative;
  width: 18px;
}

.taxonomy-node-icon.is-center,
.taxonomy-node-icon.is-section {
  background: var(--accent-soft);
  border: 1.5px solid var(--accent);
  border-radius: 3px;
  height: 13px;
  margin-top: 3px;
}

.taxonomy-node-icon.is-center::before,
.taxonomy-node-icon.is-section::before {
  background: var(--accent-soft);
  border: 1.5px solid var(--accent);
  border-bottom: 0;
  border-radius: 3px 3px 0 0;
  content: "";
  height: 4px;
  left: 1px;
  position: absolute;
  top: -5px;
  width: 8px;
}

.taxonomy-node-icon.is-section {
  background: var(--surface);
  border-color: var(--text-muted);
}

.taxonomy-node-icon.is-section::before {
  background: var(--surface);
  border-color: var(--text-muted);
}

.taxonomy-node-icon.is-document {
  border: 1.5px solid var(--text-muted);
  border-radius: 2px;
  height: 17px;
  width: 14px;
}

.taxonomy-node-icon.is-document::after {
  border-bottom: 1.5px solid var(--text-muted);
  content: "";
  left: 3px;
  position: absolute;
  right: 3px;
  top: 5px;
}

.taxonomy-node-label {
  flex: 1 1 220px;
  font-weight: 600;
  min-width: 80px;
  overflow-wrap: anywhere;
  text-align: left;
}

.taxonomy-node-label-button {
  background: transparent;
  border: 0;
  color: var(--text);
  justify-content: flex-start;
  padding: 4px 2px;
}

.taxonomy-node-label-button:hover {
  background: transparent;
  color: var(--accent-strong);
}

.taxonomy-node-meta,
.taxonomy-node-count {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.taxonomy-node-meta {
  text-transform: capitalize;
}

.taxonomy-status-badge {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 650;
  line-height: 1;
  padding: 4px 7px;
  text-transform: capitalize;
  white-space: nowrap;
}

.taxonomy-status-badge.is-hidden {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-text);
}

.taxonomy-status-badge.is-menu {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-strong);
}

.taxonomy-access-badge {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  display: inline-flex;
  font-size: 11px;
  font-weight: 650;
  line-height: 1;
  padding: 4px 8px;
  white-space: nowrap;
}

.taxonomy-access-badge::before {
  content: "●";
  font-size: 7px;
  margin-right: 5px;
}

.taxonomy-access-badge.is-inherited {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--text-muted);
}

.taxonomy-access-badge.is-custom {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-strong);
}

.taxonomy-access-badge.is-admins-only {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-text);
}

.taxonomy-access-button {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
  flex: 0 0 auto;
  font-size: 12px;
  min-height: 30px;
  padding: 5px 9px;
}

.taxonomy-access-button:hover {
  border-color: var(--accent-border);
  color: var(--accent-strong);
}

.taxonomy-node-menu {
  flex: 0 0 auto;
  position: relative;
}

.taxonomy-node-menu > summary {
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  font-weight: 800;
  height: 30px;
  justify-content: center;
  list-style: none;
  width: 34px;
}

.taxonomy-node-menu > summary::-webkit-details-marker {
  display: none;
}

.taxonomy-node-menu > summary:hover,
.taxonomy-node-menu[open] > summary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.taxonomy-node-menu-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: 2px;
  min-width: 220px;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
}

.taxonomy-node-menu-content :is(button, a) {
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text);
  display: block;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 9px;
  text-align: left;
  text-decoration: none;
  width: 100%;
}

.taxonomy-node-menu-content :is(button, a):hover {
  background: var(--surface-muted);
  color: var(--accent-strong);
}

.taxonomy-node-menu-content button.is-danger {
  color: var(--error-text);
}

.taxonomy-tree-inline-detail {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 2px 12px 8px 85px;
  padding: 14px;
}

.taxonomy-tree-inline-detail.is-create {
  margin-left: 42px;
}

.taxonomy-inline-form {
  margin-top: 0;
}

.taxonomy-move-form {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.taxonomy-move-form label {
  display: grid;
  flex: 1 1 260px;
  gap: 4px;
}

.taxonomy-move-form label > span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.taxonomy-tree-empty {
  margin: 0;
  padding: 12px 14px;
}

@media (max-width: 720px) {
  .taxonomy-tree-toolbar .primary-action {
    margin-left: 0;
  }

  .taxonomy-tree-row {
    gap: 4px;
    padding-left: 5px;
    padding-right: 5px;
  }

  .taxonomy-tree-children {
    margin-left: 11px;
    padding-left: 11px;
  }

  .taxonomy-node-count,
  .taxonomy-node-meta,
  .taxonomy-status-badge.is-menu {
    display: none;
  }

  .taxonomy-tree-inline-detail {
    margin-left: 20px;
  }
}

.admin-form {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
}

.admin-form label {
  display: grid;
  gap: 4px;
}

.admin-form label > span,
.admin-form-stacked label > span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.admin-form-stacked {
  align-items: stretch;
  flex-direction: column;
}

.notification-settings-form .checkbox-label {
  align-items: center;
  display: flex;
  gap: 8px;
}

.notification-settings-form .checkbox-label > span {
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

.notification-settings-form .form-help {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0;
}

.feedback-layout {
  margin: 24px auto;
  max-width: 760px;
  width: 100%;
}

.feedback-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
  transform: none;
}

.feedback-form textarea {
  min-height: 140px;
}

.feedback-form .checkbox-label {
  align-items: center;
  display: flex;
  gap: 8px;
}

.feedback-form .checkbox-label > span {
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

.feedback-form button[type="submit"] {
  align-self: flex-start;
}

.feedback-dialog {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  height: min(760px, calc(100vh - 32px));
  max-height: calc(100vh - 32px);
  max-width: calc(100vw - 32px);
  overflow: hidden;
  padding: 0;
  transform: translateY(0) scale(1);
  transition: opacity 180ms ease, transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
  width: min(760px, calc(100vw - 32px));
}

.feedback-dialog::backdrop {
  background: rgb(15 23 42 / 58%);
  transition: background 180ms ease;
}

.feedback-dialog.is-closing {
  opacity: 0;
  transform: translateY(10px) scale(0.98);
}

.feedback-dialog.is-closing::backdrop {
  background: rgb(15 23 42 / 0%);
}

.feedback-dialog-header {
  align-items: center;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
}

.feedback-dialog-title {
  font-size: 18px;
  margin: 0;
}

.feedback-dialog-close {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 10px;
}

.feedback-dialog-frame {
  border: 0;
  display: block;
  height: calc(100% - 54px);
  width: 100%;
}

.feedback-submission-status {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  color: var(--text);
  display: flex;
  font-size: 14px;
  font-weight: 650;
  gap: 10px;
  left: 50%;
  min-height: 44px;
  padding: 9px 16px;
  position: fixed;
  top: 50%;
  transform: translate(-50%, -50%);
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 1200;
}

.feedback-submission-status[hidden] {
  display: none;
}

.feedback-submission-status-icon {
  align-items: center;
  border-radius: 50%;
  display: inline-flex;
  flex: 0 0 22px;
  height: 22px;
  justify-content: center;
  width: 22px;
}

.feedback-submission-status.is-loading .feedback-submission-status-icon {
  animation: feedback-status-spin 700ms linear infinite;
  border: 2px solid var(--accent-border);
  border-top-color: var(--accent-strong);
}

.feedback-submission-status.is-success .feedback-submission-status-icon {
  animation: feedback-status-success 320ms cubic-bezier(0.2, 0.9, 0.3, 1.35);
  background: var(--secondary);
  color: #10210a;
  font-size: 15px;
  font-weight: 800;
}

.feedback-submission-status.is-leaving {
  opacity: 0;
  transform: translate(-50%, calc(-50% + 8px)) scale(0.98);
}

@keyframes feedback-status-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes feedback-status-success {
  from {
    opacity: 0;
    transform: scale(0.55);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .feedback-dialog,
  .feedback-dialog::backdrop,
  .feedback-submission-status,
  .feedback-submission-status-icon {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}

.feedback-embedded-body,
.feedback-embedded-shell {
  background: var(--surface);
  min-height: 100%;
}

.feedback-embedded-layout {
  margin: 0;
  max-width: none;
  padding: 20px;
}

.feedback-embedded-layout .feedback-card {
  border: 0;
  box-shadow: none;
  padding: 0;
}

/* Markdown-serializing editor */
.playbook-editor {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  display: grid;
  gap: 0;
  overflow: hidden;
}

.playbook-editor [hidden],
.editor-dialog [hidden] {
  display: none !important;
}

.editor-modebar,
.editor-toolbar {
  align-items: center;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
}

.editor-modebar {
  justify-content: flex-end;
}

.editor-toolbar-group {
  align-items: center;
  border-right: 1px solid var(--border);
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-right: 6px;
}

.editor-toolbar-group:last-child {
  border-right: 0;
  padding-right: 0;
}

.editor-toolbar-button,
.editor-dialog-tabs button {
  font-size: 13px;
  min-height: 32px;
  padding: 5px 9px;
}

.editor-toolbar-button.is-active,
.editor-dialog-tabs button.is-active,
.editor-modebar button.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-strong);
}

.editor-block-select {
  display: inline-flex;
}

.editor-block-select select {
  font-size: 13px;
  min-height: 32px;
  padding: 5px 30px 5px 9px;
}

.editor-surface {
  min-height: 300px;
}

.editor-surface .ProseMirror {
  min-height: 300px;
  outline: none;
  padding: 16px;
}

.editor-surface .ProseMirror > *:first-child {
  margin-top: 0;
}

.editor-surface .ProseMirror > *:last-child {
  margin-bottom: 0;
}

.editor-surface .ProseMirror h2,
.editor-surface .ProseMirror h3,
.editor-surface .ProseMirror h4 {
  line-height: 1.25;
  margin: 20px 0 8px;
}

.editor-surface .ProseMirror h2 {
  font-size: 24px;
}

.editor-surface .ProseMirror h3 {
  font-size: 20px;
}

.editor-surface .ProseMirror h4 {
  font-size: 17px;
}

.editor-surface .ProseMirror p {
  margin: 0 0 12px;
}

.editor-surface .ProseMirror img {
  display: block;
  height: auto;
  margin: 14px 0;
  max-width: 100%;
}

.editor-surface .ProseMirror ul,
.editor-surface .ProseMirror ol {
  margin: 0 0 12px;
  padding-left: 24px;
}

.editor-surface .ProseMirror blockquote {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent-border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
  margin: 0 0 12px;
  padding: 10px 14px;
}

.editor-surface .ProseMirror code {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 1px 5px;
}

.editor-surface .ProseMirror pre {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 0 0 14px;
  overflow-x: auto;
  padding: 12px 14px;
}

.editor-surface .ProseMirror pre code {
  background: transparent;
  border: 0;
  display: block;
  padding: 0;
  white-space: pre;
}

.editor-surface .ProseMirror table {
  border-collapse: collapse;
  margin: 0 0 14px;
  width: 100%;
}

.editor-surface .ProseMirror th,
.editor-surface .ProseMirror td {
  border: 1px solid var(--border);
  min-width: 80px;
  padding: 8px 10px;
  vertical-align: top;
}

.editor-surface .ProseMirror th {
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-weight: 650;
}

.editor-lossy-notice,
.editor-upload-notice {
  align-items: center;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  display: flex;
  justify-content: space-between;
  margin: 0;
  max-width: none;
}

.editor-dialog-backdrop {
  align-items: center;
  background: rgb(15 23 42 / 45%);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: fixed;
  z-index: 100;
}

.editor-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: 12px;
  max-width: 520px;
  padding: 18px;
  width: min(520px, 100%);
}

.editor-dialog h2 {
  font-size: 18px;
  margin: 0;
}

.editor-dialog label {
  display: grid;
  gap: 4px;
}

.editor-dialog label > span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.editor-dialog-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.editor-dialog-notice {
  color: var(--error-text);
  margin: 0;
}

.editor-document-results {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: grid;
  gap: 0;
  max-height: 220px;
  overflow: auto;
}

.editor-document-result {
  align-items: start;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  display: grid;
  justify-items: start;
  padding: 9px 10px;
  text-align: left;
}

.editor-document-result:last-child {
  border-bottom: 0;
}

.editor-document-result-title {
  font-weight: 600;
}

.editor-document-result-path {
  color: var(--text-muted);
  font-size: 12px;
}

.color-field {
  max-width: 360px;
}

.color-control {
  align-items: center;
  display: flex;
  gap: 10px;
}

.color-control input[type="color"] {
  height: 40px;
  padding: 3px;
  width: 48px;
}

.logo-preview {
  align-items: flex-start;
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.logo-preview img {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 72px;
  max-width: 240px;
  object-fit: contain;
  padding: 8px;
}

.permission-set {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.permission-set legend {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0 6px;
  text-transform: uppercase;
}

.permission-option {
  align-items: center;
  display: flex;
  gap: 7px;
  margin: 6px 0;
}

.permission-grid {
  display: grid;
  gap: 4px 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.permission-grid legend {
  grid-column: 1 / -1;
}

/* Suggestion review */
html.has-modal {
  overflow: hidden;
}

.suggestion-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-top: 20px;
  overflow: hidden;
}

.suggestion-toolbar {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
}

.suggestion-status-filters {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  display: inline-flex;
  flex: 0 0 auto;
  gap: 2px;
  padding: 3px;
}

.suggestion-status-filter {
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 14px;
}

.suggestion-status-filter:hover {
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  border: 0;
  color: var(--text);
}

.suggestion-status-filter.is-active,
.suggestion-status-filter.is-active:hover {
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--accent-strong);
}

.suggestion-facets {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.suggestion-filter {
  display: grid;
}

.suggestion-filter > span {
  block-size: 1px;
  clip-path: inset(50%);
  inline-size: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
}

.suggestion-filter select {
  font-size: 13px;
  min-width: 130px;
  padding-bottom: 6px;
  padding-top: 6px;
}

.suggestion-clear-filters {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
  font-size: 13px;
}

.suggestion-table-region .empty-note {
  margin: 0;
  padding: 32px 16px;
  text-align: center;
}

.suggestion-filter-summary {
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  margin: 0;
  padding: 8px 16px;
}

.suggestions-table-wrap {
  overflow-x: auto;
}

.suggestions-table {
  border-collapse: collapse;
  min-width: 1080px;
  width: 100%;
}

.suggestions-table th,
.suggestions-table td {
  border-bottom: 1px solid var(--border);
  padding: 11px 12px;
  text-align: left;
  vertical-align: middle;
}

.suggestions-table th {
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.suggestions-table tbody tr:last-child td {
  border-bottom: 0;
}

.suggestions-table tbody tr:hover {
  background: color-mix(in srgb, var(--surface-muted) 68%, transparent);
}

.suggestion-sort-button {
  align-items: center;
  background: transparent;
  border: 0;
  color: inherit;
  display: inline-flex;
  font: inherit;
  gap: 6px;
  letter-spacing: inherit;
  padding: 2px 0;
  text-transform: inherit;
}

.suggestion-sort-button:hover {
  background: transparent;
  border: 0;
  color: var(--text);
}

.suggestion-sort-indicator {
  color: var(--accent-strong);
  font-size: 12px;
}

.suggestion-selection-column {
  padding-left: 16px !important;
  padding-right: 4px !important;
  width: 58px;
}

.suggestion-action-column {
  width: 92px;
}

.suggestion-review-button {
  font-size: 13px;
  padding: 5px 12px;
}

.suggestion-bulk-controls {
  align-items: center;
  display: flex;
  gap: 2px;
}

.suggestion-bulk-menu {
  position: relative;
}

.suggestion-bulk-toggle {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 1;
  padding: 4px 5px;
}

.suggestion-bulk-toggle:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.suggestion-bulk-popup {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: 2px;
  left: 0;
  letter-spacing: normal;
  min-width: 200px;
  padding: 6px;
  position: absolute;
  text-transform: none;
  top: calc(100% + 6px);
  z-index: 60;
}

.suggestion-bulk-popup[hidden] {
  display: none;
}

.suggestion-bulk-item {
  background: transparent;
  border-color: transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  justify-content: flex-start;
  padding: 7px 10px;
  text-align: left;
  width: 100%;
}

.suggestion-bulk-item:hover:not(:disabled) {
  background: var(--surface-muted);
  color: var(--text);
}

.suggestion-table-title,
.suggestion-table-submitter {
  display: block;
}

.suggestion-table-title {
  min-width: 180px;
}

.suggestion-table-submitter {
  margin-bottom: 4px;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-table-placement {
  display: block;
  max-width: 240px;
}

.suggestion-type-badge,
.suggestion-status-badge {
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  display: inline-block;
  font-size: 11px;
  font-weight: 650;
  padding: 3px 8px;
  white-space: nowrap;
}

.suggestion-type-new_document {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-strong);
}

.suggestion-type-delete_document,
.suggestion-status-badge.is-rejected {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-text);
}

.suggestion-status-badge {
  text-transform: capitalize;
}

.suggestion-status-badge.is-approved {
  background: color-mix(in srgb, var(--secondary) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--secondary) 45%, var(--border));
  color: var(--text);
}

.suggestion-status-badge.is-pending {
  background: var(--surface-muted);
  color: var(--text-secondary);
}

.suggestion-review-dialog {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  height: min(900px, calc(100dvh - 40px));
  max-height: calc(100dvh - 40px);
  max-width: none;
  opacity: 0;
  overflow: hidden;
  padding: 0;
  transform: translateY(18px) scale(0.94);
  transition: opacity 180ms ease, transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
  width: min(1180px, calc(100vw - 40px));
}

.suggestion-review-dialog[open] {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.suggestion-review-dialog::backdrop {
  backdrop-filter: blur(1px);
  background: rgb(15 23 42 / 0%);
  transition: background 180ms ease;
}

.suggestion-review-dialog.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.suggestion-review-dialog.is-open::backdrop {
  background: rgb(15 23 42 / 42%);
}

.suggestion-review-dialog.is-closing {
  opacity: 0;
  transform: translateY(10px) scale(0.97);
}

.suggestion-review-dialog.is-closing::backdrop {
  background: rgb(15 23 42 / 0%);
}

.suggestion-review-dialog-header {
  align-items: flex-start;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 18px 22px;
}

.suggestion-review-dialog-header .eyebrow,
.suggestion-review-dialog-header .muted {
  margin: 0;
}

.suggestion-review-dialog-title {
  font-size: 22px;
  margin: 2px 0 5px;
}

.suggestion-review-dialog-close {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
  flex: 0 0 auto;
  font-size: 24px;
  height: 36px;
  line-height: 1;
  padding: 0;
  width: 36px;
}

.suggestion-review-dialog-status {
  border-radius: 0;
  border-width: 0 0 1px;
  margin: 0;
}

.suggestion-review-dialog-body {
  min-height: 0;
  overflow: auto;
  padding: 22px 24px 24px;
}

.suggestion-review-dialog .admin-detail {
  background: transparent;
  border: 0;
  margin: 0;
  padding: 0;
}

.suggestion-review-loading,
.suggestion-review-load-error {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: center;
  min-height: 360px;
  text-align: center;
}

.suggestion-review-loading-spinner {
  border-width: 3px;
  color: var(--accent-strong);
  height: 28px;
  width: 28px;
}

.suggestion-review-actions {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-top: 1px solid var(--border);
  bottom: -24px;
  margin: 20px -24px -24px;
  padding: 14px 24px;
  position: sticky;
  z-index: 2;
}

.suggestion-review-back {
  margin-right: auto;
}

@media (max-width: 760px) {
  .suggestion-facets {
    align-items: stretch;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-left: 0;
    width: 100%;
  }

  .suggestion-filter select {
    min-width: 0;
    width: 100%;
  }

  .suggestion-review-dialog {
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
    width: calc(100vw - 16px);
  }

  .suggestion-review-dialog-header,
  .suggestion-review-dialog-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .suggestion-review-dialog .suggestion-review-fields {
    grid-template-columns: 1fr;
  }

  .suggestion-review-dialog .suggestion-review-editor {
    height: 440px;
  }

  .suggestion-review-actions {
    bottom: -24px;
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
  }
}

.suggestion-meta {
  display: grid;
  gap: 4px;
  margin: 0 0 14px;
}

.suggestion-meta-line {
  align-items: center;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 6px;
}

.suggestion-channel-chip {
  background: var(--surface-muted);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text-secondary);
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
}

.suggestion-pagination {
  align-items: center;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  padding: 10px 16px;
}

.suggestion-pagination .muted {
  font-size: 13px;
  margin-right: auto;
}

.suggestion-pagination button {
  font-size: 13px;
  padding: 5px 12px;
}

.suggestion-review-form {
  display: grid;
  gap: 14px;
  margin: 14px 0;
}

.suggestion-review-fields {
  align-items: start;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.suggestion-review-fields label {
  display: grid;
  gap: 4px;
}

.suggestion-review-fields label > span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.suggestion-review-fields textarea {
  min-height: 64px;
  resize: vertical;
}

.suggestion-review-fields .checkbox-label {
  align-items: center;
  align-self: end;
  display: inline-flex;
  gap: 8px;
  min-height: 38px;
}

.suggestion-review-editor-heading {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 0;
  text-transform: uppercase;
}

.suggestion-review-view-heading {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.suggestion-review-view-toggle {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  display: inline-flex;
  flex: 0 0 auto;
  gap: 2px;
  padding: 3px;
}

.suggestion-review-view-button {
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 14px;
}

.suggestion-review-view-button:hover {
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  border: 0;
  color: var(--text);
}

.suggestion-review-view-button.is-active,
.suggestion-review-view-button.is-active:hover {
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--accent-strong);
}

.suggestion-review-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 520px;
  min-height: 360px;
  overflow: hidden;
}

.suggestion-review-editor[hidden],
.suggestion-review-preview[hidden] {
  display: none;
}

.suggestion-review-preview {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 520px;
  min-height: 360px;
  overflow: auto;
  padding: 24px;
}

.suggestion-review-preview-document {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin: 0 auto;
  max-width: 850px;
  min-height: 100%;
  padding: 36px 42px;
}

.suggestion-review-preview-document .document-title-row h1 {
  margin-top: 0;
}

.suggestion-review-preview-document .document-meta {
  margin-bottom: 22px;
}

.suggestion-review-editor .diff-columns {
  height: 100%;
  margin: 0;
}

.suggestion-review-editor textarea {
  background: var(--surface);
  border: 0;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  min-height: 360px;
  padding: 14px;
  resize: vertical;
  width: 100%;
}

.suggestion-review-editor > textarea {
  height: 100%;
  resize: none;
}

@media (max-width: 760px) {
  .suggestion-review-view-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .suggestion-review-preview {
    height: 440px;
    padding: 12px;
  }

  .suggestion-review-preview-document {
    padding: 24px 20px;
  }
}

.diff-columns {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  margin: 14px 0;
}

.diff-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.diff-pane h4 {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 0;
  text-transform: uppercase;
}

.diff-pane pre {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  margin: 10px 0 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Modal */
.modal-backdrop {
  align-items: center;
  backdrop-filter: blur(2px);
  background: rgb(15 23 42 / 45%);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 48px);
  max-width: 680px;
  overflow: auto;
  padding: 24px;
  width: 100%;
}

.users-modal {
  gap: 16px;
  max-width: 720px;
}

.access-policy-modal {
  gap: 16px;
  max-width: 980px;
  overflow-x: hidden;
  overflow-y: auto;
}

.access-policy-modal .modal-body,
.access-policy-modal form {
  min-width: 0;
}

.access-policy-assignment-table {
  max-height: min(52vh, 520px);
  overflow-x: hidden;
  overflow-y: auto;
}

.access-policy-assignment-table .users-table {
  min-width: 0;
  table-layout: fixed;
}

.access-policy-assignment-table th:first-child,
.access-policy-assignment-table td:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
  width: 40%;
}

.access-policy-assignment-table th:last-child,
.access-policy-assignment-table td:last-child {
  min-width: 0;
}

.access-policy-assignment-table th:not(:first-child),
.access-policy-assignment-table td:not(:first-child) {
  text-align: center;
}

.access-policy-assignment-table th:not(:first-child) {
  white-space: normal;
}

.modal-heading {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.modal-heading .eyebrow {
  margin-bottom: 4px;
}

.modal-heading .muted {
  display: block;
  font-size: 13px;
  margin-top: 6px;
}

.modal-close {
  flex: 0 0 auto;
  font-size: 22px;
  height: 34px;
  padding: 0;
  width: 34px;
}

.modal-body {
  display: grid;
  gap: 12px;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 4px;
}

.form-help {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}

.csv-header {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  overflow-x: auto;
  padding: 10px 12px;
  white-space: nowrap;
}

.import-results:empty {
  display: none;
}

.import-results .notice {
  margin: 0;
}

.import-error-list {
  margin: 0;
  max-height: 180px;
  overflow: auto;
  padding-left: 22px;
}

.import-error-list li {
  margin: 5px 0;
}

.modal .notice {
  margin: 0;
}

.email-preview-body {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
  overflow-wrap: anywhere;
  padding: 14px;
  white-space: pre-wrap;
}

/* API tokens */
.token-reveal {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  display: grid;
  gap: 10px;
  margin: 18px 0;
  padding: 16px 18px;
}

.token-secret,
.token-snippet {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  margin: 0;
  overflow-wrap: anywhere;
  padding: 12px;
  white-space: pre-wrap;
}

.api-token-table {
  border-collapse: collapse;
  margin-top: 12px;
  width: 100%;
}

.token-list-heading {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.token-visibility-toggle {
  align-items: center;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 14px;
  gap: 8px;
  white-space: nowrap;
}

.token-visibility-toggle input {
  margin: 0;
}

.token-visibility-count {
  font-variant-numeric: tabular-nums;
}

.api-token-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-top: 14px;
  overflow-x: auto;
  padding: 4px 16px 8px;
}

.api-token-table th,
.api-token-table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.api-token-table tr:last-child td {
  border-bottom: 0;
}

.api-token-table th {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.api-token-name {
  font-weight: 600;
}

.api-token-table tr.is-muted {
  color: var(--text-muted);
  opacity: 0.6;
}

/* Motion preferences */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    transition: none !important;
  }

  .button-spinner {
    animation: none;
  }
}

/* Responsive */
@media (max-width: 999px) {
  .doc-layout {
    display: block;
  }

  .toc {
    display: none;
  }

  .document-edit-layout .document-editor-sidebar {
    border-bottom: 1px solid var(--border);
    border-right: 0;
    display: block;
    padding: 18px 20px;
  }

  .document-edit-layout .document-editor-sidebar-inner {
    position: static;
  }

  .document-column {
    margin: 0 auto;
    max-width: 760px;
  }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .account-trigger .user-details {
    display: none;
  }
}

@media (max-width: 900px) {
  .app-header {
    align-items: stretch;
    flex-direction: column;
    padding: 12px 16px;
    position: static;
  }

  .document-body-field .editor-toolbar {
    top: 0;
  }

  .global-search,
  .account {
    flex-basis: auto;
    margin-left: 0;
  }

  .top-nav {
    min-height: auto;
    overflow-x: auto;
  }

  .nav-item {
    position: static;
  }

  .nav-menu {
    left: 12px;
    right: 12px;
    top: auto;
  }

  .account {
    justify-content: flex-start;
  }

  .current-user {
    text-align: left;
  }

  .account-trigger {
    text-align: left;
  }

  .session-actions.account-menu {
    left: 0;
    right: auto;
  }

  .quick-access-menu {
    left: 16px;
    max-height: min(520px, calc(100vh - var(--app-header-height, 60px) - 24px));
    min-width: min(360px, calc(100vw - 32px));
    position: fixed;
    right: auto;
    top: calc(var(--app-header-height, 60px) + 8px);
    width: min(360px, calc(100vw - 32px));
  }

  .main-content {
    margin-top: 16px;
    padding: 0 16px 48px;
  }

  .users-page-header {
    align-items: stretch;
    display: grid;
  }

  .users-page-actions {
    justify-content: flex-start;
  }

  .document-content {
    padding: 20px;
  }

  .document-title-row {
    display: grid;
    gap: 10px;
  }

  .document-actions {
    justify-content: flex-start;
  }

  .suggestion-row {
    align-items: start;
    display: grid;
  }
}

.app-shell.is-pwa-mode .main-content {
  margin-top: 0;
  padding: 0;
}

.app-shell.is-pwa-mode .chat-layout {
  height: calc(100dvh - 58px);
  min-height: 0;
}
/* Product administration is a separate, global shell. */
.product-admin-shell { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; background: var(--surface, #f6f8fb); }
.product-admin-nav { background: #122337; color: #fff; padding: 2rem 1.25rem; display: flex; flex-direction: column; gap: 2rem; }
.product-admin-nav a { color: inherit; text-decoration: none; display: block; padding: .65rem .75rem; border-radius: .5rem; }
.product-admin-nav nav { display: grid; gap: .35rem; }
.product-admin-nav nav a:hover { background: rgba(255,255,255,.1); }
.product-admin-brand { font-weight: 700; font-size: 1.1rem; }
.product-admin-brand span { display: block; font-size: .75rem; opacity: .72; text-transform: uppercase; letter-spacing: .08em; }
.product-admin-main { padding: 2rem; overflow: auto; }
.product-admin-main > header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.product-admin-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.product-admin-tile { padding: 1.1rem; border-radius: .75rem; background: var(--surface, #fff); border: 1px solid var(--border, #dbe2ea); }
.product-admin-tile span, .product-admin-tile strong { display: block; }
.product-admin-tile strong { font-size: 2rem; margin-top: .35rem; }
.product-admin-table { width: 100%; border-collapse: collapse; background: var(--surface, #fff); margin: 1rem 0; }
.product-admin-table th, .product-admin-table td { text-align: left; padding: .8rem; border-bottom: 1px solid var(--border, #dbe2ea); vertical-align: top; }
.product-admin-table th { background: var(--surface-muted, #f1f5f9); color: var(--text-muted, #475569); font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; }
.product-admin-table small { display: block; opacity: .65; }
.product-admin-form { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; }
.product-admin-form label { display: grid; gap: .35rem; }
.product-admin-form textarea { min-width: 260px; min-height: 80px; }
.product-admin-callout { align-items: center; display: flex; justify-content: space-between; margin-bottom: 1.5rem; max-width: none; padding: 1.25rem 1.5rem; width: 100%; }
.product-admin-callout h2, .product-admin-callout p { margin: 0; }
.product-admin-callout p { color: var(--text-muted, #475569); margin-top: .35rem; }
.product-admin-filter-bar { background: var(--surface, #fff); border: 1px solid var(--border, #dbe2ea); border-radius: .75rem; padding: 1rem; }
.product-admin-filter-bar select[multiple] { min-width: 170px; padding: .35rem; }
.product-admin-filter-hint { color: var(--text-muted, #475569); font-size: .75rem; }
.product-admin-table-wrap { overflow-x: auto; }
.product-admin-feedback-table { min-width: 1080px; }
.product-admin-feedback-table td:nth-child(4) { min-width: 320px; }
.product-admin-feedback-table select { min-width: 120px; }
.product-admin-feedback-summary > strong { display: block; font-size: .95rem; }
.product-admin-feedback-summary > p { color: var(--text-muted, #475569); line-height: 1.45; margin: .3rem 0 .6rem; }
.product-admin-feedback-type { background: var(--accent-soft, #e0f2fe); border-radius: 999px; display: inline-block; font-size: .75rem; padding: .25rem .55rem; text-transform: capitalize; white-space: nowrap; }
.product-admin-feedback-details summary { color: var(--accent, #007dbc); cursor: pointer; font-size: .82rem; font-weight: 600; }
.product-admin-feedback-details h3 { font-size: .82rem; margin: .8rem 0 .25rem; }
.product-admin-feedback-details pre { margin: .25rem 0 .75rem; max-width: 440px; white-space: pre-wrap; }
.product-admin-note { background: var(--surface-muted, #f6f8fb); border-left: 3px solid var(--accent, #007dbc); display: grid; margin: .6rem 0; padding: .65rem; }
.product-admin-note span { margin-top: .25rem; }
.product-admin-note-field { display: grid; font-size: .8rem; gap: .3rem; margin-top: .8rem; }
.product-admin-note-field textarea { min-height: 64px; min-width: 260px; }
.product-admin-row-actions { display: grid; gap: .5rem; }
.product-admin-row-actions button { width: 100%; }
.product-admin-resolve-button { border-color: #15803d; color: #15803d; }
.product-admin-empty { margin-top: 1rem; max-width: none; padding: 1.25rem; width: 100%; }
@media (max-width: 760px) { .product-admin-shell { grid-template-columns: 1fr; } .product-admin-nav { position: static; padding: 1rem; } .product-admin-nav nav { grid-template-columns: repeat(5, auto); overflow-x: auto; } .product-admin-main { padding: 1rem; } .product-admin-callout { align-items: flex-start; flex-direction: column; gap: 1rem; } }
.chat-research-notice { color: var(--text-muted, #475569); font-size: .75rem; margin: .35rem 0 0; text-align: center; }
.chat-research-feedback { align-items: center; display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.chat-research-feedback > button { font-size: .8rem; padding: .35rem .55rem; }
.chat-feedback-rating.is-selected { border-color: var(--accent, #007dbc); color: var(--accent, #007dbc); }
.chat-feedback-detail { display: flex; flex-basis: 100%; flex-wrap: wrap; gap: .6rem; }
.chat-feedback-detail label { align-items: center; display: flex; gap: .25rem; }
.chat-feedback-detail textarea { flex-basis: 100%; max-width: 520px; min-height: 64px; }
.assistant-research-controls { max-width: none; }
#assistant-research-detail pre { background: var(--surface-muted, #f6f8fb); max-height: 28rem; overflow: auto; padding: .75rem; white-space: pre-wrap; }
