:root {
  /* SAP Fiori Horizon, as published in the Fiori design guidelines */
  --bg: #f5f6f7;
  --panel: #ffffff;
  --panel-2: #f5f6f7;
  --line: #e5e5e5;
  --line-strong: #bcc3ca;
  --field: #556b82;
  --text: #1d2d3e;
  --muted: #556b82;
  --accent: #0064d9;
  --accent-strong: #0040b0;
  --accent-soft: #ebf8ff;
  --emphasized: #0070f2;
  --focus: #0032a5;
  --appbar: #ffffff;
  --appbar-text: #1d2d3e;
  --warn: #e76500;
  --error: #aa0808;
  --ok: #256f3a;
  --code-bg: #fbfbfc;
  --code-hi: #fff8d6;
  --code-hi-line: #e76500;
  --kw: #7a2bc0;
  --str: #256f3a;
  --cmt: #758ca4;
  --radius: 8px;
  --font: "72", "72full", system-ui, -apple-system, "Segoe UI", Arial, Helvetica, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* Horizon Evening */
    --bg: #12171c; --panel: #1d232a; --panel-2: #12171c; --line: #2f3a45; --line-strong: #4e5b68; --field: #8396a8; --text: #eaecee; --muted: #a9b4be;
    --accent: #4db1ff; --accent-strong: #8cccff; --accent-soft: #1c3b5a; --emphasized: #0070f2; --focus: #8cccff; --appbar: #1d232a; --appbar-text: #eaecee;
    --code-bg: #171d23; --code-hi: #3a3218; --kw: #c99bff; --str: #7fd49b; --cmt: #8396a8;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 13px/1.45 var(--font); color: var(--text); background: var(--bg); display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0; font-weight: 700; }
h3 { font-size: 12px; margin: 0; font-weight: 600; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
kbd { font: 11px var(--mono); padding: 1px 5px; border-radius: 4px; border: 1px solid currentColor; opacity: .7; }

button {
  border: 1px solid var(--line-strong); background: var(--panel); border-radius: var(--radius);
  padding: 5px 10px; cursor: pointer; white-space: nowrap;
}
button:hover { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .45; cursor: default; color: inherit; border-color: var(--line-strong); }
button.primary { background: var(--emphasized); border-color: var(--emphasized); color: #fff; font-weight: 700; }
button.primary:hover { background: #0064d9; color: #fff; }
button.icon { width: 30px; padding: 5px 0; line-height: 1; }
button.danger:hover { border-color: var(--error); color: var(--error); }
button.link { border: none; background: none; padding: 0 2px; color: var(--accent); }
input, select, textarea {
  border: 1px solid var(--line-strong); border-radius: 6px; background: var(--panel); padding: 4px 7px; min-width: 0;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
input, select { border-color: var(--field); border-radius: 4px; }
input.invalid { border-color: var(--error); background: color-mix(in srgb, var(--error) 6%, var(--panel)); }

/* ---------------------------------------------------------- app bar */
.extra { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px; align-items: start; }
.extra .prop { min-width: 0; }
.appbar { display: flex; align-items: center; gap: 14px; padding: 6px 14px; min-height: 52px; background: var(--appbar); color: var(--appbar-text); flex-wrap: wrap; box-shadow: 0 0 0.125rem 0 rgba(34,53,72,.15), 0 0.125rem 0.25rem 0 rgba(34,53,72,.15); position: relative; z-index: 5; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 700; }
.brand .mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--emphasized); color: #fff; font: 700 13px var(--mono); }
.brand .word span { font-weight: 400; color: var(--muted); }
.classfield { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 260px; }
.classfield label { color: var(--muted); }
.classfield #className { width: 190px; font-family: var(--mono); text-transform: uppercase; }
.classfield #description { flex: 1; max-width: 340px; }
.bar-actions { display: flex; align-items: center; gap: 6px; }
.appbar button.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.appbar button.ghost:hover { background: var(--accent-soft); border-color: transparent; color: var(--accent-strong); }
.appbar button.ghost:disabled { opacity: .4; background: transparent; }
.appbar button.cmd { border-color: var(--field); color: var(--muted); border-radius: 18px; background: var(--panel-2); }
button.cmd { display: flex; gap: 10px; align-items: center; min-width: 210px; justify-content: space-between; opacity: .9; }
.menu-wrap { position: relative; display: flex; }
.menu-wrap.split .primary:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.menu-wrap.split .caret { border-radius: 0 var(--radius) var(--radius) 0; border-left: 1px solid rgba(255,255,255,.45); padding: 5px 8px; }
.menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 230px; display: flex; flex-direction: column; padding: 5px;
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18);
}
.menu.right { left: auto; right: 0; }
.menu[hidden] { display: none; }
.menu button { border: none; text-align: left; background: none; padding: 7px 10px; border-radius: 6px; color: var(--text); }
.menu button:hover { background: var(--accent-soft); color: var(--accent-strong); }

/* ---------------------------------------------------------- workspace */
.workspace { --drawer-w: 280px; --inspector-w: 320px; flex: 1; display: grid; grid-template-columns: var(--drawer-w) 6px minmax(0, 1fr) 6px var(--inspector-w); min-height: 0; }
.resizer { cursor: col-resize; background: var(--line); touch-action: none; }
.resizer:hover, .resizer:active { background: var(--accent); }
/* the left pane's tabs, after the Fiori icon tab bar (text only) */
.rail { display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--line); background: var(--panel); }
.rail-btn { position: relative; border: none; border-radius: 0; background: none; padding: 11px 8px 9px; color: var(--text); border-bottom: 3px solid transparent; font-size: 13px; }
.rail-btn:hover { color: var(--accent); background: none; }
.rail-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.rail .dot { display: inline-block; min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--error); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; }
.rail .dot.warn { background: var(--warn); }
.drawer { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 8px; }
.panel-head input { flex: 1; }
.scroll { overflow: auto; min-height: 0; flex: 1; }
.pad { padding: 0 12px 24px; }

/* insert */
.insert-target { margin: 0 12px 8px; padding: 6px 8px; border-radius: 6px; background: var(--panel-2); border: 1px dashed var(--line-strong); font-size: 12px; color: var(--muted); }
.insert-target b { color: var(--text); font-weight: 600; }
.ins-group { padding: 0 8px 10px; }
.ins-group > h3 { padding: 6px 6px 4px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.ins-item {
  display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 0 8px; align-items: center; padding: 6px 6px; border-radius: 8px;
  cursor: grab; user-select: none; border: 1px solid transparent;
}
.ins-item:hover { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.ins-item .ig { grid-row: span 2; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); color: var(--accent); font-size: 13px; }
.ins-item .in { font-weight: 600; font-size: 12.5px; }
.ins-item .id { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ins-item.pattern .ig { background: var(--accent); color: #fff; border-color: var(--accent); }
.ins-item.runtime .ig { color: var(--warn); }
.ins-group.byname { border-top: 1px solid var(--line); padding-top: 8px; }
.ins-group.byname .add-row { padding: 0 6px; }
.ins-group.byname .hint { padding: 0 6px; }

/* layers */
.tree { padding: 2px 0 16px; }
.lrow {
  display: flex; align-items: center; gap: 4px; padding: 3px 8px; cursor: pointer; white-space: nowrap; user-select: none; position: relative; border-radius: 6px; margin: 0 6px;
}
.lrow:hover { background: var(--accent-soft); }
.lrow:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.lrow.sel { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); color: var(--text); }
.lrow.sel .ltype { font-weight: 700; }
.lrow .caret { width: 14px; text-align: center; color: var(--muted); font-size: 10px; flex: none; border: none; background: none; padding: 0; }
.lrow .ltype { font-weight: 500; }
.lrow .lmeta { color: var(--muted); overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.lrow.agg { cursor: default; }
.lrow.agg .lagg { color: var(--muted); font-style: italic; font-size: 12px; }
.lrow .bind { color: var(--ok); font-size: 10px; }
.lrow.drop-before::before, .lrow.drop-after::after { content: ""; position: absolute; left: 8px; right: 8px; height: 2px; background: var(--accent); }
.lrow.drop-before::before { top: -1px; }
.lrow.drop-after::after { bottom: -1px; }
.lrow.drop-inside { outline: 2px dashed var(--accent); outline-offset: -2px; }

/* ---------------------------------------------------------- stage */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
/* the Fiori segmented button */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: none; border-radius: 0; background: var(--panel); padding: 5px 12px; color: var(--accent); }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button:hover { background: var(--accent-soft); }
.seg button.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; box-shadow: inset 0 -2px 0 var(--accent); }
.seg.small button { padding: 2px 8px; font-size: 12px; }
.stage-body { flex: 1; min-height: 0; display: grid; gap: 0; }
.stage-body.view-split { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.stage-body.view-canvas { grid-template-columns: 1fr; }
.stage-body.view-canvas .code-pane { display: none; }
.stage-body.view-code { grid-template-columns: 1fr; }
.stage-body.view-code .canvas-pane { display: none; }
.canvas-pane { display: flex; justify-content: center; padding: 14px; min-height: 0; min-width: 0; background: var(--panel-2); position: relative; }
.preview-status { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); z-index: 3; max-width: calc(100% - 40px); padding: 5px 12px; border-radius: 8px; font-size: 12px; background: var(--panel); color: var(--muted); border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(0,0,0,.12); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-status.error { color: var(--error); border-color: var(--error); }
.preview-status.warn { color: var(--warn); border-color: var(--warn); }
.preview-status button.link { margin-left: 10px; font-size: 12px; }
.device-frame { width: 100%; height: 100%; max-width: 100%; transition: width .15s; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 0 0.125rem 0 rgba(34,53,72,.15), 0 0.5rem 1rem 0 rgba(34,53,72,.15); }
.device-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.code-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-left: 1px solid var(--line); background: var(--panel); }
.code-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.codeblock { flex: 1; margin: 0; padding: 10px 0; overflow: auto; background: var(--code-bg); font: 12px/1.55 var(--mono); }
.codeblock .ln { display: block; padding: 0 14px 0 52px; position: relative; white-space: pre; cursor: default; min-height: 1.55em; }
.codeblock .ln::before { content: attr(data-n); position: absolute; left: 0; width: 40px; text-align: right; color: var(--cmt); }
.codeblock .ln[data-node] { cursor: pointer; }
.codeblock .ln[data-node]:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.codeblock .ln.hi { background: var(--code-hi); box-shadow: inset 3px 0 0 var(--code-hi-line); }
.codeblock .kw { color: var(--kw); font-weight: 600; }
.codeblock .str { color: var(--str); }
.codeblock .cmt { color: var(--cmt); font-style: italic; }
.codeblock .tag { color: var(--accent); }
.crumbs { display: flex; align-items: center; gap: 2px; padding: 5px 10px; border-top: 1px solid var(--line); background: var(--panel); min-height: 32px; overflow-x: auto; white-space: nowrap; }
.crumbs button { border: none; background: none; padding: 2px 6px; border-radius: 5px; color: var(--muted); font-size: 12px; }
.crumbs button:hover { background: var(--accent-soft); color: var(--accent-strong); }
.crumbs button.cur { color: var(--text); font-weight: 600; }
.crumbs .sep { color: var(--line-strong); }

/* ---------------------------------------------------------- inspector */
.inspector { background: var(--panel); border-left: 1px solid var(--line); overflow: auto; min-height: 0; }
.insp-head { padding: 12px 14px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.insp-title { display: flex; align-items: baseline; gap: 8px; }
.insp-title b { font-size: 15px; }
.insp-title a { font-size: 11px; color: var(--accent); margin-left: auto; }
.insp-desc { color: var(--muted); font-size: 12px; margin: 2px 0 8px; }
.insp-tools { display: flex; gap: 6px; align-items: center; }
.insp-tools input[type=search] { flex: 1; }
.insp-tools label { display: flex; gap: 4px; align-items: center; color: var(--muted); font-size: 12px; white-space: nowrap; }
.group { border-bottom: 1px solid var(--line); }
.group > summary { list-style: none; cursor: pointer; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; }
.group > summary::-webkit-details-marker { display: none; }
.group > summary::after { content: "▾"; color: var(--muted); font-size: 10px; }
.group:not([open]) > summary::after { content: "▸"; }
.group .gbody { padding: 0 14px 12px; }
.hint { color: var(--muted); font-size: 12px; margin: 2px 0 8px; }
.prop { display: grid; grid-template-columns: 104px minmax(0, 1fr) 34px; gap: 6px; align-items: center; margin-bottom: 5px; }
.prop > label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.prop.set > label { color: var(--text); font-weight: 600; }
.prop .val { display: flex; gap: 4px; min-width: 0; }
.prop .val > * { flex: 1; min-width: 0; }
.prop .val > button { flex: none; }
.kind {
  appearance: none; -webkit-appearance: none; width: 34px; padding: 3px 0; text-align: center; text-align-last: center; font: 600 11px var(--mono);
  border-radius: 6px; cursor: pointer; background: var(--panel-2); color: var(--muted);
}
.kind.k-b { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent); }
.kind.k-f { background: #fff8d6; color: #a93e00; border-color: #e76500; }
.kind.k-x { background: #efe6fb; color: #6b2fb3; border-color: #b892e8; }
.event { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 6px; align-items: center; margin-bottom: 5px; }
.event > label { color: var(--muted); font-size: 12px; }
.event input { font-family: var(--mono); text-transform: uppercase; }
.add-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.add-row select { flex: 1; }
.empty { color: var(--muted); padding: 28px 18px; text-align: center; }
.empty .big { font-size: 28px; color: var(--accent); }

/* data */
.attr { border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-bottom: 8px; background: var(--panel); }
.attr-head { display: grid; grid-template-columns: minmax(0, 1fr) 84px 28px; gap: 4px; align-items: center; }
.attr-head input.aname { font-family: var(--mono); }
.attr .uses { color: var(--muted); font-size: 11px; margin: 4px 0 0 2px; }
.attr .avalue { margin-top: 6px; display: flex; gap: 6px; align-items: center; }
.attr .avalue input:not([type=checkbox]) { flex: 1; }
.fields { margin-top: 8px; }
.frow { display: grid; grid-template-columns: minmax(0, 1fr) 84px 28px; gap: 4px; margin-bottom: 4px; }
.frow input { font-family: var(--mono); text-transform: uppercase; }
.rows-wrap { overflow-x: auto; margin-top: 6px; }
table.rows { border-collapse: collapse; font-size: 12px; }
table.rows th { text-align: left; font-weight: 600; color: var(--muted); padding: 2px 4px; font-family: var(--mono); font-size: 11px; }
table.rows td { padding: 1px 2px; }
table.rows td input { width: 92px; padding: 2px 4px; }
table.rows td input[type=checkbox] { width: auto; }

/* checks */
.issue { display: flex; gap: 8px; padding: 7px 8px; border-radius: 8px; cursor: pointer; align-items: flex-start; }
.issue:hover { background: var(--accent-soft); }
.issue .lvl { font-weight: 700; width: 14px; flex: none; }
.issue.error .lvl { color: var(--error); }
.issue.warning .lvl { color: var(--warn); }
.issue.info .lvl { color: var(--muted); }

/* dialog, command palette, toast */
.dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(720px, calc(100vw - 32px)); background: var(--panel); color: var(--text); }
.dialog::backdrop, .cmdk::backdrop { background: rgba(0, 0, 0, .3); }
.dialog header { padding: 16px 18px 6px; font-size: 16px; font-weight: 700; }
.dialog .body { padding: 6px 18px 12px; }
.dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 18px 16px; }
.dialog textarea { width: 100%; height: 300px; font: 12px/1.4 var(--mono); }
.starters { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.starter { text-align: left; padding: 12px; white-space: normal; display: flex; flex-direction: column; gap: 4px; border-radius: 10px; }
.starter b { font-size: 14px; }
.starter span { color: var(--muted); }
.cmdk { border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(600px, calc(100vw - 32px)); margin-top: 12vh; background: var(--panel); color: var(--text); box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.cmdk input { width: 100%; border: none; border-bottom: 1px solid var(--line); border-radius: 0; padding: 14px 16px; font-size: 15px; outline: none; }
.cmdk-list { max-height: 50vh; overflow: auto; padding: 6px; }
.cmdk-item { display: flex; gap: 10px; align-items: center; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.cmdk-item .ck { font-size: 11px; color: var(--muted); width: 54px; flex: none; text-transform: uppercase; letter-spacing: .04em; }
.cmdk-item .cd { color: var(--muted); font-size: 12px; margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%; }
.cmdk-item.active { background: var(--accent-soft); color: var(--accent-strong); }
.toast {
  position: fixed; bottom: 46px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: #1d2d3e; color: #fff; padding: 8px 14px; border-radius: 8px; transition: all .2s; z-index: 50; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
.toast-action { margin-left: 12px; background: var(--emphasized); border-color: var(--emphasized); color: #fff; font-weight: 700; padding: 3px 10px; }
table.rows td.nested { vertical-align: top; }
table.rows .nested-rows { margin: 2px 0 2px 12px; border-left: 2px solid var(--line-strong); padding-left: 6px; }
.fields .frow.sub { margin-left: 14px; }
.fields .subfields { margin: 2px 0 6px 14px; border-left: 2px solid var(--line-strong); padding-left: 6px; }

@media (max-width: 1280px) {
  .workspace { --drawer-w: 250px; --inspector-w: 290px; }
  .stage-body.view-split { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1.3fr) minmax(0, 1fr); }
  .stage-body.view-split .code-pane { border-left: none; border-top: 1px solid var(--line); }
}
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; grid-auto-rows: minmax(300px, auto); }
  .resizer { display: none; }
  body { height: auto; }
  .stage { min-height: 640px; }
  button.cmd span { display: none; }
  button.cmd { min-width: 0; }
}
