/* Email Template Builder — app UI styles.
   (The email itself is styled inline by render.js.) */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e7e9ee;
  --text: #1b1f27;
  --muted: #667085;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: #c7d2fe;
  --accent-bg: #eef2ff;
  --danger: #dc2626;
  --warn: #b45309;
  --ok: #15803d;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.06), 0 4px 12px rgb(16 24 40 / 0.06);
  --gap: clamp(0.5rem, 0.4rem + 0.5vw, 1rem);
  --topbar-h: 56px;
  --nav-h: 56px;
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); overflow: hidden; }
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
[hidden] { display: none !important; }
.icon { display: block; flex: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 8px; top: -60px; z-index: 100; background: var(--accent); color: #fff;
  padding: 8px 12px; border-radius: 8px; text-decoration: none; transition: top 0.15s;
}
.skip-link:focus { top: 8px; }
.noscript { padding: 2rem; text-align: center; }

/* ---------- layout ---------- */
.app {
  display: grid; height: 100dvh;
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr);
}
.workspace {
  display: grid; min-height: 0;
  grid-template-columns: clamp(220px, 19vw, 290px) minmax(0, 1fr) clamp(270px, 24vw, 340px);
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: var(--gap); padding: 0 var(--gap);
  background: var(--surface); border-bottom: 1px solid var(--border); min-width: 0;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.logo { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: #fff; }
.project { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.project-name {
  min-width: 0; width: clamp(120px, 28vw, 320px); border: 1px solid transparent; background: transparent;
  padding: 6px 8px; border-radius: 8px; font-weight: 600;
}
.project-name:hover { border-color: var(--border); }
.project-name:focus { border-color: var(--accent); background: #fff; outline: none; box-shadow: 0 0 0 3px var(--accent-bg); }
.save-status { font-size: 12px; color: var(--muted); white-space: nowrap; }
.save-status[data-state="error"] { color: var(--danger); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.btn-group { display: flex; }

.btn, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
  padding: 7px 12px; font-weight: 550; transition: background 0.12s, border-color 0.12s;
}
.btn:hover:not(:disabled), .icon-btn:hover:not(:disabled) { background: var(--surface-2); border-color: #cfd3da; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.icon-btn { padding: 7px; border-color: transparent; background: transparent; color: var(--muted); }
.icon-btn:hover:not(:disabled) { color: var(--text); }
.icon-btn.danger:hover:not(:disabled) { color: var(--danger); }
.mini {
  border: 1px solid var(--border); background: var(--surface); border-radius: 6px;
  padding: 3px 8px; font-size: 12px; font-weight: 550;
}
.mini:hover:not(:disabled) { background: var(--surface-2); }
.mini.danger { color: var(--danger); }

/* ---------- panels ---------- */
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.panel-left { border-right: 1px solid var(--border); }
.panel-right { border-left: 1px solid var(--border); }
.tabs { display: flex; gap: 2px; padding: 8px 8px 0; border-bottom: 1px solid var(--border); }
.tabs [role="tab"] {
  flex: 1; border: 0; background: transparent; padding: 9px 8px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs [role="tab"][aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.pane { flex: 1; min-height: 0; overflow-y: auto; padding: var(--gap); overscroll-behavior: contain; }
.pane[hidden] { display: none; }


/* ---------- forms ---------- */
.field { display: grid; gap: 5px; min-width: 0; }
input[type="text"], input[type="url"], input[type="number"], select, textarea {
  width: 100%; min-width: 0; border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: 7px 9px;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px rgb(220 38 38 / 0.12); }
.seg { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg label, .seg button { flex: 1; text-align: center; }
.seg label input { position: absolute; opacity: 0; pointer-events: none; }
.seg label span, .seg button { display: block; padding: 6px 8px; font-size: 13px; cursor: pointer; border: 0; background: transparent; }
.seg label + label span, .seg button + button { border-left: 1px solid var(--border); }
.seg label:has(input:checked) span, .seg button[aria-pressed="true"] { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.seg label:has(input:focus-visible) span { outline: 2px solid var(--accent); outline-offset: -2px; }
.seg-buttons button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.field-inline { display: block; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 13px; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 34px; height: 20px; border-radius: 999px; background: #d0d5dd; position: relative; transition: background 0.15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgb(0 0 0 / 0.3); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }


/* image field / library */
.image-field { display: grid; gap: 8px; }
.img-preview-wrap { display: grid; gap: 6px; }
.img-preview {
  display: grid; place-items: center; min-height: 96px; max-height: 180px; overflow: hidden;
  border: 1px dashed var(--border); border-radius: 8px; background:
    repeating-conic-gradient(#f1f2f4 0% 25%, #fff 0% 50%) 0 0 / 14px 14px;
}
.img-preview img { max-width: 100%; max-height: 180px; display: block; }
.img-preview:empty::before { content: "No preview"; color: var(--muted); font-size: 12px; }
.img-status { font-size: 12px; color: var(--muted); }
.img-preview-wrap[data-state="error"] .img-status { color: var(--danger); }
.img-preview-wrap[data-state="ok"] .img-status { color: var(--ok); }
.lib-form { display: grid; gap: 12px; }
.lib-buttons { display: grid; gap: 6px; }
.lib-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 18px 0 8px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.lib-empty { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; padding: 8px 0; }
.lib-item { border: 1px solid var(--border); border-radius: 8px; padding: 6px; display: grid; gap: 6px; background: var(--surface); cursor: grab; }
.lib-thumb { aspect-ratio: 4 / 3; display: grid; place-items: center; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.lib-thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-fail { font-size: 11px; color: var(--danger); }
.lib-name { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-actions { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- stage ---------- */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #e9ebef; }
.stage-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; padding: 8px var(--gap); background: var(--surface); border-bottom: 1px solid var(--border); }
.stage-scroll { position: relative; flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }

.canvas { min-height: 100%; padding: clamp(0.5rem, 2vw, 1.5rem); }
.canvas-page {
  margin-inline: auto; width: 100%; max-width: calc(var(--em-width, 600px) + 24px);
  background: var(--em-page-bg, #f3f4f6); padding: var(--em-outer, 24px) 12px; border-radius: 6px;
  box-shadow: var(--shadow); transition: max-width 0.2s;
}
.canvas-content { max-width: var(--em-width, 600px); margin-inline: auto; background: var(--em-content-bg, #fff); }
[data-device="mobile"] .canvas-page { max-width: 375px; padding-inline: 0; }

.cb { position: relative; outline: 2px solid transparent; outline-offset: -2px; cursor: pointer; }
.cb:hover { outline-color: var(--accent-soft); }
.cb.is-selected { outline-color: var(--accent); }
.cb:focus-visible { outline: 2px solid var(--accent); box-shadow: inset 0 0 0 4px var(--accent-bg); }
.cb.is-dragging { opacity: 0.4; }
.cb.drop-before::before, .cb.drop-after::after {
  content: ""; position: absolute; left: 0; right: 0; height: 4px; background: var(--accent); z-index: 4; border-radius: 2px;
}
.cb.drop-before::before { top: -2px; }
.cb.drop-after::after { bottom: -2px; }
.cb-toolbar {
  position: absolute; top: 6px; right: 6px; z-index: 3; display: none; gap: 2px; padding: 3px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.cb:hover .cb-toolbar, .cb.is-selected .cb-toolbar, .cb:focus-within .cb-toolbar { display: flex; }
.tb-btn {
  display: grid; place-items: center; width: 28px; height: 28px; border: 0; background: transparent;
  color: var(--muted); border-radius: 6px; padding: 0;
}
.tb-btn:hover:not(:disabled) { background: var(--accent-bg); color: var(--accent); }
.tb-btn.danger:hover:not(:disabled) { background: #fee2e2; color: var(--danger); }
.cb-handle { cursor: grab; }
.only-narrow { display: none; }
.canvas-empty { padding: 56px 24px; text-align: center; display: grid; gap: 8px; justify-items: center; color: var(--muted); font-family: inherit; }
.canvas-empty strong { color: var(--text); }
.is-drop-empty .canvas-empty { background: var(--accent-bg); outline: 2px dashed var(--accent); outline-offset: -8px; }

/* inside the rendered email (canvas only) */
.em-canvas table { border-collapse: collapse; }
.em-canvas img { max-width: 100%; }
.em-img-empty, .em-img-fail {
  margin: 0; padding: 36px 16px; text-align: center; font: 13px -apple-system, "Segoe UI", sans-serif;
  color: #667085; background: repeating-linear-gradient(135deg, #f4f5f7 0 10px, #eceef2 10px 20px);
  border: 1px dashed #c4c9d2;
}
.em-img-fail { color: #b42318; }

/* preview */
.preview { display: none; height: 100%; padding: clamp(0.5rem, 2vw, 1.5rem); }
.preview iframe { display: block; border: 0; background: #fff; height: 100%; width: 100%; margin-inline: auto; border-radius: 6px; box-shadow: var(--shadow); }
[data-mode="preview"] .canvas { display: none; }
[data-mode="preview"] .preview { display: block; }
[data-mode="preview"] .stage-scroll { overflow: hidden; }
[data-device="mobile"] .preview iframe { width: 375px; max-width: 100%; }

/* ---------- dialogs ---------- */
dialog {
  width: min(680px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 20px; border: 0;
  border-radius: 14px; box-shadow: 0 20px 50px rgb(16 24 40 / 0.3); background: var(--surface); color: var(--text);
}
dialog.wide { width: min(860px, calc(100vw - 24px)); }
dialog::backdrop { background: rgb(16 24 40 / 0.45); }
dialog[open] { display: grid; gap: 12px; align-content: start; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-head h2 { font-size: 18px; }
.dialog-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: 12px; }
.tpl-card { height: 100%; align-content: start; display: grid; gap: 4px; width: 100%; text-align: left; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.tpl-card:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.tpl-card small { color: var(--muted); font-size: 12px; }
.tpl-frame { display: block; height: 190px; overflow: hidden; border-radius: 6px; background: #f3f4f6; pointer-events: none; margin-bottom: 4px; }
.tpl-thumb { width: 600px; height: 760px; border: 0; transform: scale(0.29); transform-origin: top left; background: #fff; display: block; }
.tpl-frame { position: relative; }
.tpl-frame .tpl-thumb { margin-left: calc(50% - 87px); }
.proj-list { display: grid; gap: 8px; max-height: 45dvh; overflow: auto; }
.proj-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.proj-info { display: grid; min-width: 0; }
.proj-info small { color: var(--muted); }
.proj-actions { display: flex; gap: 6px; }
.badge { margin-left: 8px; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.warn-box { padding: 10px 12px; border-radius: 8px; background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; font-size: 13px; }
.warnings { display: grid; gap: 6px; }
.warnings li { font-size: 13px; padding: 7px 10px; border-radius: 8px; border-left: 3px solid; }
.warn-warn { background: #fffbeb; border-color: #f59e0b; color: #92400e; }
.warn-info { background: #eff6ff; border-color: #60a5fa; color: #1e40af; }
.warn-ok { background: #f0fdf4; border-color: #22c55e; color: #166534; }
#export-code {
  width: 100%; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre; overflow: auto;
  background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 12px; resize: vertical; min-height: 220px;
}

/* ---------- export + inbox ---------- */
.subject-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.subject-row span { color: var(--muted); }
.subject-row strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject-row strong:empty::before { content: "Not set — add one in Email settings"; color: var(--muted); font-weight: 400; }
.checklist li::before { flex: none; font-weight: 700; width: 1em; text-align: center; }
.checklist .warn-warn::before { content: "!"; }
.checklist .warn-info::before { content: "i"; }
.checklist .warn-pass { background: transparent; border-color: #86efac; color: var(--muted); }
.checklist .warn-pass::before { content: "✓"; color: var(--ok); }
#export-text.plain { background: #fff; color: var(--text); border: 1px solid var(--border); white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
#export-dialog textarea { width: 100%; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; border-radius: 10px; padding: 12px; resize: vertical; min-height: 200px; }
.send-test { display: grid; gap: 6px; border-top: 1px solid var(--border); padding-top: 4px; }
.send-row { display: flex; gap: 8px; }
.send-row input { flex: 1; }
.is-empty { font-style: italic; opacity: 0.7; }
.inbox-counts .over { color: var(--warn); font-weight: 600; }
.field-note { grid-column: span 2; }

/* ---------- toasts ---------- */
#toasts { position: fixed; z-index: 200; inset: auto auto 20px 50%; margin: 0; padding: 0; border: 0; background: transparent; color: inherit; overflow: visible; transform: translateX(-50%); display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 24px); pointer-events: none; }
#toasts:not(:popover-open):empty { display: none; }
.toast { background: #101828; color: #fff; padding: 9px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13.5px; animation: pop 0.18s ease-out; }
.toast-error { background: #b42318; }
.toast-warn { background: #b45309; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }

.mobile-nav { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .workspace { grid-template-columns: 210px minmax(0, 1fr) 270px; }
  .brand-name { display: none; }
}

@media (max-width: 1023px) {
  .app { grid-template-rows: var(--topbar-h) minmax(0, 1fr) var(--nav-h); }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .panel, .stage { display: none; }
  .app[data-view="blocks"] .panel-left,
  .app[data-view="settings"] .panel-right,
  .app[data-view="canvas"] .stage { display: flex; }
  .panel { border: 0; }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-nav button {
    display: grid; justify-items: center; align-content: center; gap: 2px; border: 0; background: transparent;
    font-size: 12px; font-weight: 600; color: var(--muted);
  }
  .mobile-nav button[aria-pressed="true"] { color: var(--accent); }
  .only-narrow { display: grid; }
  .cb-toolbar { display: flex; opacity: 0.0; pointer-events: none; }
  .cb.is-selected .cb-toolbar { opacity: 1; pointer-events: auto; }
  .cb-handle { display: none; }
  .tb-btn { width: 36px; height: 36px; }
  .lib-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  #toasts { inset-block-end: calc(var(--nav-h) + 12px); }
}

@media (max-width: 720px) {
  .btn-label { display: none; }
  .btn { padding: 7px 9px; }
  .save-status { display: none; }
  .project-name { width: 100%; }
  .project { flex: 1; }
  .topbar-actions { gap: 4px; }
  .stage-bar { gap: 6px; padding: 6px; }
  .tpl-thumb { transform: scale(0.29); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ================= simplified UI (compact panels, accordions) ================= */
.help { font-size: 12px; color: var(--muted); }
.help.error { color: var(--danger); }
.pane-help { margin-bottom: 8px; }

/* top bar: quiet, one primary action */
.topbar .btn:not(.btn-primary) { border-color: transparent; background: transparent; color: var(--muted); }
.topbar .btn:not(.btn-primary):hover { background: var(--surface-2); color: var(--text); }
.topbar .icon-btn { border-color: transparent; }
.stage-bar { padding: 6px var(--gap); gap: 8px; }
.stage-bar .seg { border-color: transparent; background: var(--bg); padding: 2px; border-radius: 9px; }
.stage-bar .seg button { border: 0 !important; border-radius: 7px; padding: 4px 10px; font-size: 13px; }
.stage-bar .seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(16 24 40 / 0.1); }

/* palette: compact icon tiles */
.palette { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.palette-item {
  display: grid; justify-items: center; gap: 6px; padding: 12px 6px 10px; width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: 12.5px; font-weight: 550;
}
.palette-item:hover { border-color: var(--accent-soft); background: var(--accent-bg); color: var(--accent-strong); }
.pi-icon { color: var(--accent); display: grid; place-items: center; }

/* panels */
.pane { padding: 4px var(--gap) var(--gap); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0 6px; }
.panel-title { display: flex; align-items: center; gap: 8px; color: var(--accent); }
.panel-title h2 { font-size: 14px; font-weight: 650; color: var(--text); }
.panel-actions { display: flex; }
.empty-note { padding: 28px 8px; display: grid; gap: 6px; text-align: center; }
.empty-note p:first-child { font-weight: 600; }

/* accordion sections */
.group { border-bottom: 1px solid var(--border); }
.group:last-child { border-bottom: 0; }
.group > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 2px; cursor: pointer;
  list-style: none; font-weight: 600; font-size: 13.5px; user-select: none;
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary::after {
  content: ""; width: 7px; height: 7px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg) translateY(-2px); transition: transform 0.15s; flex: none;
}
.group[open] > summary::after { transform: rotate(-135deg); }
.group > summary:hover { color: var(--accent-strong); }
.group > summary:focus-visible { outline-offset: -2px; border-radius: 6px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; padding: 2px 2px 16px; }
.fields .field { grid-column: span 2; }
.fields .field.half { grid-column: span 1; }

/* fields */
.field > label { font-size: 12px; font-weight: 550; color: var(--muted); }
input[type="text"], input[type="url"], input[type="number"], input[type="email"], select, textarea { padding: 6px 8px; font-size: 13.5px; }
.label-row { display: flex; align-items: center; gap: 6px; }
.info-btn {
  width: 16px; height: 16px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: var(--surface);
  color: var(--muted); font: italic 600 10px/1 Georgia, serif; display: inline-grid; place-items: center;
}
.info-btn:hover, .info-btn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-bg); }

/* range: label + value on one line, slider underneath */
.field-range { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 6px; }
.field-range > .range-row { display: contents; }
.field-range > label, .field-range > .label-row { grid-area: 1 / 1; }
.field-range .num { grid-area: 1 / 2; width: 60px; padding: 3px 6px; text-align: right; font-size: 12.5px; }
.field-range input[type="range"] { grid-area: 2 / 1 / 3 / 3; width: 100%; accent-color: var(--accent); margin: 0; }
.field-range .unit { display: none; }
.field-range > .field-help { grid-area: 3 / 1 / 4 / 3; }
.range-row { display: flex; align-items: center; gap: 8px; }
.range-row .num { width: 68px; flex: none; }
.field.half .range-row .num { width: 100%; }
.unit { color: var(--muted); font-size: 12px; }

/* colours: swatch + hex in one compact pill */
.color-row { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 8px; padding: 3px 4px 3px 3px; background: #fff; }
.color-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.color-row input[type="color"] { width: 26px; height: 26px; padding: 0; border: 0; border-radius: 6px; background: none; flex: none; cursor: pointer; }
.color-row .hex { flex: 1; min-width: 0; border: 0; box-shadow: none !important; padding: 3px 2px; font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: transparent; }
.color-row .mini { border: 0; color: var(--muted); padding: 2px 6px; }

/* image field */
.img-preview { min-height: 72px; max-height: 120px; }
.img-preview img { max-height: 120px; }

/* inbox preview */
.inbox { margin: 0; min-width: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); padding: 8px 10px; display: grid; gap: 6px; overflow: hidden; }
.inbox-row { display: flex; gap: 8px; align-items: flex-start; min-width: 0; }
.inbox-dot { width: 7px; height: 7px; margin-top: 6px; border-radius: 50%; background: var(--accent); flex: none; }
.inbox-main { min-width: 0; flex: 1; font-size: 12.5px; line-height: 1.35; }
.inbox-top { display: flex; justify-content: space-between; gap: 8px; min-width: 0; }
.inbox-top span { color: var(--muted); font-size: 11.5px; flex: none; }
.inbox-subject, .inbox-pre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.inbox-subject { font-weight: 600; }
.inbox-pre { color: var(--muted); }
.inbox-counts { font-size: 11.5px; }

/* export checklist: problems first, passes folded away */
.checklist { display: grid; gap: 4px; max-height: 26dvh; overflow: auto; }
.checklist li { display: flex; gap: 8px; font-size: 13px; padding: 5px 10px; border-radius: 8px; border-left: 3px solid; }
.checklist li::before { flex: none; font-weight: 700; width: 1em; text-align: center; }
.checklist .warn-warn::before { content: "!"; }
.checklist .warn-info::before { content: "i"; }
.checklist li.warn-pass::before { content: "✓"; color: var(--ok); }
.checklist li.warn-pass { background: transparent; border-color: transparent; color: var(--muted); padding: 2px 10px; }
.checklist li.all-good { color: var(--ok); font-weight: 550; }
.checklist li.passes { display: block; border: 0; padding: 0; background: transparent; }
.checklist li.passes::before { content: none; }
.checklist .passes summary { cursor: pointer; font-size: 12.5px; color: var(--muted); padding: 2px 10px; }
.checklist .passes ul { display: grid; gap: 2px; margin-top: 4px; }
