:root {
  --bg0: #0f1412;
  --bg1: #171e1b;
  --bg2: #1f2924;
  --line: #2c3a33;
  --text: #e7efe9;
  --muted: #9bb0a4;
  --accent: #3dba7a;
  --accent-2: #c9a227;
  --danger: #d96b6b;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --font: "Vazirmatn", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, #1b3a2c 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #2a2414 0%, transparent 50%),
    var(--bg0);
  color: var(--text);
  font-family: var(--font);
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr 300px;
  height: 100vh;
  min-height: 100dvh;
}

.sidebar,
.inspector {
  background: color-mix(in srgb, var(--bg1) 92%, black);
  border-inline-end: 1px solid var(--line);
  padding: 16px;
  overflow: auto;
}

.inspector {
  border-inline-end: 0;
  border-inline-start: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: linear-gradient(145deg, var(--accent), #1f6b45);
  box-shadow: var(--shadow);
}

.brand-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.8rem;
}

.section-label {
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.run-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.run-item {
  text-align: right;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
}

.run-item.active {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line));
  box-shadow: inset 3px 0 0 var(--accent);
}

.run-item small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.sidebar-foot {
  margin-top: 18px;
  font-size: 0.75rem;
  color: var(--muted);
}

.main {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg1) 80%, transparent);
  backdrop-filter: blur(10px);
}

.selectors,
.top-actions,
.composer-actions {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--muted);
}

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

select,
textarea,
input {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 140px;
}

.primary-btn,
.ghost-btn {
  border-radius: 11px;
  padding: 9px 14px;
  border: 1px solid transparent;
  cursor: pointer;
}

.primary-btn {
  width: 100%;
  background: var(--accent);
  color: #062214;
  font-weight: 600;
}

.ghost-btn {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

.ghost-btn.danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
}

.chat-panel {
  overflow: auto;
  padding: 20px;
}

.empty {
  max-width: 520px;
  margin: 12vh auto 0;
  text-align: center;
}

.empty h1 {
  font-size: 1.6rem;
  margin: 0 0 10px;
}

.empty p {
  color: var(--muted);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 860px;
  margin: 0 auto;
}

.msg {
  border: 1px solid var(--line);
  background: var(--bg1);
  border-radius: var(--radius);
  padding: 12px 14px;
  white-space: pre-wrap;
  line-height: 1.7;
}

.msg.user {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg1));
}

.msg .role {
  color: var(--muted);
  font-size: 0.75rem;
  margin-bottom: 6px;
}

.composer {
  border-top: 1px solid var(--line);
  padding: 12px 18px 16px;
  background: color-mix(in srgb, var(--bg1) 88%, black);
}

.composer textarea {
  width: 100%;
  resize: vertical;
  min-height: 64px;
}

.composer-actions {
  margin-top: 8px;
  justify-content: space-between;
}

.composer-actions input {
  flex: 1;
}

.composer-actions .primary-btn {
  width: auto;
  min-width: 110px;
}

.meta {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.55;
  overflow: auto;
}

.meta.log {
  min-height: 220px;
  max-height: 55vh;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
  .inspector {
    display: none;
  }
  .sidebar {
    border: 0;
    border-bottom: 1px solid var(--line);
    max-height: 34vh;
  }
}
