/* PhishLab — precision security console. Dark-first with full light parity. */
:root {
  color-scheme: dark;
  --ground: #0e0e11;
  --surface: #141418;
  --raised: #1b1b21;
  --active: #1f1f26;
  --border: #23232b;
  --rule: #1c1c23;
  --control: #343440;
  --text: #f4f4f6;
  --muted: #9a9da8;
  --faint: #828590;
  --accent: #3fc07a;
  --primary: #f4f4f6;
  --primary-ink: #0e0e11;
  --positive: #3fc07a;
  --negative: #e5566f;
  --warning: #d9a441;
  --hover: #25252e;
  --primary-hover: #dedee3;
  --pill-positive-bg: #15261e;
  --pill-positive-ink: #4fd18b;
  --pill-negative-bg: #2a181e;
  --pill-negative-ink: #f06c82;
  --pill-warning-bg: #292214;
  --pill-warning-ink: #e2b150;
  --pill-neutral-bg: #1e1e25;
  --pill-neutral-ink: #b0b3bd;
  --radius-card: 8px;
  --radius-control: 6px;
  --radius-chip: 4px;
  --sidebar-width: 248px;
  --gap: 20px;
  --pad: 32px;
  --card-pad: 20px;
  --control-height: 36px;
  --topbar: 52px;
  --fs-title: 24px;
  --fs-section: 15px;
  --fs-kpi: 28px;
  --fs-body: 14px;
  --fs-small: 12.5px;
  --font: "Public Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace; /* taste-skill-ignore */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 130ms;
  --t-med: 200ms;
}

:root[data-theme="light"] {
  color-scheme: light;
  --ground: #f6f7f8;
  --surface: #ffffff;
  --raised: #f0f1f4;
  --active: #eaecf0;
  --border: #e2e4e9;
  --rule: #eceef2;
  --control: #c6cad2;
  --text: #14151a;
  --muted: #52555f;
  --faint: #676b76;
  --accent: #16794b;
  --primary: #14151a;
  --primary-ink: #ffffff;
  --positive: #16794b;
  --negative: #c42f4a;
  --warning: #8f6208;
  --hover: #e6e8ed;
  --primary-hover: #2c2e36;
  --pill-positive-bg: #e0f3e9;
  --pill-positive-ink: #12613c;
  --pill-negative-bg: #fbe3e7;
  --pill-negative-ink: #a8243c;
  --pill-warning-bg: #f8ecd2;
  --pill-warning-ink: #7a5205;
  --pill-neutral-bg: #eceef2;
  --pill-neutral-ink: #434650;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--ground);
  color: var(--text);
  font: var(--fs-body)/22px var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }
.num, table, .stage-n, .stage-pct { font-variant-numeric: tabular-nums; }
.mono, .stage-n, .feed .when, .id, textarea.code { font-family: var(--mono); } /* taste-skill-ignore */
.error { color: var(--negative); min-height: 1.2em; font-size: var(--fs-small); }
.ok { color: var(--positive); font-size: var(--fs-small); }

/* Shell */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100svh;
  align-items: start;
  align-content: start;
  background: var(--ground);
}
.topbar { display: none; }
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  padding: 24px 12px 16px;
  border-right: 1px solid var(--border);
  background: var(--ground);
}
.brand {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 8px;
  margin-left: 10px;
  padding: 0 0 3px;
  color: var(--text);
  border-bottom: 1px solid var(--accent);
  font-family: var(--mono); /* taste-skill-ignore */
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand svg { width: 16px; height: 16px; color: var(--accent); flex: none; }
.sidebar .brand { margin-bottom: 20px; }

#nav { display: grid; gap: 2px; }
#nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-control);
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
#nav a svg { width: 16px; height: 16px; flex: none; opacity: 0.78; }
#nav a:hover { color: var(--text); background: var(--hover); }
#nav a:hover svg { opacity: 1; }
#nav a.active { color: var(--text); background: var(--active); }
#nav a.active svg { color: var(--accent); opacity: 1; }
#nav a.active span { border-bottom: 1px solid var(--accent); padding-bottom: 1px; }

/* Sidebar footer: username + sign-out/lang/theme icon tools */
.sidebar-foot {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  margin-top: 14px;
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
}
.foot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 0 4px 0 10px;
}
.who {
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.foot-tools {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: none;
}
.sidebar-foot > .foot-tools { padding-left: 4px; }
.sidebar-foot .btn {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.sidebar-foot .lang-toggle {
  justify-content: center;
  height: 30px;
  padding: 0 8px;
  font-size: var(--fs-small);
}
.sidebar-foot .theme-toggle,
.sidebar-foot .logout-btn {
  justify-content: center;
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0;
}
.sidebar-foot .btn:hover {
  background: var(--hover);
  color: var(--text);
}
.sidebar-foot .btn:active { background: var(--active); }
.theme-toggle svg,
.logout-btn svg { width: 16px; height: 16px; flex: none; transition: transform var(--t-med) var(--ease); }
.theme-toggle:hover svg { transform: rotate(20deg); }
.menu-toggle { display: none; }

/* Canvas & Header */
.canvas {
  padding: 32px var(--pad) 56px;
  min-width: 0;
  max-width: 1220px;
  width: 100%;
}
.title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  margin-bottom: var(--gap);
  border-bottom: 1px solid var(--border);
}
.title-row h1 {
  font-size: var(--fs-title);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.title-row .sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13.5px;
  max-width: 48rem;
}
.title-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

/* Grids & Cards (flat 1px borders, no resting shadow) */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: var(--gap);
  align-items: start;
}
.split > * { min-width: 0; }
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--card-pad);
}
.panel { margin: 0 0 var(--gap); }
.card.tint { background: var(--raised); }
.card.tint p + p { margin-top: 10px; }

.rail h2, .letter h2, #page > h2, #page form > h2, .set-copy h2 {
  font-size: var(--fs-section);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
}
.letter-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.letter h2 { margin: 0; font-size: 17px; }
.letter h2 a { text-decoration: none; }
.letter h2 a:hover { color: var(--accent); }
.letter-meta { color: var(--muted); font-size: var(--fs-small); margin-bottom: 18px; }

/* Signature element: 4-stage mail delivery & response path */
.path {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  overflow: hidden;
}
.stage {
  position: relative;
  padding: 16px 18px 18px;
}
.stage + .stage { border-left: 1px solid var(--border); }
.stage-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.stage-l {
  display: inline-block;
  color: var(--muted);
  font-size: var(--fs-small);
  font-weight: 500;
}
.stage.hot .stage-l {
  color: var(--text);
  border-bottom: 1px solid var(--accent);
  padding-bottom: 1px;
}
.stage-pct {
  font-size: 11.5px;
  color: var(--faint);
}
.stage-n {
  display: block;
  margin-top: 8px;
  font-size: var(--fs-kpi);
  line-height: 1.1;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.02em;
}
.stage-bar {
  margin-top: 12px;
  height: 2px;
  background: var(--border);
  overflow: hidden;
}
.stage-bar i {
  display: block;
  height: 100%;
  background: var(--muted);
}
.stage.hot .stage-bar i { background: var(--accent); }

/* Feed list & Rail items */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  align-items: center;
  min-height: 58px;
  padding: 10px 4px;
  border-top: 1px solid var(--rule);
}
.feed li:first-child { border-top: 0; padding-top: 0; }
.feed li:last-child { padding-bottom: 0; }
.feed a { font-weight: 500; text-decoration: none; }
.feed a:hover { color: var(--accent); }
.feed .when { grid-column: 1; color: var(--faint); font-size: 12px; }
.feed .pill { grid-column: 2; grid-row: 1 / span 2; }

.rail .card { overflow-x: auto; }
.rail-item {
  display: grid;
  justify-items: start;
  gap: 3px;
  padding: 12px 0;
  border-top: 1px solid var(--rule);
}
.rail-item:first-child { border-top: 0; padding-top: 0; }
.rail-item:last-child { padding-bottom: 0; }
.rail-item strong { font-weight: 600; font-size: 14px; }
.rail-item .hint { overflow-wrap: anywhere; }
.rail-item-actions { display: flex; align-items: center; gap: 4px; margin-top: 6px; }

#page > h2, #page form > h2 { margin-top: 28px; margin-bottom: 12px; }
#page p:empty { display: none; }
.meta-line { margin-top: 12px; }
#confirm-box { margin-bottom: 16px; border-color: var(--control); background: var(--raised); }
#confirm-box p { margin-bottom: 12px; }
#confirm-text .opt { margin: 8px 0; }
.filter-row { flex-wrap: wrap; gap: 8px; margin: 0 0 12px; align-items: center; }
.filter-row input { max-width: 18rem; }
.filter-chip { height: 28px; }
.preview-frame {
  width: 100%;
  height: 17rem;
  min-height: 14rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: #fff;
  display: block;
}
.preview-subject {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius-chip);
  background: var(--raised);
  border: 1px solid var(--rule);
}
.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 12px 0 8px;
}
.preview-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}
.preview-pane h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.preview-src { margin-top: 2px; color: var(--muted); font-size: var(--fs-small); }
.preview-src summary { cursor: pointer; user-select: none; }
.preview-src pre {
  margin: 8px 0 0;
  padding: 12px;
  max-height: 12rem;
  overflow: auto;
  background: var(--raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius-chip);
  font-family: var(--mono); /* taste-skill-ignore */
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.preview-warn { color: var(--negative); font-size: var(--fs-small); margin: 0; }
.preview-sep { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--rule); display: grid; gap: 8px; }

/* Rich text editor */
.rte {
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--ground);
  overflow: hidden;
}
:root[data-theme="light"] .rte { background: var(--surface); }
.rte:focus-within { border-color: var(--accent); }
.rte-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--rule);
  background: var(--raised);
}
.rte-tabs {
  display: inline-flex;
  border: 1px solid var(--control);
  border-radius: var(--radius-chip);
  overflow: hidden;
  margin-right: 4px;
}
.rte-tab {
  height: 26px;
  padding: 0 9px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.rte-tab.active {
  background: var(--primary);
  color: var(--primary-ink);
}
.rte-tools {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
}
.rte-btn {
  height: 26px;
  min-width: 26px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-chip);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.rte-btn:hover { background: var(--hover); border-color: var(--control); }
.rte-sep {
  width: 1px;
  height: 16px;
  background: var(--rule);
  margin: 0 3px;
}
.rte-vars {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}
.rte-var {
  height: 24px;
  padding: 0 7px;
  border: 1px solid var(--control);
  border-radius: var(--radius-chip);
  background: var(--raised);
  color: var(--muted);
  font-family: var(--mono); /* taste-skill-ignore */
  font-size: 11px;
  cursor: pointer;
}
.rte-var:hover { color: var(--text); border-color: var(--accent); }
.rte-visual {
  background: #fff;
  color: #14151a;
}
.rte-surface {
  min-height: 10rem;
  max-height: 24rem;
  overflow: auto;
  padding: 12px 14px;
  outline: none;
  font-size: 14px;
  line-height: 1.6;
  color: inherit;
  background: transparent;
}
.rte-surface p { margin: 0 0 0.65em; }
.rte-surface p:last-child { margin-bottom: 0; }
.rte-surface h1, .rte-surface h2, .rte-surface h3 { margin: 0.7em 0 0.35em; line-height: 1.3; }
.rte-surface ul, .rte-surface ol { margin: 0.4em 0 0.7em; padding-left: 1.4rem; }
.rte-surface a { color: #16794b; text-decoration: underline; }
.rte textarea.code {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  min-height: 10rem;
}
.rte textarea.code.hidden, .rte-visual.hidden, .rte-surface.hidden, .rte-tools.hidden, .rte-note.hidden { display: none; }
.rte-note {
  padding: 5px 10px;
  border-bottom: 1px solid var(--rule);
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
}

/* Tables */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: auto;
}
table.data, table { width: 100%; border-collapse: collapse; }
th {
  height: 38px;
  padding: 0 14px;
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: var(--faint);
}
td {
  padding: 12px 14px;
  border-top: 1px solid var(--rule);
  vertical-align: middle;
}
tbody tr { transition: background-color var(--t-fast) var(--ease); }
tbody tr:hover { background: var(--raised); }
tbody tr.row-link { cursor: pointer; }
tbody tr.row-link:hover { background: var(--hover); }
tbody tr.row-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
td a { font-weight: 500; text-decoration: none; }
td a:hover { color: var(--accent); }
th.n, td.n { text-align: right; }
td.n { font-family: var(--mono); } /* taste-skill-ignore */
td.phone-hide { overflow-wrap: anywhere; font-size: var(--fs-small); color: var(--muted); }
.mark { font-family: var(--mono); font-size: 12px; white-space: nowrap; } /* taste-skill-ignore */
.mark.yes { color: var(--pill-positive-ink); }
.mark.no { color: var(--faint); }
.mark.bad { color: var(--pill-negative-ink); }
.mark-links {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-weight: 400;
  white-space: normal;
}

/* Status pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 8px;
  border-radius: var(--radius-chip);
  font-size: 12px;
  font-weight: 500;
  background: var(--pill-neutral-bg);
  color: var(--pill-neutral-ink);
  white-space: nowrap;
  flex: none;
}
.pill.accent {
  background: var(--pill-positive-bg);
  color: var(--pill-positive-ink);
}
.pill.accent::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.pill.bad {
  background: var(--pill-negative-bg);
  color: var(--pill-negative-ink);
}

/* Controls & Buttons (coherent 6px terminal geometry) */
.btn, .primary, .ghost, .danger, .tiny {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-height);
  padding: 0 14px;
  border-radius: var(--radius-control);
  border: 1px solid var(--control);
  background: var(--raised);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn:hover, .ghost:hover { background: var(--hover); }
.btn.primary, .primary {
  background: var(--primary);
  color: var(--primary-ink);
  border-color: transparent;
}
.btn.primary:hover, .primary:hover { background: var(--primary-hover); }
.btn.ghost, .ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover, .ghost:hover { color: var(--text); background: var(--hover); }
:root[data-theme="light"] a.btn:not(.primary),
:root[data-theme="light"] button.btn:not(.primary):not(.ghost) {
  background: var(--surface);
  border-color: var(--control);
  color: var(--text);
}
:root[data-theme="light"] a.btn:not(.primary):hover,
:root[data-theme="light"] button.btn:not(.primary):not(.ghost):hover {
  background: var(--raised);
}
.danger {
  background: transparent;
  color: var(--negative);
  border-color: transparent;
}
.danger:hover { background: var(--pill-negative-bg); }
.tiny { height: 30px; padding: 0 10px; font-size: var(--fs-small); }
/* Login screen */
.login {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  position: relative;
  overflow: hidden;
  background-color: var(--ground);
  background-image: radial-gradient(rgba(63, 192, 122, 0.1) 1px, transparent 1px);
  background-size: 24px 24px;
}
:root[data-theme="light"] .login {
  background-image: radial-gradient(rgba(22, 121, 75, 0.11) 1px, transparent 1px);
}
.login-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
.login-tools {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.login-tools .lang-toggle {
  height: 32px;
  padding: 0 9px;
  font-size: var(--fs-small);
}
.login-tools .theme-toggle {
  width: 32px;
  height: 32px;
  padding: 0;
}
.login-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
}
.login-card {
  display: grid;
  gap: 16px;
  padding: 32px 28px;
  background: rgba(20, 20, 24, 0.94);
  box-shadow: 0 0 0 1px rgba(63, 192, 122, 0.1), 0 20px 50px rgba(0, 0, 0, 0.45);
}
:root[data-theme="light"] .login-card {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 1px 2px rgba(20, 21, 26, 0.05), 0 12px 32px rgba(20, 21, 26, 0.08);
}
.login-head {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}
.login-head .brand {
  margin-left: 0;
  font-size: 16px;
}
.login-head .brand svg {
  width: 18px;
  height: 18px;
}
.login .btn.primary {
  width: 100%;
  height: 42px;
}
#login-error:empty {
  display: none;
}

/* Forms & Inputs */
.stack { display: grid; gap: 10px; }
.stack > .btn, .stack > .primary, .stack > .danger, .stack > .ghost { justify-self: start; margin-top: 6px; }
.field-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.form-actions { margin-top: 20px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row input, .row select { width: auto; flex: 1 1 8rem; min-width: 0; }
.assist-row input { flex: 1 1 14rem; }
#ai-sum-text { white-space: pre-wrap; }
.hint { color: var(--muted); font-size: var(--fs-small); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input[type="search"] { flex: 1 1 16rem; min-width: 0; }
.toolbar select { flex: 0 0 auto; width: auto; }
.pager { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pager .hint { font-size: 12.5px; }
.crumbs { margin: 0 0 12px; font-size: 12.5px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }
table.data th.actions, table.data td.actions { width: 1%; text-align: right; white-space: nowrap; }
.empty {
  padding: 16px;
  border: 1px dashed var(--control);
  border-radius: var(--radius-control);
  color: var(--muted);
  font-size: 13.5px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin: 6px 0 0;
}
.field label { margin: 0; }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--ground);
  color: var(--text);
  font-size: 13.5px;
  transition: border-color var(--t-fast) var(--ease);
}
:root[data-theme="light"] input:not([type="checkbox"]):not([type="radio"]),
:root[data-theme="light"] select,
:root[data-theme="light"] textarea {
  background: var(--surface);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  outline: none;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
.opt {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 400;
  margin: 4px 0;
  cursor: pointer;
}
.opt input { width: auto; min-height: 0; accent-color: var(--accent); }
textarea { min-height: 8.5rem; resize: vertical; }
textarea.code { font-size: 12.5px; line-height: 1.55; }
.qbox { display: grid; gap: 8px; padding: 16px 0; border-top: 1px solid var(--rule); }
.qbox > .tiny { justify-self: start; }

/* Settings */
.set {
  max-width: 1120px;
  display: grid;
  gap: 0;
}
.set-row {
  display: grid;
  grid-template-columns: minmax(15rem, 24rem) minmax(0, 1fr);
  gap: 28px;
  padding: 28px 0;
  border-top: 1px solid var(--border);
}
.set-row:first-child { border-top: 0; padding-top: 0; }
.set-copy p { margin-top: 6px; color: var(--muted); font-size: 13.5px; max-width: 24rem; }
.set-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--card-pad);
}
.rail .card .table-wrap,
.set-panel .table-wrap { border: 0; border-radius: 0; }
.set-panel .table-wrap { margin-top: 14px; }
.link-map {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--raised);
}
.link-map h3 {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.link-map-row {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 3px 12px;
  align-items: baseline;
}
.link-map-row code { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.link-map-url { font-size: 12.5px; overflow-wrap: anywhere; }
.link-map-row .hint { grid-column: 2; }
.var-guide { gap: 6px; }
.var-guide .link-map-row { grid-template-columns: 9rem minmax(0, 1fr); gap: 6px 12px; }
.var-guide .link-map-desc { font-size: var(--fs-small); color: var(--muted); }
.warn { color: var(--warning); font-size: var(--fs-small); margin: 0; }

/* Phone & Tablet */
@media (max-width: 960px) {
  .split { grid-template-columns: 1fr; }
  .preview-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 21;
    height: var(--topbar);
    padding: 0 16px;
    background: var(--ground);
    border-bottom: 1px solid var(--border);
  }
  #bar-title { font-weight: 600; font-size: 15px; }
  .sidebar {
    display: none;
    position: fixed;
    inset: var(--topbar) 0 0 0;
    z-index: 20;
    background: var(--ground);
    border-right: 0;
    min-height: 0;
    padding: 16px;
    overflow-y: auto;
  }
  .sidebar.open { display: flex; }
  .menu-toggle { display: inline-flex; }
  .canvas { padding: 20px 16px 40px; }
  .set-row, .field-pair { grid-template-columns: 1fr; }
  .title-row { flex-wrap: wrap; align-items: flex-start; }
  .path { grid-template-columns: 1fr 1fr; }
  .stage:nth-child(n + 3) { border-top: 1px solid var(--border); }
  .stage:nth-child(odd) { border-left: 0; }
  table.data thead, table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  table.data tr, table tr { display: block; padding: 12px 14px; border-top: 1px solid var(--rule); }
  table.data tr:first-child, table tr:first-child { border-top: 0; }
  table.data td, table td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    border: 0;
    padding: 3px 0;
    text-align: right;
  }
  table.data td::before, table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    text-align: left;
    flex: none;
  }
  table.data td:first-child, table td:first-child {
    display: block;
    text-align: left;
    font-weight: 500;
    padding-bottom: 4px;
  }
  table.data td:first-child::before, table td:first-child::before { content: none; }
  table.data td.phone-hide, table td.phone-hide { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}

/* Rich text canvas. The surface renders the operator's page, not app chrome,
   so the app's own label/control styling must not leak into it: on the white
   canvas the dark theme would otherwise paint near-white labels (invisible)
   and near-black fields. Page CSS is injected after this sheet, so an imported
   page's own rules still win at equal specificity. */
.rte-visual { color-scheme: light; }
.rte-surface label {
  display: inline;
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
}
.rte-surface :is(input, textarea, select):not([type="checkbox"], [type="radio"]) {
  width: auto;
  min-height: 0;
  padding: 1px 2px;
  border: 1px solid #767676;
  border-radius: 0;
  background: #fff;
  color: #14151a;
  font-size: inherit;
  transition: none;
}
.rte-surface textarea:not([type="checkbox"], [type="radio"]) {
  min-height: 4em;
  resize: vertical;
}
.rte-surface input::placeholder,
.rte-surface textarea::placeholder { color: #757575; }

/* Form landing builder (3-column visual editor: palette | live canvas | properties) */
.canvas.is-form-editor {
  max-width: none;
  padding: 20px 24px 28px;
}
.canvas.is-form-editor .title-row {
  display: none;
}
.fe-shell {
  display: flex;
  flex-direction: column;
  height: calc(100svh - 48px);
  min-height: 560px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  overflow: hidden;
}
.fe-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.fe-topbar-left,
.fe-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.fe-topbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.fe-topbar-title strong {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.fe-back {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: var(--radius-control);
}
.fe-back:hover { color: var(--text); background: var(--hover); }
.fe-status {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--pill-neutral-bg);
  color: var(--pill-neutral-ink);
}
.fe-status.is-dirty {
  background: var(--pill-warning-bg);
  color: var(--pill-warning-ink);
}
.fe-status.is-saved {
  background: var(--pill-positive-bg);
  color: var(--pill-positive-ink);
}
.fe-banner {
  padding: 7px 16px;
  border-bottom: 1px solid var(--rule);
  background: var(--raised);
  font-size: var(--fs-small);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.fe-banner:empty { display: none; }
.fe-panes {
  display: none;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.fe-panes button {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--control);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}
.fe-panes button[aria-pressed="true"] {
  background: var(--primary);
  border-color: transparent;
  color: var(--primary-ink);
}
.fe-columns {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr) 356px;
}
.fe-palette {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.fe-settings-nav {
  padding: 10px 10px 10px;
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 2px;
}
.fe-palette h3 {
  margin: 4px 4px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--faint);
}
.fe-settings-nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  padding: 7px 9px;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.fe-settings-nav button:hover { background: var(--hover); color: var(--text); }
.fe-settings-nav button.is-active {
  background: var(--active);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--accent);
}
.fe-search {
  padding: 10px 10px 6px;
}
.fe-search input {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 12.5px;
}
.fe-palette-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 14px;
  display: grid;
  gap: 12px;
  align-content: start;
}
.fe-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.fe-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 9px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--raised);
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
  text-align: center;
  cursor: grab;
  user-select: none;
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.fe-tile:hover {
  border-color: var(--accent);
  background: var(--hover);
}
.fe-tile:active { cursor: grabbing; }
.fe-tile.is-dragging { opacity: 0.45; }
.fe-tile-glyph {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1;
}

/* Middle column: live canvas */
.fe-canvas-wrap {
  overflow-y: auto;
  padding: 20px 24px 48px;
  background: var(--ground);
}
.fe-canvas-wrap.is-over {
  background: color-mix(in srgb, var(--accent) 7%, var(--ground));
}
.fe-sheet {
  max-width: 620px;
  margin: 0 auto;
  display: grid;
  gap: 0;
}
.fe-canvas-header,
.fe-canvas-footer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease);
}
.fe-canvas-header:hover,
.fe-canvas-footer:hover { border-color: var(--control); }
.fe-canvas-header.is-selected,
.fe-canvas-footer.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.fe-canvas-header h2 {
  font-size: 19px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
}
.fe-canvas-header .fe-intro {
  font-size: 13.5px;
  color: var(--muted);
  white-space: pre-line;
  margin: 0;
}
.fe-canvas-meta {
  display: inline-block;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--faint);
}
.fe-canvas-submit {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.fe-submit-pill {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 18px;
  border-radius: var(--radius-control);
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 13.5px;
  font-weight: 600;
  border: 0;
  cursor: pointer;
}
.fe-canvas-footer {
  margin-top: 14px;
}
.fe-canvas-footer-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.fe-thanks-snippet {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* Insert bar between cards */
.fe-insert {
  position: relative;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fe-insert::before {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  border-top: 1px dashed transparent;
  transition: border-color var(--t-fast) var(--ease);
}
.fe-insert:hover::before,
.fe-insert.is-active::before,
.fe-insert.is-over::before {
  border-top: 2px solid var(--accent);
}
.fe-insert button {
  position: relative;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--control);
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.fe-insert:hover button,
.fe-insert.is-active button,
.fe-insert.is-over button {
  opacity: 1;
  background: var(--accent);
  border-color: var(--accent);
  color: #0e0e11;
}

/* Question card on canvas */
.fe-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 10px 14px 14px;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
}
.fe-card:hover { border-color: var(--control); }
.fe-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.fe-card.is-dragging { opacity: 0.45; }
.fe-card.is-drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.fe-card-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}
.fe-handle {
  border: 0;
  background: transparent;
  color: var(--faint);
  cursor: grab;
  font-size: 15px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
}
.fe-handle:hover { color: var(--text); background: var(--hover); }
.fe-handle:active { cursor: grabbing; }
.fe-card-type {
  font-weight: 600;
  color: var(--muted);
}
.fe-badge {
  display: inline-flex;
  align-items: center;
  height: 19px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--pill-neutral-bg);
  color: var(--pill-neutral-ink);
}
.fe-badge.is-warn {
  background: var(--pill-warning-bg);
  color: var(--pill-warning-ink);
}
.fe-badge.is-accent {
  background: var(--pill-positive-bg);
  color: var(--pill-positive-ink);
}
.fe-card-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
}
.fe-card-actions button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 4px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fe-card-actions button:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.fe-card-actions button:disabled { opacity: 0.3; cursor: default; }
.fe-card-actions button.is-danger:hover:not(:disabled) {
  background: var(--pill-negative-bg);
  color: var(--negative);
}
.fe-card-preview {
  pointer-events: none;
  display: grid;
  gap: 6px;
}
.fe-preview-q {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.fe-preview-req { color: var(--negative); margin-left: 2px; }
.fe-preview-help {
  font-size: 12.5px;
  color: var(--muted);
  white-space: pre-line;
}
.fe-preview-input,
.fe-preview-textarea,
.fe-preview-select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--ground);
  color: var(--faint);
  padding: 7px 10px;
  font-size: 13px;
}
.fe-preview-textarea { min-height: 54px; }
.fe-preview-opt {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
}
.fe-preview-rating {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.fe-preview-rating span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--ground);
  color: var(--muted);
  font-size: 12.5px;
}
.fe-preview-statement {
  padding: 10px 12px;
  border-radius: var(--radius-control);
  background: var(--raised);
  border-left: 3px solid var(--accent);
}
.fe-drop-empty {
  padding: 28px 18px;
  border: 1.5px dashed var(--control);
  border-radius: var(--radius-card);
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

/* Right column: properties inspector */
.fe-props {
  overflow-y: auto;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 14px 16px 28px;
  display: grid;
  gap: 12px;
  align-content: start;
}
.fe-props-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}
.fe-props-head h2 {
  font-size: 14.5px;
  font-weight: 600;
  margin: 0;
}
.fe-prop-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 10px 11px;
  display: grid;
  gap: 8px;
  background: var(--raised);
}
.fe-prop-group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.fe-opt-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 4px;
  align-items: center;
}
.fe-opt-row input {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 13px;
}
.fe-opt-row button {
  width: 26px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-chip);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}
.fe-opt-row button:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.fe-opt-row button:disabled { opacity: 0.3; cursor: default; }
.fe-props label { margin: 0; font-size: 12.5px; }
.fe-props textarea { min-height: 4.5rem; }

/* Preview modal */
.fe-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.fe-modal {
  width: min(1080px, 100%);
  max-height: calc(100svh - 40px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.fe-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.fe-modal-head h2 { font-size: 15px; font-weight: 600; }
.fe-modal-body {
  padding: 16px;
  overflow-y: auto;
}
.fe-modal-body .preview-frame {
  height: 28rem;
}

@media (max-width: 1180px) {
  .fe-panes { display: flex; }
  .fe-panes [data-fe-pane="props"] { display: none; }
  .fe-columns { grid-template-columns: minmax(0, 1fr) 330px; }
  .fe-columns > .fe-palette { display: none; }
  .fe-columns[data-pane="palette"] > .fe-palette { display: flex; }
  .fe-columns[data-pane="palette"] > .fe-canvas-wrap { display: none; }
}
@media (max-width: 860px) {
  .canvas.is-form-editor { padding: 12px; }
  .fe-shell { height: auto; min-height: calc(100svh - 76px); }
  .fe-panes [data-fe-pane="props"] { display: inline-flex; align-items: center; }
  .fe-columns { grid-template-columns: minmax(0, 1fr); }
  .fe-columns > .fe-palette,
  .fe-columns > .fe-canvas-wrap,
  .fe-columns > .fe-props { display: none; }
  .fe-columns[data-pane="palette"] > .fe-palette { display: flex; }
  .fe-columns[data-pane="canvas"] > .fe-canvas-wrap { display: block; }
  .fe-columns[data-pane="props"] > .fe-props { display: grid; }
  .fe-props { border-left: 0; }
  .fe-canvas-wrap { padding: 14px 12px 32px; }
}

/* HTML landing editor: full-height split studio (tabbed tools + inspector + editor | resizer | sticky preview) */
.hl-columns {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, var(--hl-left, 52%)) 6px minmax(260px, 1fr);
}
.hl-columns[data-layout="edit"] {
  grid-template-columns: minmax(0, 1fr);
}
.hl-columns[data-layout="edit"] > .hl-resizer,
.hl-columns[data-layout="edit"] > .hl-preview { display: none; }
.hl-columns[data-layout="preview"] {
  grid-template-columns: minmax(0, 1fr);
}
.hl-columns[data-layout="preview"] > .hl-editor,
.hl-columns[data-layout="preview"] > .hl-resizer { display: none; }

.hl-resizer {
  position: relative;
  cursor: col-resize;
  background: var(--border);
  transition: background-color var(--t-fast) var(--ease);
  user-select: none;
  touch-action: none;
}
.hl-resizer:hover,
.hl-resizer.is-active {
  background: var(--accent);
}
.hl-resizer::after {
  content: "";
  position: absolute;
  inset: 0 -4px;
}
.hl-dragging iframe { pointer-events: none; }
.hl-dragging { user-select: none; cursor: col-resize; }

.hl-editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px 16px;
  gap: 10px;
  background: var(--surface);
}
.hl-tools {
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--raised);
  overflow: hidden;
  flex: none;
}
.hl-tool-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}
.hl-tools.is-collapsed .hl-tool-tabs { border-bottom: 0; }
.hl-tool-tab {
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-chip);
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}
.hl-tool-tab:hover { color: var(--text); background: var(--hover); }
.hl-tool-tab.is-active {
  background: var(--active);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.hl-tool-toggle {
  margin-left: auto;
  height: 26px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-chip);
  background: transparent;
  color: var(--faint);
  font-size: 12px;
  cursor: pointer;
}
.hl-tool-toggle:hover { color: var(--text); background: var(--hover); }
.hl-tool-body {
  padding: 10px 12px;
  display: grid;
  gap: 8px;
}
.hl-tools.is-collapsed .hl-tool-body { display: none; }

.hl-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.hl-card-head h3 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.hl-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.hl-chip {
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--control);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.hl-chip:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--hover);
}
.hl-inspect {
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--raised);
  padding: 8px 11px;
  display: grid;
  gap: 6px;
  flex: none;
}
.hl-inspect-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.hl-inspect-warn {
  color: var(--warning);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.hl-inspect-bad {
  color: var(--negative);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.hl-code-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 260px;
  min-height: 240px;
}
.hl-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.hl-code-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hl-code-head label { margin: 0; }
.hl-code-stats {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--faint);
}
.hl-code-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.hl-code-wrap .rte {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 220px;
}
.hl-code-wrap .rte-visual {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.hl-code-wrap .rte-surface {
  flex: 1;
  max-height: none;
  min-height: 200px;
}
.hl-code-wrap .rte textarea.code {
  flex: 1;
  min-height: 220px;
  resize: none;
}

.hl-preview {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--ground);
}
.hl-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}
.hl-viewport-tabs {
  display: inline-flex;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  overflow: hidden;
}
.hl-viewport-tabs button {
  height: 28px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.hl-viewport-tabs button.is-active {
  background: var(--primary);
  color: var(--primary-ink);
}
.hl-preview-stage {
  flex: 1;
  min-height: 0;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  overflow-y: auto;
}
.hl-preview-frame {
  width: 100%;
  flex: 1 1 auto;
  min-height: 420px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: #fff;
  display: block;
  transition: width var(--t-med) var(--ease);
}
.hl-preview-frame.is-mobile {
  width: 390px;
  max-width: 100%;
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
}
.hl-preview-stage .preview-src {
  width: 100%;
  flex: none;
}
@media (max-width: 1020px) {
  .hl-columns { grid-template-columns: minmax(0, 1fr); }
  .hl-resizer { display: none; }
  .hl-columns[data-layout="split"] { grid-template-columns: minmax(0, 1fr); }
  .hl-editor { border-bottom: 1px solid var(--border); }
  .hl-preview-frame { min-height: 360px; }
}

/* Dashboard & Campaigns upgrades */
.dash-kpis {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.dash-split {
  margin-top: 20px;
}
.dash-main {
  display: grid;
  gap: 20px;
  min-width: 0;
}
.dash-main h2,
.dash-rail h2 {
  font-size: var(--fs-section);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
}
.active-list {
  display: grid;
  gap: 10px;
}
.active-item {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--raised);
}
.active-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.active-head a {
  font-weight: 600;
  text-decoration: none;
}
.active-head a:hover { color: var(--accent); }
.prog-bar {
  height: 5px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.prog-bar i {
  display: block;
  height: 100%;
  background: var(--accent);
}
.active-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}
.rate-cell {
  display: inline-grid;
  justify-items: end;
  gap: 3px;
  min-width: 4.5rem;
}
.rate-bar {
  width: 56px;
  height: 3px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.rate-bar i {
  display: block;
  height: 100%;
  background: var(--muted);
}
.rate-bar.hot i { background: var(--accent); }
.act-feed {
  list-style: none;
  margin: 0;
  padding: 0;
}
.act-feed li {
  display: grid;
  gap: 3px;
  padding: 10px 0;
  border-top: 1px solid var(--rule);
}
.act-feed li:first-child { border-top: 0; padding-top: 0; }
.act-feed li:last-child { padding-bottom: 0; }
.act-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.act-who {
  font-size: 13px;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.act-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.act-sub a {
  text-decoration: none;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.act-sub a:hover { color: var(--accent); }
.cell-sub {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--faint);
  font-weight: 400;
}
.cd-progress {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  margin-top: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: 13px;
}
.cd-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 20px 0 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.cd-tab {
  height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.cd-tab:hover { color: var(--text); background: var(--hover); }
.cd-tab.is-active {
  background: var(--active);
  color: var(--text);
  border-color: var(--border);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.cd-panel.hidden { display: none; }
.ans-detail summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 500;
}
.ans-list {
  margin: 6px 0 0;
  display: grid;
  gap: 4px;
  font-size: 12.5px;
  text-align: left;
}
.ans-list div {
  display: grid;
  gap: 1px;
}
.ans-list dt {
  color: var(--faint);
  font-size: 11.5px;
}
.ans-list dd {
  margin: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

/* Email template studio, Groups & Profiles helpers */
.mail-head {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  padding: 10px 12px;
  display: grid;
  gap: 4px;
  font-size: 12.5px;
  flex: none;
}
.mail-head-row {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}
.mail-head-row span:first-child { color: var(--faint); font-weight: 500; }
.mail-head-row strong { font-weight: 600; color: var(--text); }
.rail-item.is-editing {
  background: var(--raised);
  margin: 0 -10px;
  padding: 12px 10px;
  border-radius: var(--radius-control);
  box-shadow: inset 2px 0 0 var(--accent);
}
.pw-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}
.err-list {
  margin: 6px 0 0;
  padding-left: 1.2rem;
  font-size: 12px;
  color: var(--negative);
  max-height: 10rem;
  overflow-y: auto;
}

/* Awareness quiz editor & training report */
.fe-opt-row.has-key {
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
}
.fe-key-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--control);
  border-radius: var(--radius-chip);
  background: var(--surface);
  color: var(--faint);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}
.fe-key-btn:hover { border-color: var(--accent); color: var(--text); }
.fe-key-btn.is-correct {
  background: var(--pill-positive-bg);
  border-color: var(--accent);
  color: var(--pill-positive-ink);
}
.fe-preview-opt.is-correct {
  color: var(--pill-positive-ink);
  font-weight: 600;
}
.quiz-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.quiz-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  display: grid;
  gap: 4px;
}
.quiz-kpi-l {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.quiz-kpi-v {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.15;
  color: var(--text);
}
.quiz-kpi-s {
  font-size: 12px;
  color: var(--faint);
}
.dist-grid {
  display: grid;
  gap: 10px;
}
.dist-row {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr) 4.5rem;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}
.dist-track {
  height: 10px;
  border-radius: 999px;
  background: var(--raised);
  border: 1px solid var(--border);
  overflow: hidden;
}
.dist-track i {
  display: block;
  height: 100%;
  background: var(--accent);
}
.dist-row.is-low .dist-track i { background: var(--negative); }
.dist-row.is-mid .dist-track i { background: var(--warning); }
.fe-tpl-list {
  display: grid;
  gap: 6px;
}
.fe-tpl-card {
  display: grid;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.fe-tpl-card:hover {
  border-color: var(--accent);
  background: var(--hover);
}
.fe-tpl-card strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.fe-tpl-card span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}
@media (max-width: 860px) {
  .quiz-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
