:root {
  color-scheme: light;
  --bs-primary: #f97316;
  --bs-primary-rgb: 249, 115, 22;
  --bs-body-bg: #fff7ed;
  --bs-body-color: #1f2937;
  --rp-bg: #fff7ed;
  --rp-panel: #ffffff;
  --rp-panel-soft: #fffaf4;
  --rp-ink: #1f2937;
  --rp-muted: #6b7280;
  --rp-line: #fed7aa;
  --rp-line-strong: #fdba74;
  --rp-accent: #f97316;
  --rp-accent-strong: #ea580c;
  --rp-accent-soft: #ffedd5;
  --rp-danger: #be123c;
  --rp-success: #16a34a;
  --rp-blue: #2563eb;
  --rp-shadow: 0 18px 45px rgba(154, 52, 18, 0.13);
  --rp-shadow-soft: 0 10px 30px rgba(154, 52, 18, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(251, 146, 60, 0.22), transparent 34rem),
    linear-gradient(180deg, #fff7ed 0%, #ffffff 48%, #fff7ed 100%);
  color: var(--rp-ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
}

.auth-gate {
  grid-column: 1 / -1;
  min-height: 100vh;
  padding: 28px;
  display: grid;
  place-items: center;
}

.auth-gate-card {
  width: min(1080px, 100%);
  min-height: 620px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) 420px;
  overflow: hidden;
  border: 1px solid rgba(251, 146, 60, 0.28);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--rp-shadow);
}

.auth-gate-copy {
  padding: clamp(28px, 5vw, 56px);
  display: grid;
  align-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(251, 146, 60, 0.22), transparent 18rem),
    linear-gradient(135deg, #ffffff 0%, #fff7ed 100%);
}

.auth-brand {
  width: fit-content;
  margin-bottom: 28px;
}

.auth-gate-copy h1 {
  max-width: 620px;
  margin-bottom: 14px;
  color: #7c2d12;
  font-size: clamp(2.1rem, 4vw, 4.4rem);
  font-weight: 920;
  line-height: 1.02;
  letter-spacing: 0;
}

.auth-gate-copy p {
  max-width: 560px;
  color: var(--rp-muted);
  font-size: 1.08rem;
  line-height: 1.7;
}

.auth-gate-form {
  padding: clamp(24px, 4vw, 42px);
  display: grid;
  align-content: center;
  gap: 12px;
  border-left: 1px solid var(--rp-line);
  background: rgba(255, 255, 255, 0.92);
}

.auth-gate-form h2 {
  margin-bottom: 4px;
  font-size: 1.7rem;
}

.auth-gate-form p {
  margin-bottom: 8px;
  color: var(--rp-muted);
  line-height: 1.55;
}

.auth-gate-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.auth-error {
  padding: 10px 12px;
  border: 1px solid #fecdd3;
  border-radius: 8px;
  background: #fff1f2;
  color: var(--rp-danger);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.45;
}

.auth-notice {
  padding: 10px 12px;
  border: 1px solid var(--rp-line-strong);
  border-radius: 8px;
  background: var(--rp-panel-soft);
  color: var(--rp-ink);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.45;
}

.auth-gate-links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--rp-accent);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

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

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.sidebar {
  min-height: 100vh;
  position: sticky;
  top: 0;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: rgba(255, 255, 255, 0.86);
  border-right: 1px solid rgba(251, 146, 60, 0.28);
  box-shadow: 8px 0 30px rgba(154, 52, 18, 0.06);
  backdrop-filter: blur(16px);
  z-index: 2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--rp-line);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff 0%, #fff7ed 100%);
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--rp-accent), #fb923c);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(249, 115, 22, 0.3);
}

.brand strong,
.brand span,
.auth-panel strong,
.auth-panel span {
  display: block;
}

.brand strong {
  font-size: 1.02rem;
}

.brand span,
.status-panel span,
.auth-panel span,
.topbar p,
.section-head p,
.chat-header p,
.content-toolbar p {
  color: var(--rp-muted);
  font-size: 0.92rem;
}

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

.step {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  background: transparent;
  color: #7c2d12;
  text-align: left;
  font-weight: 700;
  transition: 160ms ease;
}

.step:hover {
  background: var(--rp-accent-soft);
  color: var(--rp-accent-strong);
}

.step.is-active {
  background: var(--rp-accent);
  border-color: var(--rp-accent);
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(249, 115, 22, 0.25);
}

.status-panel,
.auth-panel {
  border: 1px solid var(--rp-line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--rp-shadow-soft);
}

.status-panel {
  margin-top: auto;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-panel {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.auth-form {
  display: grid;
  gap: 9px;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.is-hidden {
  display: none !important;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f59e0b;
  flex: 0 0 auto;
}

.status-dot.is-ok {
  background: var(--rp-success);
}

.app-shell {
  min-width: 0;
  padding: 28px;
}

.topbar {
  min-height: 132px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  padding: 24px;
  border: 1px solid rgba(251, 146, 60, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96) 0%, rgba(255, 237, 213, 0.96) 100%),
    linear-gradient(135deg, #ffffff, #fff7ed);
  box-shadow: var(--rp-shadow);
}

.topbar h1 {
  max-width: 760px;
  margin-bottom: 8px;
  font-size: clamp(1.85rem, 3vw, 3rem);
  font-weight: 900;
  letter-spacing: 0;
  color: #7c2d12;
}

.topbar p {
  max-width: 780px;
  margin-bottom: 0;
  font-size: 1rem;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h2 {
  margin-bottom: 6px;
  color: #7c2d12;
  font-size: 1.4rem;
  font-weight: 850;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
  color: #9a3412;
  font-size: 1rem;
  font-weight: 850;
}

.view {
  display: none;
  padding: 20px;
  border: 1px solid rgba(251, 146, 60, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: var(--rp-shadow);
}

.view.is-visible {
  display: block;
}

.section-head,
.content-toolbar,
.chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.section-head {
  margin-bottom: 18px;
}

.primary-button,
.ghost-button,
.small-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
  transition: 160ms ease;
}

.primary-button {
  border: 1px solid var(--rp-accent);
  background: var(--rp-accent);
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(249, 115, 22, 0.22);
}

.primary-button:hover {
  background: var(--rp-accent-strong);
  border-color: var(--rp-accent-strong);
  transform: translateY(-1px);
}

.ghost-button,
.small-button {
  border: 1px solid var(--rp-line-strong);
  background: #ffffff;
  color: #9a3412;
}

.ghost-button:hover,
.small-button:hover {
  background: var(--rp-accent-soft);
  border-color: var(--rp-accent);
  color: var(--rp-accent-strong);
}

.onboarding-view {
  overflow: hidden;
  padding: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(255, 250, 244, 0.96) 100%);
}

.onboarding-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
  padding: 24px;
  border-bottom: 1px solid var(--rp-line);
  background:
    radial-gradient(circle at 90% 0%, rgba(251, 146, 60, 0.2), transparent 22rem),
    linear-gradient(135deg, #ffffff 0%, #fff7ed 100%);
}

.onboarding-copy {
  max-width: 760px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-bottom: 10px;
  padding: 4px 10px;
  border: 1px solid var(--rp-line-strong);
  border-radius: 999px;
  background: #ffffff;
  color: var(--rp-accent-strong);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.onboarding-copy h2 {
  margin-bottom: 8px;
  font-size: clamp(1.65rem, 2.6vw, 2.35rem);
  line-height: 1.1;
}

.onboarding-copy p {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--rp-muted);
  font-size: 1rem;
  line-height: 1.65;
}

.onboarding-save {
  align-self: stretch;
  display: grid;
  align-content: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(249, 115, 22, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 12px 30px rgba(154, 52, 18, 0.08);
}

.save-note strong,
.save-note span {
  display: block;
}

.save-note strong {
  color: #7c2d12;
}

.save-note span {
  color: var(--rp-muted);
  font-size: 0.9rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 20px;
}

fieldset {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--rp-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 28px rgba(154, 52, 18, 0.07);
}

.setting-card-wide {
  grid-column: span 2;
}

legend {
  width: auto;
  float: none;
  margin-bottom: 12px;
  padding: 0;
  color: #9a3412;
  font-size: 0.96rem;
  font-weight: 850;
}

legend span {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-right: 8px;
  border-radius: 999px;
  background: var(--rp-accent-soft);
  color: var(--rp-accent-strong);
  font-size: 0.78rem;
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(142px, 1fr));
  gap: 8px;
}

.chip {
  position: relative;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--rp-line);
  border-radius: 8px;
  background: #ffffff;
  color: #7c2d12;
  font-weight: 700;
  transition: 140ms ease;
}

.chip:hover {
  border-color: var(--rp-accent);
  background: #fffaf4;
  transform: translateY(-1px);
}

.chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chip:has(input:checked) {
  border-color: var(--rp-accent);
  background: linear-gradient(180deg, #ffffff 0%, #fff7ed 100%);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.14);
}

.chip-check {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border: 2px solid var(--rp-line-strong);
  border-radius: 999px;
  background: #ffffff;
}

.chip input[type="checkbox"]:checked + .chip-check,
.chip input[type="radio"]:checked + .chip-check {
  border-color: var(--rp-accent);
  background:
    radial-gradient(circle, #ffffff 0 30%, transparent 34%),
    var(--rp-accent);
}

.chip-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.chip-text strong {
  font-size: 0.94rem;
  line-height: 1.2;
}

.chip-text small {
  color: var(--rp-muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.inline-controls,
.character-builder {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.profile-controls {
  margin: 0 20px 20px;
  padding: 16px;
  border: 1px solid var(--rp-line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(154, 52, 18, 0.06);
}

label {
  display: grid;
  gap: 7px;
  color: #9a3412;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--rp-line-strong);
  border-radius: 8px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--rp-ink);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--rp-accent);
  box-shadow: 0 0 0 0.22rem rgba(249, 115, 22, 0.16);
}

.content-toolbar {
  margin-bottom: 14px;
  padding: 15px;
  border: 1px solid var(--rp-line);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff 0%, #fff7ed 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.story-toolbar {
  margin-top: 18px;
}

.generation-actions {
  display: grid;
  width: min(100%, 440px);
  gap: 10px;
  flex: 0 1 440px;
}

.generation-request {
  min-width: 0;
}

.generation-request textarea {
  min-height: 82px;
  padding: 10px 12px;
  line-height: 1.45;
  resize: vertical;
}

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

.selection-note,
.selection-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid rgba(249, 115, 22, 0.32);
  border-radius: 999px;
  background: #fff7ed;
  color: var(--rp-accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.selection-note {
  padding: 0 10px;
}

.selection-badge {
  padding: 0 8px;
}

.pack-grid,
.story-grid,
.character-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.pack-grid {
  margin-bottom: 16px;
}

.pack-card,
.story-card,
.character-card,
.metric,
.memory-group {
  border: 1px solid var(--rp-line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 25px rgba(154, 52, 18, 0.08);
}

.pack-card,
.story-card,
.character-card {
  min-height: 220px;
  padding: 15px;
  display: grid;
  gap: 10px;
}

.pack-card {
  min-height: 190px;
  background: linear-gradient(180deg, #ffffff 0%, #fffaf4 100%);
}

.pack-card.is-selected,
.story-card.is-selected,
.character-card.is-selected {
  border-color: var(--rp-accent);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.18), var(--rp-shadow-soft);
}

.pack-card p,
.story-card p,
.character-card p {
  margin-bottom: 0;
  color: var(--rp-muted);
  line-height: 1.45;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--rp-accent-soft);
  color: #9a3412;
  font-size: 0.78rem;
  font-weight: 850;
}

.card-actions {
  margin-top: auto;
  display: flex;
  gap: 8px;
}

.small-button {
  min-height: 34px;
  padding: 0 10px;
}

.small-button.is-active {
  border-color: var(--rp-accent);
  background: var(--rp-accent);
  color: #ffffff;
}

.start-row {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
}

.chat-panel,
.memory-panel {
  min-width: 0;
  border: 1px solid var(--rp-line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--rp-shadow-soft);
}

.chat-header {
  padding: 15px;
  border-bottom: 1px solid var(--rp-line);
}

.message-list {
  height: 520px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 15px;
  background: linear-gradient(180deg, #fffaf4 0%, #ffffff 100%);
}

.message {
  max-width: 78%;
  padding: 10px 12px;
  border: 1px solid var(--rp-line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(154, 52, 18, 0.07);
}

.message.user {
  justify-self: end;
  border-color: var(--rp-accent);
  background: var(--rp-accent);
  color: #ffffff;
}

.message strong {
  display: block;
  margin-bottom: 5px;
}

.message small {
  display: block;
  margin-top: 6px;
  color: var(--rp-muted);
  line-height: 1.35;
}

.message.user small {
  color: rgba(255, 255, 255, 0.78);
}

.composer {
  padding: 12px;
  border-top: 1px solid var(--rp-line);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.memory-panel {
  padding: 15px;
}

.conversation-list {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.conversation-item {
  width: 100%;
  border: 1px solid var(--rp-line);
  border-radius: 8px;
  padding: 10px;
  background: var(--rp-panel-soft);
  color: var(--rp-ink);
  text-align: left;
  transition: 160ms ease;
}

.conversation-item:hover,
.conversation-item.is-active {
  border-color: var(--rp-accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.13);
}

.conversation-item strong,
.conversation-item span {
  display: block;
}

.conversation-item strong {
  margin-bottom: 4px;
  color: #9a3412;
}

.conversation-item span {
  color: var(--rp-muted);
  font-size: 0.82rem;
}

.memory-list,
.relationship-grid {
  display: grid;
  gap: 10px;
}

.memory-list {
  margin-bottom: 20px;
}

.memory-group {
  padding: 11px;
  background: var(--rp-panel-soft);
}

.memory-group strong {
  display: block;
  margin-bottom: 6px;
  color: #9a3412;
}

.memory-group ul {
  margin: 0;
  padding-left: 18px;
  color: var(--rp-muted);
}

.meter {
  display: grid;
  gap: 5px;
}

.meter span {
  display: flex;
  justify-content: space-between;
  color: var(--rp-muted);
  font-size: 0.9rem;
}

.bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--rp-accent-soft);
}

.bar i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--rp-accent), #fb923c);
}

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

.admin-metrics {
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  padding: 14px;
}

.metric span {
  color: var(--rp-muted);
  font-size: 0.86rem;
}

.metric strong {
  display: block;
  margin-top: 4px;
  color: #9a3412;
  font-size: 1.48rem;
}

pre {
  padding: 14px;
  overflow: auto;
  border-radius: 8px;
  background: #1c1917;
  color: #fff7ed;
  line-height: 1.5;
}

.prompt-output {
  max-height: 460px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 380px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #7c2d12;
  color: #ffffff;
  box-shadow: var(--rp-shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: 180ms ease;
  pointer-events: none;
  z-index: 10;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  body {
    grid-template-columns: 1fr;
  }

  .auth-gate-card {
    grid-template-columns: 1fr;
  }

  .auth-gate-form {
    border-left: 0;
    border-top: 1px solid var(--rp-line);
  }

  .sidebar {
    min-height: auto;
    position: static;
  }

  .steps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .step {
    text-align: center;
  }

  .status-panel {
    margin-top: 0;
  }

  .onboarding-hero {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .generation-actions {
    width: 100%;
    flex-basis: auto;
  }

  .pack-grid,
  .story-grid,
  .character-grid,
  .chat-layout,
  .api-grid,
  .admin-metrics {
    grid-template-columns: 1fr;
  }

  .message-list {
    height: 430px;
  }
}

@media (max-width: 720px) {
  .auth-gate {
    padding: 16px;
  }

  .auth-gate-card {
    min-height: auto;
  }

  .auth-gate-actions {
    grid-template-columns: 1fr;
  }

  .app-shell,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .section-head,
  .chat-header,
  .content-toolbar {
    display: grid;
  }

  .topbar {
    min-height: auto;
    padding: 18px;
  }

  .settings-grid,
  .inline-controls,
  .character-builder,
  .steps,
  .auth-actions {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    padding: 16px;
  }

  .setting-card-wide {
    grid-column: span 1;
  }

  .profile-controls {
    margin: 0 16px 16px;
  }

  .message {
    max-width: 92%;
  }

  .composer {
    grid-template-columns: 1fr;
  }
}

/* ---- API reference (tab API) ---- */
.api-head-actions {
  display: flex;
  gap: 8px;
}

.api-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.api-overview-block {
  padding: 14px 16px;
  border: 1px solid var(--rp-line);
  border-radius: 8px;
  background: var(--rp-panel-soft);
}

.api-overview-block h4 {
  margin: 0 0 8px;
  color: #9a3412;
  font-size: 0.95rem;
  font-weight: 850;
}

.api-overview-block ul {
  margin: 0;
  padding-left: 18px;
  color: var(--rp-muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.api-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.api-toolbar input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--rp-line);
  border-radius: 8px;
  background: #ffffff;
}

.api-count {
  color: var(--rp-muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

.api-group {
  margin-bottom: 26px;
}

.api-group > h3 {
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rp-line);
}

.api-endpoint {
  margin-bottom: 12px;
  padding: 14px 16px;
  border: 1px solid var(--rp-line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--rp-shadow-soft);
}

.api-endpoint-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.api-method {
  padding: 3px 9px;
  border-radius: 6px;
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.method-get { background: var(--rp-blue); }
.method-post { background: var(--rp-success); }
.method-patch { background: var(--rp-accent-strong); }
.method-delete { background: var(--rp-danger); }

.api-path {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--rp-ink);
}

.api-auth,
.api-rate {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
}

.auth-public { background: #ecfdf5; color: #047857; }
.auth-user { background: #eff6ff; color: #1d4ed8; }
.auth-admin { background: #fff1f2; color: var(--rp-danger); }

.api-rate {
  background: var(--rp-accent-soft);
  color: #9a3412;
}

.api-summary {
  margin-bottom: 10px;
  color: var(--rp-muted);
  line-height: 1.55;
}

.api-endpoint h4 {
  margin: 12px 0 6px;
  color: #9a3412;
  font-size: 0.85rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.api-fields {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.api-fields th,
.api-fields td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--rp-line);
  text-align: left;
  vertical-align: top;
}

.api-fields th {
  color: var(--rp-muted);
  font-weight: 700;
}

.api-fields .req {
  color: var(--rp-danger);
  font-weight: 700;
}

.api-response pre {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--rp-panel-soft);
  overflow-x: auto;
  font-size: 0.84rem;
}

.api-notes {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--rp-muted);
  font-size: 0.86rem;
  line-height: 1.6;
}

/* ---- Character media (character-centric spec) ---- */
.character-media {
  margin: -4px -4px 12px;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  background: var(--rp-panel-soft);
}

.character-media img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.character-media-empty {
  height: 120px;
  display: grid;
  place-items: center;
  color: var(--rp-muted);
  font-size: 0.85rem;
  border: 1px dashed var(--rp-line);
}

.character-video {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
}

.character-agegender {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--rp-muted);
}

.pill.media-ready { background: #ecfdf5; color: #047857; }
.pill.media-generating { background: var(--rp-accent-soft); color: #9a3412; }
.pill.media-pending { background: #eff6ff; color: #1d4ed8; }
.pill.media-failed { background: #fff1f2; color: var(--rp-danger); }
