:root {
  --bg0: #10151c;
  --bg1: #182230;
  --ink: #eef3f8;
  --muted: #9aacbd;
  --line: rgba(238, 243, 248, 0.12);
  --amber: #e0a21a;
  --amber-ink: #1a1406;
  --ok: #3dba86;
  --danger: #e25b4c;
  --warn: #d89a3a;
  --panel: rgba(18, 26, 36, 0.82);
  --font: "Manrope", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  background: var(--bg0);
  min-height: 100%;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(224, 162, 26, 0.18), transparent 55%),
    radial-gradient(700px 420px at 90% 10%, rgba(74, 130, 180, 0.16), transparent 50%),
    linear-gradient(160deg, #0d1218 0%, #152031 45%, #101820 100%);
}
.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 40% 20%, black, transparent 75%);
}

.screen { min-height: 100vh; }
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  border: 0;
}

.brand, .brand-sm {
  margin: 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--amber);
}
.brand { font-size: 0.85rem; margin-bottom: 0.75rem; }
.brand-sm { font-size: 0.72rem; opacity: 0.95; }

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}
h2 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
h3 { margin: 0 0 0.4rem; font-size: 1.05rem; }

.lead, .meta, .empty { color: var(--muted); }
.lead { margin: 0.75rem 0 1.5rem; line-height: 1.45; max-width: 28rem; }

.login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem;
  max-width: 28rem;
  margin: 0 auto;
  animation: rise 0.55s ease both;
}

#login-form {
  display: grid;
  gap: 0.75rem;
}
input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(8, 12, 18, 0.55);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  font: 500 1rem/1.3 var(--font);
}
input:focus {
  outline: 2px solid rgba(224, 162, 26, 0.45);
  outline-offset: 1px;
}
input[readonly] {
  opacity: 0.7;
  font-family: var(--mono);
  font-size: 0.9rem;
}

.btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  font: 700 0.92rem/1.2 var(--font);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: var(--amber);
  color: var(--amber-ink);
  border-color: transparent;
}
.btn.ghost { color: var(--muted); }
.btn.danger {
  border-color: rgba(226, 91, 76, 0.45);
  color: #ffb0a8;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.error { color: #ff9d93; margin: 0.25rem 0 0; font-size: 0.9rem; }

.top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--line);
  animation: rise 0.45s ease both;
}
.top-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 0;
  min-height: calc(100vh - 5.5rem);
}

.rail {
  border-right: 1px solid var(--line);
  padding: 1.25rem 1rem;
  background: rgba(8, 12, 18, 0.35);
}
.list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}
.list button {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  border-radius: 8px;
  padding: 0.65rem 0.7rem;
  cursor: pointer;
  font: 600 0.9rem/1.25 var(--font);
}
.list button:hover,
.list button.active {
  background: rgba(224, 162, 26, 0.1);
  border-color: rgba(224, 162, 26, 0.35);
}
.list .id {
  display: block;
  font-family: var(--mono);
  font-size: 0.78rem;
}
.list .st {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail {
  padding: 1.25rem 1.5rem 2.5rem;
  animation: fade 0.35s ease both;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.awaiting_approval { color: var(--amber); border-color: rgba(224,162,26,.4); }
.badge.executing { color: #7eb6ff; border-color: rgba(126,182,255,.4); }
.badge.done { color: var(--ok); border-color: rgba(61,186,134,.4); }
.badge.failed, .badge.cancelled { color: var(--danger); border-color: rgba(226,91,76,.4); }

.narrative {
  white-space: pre-wrap;
  line-height: 1.5;
  margin: 0.5rem 0 0;
}
.context {
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
  max-height: 220px;
  overflow: auto;
  margin: 0;
}

.action {
  border-top: 1px solid var(--line);
  padding: 1rem 0 0.25rem;
}
.action:first-of-type { border-top: 0; padding-top: 0.25rem; }
.action-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}
.action .owner {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--amber);
}
.action p {
  margin: 0.45rem 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.5rem 0;
}
.chip {
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  color: var(--muted);
}
.decide {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.75rem;
}
.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
}
.seg label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.4rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
}
.seg input { width: auto; accent-color: var(--amber); }
.seg label:has(input:checked) {
  border-color: rgba(224, 162, 26, 0.55);
  background: rgba(224, 162, 26, 0.12);
}
textarea {
  width: 100%;
  min-height: 64px;
  resize: vertical;
  border: 1px solid var(--line);
  background: rgba(8, 12, 18, 0.55);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  font: 500 0.9rem/1.35 var(--font);
}

.actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.discussion {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}
.discussion li {
  border-left: 2px solid rgba(224,162,26,.35);
  padding: 0.2rem 0 0.2rem 0.7rem;
}
.discussion .who {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--amber);
}
.discussion .txt {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: #1c2734;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-width: min(24rem, calc(100vw - 2rem));
  animation: rise 0.25s ease both;
}

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

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .top {
    flex-direction: column;
    align-items: stretch;
  }
}
