:root {
  color-scheme: dark;
  --ink: #f7f1e8;
  --muted: #bdb4aa;
  --panel: rgba(19, 24, 31, 0.76);
  --panel-strong: rgba(13, 18, 25, 0.92);
  --line: rgba(255, 255, 255, 0.12);
  --accent: #7ee7c8;
  --accent-strong: #43d7b4;
  --warm: #ffb86b;
  --danger: #ff7d8f;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 15%, rgba(126, 231, 200, 0.18), transparent 26rem),
    radial-gradient(circle at 78% 70%, rgba(255, 184, 107, 0.13), transparent 24rem),
    linear-gradient(135deg, #0f151c 0%, #14191e 50%, #1d1b18 100%);
  overflow: hidden;
}

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

button {
  border: 0;
}

#ambientCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.58;
}

.version-counter {
  position: fixed;
  top: 10px;
  right: 14px;
  z-index: 3;
  color: rgba(247, 241, 232, 0.38);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  pointer-events: none;
  user-select: none;
}

.shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: clamp(18px, 4vw, 48px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 240px);
  gap: clamp(14px, 2vw, 24px);
  align-items: stretch;
}

.workspace {
  min-width: 0;
  min-height: min(720px, calc(100vh - 48px));
  display: grid;
}

.screen {
  width: 100%;
  min-height: min(720px, calc(100vh - 48px));
  display: none;
  opacity: 0;
  transform: translateY(18px) scale(0.985);
}

.screen.is-active {
  display: flex;
  animation: screenIn 420ms cubic-bezier(0.2, 0.9, 0.25, 1) forwards;
}

.menu-screen {
  align-items: center;
  justify-content: center;
  text-align: center;
  flex-direction: column;
}

.brand-block {
  max-width: 900px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(5rem, 15vw, 13rem);
  line-height: 0.88;
  letter-spacing: 0;
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: clamp(12px, 2vw, 24px);
  flex-wrap: wrap;
  text-align: center;
}

.wordmark-main {
  font-family: "Segoe UI Variable Display", "Inter", ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(5rem, 14vw, 11rem);
  font-weight: 900;
  letter-spacing: 0;
}

.wordmark-accent {
  color: var(--accent);
  font-family: "Segoe Print", "Bradley Hand ITC", "Comic Sans MS", cursive;
  font-size: clamp(1.7rem, 4.6vw, 4.2rem);
  font-weight: 700;
  transform: rotate(-3deg) translateY(-0.22em);
}

.intro {
  margin: 22px auto 0;
  max-width: 34rem;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.side-nav {
  min-height: min(720px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.side-brand {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 1.28rem;
  font-weight: 900;
}

.side-button {
  width: 100%;
  min-height: 54px;
  padding: 0 14px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  cursor: pointer;
  text-align: left;
  font-size: 1rem;
  font-weight: 800;
  transition:
    transform 180ms ease,
    background 180ms ease,
    border-color 180ms ease;
}

.side-button:hover,
.side-button.is-active {
  transform: translateX(-2px);
  color: #07110e;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--warm));
}

.side-group {
  display: grid;
  gap: 8px;
}

.side-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.side-chevron {
  width: 11px;
  height: 11px;
  border-right: 3px solid currentColor;
  border-bottom: 3px solid currentColor;
  transform: rotate(45deg);
  transition: transform 180ms ease;
}

.side-group.is-open .side-chevron {
  transform: rotate(225deg) translate(-2px, -2px);
}

.side-subnav {
  display: grid;
  gap: 8px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  transition:
    max-height 220ms ease,
    opacity 180ms ease,
    transform 180ms ease;
}

.side-group.is-open .side-subnav {
  max-height: 140px;
  opacity: 1;
  transform: translateY(0);
}

.side-sub-button {
  min-height: 46px;
  width: calc(100% - 16px);
  justify-self: end;
  padding: 0 14px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  text-align: left;
  font-weight: 800;
  transition:
    transform 180ms ease,
    background 180ms ease,
    border-color 180ms ease;
}

.side-sub-button:hover,
.side-sub-button.is-active {
  transform: translateX(-2px);
  color: #07110e;
  border-color: transparent;
  background: linear-gradient(135deg, rgba(126, 231, 200, 0.9), rgba(255, 184, 107, 0.9));
}

.chat-screen,
.image-screen,
.stocks-screen {
  flex-direction: column;
  gap: 14px;
  padding: clamp(14px, 2.5vw, 24px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.chat-topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.chat-topbar h1 {
  font-size: clamp(1.8rem, 5vw, 3rem);
  line-height: 1;
}

.ghost-button,
.send-button {
  min-height: 44px;
  border-radius: 8px;
  cursor: pointer;
  transition:
    transform 180ms ease,
    background 180ms ease,
    border-color 180ms ease;
}

.ghost-button {
  padding: 0 18px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.ghost-button:hover {
  transform: translateY(-1px);
  border-color: rgba(126, 231, 200, 0.42);
  background: rgba(126, 231, 200, 0.08);
}

.status-pill {
  justify-self: end;
  min-width: 78px;
  padding: 8px 12px;
  color: var(--accent);
  border: 1px solid rgba(126, 231, 200, 0.25);
  border-radius: 999px;
  background: rgba(126, 231, 200, 0.08);
  text-align: center;
  font-size: 0.82rem;
}

.status-pill.is-error {
  color: var(--danger);
  border-color: rgba(255, 125, 143, 0.35);
  background: rgba(255, 125, 143, 0.08);
}

.model-panel {
  display: grid;
  grid-template-columns: minmax(92px, auto) 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.model-panel label {
  color: var(--muted);
  font-size: 0.92rem;
}

.model-panel select {
  width: 100%;
  min-height: 44px;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: var(--panel-strong);
  padding: 0 12px;
  outline: none;
}

.model-panel select:focus {
  border-color: rgba(126, 231, 200, 0.55);
}

.chat-log {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 4px 4px 8px;
  scrollbar-color: rgba(126, 231, 200, 0.5) transparent;
}

.message {
  width: min(76%, 680px);
  display: grid;
  gap: 7px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  animation: messageIn 240ms ease both;
}

.message span {
  color: var(--accent);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

.user-message {
  align-self: flex-end;
  background: rgba(255, 184, 107, 0.11);
}

.user-message span {
  color: var(--warm);
}

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

.message.is-thinking p::after {
  content: "";
  display: inline-block;
  width: 1.1em;
  animation: dots 1.15s steps(4, end) infinite;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.composer textarea,
.stock-search input,
.image-form textarea {
  min-height: 52px;
  max-height: 170px;
  resize: none;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: var(--panel-strong);
  padding: 15px 16px;
  line-height: 1.45;
  outline: none;
}

.composer textarea:focus {
  border-color: rgba(126, 231, 200, 0.55);
}

.stock-search input:focus,
.image-form textarea:focus {
  border-color: rgba(126, 231, 200, 0.55);
}

.send-button {
  min-width: 96px;
  padding: 0 20px;
  color: #07110e;
  background: var(--accent);
  font-weight: 800;
}

.send-button:hover {
  transform: translateY(-1px);
  background: var(--accent-strong);
}

.send-button:disabled,
.stock-search input:disabled,
.composer textarea:disabled,
.image-form textarea:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.stock-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.stock-search input {
  min-height: 52px;
  text-transform: uppercase;
}

.stock-dashboard {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(220px, 0.9fr);
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.stock-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  padding: clamp(14px, 2vw, 20px);
  animation: messageIn 260ms ease both;
}

.stock-quote {
  display: grid;
  align-content: center;
  min-height: 210px;
}

.stock-quote h2 {
  margin: 0;
  font-size: clamp(2.6rem, 7vw, 5rem);
  line-height: 1;
}

.stock-price {
  margin: 14px 0 0;
  color: var(--accent);
  font-size: clamp(1.4rem, 3.5vw, 3rem);
  font-weight: 900;
}

.stock-actions {
  display: grid;
  align-content: center;
  gap: 14px;
}

.trade-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.danger-button {
  color: var(--danger);
}

.danger-button:hover {
  color: #170408;
  border-color: transparent;
  background: var(--danger);
}

.stock-account {
  grid-column: 1 / -1;
  overflow: auto;
}

.cash-line {
  margin: 0 0 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 1.05rem;
}

.cash-line span {
  color: var(--ink);
  font-weight: 900;
}

.portfolio-list {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.portfolio-row {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.portfolio-row span {
  color: var(--ink);
  font-weight: 900;
}

.image-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.image-preview {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.image-preview p {
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.image-preview img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-preview.has-image img {
  display: block;
  animation: messageIn 260ms ease both;
}

.image-preview.has-image p {
  display: none;
}

.image-preview.is-loading::after {
  content: "Creating image...";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: rgba(13, 18, 25, 0.72);
}

@keyframes screenIn {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@keyframes dots {
  0% {
    content: "";
  }
  25% {
    content: ".";
  }
  50% {
    content: "..";
  }
  75%,
  100% {
    content: "...";
  }
}

@media (max-width: 720px) {
  body {
    overflow: auto;
  }

  .shell {
    min-height: 100svh;
    padding: 12px;
    grid-template-columns: 1fr;
  }

  .workspace {
    min-height: calc(100svh - 24px);
  }

  .side-nav {
    order: -1;
    min-height: auto;
  }

  .screen {
    min-height: calc(100svh - 24px);
  }

  .status-pill {
    display: none;
  }

  .model-panel,
  .composer,
  .stock-search,
  .stock-dashboard,
  .trade-buttons,
  .image-form {
    grid-template-columns: 1fr;
  }

  .stock-account {
    grid-column: auto;
  }

  .message {
    width: 94%;
  }
}
