:root {
  --bg: #070b10;
  --bg-elevated: #101820;
  --bg-ink: #0c131b;
  --fg: #ece6d6;
  --muted: #8b938c;
  --accent: #c9a36a;
  --accent-fg: #1a140c;
  --accent-2: #6f9b94;
  --border: rgba(236, 230, 214, 0.12);
  --border-strong: rgba(201, 163, 106, 0.38);
  --danger: #c97862;
  --success: #7ea8a0;
  --radius: 6px;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.42);
  --pad: clamp(16px, 3.6vw, 40px);
  --max: 880px;
  --panel-max: 1080px;
  --type-display: clamp(2.6rem, 9vw, 5.4rem);
  --type-title: clamp(1.15rem, 2vw, 1.45rem);
  --type-body: 1rem;
  --type-label: 0.75rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: Vazirmatn, sans-serif;
  font-size: var(--type-body);
  line-height: 1.7;
}

.studio {
  min-height: 100dvh;
  position: relative;
}

.atmosphere,
.mesh,
.grain,
.frame,
.rail {
  pointer-events: none;
  position: fixed;
  inset: 0;
}

.atmosphere {
  background:
    radial-gradient(1100px 640px at 88% -8%, rgba(201, 163, 106, 0.16), transparent 58%),
    radial-gradient(820px 520px at -12% 108%, rgba(111, 155, 148, 0.12), transparent 52%),
    linear-gradient(165deg, #0a1017 0%, #070b10 42%, #0c141c 100%);
  z-index: 0;
}

.mesh {
  z-index: 1;
  opacity: 0.28;
  background-image:
    linear-gradient(rgba(201, 163, 106, 0.11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201, 163, 106, 0.08) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at 70% 0%, #000 0%, transparent 72%);
}

.grain {
  z-index: 2;
  opacity: 0.07;
  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='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.frame {
  z-index: 4;
  inset: 14px;
  border: 1px solid rgba(201, 163, 106, 0.16);
}

.frame::before,
.frame::after {
  content: "";
  position: absolute;
  width: 28px;
  height: 28px;
  border: 2px solid var(--accent);
}

.frame::before {
  top: -1px;
  right: -1px;
  border-left: 0;
  border-bottom: 0;
}

.frame::after {
  bottom: -1px;
  left: -1px;
  border-right: 0;
  border-top: 0;
}

.rail {
  z-index: 3;
  inset: auto 22px 18% auto;
  top: 16%;
  width: 2px;
  background: linear-gradient(to bottom, transparent, var(--accent) 18%, var(--accent) 82%, transparent);
  opacity: 0.42;
}

.gate,
.app,
.panel-app {
  position: relative;
  z-index: 5;
}

.wordmark {
  margin: 0;
  font-family: Syne, Vazirmatn, sans-serif;
  font-weight: 800;
  letter-spacing: 0.22em;
  font-size: 0.82rem;
  color: var(--accent);
}

.wordmark.display {
  font-size: var(--type-display);
  letter-spacing: 0.18em;
  line-height: 0.92;
  color: var(--fg);
  text-shadow: 0 0 0 transparent;
}

.eyebrow {
  margin: 0 0 12px;
  font-family: Syne, Vazirmatn, sans-serif;
  font-size: var(--type-label);
  letter-spacing: 0.28em;
  color: var(--accent);
}

h1 {
  margin: 16px 0 0;
  font-size: var(--type-title);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.lede,
.clock,
.composer-hint,
.caption,
.panel-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.kicker {
  margin: 0 0 8px;
  font-size: var(--type-label);
  letter-spacing: 0.16em;
  color: var(--accent);
  font-family: Syne, Vazirmatn, sans-serif;
}

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--pad);
}

.gate-inner {
  width: min(460px, 100%);
}

.gate-inner::after {
  content: "";
  display: block;
  width: 72px;
  height: 2px;
  margin: 20px 0 0;
  background: var(--accent);
}

.gate form {
  display: grid;
  gap: 10px;
  margin-top: 1.6rem;
}

label {
  font-size: var(--type-label);
  letter-spacing: 0.06em;
  color: var(--muted);
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(16, 24, 32, 0.82);
  color: var(--fg);
  border-radius: var(--radius);
  padding: 14px 16px;
}

input:focus,
textarea:focus,
select:focus-visible,
button:focus-visible,
.site-nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button {
  border: 0;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 700;
  border-radius: var(--radius);
  padding: 12px 18px;
  min-height: 44px;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.06);
}

button:active {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.error {
  color: var(--danger);
  margin: 0;
}

.app,
.panel-app {
  min-height: 100dvh;
  display: grid;
  width: min(var(--max), calc(100% - 48px));
  margin: 0 auto;
  padding: 8px 0 12px;
}

.app {
  grid-template-rows: auto 1fr auto;
}

.panel-app {
  width: min(var(--panel-max), calc(100% - 48px));
  grid-template-rows: auto auto 1fr;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px 24px;
  padding: 28px 0 18px;
  border-bottom: 1px solid var(--border);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.hairline {
  width: 1px;
  height: 28px;
  background: var(--border-strong);
}

.status-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.status-cluster p,
#status-line {
  margin: 0;
  font-size: 0.92rem;
  color: var(--fg);
}

.pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 8px;
  box-shadow: 0 0 0 4px rgba(201, 163, 106, 0.08);
}

.pip[data-state="ok"] {
  background: var(--success);
}

.pip[data-state="connecting"],
.pip[data-state="http"] {
  background: var(--accent);
}

.pip[data-state="error"] {
  background: var(--danger);
}

.top-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 4px;
}

.model-pick {
  display: flex;
  min-width: 0;
}

.model-pick select {
  width: auto;
  max-width: 220px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(16, 24, 32, 0.45);
  color: var(--fg);
  cursor: pointer;
}

.model-pick select:disabled {
  opacity: 0.55;
  cursor: wait;
}

.site-nav {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(16, 24, 32, 0.45);
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  min-height: 44px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
}

.site-nav a[aria-current="page"] {
  color: var(--accent-fg);
  background: var(--accent);
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 500;
}

button.ghost:hover {
  filter: none;
  color: var(--accent);
  border-color: var(--accent);
}

.stage {
  position: relative;
  min-height: 0;
  display: grid;
}

.empty-log {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: start;
  padding: 32px 0;
}

.empty-log[hidden] {
  display: none;
}

.empty-title {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 600;
  letter-spacing: -0.03em;
}

.watermark {
  position: absolute;
  top: 8%;
  left: 0;
  margin: 0;
  font-family: Syne, sans-serif;
  font-size: clamp(6rem, 22vw, 12rem);
  font-weight: 800;
  letter-spacing: -0.08em;
  color: rgba(201, 163, 106, 0.07);
  line-height: 0.8;
  user-select: none;
}

.log {
  overflow: auto;
  padding: 28px 0 16px;
  display: grid;
  gap: 22px;
  align-content: start;
}

.msg {
  max-width: 86%;
  min-width: 0;
}

.msg .who {
  display: block;
  font-size: var(--type-label);
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 6px;
  font-family: Syne, Vazirmatn, sans-serif;
}

.msg .body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.8;
}

.msg.user {
  justify-self: start;
}

.msg.user .who {
  color: var(--accent-2);
}

.msg.assistant {
  justify-self: stretch;
  max-width: 100%;
  padding-right: 14px;
  border-right: 2px solid rgba(201, 163, 106, 0.45);
}

.msg.error {
  max-width: 100%;
  justify-self: stretch;
}

.msg.error .who,
.msg.error .body {
  color: var(--danger);
}

.msg.error .body {
  white-space: normal;
  font-size: 0.95rem;
  line-height: 1.6;
}

.msg.progress {
  color: var(--muted);
}

.msg.progress .body {
  font-size: 0.92rem;
}

.composer {
  padding: 8px 0 28px;
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--bg) 62%, transparent);
}

.composer-shell {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  background: rgba(12, 19, 27, 0.88);
  box-shadow: var(--shadow);
}

.composer-shell:focus-within {
  border-color: var(--border-strong);
}

.composer textarea {
  resize: none;
  min-height: 56px;
  max-height: 180px;
  border: 0;
  background: transparent;
  padding: 12px 8px;
}

.composer textarea:focus {
  outline: none;
}

.composer button {
  align-self: end;
  min-width: 96px;
}

.composer-hint {
  margin: 8px 8px 0;
  font-size: 0.78rem;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.panel-meta {
  margin: 14px 0 0;
}

.panel-meta.error {
  color: var(--danger);
}

.board {
  padding: 28px 0 56px;
  display: grid;
  gap: 40px;
  align-content: start;
}

.block {
  min-width: 0;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.block:first-child {
  border-top: 0;
  padding-top: 0;
}

.id-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}

.id-line strong {
  font-size: clamp(1.4rem, 2.4vw, 1.85rem);
  font-weight: 600;
  letter-spacing: -0.03em;
}

.muted {
  color: var(--muted);
}

.caption {
  margin: 12px 0 0;
  font-size: 0.82rem;
}

.facts {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 8px 16px;
  margin: 0;
}

.facts.compact {
  grid-template-columns: 7.5rem auto;
}

.facts dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.res-grid {
  display: grid;
  gap: 20px;
}

.res-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 0.88rem;
}

.res-head .muted {
  font-size: 0.82rem;
  text-align: left;
}

.meter {
  height: 3px;
  background: var(--border);
  overflow: hidden;
}

.meter > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent-2);
}

.meter.warn > i {
  background: var(--accent);
}

.meter.hot > i {
  background: var(--danger);
}

.split {
  display: grid;
  gap: 40px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 8px;
}

.dot.ok {
  background: var(--success);
}

.dot.warn {
  background: var(--accent);
}

.dot.down {
  background: var(--danger);
}

.ok-text {
  color: var(--success);
}

.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.grid th,
.grid td {
  text-align: start;
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.grid th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.grid tr.dim td {
  color: var(--muted);
}

.activity {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 18px;
}

.act-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 0.78rem;
  color: var(--accent);
  margin-bottom: 4px;
}

.activity p {
  margin: 0;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.log-stream {
  margin: 0;
  max-height: 280px;
  overflow: auto;
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.65;
  color: var(--muted);
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.state h2 {
  margin: 0.2rem 0 8px;
  font-size: 1.2rem;
}

.skel {
  display: grid;
  gap: 16px;
}

.skel-row {
  display: grid;
  gap: 16px;
}

.skel-block {
  height: 72px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--bg-elevated), #18222d, var(--bg-elevated));
  background-size: 200% 100%;
}

.skel-block.tall {
  height: 160px;
}

.llm-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.llm-item {
  display: grid;
  gap: 4px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.llm-item .host {
  font-size: 0.82rem;
}

@media (min-width: 760px) {
  .res-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .split {
    grid-template-columns: 1fr 1fr;
  }

  .skel-row {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .app,
  .panel-app {
    width: min(100% - 28px, 1080px);
  }

  .frame {
    inset: 8px;
  }

  .rail {
    display: none;
  }

  .top {
    align-items: start;
    flex-direction: column;
  }

  .top-meta {
    width: 100%;
    justify-content: space-between;
  }

  .model-pick select {
    max-width: 160px;
  }

  .brand-lockup {
    width: 100%;
  }

  .composer-shell {
    grid-template-columns: 1fr;
  }

  .composer button {
    width: 100%;
  }

  .facts,
  .facts.compact {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }

  .facts dd {
    margin-bottom: 8px;
  }

  .grid th:nth-child(4),
  .grid td:nth-child(4) {
    display: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .gate-inner,
  .app,
  .panel-app {
    animation: enter 0.45s ease-out;
  }

  .msg {
    animation: rise 0.28s ease;
  }

  .skel-block {
    animation: pulse 1.2s ease-in-out infinite;
  }

  .composer-shell {
    transition: border-color 0.2s ease;
  }
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 0.95;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gate-inner,
  .app,
  .panel-app,
  .msg,
  .skel-block {
    animation: none;
  }

  button:active {
    transform: none;
  }
}
