/* ============================================================
   NEUROSTEER STIMULUS COMPOSER — GLOBAL STYLES
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #f4f6f9;
  --surface:      #ffffff;
  --border:       #e2e6ec;
  --border-light: #edf0f4;

  --text-primary:   #1a2233;
  --text-secondary: #5a6478;
  --text-tertiary:  #8c95a6;

  --blue:        #235feb;
  --blue-light:  #eff4ff;
  --blue-mid:    #3b82f6;
  --green:       #16a34a;
  --green-light: #dcfae6;
  --green-light-border: #aef2c9;
  --amber:       #ab7e55;
  --amber-medium: #984c1b;
  --amber-light: #faf0c3;
  --amber-border:#fde68a;
  --amber-light-border: #fae190;
  --red:         #dc2626;
  --purple:      #7c3aed;
  --pink:        #ec4899;
  --pink-light:  #fae6f0;
  --pink-light-border: #f9d9eb;
  --violet-dark: #3f5bba;
  --violet: #6478b0;
  --violet-light: #dce6ff;
  --violet-light-border: #c3d0fb;
  --violet-lighter: #ebf5ff;
  --violet-lighter-border: #e1ecfb;
  --orange-gold: #f59b0a;

  --font:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --radius:    6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 4px 12px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12), 0 4px 10px rgba(0,0,0,.07);

  --topnav-h:   48px;
  --statusbar-h:32px;
  --sidebar-w:  240px;
  --props-w:    260px;
}

html, body, #app {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ── Shared button primitives ── */
.btn-primary {
  padding: 5px 16px;
  border: none; border-radius: var(--radius);
  background: var(--blue); color: #fff;
  font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.btn-primary:hover { background: #1d4ed8; }

.btn-danger {
  padding: 5px 16px;
  border: none; border-radius: var(--radius);
  background: var(--red); color: #fff;
  font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.btn-danger:hover { background: #b91c1c; }

.confirm-modal { width: 400px; }
.confirm-modal .cm-message { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--text-primary); }

.btn-secondary {
  padding: 5px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text-primary);
  font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background .15s;
}
.btn-secondary:hover { background: var(--bg); }

.btn-outline-info {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  border: 1.5px solid var(--blue); border-radius: var(--radius);
  background: transparent; color: var(--blue);
  font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .15s, color .15s;
}
.btn-outline-info:hover { background: var(--blue-light); }
.btn-outline-info svg { width: 15px; height: 15px; }

.btn-icon {
  width: 28px; height: 28px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); transition: all .15s;
}
.btn-icon svg { width: 15px; height: 15px; }
.btn-icon:hover { background: var(--bg); border-color: #c5cbd6; }

/* ── Form primitives ── */
.prop-input {
  width: 100%; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 12.5px; color: var(--text-primary);
  font-family: var(--font);
  outline: none; background: var(--surface);
  transition: border-color .12s;
}
.prop-input:focus { border-color: var(--blue); }

.prop-select {
  width: 100%; padding: 6px 24px 6px 8px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 12.5px; color: var(--text-primary);
  font-family: var(--font);
  outline: none; background: var(--surface);
  -webkit-appearance: none; appearance: none; cursor: pointer;
}

.prop-select-wrap {
  position: relative;
}
.prop-select-wrap::after {
  content: '▾'; font-size: 10px; color: var(--text-tertiary);
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  pointer-events: none;
}

.prop-label {
  font-size: 11px; color: var(--text-tertiary);
  display: block; margin-bottom: 4px;
}

.prop-divider { height: 1px; background: var(--border-light); margin: 12px 0; }

.prop-section-label {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-tertiary); margin-bottom: 8px;
}

/* ── Modal overlay ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15,23,42,.4);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}

/* ── Toast ── */
.toast-stack {
  position: fixed; bottom: 44px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px; z-index: 500; pointer-events: none;
}
.toast {
  background: var(--text-primary); color: #fff;
  padding: 7px 18px; border-radius: 20px; font-size: 12.5px;
  box-shadow: var(--shadow); white-space: nowrap;
}

/* ── App shell ── */
.app-shell { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ── TopNav ── */
.topnav {
  height: var(--topnav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; flex-shrink: 0; z-index: 100;
}
.topnav-left  { display: flex; align-items: center; gap: 12px; }
.topnav-right { display: flex; align-items: center; gap: 8px; }
.logo-mark {
  width: 28px; height: 28px; background: var(--blue); color: #fff;
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.logo-text { display: flex; flex-direction: column; line-height: 1.1; }
.logo-name  { font-weight: 600; font-size: 13px; }
.logo-sub   { font-size: 10.5px; color: var(--text-tertiary); }
.breadcrumb { display: flex; align-items: center; gap: 4px; margin-left: 4px; }
.breadcrumb-parent  { color: var(--text-tertiary); font-size: 12px; cursor: pointer; }
.breadcrumb-parent:hover { color: var(--blue); }
.breadcrumb-sep     { color: var(--text-tertiary); font-size: 12px; }
.breadcrumb-input {
  font-weight: 600; font-size: 13px; font-family: var(--font);
  border: none; outline: none; background: transparent;
  color: var(--text-primary); min-width: 40px; width: auto;
  padding: 1px 4px; border-radius: 3px;
}
.breadcrumb-input:hover { background: var(--bg); }
.breadcrumb-input:focus { background: var(--bg); box-shadow: 0 0 0 1px var(--blue); }
.locale-selector {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 3px 8px; background: var(--surface);
}
.locale-dot { width: 7px; height: 7px; background: var(--green); border-radius: 50%; }
.locale-selector select {
  border: none; outline: none; font-size: 12px;
  color: var(--text-primary); background: transparent; cursor: pointer;
  font-family: var(--font);
}
.btn-icon:disabled { opacity: .35; cursor: not-allowed; }

/* ── StatusBar ── */
.statusbar {
  height: var(--statusbar-h);
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; font-size: 11.5px; color: var(--text-tertiary); flex-shrink: 0;
}
.status-left, .status-center, .status-right { display: flex; align-items: center; gap: 6px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; }
.status-dot.green  { background: var(--green); }
.status-dot.amber  { background: var(--amber); }
.status-dot.red    { background: #d04444; }
.sep { color: var(--border); }
.statusbar strong { color: var(--text-primary); }
.dur-warn { color: #e8a020; cursor: help; }
.schema-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; color: inherit;
  background: transparent; border: 1px solid transparent;
  padding: 1px 6px; border-radius: 999px; line-height: 1.4;
}
button.schema-chip--err {
  cursor: pointer; color: #c0392b;
  background: #fff1f1; border-color: #f3c5c5;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
button.schema-chip--err:hover { background: #ffe1e1; border-color: #e89494; }
button.schema-chip--err:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(208,68,68,.35); }

#tn-save.is-invalid {
  color: #c0392b; border-color: #f3c5c5; background: #fff6f6;
}
#tn-save.is-invalid:hover { background: #ffe9e9; border-color: #e89494; }

.tool-btn.is-invalid {
  color: #c0392b; border-color: #f3c5c5; background: #fff6f6;
}
.tool-btn.is-invalid:hover { background: #ffe9e9; border-color: #e89494; }

/* ── Validation Errors modal ── */
.vem-modal { width: 640px; max-width: 92vw; }
.vem-body-pane { padding: 0; max-height: 60vh; overflow-y: auto; gap: 0; }
.vem-empty {
  padding: 24px; text-align: center; color: var(--text-tertiary); font-size: 13px;
}
.vem-row {
  display: grid; grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border-light);
  align-items: start;
}
.vem-row:last-child { border-bottom: none; }
.vem-num {
  font-size: 11px; font-weight: 600; color: var(--text-tertiary);
  background: var(--bg); border-radius: var(--radius);
  text-align: center; padding: 2px 0; line-height: 1.4;
}
.vem-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.vem-path {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px;
  align-self: flex-start; line-height: 1.6;
}
.vem-path--root {
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--text-tertiary); padding: 1px 6px;
  background: var(--bg); border-radius: var(--radius);
}
.vem-crumb {
  display: inline-block; font-size: 11.5px; font-weight: 500;
  padding: 1px 8px; border-radius: 999px;
  background: var(--bg); color: var(--text-secondary);
  border: 1px solid var(--border-light);
}
.vem-crumb--block   { background: #eef4ff; border-color: #cfdcf5; color: #2c4d8c; }
.vem-crumb--section { background: #fdf2e9; border-color: #f3d1ad; color: #8a4f1d; }
.vem-sep { color: var(--text-tertiary); font-size: 12px; }
.vem-field {
  font-family: var(--font-mono); font-size: 11.5px;
  color: #c0392b; background: #fff1f1; border: 1px solid #f3c5c5;
  padding: 1px 6px; border-radius: var(--radius);
  word-break: break-all;
}
.vem-msg { font-size: 13px; color: var(--text-primary); line-height: 1.45; word-wrap: break-word; }

/* ── SequencesView ── */
.sequences-page {
  flex: 1; display: flex; flex-direction: column;
  padding: 32px 40px; overflow-y: auto; gap: 24px;
}
.sequences-header {
  display: flex; align-items: center; justify-content: space-between;
}
.sequences-header h1 { font-size: 18px; font-weight: 600; margin: 0; }
.sequences-list { display: flex; flex-direction: column; gap: 8px; }
.sequences-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.sequences-list.is-loading,
.sequences-grid.is-loading { position: relative; pointer-events: none; }
.sequences-list.is-loading > *:not(.list-spinner),
.sequences-grid.is-loading > *:not(.list-spinner) {
  opacity: 0.55; transition: opacity 0.12s;
}
.list-spinner { display: none; }
.sequences-list.is-loading > .list-spinner,
.sequences-grid.is-loading > .list-spinner {
  display: block;
  position: absolute; top: 50%; left: 50%;
  width: 32px; height: 32px; margin: -16px 0 0 -16px;
  border: 3px solid var(--blue); border-right-color: transparent;
  border-radius: 50%; animation: btn-spin .7s linear infinite;
  z-index: 2; pointer-events: none;
}
.sequences-list.is-loading-empty,
.sequences-grid.is-loading-empty {
  display: flex; flex: 1; align-items: center; justify-content: center;
  min-height: 320px;
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0;
  background: transparent; border: 1px solid var(--border);
  border-radius: 4px; cursor: pointer; color: var(--text-secondary);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.icon-btn:hover { background: var(--bg); color: var(--text-primary); }
.icon-btn-danger { border-color: var(--red); color: var(--red); background: transparent; }
.icon-btn-danger:hover { background: rgba(220, 38, 38, 0.08); color: var(--red); border-color: var(--red); }
.icon-btn-primary { border-color: var(--blue); color: var(--blue); background: transparent; }
.icon-btn-primary:hover { background: var(--blue-light); color: var(--blue); border-color: var(--blue); }
.icon-btn-success { border-color: var(--green); color: var(--green); background: transparent; }
.icon-btn-success:hover { background: var(--green-light); color: var(--green); border-color: var(--green); }
.icon-btn-warning { border-color: var(--orange-gold); color: var(--orange-gold); background: transparent; }
.icon-btn-warning:hover { background: #fff4dc; color: var(--orange-gold); border-color: var(--orange-gold); }
.icon-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.view-toggle {
  display: inline-flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden;
}
.divider-v {
  display: inline-block; width: 1px; height: 20px;
  background: var(--border); margin: 0 4px;
}
.view-toggle-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0;
  background: transparent; border: none; cursor: pointer;
  color: var(--text-tertiary);
}
.view-toggle-btn + .view-toggle-btn { border-left: 1px solid var(--border); }
.view-toggle-btn:hover { color: var(--text-primary); background: var(--bg); }
.view-toggle-btn.is-active { color: var(--blue); background: var(--bg); }
.sequence-grid-card {
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  overflow: hidden; transition: border-color 0.15s, transform 0.15s;
}
.sequence-grid-card:hover { border-color: var(--blue); }
.sequence-grid-thumb {
  position: relative; height: 100px; cursor: pointer;
  background: linear-gradient(135deg, var(--bg) 0%, var(--surface) 100%);
  display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--border);
}
.sequence-grid-initial {
  font-size: 32px; font-weight: 600; color: var(--text-tertiary);
}
.sequence-grid-badge {
  position: absolute; top: 8px; right: 8px;
  padding: 2px 8px; font-size: 10px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-secondary);
}
.sequence-grid-body {
  padding: 10px 12px 4px; display: flex; flex-direction: column; gap: 2px; min-height: 44px;
}
.sequence-grid-body .sequence-name {
  font-size: 13px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sequence-grid-body .sequence-meta { font-size: 11px; color: var(--text-tertiary); }
.sequence-grid-actions {
  display: flex; justify-content: flex-end; gap: 6px;
  padding: 8px 12px 12px;
}
.sequences-pager {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--text-secondary);
}
.sequences-pager:empty { display: none; }
.pager-info { font-size: 12px; color: var(--text-tertiary); }
.pager-controls { display: flex; align-items: center; gap: 10px; }
.pager-size { display: inline-flex; align-items: center; gap: 6px; color: var(--text-tertiary); }
.pager-page { color: var(--text-secondary); }
.sequences-pager button[disabled] { opacity: 0.4; cursor: not-allowed; }
.pager-nav {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0;
  background: transparent; border: 1px solid var(--border);
  border-radius: 4px; cursor: pointer; color: var(--text-secondary);
}
.pager-nav:hover:not([disabled]) { background: var(--bg); color: var(--text-primary); }
.sequence-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface);
}
.sequence-info { display: flex; flex-direction: column; gap: 2px; }
.sequence-name { font-size: 13px; font-weight: 500; }
.sequence-meta { font-size: 11px; color: var(--text-tertiary); }
.sequence-actions { display: flex; gap: 8px; }
.empty-state { font-size: 13px; color: var(--text-tertiary); padding: 24px 0; }
.btn-ghost {
  padding: 5px 14px; font-size: 12px; border-radius: 4px; cursor: pointer;
  background: transparent; border: 1px solid var(--border); color: var(--text-primary);
}
.btn-ghost-sm {
  padding: 3px 10px; font-size: 11px; border-radius: 4px; cursor: pointer;
  background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
}
.btn-ghost-sm:hover { background: var(--bg); color: var(--text-primary); }

/* User menu (avatar + dropdown) */
.user-menu { position: relative; display: inline-flex; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--blue-light);
  color: var(--blue); font-family: var(--font); font-size: 12px; font-weight: 600;
  letter-spacing: .02em; cursor: pointer; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.user-avatar:hover { background: #e4ecff; border-color: #cfdcfb; }
.user-avatar[aria-expanded="true"] {
  background: var(--blue); color: #fff; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(35, 95, 235, 0.18);
}
.user-avatar-initials { line-height: 1; }

.user-menu-popover {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 240px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  padding: 4px; z-index: 200;
  animation: ump-fade .12s ease-out;
}
@keyframes ump-fade {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ump-header { display: flex; align-items: center; gap: 12px; padding: 12px 12px 10px; }
.ump-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--blue-light); color: var(--blue);
  font-size: 14px; font-weight: 600; letter-spacing: .02em;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ump-id { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ump-name { font-size: 13.5px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ump-email { font-size: 11.5px; color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ump-id .uv-role { margin-top: 4px; align-self: flex-start; }
.ump-sep { height: 1px; background: var(--border-light); margin: 2px 4px; }
.ump-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border: none; background: transparent;
  font-family: var(--font); font-size: 13px; color: var(--text-primary);
  border-radius: var(--radius); cursor: pointer; text-align: left;
  transition: background .12s;
}
.ump-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.ump-item:hover { background: var(--bg); }
.ump-item-danger { color: var(--red); }
.ump-item-danger:hover { background: rgba(220, 38, 38, 0.08); }
.ump-item:disabled { opacity: .5; cursor: default; }
.btn-ghost-preview {
  padding: 5px 14px; font-size: 12px; border-radius: 4px; cursor: pointer;
  background: transparent; border: 1px solid var(--border); color: #fff; text-decoration: none;
}
.nav-btns {
  margin-left: 32px;
}
.nav-btns button{
  margin-left: 8px;
  border: 1px solid var(--blue);
  color: var(--blue);
}

.nav-btns button:hover{
  opacity: 0.7;
}

.nav-btns button.active{
  background-color: var(--blue);
  color: #fff;
}
/* ── CreateView ── */
.create-page {
  flex: 1; display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 40px; overflow-y: auto;
}
.create-form {
  width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 20px;
}
.create-form h1 { font-size: 18px; font-weight: 600; margin: 0; }
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-group label { font-size: 12px; color: var(--text-secondary); }
.create-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.input {
  padding: 6px 10px; font-size: 13px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text-primary);
  outline: none;
}
.input:focus { border-color: var(--accent); }

/* ── EditorView ── */
.app-body { flex: 1; display: flex; overflow: hidden; min-height: 0; }
.app-body--editor { flex-direction: column; }
.editor-row { flex: 1; display: flex; overflow: hidden; min-height: 0; }

/* ── Timeline Bar ── */
.timeline-bar {
  flex-shrink: 0; height: 32px;
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 12px; overflow: hidden;
}
.tl-inner { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; }
.tl-total { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; flex-shrink: 0; }
.tl-track {
  flex: 1; display: flex; height: 18px; border-radius: 4px; overflow: hidden;
  gap: 1px; background: var(--border-light); min-width: 0;
}
.tl-seg {
  position: relative; min-width: 4px; cursor: pointer; overflow: hidden;
  display: flex; align-items: center; transition: opacity .15s;
}
.tl-seg:hover { opacity: 1 !important; }
.tl-seg--active { outline: 2px solid white; outline-offset: -2px; }
.tl-seg-label {
  font-size: 10px; color: rgba(255,255,255,0.9); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; padding: 0 4px; pointer-events: none;
}

/* ── SequenceTree / Sidebar ── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.sidebar-section { padding: 12px 12px 8px; }
.tree-section { flex: 1; overflow-y: auto; }
.sidebar-divider { height: 1px; background: var(--border-light); flex-shrink: 0; }
.sidebar-label {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-tertiary); margin-bottom: 8px;
}
.search-wrap { position: relative; margin-bottom: 10px; }
.search-icon {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 12px; height: 12px; color: var(--text-tertiary);
}
.search-input {
  width: 100%; padding: 5px 8px 5px 26px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 12px; outline: none; background: var(--bg);
  font-family: var(--font);
}
.search-input:focus { border-color: var(--blue); background: var(--surface); }
.search-input::placeholder { color: var(--text-tertiary); }
.lib-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 4px; cursor: pointer; border-radius: 4px;
  transition: background .1s;
}
.lib-item:hover { background: var(--bg); }
.lib-icon { font-size: 12px; width: 16px; text-align: center; color: var(--text-tertiary); }
.icon-param   { color: var(--green); }
.icon-trigger { color: var(--amber); }
.lib-name  { flex: 1; font-size: 12px; }
.lib-count { font-size: 11px; color: var(--text-tertiary); }

/* ── TreeItem ── */
.tree-item {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 4px; border-radius: 4px; cursor: pointer;
  user-select: none; white-space: nowrap; overflow: hidden;
  transition: background .1s; font-size: 12px;
}
.tree-item:hover { background: var(--bg); }
.tree-item.selected { background: var(--blue-light); }
.tree-item.selected .tree-name { color: var(--blue); font-weight: 600; }
.tree-item.tree-dragging { opacity: .35; }
.tree-inline-input { font: inherit; font-size: 12px; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--blue); border-radius: 3px; padding: 0 4px; height: 18px; width: calc(100% - 8px); outline: none; }
.tree-inline-input.is-invalid { border-color: var(--red); background: #fff5f5; }
.tree-item { transition: margin .12s ease; position: relative; }
.tree-item.drop-before { margin-top: 22px; }
.tree-item.drop-after  { margin-bottom: 22px; }
.tree-item.drop-before::before,
.tree-item.drop-after::after {
  content: ''; position: absolute; left: 8px; right: 8px; height: 3px;
  background: #4ade80; border-radius: 2px; box-shadow: 0 0 0 2px #f0fdf4;
  pointer-events: none;
}
.tree-item.drop-before::before { top: -12px; }
.tree-item.drop-after::after   { bottom: -12px; }
.tree-arrow {
  width: 12px; flex-shrink: 0; font-size: 10px;
  color: var(--text-tertiary); transition: transform .15s;
  display: inline-flex; align-items: center;
}
.tree-arrow.expanded { transform: rotate(0deg); }
.tree-arrow:not(.expanded) { transform: rotate(-90deg); }
.tree-arrow-spacer { width: 12px; flex-shrink: 0; }
.icon-block {
  width: 13px; height: 13px; flex-shrink: 0;
  border: 1.5px solid var(--border); border-radius: 2px; display: inline-block;
}
.icon-circle {
  width: 7px; height: 7px; flex-shrink: 0;
  border: 1.5px solid var(--text-tertiary); border-radius: 50%; display: inline-block;
}
.icon-circle.nback { background: var(--blue); border-color: var(--blue); }
.icon-circle.branch-circle { border-radius: 2px; }
.tree-name { flex: 1; overflow: hidden; text-overflow: ellipsis; color: var(--text-primary); }
.block-name { font-weight: 600; }

/* ── FlowEditor ── */
.flow-pane { flex: 1; display: flex; flex-direction: row; overflow: hidden; background: var(--bg); min-width: 0; position: relative; }

/* ── Palette strip ── */
.flow-palette {
  width: 144px; flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 10px 7px; gap: 4px; overflow-y: auto;
}
.fp-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-tertiary);
  padding: 6px 4px 4px; margin-top: 2px;
}
.fp-item {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 7px; border-radius: 5px;
  font-size: 11.5px; color: var(--text-primary);
  cursor: grab; border: 1px solid var(--border);
  background: var(--bg); user-select: none; transition: all .12s;
}
.fp-item:hover { background: var(--surface); border-color: #c5cbd6; box-shadow: var(--shadow-sm); }
.fp-item:active, .fp-item.dragging { cursor: grabbing; opacity: .6; }
.fp-hint { margin-top: auto; padding-top: 16px; font-size: 10.5px; color: var(--text-tertiary); line-height: 1.4; padding: 16px 2px 0; }
.fp-dot { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }

/* ── Flow main (toolbar + canvas) ── */
.flow-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; min-width: 0; }

.flow-toolbar {
  height: 40px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; flex-shrink: 0;
}
.view-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg); }
.view-btn {
  padding: 4px 14px; border: none; background: transparent;
  font-size: 12px; font-weight: 500; cursor: pointer;
  color: var(--text-secondary); transition: all .12s; font-family: var(--font);
}
.view-btn.active { background: var(--surface); color: var(--text-primary); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.flow-tools { display: flex; gap: 4px; align-items: center; }
.tool-btn {
  width: 28px; height: 26px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); font-size: 14px; font-weight: 600; cursor: pointer;
  color: var(--text-secondary); display: flex; align-items: center; justify-content: center;
  transition: background .12s; font-family: var(--font);
}
.tool-btn:hover { background: var(--bg); color: var(--text-primary); }
.tool-btn svg { display: block; }
.tool-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.fit-btn { width: auto; padding: 0 8px; font-size: 11px; }

/* Trigger Library entry — labeled toolbar button with optional count badge.
   Sits between view-toggle and flow-tools; amber identity matches canvas
   trigger badges (#92400e), but kept subtle so it reads as an entry point. */
.trig-lib-btn {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px 0 9px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  font-family: var(--font); font-size: 11px; font-weight: 600; letter-spacing: .03em;
  color: var(--text-secondary); cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.trig-lib-btn:hover  { background: var(--bg); color: var(--text-primary); border-color: #d3d8e0; }
.trig-lib-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.trig-lib-btn svg    { display: block; opacity: .85; }
.trig-lib-label      { line-height: 1; }
.trig-lib-btn.has-triggers {
  color: var(--amber-medium); border-color: var(--amber-border); background: #fffaf0;
}
.trig-lib-btn.has-triggers:hover { background: var(--amber-light); border-color: var(--amber-light-border); }
.trig-lib-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 16px; padding: 0 5px; margin-left: 1px;
  background: var(--amber-medium); color: #fff;
  border-radius: 8px; font-size: 10px; font-weight: 700; line-height: 1;
  letter-spacing: 0; font-variant-numeric: tabular-nums;
}
.flow-canvas-wrap {
  flex: 1; overflow: hidden; cursor: grab; user-select: none; position: relative;
  background-color: #f8f9fb;
  background-image:
    linear-gradient(to right, rgba(180,186,198,0.15) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(180,186,198,0.15) 1px, transparent 1px);
  background-size: 64px 64px;
}
.flow-canvas-wrap:active { cursor: grabbing; }
.flow-node { cursor: pointer; }
.flow-node:hover rect { filter: brightness(.97); }
.flow-port { opacity: 0; cursor: crosshair; transition: opacity .15s; }
.flow-node:hover .flow-port,
.connecting-active .flow-port,
.flow-port.port-active { opacity: 1; }
g[data-port-id]:hover .flow-port { r: 6px; opacity: 1; filter: drop-shadow(0 0 5px currentColor); }
.conn-delete { opacity: 0; cursor: pointer; transition: opacity .15s; }
.conn-group:hover .conn-delete { opacity: 1; }
.conn-label-fo { overflow: visible; pointer-events: none; }
.conn-label-input {
  width: 100%; height: 100%; box-sizing: border-box;
  font-size: 10px; font-family: Inter, sans-serif;
  text-align: center; background: #fff; color: #1a2233;
  border: 1px solid #94a3b8; border-radius: 4px;
  padding: 2px 4px; outline: none; pointer-events: all;
}
.conn-label-input:focus { border-color: #475569; box-shadow: 0 0 0 2px rgba(71,85,105,.15); }
.conn-label-input::placeholder { color: #c0c7d4; }

/* ── Delete confirm dialog ── */
.del-confirm-overlay {
  position: absolute; inset: 0; z-index: 200;
  background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
}
.del-confirm-box {
  background: #fff; border-radius: 10px; padding: 24px 28px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  min-width: 300px; max-width: 400px;
}
.del-confirm-title { font-size: 15px; font-weight: 700; color: #1a2233; margin-bottom: 8px; }
.del-confirm-msg   { font-size: 13px; color: #5a6478; margin-bottom: 20px; line-height: 1.5; }
.del-confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }
.del-confirm-cancel {
  padding: 7px 16px; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid #e2e6ec; background: #fff; color: #5a6478;
}
.del-confirm-cancel:hover { background: #f4f6f9; }
.del-confirm-ok {
  padding: 7px 16px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; background: #dc2626; color: #fff;
  outline: none;
}
.del-confirm-ok:hover { background: #b91c1c; }
/* .del-confirm-ok:focus-visible { box-shadow: 0 0 0 3px rgba(220, 38, 38, .35); } */
.del-confirm-cancel { outline: none; }
/* .del-confirm-cancel:focus-visible { box-shadow: 0 0 0 3px rgba(148, 163, 184, .35); } */

/* ── PropertyEditor ── */
.properties-pane {
  width: var(--props-w); flex-shrink: 0;
  background: var(--surface); border-left: 1px solid var(--border);
  overflow-y: auto; padding: 14px;
}
.prop-header {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-tertiary); margin-bottom: 10px;
}
.prop-empty { font-size: 12px; color: var(--text-tertiary); padding: 8px 0; }

/* ── Props shared ── */
.prop-title    { font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.prop-subtitle { font-size: 11px; color: var(--text-tertiary); margin-bottom: 14px; }
.prop-field    { margin-bottom: 12px; }
.prop-row      { display: flex; gap: 8px; }
.prop-row .prop-field { flex: 1; }
.checkbox-row  { display: flex; align-items: center; gap: 8px; }
.checkbox-row label { font-size: 12.5px; }
.prop-validation-sticky {
  position: sticky; bottom: -14px;
  background: var(--surface);
  margin: 16px -14px -14px; padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
  z-index: 1;
}
.val-list { display: flex; flex-direction: column; gap: 4px; }
.val-item { display: flex; align-items: center; gap: 6px; font-size: 11.5px; }
.val-dot  { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-ok   { background: var(--green); }
.dot-warn { background: var(--amber); }
.dot-err  { background: var(--red); }
.empty { font-size: 12px; color: var(--text-tertiary); }

/* ── NBackProps specific ── */
.prob-row { position: relative; }
.prob-row .prop-input { padding-right: 52px; }
.prob-badge {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--text-secondary);
  background: var(--bg); border: 1px solid var(--border);
  padding: 2px 7px; border-radius: 4px; white-space: nowrap;
  pointer-events: none;
}
.override-list { display: flex; flex-direction: column; gap: 5px; margin-bottom: 4px; background: #f5fafa; border: 1px solid #ebedf5; border-radius: 5px; padding: 6px 8px; }
.override-item { display: flex; align-items: center; gap: 6px; font-size: 11.5px; }
.override-dot  { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-active  { background: #235feb; }
.dot-inherit { background: #d1d5db; }
.override-key { color: var(--text-secondary); font-family: var(--font-mono); font-size: 10.5px; }
.override-val { font-weight: 500; font-family: var(--font-mono); font-size: 10.5px; }
.override-globals-list { display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 8px; margin-bottom: 4px; overflow: hidden; }
.og-row { display: flex; align-items: center; gap: 8px; padding: 5px 4px; border-radius: 4px; cursor: pointer; user-select: none; min-width: 0; }
.og-row:hover { background: var(--hover); }
.og-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: #c5c9d4; transition: background .15s; }
.og-dot--active { background: #235feb; }
.og-key { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.og-row--active .og-key { color: var(--text); }
.og-inherit { font-size: 11px; color: var(--text-tertiary); flex-shrink: 0; }
.og-display { font-size: 11px; font-weight: 700; color: var(--text); flex-shrink: 0; cursor: text; }
.og-row .og-value.prop-input { height: 22px; padding: 1px 5px; font-size: 11px; width: 64px; flex-shrink: 0; }
.trigger-card {
  background: var(--amber-light); border: 1px solid var(--amber-border);
  border-radius: var(--radius); padding: 8px 10px; margin-bottom: 6px; cursor: pointer;
}
.trigger-card:hover { box-shadow: var(--shadow-sm); }
.tc-name { font-size: 12px; font-weight: 600; color: var(--amber); display: flex; align-items: center; gap: 5px; margin-bottom: 3px; }
.tc-dot  { width: 7px; height: 7px; background: var(--orange-gold); border-radius: 50%; }
.tc-cond, .tc-action { font-size: 11px; color: var(--text-secondary); line-height: 1.5; }
.add-trigger-btn {
  width: 100%; padding: 6px; border: 1px dashed var(--border); border-radius: var(--radius);
  background: transparent; font-size: 12px; color: var(--text-tertiary); cursor: pointer;
  transition: all .12s; font-family: var(--font);
}
.add-trigger-btn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }

/* ── TriggerBuilderModal ── */
.trigger-modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 65%; max-width: 96vw; max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.tm-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.tm-title   { font-size: 15px; font-weight: 700; }
.tm-sub     { font-size: 11.5px; color: var(--text-tertiary); margin-top: 2px; }
.tm-actions { display: flex; gap: 8px; }
.tm-body { display: flex; flex: 1; overflow: hidden; min-height: 0; }
.palette {
  width: 210px; flex-shrink: 0; border-right: 1px solid var(--border);
  padding: 14px; overflow-y: auto; background: #fafbfc;
}
.pal-label   { font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.pal-sub     { font-size: 11px; color: var(--text-tertiary); margin-bottom: 12px; }
.pal-section {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-primary); margin: 10px 0 6px;
}
.pal-blocks  { display: flex; flex-wrap: wrap; gap: 5px; }
.pal-block   { padding: 5px 10px; border-radius: 5px; font-size: 12px; font-weight: 700; cursor: grab; user-select: none; }
.pal-block:active, .var-item:active { opacity: 0.7; cursor: grabbing; }
.logic-cmd   { width: 48%; display: flex; justify-content: center; }
.logic-and   { background: var(--amber-light); color: #000; border: 1.5px solid var(--amber-light-border); }
.logic-or    { background: var(--violet-light); color: #000; border: 1.5px solid var(--violet-light-border); }
.logic-not   { background: var(--violet-light); color: #000; border: 1.5px solid var(--violet-light-border); }
.comp-grid   { display: flex; flex-wrap: wrap; gap: 4px; }
.comp-op     { background: var(--pink-light); color: #374151; border: 1.5px solid var(--pink-light-border); text-align: center; }
.comp-op:not(.wide) { width: 23%; }
.comp-op.wide { width: 48%; }
.comp-op:hover { background: var(--pink-light); }
.wide        { text-align: center; }
.var-search  {
  width: 100%; padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 11.5px; outline: none; background: var(--surface); margin-bottom: 6px;
  font-family: var(--font);
}
.var-list    { display: flex; flex-direction: column; gap: 2px; }
.var-item    {
  background: var(--violet-light); border: 1px solid var(--violet-light-border); display: flex; align-items: center; justify-content: space-between;
  padding: 4px 6px; margin-bottom: 4px; border-radius: 4px; cursor: grab; transition: background .1s;
}
.var-item:hover { background: var(--bg); }
.var-name    { font-family: var(--font-mono); color: var(--text-primary); font-size: 10.5px; font-weight: 600; }
.var-type    { font-size: 10px; color: var(--text-tertiary); }
.add-var-btn {
  width: 100%; margin-top: 8px; padding: 5px; border: 1px dashed var(--border);
  border-radius: var(--radius); background: transparent; font-size: 11.5px; color: var(--text-tertiary);
  cursor: pointer; font-family: var(--font);
}
.add-var-btn:hover { border-color: var(--blue); color: var(--blue); }
.canvas-col  { flex: 1; padding: 16px 20px; overflow-y: auto; min-width: 0; }
.canvas-section { font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.canvas-sub  { font-size: 11.5px; color: var(--text-tertiary); margin-bottom: 14px; }
.logic-tree           { display: flex; flex-direction: column; align-items: center; margin-bottom: 8px; --tree-line: #c5cbd6; --tree-box-bg: transparent; --tree-box-border: transparent; --tree-badge-color: var(--text-primary); }
.tree-op-and          { --tree-line: #fde68a;  --tree-box-bg: #fffbeb; --tree-box-border: #fde68a; --tree-badge-color: #92400e; }
.tree-op-or,
.tree-op-not          { --tree-line: #c3d0fb;  --tree-box-bg: #dce6ff; --tree-box-border: #c3d0fb; --tree-badge-color: #3730a3; }
.tree-root   { display: flex; justify-content: center; margin-bottom: 20px; position: relative; }
.root-node-box {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--tree-box-bg); border: 1.5px solid var(--tree-box-border); border-radius: 6px;
  padding: 6px 14px; position: relative;
}
.root-node-box::after {
  content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  width: 2px; height: 22px; background: var(--tree-line);
}
.tree-level  { display: flex; gap: 16px; position: relative; padding-top: 20px; overflow-x: auto; max-width: 100%; }
.tree-leaf   { width: 290px; flex-shrink: 0; position: relative; }
.tree-leaf::before {
  content: ''; position: absolute; top: -20px; left: 50%; transform: translateX(-50%);
  width: 2px; height: 20px; background: var(--tree-line);
}
.tree-leaf:first-child::after {
  content: ''; position: absolute; top: -20px; left: 50%; right: -8px;
  height: 2px; background: var(--tree-line);
}
.tree-leaf:not(:first-child):not(:last-child)::after {
  content: ''; position: absolute; top: -20px; left: -8px; right: -8px;
  height: 2px; background: var(--tree-line);
}
.tree-leaf:last-child::after {
  content: ''; position: absolute; top: -20px; left: -8px; right: 50%;
  height: 2px; background: var(--tree-line);
}
.tree-leaf:only-child::after { display: none; }
.op-badge-drop {
  padding: 4px 12px; border-radius: 4px; font-size: 13px; font-weight: 700;
  color: var(--text-primary); cursor: copy; min-width: 44px; text-align: center;
}
.op-badge-drop.drag-over { background: #fde68a; outline: 2px dashed #d97706; }
.op-badge-empty { border: 2px dashed var(--border); color: var(--text-tertiary); font-weight: 400; font-size: 11px; letter-spacing: .04em; }
.node-x      { border: none; background: transparent; cursor: pointer; color: var(--text-tertiary); font-size: 14px; }
.leaf-node   { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; }
.ln-type-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.ln-type     { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-tertiary); }
.leaf-row    { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.leaf-var-select {
  flex: 1; padding: 7px 24px 7px 8px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 10.5px; font-family: var(--font-mono); background: var(--violet-light);
  color: var(--text-primary); outline: none; cursor: pointer; min-width: 0; width: 60%;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}
.leaf-var-select:focus { border-color: var(--blue); }
.op-chip-drop {
  padding: 7px; background: var(--pink-light); color: #374151; border: 1px solid var(--pink-light-border);
  border-radius: 4px; font-weight: 700; font-size: 11.5px; cursor: default;
  min-width: 24px; width: 15%; text-align: center;
}
.op-chip-drop.drag-over  { filter: brightness(.85); border: var(--pink-light); }
.act-target-drop {
  flex: 1; padding: 4px 8px; border: 1px dashed var(--border); border-radius: 4px;
  font-size: 11.5px; font-family: var(--font-mono); color: var(--blue);
  background: var(--blue-light); cursor: default; min-width: 80px; max-width: 30%;
}
.act-target-drop.drag-over { border-color: var(--blue); background: #dbeafe; }
.leaf-val    { width: 25%; padding: 7px 6px; border: 1px solid var(--green-light-border); border-radius: 4px; font-size: 12px; font-weight: 600; color: #166534; background: var(--green-light); outline: none; text-align: center; }
.leaf-val::-webkit-outer-spin-button,
.leaf-val::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.leaf-val { -moz-appearance: textfield; appearance: textfield; }
.leaf-val2   { width: 25%; padding: 7px 6px; border: 1px solid var(--green-light-border); border-radius: 4px; font-size: 12px; font-weight: 600; color: #166534; background: var(--green-light); outline: none; text-align: center; }
.leaf-val2::-webkit-outer-spin-button,
.leaf-val2::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.leaf-val2 { -moz-appearance: textfield; appearance: textfield; }
.leaf-between-sep { font-size: 11px; color: var(--text-tertiary); flex-shrink: 0; }
.leaf-in-vals { flex: 1; padding: 7px 6px; border: 1px solid var(--green-light-border); border-radius: 4px; font-size: 11.5px; color: #166534; background: var(--green-light); outline: none; }
.leaf-desc   { font-size: 10.5px; color: var(--text-tertiary); font-style: italic; }
.tree-ctx-menu { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,.12); padding: 4px 0; min-width: 150px; }
.ctx-item { padding: 7px 14px; font-size: 12.5px; cursor: pointer; color: var(--text-primary); }
.ctx-item:hover { background: var(--bg); }
.add-cond-btn {
  display: block; margin: 0 auto; padding: 5px 16px; border: 1px dashed #c5cbd6;
  border-radius: var(--radius); background: transparent; font-size: 11.5px; color: var(--text-tertiary);
  cursor: pointer; font-family: var(--font);
}
.add-cond-btn:hover { border-color: var(--blue); color: var(--blue); }
.action-item { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--green); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 6px; }
.act-header  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.act-header-right { width: 60%; display: flex; justify-content: end; }
.act-row     { display: flex; align-items: center; gap: 8px; }
.act-label   { font-size: 11.5px; color: var(--text-tertiary); }
.act-type-select  { padding: 3px 6px; margin-right: 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 11.5px; font-family: var(--font-mono); color: var(--text-secondary); background: var(--surface); outline: none; flex: 1; max-width: 50%; }
.act-target  { padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 11.5px; font-family: var(--font-mono); color: var(--blue); background: var(--blue-light); outline: none; }
.act-val     { width: 52px; padding: 4px 6px; border: 1px solid var(--green-light-border); border-radius: 4px; font-size: 12px; font-weight: 600; color: #166534; background: var(--green-light); outline: none; text-align: center; -moz-appearance: textfield; appearance: textfield; }
.act-val::-webkit-outer-spin-button, .act-val::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.add-act-btn { width: 100%; padding: 7px; border: 1px dashed var(--border); border-radius: var(--radius); background: transparent; font-size: 11px; color: var(--text-tertiary); cursor: pointer; text-align: center; font-family: var(--font); }
.add-act-btn:hover { border-color: var(--blue); color: var(--blue); }
.trigger-meta { display: flex; gap: 16px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border-light); align-items: flex-end; }
.meta-field   { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.meta-field label { font-size: 11px; color: var(--text-tertiary); font-weight: 500; white-space: nowrap; }
.meta-input-wrap  { display: flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; overflow: hidden; }
.meta-input-wrap .meta-input { border: none; border-radius: 0; background: transparent; padding: 5px 6px; width: 0; flex: 1; }
.meta-input  { width: 100%; padding: 5px 7px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 12px; outline: none; font-family: var(--font); background: #fff; -moz-appearance: textfield; appearance: textfield; box-sizing: border-box; }
.meta-input::-webkit-outer-spin-button, .meta-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.meta-unit   { padding: 5px 7px 5px 2px; font-size: 11px; color: var(--text-tertiary); background: transparent; user-select: none; }
.meta-select { width: 100%; padding: 5px 26px 5px 8px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 12px; outline: none; font-family: var(--font); background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center; -webkit-appearance: none; appearance: none; cursor: pointer; box-sizing: border-box; }
.plain-language { margin-top: 12px; padding: 10px 12px; background: var(--violet-lighter); border: 1px solid var(--violet-lighter-border); border-radius: var(--radius); }
.pl-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--violet-dark); display: block; margin-bottom: 3px; }
.pl-text  { font-size: 10px; color: var(--violet); font-style: italic; }
.json-col    { width: 280px; flex-shrink: 0; border-left: 1px solid var(--border); padding: 14px; background: #fafbfc; overflow-y: auto; }
.json-label  { font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.json-sub    { font-size: 11px; color: var(--text-tertiary); margin-bottom: 10px; }
.json-code-wrap { position: relative; }
.json-copy-btn {
  position: absolute; top: 6px; right: 6px;
  border: none; background: rgba(255,255,255,.08); cursor: pointer;
  color: #a8d8ea; padding: 4px; border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.json-copy-btn:hover { background: rgba(255,255,255,.18); color: #fff; }
.json-code   {
  background: #1e2233; border-radius: var(--radius); padding: 12px;
  font-family: var(--font-mono); font-size: 10.5px; line-height: 1.6;
  overflow-x: auto; white-space: pre; margin-bottom: 12px; color: #a8d8ea;
}
.json-key    { color: #7cb8f5; }
.json-string { color: #ffdf2a; }
.json-number { color: #86e1a0; }
.json-bool   { color: #f87070; }
.json-null   { color: #f87070; }
.design-principle { background: var(--amber-light); border: 1px solid var(--amber-border); border-radius: var(--radius); padding: 10px 12px; }
.dp-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--amber-medium); margin-bottom: 5px; }
.dp-text  { font-size: 11px; color: var(--amber); line-height: 1.6; }

/* ── PreviewModal ── */
.preview-overlay { align-items: stretch; padding: 0; }
.preview-modal {
  width: 100%; height: 100%; display: flex; flex-direction: column; background: #0d0d0d;
}
.preview-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; background: #1a1a2e; border-bottom: 1px solid #333; flex-shrink: 0;
}
.preview-title { font-size: 13px; font-weight: 600; color: #ccc; }
.preview-header-actions { display: flex; gap: 8px; align-items: center; }
.preview-frame { flex: 1; border: none; background: #111; }

/* ── Add-variable popup ── */
.add-var-overlay { z-index: 1100; }
.add-var-popup {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(420px, 92vw);
  display: flex; flex-direction: column;
}
.avp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.avp-header h3 { font-size: 14px; font-weight: 700; }
.avp-body   { padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.avp-hint   { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }
.avp-error  {
  display: none; padding: 8px 10px; background: #fdecea; color: #c0392b;
  border: 1px solid #f4c5c0; border-radius: var(--radius); font-size: 12px;
}
.avp-error:not(:empty) { display: block; }
.avp-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--border);
}

/* ── ExportModal ── */
.export-modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 640px; max-width: 92vw; max-height: 84vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.em-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.em-header h2 { font-size: 15px; font-weight: 700; }
.em-header-title { display: flex; align-items: center; gap: 8px; }
.em-icon-btn {
  border: none; background: transparent; cursor: pointer;
  color: var(--text-tertiary); padding: 4px; border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.em-icon-btn:hover { background: var(--bg); color: var(--text-primary); }
.em-close { border: none; background: transparent; font-size: 20px; cursor: pointer; color: var(--text-tertiary); line-height: 1; }
.em-json {
  flex: 1; overflow-y: auto; margin: 0;
  background: #1e2233; font-family: var(--font-mono); font-size: 11.5px;
  line-height: 1.6; padding: 16px 20px; white-space: pre; color: #a8d8ea;
}
.em-footer {
  padding: 12px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ── Login ── */
.login-page {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 48px 52px; width: 480px;
  display: flex; flex-direction: column; gap: 22px;
}
.login-brand {
  display: flex; align-items: center; gap: 14px; margin-bottom: 14px;
}
.login-brand .logo-mark {
  width: 48px; height: 48px; font-size: 24px;
}
.login-brand .logo-name { font-size: 20px; font-weight: 700; }
.login-brand .logo-sub  { font-size: 13px; color: var(--text-secondary); }
.login-card .field-group label { font-size: 14px; }
.login-card .input { font-size: 15px; padding: 12px 14px; }
.login-error {
  font-size: 13px; color: #d32f2f; background: #fff0f0;
  border: 1px solid #fccaca; border-radius: var(--radius);
  padding: 10px 12px;
}
.login-submit { width: 100%; justify-content: center; font-size: 15px; padding: 12px 16px; display: inline-flex; align-items: center; gap: 8px; }

.btn-spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin .7s linear infinite;
  vertical-align: -1px;
  flex-shrink: 0;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

button.is-busy {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: progress; opacity: .85;
}
button.is-busy .btn-spinner { color: currentColor; }

/* ── App loader (blue circular spinner) ── */
.app-loader {
  flex: 1; display: flex; align-items: center; justify-content: center;
  min-height: 240px; width: 100%;
  grid-column: 1 / -1;
}
.app-loader::after {
  content: '';
  width: 32px; height: 32px;
  border: 3px solid var(--blue);
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin .7s linear infinite;
}

/* ── Loading state ── */
.loading-state {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--text-tertiary); font-size: 13px;
}
.loading-state::before,
.hm-loading::before {
  content: '';
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin .7s linear infinite;
  flex-shrink: 0;
}
.hm-loading { display: inline-flex; align-items: center; gap: 8px; justify-content: center; width: 100%; }

.loading-inline {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 10px; color: var(--text-tertiary); font-size: 12px;
}
.loading-inline--center {
  display: flex; justify-content: center; align-items: center;
  width: 100%; min-height: 56px; padding: 16px; gap: 0;
}
.loading-inline::before {
  content: '';
  display: inline-block;
  width: 10px; height: 10px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin .7s linear infinite;
  flex-shrink: 0;
}

/* ── History modal ── */
.history-modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 640px; max-width: 92vw; max-height: 80vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.history-modal-wide {
  width: 1080px; max-width: 95vw; max-height: 90vh;
}
.hm-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.hm-header h2 { font-size: 15px; font-weight: 700; }
.hm-body { flex: 1; overflow-y: auto; padding: 8px 0; }
.hm-loading, .hm-empty, .hm-error {
  padding: 24px 20px; font-size: 13px; color: var(--text-secondary); text-align: center;
}
.hm-error { color: #d32f2f; }
.hm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.hm-table th {
  text-align: left; padding: 6px 16px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-tertiary);
  border-bottom: 1px solid var(--border);
}
.hm-table td { padding: 8px 16px; border-bottom: 1px solid var(--border-light, var(--border)); }
.hm-table tr:last-child td { border-bottom: none; }
.hm-current td { background: var(--bg); }
.hm-ver { font-family: var(--font-mono); font-size: 12px; font-weight: 600; vertical-align: middle; }
.hm-badge {
  display: inline-flex; align-items: center; height: 16px;
  font-size: 9px; font-weight: 600; padding: 0 6px;
  background: var(--blue); color: #fff; border-radius: 8px;
  text-transform: uppercase; letter-spacing: .04em;
  margin-left: 6px; vertical-align: middle;
}
.hm-th-pick, .hm-td-pick { text-align: center; width: 36px; }
.hm-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; cursor: pointer; position: relative;
}
.hm-dot input { position: absolute; opacity: 0; pointer-events: none; }
.hm-dot-mark {
  width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--text-tertiary); background: transparent;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.hm-dot:hover .hm-dot-mark { border-color: var(--blue); }
.hm-dot:has(input:checked) .hm-dot-mark {
  border-color: var(--blue);
  background: radial-gradient(circle, var(--blue) 0 45%, #fff 50% 100%);
}
.hm-dot:focus-within .hm-dot-mark { box-shadow: 0 0 0 2px rgba(59,130,246,.35); }
.hm-dot.is-disabled { cursor: not-allowed; }
.hm-dot.is-disabled .hm-dot-mark {
  border-color: var(--border); background: var(--bg);
}
.btn-sm { padding: 3px 10px; font-size: 12px; }

/* ── History diff ── */
.hm-compare-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; border-top: 1px solid var(--border); background: var(--bg);
}
.hm-compare-label { font-size: 12px; color: var(--text-secondary); }
.hm-diff { padding: 12px 16px; border-top: 1px solid var(--border); background: #fafbfd; }
.hm-diff-title   { font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.hm-diff-section { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-tertiary); margin: 10px 0 4px; }
.hm-diff-table   { width: 100%; border-collapse: collapse; font-size: 12px; }
.hm-diff-table th, .hm-diff-table td { padding: 4px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.diff-a { background: #fdecea; font-family: var(--font-mono); font-size: 11px; }
.diff-b { background: #e8f5e9; font-family: var(--font-mono); font-size: 11px; }
.diff-blocks { margin: 0; padding-left: 18px; font-size: 12px; }
.diff-blocks li { margin: 2px 0; }
.hm-diff-trials { font-size: 12px; color: var(--text-secondary); }

/* ── History compare diagram (side-by-side) ── */
.cmp-diagram { display: flex; flex-direction: column; gap: 8px; }
.cmp-headers {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-secondary);
}
.cmp-header-cell {
  padding: 4px 8px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.cmp-legend { display: flex; gap: 6px; flex-wrap: wrap; font-size: 10px; }
.cmp-chip {
  padding: 1px 8px; border-radius: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; font-size: 10px;
  border: 1px solid transparent;
}
.cmp-chip.diff-added     { background: #e8f5e9; color: #1b5e20; border-color: #a5d6a7; }
.cmp-chip.diff-removed   { background: #fdecea; color: #8a1c13; border-color: #f1a9a0; }
.cmp-chip.diff-modified  { background: #fff4e0; color: #7a4a02; border-color: #f3c879; }
.cmp-chip.diff-unchanged { background: #eef1f6; color: #5a6478; border-color: #d5dbe5; }

.cmp-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  align-items: stretch;
}
.cmp-block {
  background: #fff; border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius); padding: 8px 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.cmp-block.diff-added     { border-left-color: #2e7d32; background: #f3faf4; }
.cmp-block.diff-removed   { border-left-color: #c62828; background: #fdf3f2; }
.cmp-block.diff-modified  { border-left-color: #ed8b00; background: #fffaf0; }
.cmp-block.diff-unchanged { opacity: .72; }
.cmp-block-empty {
  background: transparent; border: 1px dashed var(--border);
  border-left-color: var(--border);
}
.cmp-block-hdr {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; font-size: 12px;
}
.cmp-block-name { font-weight: 600; color: var(--text-primary); }
.cmp-block-status {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; padding: 1px 6px; border-radius: 10px;
}
.cmp-block-status.diff-added    { background: #2e7d32; color: #fff; }
.cmp-block-status.diff-removed  { background: #c62828; color: #fff; }
.cmp-block-status.diff-modified { background: #ed8b00; color: #fff; }

.cmp-sections { display: flex; flex-direction: column; gap: 3px; }
.cmp-sec {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 6px; font-size: 11px;
  border-radius: 3px; border: 1px solid transparent;
}
.cmp-sec-tag {
  display: inline-block; min-width: 64px; text-align: center;
  padding: 1px 6px; color: #fff; font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; border-radius: 3px;
}
.cmp-sec-name { color: var(--text-primary); font-weight: 500; }
.cmp-sec.diff-added     { background: #e8f5e9; border-color: #a5d6a7; }
.cmp-sec.diff-removed   { background: #fdecea; border-color: #f1a9a0; }
.cmp-sec.diff-modified  { background: #fff4e0; border-color: #f3c879; }
.cmp-sec.diff-unchanged { opacity: .65; }
.cmp-sec-ghost { opacity: .55; border-style: dashed; }
.cmp-empty, .cmp-empty-sec {
  padding: 8px; text-align: center; color: var(--text-tertiary);
  font-size: 11px; font-style: italic;
}

/* ── Users page ── */
.users-page { flex: 1; display: flex; flex-direction: column; padding: 24px 32px; overflow-y: auto; gap: 20px; }
.uv-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.uv-table th { text-align: left; padding: 10px 16px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-tertiary); background: var(--bg); border-bottom: 1px solid var(--border); }
.uv-table td { padding: 12px 16px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.uv-table tbody tr { transition: background 0.12s; }
.uv-table tbody tr:hover { background: var(--bg); }
.uv-table tbody tr:last-child td { border-bottom: none; }
.uv-table .uv-email { font-weight: 500; color: var(--text-primary); }
.uv-table .uv-name { color: var(--text-secondary); }
.uv-table .uv-last-login { color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.uv-role { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; text-transform: capitalize; letter-spacing: .02em; border: 1px solid transparent; }
.uv-role-admin      { background: #fce8e8; color: #c0392b; border-color: #f5cdc7; }
.uv-role-researcher { background: var(--blue-light); color: #1a56db; border-color: #cfdcfb; }
.uv-role-read_only  { background: #f1f3f7; color: var(--text-secondary); border-color: var(--border); }
.uv-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; }
.uv-status::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; }
.uv-active   { color: var(--green); }
.uv-active::before { background: var(--green); box-shadow: 0 0 0 2px var(--green-light); }
.uv-inactive { color: var(--text-tertiary); }
.uv-inactive::before { background: var(--text-tertiary); box-shadow: 0 0 0 2px var(--border-light); }
.uv-actions { display: flex; gap: 6px; align-items: center; }

/* ── Import modal ── */
.import-modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 480px; max-width: 92vw; display: flex; flex-direction: column; overflow: hidden;
}
.im-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.im-drop {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 32px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  cursor: pointer; transition: border-color .15s, background .15s; color: var(--text-secondary);
}
.im-drop:hover, .im-drop--over { border-color: var(--blue); background: #f0f4ff; }
.im-drop--has-file { border-color: var(--blue); background: #f0f4ff; color: var(--blue); font-weight: 500; }
.im-drop-label { font-size: 13px; text-align: center; }
.im-errors {
  font-size: 12px; background: #fff0f0; border: 1px solid #fccaca;
  border-radius: var(--radius); padding: 10px 12px; color: #c0392b;
}
.im-errors ul { margin: 6px 0 0; padding-left: 16px; }
.im-errors li { margin-bottom: 2px; }

/* ── Locale form modal ── */
.locale-form-modal { width: 520px; max-width: 92vw; }
.lf-body { gap: 0; padding: 4px 0 16px; }
.lf-section { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.lf-section + .lf-section { border-top: 1px solid var(--border-light, var(--border)); }
.lf-section-title {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-tertiary);
}
.lf-field { display: flex; flex-direction: column; gap: 4px; }
.lf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.lf-mono { font-family: var(--font-mono); font-size: 12px; }
.lf-textarea { resize: vertical; min-height: 60px; font-family: var(--font); line-height: 1.5; }
.lf-help { font-size: 11px; color: var(--text-tertiary); margin-top: 1px; }
.lf-req { color: var(--red); margin-left: 2px; }
.lf-error {
  margin: 0 20px; font-size: 12px; background: #fff0f0;
  border: 1px solid #fccaca; border-radius: var(--radius);
  padding: 8px 10px; color: #c0392b;
}

/* ── Create sequence modal ── */
.create-sequence-modal { width: 520px; max-width: 92vw; }

/* ── User form modal ── */
.user-form-modal { width: 520px; max-width: 92vw; }
.uf-role-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
}
.uf-role-card {
  position: relative; display: flex; align-items: center; justify-content: center;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; transition: border-color .12s, background .12s, box-shadow .12s;
}
.uf-role-card:hover { border-color: var(--text-tertiary); }
.uf-role-card.is-selected {
  border-color: var(--blue); background: var(--blue-light);
  box-shadow: 0 0 0 1px var(--blue) inset;
}
.uf-role-card input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.uf-role-card-title { font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.uf-role-card.is-selected .uf-role-card-title { color: var(--blue); }

.uf-status-toggle { display: inline-flex; gap: 8px; }
.uf-status-pill {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border: 1px solid var(--border); border-radius: 20px;
  background: var(--surface); cursor: pointer; font-size: 12px; font-weight: 500;
  color: var(--text-secondary); transition: border-color .12s, background .12s, color .12s;
}
.uf-status-pill input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.uf-status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-tertiary); }
.uf-status-pill:hover { border-color: var(--text-tertiary); }
.uf-status-pill.is-selected.uf-status-active {
  border-color: var(--green); background: var(--green-light); color: var(--green);
}
.uf-status-pill.is-selected.uf-status-active .uf-status-dot { background: var(--green); }
.uf-status-pill.is-selected.uf-status-inactive {
  border-color: var(--text-secondary); background: var(--bg); color: var(--text-secondary);
}

/* ── Reset password modal ── */
.reset-pw-modal { width: 460px; max-width: 92vw; }
.rpm-user-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 20px;
  background: var(--bg); font-size: 12.5px; color: var(--text-primary);
  align-self: flex-start; max-width: 100%;
}
.rpm-user-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); flex-shrink: 0; }
.rpm-user-email {
  font-family: var(--font-mono); font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rpm-show {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-secondary); cursor: pointer;
  user-select: none; align-self: flex-start;
}
.rpm-show input[type=checkbox] { margin: 0; cursor: pointer; }

/* ── Locale coverage report ── */
.coverage-section { margin-top: 28px; }
.coverage-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 12px;
}
.coverage-title { font-size: 14px; font-weight: 700; margin: 0 0 4px; }
.coverage-subtitle { font-size: 12px; color: var(--text-tertiary); max-width: 540px; line-height: 1.5; }
.coverage-subtitle code {
  font-family: var(--font-mono); font-size: 11px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 3px; padding: 1px 4px;
}
.coverage-summary { display: flex; gap: 6px; flex-wrap: wrap; }
.coverage-chip {
  font-size: 11px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid transparent;
}
.coverage-chip--complete { background: var(--green-light); color: #166534; border-color: var(--green-light-border); }
.coverage-chip--partial  { background: var(--amber-light); color: #92400e; border-color: var(--amber-light-border); }
.coverage-chip--sparse   { background: #fde2e2; color: #991b1b; border-color: #f9b4b4; }

.coverage-list {
  display: flex; flex-direction: column; gap: 6px;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); padding: 6px; overflow: hidden;
}
.coverage-row {
  display: grid;
  grid-template-columns: 8px minmax(180px, 1fr) minmax(220px, 2fr) auto;
  align-items: center; gap: 14px;
  padding: 10px 14px; border-radius: var(--radius);
  transition: background .12s;
}
.coverage-row:hover { background: var(--bg); }

.coverage-status {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block;
}
.coverage-row--complete .coverage-status { background: var(--green); box-shadow: 0 0 0 3px rgba(22,163,74,0.12); }
.coverage-row--partial  .coverage-status { background: var(--orange-gold); box-shadow: 0 0 0 3px rgba(245,155,10,0.14); }
.coverage-row--sparse   .coverage-status { background: var(--red); box-shadow: 0 0 0 3px rgba(220,38,38,0.14); }

.coverage-locale { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.coverage-locale-code code {
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  color: var(--text-primary);
}
.coverage-locale-name { font-size: 11.5px; color: var(--text-tertiary); }

.coverage-progress { display: flex; align-items: center; gap: 10px; min-width: 0; }
.coverage-bar {
  flex: 1; min-width: 80px; max-width: 280px;
  height: 8px; border-radius: 999px;
  background: #eef1f6; overflow: hidden;
}
.coverage-bar-fill { height: 100%; border-radius: 999px; transition: width .25s ease; }
.coverage-row--complete .coverage-bar-fill { background: linear-gradient(90deg, #16a34a, #22c55e); }
.coverage-row--partial  .coverage-bar-fill { background: linear-gradient(90deg, #f59b0a, #fbbf24); }
.coverage-row--sparse   .coverage-bar-fill { background: linear-gradient(90deg, #dc2626, #ef4444); }
.coverage-pct {
  font-size: 12px; font-weight: 700; min-width: 38px; text-align: right;
  font-variant-numeric: tabular-nums;
}
.coverage-row--complete .coverage-pct { color: #166534; }
.coverage-row--partial  .coverage-pct { color: #92400e; }
.coverage-row--sparse   .coverage-pct { color: #991b1b; }

.coverage-counts { display: flex; gap: 6px; }
.coverage-count {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 8px; border-radius: var(--radius);
  background: var(--green-light); color: #166534;
  font-variant-numeric: tabular-nums;
}
.coverage-count svg { stroke-width: 2.2; }
.coverage-count--missing { background: #fde2e2; color: #991b1b; }
.coverage-count--missing.is-zero { background: var(--bg); color: var(--text-tertiary); }

.coverage-spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: coverage-spin .7s linear infinite;
  vertical-align: -2px;
}
@keyframes coverage-spin { to { transform: rotate(360deg); } }
.btn-outline-info[disabled] { opacity: .7; cursor: progress; }

.coverage-missing { display: inline; }
.coverage-missing > summary {
  cursor: pointer; list-style: none; user-select: none;
  transition: background .12s;
}
.coverage-missing > summary::-webkit-details-marker { display: none; }
.coverage-missing > summary:hover { background: #fbd0d0; }
.coverage-missing[open] > summary { background: #f5b8b8; }

.coverage-missing-list {
  grid-column: 1 / -1;
  display: none;
  margin: 4px 0 2px 22px;
  padding: 10px 12px;
  list-style: none;
  background: var(--bg);
  border: 1px dashed #f3b6b6;
  border-radius: var(--radius);
  flex-direction: column;
  gap: 8px;
}
.coverage-row:has(.coverage-missing[open]) .coverage-missing-list { display: flex; }

.missing-ref-entry { display: flex; flex-direction: column; gap: 4px; }
.missing-ref {
  display: inline-block; align-self: flex-start;
  font-size: 11.5px; font-family: ui-monospace, monospace;
  color: #991b1b; background: #fde2e2;
  padding: 2px 7px; border-radius: 4px;
}
.missing-locations {
  list-style: none;
  margin: 0; padding: 0 0 0 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.missing-locations li {
  font-size: 11.5px; color: var(--text-secondary);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.missing-locations .ml-seq { font-weight: 600; color: var(--text-primary); }
.missing-locations .ml-arrow { color: var(--text-tertiary); font-weight: 700; }
.missing-locations .ml-block { color: var(--text-secondary); }
.missing-locations .ml-section { color: var(--text-secondary); font-style: italic; }
.coverage-missing-list li {
  font-size: 11.5px; font-family: ui-monospace, monospace;
  color: #991b1b;
  background: #fde2e2;
  padding: 2px 7px; border-radius: 4px;
}
.coverage-missing-list li code {
  font: inherit; color: inherit; background: transparent; padding: 0;
}

/* ── Media library ── */
.media-page { flex: 1; display: flex; flex-direction: column; padding: 24px 32px; overflow-y: auto; gap: 16px; }
.media-search { height: 32px; }
.ml-audio { width: 100%; height: 36px; }
#ml-audio-bar { margin: 0 -4px; }
.media-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.media-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.mf-top { display: flex; align-items: center; gap: 10px; }
.mf-play { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg); cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--text-secondary); }
.mf-play:hover, .mf-play--active { border-color: var(--blue); color: var(--blue); background: #f0f4ff; }
.mf-play svg { width: 14px; height: 14px; }
.mf-info { flex: 1; min-width: 0; }
.mf-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mf-meta { display: flex; gap: 8px; font-size: 11px; color: var(--text-tertiary); margin-top: 2px; flex-wrap: wrap; }
.mf-format { background: var(--bg); border: 1px solid var(--border); border-radius: 3px; padding: 0 4px; font-weight: 600; font-size: 10px; }
.mf-actions { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.mf-tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.mf-tag { font-size: 11px; background: var(--bg); border: 1px solid var(--border); border-radius: 20px; padding: 1px 8px; }
.mf-tag-empty { font-size: 11px; color: var(--text-tertiary); }
.mf-tag-editor { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding-top: 2px; }
.mf-tag-check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; line-height: 1;
  padding: 4px 10px 4px 7px;
  border: 1px solid var(--border); border-radius: 20px;
  background: var(--bg); color: var(--text-secondary);
  cursor: pointer; user-select: none;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.mf-tag-check input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.mf-tag-check::before {
  content: ""; flex-shrink: 0;
  width: 12px; height: 12px;
  border: 1.5px solid #c4c7ce; border-radius: 3px;
  background: var(--surface);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.mf-tag-check:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }
.mf-tag-check:hover::before { border-color: var(--blue); }
.mf-tag-check:has(input:checked) {
  background: var(--blue); border-color: var(--blue); color: #fff;
}
.mf-tag-check:has(input:checked)::before {
  border-color: #fff;
  background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='none' stroke='%23235feb' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round' d='M3 8.5l3 3 7-7'/></svg>") center/9px no-repeat;
}
.mf-tag-check:focus-within { box-shadow: 0 0 0 2px var(--blue-light); }

/* ── Property breadcrumb ── */
.prop-breadcrumb { display: flex; align-items: center; gap: 4px; padding: 4px 12px 8px; font-size: 11px; }
.prop-bc-seq { background: none; border: none; padding: 0; color: var(--blue); cursor: pointer; font-size: 11px; }
.prop-bc-seq:hover { text-decoration: underline; }
.prop-bc-sep { color: var(--text-tertiary); }
.prop-bc-node { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }

/* ── Trigger Library modal ── */
.tlm-modal { width: 920px; max-width: 92vw; }
.tlm-header-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 20px; padding: 0 7px; margin-left: 6px;
  background: var(--amber-light); color: var(--amber-medium);
  border: 1px solid var(--amber-border); border-radius: 10px;
  font-size: 11px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
}
.tlm-body { max-height: 62vh; overflow: auto; }
.tlm-footer { justify-content: space-between; }

/* Table */
.tlm-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tlm-table thead th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; padding: 10px 14px;
  background: var(--bg); border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 11px; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: .06em;
}
.tlm-th-actions { width: 80px; }
.tlm-th-scope   { width: 130px; }
.tlm-th-limits  { width: 130px; }
.tlm-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background .1s;
}
.tlm-table tbody tr:hover { background: var(--bg); }
.tlm-table tbody tr:last-child { border-bottom: none; }
.tlm-table td { padding: 12px 14px; vertical-align: middle; }

/* Scope chip */
.tlm-scope {
  display: inline-flex; align-items: center; max-width: 100%;
  padding: 3px 9px; border-radius: 10px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .05em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tlm-scope--global { background: var(--violet-light); color: var(--violet-dark); border: 1px solid var(--violet-light-border); }
.tlm-scope--local  { background: var(--amber-light); color: var(--amber-medium); border: 1px solid var(--amber-border); letter-spacing: 0; text-transform: none; font-weight: 600; }

/* When (condition) */
.tlm-when-text  { font-family: var(--font-mono); font-size: 12px; color: var(--text-primary); word-break: break-word; }
.tlm-when-empty { color: var(--text-tertiary); font-style: italic; font-size: 12px; }

/* Then (actions) */
.tlm-c-then { display: flex; flex-wrap: wrap; gap: 4px; align-content: center; }
.tlm-act {
  display: inline-flex; align-items: stretch;
  border: 1px solid var(--border); border-radius: 6px; overflow: hidden;
  background: var(--surface); font-size: 11px; line-height: 1.5;
}
.tlm-act-verb {
  padding: 2px 7px; background: var(--blue-light); color: var(--blue);
  font-weight: 600; letter-spacing: .02em;
}
.tlm-act-body {
  padding: 2px 7px; color: var(--text-primary);
  font-family: var(--font-mono); border-left: 1px solid var(--border);
}

/* Limits — compact key/value pairs */
.tlm-limits { display: flex; flex-direction: column; gap: 2px; }
.tlm-lim {
  display: inline-flex; align-items: baseline; gap: 6px;
  font-size: 11px; line-height: 1.4;
}
.tlm-lim-k { color: var(--text-tertiary); text-transform: uppercase; font-size: 9.5px; letter-spacing: .05em; min-width: 24px; }
.tlm-lim-v { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
.tlm-lim-u { color: var(--text-tertiary); font-weight: 500; font-size: 10px; margin-left: 1px; }

/* Row actions */
.tlm-c-actions { white-space: nowrap; text-align: right; }
.tlm-c-actions .icon-btn { width: 26px; height: 26px; }
.tlm-c-actions .icon-btn + .icon-btn { margin-left: 4px; }

/* Empty state */
.tlm-empty {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; padding: 48px 24px; text-align: center;
}
.tlm-empty-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--amber-light); color: var(--amber-medium);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--amber-border);
}
.tlm-empty-title { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-top: 4px; }
.tlm-empty-sub   { font-size: 12px; color: var(--text-secondary); max-width: 420px; line-height: 1.5; }
.tlm-empty-cta   { margin-top: 10px; }
