:root {
  color-scheme: dark;
  --bg: #030303;
  --panel: rgba(7, 10, 16, 0.88);
  --panel-strong: rgba(10, 16, 28, 0.96);
  --ink: #f7f7f2;
  --muted: rgba(247, 247, 242, 0.68);
  --soft: rgba(247, 247, 242, 0.46);
  --line: rgba(247, 247, 242, 0.18);
  --cyan: #00f0ff;
  --green: #d8ff86;
  --rose: #fb7185;
  --black: #000000;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 82% 10%, rgba(137, 115, 181, 0.2), transparent 58%),
    radial-gradient(ellipse at 12% 88%, rgba(103, 143, 177, 0.14), transparent 60%),
    linear-gradient(135deg, #101322 0%, #1b2035 48%, #14182a 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
select,
textarea {
  font: inherit;
}

.uz-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 36px;
  border-bottom: 1px solid var(--line);
  background: rgba(3, 3, 3, 0.82);
  backdrop-filter: blur(18px);
}

.brand,
.nav {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  font-weight: 700;
}

.brand-mark {
  width: 32px;
  height: 32px;
  padding: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
}

.nav {
  gap: 28px;
  color: var(--muted);
  font-size: 0.94rem;
}

.nav a:hover {
  color: var(--green);
}

.wallet-button,
.composer button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  color: var(--black);
  background: var(--green);
  font-weight: 800;
  cursor: pointer;
}

.wallet-button {
  padding: 0 18px;
}

.wallet-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.wallet-label {
  font-size: 0.75rem;
  color: var(--muted);
}

.wallet-controls select {
  min-height: 44px;
  max-width: 150px;
  padding: 0 10px;
  background: var(--panel-strong);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.wallet-button.secondary {
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
}

.wallet-controls :focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.token-requirement,
.model-name {
  margin: 8px 0;
  color: var(--muted);
  font-size: 0.75rem;
  overflow-wrap: anywhere;
}

.wallet-button:disabled,
.composer button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.uz-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(280px, 0.34fr) minmax(0, 0.66fr);
  gap: 22px;
  min-height: calc(100vh - 81px);
  padding: 28px;
}

.status-rail,
.chat-panel,
.identity-card,
.gate-card,
.steps-card {
  position: relative;
}

.status-rail {
  display: grid;
  align-content: start;
  gap: 16px;
}

.identity-card,
.gate-card,
.steps-card,
.chat-panel {
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

.identity-card {
  padding: 28px;
}

.eyebrow {
  display: inline-flex;
  margin-bottom: 14px;
  color: var(--cyan);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  margin-bottom: 14px;
  font-family: "Chakra Petch", sans-serif;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(3.5rem, 10vw, 6.8rem);
  line-height: 0.88;
}

h2 {
  font-size: clamp(1.8rem, 4vw, 3.4rem);
  line-height: 0.98;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.gate-card,
.steps-card {
  padding: 18px;
}

.gate-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
}

.gate-row:last-child {
  border-bottom: 0;
}

.gate-row span {
  color: var(--soft);
}

.gate-row strong {
  color: var(--ink);
  text-align: right;
}

.step {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 58px;
  color: var(--soft);
}

.step span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
}

.step p {
  margin: 0;
  color: inherit;
  font-size: 0.94rem;
}

.step.is-active,
.step.is-done {
  color: var(--ink);
}

.step.is-done span {
  color: var(--black);
  background: var(--green);
  border-color: var(--green);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  min-height: 640px;
  overflow: hidden;
}

.chat-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  padding: 26px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(3, 3, 3, 0.32);
}

.model-pill {
  min-width: max-content;
  padding: 8px 10px;
  border: 1px solid rgba(0, 240, 255, 0.32);
  border-radius: 999px;
  color: var(--cyan);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
  padding: 24px 28px;
}

.message {
  flex-shrink: 0;
  width: min(760px, 88%);
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.message.user {
  align-self: flex-end;
  border-color: rgba(216, 255, 134, 0.32);
  background: rgba(216, 255, 134, 0.08);
}

.message.assistant {
  align-self: flex-start;
  border-color: rgba(0, 240, 255, 0.24);
}

.message.error {
  border-color: rgba(251, 113, 133, 0.44);
}

.message span {
  display: block;
  margin-bottom: 8px;
  color: var(--cyan);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
}

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

.message.error span {
  color: var(--rose);
}

.message p {
  margin: 0;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 12px;
  padding: 18px 20px 10px;
  border-top: 1px solid var(--line);
  background: var(--panel-strong);
}

.composer textarea {
  width: 100%;
  min-height: 56px;
  max-height: 180px;
  resize: vertical;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 14px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.44);
  outline: none;
}

.composer textarea:focus {
  border-color: rgba(0, 240, 255, 0.68);
}

.composer button {
  align-self: end;
}

.notice {
  min-height: 34px;
  margin: 0;
  padding: 0 22px 18px;
  color: var(--soft);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.74rem;
}

.notice.is-error {
  color: var(--rose);
}

/* Keep both desktop panels inside the space below the header. */
@media (min-width: 981px) {
  body {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  main {
    min-height: 0;
  }

  .uz-shell {
    height: 100%;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
  }

  .status-rail {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
  }

  .chat-panel {
    min-height: 0;
  }
}

@media (max-width: 980px) {
  .uz-shell {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    height: 80vh;
    height: 80dvh;
    min-height: 480px;
  }
}

@media (max-width: 720px) {
  .uz-header {
    position: relative;
    flex-wrap: wrap;
    padding: 16px;
  }

  .nav {
    order: 3;
    width: 100%;
    justify-content: space-between;
    gap: 12px;
  }

  .wallet-button {
    padding: 0 14px;
  }

  .uz-shell {
    padding: 14px;
  }

  .identity-card,
  .gate-card,
  .steps-card {
    padding: 18px;
  }

  .chat-top,
  .messages {
    padding-left: 18px;
    padding-right: 18px;
  }

  .chat-top {
    display: grid;
  }

  .message {
    width: 100%;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .composer button {
    min-height: 48px;
  }
}

.planning-card { padding: 22px; border: 1px solid var(--line, #294146); border-radius: 14px; }
.planning-card h2 { font-size: 1.1rem; margin-top: 0; }
.planning-card p { color: var(--soft); font-size: .82rem; line-height: 1.6; overflow-wrap: anywhere; }
.planning-card button { width: 100%; margin: 8px 0; }
.planning-card details { margin-top: 16px; }
.planning-card summary { cursor: pointer; font-size: .85rem; }
.planning-card label { display: block; margin-top: 12px; }
.planning-card input { width: 100%; padding: 10px; margin-top: 8px; background: #08191e; color: #e9ffff; border: 1px solid #49686e; border-radius: 6px; }
