:root {
  --ink: #14251f;
  --muted: #6d7b75;
  --paper: #f5f5ef;
  --panel: #fffef9;
  --line: #dfe3da;
  --green: #237a54;
  --green-dark: #17563b;
  --lime: #c9e66b;
  --red: #c93f3f;
  --red-dark: #932a2a;
  --shadow: 0 18px 50px rgba(28, 50, 40, 0.08);
}

#demo-banner[hidden] { display: none; }
#demo-banner { background: var(--red); color: white; text-align: center; font-weight: 600; padding: 10px 4vw; }

.test-program-link { text-decoration: none; color: inherit; border: 1px solid rgba(74, 163, 122, .35); }
.test-program-link small, .test-meta, .test-step small { display: block; color: var(--muted); margin-top: .2rem; }
.test-warning { margin-bottom: 1.5rem; border-left: 4px solid #d39b3b; }
.test-runs { display: grid; gap: 1rem; }
.test-run { border: 1px solid var(--border); border-radius: 14px; padding: 1rem; background: rgba(255,255,255,.02); }
.test-run > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.test-run h3 { margin: 0; }
.test-status { border-radius: 999px; padding: .35rem .7rem; font-weight: 700; }
.test-run.passed .test-status, .test-step.passed .test-mark { background: rgba(61, 168, 116, .18); color: #62d49c; }
.test-run.failed .test-status, .test-step.failed .test-mark { background: rgba(211, 75, 75, .18); color: #f07b7b; }
.test-run.running .test-status, .test-step.running .test-mark { background: rgba(211, 155, 59, .18); color: #e8b862; }
.test-run ol { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .55rem; }
.test-step { display: flex; gap: .7rem; padding: .65rem; border-radius: 10px; background: rgba(0,0,0,.12); }
.test-mark { flex: 0 0 1.7rem; width: 1.7rem; height: 1.7rem; display: grid; place-items: center; border-radius: 50%; font-weight: 800; }
.archive-actions { margin-top: 1rem; text-align: center; }
.program-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(245px, 1fr)); gap: 1rem; }
.program-card { display: flex; min-height: 190px; flex-direction: column; justify-content: space-between; gap: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 14px; background: #fafaf5; }
.program-card h3 { margin: .35rem 0; }
.program-card p { margin: 0; color: var(--muted); line-height: 1.45; }
.program-card .program-schedule { margin-top: .65rem; padding: .55rem .7rem; border-radius: 8px; background: #eef4e2; color: var(--green-dark); font-size: .78rem; font-weight: 750; }
.program-state { color: var(--green); font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.program-card-actions { display: flex; flex-wrap: wrap; gap: .55rem; }
.program-card-actions .button { flex: 1 1 auto; text-align: center; text-decoration: none; }
.schedule-sync-actions { display: flex; align-items: flex-end; flex-direction: column; gap: 8px; }
.schedule-sync-summary { color: var(--muted); font-size: 12px; font-weight: 700; text-align: right; }
.schedule-sync-timestamp { color: var(--muted); font-size: 11px; text-align: right; }
.schedule-sync-summary.good { color: var(--green); }
.schedule-sync-summary.warning { color: #9a6500; }
.schedule-sync-summary.critical { color: var(--red-dark); }
.schedule-queue { display: grid; gap: 10px; }
.schedule-job { display: grid; grid-template-columns: minmax(170px,1.25fr) minmax(180px,1fr) minmax(150px,.8fr) auto; gap: 18px; align-items: center; padding: 15px 0; border-top: 1px solid var(--line); }
.schedule-job-main { display: grid; gap: 4px; }
.schedule-job-main strong { font-size: 14px; }
.schedule-job-main small, .schedule-job-meta { color: var(--muted); font-size: 11px; }
.schedule-job time { font: 700 13px ui-monospace, SFMono-Regular, Menlo, monospace; }
.schedule-job-status { display: flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 750; }
.schedule-job-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #b9bfbc; }
.schedule-job-status.confirmed::before { background: var(--green); box-shadow: 0 0 0 4px rgba(35,122,84,.10); }
.schedule-job-status.pending::before { background: #c98516; }
.schedule-job-actions { display: flex; gap: 7px; }
.schedule-job-actions .button { padding: 8px 11px; font-size: 11px; }
.schedule-help { margin: 16px 0 0; padding: 10px 12px; border-left: 3px solid var(--green); background: #f1f6e4; color: var(--muted); font-size: 11px; line-height: 1.5; }
.sidebar-label { margin: 1rem 0 .45rem; color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.sidebar-label .hint { text-transform: none; font-weight: 600; letter-spacing: normal; margin-left: 6px; opacity: .85; }
.binding-fields { display: grid; gap: .8rem; margin: 1.25rem 0; }
.binding-intro { margin: 0; padding: 1rem; border-left: 4px solid var(--green); background: #f1f6e4; color: var(--muted); line-height: 1.55; }
.binding-intro strong, #binding-save-status { color: var(--green-dark); }
.binding-row { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(260px, 1fr); gap: 1rem; padding: .85rem; border: 1px solid var(--line); border-radius: 10px; background: #fafaf5; }
.parameter-heading { margin-top: 1rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.parameter-heading h3 { margin: .25rem 0; font: 500 25px Georgia, serif; }
@media (max-width: 760px) { .binding-row { grid-template-columns: 1fr; } }
.backup-panel { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.5rem; }
.backup-panel h2 { margin: 0 0 .4rem; }
.backup-actions { min-width: 260px; display: grid; gap: .35rem; justify-items: end; text-align: right; }
.backup-actions > span { color: var(--muted); font-size: .85rem; }
.backup-actions > strong { font-size: 1.05rem; }
.current-program-panel { display: grid; grid-template-columns: minmax(220px,1fr) minmax(300px,1.2fr) auto; align-items: center; gap: 1.5rem; border-left: 5px solid var(--green); }
.current-program-panel h2 { margin: .2rem 0; }
.current-program-timing { display: grid; grid-template-columns: auto 1fr; gap: .35rem .75rem; }
.current-program-timing span { color: var(--muted); font-size: .75rem; }
.current-program-timing strong { font-size: .85rem; }
@media (max-width: 700px) {
  .backup-panel { align-items: stretch; flex-direction: column; }
  .backup-actions { min-width: 0; justify-items: stretch; text-align: left; }
  .current-program-panel { grid-template-columns: 1fr; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, a { font: inherit; }
button { cursor: pointer; }
.topbar { min-height: 76px; padding: 0 4vw; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px; background: var(--ink); color: white; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: white; text-decoration: none; justify-self: start; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50% 50% 50% 12px; background: var(--lime); color: var(--ink); font-weight: 900; font-size: 20px; transform: rotate(-8deg); }
.brand > span:last-child { display: grid; line-height: 1; gap: 5px; }
.brand strong { font-size: 17px; letter-spacing: .02em; }
.brand small { color: #aebbb4; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
nav { display: flex; align-self: stretch; }
nav a { display: grid; place-items: center; padding: 0 22px; color: #aebbb4; text-decoration: none; border-bottom: 3px solid transparent; font-size: 14px; font-weight: 650; }
nav a:hover, nav a.active { color: white; border-bottom-color: var(--lime); }
.connection { justify-self: end; display: inline-flex; align-items: center; gap: 9px; border: 1px solid #355046; border-radius: 99px; padding: 9px 14px; font-size: 12px; font-weight: 700; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #e5aa45; box-shadow: 0 0 0 4px rgba(229,170,69,.12); }
.connection.online .pulse { background: var(--lime); box-shadow: 0 0 0 4px rgba(201,230,107,.12); }
.connection.offline .pulse { background: #f56b6b; box-shadow: 0 0 0 4px rgba(245,107,107,.12); }
main { width: min(1440px, 92vw); margin: 0 auto; padding: 48px 0 64px; }
.hero { display: flex; justify-content: space-between; align-items: end; gap: 40px; padding: 18px 0 36px; }
.eyebrow { margin: 0 0 9px; color: var(--green); font-size: 11px; font-weight: 850; letter-spacing: .15em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(38px, 5vw, 64px); line-height: .98; font-weight: 500; letter-spacing: -.035em; }
.lede { margin-bottom: 0; max-width: 680px; color: var(--muted); font-size: 17px; line-height: 1.55; }
.hero-actions { display: flex; align-items: center; gap: 14px; }
.hero-action { display: flex; align-items: center; gap: 14px; min-width: 240px; padding: 15px 19px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--ink); box-shadow: var(--shadow); text-align: left; }
.hero-action:hover { background: #fafaf5; transform: translateY(-1px); }
.hero-action span:last-child { display: grid; gap: 3px; }
.hero-action small { color: var(--muted); font-size: 11px; }
.hero-action-timestamp { opacity: .8; }
.restart-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: #eef1e9; font-size: 18px; }
.emergency { display: flex; align-items: center; gap: 14px; min-width: 260px; padding: 15px 19px; border: 0; border-radius: 14px; background: var(--red); color: white; box-shadow: 0 10px 25px rgba(201,63,63,.22); text-align: left; }
.emergency:hover { background: var(--red-dark); transform: translateY(-1px); }
.stop-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.15); font-size: 15px; }
.emergency span:last-child { display: grid; gap: 3px; }
.emergency small { color: #ffd6d6; font-size: 11px; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); overflow: hidden; }
.summary-grid article { padding: 20px 22px; border-right: 1px solid var(--line); }
.summary-grid article:last-child { border-right: 0; }
.summary-grid span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.summary-grid strong { font-size: 17px; }
.error-banner { margin-top: 18px; padding: 14px 16px; border: 1px solid #efb3b3; border-radius: 10px; background: #fff0f0; color: var(--red-dark); }
.panel { margin-top: 28px; padding: 27px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: var(--shadow); }
.panel-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 22px; }
.panel-heading h2 { margin-bottom: 0; font-family: Georgia, "Times New Roman", serif; font-size: 28px; font-weight: 500; }
.panel-heading > p { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.channel-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.channel-card { min-width: 0; padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: #fafaf5; transition: border-color .2s, background .2s, transform .2s; }
.channel-card.is-on { border-color: #a9c96d; background: #f4f8e8; }
.channel-head { display: flex; justify-content: space-between; align-items: center; }
.channel-number { color: #a2aba7; font: 700 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.state-pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 8px; border-radius: 99px; background: #e9ece8; color: #6f7974; font-size: 10px; font-weight: 900; }
.state-pill i { width: 7px; height: 7px; border-radius: 50%; background: #98a19d; }
.is-on .state-pill { background: #e3edc7; color: var(--green-dark); }
.is-on .state-pill i { background: var(--green); box-shadow: 0 0 0 3px rgba(35,122,84,.12); }
.channel-title { display: grid; gap: 3px; margin: 24px 0 15px; }
.channel-title span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.channel-title strong { font-family: Georgia, "Times New Roman", serif; font-size: 22px; font-weight: 500; }
.rename-channel { justify-self: start; margin-top: 5px; padding: 3px 0; border: 0; background: transparent; color: var(--green); font-size: 11px; font-weight: 750; text-decoration: underline; text-underline-offset: 3px; }
.relay-toggle { width: 100%; min-height: 54px; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 13px 16px; border: 0; border-radius: 11px; background: var(--green); color: white; box-shadow: 0 7px 16px rgba(35,122,84,.18); font-size: 14px; font-weight: 800; }
.relay-toggle:hover { background: var(--green-dark); transform: translateY(-1px); }
.relay-toggle:disabled { cursor: wait; opacity: .55; }
.relay-toggle i { position: relative; width: 36px; height: 20px; border-radius: 99px; background: rgba(255,255,255,.32); }
.relay-toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: white; transition: transform .2s; }
.is-on .relay-toggle { background: var(--ink); }
.is-on .relay-toggle i { background: rgba(255,255,255,.32); }
.is-on .relay-toggle i::after { transform: translateX(14px); }
.read-only { color: #9ba39f; font-size: 11px; font-weight: 650; }
.activity-panel { margin-bottom: 0; }
.text-link { color: var(--green); font-size: 13px; font-weight: 750; text-decoration: none; }
.text-link:hover { text-decoration: underline; }
.event-list { list-style: none; margin: 0; padding: 0; }
.event-list li { display: grid; grid-template-columns: 190px 1fr; gap: 20px; padding: 12px 0; border-top: 1px solid var(--line); font-size: 13px; }
.event-list time { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.load-more { display: block; margin: 22px auto 0; }
.load-more[hidden] { display: none; }
.dialog-backdrop { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: rgba(11,26,20,.72); backdrop-filter: blur(4px); }
.dialog-backdrop[hidden] { display: none; }
.dialog { width: min(460px, 100%); padding: 30px; border-radius: 18px; background: var(--panel); box-shadow: 0 30px 80px rgba(0,0,0,.28); }
.dialog h2 { margin-bottom: 9px; font: 500 30px Georgia, serif; }
.dialog > p:not(.eyebrow) { color: var(--muted); line-height: 1.5; }
.dialog-actions { display: flex; justify-content: end; gap: 10px; margin-top: 25px; }
.schedule-dialog { width: min(560px, 100%); }
.schedule-fields { display: grid; gap: 18px; margin-top: 22px; }
.schedule-actions { align-items: center; }
.button { padding: 11px 16px; border-radius: 9px; border: 0; font-weight: 750; }
.button.secondary { border: 1px solid var(--line); background: white; }
.button.danger { background: var(--red); color: white; }
.button.primary { border: 0; background: var(--green); color: white; }
.button.primary:hover { background: var(--green-dark); }
.button.danger-outline { border: 1px solid #e2aaaa; background: transparent; color: var(--red-dark); }
.diagnostic-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:16px; margin:22px 0; }
.diagnostic-card { display:grid; gap:7px; min-height:150px; padding:22px; border:1px solid var(--line); border-radius:16px; background:var(--panel); box-shadow:var(--shadow); }
.diagnostic-card > span { color:var(--muted); font-size:12px; font-weight:800; letter-spacing:.05em; text-transform:uppercase; }
.diagnostic-card > strong { align-self:center; color:var(--ink); font:500 30px Georgia,serif; }
.diagnostic-card small { color:var(--muted); line-height:1.4; }
.diagnostic-card .good { color:var(--green); }.diagnostic-card .warning { color:#9a6500; }.diagnostic-card .critical { color:var(--red-dark); }
.diagnostic-primary { border-color:#a9c972; background:#f3f7e8; }
.diagnostic-list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:0; margin:0; }
.diagnostic-list div { display:grid; grid-template-columns:minmax(130px,.7fr) 1.3fr; gap:16px; padding:15px 8px; border-bottom:1px solid var(--line); }
.diagnostic-list dt { color:var(--muted); }.diagnostic-list dd { margin:0; font-weight:750; overflow-wrap:anywhere; }
.programs-hero { min-height: 190px; }
.scenario-workspace { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 22px; align-items: start; }
.scenario-workspace > .panel { margin-top: 0; }
.scenario-sidebar { position: sticky; top: 20px; padding: 20px; }
.scenario-sidebar .panel-heading { margin-bottom: 14px; }
.scenario-list { display: grid; gap: 8px; }
.scenario-list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: #fafaf5; color: var(--ink); text-align: left; }
.scenario-list-item:hover, .scenario-list-item.active { border-color: var(--green); background: #f1f6e4; }
.scenario-list-item span { display: grid; gap: 4px; min-width: 0; }
.scenario-list-item strong { overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.scenario-list-item small, .muted-copy { color: var(--muted); font-size: 11px; }
.scenario-list-item i { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: #b9bfbc; }
.scenario-list-item i.enabled { background: var(--green); box-shadow: 0 0 0 4px rgba(35,122,84,.12); }
.scenario-list-item i.protected-badge { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: #f4ead2; font-size: 11px; font-style: normal; line-height: 1; }
.scenario-editor { display: grid; gap: 18px; }
.editor-heading { display: flex; align-items: end; gap: 18px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.grow { flex: 1; }
.field { display: grid; gap: 7px; }
.field > span, .operator-field > span, .section-label, .day-picker legend { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.field input, .field textarea, select, .inline-number input { min-height: 42px; padding: 9px 11px; border: 1px solid #ccd3ce; border-radius: 8px; background: white; color: var(--ink); font: inherit; font-size: 13px; }
.field textarea { resize: vertical; line-height: 1.5; }
.builtin-steps { margin: 0 0 1rem; padding-left: 1.4rem; display: grid; gap: .55rem; color: var(--ink); font-size: 13px; line-height: 1.45; }
.enable-field { display: flex; align-items: center; gap: 9px; min-height: 42px; font-size: 13px; font-weight: 700; }
.enable-field input { width: 18px; height: 18px; accent-color: var(--green); }
.logic-block { border: 1px solid var(--line); border-radius: 13px; background: #fafaf5; overflow: hidden; }
.when-block { display: grid; grid-template-columns: 110px 1fr; }
.logic-keyword { display: grid; place-items: center; min-height: 62px; padding: 16px; background: var(--ink); color: var(--lime); font: 900 13px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.when-settings { display: grid; grid-template-columns: 170px 1fr; gap: 20px; padding: 18px; }
.trigger-detail { display: grid; grid-template-columns: 150px 1fr; gap: 20px; }
.day-picker { min-width: 0; margin: 0; padding: 0; border: 0; }
.day-picker > div { display: flex; gap: 5px; margin-top: 7px; }
.day-picker label input { position: absolute; opacity: 0; }
.day-picker label span { display: grid; place-items: center; min-width: 34px; height: 42px; border: 1px solid #ccd3ce; border-radius: 8px; background: white; font-size: 11px; font-weight: 750; }
.day-picker input:checked + span { border-color: var(--green); background: var(--green); color: white; }
.branch-list { display: grid; gap: 14px; }
.branch-heading { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; border-bottom: 1px solid var(--line); }
.operator-field { display: flex; align-items: center; gap: 10px; padding: 10px 16px; }
.operator-field select { min-height: 38px; }
.branch-heading > .icon-button { margin-right: 14px; }
.block-section { display: grid; gap: 8px; padding: 16px; }
.actions-section { border-top: 1px dashed var(--line); background: #f4f6ef; }
.condition-row, .action-row { display: grid; grid-template-columns: minmax(130px, 1.2fr) minmax(120px, 1fr) minmax(120px, 1fr) 38px; gap: 8px; align-items: center; }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: #ecefeb; color: var(--muted); font-size: 20px; }
.icon-button:hover { background: #f6dddd; color: var(--red-dark); }
.mini-add { justify-self: start; padding: 6px 0; border: 0; background: transparent; color: var(--green); font-size: 12px; font-weight: 750; }
.inline-number { display: flex; align-items: center; gap: 8px; grid-column: span 2; color: var(--muted); font-size: 12px; }
.inline-number input { width: 130px; }
.add-branch-actions { display: flex; gap: 9px; }
.program-preview { padding: 20px; border: 1px solid #b8cf86; border-radius: 13px; background: #f3f7e8; }
.preview-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 14px; }
.preview-heading h2 { margin: 0; font: 500 25px Georgia, serif; }
#save-status { color: var(--green); font-size: 12px; font-weight: 800; }
.program-summary { display: grid; gap: 10px; font-size: 13px; line-height: 1.5; }
.summary-trigger { margin: 0; padding: 12px 14px; border-radius: 9px; background: var(--ink); color: white; }
.summary-trigger strong { color: var(--lime); }
.summary-branch { padding: 12px 14px; border-left: 4px solid var(--green); border-radius: 0 9px 9px 0; background: rgba(255,255,255,.72); }
.summary-branch > strong { color: var(--green-dark); }
.summary-branch ol { margin: 8px 0 0; padding-left: 24px; }
.summary-warning { color: var(--red-dark); }
.editor-actions { display: flex; justify-content: space-between; gap: 10px; padding-top: 20px; border-top: 1px solid var(--line); }
.builder-preview { display: grid; grid-template-columns: 320px 1fr; min-height: 520px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: var(--shadow); overflow: hidden; }
.toolbox { padding: 27px; border-right: 1px solid var(--line); background: #eef1e9; }
.tool-card { display: flex; align-items: center; gap: 13px; margin-top: 12px; padding: 15px; border: 1px solid #d8ddd2; border-radius: 11px; background: var(--panel); }
.tool-card > span { color: var(--green); font: 800 11px ui-monospace, monospace; }
.tool-card div { display: grid; gap: 3px; }
.tool-card strong { font-size: 13px; }
.tool-card small { color: var(--muted); font-size: 11px; }
.canvas-placeholder { display: grid; place-content: center; justify-items: center; padding: 60px; text-align: center; background-image: radial-gradient(#d7dcd3 1px, transparent 1px); background-size: 24px 24px; }
.canvas-placeholder h2 { margin: 12px 0 9px; font: 500 34px Georgia, serif; }
.canvas-placeholder > p { max-width: 560px; color: var(--muted); line-height: 1.6; }
.coming-soon { padding: 6px 10px; border-radius: 99px; background: var(--lime); font-size: 10px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.flow-preview { display: flex; align-items: center; gap: 12px; margin-top: 28px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,254,249,.92); box-shadow: var(--shadow); }
.flow-preview div { padding: 11px 13px; border-radius: 8px; background: #edf2dd; font-size: 12px; font-weight: 700; }
.flow-preview i { color: var(--green); font-style: normal; }
.priority-defaults { display:flex; gap:14px; align-items:end; flex-wrap:wrap; }
.priority-section { display:grid; gap:18px; margin-top:32px; padding-top:34px; border-top:1px solid var(--line); scroll-margin-top:24px; }
.priority-section > .section-heading { margin-bottom:2px; }
.priority-section > .section-heading h2 { margin:4px 0 8px; font:500 34px Georgia,"Times New Roman",serif; }
.priority-section > .section-heading .lede { margin:0; }
.global-lock-settings { display:grid; grid-template-columns:repeat(2,minmax(180px,1fr)); gap:14px; align-items:end; }
.policy-list { display:grid; gap:10px; }
.policy-row { display:grid; grid-template-columns:minmax(180px,1.4fr) 110px minmax(150px,1fr) 140px auto; gap:12px; align-items:end; padding:12px; border:1px solid var(--line); border-radius:10px; background:#fafaf5; }
.policy-row label { display:grid; gap:5px; font-size:11px; color:var(--muted); }
.policy-row input,.policy-row select { width:100%; }
.scenario-policy { grid-template-columns:minmax(200px,1fr) 120px minmax(180px,1fr) auto; }
.safety-warning { padding:12px; border-left:4px solid #c98516; background:#fff6df; }
.success-banner { background:#e8f5e9; color:#17653d; border-color:#78b994; }
.global-lock-banner { display:flex; align-items:center; justify-content:space-between; gap:16px; margin:18px 0; padding:16px; border:2px solid #b3261e; border-radius:10px; background:#fff0ee; color:#8d1813; font-weight:800; }
.global-lock-banner[hidden] { display:none; }
.global-lock-banner .button { flex:0 0 auto; }
.wifi-manager-actions { display:flex; align-items:center; gap:12px; color:var(--muted); font-size:12px; }
.wifi-profile-list,.wifi-scan-results { display:grid; gap:10px; }
.wifi-profile-row,.wifi-network-row { display:grid; grid-template-columns:minmax(180px,1fr) minmax(130px,.7fr) auto; gap:14px; align-items:center; padding:14px; border:1px solid var(--line); border-radius:11px; background:#fafaf5; }
.wifi-profile-main { display:grid; gap:4px; }
.wifi-profile-main small { color:var(--muted); }
.wifi-profile-state { color:var(--muted); font-size:12px; }
.wifi-profile-state.connected { color:var(--green); font-weight:800; }
.wifi-profile-actions { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:7px; }
.wifi-profile-actions .button { padding:8px 11px; font-size:11px; }
.wifi-scan-results { margin-top:18px; padding-top:18px; border-top:1px solid var(--line); }
.wifi-scan-results h3 { margin:0 0 4px; font:500 24px Georgia,serif; }
.shelly-devices { display:grid; gap:10px; margin-top:14px; }
.shelly-row { display:grid; grid-template-columns:34px minmax(160px,1fr) minmax(150px,1fr) minmax(120px,.8fr); gap:14px; align-items:end; padding:14px; border:1px solid var(--line); border-radius:11px; background:#fafaf5; }
.shelly-row .shelly-slot { align-self:center; color:var(--muted); font-size:12px; font-weight:800; }
.shelly-devices-actions { display:flex; justify-content:flex-end; margin-top:16px; }
.document-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:22px; }
.document-card { display:grid; grid-template-rows:auto 1fr auto; gap:22px; padding:28px; border:1px solid var(--line); border-radius:18px; background:var(--panel); box-shadow:var(--shadow); }
.document-card h2 { margin:5px 0 10px; font:500 30px Georgia,"Times New Roman",serif; }
.document-card p { margin-bottom:0; color:var(--muted); line-height:1.6; }
.document-icon { display:grid; place-items:center; width:54px; height:54px; border-radius:16px 16px 16px 5px; background:var(--lime); color:var(--ink); font:850 13px ui-monospace,monospace; }
.document-meta { color:var(--green) !important; font-size:11px; font-weight:850; letter-spacing:.1em; text-transform:uppercase; }
.document-actions { display:flex; flex-wrap:wrap; gap:10px; }
.document-actions .button { text-decoration:none; text-align:center; }
.document-footnote { margin:24px 0 0; color:var(--muted); font-size:12px; text-align:center; }

@media (max-width: 980px) {
  .topbar { grid-template-columns: 1fr auto; }
  .connection { display: none; }
  .channel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .builder-preview { grid-template-columns: 1fr; }
  .toolbox { border-right: 0; border-bottom: 1px solid var(--line); }
  .scenario-workspace { grid-template-columns: 1fr; }
  .scenario-sidebar { position: static; }
  .scenario-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .diagnostic-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width: 680px) {
  .document-grid { grid-template-columns:1fr; }
  .schedule-job { grid-template-columns: 1fr; gap: 8px; }
  .schedule-job-actions { justify-content: stretch; }
  .schedule-job-actions .button { flex: 1; }
  .global-lock-banner { align-items:stretch; flex-direction:column; }
  .global-lock-settings { grid-template-columns:1fr; }
  .policy-row,.scenario-policy { grid-template-columns:1fr; }
  .wifi-profile-row,.wifi-network-row { grid-template-columns:1fr; }
  .shelly-row { grid-template-columns:1fr; }
  .wifi-profile-actions { justify-content:stretch; }
  .wifi-profile-actions .button { flex:1; }
  .topbar { padding: 12px 4vw 0; grid-template-columns: 1fr; }
  nav { grid-row: 2; width: 100%; }
  nav a { flex: 1; padding: 14px 8px; }
  .hero { align-items: stretch; flex-direction: column; }
  .hero-actions { flex-direction: column; width: 100%; }
  .hero-action, .emergency { width: 100%; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-grid article:nth-child(2) { border-right: 0; }
  .summary-grid article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .channel-grid { grid-template-columns: 1fr; }
  .panel { padding: 20px; }
  .panel-heading { align-items: start; flex-direction: column; }
  .event-list li { grid-template-columns: 1fr; gap: 5px; }
  .flow-preview { align-items: stretch; flex-direction: column; }
  .flow-preview i { transform: rotate(90deg); }
  .canvas-placeholder { padding: 40px 20px; }
  .editor-heading, .when-settings, .trigger-detail { grid-template-columns: 1fr; align-items: stretch; flex-direction: column; }
  .when-block { grid-template-columns: 1fr; }
  .logic-keyword { min-height: 44px; }
  .branch-heading { grid-template-columns: 90px 1fr auto; }
  .condition-row, .action-row { grid-template-columns: 1fr; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: white; }
  .condition-row .icon-button, .action-row .icon-button { justify-self: end; }
  .inline-number { grid-column: auto; }
  .scenario-list { grid-template-columns: 1fr; }
  .diagnostic-grid,.diagnostic-list { grid-template-columns:1fr; }
  .day-picker > div { flex-wrap: wrap; }
  .preview-heading { align-items: start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
