:root {
  --bg: #0c1016;
  --panel: #141a22;
  --ink: #e8edf4;
  --muted: #8b97a8;
  --line: #243040;
  --accent: #3ee0b2;
  --warn: #e7b86a;
  --bad: #ef7a7a;
  --user: #7eb6ff;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: "IBM Plex Sans Thai", "IBM Plex Sans", sans-serif;
  min-height: 100vh;
}
a { color: var(--accent); }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 0.85rem 1.25rem; border-bottom: 1px solid var(--line); background: #0a0e13;
}
.brand { display: flex; gap: 0.7rem; align-items: center; text-decoration: none; color: inherit; }
.brand small { display: block; color: var(--muted); font-size: 0.78rem; }
.live-dot {
  width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 rgba(62, 224, 178, 0.7); animation: pulse 1.8s infinite;
}
nav { display: flex; gap: 1rem; align-items: center; }
nav a, nav button { color: var(--ink); background: none; border: 0; font: inherit; cursor: pointer; }
.page { max-width: 1180px; margin: 0 auto; padding: 1.4rem 1.1rem 3rem; }
.hero, .show-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-end; }
h1 { margin: 0 0 0.35rem; font-size: 1.55rem; }
.lede, .muted, .kicker { color: var(--muted); }
.primary, button.primary {
  background: var(--accent); color: #06231a; border: 0; padding: 0.65rem 0.95rem;
  border-radius: 0.4rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block;
}
.stack { display: grid; gap: 0.85rem; }
label, legend { display: grid; gap: 0.3rem; font-weight: 500; }
input, textarea, select {
  font: inherit; padding: 0.65rem 0.7rem; border: 1px solid var(--line);
  border-radius: 0.4rem; background: #0f151c; color: var(--ink);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 1.15rem) calc(50% - 0.18rem), calc(100% - 0.85rem) calc(50% - 0.18rem); background-size: 0.4rem 0.4rem, 0.4rem 0.4rem; background-repeat: no-repeat; padding-right: 2rem; }
.card, .auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 0.8rem; padding: 1.15rem; }
.auth-card, .narrow { max-width: 640px; }
.banner { padding: 0.7rem 0.9rem; border-radius: 0.45rem; }
.banner.ok { background: #163328; }
.banner.bad { background: #3a1c1c; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.7rem; margin: 1.2rem 0; }
.stats article { background: var(--panel); border: 1px solid var(--line); padding: 0.8rem; border-radius: 0.55rem; }
.stats strong { font-size: 1.3rem; display: block; }
.grid { width: 100%; border-collapse: collapse; background: var(--panel); }
.grid th, .grid td { text-align: left; padding: 0.7rem; border-bottom: 1px solid var(--line); }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28rem; }
.pill { display: inline-block; padding: 0.2rem 0.55rem; border-radius: 999px; font-size: 0.82rem; background: #243040; }
.pill.queued, .pill.submitted { background: #3a3118; color: var(--warn); }
.pill.analyzing, .pill.preparing_sandbox, .pill.patching, .pill.simulating, .pill.verifying, .pill.deploying { background: #163328; color: var(--accent); }
.pill.verified_awaiting_deploy, .pill.completed { background: #163328; }
.pill.failed, .pill.cancelled { background: #3a1c1c; color: var(--bad); }
.pill.pulsing { animation: pulse 1.6s infinite; }
.thumbs { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.thumbs img { width: 108px; height: 80px; object-fit: cover; border-radius: 0.35rem; border: 1px solid var(--line); }
.note { background: #2a2416; padding: 0.7rem; border-radius: 0.45rem; color: var(--warn); }
.pre { white-space: pre-wrap; }
.agent-shell { display: grid; grid-template-columns: 320px 1fr; gap: 1rem; min-height: 70vh; }
.ticket, .transcript-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 0.8rem; }
.ticket { padding: 1rem; }
.ticket-block { margin-top: 1rem; }
.ticket-block h2 { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.3rem; }
.agent-head { display: flex; justify-content: space-between; align-items: center; padding: 0.9rem 1rem; border-bottom: 1px solid var(--line); }
.transcript { padding: 1rem; display: grid; gap: 0.75rem; max-height: 68vh; overflow: auto; }
.bubble { border: 1px solid var(--line); border-radius: 0.7rem; padding: 0.75rem 0.85rem; background: #10161e; }
.bubble.user { border-color: #2a4466; }
.bubble.tool { border-color: #1e3d34; }
.bubble.error { border-color: #5a2a2a; }
.bubble .who { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.bubble h3 { margin: 0.2rem 0 0.35rem; font-size: 0.98rem; }
.bubble pre {
  margin: 0; white-space: pre-wrap; font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem; color: #c9d4e2; max-height: 220px; overflow: auto;
}
.typing { display: flex; gap: 0.35rem; align-items: center; color: var(--muted); padding: 0 1rem 1rem; font-size: 0.9rem; }
.typing span {
  width: 0.4rem; height: 0.4rem; border-radius: 50%; background: var(--accent);
  animation: bounce 1s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
.hidden { display: none; }
.tabs {
  display: flex; gap: 0.4rem; padding: 0.3rem;
  background: #0f151c; border: 1px solid var(--line); border-radius: 0.7rem;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem;
  padding: 0.7rem 0.85rem; border: 0; border-radius: 0.5rem;
  background: transparent; color: var(--ink); font: inherit; cursor: pointer; text-align: left;
}
.tab-state { display: none; font-size: 0.75rem; color: var(--accent); }
.tab.is-active {
  background: #163328; color: var(--accent); box-shadow: inset 0 0 0 1px #1e4a3c;
}
.tab.is-active .tab-state { display: inline; }
.panel { display: grid; }
.panel[hidden] { display: none; }
.field-label { margin: 0; font-weight: 500; }
.readonly-field {
  margin: 0; font-family: "IBM Plex Mono", monospace; font-size: 0.82rem;
  padding: 0.65rem 0.7rem; border: 1px dashed var(--line); border-radius: 0.4rem;
  background: #0a0e13; color: var(--muted); word-break: break-all;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(62, 224, 178, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(62, 224, 178, 0); }
  100% { box-shadow: 0 0 0 0 rgba(62, 224, 178, 0); }
}
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-3px); opacity: 1; }
}
@media (max-width: 900px) {
  .agent-shell, .hero { grid-template-columns: 1fr; display: flex; flex-direction: column; }
}
