:root {
  --ink: #10221f;
  --muted: #4a635e;
  --paper: #eef5f3;
  --paper-2: #d7e8e3;
  --teal: #0a3c3a;
  --teal-2: #14615c;
  --lime: #c8f542;
  --warn: #e35d2a;
  --line: rgba(16, 34, 31, 0.12);
  --shadow: 0 18px 50px rgba(10, 60, 58, 0.12);
  --display: "Syne", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

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

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(200, 245, 66, 0.28), transparent 55%),
    radial-gradient(800px 480px at 100% 0%, rgba(20, 97, 92, 0.18), transparent 50%),
    linear-gradient(160deg, #f5faf8 0%, #e4f0ec 45%, #d3e6e1 100%);
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
  pointer-events: none;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  padding: 1.5rem clamp(1.25rem, 4vw, 3rem) 0.5rem;
  animation: rise 0.7s ease both;
}

.brand-mark {
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 0.9;
  color: var(--teal);
}

.brand-sub {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8rem;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #9aa;
  box-shadow: 0 0 0 4px rgba(154, 170, 170, 0.25);
}

.dot.ok {
  background: #2f9e6c;
  box-shadow: 0 0 0 4px rgba(47, 158, 108, 0.2);
}

.dot.warn {
  background: var(--warn);
  box-shadow: 0 0 0 4px rgba(227, 93, 42, 0.2);
}

.stage {
  padding: 1rem clamp(1.25rem, 4vw, 3rem) 4rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(1.25rem, 3vw, 2.5rem);
  align-items: start;
  max-width: 1480px;
  margin: 0 auto;
}

.col-left {
  min-width: 0;
}

.col-right {
  position: sticky;
  top: 1rem;
  align-self: start;
  min-width: 0;
}

.answer-dock {
  display: flex;
  flex-direction: column;
  min-height: min(72vh, 44rem);
  max-height: calc(100vh - 2rem);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise 0.75s 0.08s ease both;
}

.answer-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem 0.55rem;
  border-bottom: 1px solid var(--line);
}

.answer-head h2 {
  margin: 0;
  font-size: 0.95rem;
}

.stream-status {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stream-status.live {
  color: var(--teal-2);
}

.stream-status.error {
  color: var(--warn);
}

.answer-dock .output {
  flex: 1;
  margin: 0;
  max-height: none;
  border-radius: 0;
  min-height: 16rem;
}

.composer {
  animation: rise 0.8s 0.05s ease both;
}

.composer h1 {
  margin: 1.4rem 0 0.4rem;
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  letter-spacing: -0.03em;
  max-width: 14ch;
}

.lede {
  margin: 0 0 1.25rem;
  max-width: 42rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.92rem;
  line-height: 1.55;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(8px);
  border-radius: 0;
  padding: 1rem 1.1rem;
  font-family: var(--mono);
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink);
  resize: vertical;
  min-height: 8rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea:focus {
  border-color: var(--teal-2);
  box-shadow: 0 0 0 3px rgba(20, 97, 92, 0.15);
}

.controls {
  margin-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  min-width: 0;
}

.controls-row.actions {
  align-items: center;
}

.field {
  display: grid;
  gap: 0.25rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  min-width: 0;
}

.field.mode {
  flex: 0 0 auto;
}

.field.mode select {
  width: auto;
  min-width: 6.5rem;
}

.field.grow {
  flex: 1 1 12rem;
  min-width: 0;
}

.field.grow select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

select {
  display: block;
  width: 100%;
  max-width: 100%;
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  /* Long option labels must not inflate the control past its flex slot */
  text-overflow: ellipsis;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}

button {
  font-family: var(--display);
  font-weight: 700;
  border: 0;
  cursor: pointer;
  padding: 0.7rem 1.1rem;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

button:active {
  transform: translateY(1px);
}

button.primary {
  margin-left: auto;
  background: var(--teal);
  color: var(--lime);
  min-width: 7rem;
}

button.primary:hover {
  background: var(--teal-2);
}

button.primary[disabled] {
  opacity: 0.55;
  cursor: wait;
}

button.ghost {
  background: transparent;
  color: var(--teal);
  border: 1px solid var(--line);
}

.meter {
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  animation: rise 0.5s ease both;
}

.timing {
  margin-top: 1.25rem;
  padding: 1rem 1.1rem;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  animation: rise 0.55s ease both;
}

.timing h2 {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
}

.meter-item {
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.55);
  border-top: 3px solid var(--teal);
}

.meter-item .k {
  display: block;
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.meter-item .v {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.pipeline {
  margin-top: 1.75rem;
  animation: rise 0.55s ease both;
}

.pipeline h2,
.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

#steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#steps li {
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.6);
}

#steps li.done {
  border-color: transparent;
  background: var(--teal);
  color: #e9f7ef;
}

#steps li.error {
  background: #fff1eb;
  border-color: var(--warn);
  color: #8a2e10;
}

#steps li.skipped {
  opacity: 0.55;
}

.grid {
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  animation: rise 0.6s ease both;
}

.panel {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  padding: 1rem 1.1rem 1.15rem;
  box-shadow: var(--shadow);
}

.panel.wide {
  grid-column: 1 / -1;
}

.body {
  font-size: 0.9rem;
  line-height: 1.45;
}

.mono,
.output {
  font-family: var(--mono);
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.output {
  margin: 0;
  max-height: 28rem;
  overflow: auto;
  background: #0f2421;
  color: #d7f0ea;
  padding: 1rem;
  scroll-behavior: smooth;
}

.output.streaming::after {
  content: "▍";
  display: inline-block;
  margin-left: 0.1ch;
  animation: blink 1s steps(1) infinite;
  color: var(--lime);
}

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

.verify-notes {
  margin: 0.6rem 0 0;
  max-height: 16rem;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  padding: 0.85rem 1rem;
  color: var(--ink);
}

.model-row,
.node-row,
.usage-row {
  display: grid;
  gap: 0.35rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}

.model-row:last-child,
.node-row:last-child,
.usage-row:last-child {
  border-bottom: 0;
}

.model-id,
.node-id {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.85rem;
}

.meta {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.tool-steps {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.5rem;
  padding-left: 0.5rem;
  border-left: 2px solid var(--line);
}

.tool-step {
  font-family: var(--mono);
  font-size: 0.75rem;
}

.tool-step .tool-name {
  color: var(--ink);
  font-weight: 600;
}

.step.tool-live {
  opacity: 0.85;
  font-size: 0.78rem;
}

.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1.25rem, 4vw, 3rem) 1.5rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

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

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

  .col-right {
    position: static;
  }

  .answer-dock {
    max-height: none;
    min-height: 22rem;
  }
}

@media (max-width: 800px) {
  .meter,
  .grid {
    grid-template-columns: 1fr 1fr;
  }

  .panel.wide,
  .composer h1 {
    grid-column: auto;
  }

  button.primary {
    margin-left: 0;
    width: 100%;
  }
}

@media (max-width: 560px) {
  .meter,
  .grid {
    grid-template-columns: 1fr;
  }

  .top {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
  }
}

.top-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.65rem;
}

.keys-panel {
  margin: 0.75rem clamp(1.25rem, 4vw, 3rem) 0;
  padding: 1.1rem 1.25rem 1.25rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(8px);
  animation: rise 0.45s ease both;
}

.keys-inner {
  display: grid;
  gap: 1rem;
}

.keys-head h2 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--teal);
}

.keys-head .lede {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.keys-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr 1fr;
}

.keys-actions {
  display: flex;
  gap: 0.5rem;
  align-items: end;
  flex-wrap: wrap;
}

.copy-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.copy-row input {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.key-secret {
  padding: 0.85rem;
  border: 1px dashed rgba(227, 93, 42, 0.45);
  background: rgba(227, 93, 42, 0.06);
}

.warn-line {
  margin: 0 0 0.5rem;
  color: var(--warn);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.opencode-hint {
  margin: 0.75rem 0 0;
  padding: 0.75rem;
  background: var(--teal);
  color: #e7f7f3;
  font-family: var(--mono);
  font-size: 0.72rem;
  white-space: pre-wrap;
  overflow: auto;
}

.keys-list {
  display: grid;
  gap: 0.45rem;
  font-family: var(--mono);
  font-size: 0.75rem;
}

.key-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
}

.key-row.revoked {
  opacity: 0.55;
  text-decoration: line-through;
}

@media (max-width: 800px) {
  .keys-grid {
    grid-template-columns: 1fr;
  }
}
