:root {
  --bg: #f5f1e8;
  --surface: rgba(255, 252, 247, 0.9);
  --surface-strong: #fffdf9;
  --surface-muted: rgba(255, 252, 247, 0.62);
  --ink: #1d1c19;
  --muted: #655e54;
  --line: rgba(29, 28, 25, 0.12);
  --line-strong: rgba(29, 28, 25, 0.2);
  --accent: #123c34;
  --accent-soft: rgba(18, 60, 52, 0.1);
  --warn: #8a3b1f;
  --warn-soft: rgba(138, 59, 31, 0.08);
  --danger: #8e2222;
  --shadow: 0 16px 40px rgba(34, 25, 12, 0.08);
  --radius: 24px;
  --radius-sm: 14px;
  --font-sans: "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body.app-shell {
  background:
    radial-gradient(circle at top left, rgba(18, 60, 52, 0.08), transparent 32%),
    linear-gradient(180deg, #f7f2e9 0%, #f3efe7 100%);
  color: var(--ink);
  font-family: var(--font-sans);
}

.shell-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(18px);
  background: rgba(247, 242, 233, 0.84);
  border-bottom: 1px solid var(--line);
}

.shell-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
}

.shell-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.shell-brand-mark {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
}

.shell-header-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.shell-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.demo-app.is-loading [data-demo-shell] {
  opacity: 0.62;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.demo-shell,
.auth-layout {
  display: grid;
  gap: 1rem;
}

.demo-topbar,
.scenario-shell,
.workspace-shell,
.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.demo-topbar,
.scenario-shell,
.workspace-shell {
  padding: 1rem 1.1rem;
}

.demo-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.status-cluster,
.hint-list,
.suggestion-row,
.conversation-strip,
.kpi-row,
.run-stack {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.status-chip,
.kpi-pill,
.ghost-chip,
.mini-badge,
.guide-inline-step {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2rem;
  padding: 0.36rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  font-size: 0.88rem;
  color: var(--muted);
}

.status-chip-strong,
.mini-badge-strong,
.mini-badge-active,
.flow-toggle-item.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.mini-badge-success {
  background: rgba(42, 117, 88, 0.12);
  border-color: rgba(42, 117, 88, 0.18);
  color: #22624a;
}

.ghost-chip {
  background: rgba(255, 255, 255, 0.45);
}

.ghost-chip-button,
.conversation-chip,
.link-button,
.flow-toggle-item {
  cursor: pointer;
  border: 1px solid var(--line);
}

.ghost-chip-button,
.conversation-chip,
.link-button {
  background: transparent;
}

.link-button {
  padding: 0;
  color: var(--accent);
  border: 0;
  text-align: left;
}

.access-popover summary,
.technical-panel summary {
  cursor: pointer;
  list-style: none;
}

.access-popover summary::-webkit-details-marker,
.technical-panel summary::-webkit-details-marker {
  display: none;
}

.access-popover {
  position: relative;
}

.access-popover summary {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.36rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  font-size: 0.88rem;
  color: var(--ink);
}

.popover-body {
  position: absolute;
  right: 0;
  top: calc(100% + 0.55rem);
  display: grid;
  gap: 0.55rem;
  min-width: 20rem;
  padding: 0.9rem;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 252, 247, 0.98);
  box-shadow: var(--shadow);
}

.credential-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.88rem;
}

.credential-row code {
  padding: 0.14rem 0.45rem;
  border-radius: 8px;
  background: rgba(18, 60, 52, 0.08);
  color: var(--accent);
}

.guide-inline {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.guide-inline-step {
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink);
}

.section-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-row-tight {
  margin-bottom: 1.15rem;
}

.section-kicker,
.panel-kicker,
.auth-kicker {
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-title,
.panel-title,
.auth-title,
.auth-subtitle {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-title {
  font-size: clamp(1.35rem, 3vw, 1.85rem);
}

.section-subtitle,
.scenario-purpose,
.auth-copy,
.compact-note,
.empty-inline {
  margin: 0;
  color: var(--muted);
}

.scenario-grid,
.workspace-grid,
.technical-grid,
.danger-grid,
.auth-grid {
  display: grid;
  gap: 1rem;
}

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

.workspace-grid {
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
}

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

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

.scenario-card,
.panel-card,
.technical-card,
.credential-card {
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 6px);
  background: var(--surface-strong);
}

.scenario-card,
.panel-card,
.technical-card {
  padding: 1rem;
}

.scenario-card.is-muted {
  opacity: 0.72;
}

.scenario-card.is-active,
.panel-card-primary {
  border-color: rgba(18, 60, 52, 0.25);
  background: linear-gradient(180deg, rgba(18, 60, 52, 0.05), rgba(255, 253, 249, 0.98));
}

.scenario-head,
.panel-head,
.credential-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.scenario-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.stack-form {
  display: grid;
  gap: 0.8rem;
}

.chat-stage {
  display: grid;
  gap: 0.85rem;
}

.chat-thread {
  display: grid;
  gap: 0.8rem;
  min-height: 24rem;
  max-height: 34rem;
  padding: 0.35rem 0.15rem 0.35rem 0;
  overflow-y: auto;
}

.chat-thread-note {
  color: var(--muted);
  font-size: 0.8rem;
}

.chat-bubble {
  display: grid;
  gap: 0.55rem;
  max-width: 88%;
  padding: 0.85rem 0.95rem;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 24px rgba(34, 25, 12, 0.04);
}

.chat-bubble-user {
  margin-left: auto;
  background: rgba(18, 60, 52, 0.1);
  border-color: rgba(18, 60, 52, 0.15);
}

.chat-bubble-assistant {
  margin-right: auto;
}

.chat-bubble-meta {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

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

.chat-empty-card {
  min-height: 14rem;
}

.chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: end;
}

.chat-input {
  min-height: 3.5rem;
  max-height: 12rem;
  resize: vertical;
  border-radius: 18px;
  border-color: var(--line-strong);
}

.typing-loader {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 1.35rem;
}

.typing-loader span {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.28;
  animation: chat-typing 1s infinite ease-in-out;
}

.typing-loader span:nth-child(2) {
  animation-delay: 0.12s;
}

.typing-loader span:nth-child(3) {
  animation-delay: 0.24s;
}

.field-label {
  font-size: 0.86rem;
  font-weight: 600;
}

.demo-textarea {
  min-height: 8rem;
  resize: vertical;
  border-radius: 16px;
  border-color: var(--line-strong);
}

.button-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.answer-card,
.empty-card {
  display: grid;
  gap: 0.9rem;
  min-height: 100%;
}

.empty-card {
  place-content: center;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(18, 60, 52, 0.04);
  color: var(--muted);
}

.result-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.result-copy {
  margin: 0;
  font-size: 1.06rem;
  line-height: 1.55;
}

.token-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.token-strip-soft .token-box {
  background: rgba(255, 255, 255, 0.48);
}

.token-box,
.mini-stat {
  padding: 0.8rem 0.9rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(18, 60, 52, 0.06);
}

.token-label,
.mini-stat span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.token-box strong,
.mini-stat strong {
  font-size: 1.1rem;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.technical-stack {
  display: grid;
  gap: 0.9rem;
  margin-top: 1rem;
}

.technical-panel {
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 6px);
  background: rgba(255, 252, 247, 0.78);
}

.technical-panel summary {
  padding: 0.95rem 1rem;
  font-weight: 700;
}

.technical-panel[open] {
  background: rgba(255, 252, 247, 0.96);
}

.technical-panel[open] summary {
  border-bottom: 1px solid var(--line);
}

.technical-panel[open] .technical-grid,
.technical-panel[open] .danger-grid {
  padding: 1rem;
}

.danger-panel {
  border-color: rgba(142, 34, 34, 0.2);
  background: var(--warn-soft);
}

.compact-list {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.55rem;
}

.timeline-list li {
  padding-bottom: 0.2rem;
}

.evidence-stack {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

.flow-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  padding: 0.3rem;
  border-radius: 999px;
  background: rgba(18, 60, 52, 0.08);
}

.flow-toggle-item {
  min-width: 9rem;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}

.auth-layout {
  max-width: 72rem;
  margin: 0 auto;
}

.auth-grid {
  align-items: start;
}

.auth-card {
  padding: 1.25rem;
}

.auth-card-primary {
  background: linear-gradient(180deg, rgba(18, 60, 52, 0.08), rgba(255, 252, 247, 0.98));
}

.auth-title {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}

.credential-stack {
  display: grid;
  gap: 0.75rem;
}

.credential-card {
  padding: 0.9rem;
}

@media (max-width: 1100px) {
  .scenario-grid,
  .workspace-grid,
  .technical-grid,
  .danger-grid,
  .auth-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell-header-inner,
  .demo-topbar,
  .section-row {
    flex-direction: column;
  }

  .token-strip,
  .mini-grid,
  .chat-composer {
    grid-template-columns: 1fr;
  }

  .scenario-shell,
  .workspace-shell,
  .demo-topbar,
  .auth-card {
    padding: 0.95rem;
  }

  .flow-toggle {
    width: 100%;
  }

  .flow-toggle-item {
    min-width: 0;
  }

  .popover-body {
    right: auto;
    left: 0;
    min-width: min(20rem, 88vw);
  }
}

@keyframes chat-typing {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.28;
  }
  40% {
    transform: translateY(-3px);
    opacity: 1;
  }
}
