:root {
  --ink: #1a2748;
  --muted: #5a6a8f;
  --paper: #f6f4f0;
  --brand: #273f82;
  --accent: #f49f43;
  --sidebar: #1a2748;
  --display: "Montserrat", system-ui, sans-serif;
  --body: "Source Serif 4", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --rail-w: 300px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--display);
}

.demo-atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1000px 520px at 0% 0%, rgba(244, 159, 67, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 10%, rgba(39, 63, 130, 0.14), transparent 50%),
    linear-gradient(165deg, #faf8f4 0%, #f1eee8 40%, #e6eaf4 100%);
}

.demo-app {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
}

.demo-rail {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem 1rem;
  background: linear-gradient(180deg, #22356e 0%, var(--sidebar) 45%, #15203c 100%);
  color: #eef2fb;
  border-right: 1px solid rgba(244, 159, 67, 0.25);
  max-height: 100vh;
  overflow: hidden;
  position: sticky;
  top: 0;
}

.rail-brand img {
  width: 6.5rem;
  height: auto;
  display: block;
  margin-bottom: 0.35rem;
}

.rail-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
}

.rail-sub {
  margin: 0.15rem 0 0;
  font-family: var(--mono);
  font-size: 0.68rem;
  opacity: 0.7;
}

.rail-section {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 0;
}

.rail-label {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

.model-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.model-chip {
  font-family: var(--mono);
  font-size: 0.65rem;
  padding: 0.3rem 0.45rem;
  border-radius: 0.4rem;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.55);
  border: 1px solid transparent;
  transition: all 0.25s ease;
  animation: chip-in 0.4s ease both;
}

.model-chip.used {
  color: #fff;
  background: rgba(244, 159, 67, 0.22);
  border-color: rgba(244, 159, 67, 0.45);
}

.model-chip.active {
  color: #15203c;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(244, 159, 67, 0.25);
  transform: scale(1.04);
}

.rail-grow {
  flex: 1;
  min-height: 0;
}

.history-empty,
.model-empty {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.38);
  font-style: italic;
  padding: 0.35rem 0.2rem;
  line-height: 1.4;
}

.model-empty {
  font-style: normal;
}

.history-list {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: auto;
  max-height: 48vh;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.history-list li {
  display: flex;
  gap: 0.55rem;
  padding: 0.55rem 0.6rem;
  border-radius: 0.55rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  animation: hist-in 0.35s ease both;
}

.history-list li.active {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(244, 159, 67, 0.35);
  box-shadow: inset 3px 0 0 var(--accent);
}

.history-list li.done {
  opacity: 0.82;
}

.hist-num {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--accent);
  padding-top: 0.1rem;
}

.hist-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.hist-q {
  font-size: 0.72rem;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.88);
  display: -webkit-box;
  -webkit-line-clamp: +2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hist-model {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: rgba(244, 159, 67, 0.95);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.hist-model.visible {
  opacity: 1;
  transform: none;
}

.hist-model.pending {
  color: rgba(255, 255, 255, 0.45);
  font-style: italic;
  opacity: 1;
  transform: none;
}

.hist-status {
  font-family: var(--mono);
  font-size: 0.58rem;
  color: rgba(255, 255, 255, 0.4);
}

@keyframes hist-in {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes chip-in {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.rail-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-family: var(--mono);
  font-size: 0.68rem;
}

.badge {
  display: inline-block;
  width: fit-content;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: rgba(244, 159, 67, 0.2);
  color: var(--accent);
  border: 1px solid rgba(244, 159, 67, 0.4);
}

.muted {
  opacity: 0.55;
}

.demo-main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-height: 100vh;
}

.demo-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.4rem;
  border-bottom: 1px solid rgba(39, 63, 130, 0.12);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(10px);
}

.top-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.top-logo {
  width: 2.5rem;
  height: auto;
}

.demo-top h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}

.top-sub {
  margin: 0.1rem 0 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.top-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: 1px solid rgba(39, 63, 130, 0.2);
  background: #fff;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.55rem 0.85rem;
  border-radius: 0.55rem;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
}

.btn-accent {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn-accent:hover:not(:disabled) {
  background: #1e3270;
}

.route-banner {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 0.85rem 1.4rem 0;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: linear-gradient(90deg, rgba(39, 63, 130, 0.95), rgba(30, 50, 112, 0.9));
  color: #fff;
  box-shadow: 0 12px 40px rgba(39, 63, 130, 0.2);
  animation: route-in 0.35s ease both;
}

.route-banner[hidden] {
  display: none !important;
}

.route-pulse {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(244, 159, 67, 0.7);
  animation: pulse 1.2s ease infinite;
}

.route-copy {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.route-kicker {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.7;
}

.route-copy strong {
  font-size: 1.05rem;
  font-weight: 800;
}

.route-copy span:last-child {
  font-size: 0.78rem;
  opacity: 0.85;
}

.thread {
  flex: 1;
  overflow: auto;
  padding: 1.2rem 1.4rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.empty {
  margin: auto;
  max-width: 28rem;
  text-align: center;
  padding: 2rem 1rem;
}

.empty img {
  width: 8rem;
  height: auto;
  margin-bottom: 0.75rem;
}

.empty h2 {
  margin: 0 0 0.5rem;
  font-size: 1.45rem;
}

.empty p {
  margin: 0 0 0.65rem;
  font-family: var(--body);
  color: var(--muted);
  line-height: 1.5;
}

.hint {
  font-family: var(--mono) !important;
  font-size: 0.75rem !important;
}

.message-row {
  display: flex;
  max-width: min(720px, 100%);
  animation: rise 0.35s ease both;
}

.message-row.user {
  align-self: flex-end;
}

.message-row.assistant {
  align-self: flex-start;
}

.bubble {
  padding: 0.85rem 1rem;
  border-radius: 1rem;
  line-height: 1.5;
  font-size: 0.95rem;
}

.message-row.user .bubble {
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 0.3rem;
  font-family: var(--display);
  font-weight: 600;
}

.message-row.assistant .bubble {
  background: #fff;
  border: 1px solid rgba(39, 63, 130, 0.1);
  box-shadow: 0 10px 30px rgba(39, 63, 130, 0.06);
  border-bottom-left-radius: 0.3rem;
  font-family: var(--body);
  color: var(--ink);
}

.md p {
  margin: 0 0 0.65rem;
}

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

.md ul,
.md ol {
  margin: 0.35rem 0 0.65rem;
  padding-left: 1.2rem;
}

.md li {
  margin: 0.2rem 0;
}

.md pre {
  margin: 0.5rem 0;
  padding: 0.75rem 0.85rem;
  border-radius: 0.55rem;
  background: #15203c;
  color: #eef2fb;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.45;
}

.md code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: rgba(39, 63, 130, 0.08);
  padding: 0.1rem 0.3rem;
  border-radius: 0.25rem;
}

.md pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.md strong {
  font-weight: 700;
  font-family: var(--display);
}

.msg-meta {
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(39, 63, 130, 0.1);
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
}

.msg-meta .model-name {
  color: var(--brand);
  font-weight: 600;
}

.image-gen-card {
  display: block;
  margin: 0.6rem 0 0;
  border-radius: 0.8rem;
  overflow: hidden;
  border: 1px solid rgba(39, 63, 130, 0.12);
  box-shadow: 0 14px 40px rgba(39, 63, 130, 0.12);
  animation: img-pop 0.5s ease both;
}

.image-gen-card img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
}

@keyframes img-pop {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.item-cap {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid rgba(244, 159, 67, 0.35);
  border-radius: 0.3rem;
  padding: 0.1rem 0.4rem;
  margin-bottom: 0.3rem;
}

.typing::after {
  content: "▋";
  animation: blink 0.9s step-end infinite;
  margin-left: 2px;
  color: var(--accent);
}

.composer-fake {
  padding: 0.75rem 1.4rem 1.1rem;
  border-top: 1px solid rgba(39, 63, 130, 0.1);
  background: rgba(255, 255, 255, 0.7);
}

.composer-wrap {
  padding: 0.75rem 1.4rem 1.1rem;
  border-top: 1px solid rgba(39, 63, 130, 0.1);
  background: rgba(255, 255, 255, 0.7);
}

.composer-row {
  display: flex;
  gap: 0.65rem;
  align-items: flex-end;
}

.fake-input {
  flex: 1;
  min-height: 3rem;
  max-height: 5.5rem;
  padding: 0.85rem 1rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(39, 63, 130, 0.15);
  background: #fff;
  font-family: var(--display);
  font-size: 0.9rem;
  color: var(--ink);
  line-height: 1.45;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  word-break: break-word;
}

.fake-input.typing-prompt {
  border-color: rgba(39, 63, 130, 0.28);
  box-shadow: 0 0 0 3px rgba(39, 63, 130, 0.06);
}

.typed-text {
  white-space: pre-wrap;
}

.caret {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  margin-left: 1px;
  vertical-align: text-bottom;
  background: var(--brand);
  animation: blink 0.85s step-end infinite;
}

.caret.hidden {
  display: none;
}

.btn-send {
  appearance: none;
  border: 0;
  background: var(--brand);
  color: #fff;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.1rem;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.75rem;
  opacity: 0.45;
  flex-shrink: 0;
}

.btn-send.live {
  opacity: 1;
  animation: send-pulse 1.2s ease infinite;
}

@keyframes send-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(39, 63, 130, 0.25);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(39, 63, 130, 0);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

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

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(244, 159, 67, 0.65);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(244, 159, 67, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(244, 159, 67, 0);
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

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

  .demo-rail {
    display: none;
  }
}
