:root {
  --admin-font-size: 16px;

  --admin-background: #2a2a2a;
  --admin-foreground: #fafafa;

  --admin-card: #323232;
  --admin-card-foreground: #fafafa;

  --admin-muted-foreground: #a1a1aa;

  --admin-border: #4f4f4f;
  --admin-input-background: #4f4f4f;
  --admin-ring: rgba(255, 255, 255, 0.18);

  --admin-hover: rgba(255, 255, 255, 0.06);
  --admin-active: rgba(255, 255, 255, 0.1);

  --admin-accent: #19e6c0;
  --admin-accent-hover: #14ccaa;
  --admin-accent-subtle: rgba(25, 230, 192, 0.08);
  --admin-accent-border: rgba(25, 230, 192, 0.25);
  --admin-accent-text: #19e6c0;
  --admin-on-accent: #0b0c0e;

  --admin-score-good: #34d399;
  --admin-score-good-subtle: rgba(52, 211, 153, 0.12);
  --admin-score-good-border: rgba(52, 211, 153, 0.3);

  --admin-score-mid: #fbbf24;
  --admin-score-mid-subtle: rgba(251, 191, 36, 0.12);
  --admin-score-mid-border: rgba(251, 191, 36, 0.3);

  --admin-score-low: #f87171;
  --admin-score-low-subtle: rgba(248, 113, 113, 0.12);
  --admin-score-low-border: rgba(248, 113, 113, 0.35);

  --admin-muted: rgba(255, 255, 255, 0.04);

  --admin-radius: 0.625rem;

  --admin-font-weight-normal: 400;
  --admin-font-weight-medium: 500;
  --admin-font-weight-semibold: 600;

  --dash-font-display: "Barlow Condensed", sans-serif;
  --dash-font-body: "Onest", ui-sans-serif, system-ui, sans-serif;
}

[data-theme="light"] {
  --admin-background: #f5f5f5;
  --admin-foreground: #111827;

  --admin-card: #ffffff;
  --admin-card-foreground: #111827;

  --admin-muted-foreground: #6b7280;

  --admin-border: #e5e7eb;
  --admin-input-background: #f3f4f6;
  --admin-ring: rgba(0, 0, 0, 0.1);

  --admin-hover: rgba(0, 0, 0, 0.04);
  --admin-active: rgba(0, 0, 0, 0.08);

  --admin-accent: #0fa892;
  --admin-accent-hover: #0d9680;
  --admin-accent-subtle: rgba(15, 168, 146, 0.08);
  --admin-accent-border: rgba(15, 168, 146, 0.25);
  --admin-accent-text: #0d9680;
  --admin-on-accent: #ffffff;

  --admin-score-good: #059669;
  --admin-score-good-subtle: rgba(5, 150, 105, 0.12);
  --admin-score-good-border: rgba(5, 150, 105, 0.3);

  --admin-score-mid: #d97706;
  --admin-score-mid-subtle: rgba(217, 119, 6, 0.12);
  --admin-score-mid-border: rgba(217, 119, 6, 0.3);

  --admin-score-low: #dc2626;
  --admin-score-low-subtle: rgba(220, 38, 38, 0.12);
  --admin-score-low-border: rgba(220, 38, 38, 0.35);
}

html {
  font-size: var(--admin-font-size);
}

body {
  margin: 0;
}

.admin-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--admin-background);
  color: var(--admin-foreground);
  font-family: var(--dash-font-body), ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: left;
}

.admin-topbar {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--admin-muted-foreground);
  font-weight: var(--admin-font-weight-medium);
}

.admin-table a,
.admin-breadcrumbs a {
  color: var(--admin-foreground);
  text-decoration: none;
}

.admin-table-action,
a.admin-table-action,
button.admin-table-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--admin-border);
  border-radius: calc(var(--admin-radius) - 2px);
  font-size: 0.8125rem;
  font-weight: var(--admin-font-weight-medium);
  font-family: inherit;
  line-height: 1.5;
  color: var(--admin-muted-foreground);
  background: transparent;
  text-decoration: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition:
    color 0.15s ease,
    border-color 0.15s ease;
}

.admin-table-action:hover,
a.admin-table-action:hover,
button.admin-table-action:hover {
  color: var(--admin-foreground);
  border-color: var(--admin-foreground);
}

.admin-breadcrumb-link {
  cursor: pointer;
  color: var(--admin-muted-foreground);
  transition: color 0.15s ease;
}

.admin-breadcrumb-link:hover {
  color: var(--admin-foreground);
}

.admin-breadcrumb-sep {
  color: var(--admin-muted-foreground);
  opacity: 0.55;
  user-select: none;
}

.admin-breadcrumbs .current {
  color: var(--admin-foreground);
}

.breadcrumb-separator {
  color: var(--admin-muted-foreground);
  opacity: 0.7;
  font-size: 0.95rem;
  line-height: 1;
}

.admin-action-button {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 48px;
  padding: 0 18px;
  background: transparent;
  border: 1px solid var(--admin-border);
  border-radius: calc(var(--admin-radius) - 2px);
  color: var(--admin-muted-foreground);
  font-size: 1rem;
  font-weight: var(--admin-font-weight-medium);
  line-height: 1.5;
  cursor: default;
}

.admin-action-icon {
  font-size: 0.95rem;
  opacity: 0.9;
}

.admin-divider {
  flex: 1;
  border-top: 1px solid var(--admin-border);
}

.admin-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 44px 32px 80px;
}

.admin-header h1 {
  margin: 0;
  font-family: var(--dash-font-display);
  font-size: 2.25rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
  font-weight: 700;
  color: var(--admin-foreground);
}

.admin-header h2 {
  font-family: var(--dash-font-display);
  font-size: 1.75rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
  font-weight: 700;
  color: var(--admin-foreground);
}

.dash-page-header h2 {
  font-size: 2.5rem;
}

.admin-header {
  margin-bottom: 1.25rem;
}

.admin-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.admin-header p {
  margin: 0.5rem 0 0;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--admin-muted-foreground);
  font-weight: var(--admin-font-weight-normal);
}

.dash-masthead-date {
  font-size: 0.9375rem;
  color: var(--admin-muted-foreground);
  font-weight: var(--admin-font-weight-normal);
  white-space: nowrap;
}

.admin-meta-card {
  margin-top: 2rem;
}

.admin-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
  line-height: 1.5;
  font-weight: var(--admin-font-weight-medium);
  color: var(--admin-muted-foreground);
}

.admin-page .form-group--checkbox label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0;
}

.admin-page .form-group--checkbox input[type="checkbox"] {
  width: auto;
  margin: 0;
  padding: 0;
}

.required {
  color: var(--admin-score-low);
}

.form-group--error input,
.form-group--error input[type],
.form-group--error textarea,
.form-group--error .section-name-input {
  box-shadow: 0 0 0 1px var(--admin-score-low);
}

.form-group--error input:focus,
.form-group--error textarea:focus {
  box-shadow: 0 0 0 2px var(--admin-score-low);
}

.form-group-error-msg {
  margin: 4px 0 0;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--admin-score-low);
}

.admin-page input,
.admin-page input[type],
.admin-page textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--admin-input-background);
  border: 1px solid var(--admin-border);
  border-radius: calc(var(--admin-radius) - 2px);
  color: var(--admin-card-foreground);
  padding: 0.625rem 0.875rem;
  font-size: 1rem;
  line-height: 1.5;
  font-family: inherit;
  font-weight: var(--admin-font-weight-normal);
  outline: none;
}

.admin-page input::placeholder {
  color: var(--admin-muted-foreground);
  opacity: 1;
}

.admin-page textarea::placeholder {
  color: var(--admin-muted-foreground);
  opacity: 1;
}

.admin-page input[readonly],
.admin-page input:disabled,
.admin-page textarea:disabled {
  background-color: var(--admin-input-background);
  opacity: 1;
  -webkit-text-fill-color: var(--admin-card-foreground);
}

.admin-page select {
  width: 100%;
  background: var(--admin-input-background);
  border: 1px solid var(--admin-border);
  border-radius: calc(var(--admin-radius) - 2px);
  color: var(--admin-card-foreground);
  padding: 0.625rem 2.25rem 0.625rem 0.875rem;
  font-size: 1rem;
  line-height: 1.5;
  font-family: inherit;
  font-weight: var(--admin-font-weight-normal);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

/* Custom dropdown chevron — replaces the native select arrow so it sits
   inset from the right edge instead of flush against the border. */
.admin-select-wrapper {
  position: relative;
  display: block;
  width: 100%;
}

.admin-select-chevron {
  position: absolute;
  top: 50%;
  right: 0.875rem;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: var(--admin-muted-foreground);
  pointer-events: none;
}

.input-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.admin-page textarea[readonly] {
  cursor: default;
}

.admin-page h2 {
  margin: 0;
}

/* Script name above panels */
.template-name-field {
  margin-bottom: 1.5rem;
}

.template-nav-no-top {
  margin-top: 0;
}

/* Two-panel layout */
.template-panels {
  display: flex;
  gap: 32px;
}

.template-panel-left {
  width: 260px;
  flex-shrink: 0;
  position: sticky;
  top: 24px;
  align-self: flex-start;
}

.template-panel-right {
  flex: 1;
  min-width: 0;
}

/* Section nav */
.section-nav {
  margin-top: 24px;
}

.admin-section-card {
  margin-top: 0;
  overflow: hidden;
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: calc(var(--admin-radius) + 4px);
}

.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--admin-border);
}

.admin-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.admin-search-icon {
  position: absolute;
  left: 0.75rem;
  color: var(--admin-muted-foreground);
  font-size: 0.8125rem;
  pointer-events: none;
  transition: color 0.15s ease;
}

.admin-search:focus-within .admin-search-icon {
  color: var(--admin-foreground);
}

.admin-page input.admin-search-input,
.admin-page input[type].admin-search-input {
  flex: 1;
  width: 100%;
  height: 2.25rem;
  padding: 0 2.25rem;
  font-size: 0.875rem;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.admin-page input.admin-search-input:focus,
.admin-page input[type].admin-search-input:focus {
  border-color: var(--admin-foreground);
  box-shadow: 0 0 0 3px var(--admin-ring);
}

.admin-search-clear {
  position: absolute;
  right: 0.375rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--admin-muted-foreground);
  cursor: pointer;
  border-radius: 999px;
  transition:
    color 0.15s ease,
    background-color 0.15s ease;
}

.admin-search-clear:hover {
  color: var(--admin-foreground);
  background-color: var(--admin-hover);
}

.admin-search-clear:focus-visible {
  outline: none;
  color: var(--admin-foreground);
  box-shadow: 0 0 0 2px var(--admin-ring);
}

.admin-section-body {
  padding: 18px;
}

.admin-section-card .dash-empty-state {
  padding: 32px 24px;
}

.admin-section-card .dash-empty-icon {
  font-size: 1.5rem;
  color: var(--admin-muted-foreground);
}

.admin-section-card .dash-empty-sub {
  margin-bottom: 14px;
}

.new-section-card {
  margin-top: 1rem;
  overflow: hidden;
  text-align: center;
  background: var(--admin-card);
  border: 1px dashed var(--admin-border);
  border-radius: calc(var(--admin-radius) + 4px);
  padding: 10px;
  border-color: var(--admin-accent-border);
  cursor: pointer;
  transition:
    color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.new-section-card:hover {
  color: #19e6c0b3;
  background-color: #19e6c024;
  border-color: #19e6c04d;
}

.section-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--admin-border);
  margin-bottom: 4px;
}

.section-nav-title {
  font-family: var(--dash-font-display);
  font-size: 0.75rem;
  font-weight: var(--admin-font-weight-semibold);
  color: var(--admin-muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.section-nav-item {
  display: flex;
  align-items: center;
  border-radius: calc(var(--admin-radius) - 2px);
  transition: background-color 0.15s ease;
}

.section-nav-item:hover {
  background: var(--admin-hover);
}

.section-nav-item-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  background: none;
  border: none;
  color: var(--admin-foreground);
  font-size: 0.875rem;
  font-weight: var(--admin-font-weight-medium);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.section-nav-item-btn:focus-visible {
  outline: 2px solid var(--admin-ring);
  outline-offset: -2px;
  border-radius: calc(var(--admin-radius) - 2px);
}

.section-nav-delete {
  padding: 8px;
  opacity: 0;
  transition:
    opacity 0.15s ease,
    color 0.15s ease,
    filter 0.15s ease;
}

.section-nav-item:hover .section-nav-delete {
  opacity: 1;
}

.section-nav-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Section groups & dividers */
.section-group {
  margin-top: 1.5rem;
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: calc(var(--admin-radius) + 4px);
  padding: 18px;
}

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

.section-divider {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--admin-border);
}

.section-number {
  font-family: var(--dash-font-display);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--admin-muted-foreground);
  line-height: 1;
  padding-top: 0.125rem;
  flex-shrink: 0;
  user-select: none;
}

.section-divider .form-group {
  flex: 1;
  min-width: 0;
}

.section-name-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--admin-input-background);
  border: 1px solid var(--admin-border);
  border-radius: calc(var(--admin-radius) - 2px);
  color: var(--admin-foreground);
  padding: 0.625rem 0.875rem;
  font-size: 1rem;
  font-weight: var(--admin-font-weight-normal);
  font-family: inherit;
  line-height: 1.5;
  outline: none;
  transition: box-shadow 0.15s ease;
}

.section-name-input::placeholder {
  color: var(--admin-muted-foreground);
}

.section-name-input:focus {
  box-shadow: 0 0 0 1px var(--admin-ring);
}

.admin-section-card--mt {
  margin-top: 2rem;
}

.admin-table-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.input-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.text-muted-no-margin {
  color: var(--admin-muted-foreground);
  margin: 0;
}

.admin-section-body--min-height {
  min-height: 400px;
  display: flex;
  flex-direction: column;
}

.admin-section-body--table {
  padding: 0;
}

.admin-section-body--table .admin-pagination {
  padding: 12px 18px 16px;
}

.admin-section-body--min-height .admin-pagination {
  margin-top: auto;
}

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

.admin-table th {
  padding: 12px 16px;
  text-align: left;
  font-family: var(--dash-font-display);
  font-size: 0.8125rem;
  font-weight: var(--admin-font-weight-semibold);
  letter-spacing: 0.06em;
  color: var(--admin-muted-foreground);
  border-bottom: 1px solid var(--admin-border);
}

.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--admin-border);
}

.admin-table th:last-child,
.admin-table td:last-child {
  text-align: right;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table tbody tr {
  transition: background-color 0.12s ease;
}

.admin-table tbody tr:hover {
  background: var(--admin-hover);
}

.admin-table-row--clickable {
  cursor: pointer;
}

.question-count {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--admin-muted-foreground);
  font-weight: var(--admin-font-weight-normal);
  white-space: nowrap;
}

.icon-button {
  background: none;
  border: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  color: var(--admin-muted-foreground);
  font-size: 1rem;
  line-height: 1;
  user-select: none;
  cursor: pointer;
  transition:
    color 0.15s ease,
    filter 0.15s ease;
}

.icon-button:hover {
  color: var(--admin-score-low);
}

.icon-button:focus-visible {
  outline: 2px solid var(--admin-ring);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Question accordion */
.question-list {
  display: flex;
  flex-direction: column;
}

.question-accordion {
  border-bottom: 1px solid var(--admin-border);
}

.question-accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.question-accordion-header:hover {
  background: rgba(255, 255, 255, 0.09);
}

.question-accordion-header:focus-visible {
  outline: 2px solid var(--admin-ring);
  outline-offset: -2px;
}

.question-accordion-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.question-chevron {
  font-size: 0.8rem;
  color: var(--admin-muted-foreground);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

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

.question-index {
  font-family: var(--dash-font-display);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--admin-muted-foreground);
  font-weight: var(--admin-font-weight-semibold);
  flex-shrink: 0;
}

.question-preview {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--admin-muted-foreground);
  font-weight: var(--admin-font-weight-normal);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.question-preview--filled {
  color: var(--admin-foreground);
}

.question-preview--error {
  color: var(--admin-score-low);
}

.question-accordion-body {
  padding: 4px 8px 16px 26px;
  animation: accordion-open 0.18s ease-out both;
}

@keyframes accordion-open {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.question-accordion-body textarea {
  min-height: 96px;
  resize: none;
}

/* Script template show — document layout */
.dash-stats-row.script-show-stats {
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 24px;
}

@media (max-width: 960px) {
  .dash-stats-row.script-show-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .dash-stats-row.script-show-stats {
    grid-template-columns: 1fr;
  }
}

.script-show-score-denominator {
  font-size: 0.75em;
  font-weight: var(--admin-font-weight-normal);
  color: var(--admin-muted-foreground);
  margin-left: 2px;
}

.script-show-doc {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.script-show-section {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 24px 28px;
}

.script-show-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--admin-border);
}

.script-show-section-heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.script-show-section-eyebrow {
  font-family: var(--dash-font-display);
  font-size: 0.75rem;
  font-weight: var(--admin-font-weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--admin-muted-foreground);
}

.script-show-section-title {
  margin: 0;
  font-family: var(--dash-font-display);
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--admin-foreground);
  line-height: 1.3;
  letter-spacing: 0.01em;
}

.script-show-metric-group {
  display: flex;
  gap: 24px;
  flex-shrink: 0;
}

.script-show-metric {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.script-show-metric-label {
  font-size: 0.75rem;
  color: var(--admin-muted-foreground);
}

.script-show-metric-value {
  font-family: var(--dash-font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--admin-foreground);
  line-height: 1.2;
}

.script-show-question-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.script-show-question {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.script-show-question-lead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.script-show-question-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.script-show-question--excluded .script-show-question-body,
.script-show-question--excluded .script-show-ideal {
  opacity: 0.55;
}

.script-show-exclude-btn {
  font-size: 0.75rem;
  font-weight: var(--admin-font-weight-medium);
  color: var(--admin-muted-foreground);
  background: transparent;
  border: 1px solid var(--admin-border);
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition:
    color 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

.script-show-exclude-btn:hover:not(:disabled) {
  color: var(--admin-foreground);
  border-color: var(--admin-foreground);
}

.script-show-exclude-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.script-show-question-number {
  color: var(--admin-muted-foreground);
  font-weight: var(--admin-font-weight-semibold);
  margin-right: 2px;
}

.script-show-chip {
  font-size: 0.75rem;
  font-weight: var(--admin-font-weight-medium);
  color: var(--admin-foreground);
  background: var(--admin-input-background);
  border: 1px solid var(--admin-border);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

.script-show-chip--muted {
  color: var(--admin-muted-foreground);
}

.script-show-chip--high {
  color: var(--admin-score-good);
  background: var(--admin-score-good-subtle);
  border-color: var(--admin-score-good-border);
}

.script-show-chip--mid {
  color: var(--admin-score-mid);
  background: var(--admin-score-mid-subtle);
  border-color: var(--admin-score-mid-border);
}

.script-show-chip--low {
  color: var(--admin-score-low);
  background: var(--admin-score-low-subtle);
  border-color: var(--admin-score-low-border);
}

.script-show-score--high {
  color: var(--admin-score-good);
}

.script-show-score--mid {
  color: var(--admin-score-mid);
}

.script-show-score--low {
  color: var(--admin-score-low);
}

.script-show-score--muted {
  color: var(--admin-muted-foreground);
}

.script-show-score-popover-wrapper {
  position: relative;
  display: inline-flex;
}

.script-show-score-popover-wrapper--open {
  z-index: 30;
}

.script-show-score-trigger {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: inherit;
  font-size: 0.75rem;
  line-height: 1.3;
  transition:
    filter 0.12s ease,
    border-color 0.12s ease,
    box-shadow 0.12s ease,
    transform 0.12s ease;
}

.script-show-score-trigger:hover {
  filter: brightness(1.12);
  border-color: var(--admin-foreground);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transform: translateY(-1px);
}

.script-show-score-trigger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--admin-ring);
}

.script-show-score-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  width: 300px;
  max-width: 80vw;
  padding: 12px;
  background-color: var(--admin-card);
  color: var(--admin-card-foreground);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.script-show-score-pop-header {
  font-family: var(--dash-font-display);
  font-size: 0.6875rem;
  font-weight: var(--admin-font-weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--admin-muted-foreground);
  margin-bottom: 8px;
}

.script-show-metric-defn-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.script-show-metric-defn-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.script-show-metric-defn-label {
  font-size: 0.8125rem;
  font-weight: var(--admin-font-weight-semibold);
  color: var(--admin-foreground);
}

.script-show-metric-defn-value {
  font-size: 0.8125rem;
  font-weight: var(--admin-font-weight-semibold);
  color: var(--admin-foreground);
  white-space: nowrap;
}

.script-show-metric-defn-desc {
  margin: 2px 0 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--admin-muted-foreground);
}

.script-show-excerpt-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.script-show-excerpt-item {
  position: relative;
  padding-left: 14px;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--admin-card-foreground);
}

.script-show-excerpt-item::before {
  content: "\2022";
  position: absolute;
  left: 0;
  color: var(--admin-accent-text);
  font-weight: 700;
}

.summary-stat-text {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--admin-foreground);
}

.summary-stat-text--placeholder {
  color: var(--admin-muted-foreground);
  font-style: italic;
}

.summary-hero {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.summary-metrics {
  margin-bottom: 4px;
}

.dash-metrics-row.summary-metrics-row {
  grid-template-columns: repeat(2, 1fr);
  padding: 12px 0 20px;
}

.summary-prose-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.summary-prose-card {
  min-height: 140px;
}

.summary-prose-card--accent {
  background: var(--admin-accent-subtle);
  border-color: var(--admin-accent-border);
}

.summary-accent-label {
  color: var(--admin-accent-text);
}

@media (max-width: 720px) {
  .summary-prose-row {
    grid-template-columns: 1fr;
  }

  .dash-metrics-row.summary-metrics-row {
    grid-template-columns: 1fr;
  }
}

.summary-placeholder-chip {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  font-family: var(--dash-font-body);
  font-size: 0.625rem;
  font-weight: var(--admin-font-weight-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--admin-muted-foreground);
  background: var(--admin-muted);
  border: 1px dashed var(--admin-border);
  border-radius: 999px;
  vertical-align: middle;
}

.summary-placeholder-chip--accent {
  color: var(--admin-accent-text);
  background: var(--admin-accent-subtle);
  border-color: var(--admin-accent-border);
}

/* Skeleton state — match the loaded layout's vertical rhythm */
.summary-skeleton-header {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.summary-skeleton-title {
  height: 1.75rem;
  width: 40%;
  max-width: 18rem;
}

.summary-skeleton-sub {
  height: 1rem;
  width: 60%;
  max-width: 28rem;
}

.summary-skeleton-metric-label {
  display: block;
  height: 0.875rem;
  margin-bottom: 0.625rem;
}

.summary-skeleton-metric-value {
  display: block;
  height: 2.25rem;
  width: 60%;
}

.summary-skeleton-stat-label {
  display: block;
  height: 0.875rem;
  margin-bottom: 0.875rem;
  width: 35%;
}

.summary-skeleton-stat-line {
  display: block;
  height: 0.875rem;
  margin-top: 0.5rem;
}

.summary-skeleton-eyebrow {
  display: block;
  height: 0.75rem;
  width: 5rem;
  margin-bottom: 0.5rem;
}

.summary-skeleton-section-title {
  display: block;
  height: 1.375rem;
}

/* Error state — friendlier than a bare <p> */
.summary-error {
  padding: 5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
  max-width: 32rem;
  margin: 0 auto;
}

.summary-error-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: var(--admin-font-weight-semibold);
  color: var(--admin-foreground);
}

.summary-error-body {
  margin: 0;
  color: var(--admin-muted-foreground);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.summary-error-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.summary-not-found {
  padding: 96px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.summary-not-found-eyebrow {
  font-family: var(--dash-font-display);
  font-size: 0.75rem;
  font-weight: var(--admin-font-weight-semibold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--admin-muted-foreground);
}

.summary-not-found-title {
  margin: 0;
  font-family: var(--dash-font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--admin-foreground);
  letter-spacing: -0.01em;
}

.summary-not-found-sub {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--admin-muted-foreground);
  max-width: 42ch;
  line-height: 1.5;
}

.script-show-question-body {
  margin: 0;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--admin-foreground);
  white-space: pre-wrap;
  flex: 1;
  min-width: 0;
}

.script-show-ideal {
  background: var(--admin-input-background);
  border-radius: 6px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.script-show-ideal-label {
  font-family: var(--dash-font-display);
  font-size: 0.6875rem;
  font-weight: var(--admin-font-weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--admin-muted-foreground);
}

.script-show-ideal-text {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--admin-card-foreground);
  white-space: pre-wrap;
}

.script-show-analytics-row {
  display: flex;
  gap: 0;
  background: var(--admin-input-background);
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  overflow: hidden;
}

.script-show-analytics-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 14px;
  flex: 1;
  min-width: 0;
  border-right: 1px solid var(--admin-border);
}

.script-show-analytics-cell:last-child {
  border-right: none;
}

.script-show-analytics-label {
  font-family: var(--dash-font-display);
  font-size: 0.6875rem;
  font-weight: var(--admin-font-weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--admin-muted-foreground);
  white-space: nowrap;
}

.script-show-analytics-value {
  font-size: 0.9375rem;
  font-weight: var(--admin-font-weight-semibold);
  color: var(--admin-foreground);
  line-height: 1.3;
}

@media (max-width: 720px) {
  .script-show-analytics-row {
    flex-wrap: wrap;
  }

  .script-show-analytics-cell {
    flex: 1 1 40%;
    border-right: 1px solid var(--admin-border);
    border-bottom: 1px solid var(--admin-border);
  }

  .script-show-analytics-cell:last-child {
    border-right: none;
  }
}

@media (max-width: 720px) {
  .script-show-section-header {
    flex-direction: column;
    gap: 12px;
  }

  .script-show-metric-group {
    align-self: stretch;
    justify-content: flex-start;
  }

  .script-show-metric {
    align-items: flex-start;
  }
}

/* Add inline buttons */
.add-inline-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 0;
  background: none;
  border: none;
  color: var(--admin-muted-foreground);
  font-size: 0.875rem;
  font-weight: var(--admin-font-weight-medium);
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s ease;
}

.add-inline-btn:hover {
  color: var(--admin-accent-text);
}

.add-dashed-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 16px;
  padding: 20px;
  background: none;
  border: 2px dashed var(--admin-border);
  border-radius: var(--admin-radius);
  color: var(--admin-muted-foreground);
  font-size: 0.9375rem;
  font-weight: var(--admin-font-weight-medium);
  font-family: inherit;
  cursor: pointer;
  gap: 8px;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.add-dashed-btn:hover {
  background: rgba(25, 230, 192, 0.06);
  border-color: var(--admin-accent);
  color: var(--admin-accent);
}

.add-dashed-btn:focus-visible {
  outline: 2px solid var(--admin-ring);
  outline-offset: 2px;
}

.add-dashed-btn--sm {
  padding: 10px;
  font-size: 0.8125rem;
  margin-top: 12px;
}

.field-help {
  margin: 0.5rem 2px 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--admin-muted-foreground);
  font-weight: var(--admin-font-weight-normal);
}

.admin-page input:focus,
.admin-page textarea:focus,
.admin-action-button:focus {
  outline: none;
  box-shadow: 0 0 0 1px var(--admin-ring);
}

/* Table skeleton loading */
.admin-table-skeleton {
  display: inline-block;
  height: 12px;
  border-radius: 4px;
  background: var(--admin-border);
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}

.admin-table-skeleton--wide {
  width: 160px;
}
.admin-table-skeleton--mid {
  width: 80px;
}
.admin-table-skeleton--narrow {
  width: 32px;
}

@keyframes skeleton-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--admin-border);
}

.admin-pagination-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--admin-border);
  border-radius: calc(var(--admin-radius) - 2px);
  color: var(--admin-muted-foreground);
  font-size: 0.875rem;
  font-weight: var(--admin-font-weight-medium);
  font-family: inherit;
  cursor: pointer;
  transition:
    color 0.15s ease,
    border-color 0.15s ease;
}

.admin-pagination-btn:hover:not(:disabled) {
  color: var(--admin-foreground);
  border-color: var(--admin-foreground);
}

.admin-pagination-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.admin-pagination-page {
  font-size: 0.875rem;
  font-weight: var(--admin-font-weight-medium);
  color: var(--admin-muted-foreground);
}

/* Footer */
.admin-footer {
  position: sticky;
  bottom: 0;
  background: var(--admin-card);
  border-top: 1px solid var(--admin-border);
  padding: 16px 32px;
  display: flex;
  justify-content: flex-end;
}

.admin-footer-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0 16px;
  background: var(--admin-accent);
  border: 1px solid var(--admin-accent);
  border-radius: calc(var(--admin-radius) - 2px);
  color: var(--admin-on-accent);
  font-size: 0.875rem;
  font-weight: var(--admin-font-weight-semibold);
  font-family: inherit;
  line-height: 1.5;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
}

a.admin-footer-btn {
  text-decoration: none;
}

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

.admin-footer-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.admin-footer-btn:focus-visible {
  outline: 2px solid var(--admin-ring);
  outline-offset: 2px;
}

.admin-footer-error {
  margin: 0 auto 0 0;
  font-size: 0.875rem;
  color: var(--admin-score-low);
}

/* Undo toast */
.undo-toast {
  position: fixed;
  bottom: 80px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 10px 16px;
  font-size: 0.875rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  animation: toast-in 0.2s ease-out both;
  z-index: 200;
}

.undo-toast-msg {
  color: var(--admin-muted-foreground);
}

.undo-toast-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--dash-font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--admin-accent);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s ease;
}

.undo-toast-btn:hover {
  color: var(--admin-accent-hover);
}

.undo-toast-btn:focus-visible {
  outline: 2px solid var(--admin-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading spinner */
.admin-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 48px 0;
}
.admin-loading-icon {
  font-size: 2rem;
  color: var(--admin-muted-foreground);
  animation: spin 1s linear infinite;
}
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Sidebar */
@media (prefers-reduced-motion: reduce) {
  .question-accordion-body {
    animation: none;
  }

  .undo-toast {
    animation: none;
  }

  .question-chevron {
    transition: none;
  }
}

@media (max-width: 900px) {
  .admin-meta-grid {
    grid-template-columns: 1fr;
  }

  .admin-topbar,
  .admin-container {
    padding-left: 20px;
    padding-right: 20px;
  }

  .admin-topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .template-panels {
    flex-direction: column;
  }

  .template-panel-left {
    width: 100%;
    position: static;
  }

  .section-divider {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .section-name-input {
    width: 100%;
  }

  .admin-header h1 {
    font-size: 2rem;
  }
}

.admin-banner {
  padding: 8px;
  margin: 2px 24px;
}

.admin-banner a {
  color: inherit;
  text-decoration: underline;
}
.admin-banner--warning {
  background-color: var(--admin-sidebar-danger);
  border-radius: 5px;
}

/* ── Wizard steps ── */

.wizard-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 20px 24px 16px;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wizard-step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  background: var(--card-bg, #1e1e1e);
  color: var(--text-muted, #888);
  border: 1px solid var(--border, #333);
}

.wizard-step-label {
  font-size: 13px;
  color: var(--text-muted, #888);
}

.wizard-step--active .wizard-step-number {
  background: var(--accent, #4db88a);
  color: #fff;
  border-color: var(--accent, #4db88a);
}

.wizard-step--active .wizard-step-label {
  color: var(--text-primary, #eee);
  font-weight: 600;
}

.wizard-step--completed .wizard-step-number {
  background: transparent;
  color: var(--accent, #4db88a);
  border-color: var(--accent, #4db88a);
}

.wizard-step--completed .wizard-step-label {
  color: var(--text-muted, #888);
}

.wizard-step-connector {
  width: 40px;
  height: 1px;
  background: var(--border, #333);
  margin: 0 12px;
}

.admin-footer-btn--secondary {
  background: transparent;
  border: 1px solid var(--border, #333);
  color: var(--text-muted, #888);
}

.admin-footer-btn--secondary:hover {
  border-color: var(--text-muted, #888);
  color: var(--text-primary, #eee);
}

/* ── Drag and drop (nav sidebar) ── */

.section-nav-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--admin-muted-foreground);
  cursor: grab;
  background: none;
  border: none;
  padding: 0;
  flex-shrink: 0;
  border-radius: 3px;
  font-size: 0.75rem;
  opacity: 0;
  transition:
    color 0.15s ease,
    background-color 0.15s ease,
    opacity 0.15s ease;
}

.section-nav-item:hover > .section-nav-drag-handle,
.section-nav-question-item:hover > .section-nav-drag-handle {
  opacity: 1;
}

.section-nav-drag-handle:hover {
  color: var(--admin-foreground);
  background: var(--admin-hover);
}

.section-nav-drag-handle:active {
  cursor: grabbing;
}

.section-nav-questions {
  display: flex;
  flex-direction: column;
  padding-left: 4px;
  margin-bottom: 4px;
}

.section-nav-question-item {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: calc(var(--admin-radius) - 2px);
  transition: background-color 0.15s ease;
}

.section-nav-question-item:hover {
  background: var(--admin-hover);
}

.section-nav-question-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  background: none;
  border: none;
  color: var(--admin-muted-foreground);
  font-size: 0.8125rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s ease;
}

.section-nav-question-btn:hover {
  color: var(--admin-foreground);
}

.section-nav-question-btn:focus-visible {
  outline: 2px solid var(--admin-ring);
  outline-offset: -2px;
  border-radius: calc(var(--admin-radius) - 2px);
}

.section-nav-question-label {
  font-family: var(--dash-font-display);
  font-weight: var(--admin-font-weight-semibold);
  font-size: 0.75rem;
  flex-shrink: 0;
  color: var(--admin-muted-foreground);
}

.section-nav-question-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.section-nav-drag-icon {
  color: var(--admin-muted-foreground);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.section-nav-item--overlay,
.section-nav-question-item--overlay {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--admin-card);
  border: 1px solid var(--admin-accent);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  padding: 8px 12px;
  font-size: 0.875rem;
  color: var(--admin-foreground);
}

.form-group-stack {
  display: flex;
  flex-direction: column;
}

.summary-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.regrade-skipped-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  margin-bottom: 4px;
  background: var(--admin-accent-subtle);
  border: 1px solid var(--admin-accent-border);
  border-radius: calc(var(--admin-radius) - 2px);
  font-size: 0.875rem;
  color: var(--admin-accent-text);
}

.regrade-skipped-banner-dismiss {
  flex-shrink: 0;
  font-size: 0.8125rem;
  font-weight: var(--admin-font-weight-medium);
  color: var(--admin-accent-text);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  opacity: 0.75;
  transition: opacity 0.1s ease;
}

.regrade-skipped-banner-dismiss:hover {
  opacity: 1;
}

/* ============================================================
   Conversation Chat — floating widget
   ============================================================ */

.conv-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* ---- Launcher button (collapsed state) ---- */

.conv-chat-launcher {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  background: var(--admin-card);
  color: var(--admin-foreground);
  border: 1px solid var(--admin-border);
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: var(--admin-font-weight-semibold);
  font-family: var(--dash-font-body);
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.conv-chat-launcher:hover {
  transform: translateY(-1px);
  border-color: var(--admin-accent-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.conv-chat-launcher-icon {
  font-size: 1.05rem;
  flex-shrink: 0;
  color: var(--admin-accent);
}

/* ---- Expanded window ---- */

.conv-chat-window {
  width: 400px;
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.32);
  overflow: hidden;
  transform-origin: bottom right;
  animation: conv-chat-window-in 0.19s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes conv-chat-window-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.conv-chat-window-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  background: var(--admin-background);
  color: var(--admin-foreground);
  border-bottom: 1px solid var(--admin-border);
  flex-shrink: 0;
}

.conv-chat-window-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--dash-font-display);
  font-size: 0.9375rem;
  font-weight: var(--admin-font-weight-semibold);
  letter-spacing: 0.01em;
}

.conv-chat-window-marker {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--admin-accent);
  flex-shrink: 0;
}

.conv-chat-window-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--admin-muted-foreground);
  cursor: pointer;
  transition: color 0.1s ease, background 0.1s ease;
  flex-shrink: 0;
}

.conv-chat-window-btn:hover {
  color: var(--admin-foreground);
  background: var(--admin-input-background);
}

/* ---- Message list ---- */

.conv-chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 16px;
  min-height: 320px;
  max-height: min(440px, calc(100vh - 220px));
}

/* ---- Empty state / starter prompts ---- */

.conv-chat-intro {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 4px;
}

.conv-chat-intro-text {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--admin-muted-foreground);
}

.conv-chat-starters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.conv-chat-starter {
  text-align: left;
  padding: 9px 13px;
  font-size: 0.8125rem;
  line-height: 1.4;
  font-family: var(--dash-font-body);
  color: var(--admin-foreground);
  background: var(--admin-input-background);
  border: 1px solid var(--admin-border);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.conv-chat-starter:hover {
  border-color: var(--admin-accent-border);
  background: var(--admin-accent-subtle);
  color: var(--admin-accent-text);
}

.conv-chat-message {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 88%;
  animation: conv-chat-msg-in 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes conv-chat-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.conv-chat-message--user {
  align-self: flex-end;
  align-items: flex-end;
}

.conv-chat-message--assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.conv-chat-message-label {
  font-family: var(--dash-font-display);
  font-size: 0.625rem;
  font-weight: var(--admin-font-weight-semibold);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--admin-muted-foreground);
}

.conv-chat-message--assistant .conv-chat-message-label {
  color: var(--admin-accent-text);
}

.conv-chat-message-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.conv-chat-message-text {
  margin: 0;
  padding: 9px 13px;
  font-size: 0.875rem;
  line-height: 1.6;
  border-radius: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
}

.conv-chat-message--user .conv-chat-message-text {
  background: var(--admin-input-background);
  color: var(--admin-foreground);
  border: 1px solid var(--admin-border);
  border-bottom-right-radius: 4px;
}

.conv-chat-message--assistant .conv-chat-message-text {
  background: var(--admin-background);
  border: 1px solid var(--admin-border);
  color: var(--admin-foreground);
  border-bottom-left-radius: 4px;
}

/* ---- Markdown rendering (assistant) ---- */

.conv-chat-md { white-space: normal; }
.conv-chat-md > :first-child { margin-top: 0; }
.conv-chat-md > :last-child { margin-bottom: 0; }
.conv-chat-md p { margin: 0 0 8px; }
.conv-chat-md ul,
.conv-chat-md ol { margin: 0 0 8px; padding-left: 20px; }
.conv-chat-md li { margin: 2px 0; }
.conv-chat-md li::marker { color: var(--admin-muted-foreground); }
.conv-chat-md h1,
.conv-chat-md h2,
.conv-chat-md h3 {
  font-family: var(--dash-font-display);
  font-size: 0.9375rem;
  font-weight: var(--admin-font-weight-semibold);
  margin: 10px 0 6px;
}
.conv-chat-md strong { font-weight: var(--admin-font-weight-semibold); }
.conv-chat-md a { color: var(--admin-accent-text); text-decoration: underline; }
.conv-chat-md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8125rem;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--admin-input-background);
  border: 1px solid var(--admin-border);
}
.conv-chat-md pre {
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--admin-input-background);
  border: 1px solid var(--admin-border);
  overflow-x: auto;
}
.conv-chat-md pre code { padding: 0; border: none; background: none; }

/* ---- Copy action ---- */

.conv-chat-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  align-self: flex-start;
  padding: 3px 7px;
  font-size: 0.6875rem;
  font-family: var(--dash-font-body);
  color: var(--admin-muted-foreground);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, color 0.12s ease, background 0.12s ease;
}

.conv-chat-message--assistant:hover .conv-chat-copy,
.conv-chat-copy:focus-visible {
  opacity: 1;
}

.conv-chat-copy:hover {
  color: var(--admin-foreground);
  background: var(--admin-input-background);
}

/* ---- Typing indicator ---- */

.conv-chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 13px;
  background: var(--admin-background);
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}

.conv-chat-typing span {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--admin-accent);
  animation: conv-chat-bounce 1.2s infinite ease-in-out;
}

.conv-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.conv-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes conv-chat-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.35; }
  40% { transform: scale(1); opacity: 1; }
}

/* ---- Error ---- */

.conv-chat-error {
  margin: 0 16px 10px;
  padding: 9px 12px;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--admin-score-low);
  background: var(--admin-score-low-subtle);
  border: 1px solid var(--admin-score-low-border);
  border-radius: 8px;
}

/* ---- Input area ---- */

.conv-chat-input-area {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--admin-border);
  flex-shrink: 0;
}

.conv-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.conv-chat-textarea {
  flex: 1;
  resize: none;
  padding: 9px 12px;
  font-size: 0.875rem;
  line-height: 1.5;
  font-family: var(--dash-font-body);
  color: var(--admin-foreground);
  background: var(--admin-input-background);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  outline: none;
  box-sizing: border-box;
  max-height: 132px;
  overflow-y: auto;
  transition: border-color 0.15s ease;
}

.conv-chat-textarea:focus {
  border-color: var(--admin-accent-border);
}

.conv-chat-textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.conv-chat-hint {
  font-size: 0.6875rem;
  color: var(--admin-muted-foreground);
}

.conv-chat-hint kbd {
  font-family: var(--dash-font-body);
  font-size: 0.6875rem;
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--admin-input-background);
  border: 1px solid var(--admin-border);
  color: var(--admin-foreground);
}

.conv-chat-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  color: var(--admin-on-accent);
  background: var(--admin-accent);
  border: none;
  border-radius: var(--admin-radius);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.12s ease;
}

.conv-chat-send-btn:hover:not(:disabled) {
  background: var(--admin-accent-hover);
}

.conv-chat-send-btn:disabled {
  background: var(--admin-input-background);
  color: var(--admin-muted-foreground);
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .conv-chat-widget {
    bottom: 16px;
    right: 16px;
    left: 16px;
    align-items: stretch;
  }

  .conv-chat-launcher {
    align-self: flex-end;
  }

  .conv-chat-window {
    width: auto;
    max-width: none;
  }

  .conv-chat-messages {
    max-height: min(60vh, 440px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .conv-chat-window,
  .conv-chat-message {
    animation: none;
  }

  .conv-chat-typing span {
    animation: none;
    opacity: 0.7;
  }
}
/* Hint text for form fields */
.form-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.8125rem;
  color: var(--admin-muted-foreground);
  line-height: 1.4;
}
