/* Signature Studio — app styling (light theme, matches the Custom Esignature look) */

:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --line: #e7eaf1;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --blue: #2f7df6;
  --blue-soft: #eaf2ff;
  --grad: linear-gradient(135deg, #4b93ff, #2f7df6);
  --admin-line: #dfe8fb;
  --radius: 14px;
  --card-r: 20px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
/* app shell: every scroll area is internal (#panelInner, #mockWrap), so the
 * window itself must never scroll — stray focus or overflow can't yank the page */
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  /* soft blue gradient washes over the base — the CE "overlay" look */
  background:
    radial-gradient(1100px 520px at 88% -8%, rgba(75, 147, 255, .10), transparent 60%),
    radial-gradient(900px 520px at -12% 108%, rgba(124, 140, 255, .08), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-size: 14px;
}
button { font: inherit; cursor: pointer; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 15px; margin: 0; }

/* three floating white cards on the wash */
#app { display: flex; height: 100vh; overflow: hidden; padding: 14px; gap: 14px; }
#sidebar, #panel, #preview {
  border: 1px solid var(--line); border-radius: var(--card-r);
  background: var(--panel); box-shadow: var(--shadow);
}

/* ============ sidebar ============ */
#sidebar {
  width: 210px; flex: 0 0 210px;
  display: flex; flex-direction: column;
  padding: 18px 12px 14px;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 2px 4px 20px; }
.brand-mark { font-size: 24px; }
.brand-name { font-weight: 800; font-size: 13px; letter-spacing: .12em; line-height: 1.25; white-space: nowrap; }
.brand-name small { font-weight: 500; font-size: 8px; letter-spacing: .26em; color: var(--ink-3); }
.admin-switch { margin-left: auto; flex-direction: column; gap: 3px; align-items: center; }
.admin-switch .knob { width: 30px; height: 17px; }
.admin-switch .knob::after { width: 11px; height: 11px; }
.admin-switch input:checked + .knob::after { left: 16px; }
.adm-lbl { font-size: 8px; font-weight: 800; letter-spacing: .14em; color: var(--ink-2); }

#tabs { display: flex; flex-direction: column; gap: 5px; }
.tab {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border: 1px solid transparent; border-radius: 12px;
  background: none; color: var(--ink-2); text-align: left; font-weight: 600;
}
.tab-ic {
  width: 30px; height: 30px; border-radius: 9px; flex: 0 0 auto;
  background: var(--blue-soft); color: var(--blue);
  display: inline-flex; align-items: center; justify-content: center;
}
.tab:hover { background: #f7f9fd; }
.tab.active {
  background: linear-gradient(135deg, #eef4ff, #e9efff);
  border-color: #cfe1ff; color: var(--ink);
}
.tab.active .tab-ic { background: var(--grad); color: #fff; box-shadow: 0 4px 10px rgba(47, 125, 246, .35); }

/* back to the dashboard (the account landing page) */
.dash-link {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  margin: 10px 4px 0; padding: 6px 10px; border-radius: 9px;
  color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 12px;
}
.dash-link:hover { background: #f3f8ff; color: #1d5fd0; }

/* admin block — gated by the brand toggle, styled as its own gradient card */
body.client-mode .admin-only { display: none !important; }
/* editor opened from the dashboard (?view=client): client view is enforced,
 * so the admin switch itself is hidden too */
body.forced-client .admin-switch { display: none !important; }
.sidebar-foot { margin-top: auto; position: relative; }
.sidebar-foot.admin-only {
  border: 1px solid var(--admin-line); border-radius: 16px; padding: 14px 12px 12px;
  background: linear-gradient(180deg, #f8fbff, #f1f6ff);
}
.admin-tag {
  position: absolute; top: -9px; left: 12px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff; font-size: 9px; font-weight: 800;
  letter-spacing: .16em; padding: 3px 10px; border-radius: 999px;
  box-shadow: 0 4px 10px rgba(47, 125, 246, .35);
}
.foot-label { font-size: 11px; color: var(--ink-3); margin-bottom: 6px; padding-left: 2px; }
#folderSelect, #sigSelect { width: 100%; border-radius: 10px; border-color: var(--admin-line); }
.sig-actions { display: flex; gap: 5px; margin-top: 10px; }
.sig-actions button {
  flex: 1; border: 1px solid var(--admin-line); background: #fff; border-radius: 10px;
  padding: 7px 0; color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.sig-actions button:hover { background: var(--blue-soft); color: var(--blue); border-color: #cfe1ff; }
#sigDel:hover { background: #fef2f2; color: #dc2626; border-color: #fecaca; }

/* ============ control panel ============ */
#panel {
  width: 440px; flex: 0 0 440px;
  overflow: hidden;
}
#panelInner { height: 100%; overflow-y: auto; padding: 22px 24px 60px; }

.panel-title { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.panel-title h2 { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.sec-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; }
.sec-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 9px;
  background: var(--blue-soft); color: var(--blue); flex: 0 0 auto;
}
.sec-chip.big { width: 36px; height: 36px; border-radius: 11px; }
.section {
  border-top: 1px solid var(--line);
  margin-top: 22px; padding-top: 18px;
}
.section:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }

.pill {
  background: var(--blue); color: #fff; font-size: 11px; font-weight: 600;
  border-radius: 999px; padding: 4px 10px; margin-left: auto;
}
.hint { color: var(--ink-3); font-size: 11.5px; font-weight: 400; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; }
.row-label { font-weight: 600; font-size: 13px; }
.row-label .hint { display: block; }
.row-ctl { display: flex; align-items: center; gap: 8px; }

.field-label { font-weight: 600; font-size: 13px; margin: 12px 0 6px; }
.field-block { margin-bottom: 4px; }
.field-line { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.field-label-row { display: flex; align-items: center; gap: 8px; margin: 12px 0 6px; }

.txt {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 9px;
  font: inherit; color: var(--ink); background: #fff;
}
.txt:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 125, 246, .12); }
.txt.small-lbl { width: 110px; flex: 0 0 110px; }
.txt.search { margin-bottom: 10px; }

.sel {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; font: inherit; font-size: 12.5px; color: var(--ink);
}

.style-strip { display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.mini {
  width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; color: var(--ink-2); font-size: 12px; line-height: 1;
}
.mini.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.color {
  width: 26px; height: 26px; padding: 2px; border: 1px solid var(--line);
  border-radius: 7px; background: #fff;
}

/* position:relative is load-bearing: the visually-hidden checkbox below is
 * absolutely positioned, and without a positioned label it resolves against
 * the PAGE — extending the document with phantom scroll space and yanking the
 * window to the bottom when a toggle click focuses it (real bug). */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; position: relative; }
.switch-txt { font-size: 10px; color: var(--ink-3); letter-spacing: .04em; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; } /* focusable, invisible */
.switch input:focus-visible + .knob { box-shadow: 0 0 0 3px rgba(47, 125, 246, .45); }
.switch .knob {
  width: 40px; height: 22px; border-radius: 999px; background: #d8dee9; position: relative;
  transition: background .18s;
}
.switch .knob::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: left .18s;
}
.switch input:checked + .knob { background: var(--blue); box-shadow: 0 0 10px rgba(47, 125, 246, .55); }
.switch input:checked + .knob::after { left: 21px; }

.slider-wrap { display: inline-flex; align-items: center; gap: 10px; width: 200px; }
.slider-wrap input[type=range] { flex: 1; accent-color: var(--blue); }
.slider-val { font-size: 12px; color: var(--ink-2); min-width: 38px; text-align: right; }

.ghost-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 9px 16px; font-weight: 600; color: var(--ink); margin-top: 10px;
}
.ghost-btn:hover { background: #f7f9fd; }
.ghost-btn.sm { padding: 5px 10px; font-size: 12px; margin: 0; }
.primary {
  border: 0; border-radius: 10px; padding: 9px 18px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #4b93ff, #2f7df6);
  box-shadow: 0 0 0 4px rgba(47, 125, 246, .18), 0 6px 16px rgba(47, 125, 246, .35);
}
.primary.big { padding: 12px 22px; font-size: 15px; }
.primary:hover { filter: brightness(1.05); }

.del { border: 0; background: none; font-size: 13px; opacity: .55; }
.del:hover { opacity: 1; }

.contact-head { display: flex; gap: 8px; font-weight: 600; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }
.contact-head span:first-child { width: 110px; flex: 0 0 110px; }
.contact-line { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.contact-line .sel { flex: 0 0 auto; }
.contact-line .txt:not(.small-lbl) { flex: 1 1 90px; min-width: 70px; }
.field-line .txt { flex: 1 1 auto; min-width: 80px; }

/* chips */
.chips { display: inline-flex; gap: 8px; align-items: center; }
.chips.wrap { flex-wrap: wrap; max-width: 240px; }
.chip {
  position: relative;
  min-width: 34px; height: 34px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 9px; background: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink); font-weight: 600; font-size: 12.5px;
}
.chip.selected { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 125, 246, .15); }
.chip.selected::after {
  content: '✓'; position: absolute; top: -7px; right: -7px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--blue); color: #fff; font-size: 9px; line-height: 15px; text-align: center;
}
.chip[disabled] { opacity: .35; pointer-events: none; }
.chip.shape svg { color: var(--ink); }
.chip.corner i { display: block; width: 20px; height: 14px; border: 2px solid var(--ink); }
.aa.aa-soft { background: #f1f5f9; }
.aa.aa-outline { border: 2px solid var(--ink); }
.aa.aa-solid { background: var(--ink); color: #fff; }
.aa.aa-ghost { color: var(--ink); font-style: italic; }

/* icon picker */
.icon-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.icon-cell {
  position: relative; aspect-ratio: 1; border: 1px solid transparent; border-radius: 8px;
  background: none; color: var(--ink-2); display: flex; align-items: center; justify-content: center;
}
.icon-cell:hover { background: #f2f5fb; }
.icon-cell.on { color: var(--ink); }
.icon-cell .check {
  display: none; position: absolute; top: -3px; right: -3px;
  width: 14px; height: 14px; border-radius: 50%; background: var(--blue); color: #fff;
  font-size: 9px; font-style: normal; line-height: 14px; text-align: center;
}
.icon-cell.on .check { display: block; }
.url-list { margin-top: 12px; }
.url-line { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.url-ic { color: var(--ink-2); flex: 0 0 18px; display: inline-flex; }

/* button presets / list */
.preset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.preset {
  background: var(--ink); color: #fff; border: 0; border-radius: 6px;
  padding: 9px 6px; font-size: 12px; font-weight: 600;
}
.preset:hover { background: #1e293b; }
.btn-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.btn-chip {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  border: 1px dashed var(--line); border-radius: 10px; padding: 8px 26px 8px 12px;
  font-size: 12.5px; cursor: pointer; background: #fff;
}
.btn-chip.selected { border: 1px solid var(--blue); box-shadow: 0 0 0 3px rgba(47, 125, 246, .12); }
.btn-chip i { color: var(--blue); font-style: normal; }
.btn-chip b { color: var(--ink-3); font-weight: 600; }
.btn-chip .x {
  position: absolute; top: -7px; right: -7px; width: 16px; height: 16px;
  border-radius: 50%; border: 0; background: var(--ink); color: #fff; font-size: 10px; line-height: 1;
}
.btn-editor { border: 1px dashed var(--line); border-radius: 12px; padding: 12px 14px; }

/* upload zone */
.drop-zone {
  border: 1.5px dashed #c9d6ef; border-radius: 12px; background: #fbfcff;
  min-height: 120px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: border-color .15s, background .15s; padding: 10px;
}
.drop-zone:hover, .drop-zone.drag { border-color: var(--blue); background: var(--blue-soft); }
.dz-empty { text-align: center; color: var(--ink-3); font-size: 12px; line-height: 1.6; }
.dz-empty b { color: var(--ink-2); }
.dz-thumb { max-height: 130px; max-width: 100%; border-radius: 8px; }
.file-chip {
  display: flex; align-items: center; gap: 8px;
  background: #eef1f7; border-radius: 9px; padding: 9px 12px; margin-top: 8px; font-size: 12.5px;
}
.file-chip .ok { color: var(--blue); }
.file-chip .fn { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .fs { color: var(--ink-3); }
.file-chip .del { margin-left: auto; }

/* layout cards — CE style: labelled list, gradient selected state, check overlay */
.layout-grid { display: flex; flex-direction: column; gap: 20px; }
.lay-label {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 13px; color: var(--ink-2); margin-bottom: 8px;
}
.ai-badge {
  /* deeper blue than --grad so the white 10.5px text passes WCAG AA (4.5:1) */
  background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff; font-size: 10.5px; font-weight: 700;
  padding: 3px 11px; border-radius: 999px; letter-spacing: .01em;
  box-shadow: 0 3px 8px rgba(47, 125, 246, .3);
}
.layout-card {
  position: relative; width: 100%;
  border: 1px solid var(--line); border-radius: 16px; background: #fff;
  padding: 8px; text-align: left; display: block;
  transition: border-color .15s, box-shadow .15s;
}
.layout-card:hover { border-color: #c9d6ef; box-shadow: 0 8px 20px rgba(15, 23, 42, .07); }
.layout-card.selected {
  border-color: var(--blue);
  background: linear-gradient(135deg, #f2f7ff, #ecf0ff 55%, #eef2ff);
  box-shadow: 0 0 0 3px rgba(47, 125, 246, .16), 0 10px 26px rgba(47, 125, 246, .12);
}
.layout-card.selected::after {
  content: '✓'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--grad); color: #fff; font-size: 20px; font-weight: 700;
  line-height: 44px; text-align: center;
  box-shadow: 0 0 0 7px rgba(255, 255, 255, .6), 0 10px 24px rgba(47, 125, 246, .45);
}
/* ============ preview column ============ */
#preview { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.preview-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 26px 10px;
}
.preview-head h2 { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.preview-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.sel-pill {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
  padding: 3px 6px 3px 12px; box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.sel-pill #clientGlyph { display: inline-flex; align-items: center; }
.sel-pill #clientGlyph svg { width: 19px; height: 15px; }
.gl { font-weight: 800; font-size: 14px; font-style: normal; }
.gl-ol { color: #0f6cbd; }
.gl-ap { color: #333; }
.sel.bare { border: 0; background: transparent; padding: 6px 2px; font-weight: 600; border-radius: 8px; }
.sel.bare:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.seg {
  display: inline-flex; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; padding: 3px; box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.seg button {
  display: inline-flex; align-items: center; gap: 7px;
  border: 0; background: none; padding: 7px 14px; border-radius: 9px;
  color: var(--ink-2); font-size: 12.5px; font-weight: 600;
}
.seg button.active { background: var(--blue-soft); color: #1d5fd0; font-weight: 700; }

#mockWrap { flex: 1; overflow: auto; padding: 18px 28px; }
#mockWrap.phone-mode { display: flex; }
#mockWrap.phone-mode .phone-frame { margin: 0 auto; } /* safe centering: never clips when overflowing */

.preview-foot { display: flex; justify-content: flex-end; gap: 12px; padding: 12px 28px; }
.preview-foot .ghost-btn { margin: 0; }
#preview footer { padding: 6px 20px 16px; color: var(--ink-2); font-size: 12px; text-align: center; }
.foot-links { margin-top: 4px; }
.foot-links a { color: var(--ink-2); text-decoration: none; font-weight: 500; margin: 0 8px; }
.foot-links a:hover { color: var(--blue); }
.foot-links i { color: #cbd5e1; font-style: normal; }

/* browser mock */
.browser-frame {
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); overflow: hidden; max-width: 860px; margin: 0 auto;
}
.b-top { display: flex; align-items: center; gap: 12px; background: #dfe3ea; padding: 8px 14px 0; }
.dots { display: inline-flex; gap: 6px; padding-bottom: 8px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; }
.dots .r { background: #ff5f57; } .dots .y { background: #febc2e; } .dots .g { background: #28c840; }
.b-tab {
  background: #f6f7f9; border-radius: 10px 10px 0 0; padding: 7px 14px;
  font-size: 11.5px; color: var(--ink-2); max-width: 280px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.b-tab b { margin-left: 8px; font-weight: 400; }
.b-plus { color: var(--ink-2); padding-bottom: 6px; }
.b-url {
  display: flex; align-items: center; gap: 12px; background: #f6f7f9;
  padding: 8px 16px; color: var(--ink-2); font-size: 12px;
  border-bottom: 1px solid var(--line);
}
.url-box {
  flex: 1; background: #eceef1; padding: 6px 14px; border-radius: 999px; font-size: 12px;
}
.g-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px; font-size: 15px; color: #5f6368; }
.g-head .g-name { font-size: 17px; color: #5f6368; }
.g-head.outlook { background: #0f6cbd; color: #fff; }
.g-head.outlook .g-name, .g-head.apple .g-name { color: inherit; font-weight: 600; }
.ol-logo { font-size: 18px; }
.g-head.apple { background: #f5f5f7; color: #333; }
.g-subject { display: flex; align-items: center; gap: 10px; padding: 10px 24px 4px; font-size: 20px; font-weight: 500; }
.chip-inbox { background: #eceef1; color: var(--ink-2); border-radius: 4px; font-size: 11px; padding: 3px 7px; }
.g-icons { margin-left: auto; color: var(--ink-3); font-size: 13px; }
.g-sender { display: flex; align-items: center; gap: 12px; padding: 12px 24px; font-size: 12.5px; }
.g-sender small { color: var(--ink-3); }
.g-time { margin-left: auto; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--ink);
  color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto;
}
.skeleton { padding: 8px 24px 4px; }
.skeleton i { display: block; height: 9px; border-radius: 5px; background: #eef0f4; margin-bottom: 9px; }
.sig-slot { padding: 18px 24px 34px; overflow-x: auto; }

/* phone mock */
.phone-frame {
  width: 400px; flex: 0 0 400px; background: #fff; border: 10px solid #1e232b; border-radius: 38px;
  box-shadow: var(--shadow); overflow: hidden; position: relative; align-self: flex-start;
}
.phone-notch {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 110px; height: 22px; background: #1e232b; border-radius: 999px;
}
.phone-status { display: flex; justify-content: space-between; padding: 12px 22px 4px; font-size: 11px; color: var(--ink-2); }
.m-head { padding: 12px 18px 4px; }
.client-name { font-size: 16px; }
.m-subject { padding: 8px 18px 0; font-size: 16.5px; font-weight: 600; }
.m-sender { display: flex; gap: 10px; align-items: center; padding: 12px 18px; font-size: 12px; }
.m-sender small { color: var(--ink-3); }
.phone-frame .skeleton { padding: 4px 18px; }
.phone-frame .sig-slot { padding: 12px 14px 30px; overflow: hidden; }

/* preview-only animation hooks (emails get GIFs / static images instead) */
.anim-icons img.ss-icon { transition: transform .18s ease; }
.anim-icons a:hover img.ss-icon { transform: translateY(-3px) scale(1.15); }
.anim-btns a.ss-btn { transition: transform .15s ease, box-shadow .15s ease; }
.anim-btns a.ss-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(15, 23, 42, .25); }

/* ============ modal / toast ============ */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: #fff; border-radius: 18px; width: 620px; max-width: calc(100vw - 40px);
  max-height: 86vh; overflow-y: auto; padding: 24px 26px; position: relative;
  box-shadow: 0 24px 80px rgba(15, 23, 42, .35);
}
.modal .close {
  position: absolute; top: 14px; right: 16px; border: 0; background: none;
  font-size: 22px; color: var(--ink-3);
}
.modal h2 { margin-bottom: 14px; }
.modal-body .section { margin-top: 18px; padding-top: 16px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 4px; align-items: center; }
.modal-actions .ghost-btn { margin: 0; }
.how {
  background: #f7f9fd; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 12.5px; line-height: 1.7; color: var(--ink-2); margin-top: 12px;
}
.how.warn { background: #fff8ed; border-color: #fcd9a8; color: #92510a; }
.row.dim { opacity: .45; }
.row.dim .row-ctl { pointer-events: none; }
.asset-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.asset-line {
  display: flex; align-items: center; gap: 10px; font-size: 12.5px;
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px;
}
.asset-line img { width: 26px; height: 26px; object-fit: contain; background: #f2f5fb; border-radius: 6px; }
.asset-line span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translate(-50%, 16px);
  background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 20px;
  font-size: 13.5px; opacity: 0; transition: all .25s ease; z-index: 99;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .4); max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============ narrow windows ============ */
@media (max-width: 1240px) {
  #panel { width: 390px; flex-basis: 390px; }
  #panelInner { padding: 18px 18px 60px; }
}
@media (max-width: 1080px) {
  #sidebar { width: 72px; flex: 0 0 72px; padding: 14px 8px; }
  .brand-name, .tab .tab-name, .foot-label, .admin-tag { display: none; }
  .brand { flex-direction: column; justify-content: center; gap: 8px; padding: 0 0 14px; }
  .admin-switch { margin-left: 0; }
  .tab { justify-content: center; padding: 6px 0; }
  .sidebar-foot.admin-only { padding: 8px 6px; }
  .sig-actions { flex-wrap: wrap; }
  #sigSelect { font-size: 10px; }
  .preview-head { flex-wrap: wrap; gap: 8px; padding: 14px 16px 6px; }
  #mockWrap { padding: 12px 16px; }
  .preview-foot, #preview footer { padding-left: 16px; padding-right: 16px; }
}

/* top Save button glows when there are unsaved changes */
#quickSave.attention {
  border-color: var(--blue); color: var(--blue); font-weight: 700;
  box-shadow: 0 0 0 3px rgba(47, 125, 246, .18);
}

/* live signature previews on the layout cards */
.lay-prev {
  display: block; height: 150px; overflow: hidden;
  border-radius: 12px; padding: 12px;
  pointer-events: none;
}
.lay-prev-inner { display: block; transform-origin: top left; }

/* ============ MOBILE (phones) ============ */
#mobileNav { display: none; }
@media (max-width: 740px) {
  #app { flex-direction: column; height: 100dvh; padding: 8px; gap: 8px; }

  /* compact top bar: brand mark + admin switch + signature/folder switcher + actions */
  #sidebar {
    width: 100%; flex: 0 0 auto; flex-direction: row; align-items: center;
    gap: 8px; padding: 8px 12px; border-radius: 14px;
  }
  .brand { flex-direction: row; padding: 0; gap: 8px; }
  .brand-name, .foot-label, .admin-tag, .adm-lbl { display: none; }
  .admin-switch { margin-left: 0; }
  #tabs { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; }
  .sidebar-foot.admin-only {
    border: 0; background: none; padding: 0;
    display: flex; align-items: center; gap: 5px;
    flex-wrap: wrap; justify-content: flex-end; /* selects + actions may take 2 rows */
  }
  #folderSelect { min-width: 64px; max-width: 78px; font-size: 11px; padding: 6px 4px; }
  #sigSelect { width: auto; min-width: 70px; max-width: 92px; font-size: 11px; padding: 6px 4px; }
  .sig-actions { margin: 0; gap: 2px; flex-wrap: nowrap; }
  .sig-actions button { padding: 5px 6px; flex: 0 0 auto; }
  .brand-mark { font-size: 20px; }

  /* one view at a time: editor panels OR preview */
  #panel { width: 100%; flex: 1 1 auto; }
  #panelInner { padding: 16px 14px calc(86px + env(safe-area-inset-bottom)); }
  #preview { display: none; }
  body.m-preview #panel { display: none; }
  body.m-preview #preview { display: flex; flex: 1 1 auto; overflow: hidden; }

  .preview-head { padding: 12px 14px 4px; flex-wrap: wrap; gap: 8px; }
  #mockWrap { padding: 10px 12px; }
  .b-tab { max-width: 130px; }
  .browser-frame { min-width: 0; }
  .phone-frame { width: 100%; max-width: 400px; }
  .g-subject { font-size: 16px; }
  .preview-foot { padding: 10px 14px 12px; }
  #preview footer { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }

  /* editor ergonomics */
  .icon-grid { grid-template-columns: repeat(6, 1fr); }
  .layout-grid { grid-template-columns: 1fr; }
  .contact-line, .field-line { flex-wrap: wrap; }
  .slider-wrap { width: 150px; }
  .preset-grid { grid-template-columns: repeat(2, 1fr); }
  .row { flex-wrap: wrap; }

  /* modal fills the screen comfortably */
  .modal { max-width: calc(100vw - 16px); width: 100%; padding: 18px 16px; max-height: 90vh; }
  .modal-actions .primary.big { width: 100%; }

  /* bottom navigation */
  #mobileNav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: #fff; border-top: 1px solid var(--line);
    padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .m-tab {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    border: 0; background: none; color: var(--ink-2);
    font-size: 10px; font-weight: 500; padding: 4px 6px; border-radius: 8px; min-width: 46px;
  }
  .m-tab svg { width: 20px; height: 20px; }
  .m-tab.active { color: #1d5fd0; font-weight: 700; }

  /* toasts must clear the fixed bottom nav */
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
