:root {
  --bg: #050b15;
  --surface: #0c1728;
  --raised: #101d31;
  --soft: #13213a;
  --border: rgba(160, 180, 222, .14);
  --border-strong: rgba(160, 180, 222, .26);
  --text: #f5f7ff;
  --muted: #8d9bb7;
  --violet: #8b7cff;
  --violet-strong: #7464f4;
  --cyan: #4ee7d0;
  --red: #ff5570;
  --pink: #fe2c55;
  --amber: #ffc25c;
  --green: #3ddc97;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 14px; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.ms { font-family: "Material Symbols Rounded"; font-weight: normal; font-style: normal; font-size: 18px; line-height: 1; display: inline-block; white-space: nowrap; direction: ltr; -webkit-font-smoothing: antialiased; font-variation-settings: "FILL" 1, "wght" 500; }
body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* top bar */
.lb-top { flex: none; display: flex; align-items: center; gap: 14px; padding: 12px 20px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, #0a1526, var(--bg)); flex-wrap: wrap; }
.lb-brand { display: flex; align-items: center; gap: 10px; }
.lb-brand > .ms { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, var(--cyan), var(--violet)); font-size: 22px; color: #06121f; }
.lb-brand b { display: block; font-size: 16px; }
.lb-brand small { color: var(--muted); font-size: 12px; }
.lb-scope { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); margin-left: 12px; }
.lb-scope button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted); padding: 7px 12px; border-radius: 9px; font-weight: 600; font-size: 13px; position: relative; }
.lb-scope button.on { background: var(--violet-strong); color: #fff; }
.lb-scope button[data-dirty="1"]::after { content: ""; position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.lb-save { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.lb-save i { width: 9px; height: 9px; border-radius: 50%; background: var(--green); }
.lb-save[data-state="dirty"] i { background: var(--amber); }
.lb-save[data-state="dirty"] span { color: var(--amber); }
.lb-save[data-state="saving"] i { background: var(--cyan); animation: lb-pulse 1s infinite; }
@keyframes lb-pulse { 50% { opacity: .4; } }
.lb-save-btn { display: inline-flex; align-items: center; gap: 5px; border: 0; border-radius: 9px; padding: 7px 14px; font-weight: 700; background: var(--violet-strong); color: #fff; }
.lb-save-btn:hover { background: var(--violet); }
.lb-undo-btn { border: 1px solid var(--border-strong); background: transparent; border-radius: 9px; padding: 6px 10px; color: var(--muted); font-weight: 600; }
.lb-link { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border-strong); color: var(--text); text-decoration: none; font-weight: 600; font-size: 13px; }
.lb-link:hover { background: var(--soft); }

.lb-banner { flex: none; padding: 8px 20px; font-size: 13px; border-bottom: 1px solid var(--border); }
.lb-banner[data-tone="global"] { background: rgba(116, 100, 244, .16); color: #d6d0ff; }
.lb-banner[data-tone="mine"] { background: rgba(78, 231, 208, .1); color: #bff7ee; }
.lb-banner[data-tone="readonly"] { background: rgba(255, 194, 92, .12); color: #ffe2ad; }

.lb-tabs { flex: none; display: flex; gap: 4px; padding: 10px 20px 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
.lb-tabs button { display: inline-flex; align-items: center; gap: 6px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); padding: 9px 12px 11px; font-weight: 600; white-space: nowrap; }
.lb-tabs button.on { color: var(--text); border-bottom-color: var(--cyan); }

.lb-main { flex: 1; min-height: 0; }
.lb-pane { height: 100%; display: grid; grid-template-columns: 290px minmax(0, 1fr); }
#pane-names, #pane-presets, #pane-excel { grid-template-columns: minmax(0, 1fr); }
.lb-side { min-height: 0; overflow-y: auto; padding: 14px; background: var(--surface); border-right: 1px solid var(--border); }
.lb-editor { min-height: 0; overflow-y: auto; padding: 18px 22px 40px; }
.lb-editor.wide { max-width: 980px; width: 100%; margin: 0 auto; }
.lb-side-title { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 4px 8px; }
.lb-side-title:first-child { margin-top: 2px; }
.lb-side-item { width: 100%; display: flex; align-items: center; gap: 8px; text-align: left; border: 1px solid transparent; background: transparent; border-radius: 10px; padding: 8px 10px; color: var(--text); }
.lb-side-item:hover { background: var(--raised); }
.lb-side-item.on { background: var(--raised); border-color: var(--violet); }
.lb-side-label { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lb-side-label b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-side-label small { color: var(--muted); font-size: 11px; }
.lb-side-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; }
.lb-side-hint { color: var(--muted); font-size: 11.5px; line-height: 1.45; margin: 6px 6px 4px; }
.lb-count { flex: none; min-width: 30px; text-align: center; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 7px; background: var(--soft); color: var(--muted); }
.lb-count.has { background: rgba(78, 231, 208, .14); color: var(--cyan); }
.lb-add { width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px; border: 1px dashed var(--border-strong); background: transparent; border-radius: 10px; padding: 9px; font-weight: 700; color: var(--cyan); margin-bottom: 8px; }
.lb-builtin { margin-top: 16px; color: var(--muted); font-size: 12px; }
.lb-builtin summary { cursor: pointer; padding: 6px 4px; }
.lb-builtin-row { padding: 6px 8px; border-top: 1px solid var(--border); }
.lb-builtin-row b { display: block; color: var(--text); font-weight: 600; font-size: 12.5px; }

.lb-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.lb-head h2 { margin: 0; font-size: 20px; }
.lb-kind { color: var(--muted); font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 7px; background: var(--soft); }
.lb-seg { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.lb-seg button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 10px; padding: 8px 12px; font-weight: 600; color: var(--muted); }
.lb-seg button.on { background: var(--violet-strong); border-color: var(--violet-strong); color: #fff; }
.lb-seg button:disabled { opacity: .45; cursor: not-allowed; }
.lb-defaults, .lb-en { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 8px 12px; margin-bottom: 12px; }
.lb-defaults summary, .lb-en summary { cursor: pointer; color: var(--muted); font-weight: 600; padding: 4px 0; }
.lb-defaults ul { margin: 8px 0; padding-left: 18px; color: #c9d1e6; line-height: 1.6; columns: 2; column-gap: 28px; }
.lb-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.lb-field-top { display: flex; align-items: baseline; gap: 8px; }
.lb-field-top em { color: var(--muted); font-style: normal; font-size: 12px; }
.lb-counter { margin-left: auto; color: var(--muted); font-size: 12px; }
textarea, .lb-editor input, .lb-editor select { width: 100%; min-width: 0; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg); outline: none; }
textarea { resize: vertical; line-height: 1.55; }
textarea:focus, .lb-editor input:focus, .lb-editor select:focus { border-color: var(--violet); }
select option, select optgroup { background: var(--surface); }
.lb-en textarea { margin: 8px 0 4px; }
.lb-tokens { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; color: var(--muted); font-size: 12px; }
.lb-token { border: 1px solid rgba(78, 231, 208, .35); background: rgba(78, 231, 208, .08); color: var(--cyan); border-radius: 8px; padding: 4px 9px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.lb-preview { border-radius: 12px; background: #1a1d29; padding: 12px; display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.lb-preview > b { color: var(--muted); font-size: 12px; font-weight: 600; }
.lb-bubble { display: inline-flex; gap: 8px; align-items: baseline; font-size: 13.5px; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.lb-bubble b { color: rgba(255, 255, 255, .6); font-weight: 600; }
.lb-note { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 6px 0 12px; }
.lb-muted { color: var(--muted); font-size: 13px; margin: 4px 0 8px; line-height: 1.5; }
.lb-name-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lb-name-chips b { width: 100%; color: var(--muted); font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.lb-name-chips span { padding: 4px 9px; border-radius: 999px; background: var(--raised); border: 1px solid var(--border); font-size: 12.5px; }

/* buttons */
.lb-ghost, .lb-primary, .lb-danger, .lb-mini, .lb-chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 10px; font-weight: 600; text-decoration: none; }
.lb-ghost { border: 1px solid var(--border-strong); background: transparent; padding: 8px 12px; color: var(--text); }
.lb-ghost:hover { background: var(--soft); }
.lb-ghost.disabled { opacity: .45; }
.lb-primary { border: 0; background: var(--violet-strong); color: #fff; padding: 9px 14px; }
.lb-primary:hover { background: var(--violet); }
.lb-danger { border: 1px solid rgba(255, 85, 112, .5); background: transparent; color: #ff8da0; padding: 8px 12px; }
.lb-danger.armed { background: var(--red); color: #fff; border-color: var(--red); }
.lb-mini { flex: none; border: 1px solid var(--border-strong); background: var(--raised); padding: 5px 9px; font-size: 12px; color: var(--text); }
.lb-chip { border: 1px solid var(--border-strong); background: var(--surface); padding: 6px 10px; font-size: 12.5px; color: var(--text); }
.lb-chip:hover { border-color: var(--cyan); }
.lb-chip .ms { font-size: 16px; color: var(--cyan); }
.lb-icon { border: 0; background: transparent; color: var(--muted); padding: 5px; border-radius: 8px; }
.lb-icon:hover { background: var(--soft); color: var(--text); }
.lb-icon.danger:hover { color: var(--red); }
.lb-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* scenarios */
.lb-empty { margin: 60px auto; max-width: 460px; text-align: center; color: var(--muted); }
.lb-empty .ms { font-size: 40px; color: var(--violet); }
.lb-empty p { color: var(--text); font-weight: 600; }
.lb-empty small { line-height: 1.55; display: block; }
.lb-scn-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.lb-editor .lb-title-input { font-size: 18px; font-weight: 700; padding: 10px 12px; }
.lb-flags { display: flex; flex-wrap: wrap; gap: 16px; }
.lb-check { display: inline-flex; align-items: center; gap: 8px; color: #c9d1e6; font-size: 13px; }
.lb-editor .lb-check input { width: 16px; height: 16px; padding: 0; accent-color: var(--violet); }
.lb-steps-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lb-steps-head h3 { margin: 6px 0; font-size: 15px; }
.lb-steps { display: flex; flex-direction: column; gap: 6px; }
.lb-step { display: grid; grid-template-columns: 74px 190px minmax(0, 1fr) auto; gap: 8px; align-items: end; padding: 8px 10px; border-radius: 12px; background: var(--raised); border: 1px solid var(--border); }
.lb-editor .lb-time { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.lb-editor .lb-time.bad { border-color: var(--red); background: rgba(255, 85, 112, .08); }
.lb-step-type { display: flex; align-items: center; gap: 6px; }
.lb-step-type .ms { color: var(--cyan); }
.lb-step-fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; min-width: 0; }
.lb-mini-field { display: flex; flex-direction: column; gap: 3px; min-width: 120px; flex: 0 1 170px; }
.lb-mini-field > span { color: var(--muted); font-size: 11px; }
.lb-mini-field.grow { flex: 1 1 240px; }
.lb-mini-field.w-num { flex: 0 0 96px; min-width: 96px; }
.lb-mini-field.w-name { flex: 0 1 150px; }
.lb-editor .lb-mini-field input, .lb-editor .lb-mini-field select, .lb-editor .lb-step select, .lb-editor .lb-step input { padding: 7px 9px; font-size: 13px; }
.lb-hint-inline { color: var(--muted); font-size: 11px; align-self: center; }
.lb-step-actions { display: flex; gap: 2px; align-self: center; }
.lb-add-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 12px 0; color: var(--muted); font-size: 12px; }
.lb-scn-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--border); color: var(--muted); }
.lb-scn-tools { display: flex; gap: 8px; flex-wrap: wrap; }

/* presets & excel */
.lb-card { padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 14px; }
.lb-card h3 { margin: 0 0 8px; font-size: 15px; }
.lb-preset { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.lb-preset-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.lb-preset-main small { color: var(--muted); font-size: 12px; }
.lb-preset-main span { color: #c9d1e6; font-size: 13px; }
.lb-file { display: flex; align-items: center; gap: 10px; border: 1px dashed var(--border-strong); border-radius: 12px; padding: 14px; cursor: pointer; color: var(--muted); margin-top: 6px; }
.lb-file:hover { border-color: var(--cyan); color: var(--text); }
.lb-file .ms { font-size: 26px; color: var(--cyan); }
.lb-file input { display: none; }
.lb-import { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--raised); border: 1px solid rgba(78, 231, 208, .35); }
.lb-import ul { margin: 8px 0; padding-left: 18px; line-height: 1.6; }
.lb-warnings { margin: 6px 0 10px; color: #ffe2ad; font-size: 12.5px; }
.lb-warnings summary { cursor: pointer; font-weight: 600; }

/* read-only */
body.lb-readonly textarea { opacity: .85; }

.lb-gate { margin: auto; max-width: 460px; text-align: center; padding: 40px 24px; }
.lb-gate .ms { font-size: 44px; color: var(--violet); }
.lb-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); padding: 10px 16px; border-radius: 12px; background: #1f9d6b; color: #fff; font-weight: 600; box-shadow: 0 12px 30px rgba(0, 0, 0, .45); z-index: 10; max-width: calc(100vw - 32px); }
.lb-toast[data-tone="bad"] { background: #b8324a; }

@media (max-width: 900px) {
  body { height: auto; overflow: auto; }
  .lb-pane { display: flex; flex-direction: column; height: auto; }
  .lb-side { border-right: 0; border-bottom: 1px solid var(--border); max-height: 320px; }
  .lb-editor { overflow: visible; padding: 14px 16px 40px; }
  .lb-step { grid-template-columns: 70px minmax(0, 1fr) auto; }
  .lb-step-fields { grid-column: 1 / -1; }
  .lb-defaults ul { columns: 1; }
  .lb-scope { margin-left: 0; }
}
@media (max-width: 560px) {
  .lb-top { padding: 10px 16px; }
  .lb-tabs { padding: 8px 16px 0; }
  .lb-banner { padding: 8px 16px; }
  .lb-save { margin-left: 0; width: 100%; }
}
