:root {
  --bg-top: #fff7ef;
  --bg-bottom: #f4efe8;
  --surface: rgba(255, 251, 246, 0.86);
  --surface-strong: rgba(255, 255, 255, 0.95);
  --ink: #172538;
  --muted: #617182;
  --accent: #db6a45;
  --accent-strong: #b84d2b;
  --secondary: #2f7d75;
  --border: rgba(23, 37, 56, 0.1);
  --shadow: 0 24px 64px rgba(23, 37, 56, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --mono: "IBM Plex Mono", "SFMono-Regular", monospace;
  --sans: "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, rgba(219, 106, 69, 0.22), transparent 28%),
    radial-gradient(circle at 92% 18%, rgba(47, 125, 117, 0.16), transparent 24%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(28px);
  pointer-events: none;
  opacity: 0.7;
}

body::before {
  width: 280px;
  height: 280px;
  left: -80px;
  top: 60px;
  background: rgba(255, 209, 176, 0.8);
}

body::after {
  width: 360px;
  height: 360px;
  right: -120px;
  bottom: 20px;
  background: rgba(205, 235, 228, 0.78);
}

code,
.placeholder-token,
.eyebrow,
.status-pill,
.info-label,
.section-kicker {
  font-family: var(--mono);
}

.app-shell {
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 40px);
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
  padding: 18px 22px;
  background: rgba(255, 251, 246, 0.82);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.app-topbar__brand {
  display: grid;
  gap: 4px;
}

.app-topbar__title {
  font-size: 1rem;
  letter-spacing: 0.01em;
}

.app-primary-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.app-primary-nav__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(23, 37, 56, 0.08);
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background-color 180ms ease,
    color 180ms ease,
    border-color 180ms ease;
}

.app-primary-nav__link:hover {
  transform: translateY(-1px);
  color: var(--ink);
  box-shadow: 0 12px 24px rgba(23, 37, 56, 0.08);
}

.app-primary-nav__link--active {
  color: var(--ink);
  border-color: rgba(23, 37, 56, 0.12);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 245, 236, 0.92));
}

.page-grid {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.workspace {
  display: grid;
  gap: 24px;
}

.panel {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent 42%);
  pointer-events: none;
}

.info-panel,
.editor-panel,
.generator-panel,
.answer-panel {
  padding: 28px;
}

.answer-panel {
  padding: 0;
}

.answer-panel-shell {
  display: grid;
  gap: 18px;
  padding: 28px;
}

.eyebrow-row,
.section-heading,
.generator-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.status-pill {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--secondary);
  background: rgba(47, 125, 117, 0.12);
}

.info-panel h1,
.section-heading h2,
.chips-output h3 {
  margin: 0;
}

.lead,
.info-card p,
.status-text,
.empty-state {
  color: var(--muted);
  line-height: 1.6;
}

.info-grid {
  display: grid;
  gap: 14px;
}

.intro-block {
  margin-top: 22px;
  display: grid;
  gap: 16px;
}

.page-toggle {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(23, 37, 56, 0.08);
}

.page-toggle-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
  transition:
    background-color 180ms ease,
    color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.page-toggle-link:hover {
  transform: translateY(-1px);
  color: var(--ink);
}

.page-toggle-link--active {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 22px rgba(23, 37, 56, 0.08);
}

.info-panel-title {
  font-size: clamp(1.2rem, 2vw, 1.6rem);
  line-height: 1.1;
  letter-spacing: 0.01em;
}

.lead {
  margin: 0;
}

.info-grid {
  margin-top: 28px;
}

.info-card,
.placeholder-guide,
.placeholder-guide-item,
.chips-output {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(23, 37, 56, 0.08);
}

.info-label,
.section-kicker {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.info-label,
.section-kicker {
  color: var(--accent-strong);
}

.info-card strong {
  display: block;
  margin: 8px 0 10px;
  font-size: 1rem;
}

.placeholder-guide {
  background: linear-gradient(180deg, rgba(255, 245, 236, 0.95), rgba(255, 251, 246, 0.72));
}

.placeholder-title {
  margin: 0 0 14px;
  font-weight: 700;
}

.placeholder-guide-list {
  display: grid;
  gap: 12px;
}

.placeholder-token,
.result-chip {
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.85rem;
}

.placeholder-token {
  display: inline-flex;
  margin-bottom: 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(23, 37, 56, 0.08);
}

.placeholder-guide-item {
  padding: 16px;
  background: rgba(255, 255, 255, 0.74);
}

.placeholder-guide-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.docs-link,
.primary-button,
.accent-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background-color 180ms ease,
    color 180ms ease,
    border-color 180ms ease;
}

.docs-link {
  margin-top: 22px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(23, 37, 56, 0.1);
}

.primary-button {
  border: 1px solid rgba(23, 37, 56, 0.1);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.88);
}

.accent-button {
  border: 0;
  color: #fff9f4;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.docs-link:hover,
.primary-button:hover,
.accent-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(23, 37, 56, 0.1);
}

.primary-button:disabled,
.accent-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.editor-panel,
.generator-panel {
  display: grid;
  gap: 18px;
}

.panel-lead {
  margin: 0;
}

.field-label {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
}

.field-group {
  display: grid;
  gap: 10px;
}

.action-stack {
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 12px;
}

.prompt-textarea,
.product-input {
  width: 100%;
  border: 1px solid rgba(23, 37, 56, 0.12);
  border-radius: 20px;
  background: var(--surface-strong);
  color: var(--ink);
  font: inherit;
  outline: none;
}

.prompt-textarea {
  min-height: 460px;
  padding: 20px;
  resize: vertical;
  line-height: 1.55;
}

.product-input {
  min-width: 180px;
  padding: 14px 16px;
}

.compact-textarea {
  min-height: 300px;
}

.field-hint {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

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

.stat-card strong {
  font-size: clamp(1.4rem, 2vw, 2rem);
}

.stat-count {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 2.4rem;
}

.stat-count--loading {
  color: transparent;
}

.stat-count--loading::after {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 1.4rem;
  height: 1.4rem;
  margin-top: -0.7rem;
  border-radius: 50%;
  border: 2px solid rgba(23, 37, 56, 0.14);
  border-top-color: var(--accent);
  border-right-color: var(--secondary);
  animation: stat-spinner 0.8s linear infinite;
}

.whitelist-editor-grid,
.whitelist-browser-grid {
  display: grid;
  gap: 18px;
}

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

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

.whitelist-section {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(23, 37, 56, 0.08);
}

.whitelist-section--full {
  min-width: 0;
}

.whitelist-section__header {
  display: grid;
  gap: 6px;
}

.whitelist-section__header h3,
.whitelist-section__header .status-text {
  margin: 0;
}

.whitelist-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
  min-height: 84px;
}

.whitelist-list--readonly {
  max-height: 300px;
  overflow: auto;
  padding-right: 4px;
  scrollbar-width: thin;
}

.whitelist-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(23, 37, 56, 0.08);
  box-shadow: 0 10px 22px rgba(23, 37, 56, 0.06);
}

.whitelist-item--readonly {
  background: linear-gradient(135deg, rgba(219, 106, 69, 0.14), rgba(47, 125, 117, 0.12));
}

.whitelist-item__label {
  max-width: 100%;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.whitelist-item__remove {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(219, 106, 69, 0.14);
  color: var(--accent-strong);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background-color 180ms ease,
    color 180ms ease;
}

.whitelist-item__remove:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(23, 37, 56, 0.08);
  background: rgba(219, 106, 69, 0.2);
}

.whitelist-item__remove:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.reasoning-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

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

.reasoning-toggle__track {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: rgba(23, 37, 56, 0.14);
  border: 1px solid rgba(23, 37, 56, 0.1);
  transition:
    background-color 180ms ease,
    border-color 180ms ease;
}

.reasoning-toggle__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fffdfa;
  box-shadow: 0 4px 10px rgba(23, 37, 56, 0.14);
  transition: transform 180ms ease;
}

.reasoning-toggle input:checked + .reasoning-toggle__track {
  background: rgba(47, 125, 117, 0.24);
  border-color: rgba(47, 125, 117, 0.38);
}

.reasoning-toggle input:checked + .reasoning-toggle__track::after {
  transform: translateX(20px);
}

.reasoning-toggle input:focus-visible + .reasoning-toggle__track {
  box-shadow: 0 0 0 4px rgba(47, 125, 117, 0.14);
}

.reasoning-toggle input:disabled + .reasoning-toggle__track {
  opacity: 0.55;
}

.reasoning-toggle input:disabled ~ .reasoning-toggle__text {
  opacity: 0.55;
}

.prompt-textarea:focus,
.product-input:focus,
.docs-link:focus-visible,
.primary-button:focus-visible,
.accent-button:focus-visible,
.app-primary-nav__link:focus-visible,
.whitelist-item__remove:focus-visible {
  border-color: rgba(219, 106, 69, 0.55);
  box-shadow: 0 0 0 4px rgba(219, 106, 69, 0.14);
}

.status-text {
  margin: 0;
  min-height: 1.6em;
}

.status-text--error {
  color: var(--accent-strong);
}

.chips-output {
  display: grid;
  gap: 14px;
  min-height: 150px;
}

.chips-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
}

#exampleChips {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

#exampleChips .result-chip-button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.result-chip {
  display: grid;
  gap: 8px;
  align-items: start;
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(219, 106, 69, 0.14), rgba(47, 125, 117, 0.12));
  border: 1px solid rgba(23, 37, 56, 0.08);
  color: var(--ink);
}

#chipsResult .result-chip {
  flex: 1 1 calc(50% - 6px);
  max-width: calc(50% - 6px);
  min-width: 0;
}

.result-chip__display,
.result-chip__query {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.result-chip__display {
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.35;
}

.result-chip__query {
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--muted);
}

.result-chip-button {
  appearance: none;
  font: inherit;
  cursor: pointer;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.result-chip-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(23, 37, 56, 0.08);
}

.result-chip-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.chat-output {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(23, 37, 56, 0.08);
  min-height: 220px;
}

.chat-output-header {
  display: grid;
  gap: 6px;
}

.chat-output-header h3,
.chat-output-note {
  margin: 0;
}

.chat-output-note {
  color: var(--muted);
  line-height: 1.5;
}

.chat-messages {
  display: grid;
  gap: 12px;
  align-content: start;
}

.chat-message {
  width: fit-content;
  max-width: min(78%, 48rem);
  padding: 14px 16px;
  border-radius: 18px;
  box-shadow: 0 10px 24px rgba(23, 37, 56, 0.07);
}

.chat-message p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.55;
}

.chat-message--user {
  justify-self: end;
  background: linear-gradient(135deg, #df6847, #b84d2b);
  color: #fff8f3;
  border-bottom-right-radius: 8px;
}

.chat-message--assistant {
  justify-self: start;
  background: rgba(255, 255, 255, 0.92);
  border-bottom-left-radius: 8px;
}

.chat-message--pending {
  position: relative;
}

.chat-message--pending::after {
  content: "";
  position: absolute;
  left: 16px;
  bottom: 10px;
  width: 48px;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(219, 106, 69, 0.25), rgba(219, 106, 69, 0.88), rgba(219, 106, 69, 0.25));
  background-size: 160% 100%;
  animation: pulse-line 1s linear infinite;
}

.empty-state {
  margin: 0;
}

@keyframes pulse-line {
  from {
    background-position: 0 0;
  }

  to {
    background-position: 160% 0;
  }
}

@keyframes stat-spinner {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1040px) {
  .page-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid,
  .whitelist-editor-grid,
  .whitelist-browser-grid {
    grid-template-columns: 1fr;
  }

  #chipsResult .result-chip {
    flex-basis: 100%;
  }
}

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

  .app-topbar {
    padding: 16px;
    border-radius: 24px;
  }

  .panel,
  .info-panel,
  .editor-panel,
  .generator-panel,
  .answer-panel {
    border-radius: 24px;
  }

  .section-heading,
  .generator-controls,
  .eyebrow-row,
  .page-toggle,
  .app-topbar,
  .app-primary-nav,
  .button-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .accent-button,
  .primary-button,
  .app-primary-nav__link,
  .docs-link {
    width: 100%;
  }

  .product-input {
    min-width: 0;
  }

  .whitelist-item {
    width: 100%;
    justify-content: space-between;
  }

  .chat-message {
    max-width: 88%;
  }
}
