:root {
  --paper: #fbf6ec;
  --paper-2: #f3e9d6;
  --white: #fff;
  --ink: #17130f;
  --soft: #6a6158;
  --line: #e6dac3;
  --haldi: #ffc93c;
  --leaf: #0b6e4f;
  --leaf-dark: #095c42;
  --chili: #b8410e;
  --bubble: #d9fdd3;
  --display: "Bricolage Grotesque", "Segoe UI", sans-serif;
  --body: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.55 var(--body); }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; letter-spacing: -0.02em; }
h1 { font-size: 32px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
p { margin: 0; }
a { color: var(--leaf); font-weight: 600; text-underline-offset: 4px; }
code, pre { font-family: var(--mono); font-size: 12.5px; }
code { overflow-wrap: anywhere; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--leaf); outline-offset: 2px; }
.mark { background: linear-gradient(transparent 62%, var(--haldi) 62%, var(--haldi) 92%, transparent 92%); }
.muted { color: var(--soft); }
.hint { color: var(--soft); font-size: 12.5px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); gap: 12px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

/* controls */
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--leaf); }
input[type="checkbox"] { width: 17px; height: 17px; margin: 2px 0 0; padding: 0; accent-color: var(--leaf); flex: none; }
.row > input, .row > select { width: auto; flex: 1 1 200px; }
.btn { font: 600 14px var(--body); background: var(--white); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 9px 16px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { border-color: var(--leaf); }
.btn.primary { background: var(--leaf); border-color: var(--leaf); color: #fff; }
.btn.primary:hover { background: var(--leaf-dark); }
.btn.danger { color: var(--chili); }
.btn.link { background: none; border: 0; padding: 0; color: var(--leaf); text-decoration: underline; }
.btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.45); padding: 5px 10px; font-size: 12.5px; margin-left: auto; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: default; }
.field { display: flex; flex-direction: column; gap: 5px; }
.label { font-weight: 600; font-size: 13.5px; }
.check { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; }
.check small { display: block; color: var(--soft); font-size: 12px; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
fieldset > .btn { align-self: flex-start; }
fieldset:disabled { opacity: .55; }
legend { font-weight: 700; margin-bottom: 10px; padding: 0; }
form > .btn { align-self: flex-start; }

/* login */
.login { max-width: 760px; margin: 0 auto; padding: 12vh 16px 40px; }
.login h1 { font-size: clamp(36px, 7vw, 56px); margin-bottom: 36px; }
.login-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 18px; }
.login-form { background: var(--white); border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 50px -30px rgba(80,52,14,.5); }

/* shell */
.shell { display: grid; grid-template-columns: 238px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--paper-2); padding: 22px 16px; display: flex; flex-direction: column; gap: 20px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font: 700 22px var(--display); color: var(--ink); text-decoration: none; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { color: var(--ink); text-decoration: none; padding: 8px 10px; border-radius: 8px; }
nav a:hover { background: var(--paper); }
nav a.on { background: var(--haldi); }
.who { margin-top: auto; font-size: 13px; color: var(--soft); display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.content { padding: 30px clamp(16px, 4vw, 48px) 70px; max-width: 1240px; width: 100%; display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.title { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 14px; }
.title p { color: var(--soft); margin-top: 6px; }
.title input { width: auto; }
.card { background: var(--white); border-radius: 12px; padding: 22px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
form.card.row { flex-direction: row; }
.notice { background: #fff1c9; border-radius: 8px; padding: 12px 14px; }
.notice.bad { background: #fde5da; color: #7c2a07; }
.notice.good { background: var(--bubble); display: flex; flex-direction: column; gap: 10px; }

/* home */
.flow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr); gap: 14px; align-items: stretch; }
.node { background: var(--white); border-radius: 12px; padding: 22px; display: flex; flex-direction: column; justify-content: center; }
.node strong { font: 700 22px var(--display); }
.node span { color: var(--soft); }
.node.green { background: var(--leaf); color: #fff; }
.node.green span { color: rgba(255,255,255,.82); }
.arrows { display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.arrows a { display: flex; align-items: center; justify-content: center; gap: 12px; background: var(--paper-2); border-radius: 8px; padding: 12px; text-align: center; color: var(--ink); text-decoration: none; }
.arrows a:hover { background: var(--haldi); }
.arrows b { font-size: 22px; color: var(--leaf); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 20px 30px; }
.steps li { display: flex; gap: 14px; }
.step { font: 700 34px/1 var(--display); color: var(--chili); min-width: 26px; }
.steps p { color: var(--soft); margin: 4px 0; }
.features { list-style: none; margin: 0; padding: 0; columns: 2 320px; column-gap: 32px; }
.features li { break-inside: avoid; padding: 8px 0 8px 26px; position: relative; border-bottom: 1px dashed var(--line); }
.features li::before { position: absolute; left: 0; font-weight: 700; }
.features li.yes::before { content: "✓"; color: var(--leaf); }
.features li.no::before { content: "–"; color: var(--soft); }
.features li.no { color: var(--soft); }
.features b, .features span { display: block; }
.features span { font-size: 13px; color: var(--soft); }

/* bot page and test chat */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 22px; align-items: start; }
.wa { position: sticky; top: 20px; background: var(--white); border-radius: 12px; overflow: hidden; box-shadow: 0 20px 50px -30px rgba(80,52,14,.5); }
.wa-head { background: var(--leaf); color: #fff; padding: 11px 14px; display: flex; align-items: baseline; gap: 10px; }
.wa-head span { font-size: 12px; opacity: .8; }
.wa-body { background: #efe7da; height: min(440px, 52vh); overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.wa-empty { margin: auto; text-align: center; color: var(--soft); max-width: 220px; }
.bubble { max-width: 86%; padding: 8px 11px; border-radius: 9px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; flex: none; }
.bubble.me { align-self: flex-end; background: var(--bubble); }
.bubble.them { align-self: flex-start; background: var(--white); }
.bubble.sys { align-self: center; background: #fff1c9; font-size: 13px; }
.bubble small { display: block; color: var(--soft); font-size: 10.5px; margin-top: 3px; }
.wa-form { display: flex; gap: 8px; padding: 10px; }
.wa-opts { padding: 0 12px 14px; display: flex; flex-direction: column; gap: 9px; font-size: 13px; }

/* wires and docs */
.wires, .group { display: flex; flex-direction: column; gap: 8px; }
details { background: var(--white); border-radius: 10px; }
summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 14px; padding: 13px 16px; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; font: 600 22px/1 var(--body); color: var(--leaf); }
details[open] > summary::after { content: "−"; }
.wire-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wire-name code { color: var(--soft); }
.wire-state { font-size: 12.5px; color: var(--soft); white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #cbbfa9; flex: none; }
.dot.on { background: #25d366; }
.wire-body { padding: 4px 16px 18px; display: flex; flex-direction: column; gap: 14px; border-top: 1px solid var(--paper-2); padding-top: 14px; }
.wire-body form { display: flex; flex-direction: column; gap: 14px; }
.verb { font: 500 11.5px var(--mono); width: 54px; text-align: center; padding: 3px 0; border-radius: 5px; background: var(--paper-2); flex: none; }
.verb.post { background: var(--bubble); }
.verb.patch { background: #fff1c9; }
.verb.delete { background: #fde5da; }
.section { margin-top: 14px; }
.group h3 { margin-top: 8px; }
dl { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 6px 14px; margin: 0; }
dt { font-weight: 700; }
dd { margin: 0; }
.plan { font-weight: 600; }
.plan.yes { color: var(--leaf); }
.plan.no { color: var(--chili); }
.plan span { color: var(--soft); font-weight: 400; }
.notes { margin: 0; padding-left: 20px; }
.code { background: #f7f1e4; border-radius: 8px; min-width: 0; }
.code-head { display: flex; justify-content: space-between; gap: 10px; padding: 7px 12px; font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--line); }
.copy { background: none; border: 0; color: var(--leaf); font: 600 12px var(--body); cursor: pointer; padding: 0; }
.code pre { margin: 0; padding: 12px; overflow: auto; max-height: 340px; }

/* tables, stats, chats, plans */
.scroll { overflow-x: auto; background: var(--white); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--paper-2); vertical-align: middle; }
th { color: var(--soft); font-weight: 600; }
td select { min-width: 120px; }
td .row { flex-wrap: nowrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: 12px; }
.stat { background: var(--white); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; }
.stat strong { font: 700 30px/1.25 var(--display); }
.stat span { color: var(--soft); font-size: 13px; }
.stat small { color: var(--soft); font-size: 12px; }
.chats { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.chats ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 70vh; overflow-y: auto; }
.chats li button { width: 100%; text-align: left; background: var(--white); border: 1px solid transparent; border-radius: 8px; padding: 10px 12px; cursor: pointer; font: inherit; display: flex; flex-direction: column; }
.chats li button:hover { border-color: var(--leaf); }
.chats li span { color: var(--soft); font-size: 12px; }
.history { background: #efe7da; border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 16px; align-items: start; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--paper-2); color: var(--soft); }
.pill.on { background: var(--bubble); color: var(--leaf-dark); }
.pill.off { background: #fde5da; color: #7c2a07; }
.result-list { display: flex; flex-direction: column; gap: 10px; }
.result-item { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }

#toast { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 10; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: var(--paper); padding: 11px 16px; border-radius: 8px; }
.toast.bad { background: #8f2f08; color: #fff; }

@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .wa { position: static; order: -1; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; gap: 12px; padding: 14px 16px; }
  nav { flex-direction: row; overflow-x: auto; }
  nav a { white-space: nowrap; }
  .who { flex-direction: row; justify-content: space-between; margin-top: 0; }
  .flow, .chats { grid-template-columns: minmax(0, 1fr); }
  dl { grid-template-columns: minmax(0, 1fr); }
  form.card.row { flex-direction: column; align-items: stretch; }
}
