/* =========================================================================
   סטודיו תעודות — עיצוב
   כיוון: סדנת דפוס חמה. סרגל עליון בצבע דיו, לוחות בגוון נייר,
   משטח עבודה כמו שולחן חיתוך מנוקד, והדגשה באדום של חותם שעווה.
   ========================================================================= */

:root {
  --font-ui: 'IBM Plex Sans Hebrew', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --font-display: 'Frank Ruhl Libre', 'IBM Plex Sans Hebrew', Georgia, serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;

  --ink: #1d1a16;
  --ink-2: #4a453d;
  --muted: #857c6f;
  --faint: #b1a796;
  --line: #e5dece;
  --line-strong: #d3c8b4;
  --paper: #fbf9f4;
  --paper-2: #f4f0e7;
  --paper-3: #ece6d9;
  --desk: #e7e1d4;
  --white: #fff;

  --accent: #b3361f;
  --accent-hover: #9c2c18;
  --accent-soft: #f7e4dd;
  --accent-ink: #fff;
  --gold: #a07d32;

  --sel: #2f5fd0;
  --sel-soft: rgba(47, 95, 208, 0.1);
  --guide: #d6337f;

  --ok: #2f6b4a;
  --ok-soft: #e4f0e8;
  --warn: #8f5410;
  --warn-soft: #fbf0dd;
  --danger: #b3261e;
  --danger-soft: #fbe5e2;

  --bar-h: 60px;
  --side-w: 304px;
  --props-w: 304px;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(40, 30, 10, 0.08);
  --shadow-md: 0 1px 2px rgba(40, 30, 10, 0.06), 0 8px 24px -10px rgba(40, 30, 10, 0.28);
  --shadow-lg: 0 2px 6px rgba(40, 30, 10, 0.08), 0 30px 70px -20px rgba(40, 30, 10, 0.45);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 400 14px/1.5 var(--font-ui);
  color: var(--ink);
  background: var(--desk);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--paper-3);
  border-radius: 4px;
  padding: 0.05em 0.35em;
  direction: rtl;
  unicode-bidi: isolate;
}
[hidden] { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
:focus-visible { outline: 2px solid var(--sel); outline-offset: 2px; }

.ic {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ----- מבנה ----- */

.app {
  display: grid;
  height: 100vh;
  grid-template-columns: var(--side-w) minmax(0, 1fr) var(--props-w);
  grid-template-rows: var(--bar-h) minmax(0, 1fr);
  grid-template-areas:
    'top top top'
    'steps ws props';
}
.topbar { grid-area: top; }
.sidebar-steps { grid-area: steps; }
.workspace { grid-area: ws; }
.sidebar-props { grid-area: props; }

/* כניסה מדורגת */
body:not(.ready) .sidebar, body:not(.ready) .stage { opacity: 0; }
body.ready .sidebar-steps { animation: rise 0.5s var(--ease) both; }
body.ready .stage { animation: rise 0.6s 0.08s var(--ease) both; }
body.ready .sidebar-props { animation: rise 0.5s 0.16s var(--ease) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ----- סרגל עליון ----- */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 16px 0 14px;
  background: var(--ink);
  color: #efe8da;
  position: relative;
  z-index: 5;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
.topbar::after {
  /* קו זהב דק בתחתית */
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(196, 160, 82, 0.55) 20%, rgba(196, 160, 82, 0.55) 80%, transparent);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  flex: none;
}
.brand-seal { width: 38px; height: 38px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35)); transition: transform 0.4s var(--ease); }
.brand:hover .brand-seal { transform: rotate(-12deg) scale(1.04); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font: 700 19px/1.1 var(--font-display); letter-spacing: 0.01em; color: #fbf3e6; }
.brand-text small { font-size: 11.5px; color: #b9ad98; letter-spacing: 0.02em; }

.doc {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  padding-inline-start: 20px;
  border-inline-start: 1px solid rgba(255, 255, 255, 0.1);
}
.doc-name {
  min-width: 120px;
  max-width: 420px;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font: 500 17px/1.2 var(--font-display);
  color: #fbf3e6;
  transition: background 0.15s, border-color 0.15s;
}
.doc-name:hover { background: rgba(255, 255, 255, 0.05); }
.doc-name:focus { outline: none; background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.2); }
.save-state {
  flex: none;
  font-size: 12px;
  color: #a99e8a;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.save-state::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.save-state[data-state='saved'] { color: #8fbf9f; }
.save-state[data-state='dirty'] { color: #e6b45e; }
.save-state[data-state='draft'] { color: #a99e8a; }

.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.topbar .btn { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.12); color: #f2ebdd; }
.topbar .btn:hover { background: rgba(255, 255, 255, 0.12); }
.topbar .btn.ghost { background: transparent; border-color: transparent; }
.topbar .btn.ghost:hover { background: rgba(255, 255, 255, 0.08); }
.topbar .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset, 0 4px 14px -4px rgba(179, 54, 31, 0.8); }
.topbar .btn.primary:hover { background: #c33c23; }
.topbar .icon-btn { color: #d9cfbd; }
.topbar .icon-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); color: #fff; }
.topbar .icon-btn:disabled { color: #5d564b; }
.btn-group { display: flex; gap: 2px; margin-inline-end: 6px; }

/* ----- כפתורים ----- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--white);
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn:hover:not(:disabled) { background: var(--paper-2); border-color: var(--faint); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--paper-3); }
.btn.danger { color: var(--danger); }
.btn.primary.danger, .btn.danger.primary { color: #fff; }
.modal .btn.danger:not(.ghost) { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 5px; }
.btn.sm .ic { width: 15px; height: 15px; }
.btn.block { width: 100%; }
.btn.busy { pointer-events: none; opacity: 0.7; }
.btn.busy .ic { animation: spin 0.9s linear infinite; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--ink-2);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover:not(:disabled) { background: var(--paper-3); color: var(--ink); }
.icon-btn:disabled { opacity: 0.35; }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm .ic { width: 16px; height: 16px; }
.icon-btn.danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: none;
  padding: 2px 0;
  color: var(--accent);
  font-weight: 500;
  font-size: 13px;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 3px;
}
.link-btn:hover { text-decoration-color: currentColor; }
.link-btn.danger { color: var(--danger); }
.link-btn .ic { width: 15px; height: 15px; }

/* ----- טפסים ----- */

.input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:hover:not(:disabled) { border-color: var(--faint); }
.input:focus { outline: none; border-color: var(--sel); box-shadow: 0 0 0 3px var(--sel-soft); }
.input:disabled { background: var(--paper-2); color: var(--ink-2); }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; min-height: 70px; line-height: 1.55; }
select.input {
  appearance: none;
  padding-inline-end: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23857c6f' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 10px center;
}
.input.num { font-family: var(--font-mono); font-size: 13px; text-align: left; direction: ltr; }
.field-label { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-2); margin: 12px 0 5px; }
.group-title {
  margin: 0 0 10px;
  font: 600 11.5px/1.2 var(--font-ui);
  letter-spacing: 0.08em;
  color: var(--muted);
}
.group-title small { font-weight: 400; letter-spacing: 0; color: var(--faint); margin-inline-start: 4px; }
.mini-title { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 16px 0 8px; }
.mini-title small { font-weight: 400; color: var(--muted); }
.hint { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 10px 0 0;
  font-size: 13.5px;
  cursor: pointer;
  line-height: 1.4;
}
.check input { margin: 2px 0 0; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.row2 + .row2 { margin-top: 0; }
.input-suffix { display: flex; align-items: center; position: relative; }
.input-suffix .input { padding-inline-end: 44px; }
.input-suffix span { position: absolute; inset-inline-end: 10px; font-family: var(--font-mono); font-size: 12px; color: var(--muted); direction: ltr; unicode-bidi: isolate; }

/* כפתורי מקטעים */
.seg {
  display: flex;
  padding: 3px;
  gap: 2px;
  background: var(--paper-3);
  border-radius: 9px;
}
.seg button {
  flex: 1;
  height: 30px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.seg button:hover { color: var(--ink); }
.seg button.active { background: var(--white); color: var(--ink); box-shadow: var(--shadow-sm), 0 0 0 1px rgba(0, 0, 0, 0.04); }
.seg.disabled { opacity: 0.45; pointer-events: none; }
.seg-icons button .ic { width: 17px; height: 17px; }
.row2 .seg { margin-top: 12px; }

/* צ'יפים */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips:empty { display: none; }
.chips.sm { margin-top: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 999px;
  background: var(--white);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  transition: all 0.15s;
}
.chip .ic { width: 13px; height: 13px; stroke-width: 2.2; color: var(--muted); }
.chip:hover { border-style: solid; border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip:hover .ic { color: var(--accent); }
.chip.used { border-style: solid; background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.chips.sm .chip { height: 25px; font-size: 12px; padding: 0 8px; }

/* ----- סרגלי צד ----- */

.sidebar {
  background: var(--paper);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  z-index: 2;
}
.sidebar-steps { border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; }
.sidebar-props { border-inline-start: 1px solid var(--line); }

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 0 8px;
}
.step {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 4px 12px;
  border: none;
  background: none;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.15s;
}
.step:hover { color: var(--ink); }
.step-num {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  font: 700 13px/1 var(--font-display);
  transition: all 0.2s;
}
.step[aria-selected='true'] { color: var(--ink); }
.step[aria-selected='true'] .step-num { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 3px 10px -3px rgba(179, 54, 31, 0.7); }
.step[aria-selected='true']::after {
  content: '';
  position: absolute;
  inset: auto 18% -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.step-badge {
  position: absolute;
  top: 8px;
  inset-inline-start: calc(50% + 10px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--ink);
  color: #fff;
  font: 600 10.5px/18px var(--font-mono);
  text-align: center;
}
.step-badge:empty { display: none; }

.tab-panel { padding: 18px 18px 28px; animation: fade 0.25s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.group { margin-top: 22px; }
.tab-panel > .group:first-child { margin-top: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-head h3 { margin: 0; font: 700 18px/1.2 var(--font-display); }

/* כיוון דף */
.orient { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.orient-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  height: 104px;
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  font-weight: 500;
  color: var(--ink-2);
  transition: all 0.18s var(--ease);
}
.orient-card:hover { border-color: var(--faint); }
.orient-card.active { border-color: var(--accent); color: var(--ink); box-shadow: 0 0 0 3px var(--accent-soft); }
.sheet {
  display: block;
  background: linear-gradient(var(--paper-2), var(--paper-2)) padding-box;
  border: 1.5px solid var(--faint);
  border-radius: 3px;
  position: relative;
  transition: all 0.2s;
}
.sheet::after {
  content: '';
  position: absolute;
  inset: 32% 22% auto;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.35;
  box-shadow: 0 7px 0 -0.5px rgba(0, 0, 0, 0.18);
}
.sheet-landscape { width: 62px; height: 44px; }
.sheet-portrait { width: 40px; height: 56px; }
.orient-card.active .sheet { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.sheet.sm { transform: scale(0.42); margin: -14px -10px; }

/* אזורי גרירה */
.dropzone {
  position: relative;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  overflow: hidden;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: #fffaf7; }
.dropzone.drag { box-shadow: 0 0 0 4px var(--accent-soft); }
.dz-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 3px;
  padding: 22px 14px;
}
.dz-empty b { font-weight: 600; font-size: 14px; }
.dz-empty span { font-size: 12px; color: var(--muted); }
.dz-ic { width: 30px; height: 30px; color: var(--accent); stroke-width: 1.5; margin-bottom: 6px; }
.dz-filled { cursor: default; }
.dz-filled img {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  background: repeating-conic-gradient(var(--paper-2) 0% 25%, var(--white) 0% 50%) 50% / 14px 14px;
}
.dz-meta { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--line); font-size: 12.5px; }
.dz-meta > span:first-child { flex: 1; color: var(--ink-2); }
.dz-links { display: flex; gap: 12px; flex: none; }
.dz-busy {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(251, 249, 244, 0.9);
  font-weight: 500;
}
.dz-row { display: flex; align-items: center; gap: 14px; padding: 16px 18px; }
.dz-row .dz-ic { margin: 0; }
.dz-row b { display: block; }
.dz-row span { font-size: 12.5px; color: var(--muted); }

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* רשימת שדות */
.field-list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.field-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field-item:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.field-item.selected { border-color: var(--sel); box-shadow: 0 0 0 3px var(--sel-soft); }
.field-item .icon-btn { opacity: 0; }
.field-item:hover .icon-btn, .field-item.selected .icon-btn { opacity: 1; }
.field-kind {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--paper-2);
  color: var(--muted);
  flex: none;
}
.field-kind.dynamic { background: var(--accent-soft); color: var(--accent); }
.field-kind .ic { width: 16px; height: 16px; }
.field-item-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.35; }
.field-item-text b { font-weight: 600; font-size: 13.5px; }
.field-item-text span { font-size: 12.5px; color: var(--ink-2); }
.field-item-text small { font-size: 11px; color: var(--muted); }
.empty-note { color: var(--muted); font-size: 13px; padding: 14px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); margin: 0; }
.quick-add { margin-top: 14px; padding: 12px; background: var(--paper-2); border-radius: var(--radius); }
.quick-add .mini-title { margin-top: 0; }

/* לומדים */
.xls-loaded { display: flex; flex-direction: column; }
.xls-loaded > .btn { margin-top: 12px; }
.file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--ok-soft);
  border: 1px solid #cfe2d6;
}
.file-ic { width: 26px; height: 26px; color: var(--ok); stroke-width: 1.6; }
.file-card-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.35; }
.file-card-text span { font-size: 12px; color: var(--ink-2); }
.var-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.var-row { padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); }
.var-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.var-head code { background: none; padding: 0; font-weight: 500; color: var(--ink); }
.var-status { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.var-status .ic { width: 12px; height: 12px; stroke-width: 2.6; }
.var-status.ok { background: var(--ok-soft); color: var(--ok); }
.var-status.manual { background: var(--paper-3); color: var(--ink-2); }
.var-status.missing { background: var(--warn-soft); color: var(--warn); }
.var-row .input { height: 32px; font-size: 13px; }
#sampleXls { margin-top: 14px; }

/* ----- משטח העבודה ----- */

.workspace {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background-color: var(--desk);
  background-image: radial-gradient(circle at 1px 1px, rgba(90, 70, 40, 0.17) 1px, transparent 1.3px);
  background-size: 20px 20px;
}
.ws-scroll { flex: 1; min-height: 0; overflow: auto; display: flex; }
.ws-inner { margin: auto; padding: 48px; display: flex; flex: none; }
.stage {
  flex: none;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(60, 45, 20, 0.08), 0 2px 4px rgba(60, 45, 20, 0.08), 0 24px 60px -18px rgba(60, 45, 20, 0.45);
}
#pageSvg { display: block; width: 100%; height: 100%; overflow: visible; user-select: none; -webkit-user-select: none; touch-action: none; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }

.paper { fill: #fff; }
.field { cursor: move; }
.field-box {
  fill: transparent;
  stroke: rgba(47, 95, 208, 0.38);
  stroke-width: 1;
  stroke-dasharray: 4 3;
  vector-effect: non-scaling-stroke;
  transition: fill 0.12s;
}
.field:hover .field-box { stroke: rgba(47, 95, 208, 0.85); fill: rgba(47, 95, 208, 0.045); }
.field.selected .field-box { stroke: transparent; fill: rgba(47, 95, 208, 0.05); }
.field.overflow .field-box { stroke: var(--accent); stroke-dasharray: 2 2; fill: rgba(179, 54, 31, 0.06); }
.no-frames .field:not(.selected):not(:hover):not(.overflow) .field-box { stroke: transparent; }
.field-text text { unicode-bidi: bidi-override; direction: ltr; white-space: pre; pointer-events: none; }
.sel-outline { fill: none; stroke: var(--sel); stroke-width: 1.5; vector-effect: non-scaling-stroke; pointer-events: none; }
.handle { fill: #fff; stroke: var(--sel); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.handle:hover { fill: var(--sel); }
.h-nw, .h-se { cursor: nwse-resize; }
.h-ne, .h-sw { cursor: nesw-resize; }
.h-n, .h-s { cursor: ns-resize; }
.h-e, .h-w { cursor: ew-resize; }
.sel-tag { pointer-events: none; }
.sel-tag rect { fill: var(--sel); }
.sel-tag text { fill: #fff; font-family: var(--font-ui); font-weight: 500; }
.guide { stroke: var(--guide); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 6 4; pointer-events: none; }

.ws-notice {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 32px);
  padding: 6px 14px 6px 6px;
  border-radius: 999px;
  background: var(--ink);
  color: #f3ead9;
  font-size: 13px;
  box-shadow: var(--shadow-md);
}
.ws-notice .ic { color: #e6b45e; }
.ws-notice .btn { height: 28px; border-radius: 999px; }

.canvas-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 16px 14px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(29, 26, 22, 0.92);
  color: #efe6d6;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-md);
}
.seg-dark { background: rgba(255, 255, 255, 0.08); }
.seg-dark button { color: #c9bea9; height: 28px; padding: 0 12px; white-space: nowrap; }
.seg-dark button:hover { color: #fff; }
.seg-dark button.active { background: #f5efe3; color: var(--ink); }
.seg-dark button .ic { width: 15px; height: 15px; }
.learner-nav { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13px; }
.learner-nav-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 340px; }
.learner-nav-text b { font-family: var(--font-mono); font-weight: 500; color: #fff; direction: ltr; unicode-bidi: isolate; }
.learner-nav-text em { font-style: normal; color: #e6b45e; }
.canvas-bar .icon-btn { color: #d9cfbd; }
.canvas-bar .icon-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); color: #fff; }
.canvas-bar .icon-btn:disabled { color: #5d564b; }
.canvas-bar .icon-btn[aria-pressed='true'] { color: #fff; background: rgba(255, 255, 255, 0.12); }
.zoom { display: flex; align-items: center; gap: 2px; }
.zoom-value {
  min-width: 56px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #efe6d6;
  font: 500 12.5px var(--font-mono);
}
.zoom-value:hover { background: rgba(255, 255, 255, 0.1); }
.zoom-value.active { color: #e6c27a; }
.bar-sep { width: 1px; height: 18px; background: rgba(255, 255, 255, 0.15); margin: 0 6px; }

/* ----- מאפייני שדה ----- */

.props-empty { padding: 34px 24px; text-align: center; color: var(--ink-2); }
.props-empty-art {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 10px auto 16px;
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--accent);
  box-shadow: 0 0 0 8px var(--paper-3);
}
.props-empty-art .ic { width: 28px; height: 28px; stroke-width: 1.5; }
.props-empty h3 { margin: 22px 0 6px; font: 700 19px/1.2 var(--font-display); color: var(--ink); }
.props-empty p { margin: 0 0 18px; font-size: 13px; line-height: 1.6; color: var(--muted); }
.shortcuts { margin: 30px 0 0; text-align: start; border-top: 1px solid var(--line); padding-top: 14px; }
.shortcuts div { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 12px; }
.shortcuts dt { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-2); direction: ltr; }
.shortcuts dd { margin: 0; color: var(--muted); }

.props { padding-bottom: 24px; }
.props-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 12px 12px 10px;
  padding-inline-start: 14px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.props-title {
  flex: 1;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  padding: 4px 6px;
  margin-inline-start: -6px;
  font: 700 17px/1.3 var(--font-display);
}
.props-title:hover { background: var(--paper-2); }
.props-title:focus { outline: none; background: var(--white); border-color: var(--sel); }
.props-actions { display: flex; gap: 2px; }
.pgroup { padding: 16px 18px 18px; border-bottom: 1px solid var(--line); }
.pgroup:last-child { border-bottom: none; }
.pgroup > .field-label:first-child { margin-top: 0; }
.pgroup .group-title { margin-bottom: 10px; }
#pText { font-size: 14px; }

.color-row { display: flex; align-items: center; gap: 8px; }
.color-row .input { width: 92px; flex: none; }
.color-well { position: relative; width: 36px; height: 36px; flex: none; cursor: pointer; }
.color-well input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.color-well span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.15);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6);
}
.swatches { display: flex; gap: 5px; flex-wrap: wrap; }
.swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.14);
  padding: 0;
  transition: transform 0.12s;
}
.swatch:hover { transform: scale(1.18); }

.grid4 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.grid4 label span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.btn-row { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; border: 1px solid var(--line); }

.warn { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.warn p {
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.5;
}
.warn p .ic { width: 15px; height: 15px; margin-top: 2px; }
.warn-warn { background: var(--warn-soft); color: var(--warn); }
.warn-info { background: var(--paper-2); color: var(--ink-2); }

/* ----- חלונות ----- */

.modal {
  border: none;
  padding: 0;
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
}
.modal[open] { animation: pop 0.24s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal::backdrop { background: rgba(29, 26, 22, 0.5); backdrop-filter: blur(3px); }
.modal-sm { width: min(420px, calc(100vw - 32px)); }
.modal-md { width: min(600px, calc(100vw - 32px)); }
.modal-lg { width: min(880px, calc(100vw - 32px)); }
.modal-xl { width: min(1180px, calc(100vw - 32px)); }
.modal-body { padding: 22px 24px 22px; display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -4px 0 16px; }
.modal-title { margin: 0; font: 700 22px/1.25 var(--font-display); }
.modal-title small { font: 400 14px var(--font-ui); color: var(--muted); }
.modal-sm .modal-title { font-size: 19px; margin-bottom: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.confirm-text { margin: 0; color: var(--ink-2); line-height: 1.6; }

/* ספריית תבניות */
.tpl-new {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 18px;
  background: var(--paper-2);
  border-radius: var(--radius);
  font-weight: 500;
}
.tpl-new > span { margin-inline-end: auto; }
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
  overflow-y: auto;
  padding: 2px 2px 6px;
  min-height: 160px;
}
.tpl-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s var(--ease);
}
.tpl-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.tpl-card.current { border-color: var(--accent); }
.tpl-thumb {
  display: grid;
  place-items: center;
  padding: 14px;
  border: none;
  background: var(--desk);
  max-height: 200px;
}
.tpl-thumb img, .tpl-blank {
  display: block;
  max-width: 100%;
  max-height: 160px;
  box-shadow: 0 6px 16px -6px rgba(40, 30, 10, 0.4);
  background: #fff;
}
.tpl-blank { width: 100%; aspect-ratio: inherit; }
.tpl-info { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px 6px; min-width: 0; }
.tpl-info b { font-weight: 600; }
.tpl-info small { font-size: 12px; color: var(--muted); }
.tpl-current { align-self: flex-start; margin-top: 4px; font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 1px 8px; border-radius: 999px; }
.tpl-actions { display: flex; gap: 4px; padding: 8px 10px 12px; }
.loading, .empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 40px;
  color: var(--muted);
  text-align: center;
}
.loading { flex-direction: row; gap: 10px; }
.empty-state b { color: var(--ink); font: 700 17px var(--font-display); }

/* פונטים */
.font-list { margin-top: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 2px 2px 4px; min-height: 0; }
.font-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px auto;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}
.font-row.broken { grid-template-columns: minmax(0, 1fr) auto; }
.font-broken-title { margin: 14px 0 4px; font: 700 15px var(--font-display); }
.font-sample { font-size: 25px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.font-meta { display: flex; flex-direction: column; gap: 2px; font-size: 12px; min-width: 0; color: var(--ink-2); }
.font-meta b { font-size: 14px; color: var(--ink); text-align: right; }
.font-meta code { background: none; padding: 0; color: var(--muted); font-size: 11.5px; direction: ltr; text-align: right; }
.badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.badge.google { background: #e8f0fe; color: #1a56c4; }
.badge { align-self: flex-start; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--paper-3); color: var(--ink-2); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

/* לשוניות בחלון */
.modal-tabs { margin-bottom: 16px; align-self: flex-start; }
.modal-tabs button { padding: 0 16px; height: 32px; white-space: nowrap; flex: none; }
.modal-tabs button span { color: var(--muted); font-weight: 400; }
.ftab { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.ftab > .dropzone, .ftab > .hint, .gf-tools, .gf-bulk { flex: none; }
#dlgFonts .modal-body { height: min(760px, calc(100vh - 48px)); }

/* Google Fonts */
.gf-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gf-tools .search { flex: 1; max-width: none; min-width: 200px; }
.gf-tools select { width: auto; min-width: 150px; }
.gf-heb { margin: 0; white-space: nowrap; }
.gf-bulk {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding: 8px 8px 8px 8px;
  padding-inline-start: 14px;
  border-radius: var(--radius);
  background: #eef3fd;
  color: #1a3f8f;
  font-size: 13px;
}
.gf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
  margin-top: 14px;
  overflow-y: auto;
  padding: 2px 2px 6px;
  min-height: 0;
  align-content: start;
}
.gf-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.gf-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.gf-card.installed { background: var(--paper); }
.gf-sample { font-size: 26px; line-height: 1.35; min-height: 36px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.gf-info { display: flex; flex-direction: column; line-height: 1.3; }
.gf-info b { font-size: 14px; text-align: right; }
.gf-info small { color: var(--muted); font-size: 12px; }
.gf-card .btn, .gf-installed { align-self: flex-start; }
.gf-installed { display: inline-flex; align-items: center; gap: 4px; height: 30px; font-size: 13px; font-weight: 600; color: var(--ok); }
.gf-installed .ic { width: 15px; height: 15px; stroke-width: 2.4; }
.gf-more { grid-column: 1 / -1; justify-self: center; }
.spinner.sm { width: 14px; height: 14px; border-width: 2px; }

/* בורר גופנים */
.font-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 42px;
  font-size: 17px;
  text-align: start;
  cursor: pointer;
}
.font-btn .fp-current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.font-btn .ic { width: 16px; height: 16px; color: var(--muted); }
.font-btn[aria-expanded='true'] { border-color: var(--sel); box-shadow: 0 0 0 3px var(--sel-soft); }
.font-pop {
  position: fixed;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop 0.16s var(--ease);
}
.fp-search { margin: 8px; width: auto; height: 34px; flex: none; }
.fp-list { overflow-y: auto; flex: 1; padding: 0 6px 6px; scrollbar-width: thin; }
.fp-group {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 8px 4px;
  background: var(--white);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.fp-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: 'sample name' 'sample meta';
  align-items: center;
  gap: 0 10px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: 8px;
  background: none;
  text-align: start;
}
.fp-item:hover, .fp-item.active { background: var(--paper-2); }
.fp-item.selected { background: var(--sel-soft); }
.fp-sample { grid-area: sample; font-size: 20px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-name { grid-area: name; font-size: 13px; font-weight: 500; text-align: left; }
.fp-item small { grid-area: meta; font-size: 11px; color: var(--muted); text-align: left; font-family: var(--font-ui); }
.fp-empty { padding: 20px; text-align: center; color: var(--muted); }
.fp-more {
  flex: none;
  border: none;
  border-top: 1px solid var(--line);
  background: var(--paper);
  padding: 10px;
  font-weight: 600;
  font-size: 13px;
  color: var(--accent);
}
.fp-more:hover { background: var(--accent-soft); }

/* תמונות וחתימות */
.add-row { display: flex; gap: 8px; margin-top: 12px; }
.add-row .btn { flex: 1; }
.empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.field-kind.image { background: repeating-conic-gradient(var(--paper-2) 0% 25%, var(--white) 0% 50%) 50% / 8px 8px; border: 1px solid var(--line); overflow: hidden; }
.field-kind.image img { max-width: 100%; max-height: 100%; object-fit: contain; }
.img-preview {
  display: grid;
  place-items: center;
  height: 130px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: repeating-conic-gradient(var(--paper-2) 0% 25%, var(--white) 0% 50%) 50% / 14px 14px;
}
.img-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.img-meta { margin-top: 6px; font-size: 12px; color: var(--muted); }
.img-meta.low { color: var(--warn); }
.range { width: 100%; accent-color: var(--accent); }
.field-label output { font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin-inline-start: 6px; }
.image-el .field-box { stroke-dasharray: 2 3; }
.ws-scroll.drop-target { outline: 3px dashed var(--accent); outline-offset: -10px; background: rgba(179, 54, 31, 0.04); }

/* טבלת לומדים */
.table-tools { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.search { position: relative; flex: 1; max-width: 320px; }
.search .ic { position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search .input { padding-inline-start: 34px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); min-height: 200px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--paper-2);
  text-align: start;
  font-weight: 600;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
.data-table td { text-align: right; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.data-table tbody tr { cursor: pointer; transition: background 0.1s; }
.data-table tbody tr:hover { background: var(--paper); }
.data-table tr.excluded td:not(.col-check) { color: var(--faint); text-decoration: line-through; text-decoration-color: rgba(0, 0, 0, 0.15); }
.data-table tr.current { background: var(--sel-soft); }
.data-table tr.current td.col-num { color: var(--sel); font-weight: 700; }
.col-check { width: 40px; text-align: center !important; }
.col-check input { accent-color: var(--accent); width: 16px; height: 16px; }
.col-num { width: 44px; color: var(--muted); font-family: var(--font-mono); font-size: 12px; }

/* ייצוא */
.choice-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  height: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  transition: all 0.15s;
}
.choice-body .ic { width: 24px; height: 24px; color: var(--muted); margin-bottom: 6px; stroke-width: 1.6; }
.choice-body b { font-size: 15px; }
.choice-body small { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.choice:hover .choice-body { border-color: var(--faint); }
.choice input:checked + .choice-body { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.choice input:checked + .choice-body .ic { color: var(--accent); }
.choice input:focus-visible + .choice-body { outline: 2px solid var(--sel); outline-offset: 2px; }
#dlgExport .group { margin-top: 18px; }
#dlgExport .group .field-label:first-child { margin-top: 0; }
#exCompressRow { margin-top: 16px; }
.preflight { display: flex; flex-direction: column; gap: 6px; margin-top: 18px; }
.pf { margin: 0; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; line-height: 1.5; border-inline-start: 3px solid; }
.pf-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.pf-info { background: var(--paper-2); color: var(--ink-2); border-color: var(--line-strong); }
.pf-warn { background: var(--warn-soft); color: var(--warn); border-color: #d99a3c; }
.pf-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.progress { margin-top: 18px; }
.progress-bar { height: 8px; border-radius: 99px; background: var(--paper-3); overflow: hidden; }
.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #d4643f, var(--accent));
  background-size: 200% 100%;
  animation: ribbon 1.4s linear infinite;
  transition: width 0.2s;
  margin-inline-start: 0;
}
@keyframes ribbon { to { background-position: -200% 0; } }
.progress-text { margin-top: 6px; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ----- הודעות ----- */

.toasts {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--ink);
  color: #f6efe2;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s, transform 0.25s var(--ease);
}
.toast.show { opacity: 1; transform: none; }
.toast-success { background: #24402f; }
.toast-error { background: #7c2015; }

/* ----- מסכים קטנים ----- */

@media (max-width: 1280px) {
  :root { --side-w: 272px; --props-w: 276px; }
  .brand-text small { display: none; }
}
@media (max-width: 1080px) {
  .top-actions .btn span { display: none; }
  .top-actions .btn { padding: 0 10px; }
  .btn-group { margin-inline-end: 0; }
}
@media (max-width: 900px) {
  body { overflow: auto; }
  .app {
    height: auto;
    min-height: 100vh;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 70vh auto auto;
    grid-template-areas: 'top' 'ws' 'props' 'steps';
  }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .doc { order: 3; flex-basis: 100%; padding: 0; border: none; }
  .top-actions { margin-inline-start: auto; }
  .sidebar { overflow: visible; border: none; border-top: 1px solid var(--line); }
  .canvas-bar { flex-wrap: wrap; justify-content: center; }
  .learner-nav { order: 3; flex-basis: 100%; justify-content: center; }
  .choice-cards { grid-template-columns: 1fr; }
  .font-row { grid-template-columns: minmax(0, 1fr) auto; }
  .font-row .font-meta { grid-column: 1; }
  .gf-grid { grid-template-columns: 1fr; }
}
