:root {
  color-scheme: dark;
  font: 16px/1.5 system-ui, sans-serif;
  background: #101322;
  color: #f2f1fa;
  --accent: #c1afff;
  --accent-ink: #211338;
  --muted: #b7b9d1;
  --line: #414661;
  --panel: #191e33;
  --sidebar: #171b2e;
  --input: #121628;
  --raised: #252b45;
  --selected: #39305e;
  --selected-line: #9d87e8;
  --feedback: #ffdfad;
  accent-color: #b9a5ff;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse at 85% 0%, #292345 0, transparent 42rem); }
header { display: flex; justify-content: space-between; align-items: center; padding: 1rem max(1rem, calc((100vw - 60rem) / 2)); border-bottom: 1px solid var(--line); background: #15192b; }
.brand { font-size: 1.4rem; font-weight: 800; color: inherit; text-decoration: none; }
.brand span, a { color: var(--accent); }
.environment { color: var(--muted); }
main { max-width: 62rem; margin: auto; padding: 2rem 1rem; }
h1 { font-size: clamp(2rem, 6vw, 3.4rem); line-height: 1.1; margin: 0.5em 0; }
h2 { margin-top: 0; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.card { background: var(--panel); padding: 1.25rem; border: 1px solid var(--line); border-radius: 1rem; box-shadow: 0 10px 24px rgb(8 10 22 / 18%); }
.metrics strong { display: block; font-size: 2rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.row input { flex: 1 1 12rem; }
label { display: block; margin-bottom: 0.35rem; }
input, select, textarea, button { font: inherit; padding: 0.65rem 0.8rem; border: 1px solid var(--line); border-radius: 0.5rem; max-width: 100%; }
input, select, textarea { background: var(--input); color: inherit; }
textarea { width: 100%; resize: vertical; }
button { background: var(--accent); color: var(--accent-ink); cursor: pointer; font-weight: 700; }
button:disabled { opacity: 0.55; cursor: wait; }
#conversation, #companies { padding: 0; list-style: none; }
#companies li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; padding: 0.75rem 0; border-top: 1px solid var(--line); }
#conversation { min-height: 6rem; max-height: 28rem; overflow: auto; }
#conversation li { background: var(--raised); border-radius: 0.65rem; margin-bottom: 0.5rem; padding: 0.75rem; }
#conversation p { margin: 0.3rem 0; white-space: pre-wrap; overflow-wrap: anywhere; }
#send-message button { display: block; margin-top: 0.75rem; }
#status:empty { display: none; }
.login { max-width: 30rem; padding-top: 12vh; }
.console { display: grid; grid-template-columns: 14rem minmax(0, 1fr); max-width: 84rem; gap: 2rem; }
.sidebar { display: flex; flex-direction: column; align-self: start; gap: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 0.8rem; background: var(--sidebar); min-width: 0; }
.sidebar nav, .stack { display: grid; gap: 0.45rem; }
.sidebar small { color: var(--muted); overflow-wrap: anywhere; }
.sidebar button { text-align: left; }
.sidebar nav button:not([aria-current]) { background: transparent; border-color: transparent; color: var(--muted); }
.sidebar nav button:not([aria-current]):hover { background: var(--raised); color: inherit; }
.sidebar button[aria-current] { background: var(--selected); border-color: var(--selected-line); }
.workspace > .card { margin-bottom: 1rem; }
.workspace h1 { margin-top: 0; }
.secondary { background: var(--raised); color: var(--accent); }
.console form, .login form { display: grid; align-items: start; justify-items: start; gap: 0.75rem; margin: 0.7rem 0; }
.console label, .login label { width: min(100%, 34rem); }
.console label > :is(input, select, textarea), .login label > input { display: block; margin-top: 0.3rem; width: 100%; }
.console label > input[type=checkbox] { display: inline; width: auto; margin-left: 0.5rem; }
.feedback { color: var(--feedback); }
.feedback:empty { display: none; }
details { border-bottom: 1px solid var(--line); padding: 0.6rem 0; }
summary { cursor: pointer; overflow-wrap: anywhere; }
.live-log { max-height: 29rem; overflow: auto; }
#conversation li:has(small) { border: 1px solid var(--line); }
.bubble { background: var(--raised); padding: 0.7rem; border-radius: 0.55rem; }
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; }
dl { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; max-width: 30rem; }
button:hover { filter: brightness(1.13); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 720px) {
  .console { grid-template-columns: 1fr; gap: 1rem; padding-top: 1rem; }
  .sidebar nav { display: flex; flex-wrap: wrap; }
  .sidebar button { padding: 0.4rem 0.55rem; }
}
.attachment-preview { display: block; max-width: min(100%, 25rem); max-height: 22rem; margin: 0.45rem 0; border-radius: 0.45rem; }
.flow-rules, .flow-step { width: 100%; }
.flow-rules:empty { display: none; }
.flow-step { border: 1px solid var(--line); border-radius: 0.65rem; padding: 0.9rem; margin: 0 0 0.6rem; min-width: 0; }
.flow-step legend { color: var(--accent); padding: 0 0.35rem; }
.flow-step [hidden] { display: none; }
