:root {
  /* Light theme variables */
  --ink: #020617;
  --bg-dark: #ffffff;
  --bg-panel: rgba(255, 255, 255, 0.7); 
  --line: rgba(2, 6, 23, 0.12);
  --muted: #7f95ab;
  --accent: #4d7b30;
  --accent-strong: #3c6c24;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: "Inter", sans-serif;
  color: var(--ink);
  background: var(--bg-dark);
  overflow: hidden;
}

#app {
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 14% 20%, rgba(77, 123, 48, 0.10), transparent 42%),
    radial-gradient(circle at 86% 66%, rgba(59, 130, 246, 0.08), transparent 46%),
    radial-gradient(circle at 52% 52%, rgba(2, 6, 23, 0.03), transparent 60%);
  pointer-events: none;
}

.landing {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  padding: clamp(24px, 4vw, 54px);
  z-index: 6;
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(2, 6, 23, 0.055) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(2, 6, 23, 0.055) 1px, transparent 1px);
  background-size: 68px 68px;
  mask-image: radial-gradient(circle at 46% 38%, black 30%, transparent 80%);
  z-index: -1;
}

.hero {
  max-width: 820px;
  margin-top: 10vh;
  padding: clamp(24px, 4vw, 42px);
  border: 1px solid var(--line);
  background: var(--bg-panel);
  backdrop-filter: blur(1px);
  box-shadow: 0 20px 80px rgba(2, 6, 23, 0.12);
}

.hero-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 14px;
  font-size: 0.8rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero h1 {
  margin: 0;
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  line-height: 1.1;
  font-size: clamp(1.95rem, 4.8vw, 4rem);
  text-transform: uppercase;
}

.subtitle {
  max-width: 58ch;
  margin: 20px 0 30px;
  color: var(--muted);
  font-size: clamp(1rem, 1.8vw, 1.14rem);
  line-height: 1.55;
}

.btn {
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 0.93rem;
  padding: 0.7rem 1rem;
  cursor: pointer;
  transition: transform 150ms ease, background-color 150ms ease, border-color 150ms ease;
  text-decoration: none;
  display: inline-block;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.btn-primary {
  background: rgba(77, 123, 48, 0.12);
  color: var(--ink);
  border-color: rgba(77, 123, 48, 0.32);
}

.btn-primary:hover {
  background: rgba(77, 123, 48, 0.18);
}

.btn-ghost {
  border-color: rgba(2, 6, 23, 0.14);
  background: rgba(255, 255, 255, 0.58);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.86);
}

.chat-page {
  position: fixed;
  inset: 0;
  background: transparent;
  backdrop-filter: none;
  padding: 12px;
  z-index: 10;
}

.chat-page.live-page {
  background: transparent;
}

.chat-shell {
  width: 100%;
  height: 100%;
  border: 1px solid rgba(2, 6, 23, 0.12);
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(1px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.live-layout {
  position: relative;
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  transition: grid-template-columns 220ms ease;
  overflow: hidden;
}

.live-layout.is-collapsed {
  grid-template-columns: minmax(0, 1fr) 0px;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(2, 6, 23, 0.12);
  background: rgba(255, 255, 255, 0.78);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.brand-wrap {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "logo title"
    "logo subtitle";
  column-gap: 10px;
  align-items: center;
}

.header-logo {
  grid-area: logo;
  width: 42px;
  height: 42px;
  object-fit: contain;
  border: 1px solid rgba(2, 6, 23, 0.12);
  background: rgba(2, 6, 23, 0.03);
}

.brand-title {
  grid-area: title;
  margin: 0;
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.04em;
  font-size: 1rem;
}

.brand-subtitle {
  grid-area: subtitle;
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.chat-column {
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 58px auto;
  padding: 16px;
  height: 100%;
  border-right: 1px solid rgba(2, 6, 23, 0.12);
  overflow: hidden;
}

.chat-log {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 4px;
}

.message {
  margin: 10px 0;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(2, 6, 23, 0.12);
  line-height: 1.45;
  font-size: 0.93rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user {
  margin-left: auto;
  max-width: 86%;
  background: rgba(77, 123, 48, 0.10);
  border-color: rgba(77, 123, 48, 0.22);
}

.message.assistant {
  margin-right: auto;
  background: rgba(255, 255, 255, 0.92);
}

.message.system {
  margin-right: auto;
  background: rgba(251, 145, 38, 0.14);
  border-color: rgba(251, 145, 38, 0.30);
  color: #7c2d12;
}

.example-caption {
  margin: 8px 0 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.examples-block {
  max-width: 100%;
  width: 100%;
  overflow: hidden;
}

.examples-heading {
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--ink);
}

.examples-carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x mandatory;
}

.example-card {
  flex: 0 0 min(320px, 82vw);
  min-width: 280px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(2, 6, 23, 0.12);
  padding: 10px;
  scroll-snap-align: start;
}

.example-card.is-selected {
  border-color: rgba(85, 189, 125, 0.7);
  box-shadow: inset 0 0 0 1px rgba(85, 189, 125, 0.35);
}

.example-title {
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}

.example-image {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border: 1px solid rgba(2, 6, 23, 0.14);
  cursor: zoom-in;
}

.example-actions {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.example-comment {
  width: 100%;
  min-height: 58px;
  resize: vertical;
  padding: 8px;
  border: 1px solid rgba(2, 6, 23, 0.14);
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
}

.example-select-btn {
  width: 100%;
  padding: 0.5rem 0.7rem;
}

.turn-progress {
  height: 58px;
  padding: 7px 2px 6px;
  border-top: 1px solid transparent;
  opacity: 0;
  visibility: hidden;
  transition: opacity 180ms ease, border-color 180ms ease;
  pointer-events: none;
}

.turn-progress.is-visible {
  border-top-color: rgba(2, 6, 23, 0.12);
  opacity: 1;
  visibility: visible;
}

.turn-progress-header,
.turn-progress-status,
.turn-progress-metrics {
  display: flex;
  align-items: center;
}

.turn-progress-header {
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.turn-progress-status {
  min-width: 0;
  gap: 8px;
  color: var(--ink);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.76rem;
  font-weight: 600;
}

.turn-progress-status span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.turn-progress-signal {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  background: var(--accent-strong);
  animation: turn-progress-pulse 1.1s ease-in-out infinite;
}

.turn-progress-metrics {
  flex: 0 0 auto;
  gap: 10px;
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
}

.turn-progress-track {
  width: 100%;
  height: 4px;
  margin-top: 6px;
  overflow: hidden;
  background: rgba(2, 6, 23, 0.10);
}

.turn-progress-bar {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent-strong);
  transition: width 300ms ease;
}

.turn-progress-detail {
  margin: 4px 0 0 15px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.turn-progress.is-complete .turn-progress-signal {
  animation: none;
  background: #2f7d4a;
}

.turn-progress.is-failed .turn-progress-signal,
.turn-progress.is-failed .turn-progress-bar {
  animation: none;
  background: #b45309;
}

@keyframes turn-progress-pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .turn-progress,
  .turn-progress-bar,
  .turn-progress-signal {
    animation: none;
    transition: none;
  }
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  border-top: 1px solid rgba(2, 6, 23, 0.12);
  padding-top: 12px;
}

#chat-input {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  padding: 10px;
  border: 1px solid rgba(2, 6, 23, 0.14);
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  font: inherit;
}

#chat-input::placeholder {
  color: rgba(2, 6, 23, 0.45);
}

#send-btn {
  min-height: 44px;
  align-self: stretch;
}

.header-right #upload-btn {
  min-height: 38px;
}

.ledger-menu {
  min-width: 0;
  position: relative;
  width: 100%;
  transition: opacity 220ms ease, border-color 220ms ease;
  border-left: 1px solid rgba(2, 6, 23, 0.12);
  overflow: hidden;
}

.ledger-toggle {
  position: static;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(2, 6, 23, 0.16);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  cursor: pointer;
  transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ledger-chevron {
  display: inline-block;
  transition: transform 160ms ease;
}

.ledger-menu.is-collapsed {
  opacity: 0;
  pointer-events: none;
  border-left-color: transparent;
}

.ledger-menu.is-collapsed .ledger-panel {
  opacity: 0;
}

.ledger-toggle.is-collapsed .ledger-chevron {
  transform: rotate(180deg);
}

.ledger-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  gap: 10px;
  min-width: 0;
  transition: opacity 180ms ease;
}

.ledger-title {
  margin: 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.84rem;
  color: var(--ink);
}

.ledger-buttons {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.ledger-btn {
  text-align: left;
  padding: 8px;
  border: 1px solid rgba(2, 6, 23, 0.14);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.82rem;
}

.ledger-btn.is-active {
  border-color: rgba(77, 123, 48, 0.35);
  background: rgba(77, 123, 48, 0.12);
}

.ledger-content {
  margin-top: 2px;
  border: 1px solid rgba(2, 6, 23, 0.14);
  background: rgba(255, 255, 255, 0.92);
  padding: 10px;
  min-height: 120px;
  overflow: auto;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.live-layout.is-collapsed .chat-column {
  border-right: none;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(6px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.image-lightbox.hidden {
  display: none;
}

.image-lightbox-inner {
  max-width: min(1200px, 96vw);
  max-height: 92vh;
  display: grid;
  gap: 10px;
}

.image-lightbox-img {
  max-width: min(1200px, 96vw);
  max-height: 82vh;
  width: auto;
  height: auto;
  border: 1px solid rgba(2, 6, 23, 0.22);
  box-shadow: 0 18px 42px rgba(2, 6, 23, 0.20);
}

.image-lightbox-caption {
  font-size: 0.82rem;
  color: var(--muted);
}

.hidden {
  display: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  body {
    overflow: hidden;
  }

  .landing {
    padding: 12px;
  }

  .hero {
    margin-top: 5vh;
    padding: 18px;
  }

  .chat-page {
    padding: 0;
  }

  .chat-shell {
    border: none;
  }

  .chat-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 10px;
  }

  .header-logo {
    width: 34px;
    height: 34px;
  }

  .brand-title {
    font-size: 0.82rem;
  }

  .brand-subtitle,
  .header-meta {
    display: none;
  }

  .header-right {
    margin-left: auto;
    gap: 6px;
  }

  .header-right .btn {
    padding: 0.5rem 0.62rem;
    font-size: 0.76rem;
  }

  .live-layout,
  .live-layout.is-collapsed {
    display: block;
  }

  .chat-column {
    width: 100%;
    padding: 10px;
    border-right: none;
  }

  .ledger-menu {
    position: absolute;
    z-index: 8;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(340px, calc(100vw - 42px));
    background: rgba(255, 255, 255, 0.97);
    transform: translateX(0);
    transition: transform 220ms ease, opacity 220ms ease;
  }

  .ledger-menu.is-collapsed {
    transform: translateX(100%);
  }

  .message.user {
    max-width: 94%;
  }

  .composer {
    grid-template-columns: minmax(0, 1fr) 64px;
    gap: 6px;
  }

  #chat-input {
    min-height: 64px;
  }

  .turn-progress-detail {
    max-width: calc(100vw - 42px);
  }
}
