/*
 * Tag Tester — Adzymic internal ad tag testing platform.
 * A small hand-rolled design system: tokens, layout, components.
 */

:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;

  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --muted-2: #98a2b3;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;

  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f9fafb;

  --navy: #0b1220;
  --navy-2: #111a2e;
  --navy-3: #1a2742;

  --brand: #4f46e5;
  --brand-strong: #4338ca;
  --brand-soft: #eef2ff;
  --brand-ink: #3538cd;

  --success: #067647;
  --success-soft: #ecfdf3;
  --warning: #b54708;
  --warning-soft: #fffaeb;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --info: #175cd3;
  --info-soft: #eff8ff;

  --code-bg: #0d1117;
  --code-ink: #e6edf3;

  --radius-sm: 7px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.09);
  --shadow-lg: 0 24px 60px rgba(5, 10, 25, 0.24);

  --sidebar-w: 248px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; color: var(--ink); font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }

img, svg, video { max-width: 100%; }

::selection { background: #c7d2fe; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------------------------------------------------------------- Layout */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1100px 500px at -10% -20%, rgba(79, 70, 229, 0.28), transparent 60%),
    var(--navy);
  color: #c7d2e4;
  padding: 20px 14px 14px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 20;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 22px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 750;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: #fff;
  background: linear-gradient(140deg, #6366f1, #8b5cf6 55%, #ec4899);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { color: #fff; font-size: 15px; letter-spacing: -0.01em; }
.brand-text small { color: #8da0bd; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px; }

.sidebar__nav { display: flex; flex-direction: column; gap: 3px; }

.nav-section {
  margin: 18px 10px 6px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6f81a0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 8px;
  color: #b6c4da;
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link .icon { flex: 0 0 auto; opacity: 0.8; }
.nav-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(99, 102, 241, 0.2); color: #fff; box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.28); }
.nav-link.active .icon { color: #a5b4fc; opacity: 1; }

.nav-link--button {
  width: 100%;
  background: transparent;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.sidebar__footer { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.08); }

.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px 12px; }
.user-chip__text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-chip__text strong { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.user-chip__text small { color: #8da0bd; font-size: 11px; }

.avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 650;
  color: #e0e7ff;
  background: rgba(99, 102, 241, 0.35);
  border: 1px solid rgba(165, 180, 252, 0.35);
}

.app-main {
  flex: 1;
  min-width: 0;
  padding: 28px 34px 56px;
  max-width: 1600px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.page-header__text { min-width: 0; }
.page-header h1 { font-size: 26px; line-height: 1.2; }
.eyebrow { font-size: 11px; font-weight: 650; letter-spacing: 0.09em; text-transform: uppercase; color: var(--brand-ink); margin-bottom: 6px; }
.page-subtitle { color: var(--muted); margin-top: 6px; max-width: 68ch; }

.page-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; padding-top: 4px; }
.page-body { display: flex; flex-direction: column; gap: 20px; }

.guest-main {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 18px;
  background:
    radial-gradient(900px 500px at 15% 0%, rgba(79, 70, 229, 0.45), transparent 55%),
    radial-gradient(900px 600px at 90% 100%, rgba(236, 72, 153, 0.22), transparent 50%),
    #070b14;
}

/* ---------------------------------------------------------------- Flash */

.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  font-size: 13.5px;
}
.flash--success, .flash--notice { border-color: #abefc6; background: var(--success-soft); color: #085d3a; }
.flash--danger, .flash--alert { border-color: #fecdca; background: var(--danger-soft); color: #912018; }
.flash--warning { border-color: #fedf89; background: var(--warning-soft); color: #7a2e0e; }
.flash--info { border-color: #b2ddff; background: var(--info-soft); color: #174ea6; }
.flash__close { background: none; border: 0; cursor: pointer; font-size: 18px; line-height: 1; color: inherit; opacity: 0.6; padding: 0 2px; }
.flash__close:hover { opacity: 1; }

/* ---------------------------------------------------------------- Cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card--flush { padding: 0; }
.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #fbfcfe);
}
.card__header h2 { font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card__header .icon { color: var(--muted); }
.card__header p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card__body { padding: 18px; }
.card__body--tight { padding: 12px 14px; }
.card__footer { padding: 13px 18px; border-top: 1px solid var(--line); background: var(--surface-2); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------------------------------------------------------------- Buttons */

.btn {
  --btn-bg: var(--surface);
  --btn-ink: var(--ink-2);
  --btn-line: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: 8px;
  border: 1px solid var(--btn-line);
  background: var(--btn-bg);
  color: var(--btn-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, color 0.12s ease;
  box-shadow: var(--shadow-xs);
}
.btn:hover { text-decoration: none; background: var(--surface-2); border-color: #b8c0cc; color: var(--ink); }
.btn:active { transform: translateY(0.5px); }
.btn .icon { flex: 0 0 auto; }

.btn--primary { --btn-bg: var(--brand); --btn-ink: #fff; --btn-line: var(--brand); box-shadow: 0 1px 2px rgba(16,24,40,.1), inset 0 1px 0 rgba(255,255,255,.16); }
.btn--primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }

.btn--dark { --btn-bg: var(--navy-2); --btn-ink: #fff; --btn-line: var(--navy-2); }
.btn--dark:hover { background: var(--navy-3); border-color: var(--navy-3); color: #fff; }

.btn--danger { --btn-bg: var(--danger-soft); --btn-ink: var(--danger); --btn-line: #fecdca; box-shadow: none; }
.btn--danger:hover { background: #fee4e2; border-color: #fda29b; color: var(--danger); }

.btn--ghost { --btn-bg: transparent; --btn-line: transparent; --btn-ink: var(--muted); box-shadow: none; }
.btn--ghost:hover { background: rgba(16, 24, 40, 0.05); border-color: transparent; }

.btn--sm { padding: 6px 10px; font-size: 12px; border-radius: 7px; }
.btn--xs { padding: 4px 8px; font-size: 11.5px; border-radius: 6px; gap: 5px; }
.btn--block { width: 100%; }
.btn:disabled, .btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.btn-group { display: inline-flex; gap: 0; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
.btn-group .btn:last-child { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }
.btn-group .btn + .btn { margin-left: -1px; }

/* ---------------------------------------------------------------- Forms */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field + .field { margin-top: 14px; }
.label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.label small { font-weight: 500; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); }
.error-text { font-size: 12px; color: var(--danger); }

.input, .select, .textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.4;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.16);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.textarea { min-height: 90px; resize: vertical; }
.input--mono, .textarea--mono { font-family: var(--font-mono); font-size: 12.5px; }
.input--sm { padding: 6px 9px; font-size: 12.5px; }
.select--sm { padding: 5px 8px; font-size: 12px; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.checkbox input { width: 15px; height: 15px; accent-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-errors { border: 1px solid #fecdca; background: var(--danger-soft); color: #912018; border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; }
.form-errors ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------------------------------------------------------------- Badges & pills */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
}
.badge--brand { background: var(--brand-soft); border-color: #c7d2fe; color: var(--brand-ink); }
.badge--success { background: var(--success-soft); border-color: #abefc6; color: #067647; }
.badge--warning { background: var(--warning-soft); border-color: #fedf89; color: var(--warning); }
.badge--danger { background: var(--danger-soft); border-color: #fecdca; color: var(--danger); }
.badge--info { background: var(--info-soft); border-color: #b2ddff; color: var(--info); }
.badge--neutral { background: #f2f4f7; border-color: #e4e7ec; color: #475467; }
.badge--mono { font-family: var(--font-mono); font-size: 11px; font-weight: 500; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------------------------------------------------------------- Tables */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid #eef0f4; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfd; }
.table .cell-strong { font-weight: 600; color: var(--ink); }
.table .cell-muted { color: var(--muted); }
.table .cell-actions { text-align: right; white-space: nowrap; }

/* ---------------------------------------------------------------- Detection */

.detection-panel { display: flex; flex-direction: column; gap: 12px; }
.detection-primary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border-radius: var(--radius);
  border: 1px solid #c7d2fe;
  background: linear-gradient(135deg, #eef2ff, #f5f3ff);
}
.detection-primary__icon { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 10px; background: #fff; display: grid; place-items: center; color: var(--brand-ink); border: 1px solid #dbe3ff; }
.detection-primary__name { font-weight: 650; font-size: 15px; }
.detection-primary__meta { color: var(--muted); font-size: 12px; }
.confidence { margin-left: auto; text-align: right; }
.confidence__value { font-weight: 700; font-size: 17px; color: var(--brand-ink); font-variant-numeric: tabular-nums; }
.confidence__label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }

.meter { height: 6px; border-radius: 999px; background: #e9ecf4; overflow: hidden; }
.meter__fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #6366f1, #8b5cf6); }
.meter--success .meter__fill { background: linear-gradient(90deg, #12b76a, #32d583); }
.meter--muted .meter__fill { background: #98a2b3; }

.candidate { padding: 9px 0; border-bottom: 1px dashed var(--line); }
.candidate:last-child { border-bottom: 0; }
.candidate__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.candidate__name { font-weight: 600; }
.candidate__score { color: var(--muted); font-variant-numeric: tabular-nums; }
.matched-tokens { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.token-pill { font-family: var(--font-mono); font-size: 10.5px; padding: 2px 6px; border-radius: 5px; background: #f2f4f7; border: 1px solid #e4e7ec; color: #475467; }
.detection-empty { color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- Editor workspace */

.tag-workspace { display: grid; grid-template-columns: minmax(0, 1.06fr) minmax(0, 0.94fr); gap: 20px; align-items: start; }
.tag-pane { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.editor-surface {
  background: var(--code-bg);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  overflow: hidden;
}
.editor-surface .CodeMirror,
.editor-surface .cm-editor { min-height: 340px; font-family: var(--font-mono); font-size: 12.5px; }
.code-fallback {
  width: 100%;
  min-height: 340px;
  padding: 14px 16px;
  border: 0;
  resize: vertical;
  background: var(--code-bg);
  color: var(--code-ink);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  tab-size: 2;
}
.code-fallback:focus { outline: none; }

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: #161b22;
  border-bottom: 1px solid #21262d;
  color: #8b949e;
  font-size: 12px;
}
.editor-toolbar__name { color: #c9d1d9; font-weight: 600; font-family: var(--font-mono); font-size: 11.5px; }
.editor-toolbar .tag { font-family: var(--font-mono); font-size: 10.5px; padding: 2px 7px; border-radius: 5px; background: #21262d; border: 1px solid #30363d; color: #8b949e; }

.preview-surface { background: #0f1420; }
.preview-toolbar { display: flex; align-items: center; gap: 8px; padding: 9px 13px; background: #131a2a; border-bottom: 1px solid #1e293b; color: #8fa3c4; font-size: 12px; }
.preview-toolbar .badge { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); color: #c7d2e4; }
.preview-frame-wrap {
  padding: 18px;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  background: repeating-conic-gradient(from 0deg, #111827 0% 25%, #0d1320 0% 50%) 0 0 / 22px 22px;
}
.preview-frame {
  width: 100%;
  min-height: 340px;
  border: 0;
  border-radius: 0; /* never mask/clip the creative's corners */
  background: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.preview-empty { color: #7b8aa8; text-align: center; font-size: 13px; padding: 40px 20px; }
.preview-default-size { width: 970px; max-width: 100%; height: 250px; }
.preview-phone { width: 320px; height: 568px; }
.preview-banner { width: 320px; height: 50px; }
.preview-large { width: 300px; height: 250px; }
.preview-square { width: 250px; height: 250px; }
.preview-natural { width: 100%; height: 340px; }

.macro-panel { display: flex; flex-direction: column; }
.macro-group + .macro-group { border-top: 1px solid var(--line); }
.macro-group__head { display: flex; align-items: center; gap: 8px; padding: 9px 14px; background: var(--surface-2); border-bottom: 1px solid #eef0f4; font-size: 12px; font-weight: 650; color: var(--ink-2); }
.macro-group__head .badge { margin-left: auto; }
.macro-row {
  display: grid;
  grid-template-columns: minmax(130px, 1.1fr) minmax(0, 1.4fr);
  gap: 10px 14px;
  padding: 10px 14px;
  align-items: center;
  border-bottom: 1px solid #f1f3f7;
}
.macro-row:last-child { border-bottom: 0; }
.macro-row:hover { background: #fcfcfe; }
.macro-meta { min-width: 0; }
.macro-token { display: block; font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; color: #3538cd; word-break: break-all; }
.macro-desc { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.macro-row .input { font-family: var(--font-mono); font-size: 12px; padding: 6px 9px; }
.macro-row input[data-macro-override] { background: #fefdf6; }
.macro-empty { padding: 22px 16px; text-align: center; color: var(--muted); font-size: 13px; }

.macro-value-wrap { position: relative; }
.macro-value-wrap .clear-override {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: none;
  color: var(--muted-2);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
}
.macro-value-wrap .clear-override:hover { color: var(--danger); }

/* ---------------------------------------------------------------- Emulators */

.emulator { display: flex; flex-direction: column; gap: 0; }
.emulator__stage { background: #0f1420; padding: 18px; }
.emulator__frame { width: 100%; min-height: 360px; border: 0; border-radius: 8px; background: #fff; }
.emulator__controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px; background: var(--surface-2); border-top: 1px solid var(--line); }
.emulator__controls .divider { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.event-log { max-height: 280px; overflow-y: auto; font-family: var(--font-mono); font-size: 11.5px; }
.event-log__row { display: grid; grid-template-columns: 72px minmax(120px, 170px) minmax(0, 1fr) 64px; gap: 10px; padding: 6px 12px; border-bottom: 1px solid #f1f3f7; align-items: baseline; }
.event-log__time { color: var(--muted-2); white-space: nowrap; }
.event-log__type { color: var(--brand-ink); font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.event-log__detail { color: var(--ink-2); overflow-wrap: anywhere; }
.event-log__status { text-align: right; font-size: 10.5px; }
.event-log__empty { padding: 18px; color: var(--muted); font-size: 12.5px; text-align: center; }

.vast-tree { display: flex; flex-direction: column; }
.vast-node { padding: 12px 16px; border-bottom: 1px solid #eef0f4; }
.vast-node:last-child { border-bottom: 0; }
.vast-node__title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.vast-node__sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.vast-list { display: flex; flex-direction: column; gap: 6px; margin-top: 9px; }
.vast-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); font-family: var(--font-mono); overflow-wrap: anywhere; }
.vast-item .badge { flex-shrink: 0; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- Misc */

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-xs); }
.stat-card__label { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--muted); }
.stat-card__value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.stat-card__meta { font-size: 12px; color: var(--muted); margin-top: 4px; }

.empty-state { text-align: center; padding: 44px 24px; }
.empty-state__icon { width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; margin: 0 auto 14px; background: var(--brand-soft); color: var(--brand-ink); border: 1px solid #dbe3ff; }
.empty-state h3 { font-size: 16px; margin-bottom: 6px; }
.empty-state p { color: var(--muted); max-width: 48ch; margin: 0 auto 16px; font-size: 13.5px; }

.tag-list { display: flex; flex-direction: column; }
.tag-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 18px;
  border-bottom: 1px solid #eef0f4;
  text-decoration: none;
  color: inherit;
}
.tag-row:last-child { border-bottom: 0; }
.tag-row:hover { background: #fafbfd; text-decoration: none; }
.tag-row__icon { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 9px; display: grid; place-items: center; background: #f2f4f7; color: #475467; border: 1px solid var(--line); }
.tag-row__body { min-width: 0; flex: 1; }
.tag-row__name { font-weight: 600; font-size: 13.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag-row__meta { display: flex; align-items: center; gap: 7px; margin-top: 3px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.tag-row__side { text-align: right; color: var(--muted); font-size: 12px; white-space: nowrap; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.search-field { position: relative; flex: 1; min-width: 200px; max-width: 380px; }
.search-field .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted-2); pointer-events: none; }
.search-field .input { padding-left: 33px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 14px; background: var(--surface); }
.tab {
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 550;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.is-active { color: var(--brand-ink); border-bottom-color: var(--brand); }

.section-title { font-size: 12px; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }

.divider { border: 0; border-top: 1px solid var(--line); margin: 0; }

.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 5px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--muted);
  box-shadow: 0 1px 0 var(--line-strong);
}

.copy-field { display: flex; gap: 6px; }
.copy-field .input { font-family: var(--font-mono); font-size: 12px; }

.help-callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--info-soft); border: 1px solid #b2ddff; color: #174ea6; font-size: 12.5px; }
.help-callout--warning { background: var(--warning-soft); border-color: #fedf89; color: #7a2e0e; }
.help-callout .icon { flex: 0 0 auto; margin-top: 1px; }

/* ---------------------------------------------------------------- Auth */

.auth-page .guest-main { align-items: center; }
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 18px;
  padding: 34px 32px 30px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.auth-card__brand { display: flex; align-items: center; gap: 11px; margin-bottom: 24px; }
.auth-card__brand .brand-mark { box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35); }
.auth-card__brand strong { font-size: 17px; letter-spacing: -0.01em; }
.auth-card__brand small { display: block; color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; margin-top: 1px; }
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-card > p { color: var(--muted); margin-bottom: 20px; font-size: 13.5px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card .btn { margin-top: 4px; }
.auth-card__badge { display: inline-flex; padding: 3px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-ink); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; margin-bottom: 12px; }
.auth-card__actions { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.auth-links { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--muted); }
.auth-links a { font-weight: 600; }
.auth-footnote { margin-top: 18px; text-align: center; color: #8da0bd; font-size: 12px; }

/* ---------------------------------------------------------------- Public share */

.public-body { background: #f5f7fb; }
.public-shell { min-height: 100vh; display: flex; flex-direction: column; }
.public-header { background: var(--navy); color: #c7d2e4; border-bottom: 1px solid rgba(255,255,255,.08); }
.public-header__inner { max-width: 1200px; margin: 0 auto; padding: 14px 24px; display: flex; align-items: center; gap: 14px; }
.public-header__brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 650; }
.public-header__brand .brand-mark { width: 30px; height: 30px; font-size: 11px; border-radius: 8px; }
.public-header__meta { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.public-main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 26px 24px 60px; }
.public-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.public-hero { padding: 24px; border-bottom: 1px solid var(--line); }
.public-hero h1 { font-size: 22px; }
.public-hero p { color: var(--muted); margin-top: 5px; }
.public-toolbar { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.public-preview { padding: 22px; background: #0f1420; }
.public-preview iframe { width: 100%; min-height: 360px; border: 0; border-radius: 8px; background: #fff; }
.public-footer { text-align: center; color: var(--muted); font-size: 12px; padding: 24px; }
.unlock-shell { max-width: 440px; margin: 8vh auto; }
.unlock-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 30px; box-shadow: var(--shadow-md); text-align: center; }
.unlock-card__icon { width: 46px; height: 46px; border-radius: 13px; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; margin: 0 auto 14px; }
.unlock-card h1 { font-size: 20px; }
.unlock-card p { color: var(--muted); margin: 6px 0 18px; }
.unlock-card form { display: flex; flex-direction: column; gap: 12px; text-align: left; }

/* ---------------------------------------------------------------- Admin macros grid */

.macros-grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.macros-grid th { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 650; text-align: left; padding: 9px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1; }
.macros-grid td { padding: 8px 12px; border-bottom: 1px solid #f1f3f7; vertical-align: middle; }
.macros-grid tbody tr:hover { background: #fbfcfe; }
.macros-grid .input { padding: 6px 9px; font-size: 12.5px; }
.macros-grid .token-cell { font-family: var(--font-mono); font-weight: 600; color: #3538cd; font-size: 12px; word-break: break-all; max-width: 240px; }
.macros-grid .description-cell { color: var(--muted); font-size: 12px; max-width: 280px; }
.macros-grid tr.is-inactive .token-cell { color: var(--muted-2); text-decoration: line-through; }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 12px 18px; display: flex; justify-content: flex-end; align-items: center; gap: 10px; z-index: 2; }
.admin-search { display: flex; gap: 8px; align-items: center; }

.chart-bars { display: flex; flex-direction: column; gap: 10px; }
.chart-bar { display: grid; grid-template-columns: 120px minmax(0, 1fr) 46px; gap: 10px; align-items: center; font-size: 12.5px; }
.chart-bar__label { color: var(--ink-2); font-weight: 550; }
.chart-bar__track { height: 8px; background: #eef0f4; border-radius: 999px; overflow: hidden; }
.chart-bar__fill { height: 100%; background: linear-gradient(90deg, #6366f1, #8b5cf6); border-radius: inherit; }
.chart-bar__value { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- Utilities */

.text-muted { color: var(--muted); }
.text-small { font-size: 12px; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 18px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.flex-1 { flex: 1; }
.full-width { width: 100%; }

/* ---------------------------------------------------------------- Responsive */

@media (max-width: 1200px) {
  .tag-workspace { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex: none; padding: 12px 14px; }
  .sidebar__brand { padding: 2px 6px 10px; }
  .sidebar__nav { flex-direction: row; flex-wrap: wrap; }
  .nav-link { padding: 7px 10px; }
  .nav-section, .sidebar__footer .user-chip { display: none; }
  .sidebar__footer { border-top: 0; padding-top: 6px; }
  .sidebar__footer .nav-link--button { width: auto; }
  .app-main { padding: 20px 16px 44px; }
  .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .page-header h1 { font-size: 22px; }
  .public-main { padding: 18px 14px 40px; }
  .stat-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .macro-row { grid-template-columns: 1fr; gap: 6px; }
  .event-log__row { grid-template-columns: 65px 90px minmax(0,1fr); }
  .event-log__status { display: none; }
  .card__body { padding: 14px; }
}

/* Flash dismissal */
.flash { transition: opacity 0.18s ease, transform 0.18s ease; }
.flash--leaving { opacity: 0; transform: translateY(-4px); }

/* Inline forms used by button_to helpers */
.inline-form { display: inline-flex; margin: 0; }
.page-actions form { margin: 0; }
.macro-bulk-form { margin: 0; }

/* Tag editor chrome */
.editor-actionbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  margin-bottom: 18px;
}
.editor-actionbar__status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.editor-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.editor-meta .field + .field { margin-top: 0; }
.preview-error {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 11px 14px;
  background: var(--danger-soft);
  color: #912018;
  border-bottom: 1px solid #fecdca;
  font-size: 12.5px;
}
.preview-error .icon { flex: 0 0 auto; margin-top: 1px; }
.preview-toolbar__note { font-size: 11px; color: #7b8aa8; white-space: nowrap; }
.macro-row .input.is-override { background: #fffcf2; border-color: #fdb022; }
.editor-surface .cm-editor { max-height: 540px; }
.editor-surface .cm-scroller { overflow: auto; font-family: var(--font-mono); }
.editor-surface .cm-editor.cm-focused { outline: none; }
.editor-surface .cm-gutters { background: #0d1117; border-right: 1px solid #21262d; color: #6e7681; }

@media (max-width: 900px) {
  .editor-meta { grid-template-columns: 1fr; }
  .preview-toolbar__note { display: none; }
}

/* Public share header */
.public-header__brand > span:last-child { display: flex; flex-direction: column; line-height: 1.15; }
.public-header__brand-sub {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8da0bd;
  font-weight: 500;
  margin-top: 1px;
}
#share-panel .card__body > .field + .divider { margin-top: 4px; }

/* VAST emulator */
#preview-panel.stack { gap: 18px; }
#vast-emulator .event-log { background: var(--surface); border-top: 1px solid var(--line); }
.vast-structure { padding: 0; }
.vast-item { min-width: 0; }
.vast-item .truncate { flex: 1; min-width: 0; }
.vast-node .chip-row { row-gap: 4px; }
.preview-frame-wrap { min-height: 0; }

/* MRAID emulator */
.preview-frame--mraid { max-width: 390px; min-height: 520px; }
#mraid-emulator .event-log { background: var(--surface); border-top: 1px solid var(--line); }
.event-log__status--api { color: var(--muted); }
.event-log__status--event { color: var(--brand-ink); }
.event-log__status--dry-run { color: var(--warning); }
.event-log__status--fired { color: var(--success); }
.event-log__status--error { color: var(--danger); }
#mraid-emulator .emulator-controls .select { width: auto; }

/* Accessible magnitude bars (single hue, labeled values, semantic table) */
.viz-bars { width: 100%; border-collapse: collapse; }
.viz-bar-row th {
  text-align: left;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink-2);
  padding: 9px 14px 9px 0;
  white-space: nowrap;
}
.viz-bar-row td { padding: 9px 0; vertical-align: middle; }
.viz-bar-cell { width: 100%; }
.viz-bar-track {
  height: 8px;
  background: #eef0f4;
  border-radius: 999px;
  overflow: hidden;
}
.viz-bar-fill {
  height: 100%;
  min-width: 2px;
  background: var(--brand);
  border-radius: 0 4px 4px 0;
  transition: background 0.12s ease;
}
.viz-bar-row:hover .viz-bar-track { background: #e4e7ec; }
.viz-bar-row:hover .viz-bar-fill { background: var(--brand-strong); }
.viz-bar-value {
  width: 56px;
  padding-left: 12px !important;
  text-align: right;
  color: var(--ink);
  font-weight: 600;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.stat-card__value { font-variant-numeric: normal; }

/* Size-aware creative preview stage */
.preview-toolbar { flex-wrap: wrap; row-gap: 6px; }
.preview-size-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: #8fa3c4;
}
.preview-toolbar .preview-size-control .select {
  width: auto;
  height: auto;
  padding: 3px 8px;
  font-size: 11.5px;
  color: #c7d2e4;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: none;
}
.preview-toolbar .preview-size-control .select option {
  color: #e6edf3;
  background: #111a2e;
}
.preview-sizer {
  position: relative;
  flex: 0 0 auto;
  max-width: 100%;
  margin: 0 auto;
  overflow: visible;
}
.preview-sizer .preview-frame {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  min-height: 0;
  height: auto;
  transform-origin: top left;
}
