:root {
  --bg: #e8eef5;
  --card: #ffffff;
  --card-soft: #f1f5f9;
  --text: #0f172a;
  --muted: #475569;
  --border: #94a3b8;
  --border-soft: #cbd5e1;
  --card-shadow: 0 3px 10px rgba(15,23,42,.08);
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-soft: #ccfbf1;
  --accent: #0369a1;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --draft-bg: #fef9c3;
  --draft-border: #eab308;
  --radius: 14px;
}

body[data-contrast="soft"] {
  --bg: #f1f5f9;
  --card-soft: #f8fafc;
  --border: #e2e8f0;
  --border-soft: #e2e8f0;
  --muted: #64748b;
  --card-shadow: 0 2px 6px rgba(15,23,42,.04);
}

body[data-contrast="high"] {
  --bg: #dce5f0;
  --card: #ffffff;
  --card-soft: #e2e8f0;
  --border: #475569;
  --border-soft: #64748b;
  --muted: #334155;
  --card-shadow: 0 4px 14px rgba(15,23,42,.14);
}

body.theme-dark {
  --bg: #0b1120;
  --card: #111827;
  --card-soft: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --border: #475569;
  --border-soft: #334155;
  --primary: #14b8a6;
  --primary-dark: #0d9488;
  --primary-soft: #134e4a;
  --draft-bg: #422006;
  --draft-border: #ca8a04;
}

body.theme-dark[data-contrast="high"] {
  --bg: #030712;
  --border: #64748b;
  --border-soft: #475569;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-family: "Rubik", system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); padding-bottom: 120px; }
.hidden { display: none !important; }

/* Header - responsive cleanly even at 300px */
.top-nav {
  position: sticky; top: 0; z-index: 40;
  background: linear-gradient(135deg, #0f172a, #1e293b); color: #fff;
  padding: 8px 12px; display: flex; align-items: center; justify-content: space-between;
  gap: 6px; flex-wrap: wrap; box-shadow: 0 4px 16px rgba(15,23,42,.2);
}
.top-nav-brand { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.top-nav-actions { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.ver-tag { font-size: .7rem; opacity: .75; }
.sync-pill { font-size: .7rem; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.15); color: #fff; white-space: nowrap; }
.sync-pill.ok { background: rgba(34,197,94,.25); color: #bbf7d0; }
.sync-pill.syncing { background: rgba(250,204,21,.22); color: #fef08a; }
.sync-pill.err { background: rgba(239,68,68,.28); color: #fecaca; }
.icon-btn { border: 0; background: rgba(255,255,255,.14); color: #fff; border-radius: 9px; padding: 6px 9px; font-family: inherit; font-weight: 600; cursor: pointer; font-size: .8rem; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.icon-btn:hover { background: rgba(255,255,255,.22); }
.icon-btn.active { background: var(--primary); }

/* Update Banner */
.update-banner { background: linear-gradient(90deg, #1e3a8a, #0369a1); color: #fff; padding: 9px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: .84rem; }
.update-sub { opacity: .9; margin-right: 6px; font-size: .8rem; }
.btn-update-cta { background: #fde047; color: #0f172a; border: 0; border-radius: 9px; padding: 6px 12px; font-weight: 700; cursor: pointer; font-family: inherit; font-size: .8rem; }

/* Container & List Tabs */
.container { max-width: 1020px; margin: 0 auto; padding: 12px; }
.tabs-scroll-wrap { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; scrollbar-width: thin; align-items: center; }
.tab-btn {
  flex: 0 0 auto; border: 1.5px solid var(--border); background: var(--card); color: var(--muted);
  border-radius: 11px; padding: 8px 12px; font-family: inherit; font-weight: 700; font-size: .84rem;
  cursor: pointer; transition: .15s; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 4px 12px rgba(15,118,110,.25); }
.tab-badge { font-size: .72rem; padding: 1px 7px; border-radius: 999px; background: rgba(15,23,42,.12); color: inherit; }
.tab-btn.active .tab-badge { background: rgba(255,255,255,.25); color: #fff; }
.tab-add-btn { border: 1.5px dashed var(--primary); background: transparent; color: var(--primary); border-radius: 11px; padding: 7px 11px; font-family: inherit; font-weight: 700; font-size: .8rem; cursor: pointer; flex: 0 0 auto; }

.search-and-sort-row { display: flex; gap: 8px; margin-bottom: 9px; align-items: stretch; }
.search-box { position: relative; flex: 1; min-width: 0; }
.search-box input { width: 100%; padding: 10px 12px 10px 34px; border: 1.5px solid var(--border); border-radius: 11px; font-family: inherit; font-size: .9rem; background: var(--card); color: var(--text); outline: none; }
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.15); }
.search-clear { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); border: 0; background: var(--border); color: var(--text); border-radius: 999px; width: 22px; height: 22px; cursor: pointer; font-weight: 700; display: none; }
.sort-select { border: 1.5px solid var(--border); background: var(--card); color: var(--text); border-radius: 11px; padding: 8px 10px; font-family: inherit; font-size: .82rem; font-weight: 600; max-width: 165px; }

.chips-row { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips-row::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; border: 1px solid var(--border); background: var(--card); color: var(--text); padding: 5px 11px; border-radius: 999px; font-size: .8rem; font-weight: 600; cursor: pointer; font-family: inherit; }
.chip.active { background: #0f172a; color: #fff; border-color: #0f172a; }

.list-meta { font-size: .8rem; color: var(--muted); margin: 2px 2px 9px; display: flex; justify-content: space-between; }
.leads-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; }
@media(min-width: 720px) { .leads-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.lead-card { min-width: 0; overflow: hidden; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 13px; cursor: pointer; transition: .15s; box-shadow: 0 2px 6px rgba(15,23,42,.04); display: flex; flex-direction: column; gap: 5px; }
.lead-card:hover { border-color: #94a3b8; transform: translateY(-1px); }
.lead-card.overdue { border-right: 4px solid var(--danger); }
.lead-card.today { border-right: 4px solid var(--warn); }
.lead-card.done { border-right: 4px solid var(--ok); }
.lead-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.lead-name { font-weight: 700; font-size: .96rem; }
.lead-sub { font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lead-note-preview { font-size: .78rem; color: var(--muted); background: var(--card-soft); padding: 5px 8px; border-radius: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-quick-mini { display: flex; gap: 5px; margin-top: 2px; }
.card-mini-btn { border: 1px solid var(--border); background: var(--card-soft); color: var(--text); border-radius: 7px; padding: 3px 8px; font-size: .74rem; text-decoration: none; font-weight: 600; }

.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--border); color: var(--text); white-space: nowrap; }
.badge.status { background: #e0f2fe; color: #0369a1; }
.badge.overdue { background: var(--danger-soft); color: var(--danger); }
.badge.today { background: var(--warn-soft); color: #b45309; }
.badge.done { background: var(--ok-soft); color: var(--ok); }

/* Detail Card Sections + Visual Size (5 Levels) / Layout Editor */
.section-card { background: var(--card); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 11px 13px; margin-bottom: 10px; box-shadow: var(--card-shadow); transition: .15s; position: relative; }
.section-card.size-xs { padding: 5px 8px; margin-bottom: 5px; font-size: .78rem; }
.section-card.size-xs .section-title { margin-bottom: 4px; font-size: .78rem; }
.section-card.size-xs .opt-btn, .section-card.size-xs .preset-pill { padding: 3px 7px; font-size: .72rem; }
.section-card.size-xs .summary-micro-grid { grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 4px; }
.section-card.size-xs .summary-cube { padding: 3px 5px; min-height: 28px; }
.section-card.size-xs .summary-cube-label { font-size: .58rem; }
.section-card.size-xs .summary-cube-val { font-size: .68rem; }

.section-card.size-compact { padding: 8px 10px; margin-bottom: 7px; font-size: .85rem; }
.section-card.size-compact .opt-btn, .section-card.size-compact .preset-pill { padding: 5px 8px; font-size: .76rem; }
.section-card.size-compact .summary-cube { padding: 4px 6px; min-height: 34px; }

.section-card.size-normal { padding: 11px 13px; margin-bottom: 10px; }

.section-card.size-wide { padding: 15px 17px; margin-bottom: 12px; font-size: .96rem; }
.section-card.size-wide .section-title { font-size: 1rem; }
.section-card.size-wide .opt-btn, .section-card.size-wide .preset-pill { padding: 8px 13px; font-size: .88rem; }
.section-card.size-wide .summary-micro-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 7px; }
.section-card.size-wide .summary-cube { padding: 7px 9px; min-height: 46px; }
.section-card.size-wide .summary-cube-label { font-size: .72rem; }
.section-card.size-wide .summary-cube-val { font-size: .84rem; }

.section-card.size-xl { padding: 20px 22px; margin-bottom: 14px; border-width: 2px; font-size: 1.04rem; }
.section-card.size-xl .section-title { font-size: 1.08rem; }
.section-card.size-xl .opt-btn, .section-card.size-xl .preset-pill { padding: 10px 16px; font-size: .96rem; }
.section-card.size-xl .summary-micro-grid { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 9px; }
.section-card.size-xl .summary-cube { padding: 9px 11px; min-height: 54px; }
.section-card.size-xl .summary-cube-label { font-size: .78rem; }
.section-card.size-xl .summary-cube-val { font-size: .94rem; }

.sum-field-small { font-size: .72rem; opacity: .9; }
.sum-field-normal { font-size: .8rem; }
.sum-field-large { font-size: .92rem; font-weight: 700; color: var(--text); }
.lead-note-preview.multiline { white-space: pre-line; overflow: visible; text-overflow: unset; }
.section-card.layout-editing { border: 2px dashed var(--primary); }
.section-card.dragging { opacity: .45; }
.section-card.hidden-section { opacity: .45; border-style: dotted; }

.inline-edit-trigger {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--card-soft); color: var(--text);
  border-radius: 7px; padding: 2px 7px; font-size: .72rem; font-weight: 700;
  cursor: pointer; font-family: inherit; transition: .12s; flex-shrink: 0;
}
.inline-edit-trigger:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

.section-title { font-weight: 700; font-size: .9rem; margin: 0 0 8px; display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; }
.title-with-info { display: inline-flex; align-items: center; gap: 5px; }
.info-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card-soft); color: var(--accent); font-size: .7rem; font-weight: 700;
  cursor: pointer; padding: 0; flex-shrink: 0; line-height: 1;
}
.info-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.info-popover {
  position: fixed; z-index: 200; max-width: 360px; min-width: 260px; background: #0f172a; color: #f8fafc;
  padding: 11px 14px; border-radius: 12px; font-size: .8rem; line-height: 1.5;
  box-shadow: 0 14px 36px rgba(0,0,0,.42); border: 1.5px solid #475569;
}
.info-popover-tabs { display: flex; gap: 4px; margin-bottom: 8px; border-bottom: 1px solid #334155; padding-bottom: 6px; }
.info-tab-btn {
  border: 1px solid #334155; background: #1e293b; color: #cbd5e1; border-radius: 7px;
  padding: 3px 9px; font-size: .74rem; font-family: inherit; font-weight: 700; cursor: pointer;
}
.info-tab-btn.active { background: #0ea5e9; color: #0f172a; border-color: #38bdf8; }
.info-example-box { background: #1e293b; border: 1px solid #334155; border-radius: 8px; padding: 6px 8px; margin-top: 5px; font-family: inherit; direction: rtl; font-size: .76rem; color: #fde68a; }

.layout-toolbar-row {
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  background: var(--primary-soft); padding: 5px 8px; border-radius: 8px; margin-bottom: 8px; font-size: .74rem;
}
.drag-handle { cursor: grab; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: rgba(15,23,42,.1); user-select: none; }
.layout-mini-btn { border: 1px solid var(--border); background: var(--card); color: var(--text); border-radius: 6px; padding: 2px 7px; font-size: .72rem; font-family: inherit; font-weight: 600; cursor: pointer; }
.layout-mini-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.back-btn { border: 1px solid var(--border); background: var(--card-soft); color: var(--text); border-radius: 9px; padding: 5px 10px; font-family: inherit; font-weight: 600; cursor: pointer; font-size: .8rem; }

/* Quick Presets Bar - Single Row (Item 13) */
.presets-single-row { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 6px; padding: 2px 0; scrollbar-width: none; align-items: center; }
.presets-single-row::-webkit-scrollbar { display: none; }
.preset-pill {
  flex: 0 0 auto; border: 1.5px solid var(--primary); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 6px 11px; font-family: inherit; font-size: .78rem; font-weight: 700;
  cursor: pointer; white-space: nowrap; transition: .12s; display: inline-flex; align-items: center; gap: 5px;
}
.preset-pill:hover { transform: translateY(-1px); }
.preset-pill.active { background: var(--primary); color: #fff; }

/* Micro Summary Cubes - Quarter Size (Item 8) */
.summary-micro-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 5px; }
.summary-cube {
  background: var(--card-soft); border: 1px solid var(--border); border-radius: 8px;
  padding: 4px 6px; cursor: pointer; transition: .12s; position: relative; min-height: 36px;
  display: flex; flex-direction: column; justify-content: center;
}
.summary-cube:hover { border-color: var(--primary); background: var(--card); }
.summary-cube.dirty { background: var(--draft-bg); border-color: var(--draft-border); }
.summary-cube-label { font-size: .64rem; color: var(--muted); font-weight: 600; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-cube-val { font-size: .74rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.summary-cube.editing { grid-column: span 2; background: var(--card); border-color: var(--primary); padding: 4px 6px; }
.cube-inline-input { width: 100%; border: 1px solid var(--primary); border-radius: 6px; padding: 3px 5px; font-family: inherit; font-size: .76rem; background: var(--card); color: var(--text); margin-top: 2px; }

/* Actions Strip - Guaranteed Single Row even on Mobile (Items 9 + 14) */
.action-single-row {
  display: flex; flex-wrap: nowrap; align-items: stretch; gap: 5px; width: 100%; overflow: hidden;
}
.act-compact {
  flex: 1 1 0; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 8px 4px; border-radius: 9px; text-decoration: none; font-weight: 700; font-size: clamp(.66rem, 2.3vw, .82rem);
  border: 0; cursor: pointer; font-family: inherit; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.act-wa { background: #16a34a; color: #fff; flex: 1.45 1 0; }
.act-chat { background: #dcfce7; color: #166534; }
.act-call { background: #0284c7; color: #fff; }
.act-sheet { background: var(--card-soft); color: var(--text); border: 1px solid var(--border); flex: .85 1 0; }
.act-copy-split {
  flex: 1.15 1 0; min-width: 0; display: inline-flex; align-items: stretch;
  border-radius: 9px; overflow: hidden; border: 1px solid #fcd34d; background: #fef3c7;
}
.act-copy-main {
  flex: 1; min-width: 0; border: 0; background: transparent; color: #92400e;
  font-family: inherit; font-weight: 700; font-size: clamp(.65rem, 2.2vw, .8rem);
  padding: 7px 4px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.act-copy-auto {
  border: 0; border-right: 1px solid #fcd34d; background: rgba(255,255,255,.45); color: #92400e;
  padding: 0 7px; font-size: .74rem; cursor: pointer; font-weight: 700; flex-shrink: 0;
}
.act-copy-auto.on { background: #f59e0b; color: #fff; }

/* Unified Due Bar (Item 10) */
.due-unified-bar { display: flex; align-items: center; gap: 6px; }
.due-unified-input-wrap { flex: 1; display: flex; align-items: center; border: 1.5px solid var(--border); border-radius: 10px; background: var(--card); overflow: hidden; }
.due-unified-input-wrap.dirty { background: var(--draft-bg); border-color: var(--draft-border); }
.due-unified-input { flex: 1; border: 0; background: transparent; color: var(--text); padding: 9px 11px; font-family: inherit; font-size: .88rem; outline: none; min-width: 0; }
.due-cal-trigger-btn {
  border: 0; border-right: 1px solid var(--border); background: var(--primary-soft); color: var(--primary-dark);
  padding: 9px 12px; font-size: 1rem; cursor: pointer; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.due-cal-trigger-btn:hover { background: var(--primary); color: #fff; }

.btn-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.opt-btn { border: 1.5px solid var(--border); background: var(--card-soft); color: var(--text); border-radius: 9px; padding: 6px 10px; font-family: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; transition: .12s; }
.opt-btn.selected { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 3px 10px rgba(15,118,110,.24); }
.opt-btn.danger-selected { background: var(--danger); color: #fff; border-color: var(--danger); }

.text-input, .select-input, .notes-area { width: 100%; padding: 9px 11px; border: 1.5px solid var(--border); border-radius: 10px; font-family: inherit; font-size: .88rem; background: var(--card); color: var(--text); }
.text-input.dirty, .select-input.dirty { background: var(--draft-bg); border-color: var(--draft-border); }
.notes-area { min-height: 110px; line-height: 1.5; resize: vertical; margin-top: 7px; }
.field-row { margin-bottom: 9px; }
.field-label { display: flex; align-items: center; gap: 5px; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.two-col-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
@media(max-width: 560px) { .two-col-row { grid-template-columns: 1fr; } }

/* Floating Corner Save Pill (Items 11, 12, 19) */
.floating-dock { position: fixed; bottom: 14px; left: 14px; z-index: 60; max-width: calc(100vw - 28px); }
.floating-dock-card {
  background: #0f172a; color: #fff; border-radius: 16px; padding: 9px 12px;
  box-shadow: 0 10px 30px rgba(15,23,42,.38); border: 1px solid #334155;
  display: flex; flex-direction: column; gap: 7px; min-width: 245px;
}
.floating-dock-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .78rem; }
.floating-dock-btns { display: flex; align-items: center; gap: 6px; }
.save-done-toggle { display: flex; align-items: center; gap: 5px; font-size: .78rem; font-weight: 600; cursor: pointer; }
.diff-toggle-btn { border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); color: #fde047; border-radius: 7px; padding: 2px 7px; font-size: .72rem; cursor: pointer; font-family: inherit; font-weight: 700; }
.diff-preview-drawer {
  background: #1e293b; color: #f8fafc; border-radius: 12px; padding: 9px 11px; margin-bottom: 7px;
  font-size: .78rem; border: 1px solid #475569; box-shadow: 0 8px 24px rgba(0,0,0,.3); max-height: 180px; overflow-y: auto;
}
.save-btn { flex: 1; background: #22c55e; color: #052e16; border: 0; border-radius: 10px; padding: 9px 14px; font-family: inherit; font-weight: 700; font-size: .86rem; cursor: pointer; white-space: nowrap; }
.save-btn.mode-done { background: #14b8a6; color: #042f2e; }
.save-btn.mode-delete { background: #ef4444; color: #fff; }
.save-btn:disabled { opacity: .6; cursor: wait; }
.discard-btn { background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 10px; padding: 9px 11px; font-family: inherit; font-weight: 700; cursor: pointer; }

/* Settings Accordions, Rule Boxes, Inline Colored Editor, Connector Two-Col Mapper */
.accordion { background: var(--card); border: 1.5px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; box-shadow: var(--card-shadow); }
.accordion-header { width: 100%; border: 0; background: var(--card); color: var(--text); padding: 13px 15px; display: flex; align-items: center; justify-content: space-between; font-family: inherit; font-weight: 700; font-size: .92rem; cursor: pointer; text-align: right; gap: 8px; }
.accordion-header:hover { background: var(--card-soft); }
.accordion-body { padding: 13px 15px; border-top: 1.5px solid var(--border-soft); background: var(--card-soft); display: none; }
.accordion.open .accordion-body { display: block; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--card); border: 1.5px solid var(--border); padding: 9px 11px; border-radius: 10px; font-size: .84rem; }

.rule-box-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.rule-box-item { border: 1.5px solid var(--border); border-radius: 10px; padding: 9px; background: var(--card); box-shadow: 0 2px 5px rgba(15,23,42,.05); }
.rule-box-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; font-size: .76rem; font-weight: 700; color: var(--accent); }
.rule-editor-box { border: 1.5px solid var(--border); border-radius: 10px; padding: 8px; background: var(--card); }
.inline-rule-editor {
  width: 100%; min-height: 44px; border: 1.5px solid var(--border); border-radius: 9px;
  padding: 8px 10px; background: var(--card); color: var(--text); font-family: inherit;
  font-size: .86rem; line-height: 1.65; outline: none; white-space: pre-wrap; word-break: break-word;
}
.inline-rule-editor.compact { min-height: 36px; padding: 6px 9px; font-size: .84rem; }
.inline-rule-editor:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.18); }
.inline-rule-editor:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.tok-inline { display: inline; padding: 1px 5px; border-radius: 5px; font-weight: 700; }
.tok-pill { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 6px; font-size: .75rem; font-weight: 700; }
.tok-op { background: #dbeafe; color: #1e3a8a; border: 1.5px solid #3b82f6; }
.tok-paren { background: #ede9fe; color: #5b21b6; border: 1.5px solid #8b5cf6; }
.tok-var { background: #fef3c7; color: #92400e; border: 1.5px solid #f59e0b; }
.tok-text, .tok-text-kw { background: #f1f5f9; color: #334155; border: 1.5px solid #94a3b8; }
.tok-arrow { background: #dcfce7; color: #166534; border: 1.5px solid #22c55e; }
.rule-token-line { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; width: 100%; }
.rule-or-divider { width: 100%; text-align: center; font-size: .7rem; color: var(--accent); font-weight: 700; margin: 3px 0; }
.muted-hint { color: var(--muted); font-size: .76rem; }

.smart-chip-pill { display: inline-flex; align-items: center; gap: 4px; background: var(--card); border: 1.5px solid var(--border); border-radius: 999px; padding: 3px 9px; font-size: .76rem; font-weight: 600; }
.smart-chip-pill button { border: 0; background: transparent; color: var(--danger); font-weight: 700; cursor: pointer; padding: 0 2px; }

.conn-map-grid { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.conn-map-pair { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 6px; align-items: center; background: var(--card); border: 1px solid var(--border); border-radius: 9px; padding: 6px; }
@media(max-width: 600px) { .conn-map-pair { grid-template-columns: 1fr; } }

.rule-ac-menu { position: fixed; z-index: 150; background: var(--card); border: 1.5px solid var(--primary); border-radius: 12px; box-shadow: 0 12px 32px rgba(15,23,42,.24); max-height: 260px; overflow-y: auto; min-width: 240px; max-width: 340px; padding: 6px; }
.rule-ac-item { padding: 7px 10px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .82rem; }
.rule-ac-item:hover, .rule-ac-item.active { background: var(--primary-soft); color: #0f172a; }

/* Modals & Toast */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(15,23,42,.58); display: flex; align-items: center; justify-content: center; padding: 14px; }
.modal-card { background: var(--card); color: var(--text); border-radius: 16px; max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.btn-primary { background: var(--primary); color: #fff; border: 0; border-radius: 9px; padding: 8px 14px; font-family: inherit; font-weight: 700; cursor: pointer; font-size: .86rem; }
.btn-secondary { background: var(--card-soft); color: var(--text); border: 1px solid var(--border); border-radius: 9px; padding: 7px 12px; font-family: inherit; font-weight: 600; cursor: pointer; font-size: .84rem; }
.btn-danger { background: var(--danger); color: #fff; border: 0; border-radius: 9px; padding: 7px 12px; font-family: inherit; font-weight: 700; cursor: pointer; font-size: .82rem; }
.toast { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 180; background: #0f172a; color: #fff; padding: 9px 16px; border-radius: 999px; font-size: .84rem; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.26); display: none; }
.empty-state { text-align: center; padding: 36px 14px; color: var(--muted); background: var(--card); border-radius: var(--radius); border: 1px dashed var(--border); }
