/* ══════════════════════════════════════════════
   DocGen Pro · styles.css
   ══════════════════════════════════════════════ */

*,::before,::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0c0e14;
  --surf: #13151c;
  --elev: #1a1d26;
  --b1: #252933;
  --b2: #2e3344;
  --b3: #3c4260;
  --acc: #4f72f5;
  --acc2: #3a5cd8;
  --acc-s: rgba(79,114,245,.12);
  --txt: #e2e6f3;
  --txt2: #8d94b8;
  --txt3: #4e5573;
  --suc: #22c55e;
  --err: #ef4444;
  --warn: #f59e0b;
  --tb-h: 44px;
  --sb-w: 282px;
  --tl-h: 40px;
  --st-h: 26px;
  --r: 8px;
  --r2: 5px;
}

html, body { height: 100%; overflow: hidden; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--txt);
  font-size: 13px;
}

/* ── TOPBAR ─────────────────────────────────────────────────────── */
#topbar {
  height: var(--tb-h);
  background: var(--surf);
  border-bottom: 1px solid var(--b1);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 200;
  flex-shrink: 0;
}

.logo {
  font-family: 'Syne', sans-serif;
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -.3px;
  flex-shrink: 0;
}
.logo-mark {
  width: 28px; height: 28px;
  background: var(--acc);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.logo-mark svg { width: 16px; height: 16px; fill: #fff; }
.logo sup { font-size: 9px; font-weight: 500; color: var(--acc); letter-spacing: .05em; vertical-align: super; margin-left: 1px; }

.vsep { width: 1px; height: 18px; background: var(--b2); flex-shrink: 0; }

.breadcrumb { font-size: 12px; color: var(--txt3); display: flex; align-items: center; gap: 6px; }
.breadcrumb strong { color: var(--txt2); font-weight: 500; }

.tb-center { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.stat-pill {
  background: var(--elev);
  border: 1px solid var(--b1);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
  color: var(--txt3);
  display: flex; align-items: center; gap: 5px;
}
.stat-pill span { color: var(--txt2); font-weight: 600; font-variant-numeric: tabular-nums; }

.save-status {
  font-size: 11px; color: var(--txt3);
  display: flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  transition: all .2s;
}
.save-status.saved  { color: var(--suc); }
.save-status.unsaved{ color: var(--warn); }

.tb-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12.5px; font-weight: 500;
  padding: 6px 14px; border-radius: var(--r2);
  border: none; cursor: pointer;
  transition: all .12s; white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; fill: currentColor; flex-shrink: 0; }
.btn-ghost { background: transparent; color: var(--txt2); border: 1px solid var(--b2); }
.btn-ghost:hover { background: var(--elev); color: var(--txt); border-color: var(--b3); }
.btn-primary { background: var(--acc); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--acc2); box-shadow: 0 0 0 3px rgba(79,114,245,.25); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── LAYOUT ─────────────────────────────────────────────────────── */
#app { display: flex; height: calc(100vh - var(--tb-h)); overflow: hidden; }

/* ── SIDEBAR ────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sb-w); flex-shrink: 0;
  background: var(--surf);
  border-right: 1px solid var(--b1);
  display: flex; flex-direction: column;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--b2) transparent;
}
.sb-section { padding: 14px; border-bottom: 1px solid var(--b1); }
.sb-section:last-child { border-bottom: none; }

.sb-label {
  font-family: 'Syne', sans-serif;
  font-size: 9.5px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--txt3); margin-bottom: 10px;
  display: flex; align-items: center; gap: 7px;
}
.sb-label::after { content: ''; flex: 1; height: 1px; background: var(--b1); }

.type-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 5px; }
.type-card {
  background: var(--elev);
  border: 1.5px solid var(--b1);
  border-radius: var(--r);
  padding: 10px 5px 8px;
  cursor: pointer; text-align: center;
  transition: all .12s; user-select: none;
}
.type-card:hover { border-color: var(--b3); background: #1e2130; }
.type-card.active { border-color: var(--acc); background: var(--acc-s); }
.type-card .ic { font-size: 18px; line-height: 1; display: block; margin-bottom: 5px; }
.type-card .lb { font-size: 9.5px; font-weight: 600; color: var(--txt3); letter-spacing: .02em; }
.type-card.active .lb { color: var(--acc); }

.field { margin-bottom: 9px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block; font-size: 9.5px; font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase;
  color: var(--txt3); margin-bottom: 4px;
  font-family: 'Syne', sans-serif;
}
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--elev);
  border: 1px solid var(--b2);
  border-radius: var(--r2);
  color: var(--txt);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px; padding: 6px 9px;
  outline: none; transition: border-color .12s;
  appearance: none; resize: vertical;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--acc);
  box-shadow: 0 0 0 2px rgba(79,114,245,.15);
}
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%234e5573'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  padding-right: 26px;
}
.field select option { background: #1a1d26; }

.ins-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.ins-btn {
  background: var(--elev); border: 1px solid var(--b2);
  border-radius: var(--r2); padding: 7px 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px; font-weight: 500; color: var(--txt2);
  cursor: pointer; transition: all .12s;
  text-align: center; display: flex;
  align-items: center; justify-content: center; gap: 5px;
}
.ins-btn:hover { background: #1e2130; color: var(--txt); border-color: var(--b3); }

.toggle-row {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 8px;
}
.toggle-row:last-child { margin-bottom: 0; }
.toggle-row label { font-size: 12px; color: var(--txt2); }
.toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--b2); border-radius: 10px;
  transition: .2s; cursor: pointer;
}
.toggle input:checked + .toggle-track { background: var(--acc); }
.toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 14px; height: 14px;
  background: #fff; border-radius: 50%;
  transition: .2s; pointer-events: none;
}
.toggle input:checked ~ .toggle-thumb { left: 19px; }

/* ── EDITOR MAIN ─────────────────────────────────────────────────── */
#editor-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ── TOOLBAR ─────────────────────────────────────────────────────── */
#toolbar {
  height: var(--tl-h);
  background: var(--surf);
  border-bottom: 1px solid var(--b1);
  display: flex; align-items: center;
  padding: 0 8px; gap: 1px;
  flex-shrink: 0; overflow-x: auto;
  scrollbar-width: none;
}
#toolbar::-webkit-scrollbar { display: none; }

.tl-sep { width: 1px; height: 20px; background: var(--b2); margin: 0 5px; flex-shrink: 0; }

.tl-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; border: none;
  background: transparent; border-radius: var(--r2);
  color: var(--txt3); cursor: pointer;
  font-size: 13px; font-family: 'DM Sans', sans-serif; font-weight: 600;
  transition: all .1s; flex-shrink: 0; padding: 0 5px; gap: 3px;
  white-space: nowrap; position: relative;
}
.tl-btn:hover { background: var(--elev); color: var(--txt); }
.tl-btn.active { background: var(--acc-s); color: var(--acc); }
.tl-btn svg { width: 15px; height: 15px; fill: currentColor; }

.tl-select {
  background: var(--elev); border: 1px solid var(--b2);
  border-radius: var(--r2); color: var(--txt);
  font-family: 'DM Sans', sans-serif;
  font-size: 11.5px; padding: 3px 6px;
  outline: none; cursor: pointer;
  flex-shrink: 0; appearance: none; height: 28px;
}
.tl-select:focus { border-color: var(--acc); }
.tl-select option { background: #1a1d26; }

.fs-wrap { display: flex; align-items: center; flex-shrink: 0; }
.fs-btn {
  width: 20px; height: 28px;
  background: var(--elev); border: 1px solid var(--b2);
  color: var(--txt3); cursor: pointer; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: all .1s; flex-shrink: 0;
}
.fs-btn:first-child { border-radius: var(--r2) 0 0 var(--r2); }
.fs-btn:last-child  { border-radius: 0 var(--r2) var(--r2) 0; }
.fs-btn:hover { background: var(--acc); color: #fff; border-color: var(--acc); }
.fs-input {
  width: 36px; text-align: center;
  background: var(--elev); border: 1px solid var(--b2);
  border-left: none; border-right: none;
  color: var(--txt);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; padding: 3px 2px; height: 28px; outline: none;
  -moz-appearance: textfield;
}
.fs-input::-webkit-inner-spin-button,
.fs-input::-webkit-outer-spin-button { display: none; }

.color-btn {
  width: 28px; height: 28px; border-radius: var(--r2);
  border: 1px solid var(--b2); background: var(--elev);
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; flex-direction: column; gap: 2px;
  flex-shrink: 0; position: relative; overflow: hidden;
}
.color-btn input[type=color] {
  position: absolute; inset: 0; opacity: 0;
  cursor: pointer; width: 100%; height: 100%;
  border: none; padding: 0;
}
.color-swatch { height: 3px; width: 14px; border-radius: 1px; }

/* ── CANVAS ─────────────────────────────────────────────────────── */
#canvas {
  flex: 1; background: #b8b5b0;
  overflow: auto;
  display: flex; flex-direction: column;
  align-items: center; padding: 28px 24px 60px;
  position: relative;
}
#canvas::-webkit-scrollbar { width: 8px; height: 8px; }
#canvas::-webkit-scrollbar-track { background: #a8a5a0; }
#canvas::-webkit-scrollbar-thumb { background: #888580; border-radius: 4px; }

/* A4 = 794×1123px */
#doc-sheet {
  width: 794px; min-height: 1123px;
  background: #fff;
  box-shadow: 0 4px 24px rgba(0,0,0,.3), 0 0 0 1px rgba(0,0,0,.08);
  flex-shrink: 0; position: relative;
  font-family: 'Lora', Georgia, serif; color: #111318;
  /* Impede texto de vazar para fora da folha */
  overflow: hidden;
}
#doc-inner {
  padding: 72px 80px 100px; min-height: 1123px;
  display: flex; flex-direction: column;
  /* Garante que conteúdo não extrapole a largura da folha */
  overflow-wrap: break-word;
  word-break: break-word;
  word-wrap: break-word;
}

/* ── DOCUMENT HEADER ─────────────────────────────────────────────── */
#doc-header { flex-shrink: 0; margin-bottom: 20px; }
.dh-wrap { padding-bottom: 14px; }
.dh-top { display: flex; align-items: flex-start; gap: 12px; }
.dh-logo-box {
  width: 48px; height: 48px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.dh-logo-box svg { width: 26px; height: 26px; fill: #fff; }
.dh-org-info { flex: 1; }
.dh-org-name { font-family: 'Syne', sans-serif; font-size: 11pt; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.dh-org-sub  { font-size: 9pt; color: #4a5070; margin-top: 2px; }
.dh-org-dept { font-size: 8.5pt; color: #7a8090; margin-top: 1px; }
.dh-badge-wrap { text-align: right; flex-shrink: 0; }
.dh-badge { display: inline-block; font-family: 'Syne', sans-serif; font-size: 9pt; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; padding: 4px 12px; border-radius: 3px; color: #fff; }
.dh-num { font-family: 'JetBrains Mono', monospace; font-size: 10pt; color: #4a5070; margin-top: 4px; }
.dh-divider { height: 2.5px; width: 100%; margin-top: 12px; border-radius: 1px; }
.dh-meta {
  display: grid; grid-template-columns: max-content 1fr max-content 1fr;
  gap: 2px 10px; font-size: 9pt;
  border: 1px solid #d8d4d0; border-radius: 4px;
  padding: 8px 12px; background: #f8f7f6; margin-top: 10px;
}
.dh-mk { color: #6a7090; font-weight: 700; text-transform: uppercase; font-size: 7.5pt; letter-spacing: .08em; font-family: 'Syne', sans-serif; padding: 2px 0; }
.dh-mv { color: #111318; padding: 2px 0; font-size: 9pt; }
.dh-single-meta {
  display: flex; gap: 18px; font-size: 9pt;
  border: 1px solid #d8d4d0; border-radius: 4px;
  padding: 8px 12px; background: #f8f7f6; margin-top: 10px; flex-wrap: wrap;
}
.dh-single-meta .dh-item { display: flex; gap: 6px; align-items: baseline; }

/* ── EDITOR BODY ─────────────────────────────────────────────────── */
#doc-body {
  flex: 1; outline: none;
  font-family: 'Lora', Georgia, serif;
  font-size: 11.5pt; line-height: 1.7; color: #111318;
  min-height: 600px; caret-color: #4f72f5;
  /* Garante quebra de linha mesmo em sequências longas sem espaço */
  overflow-wrap: break-word;
  word-break:    break-word;
  word-wrap:     break-word;
}
#doc-body:empty::before {
  content: attr(data-placeholder);
  color: #c0bab4; pointer-events: none; font-style: italic;
}
#doc-body h1 { font-size: 15pt; font-weight: 700; margin: 14px 0 6px; line-height: 1.3; overflow-wrap: break-word; word-break: break-word; }
#doc-body h2 { font-size: 13pt; font-weight: 700; margin: 12px 0 5px; line-height: 1.3; overflow-wrap: break-word; word-break: break-word; }
#doc-body h3 { font-size: 11.5pt; font-weight: 700; color: #2a3a5a; margin: 10px 0 4px; overflow-wrap: break-word; word-break: break-word; }
#doc-body p  { margin-bottom: 8px; text-align: justify; overflow-wrap: break-word; word-break: break-word; }
#doc-body ul, #doc-body ol { margin: 6px 0 9px 24px; }
#doc-body li { margin-bottom: 3px; overflow-wrap: break-word; word-break: break-word; }
#doc-body blockquote { border-left: 3px solid #c8c4be; padding-left: 14px; color: #4a5070; margin: 10px 0; font-style: italic; }
#doc-body a  { color: #1b3d87; text-decoration: underline; word-break: break-all; }
#doc-body hr { border: none; border-top: 1.5px solid #d0ccc8; margin: 16px 0; }
#doc-body pre { background: #f4f4f4; padding: 10px 14px; border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: 9pt; overflow: auto; margin: 8px 0; white-space: pre-wrap; word-break: break-all; }
#doc-body table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 10pt; table-layout: fixed; }
#doc-body th { color: #fff; font-weight: 700; padding: 7px 10px; text-align: left; font-size: 9pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; overflow-wrap: break-word; word-break: break-word; }
#doc-body td { border: 1px solid #d0ccc8; padding: 6px 10px; vertical-align: top; overflow-wrap: break-word; word-break: break-word; }
#doc-body tr:nth-child(even) td { background: #f8f7f6; }

/* ── QUEBRA DE PÁGINA ────────────────────────────────────────────── */
/* A altura é definida pelo JS (recalcPageBreaks) para preencher até o fim
   da página atual e simular a borda da próxima folha */
.page-break {
  display: block;
  width: 100%;
  /* altura mínima; o JS vai setar a altura real via style.height */
  min-height: 40px;
  position: relative;
  user-select: none;
  cursor: default;
  page-break-after: always;
  break-after: page;
  /* Gradiente que simula o fundo cinza do canvas entre páginas */
  background: linear-gradient(
    to bottom,
    rgba(79,114,245,.03) 0,
    rgba(79,114,245,.03) calc(100% - 28px),
    #c0bbb6 calc(100% - 28px),
    #c0bbb6 calc(100% - 20px),
    #fff calc(100% - 20px),
    #fff 100%
  );
  border-top: 2px dashed rgba(79,114,245,.4);
  box-sizing: border-box;
}

/* Label "QUEBRA DE PÁGINA" no topo */
.page-break::before {
  content: '⏎  QUEBRA DE PÁGINA — clique e delete para remover';
  position: absolute;
  top: 8px; left: 50%;
  transform: translateX(-50%);
  background: rgba(79,114,245,.1);
  border: 1px solid rgba(79,114,245,.25);
  color: rgba(79,114,245,.75);
  font-size: 8px; font-family: 'Syne', sans-serif; font-weight: 700;
  letter-spacing: .1em; padding: 3px 10px; border-radius: 4px;
  pointer-events: none; white-space: nowrap;
}

/* "Pág N" no canto direito, próximo da borda da folha seguinte */
.page-break::after {
  content: attr(data-next-label);
  position: absolute;
  bottom: 4px; right: 0;
  background: rgba(79,114,245,.15);
  color: rgba(79,114,245,.8);
  font-size: 9px; font-family: 'Syne', sans-serif; font-weight: 700;
  letter-spacing: .08em; padding: 2px 8px; border-radius: 3px 0 0 3px;
  pointer-events: none;
}

/* Signature block */
.sig-block {
  margin-top: 8px; padding-top: 8px;
  display: inline-block; min-width: 220px;
}
.sig-name  { font-size: 10pt; font-weight: 700; margin-top: 2px; }
.sig-role  { font-size: 9pt; color: #5a6080; margin-top: 2px; }
.sig-dept  { font-size: 8.5pt; color: #8a9090; margin-top: 1px; }

/* ── IMAGE RESIZE SYSTEM ─────────────────────────────────────────── */
.img-wrapper {
  display: inline-block;
  position: relative;
  max-width: 100%;
  cursor: default;
  line-height: 0;
  /* float: none by default - changed by alignment buttons */
}
.img-wrapper img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 2px;
  user-select: none;
  pointer-events: none;
}
.img-wrapper.align-left  { float: left;  margin: 4px 14px 4px 0; }
.img-wrapper.align-right { float: right; margin: 4px 0 4px 14px; }
.img-wrapper.align-center{ display: block; margin: 8px auto; }

/* Selection outline */
.img-wrapper.selected { outline: 2px solid var(--acc); outline-offset: 1px; }

/* Resize handles */
.img-handle {
  position: absolute;
  width: 10px; height: 10px;
  background: var(--acc);
  border: 2px solid #fff;
  border-radius: 2px;
  z-index: 50;
  display: none;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.img-wrapper.selected .img-handle { display: block; }
.img-handle.nw { top: -5px;  left: -5px;  cursor: nw-resize; }
.img-handle.ne { top: -5px;  right: -5px; cursor: ne-resize; }
.img-handle.sw { bottom: -5px; left: -5px; cursor: sw-resize; }
.img-handle.se { bottom: -5px; right: -5px; cursor: se-resize; }
.img-handle.n  { top: -5px;  left: 50%; transform: translateX(-50%); cursor: n-resize; }
.img-handle.s  { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.img-handle.e  { right: -5px; top: 50%; transform: translateY(-50%); cursor: e-resize; }
.img-handle.w  { left: -5px;  top: 50%; transform: translateY(-50%); cursor: w-resize; }

/* Image floating toolbar */
.img-toolbar {
  position: absolute;
  top: -38px; left: 50%; transform: translateX(-50%);
  background: #111318; border: 1px solid #2e3038;
  border-radius: 7px; display: none;
  align-items: center; gap: 1px;
  padding: 3px 5px; white-space: nowrap;
  z-index: 60; box-shadow: 0 4px 16px rgba(0,0,0,.5);
}
.img-wrapper.selected .img-toolbar { display: flex; }
.img-toolbar button {
  background: transparent; border: none; color: #aaa;
  font-size: 11px; cursor: pointer; padding: 3px 7px;
  border-radius: 4px; font-family: 'DM Sans', sans-serif;
  font-weight: 500; transition: all .1s;
}
.img-toolbar button:hover { background: #2e3038; color: #fff; }
.img-toolbar button.active { color: var(--acc); }
.img-toolbar .it-sep { width: 1px; height: 14px; background: #2e3038; margin: 0 2px; }
.img-toolbar .it-size {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; color: #666;
  padding: 0 4px; border: none; background: transparent;
  pointer-events: none;
}

/* Drag move cursor */
.img-wrapper.selected { cursor: move; }
.img-wrapper.selected .img-handle { cursor: inherit; }
.img-wrapper.selected .img-handle.nw { cursor: nw-resize; }
.img-wrapper.selected .img-handle.ne { cursor: ne-resize; }
.img-wrapper.selected .img-handle.sw { cursor: sw-resize; }
.img-wrapper.selected .img-handle.se { cursor: se-resize; }
.img-wrapper.selected .img-handle.n  { cursor: n-resize; }
.img-wrapper.selected .img-handle.s  { cursor: s-resize; }
.img-wrapper.selected .img-handle.e  { cursor: e-resize; }
.img-wrapper.selected .img-handle.w  { cursor: w-resize; }

/* ── PAGE MARKER ─────────────────────────────────────────────────── */
.pg-marker {
  position: absolute; left: 0; right: 0;
  border-top: 1px dashed rgba(79,114,245,.2);
  pointer-events: none; z-index: 5;
}
.pg-marker::after {
  content: attr(data-label);
  position: absolute; right: -80px; top: -9px;
  background: #a8a5a0; color: #706c68;
  font-size: 8px; font-family: 'Syne', sans-serif; font-weight: 600;
  letter-spacing: .08em; padding: 1px 7px; border-radius: 3px;
}

/* ── STATUS BAR ──────────────────────────────────────────────────── */
#statusbar {
  height: var(--st-h);
  background: var(--surf); border-top: 1px solid var(--b1);
  display: flex; align-items: center;
  padding: 0 16px; gap: 18px;
  flex-shrink: 0; font-size: 10.5px; color: var(--txt3);
}
.st-item { display: flex; align-items: center; gap: 4px; }
.st-item span { color: var(--txt2); font-weight: 600; }
.st-badge {
  margin-left: auto;
  font-family: 'Syne', sans-serif; font-size: 9px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--acc); background: var(--acc-s);
  padding: 2px 8px; border-radius: 3px;
}

/* ── MODALS ──────────────────────────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(6px);
  z-index: 1000; display: flex;
  align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .18s;
}
.modal-bg.open { opacity: 1; pointer-events: all; }
.modal-box {
  background: var(--elev); border: 1px solid var(--b2);
  border-radius: 12px; padding: 24px;
  width: 400px; max-width: 92vw; max-height: 85vh;
  overflow-y: auto;
  transform: translateY(10px) scale(.97);
  transition: transform .18s;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
}
.modal-bg.open .modal-box { transform: none; }
.modal-title { font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.modal-sub { font-size: 11.5px; color: var(--txt2); margin-bottom: 18px; }
.modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.modal-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--b1);
}

/* ── TOAST ───────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 22px; right: 22px;
  background: var(--elev); border: 1px solid var(--b2);
  border-radius: var(--r); padding: 10px 16px;
  font-size: 12.5px; color: var(--txt);
  z-index: 3000; box-shadow: 0 10px 32px rgba(0,0,0,.5);
  transform: translateY(70px); opacity: 0;
  transition: all .22s cubic-bezier(.34,1.56,.64,1);
  display: flex; align-items: center; gap: 9px; max-width: 340px;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast .t-icon { font-size: 16px; }
#toast.success .t-icon { color: var(--suc); }
#toast.error   .t-icon { color: var(--err); }
#toast.warn    .t-icon { color: var(--warn); }

/* Spin animation for loading */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* Clearfix for floated images */
#doc-body::after { content: ''; display: table; clear: both; }