:root {
  color-scheme: light;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  --canvas: #f5f6fa;
  --surface: #fff;
  --rail: #eef0fa;
  --ink: #1b213e;
  --muted: #555d79;
  --rule: #d9ddec;
  --blue: #233a93;
  --on-blue: #fff;
  --blue-soft: #e1e8fc;
  --mint: #acdfcd;
  --mint-ink: #145543;
  --mint-bg: #e4f4ee;
  --amber-ink: #78541a;
  --amber-bg: #fbf0d9;
  --danger: #a82747;
  --danger-bg: #fdebf0;
  --stage: #1f327c;
  --stage-text: #fff;
  --stage-muted: #dbe4fd;
  --stage-rule: #7189db;
  --focus: #3456c4;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --canvas: #141829;
    --surface: #1e2439;
    --rail: #171d32;
    --ink: #f2f4ff;
    --muted: #b7c0df;
    --rule: #3c4664;
    --blue: #b8caff;
    --on-blue: #172457;
    --blue-soft: #273861;
    --mint-ink: #b4ead7;
    --mint-bg: #253f43;
    --amber-ink: #ffd28f;
    --amber-bg: #4b3b30;
    --danger: #ffb0bc;
    --danger-bg: #513246;
    --stage: #263c87;
    --stage-rule: #8098e2;
    --focus: #b8caff;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; }
button, select, summary { cursor: pointer; }
button:disabled { opacity: .6; cursor: wait; }
button, a, summary, input, textarea, select { outline-offset: 3px; }
:focus-visible { outline: 2px solid var(--focus); }
a { color: var(--blue); text-underline-offset: 4px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { letter-spacing: -.035em; line-height: 1.18; }
h1 { font-size: clamp(1.7rem, 4vw, 2.34rem); }
h2 { font-size: 1.42rem; }
h3 { font-size: 1.06rem; overflow-wrap: anywhere; }
p { color: var(--muted); }
.symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.icon { width: 20px; height: 20px; flex: 0 0 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.gate { max-width: 35rem; margin: min(16vh, 128px) auto; padding: 28px; }
.gate h1 { margin: 20px 0 12px; }
.workspace { display: grid; min-height: 100vh; grid-template-columns: minmax(214px, 252px) minmax(0, 1fr); }
.rail { background: var(--rail); border-right: 1px solid var(--rule); padding: 29px 18px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 1px 8px; }
.brand img { flex: none; }
.brand strong { display: block; font-size: 1.13rem; font-weight: 750; letter-spacing: -.025em; }
.brand span { display: block; color: var(--muted); font-size: .81rem; }
.bot-nav { margin-top: 40px; }
.rail-label { display: flex; align-items: center; justify-content: space-between; padding: 0 9px 12px; }
.rail-label h2 { font-size: .93rem; font-weight: 680; letter-spacing: 0; }
.rail-label > span { font-variant-numeric: tabular-nums; font-size: .8rem; color: var(--muted); }
.bot-list { display: grid; gap: 6px; }
.mobile-bots { display: none; }
.bot-pick { background: transparent; border: 1px solid transparent; border-radius: 12px; color: var(--ink); padding: 11px 10px; min-height: 56px; display: flex; width: 100%; min-width: 0; gap: 9px; align-items: center; text-align: left; }
.bot-pick:hover { background: var(--surface); }
.bot-pick[aria-pressed="true"] { background: var(--blue-soft); border-color: var(--rule); color: var(--blue); }
.bot-pick:active, .button:active, .icon-button:active { opacity: .75; }
.bot-pick .names { min-width: 0; overflow-wrap: anywhere; }
.names strong, .names small { display: block; }
.names strong { font-size: .88rem; font-weight: 680; }
.names small { color: var(--muted); font-size: .78rem; }
.content { width: 100%; max-width: 1120px; margin: 0 auto; min-width: 0; padding: 36px clamp(24px,4vw,56px) 48px; }
.top { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 18px; margin-bottom: 28px; }
.mode { margin-bottom: 6px; font-size: .81rem; font-weight: 660; color: var(--muted); }
.top-actions, .dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 14px; border: 1px solid transparent; border-radius: 9px; font-size: .88rem; font-weight: 680; text-decoration: none; line-height: 1.3; transition: opacity .15s, background-color .15s; }
.button .icon { width: 17px; height: 17px; flex-basis: 17px; }
.primary { color: var(--on-blue); background: var(--blue); }
.primary:hover { opacity: .9; }
.secondary { color: var(--ink); background: var(--surface); border-color: var(--rule); }
.secondary:hover { background: var(--blue-soft); }
.stage { position: relative; isolation: isolate; overflow: hidden; color: var(--stage-text); background: var(--stage); border-radius: 18px; min-height: 168px; padding: 26px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.stage-copy { min-width: 0; }
.stage-id { display: flex; gap: 12px; align-items: center; }
.stage-icon { width: 46px; height: 46px; border-radius: 12px; background: #ffffff17; color: var(--stage-muted); display: grid; place-items: center; flex: none; }
.stage h2 { font-size: clamp(1.35rem, 3.2vw, 1.83rem); overflow-wrap: anywhere; }
.stage p { color: var(--stage-muted); overflow-wrap: anywhere; margin-top: 3px; font-size: .915rem; }
.stage-tools { display: flex; flex-wrap: wrap; align-items: center; margin-top: 18px; gap: 10px 14px; }
.stage .button { background: transparent; color: var(--stage-text); border-color: var(--stage-rule); }
.stage .button:hover { background: #ffffff18; }
.stage :focus-visible { outline-color: var(--stage-text); }
.status { display: inline-flex; align-items: center; gap: 6px; color: inherit; font-size: .81rem; font-weight: 650; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.stage .status { color: var(--stage-muted); }
.stage .status.running, .stage .status.demo { color: var(--mint); }
.stage .status.error { color: #ffd3dc; }
.stage-drawing { width: min(30%,215px); min-width: 112px; flex: none; color: var(--stage-rule); }
.stage-drawing line, .stage-drawing path { stroke: currentColor; stroke-width: 1.5; fill: none; }
.stage-drawing circle { stroke: currentColor; stroke-width: 1.5; fill: var(--stage); }
.stage-drawing .mint { fill: var(--mint); stroke: var(--mint); }
.stage-drawing .pale { fill: var(--stage-muted); }
.product-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 30px 0 12px; }
.products { border: 1px solid var(--rule); border-radius: 13px; background: var(--surface); overflow: hidden; }
.product { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 15px; padding: 16px; }
.product + .product { border-top: 1px solid var(--rule); }
.product-icon { width: 42px; height: 42px; display: grid; place-items: center; flex-shrink: 0; border-radius: 10px; background: var(--blue-soft); color: var(--blue); }
.product-icon.course { background: var(--mint-bg); color: var(--mint-ink); }
.product .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 4px; color: var(--muted); font-size: .83rem; }
.tag { border-radius: 5px; padding: 3px 7px; background: var(--mint-bg); color: var(--mint-ink); font-size: .76rem; font-weight: 660; }
.tag.draft { background: var(--amber-bg); color: var(--amber-ink); }
.row-actions { display: flex; gap: 5px; align-items: center; }
.icon-button { display: inline-grid; width: 44px; height: 44px; flex: 0 0 44px; place-items: center; border: 1px solid transparent; border-radius: 9px; color: var(--muted); background: transparent; transition: opacity .15s, background-color .15s; }
.icon-button:hover { background: var(--blue-soft); color: var(--blue); }
.payment { margin-top: 18px; border: 1px solid var(--rule); background: var(--surface); border-radius: 11px; padding: 13px 16px; }
.payment label { min-height: 44px; display: flex; gap: 14px; align-items: center; justify-content: space-between; cursor: pointer; }
.payment strong { display: block; font-size: .9rem; }
.payment small { display: block; color: var(--muted); font-size: .81rem; }
.payment input { width: 44px; height: 24px; flex: 0 0 44px; appearance: none; border-radius: 20px; background: var(--rule); border: 1px solid var(--muted); cursor: pointer; margin: 0; position: relative; }
.payment input:checked { background: var(--blue); border-color: var(--blue); }
.payment input::before { content: ""; width: 16px; height: 16px; border-radius: 50%; position: absolute; inset: 3px auto auto 3px; background: var(--surface); box-shadow: 0 0 0 1px var(--rule); transition: transform .15s; }
.payment input:checked::before { transform: translateX(20px); background: var(--on-blue); }
.empty { padding: clamp(20px,4vw,35px); border: 1px dashed var(--rule); border-radius: 13px; background: var(--surface); }
.empty p { margin-top: 7px; max-width: 47ch; }
.empty .button { margin-top: 16px; }
.notice { margin-top: 12px; padding: 12px 14px; color: var(--danger); background: var(--danger-bg); border-radius: 9px; }
.notice button { margin-top: 8px; }
.toast { position: fixed; z-index: 2; bottom: max(20px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); max-width: calc(100% - 24px); width: max-content; padding: 10px 16px; background: var(--ink); color: var(--canvas); border-radius: 10px; box-shadow: 0 8px 22px #12254c33; font-size: .9rem; }
dialog { color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: 17px; padding: 0; width: min(100% - 32px, 580px); max-height: 91vh; max-height: 91dvh; box-shadow: 0 24px 70px #0d163a44; overflow-x: hidden; overscroll-behavior: contain; }
dialog::backdrop { background: #101b42a8; }
dialog form { display: grid; gap: 16px; padding: 23px; }
.dialog-head { display: flex; gap: 14px; justify-content: space-between; align-items: flex-start; }
.dialog-head h2 { margin-top: 5px; }
.dialog-head p { font-size: .88rem; margin-top: 5px; overflow-wrap: anywhere; }
.dialog-actions { justify-content: flex-end; padding-top: 5px; }
.field { display: grid; gap: 6px; min-width: 0; font-size: .92rem; font-weight: 650; }
input:not([type="radio"],[type="checkbox"]), select, textarea { color: var(--ink); background: var(--canvas); border: 1px solid var(--rule); border-radius: 8px; padding: 9px 11px; width: 100%; min-width: 0; min-height: 44px; }
.field input, .field textarea, select { font-size: 1rem; font-weight: 450; }
input:disabled { opacity: .72; }
textarea { resize: vertical; }
.hint { font-size: .8rem; font-weight: 450; color: var(--muted); }
.format, .pricing { min-width: 0; border: 0; padding: 0; margin: 0; }
fieldset legend { padding: 0; font-size: .92rem; font-weight: 680; margin-bottom: 7px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choices label { position: relative; cursor: pointer; }
.choices input { opacity: 0; position: absolute; top: 9px; left: 9px; }
.choices label > span { display: grid; gap: 5px; align-content: start; height: 100%; padding: 10px; border: 1px solid var(--rule); border-radius: 9px; font-size: .89rem; }
.choices input:checked + span { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.choices input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.choices small { color: var(--muted); font-size: .77rem; }
.period-head, .plan { display: grid; grid-template-columns: minmax(68px,.65fr) minmax(100px,1fr) 44px; align-items: center; gap: 9px; }
.period-head { font-size: .79rem; color: var(--muted); }
.plan { margin-top: 6px; }
.add-plan { margin-top: 8px; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-top: 13px; }
details summary { min-height: 44px; display: list-item; padding-block: 10px; color: var(--blue); font-size: .88rem; font-weight: 650; }
.form-error { padding: 9px 12px; border-radius: 7px; color: var(--danger); background: var(--danger-bg); font-size: .88rem; overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .workspace { display: block; }
  .rail { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; padding: max(12px, env(safe-area-inset-top)) 16px 12px; border: 0; border-bottom: 1px solid var(--rule); }
  .brand { padding: 0; gap: 8px; }
  .brand img { width: 34px; height: 34px; }
  .brand span { font-size: .74rem; }
  .bot-nav { margin: 0; min-width: 0; max-width: 100%; }
  .rail-label, .bot-list { display: none; }
  .mobile-bots { display: block; }
  .mobile-bots select { max-width: 210px; min-width: 120px; }
  .content { padding: 21px 16px max(36px, env(safe-area-inset-bottom)); }
  .top { gap: 13px; margin-bottom: 18px; }
  .stage { padding: 17px; border-radius: 13px; min-height: 138px; gap: 8px; }
  .stage-drawing { width: 24%; min-width: 62px; }
  .stage-icon { width: 35px; height: 35px; border-radius: 8px; }
  .stage-id { gap: 8px; }
  .product { padding: 12px 9px 12px 12px; column-gap: 9px; }
  .product-icon { width: 34px; height: 34px; border-radius: 8px; }
  .product-head { margin-top: 22px; }
  .row-actions { gap: 0; }
  .product .meta { gap: 4px 8px; }
}
@media (max-width: 400px) {
  .mobile-bots select { max-width: 155px; min-width: 0; }
  .top-actions { gap: 7px; }
  .top-actions .button { padding-inline: 9px; font-size: .79rem; }
  .stage-drawing { display: none; }
  .stage { min-height: 0; }
  dialog { width: calc(100% - 20px); }
  dialog form { padding: 15px; }
  .product .meta { font-size: .78rem; }
  .product { grid-template-columns: auto minmax(0, 1fr); }
  .row-actions { grid-column: 2; justify-self: end; margin-top: -5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
