:root {
  --bg:          #0d1117;
  --panel:       #12161e;
  --card:        #161b24;
  --line:        rgba(255,255,255,.14);
  --text:        #e8ecf2;
  --muted:       #98a2b3;
  --accent:      #dca24a;
  --accent-soft: #d3a05a;
  --accent2:     #2f86ff;
  --ok:          #33bd6b;
  --input:       #10151d;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: "Rubik", "Segoe UI", system-ui, sans-serif;
}

#nmg-app { display: flex; flex-direction: column; height: 100vh; }
#topbar{ flex-shrink: 0; background: var(--panel);
         border-bottom: 1px solid var(--line); padding: 12px 22px;
         display: flex; align-items: center; justify-content: space-between;
         gap: 12px; flex-wrap: wrap; }
#topbar h1 { font-size: 1.3rem; font-weight: 800; color: var(--accent);
             letter-spacing: .3px; margin: 0; }
#topbar .subtitle { font-size: .85rem; color: var(--muted); margin: 2px 0 0; }
.topbar-actions { display: flex; gap: 8px; flex-shrink: 0; }
.topbar-actions button { font-size: .8rem; padding: 7px 12px; width: auto; }

#main  { display: flex; flex: 1; min-height: 0; }
#viewport { position: relative; flex: 1; min-width: 0; background: #0a0d12; }
#panel    { width: 340px; flex-shrink: 0; background: var(--panel);
            border-left: 1px solid var(--line); overflow-y: auto; padding: 12px 14px; }

#mobileNotice { display: none; }

/* ---- card ---- */
.card   { background: var(--card); border: 1px solid var(--line);
          border-radius: 11px; padding: 9px 12px; margin-bottom: 10px; }
.card h2{ font-size: .95rem; color: var(--accent); margin: 0 0 8px;
          font-weight: 700; letter-spacing: .2px; }
.card.locked        { opacity: .5; }
.card.locked h2     { color: var(--muted); }
.card .hint { font-size: .78rem; color: var(--muted); line-height: 1.45; margin: 6px 0 0; }

/* ---- collapsible cards 3/4/5/6 — folded by default, one open at a time ---- */
.accordion-trigger {
  width: calc(100% + 24px); margin: -9px -12px 0; padding: 9px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: transparent; border: none; border-radius: 11px 11px 0 0;
  cursor: pointer; color: var(--text); font-family: inherit; text-align: right;
}
.accordion-trigger:hover:not(:disabled) { background: rgba(255,255,255,.04); }
.accordion-trigger:disabled { cursor: not-allowed; }
.accordion-title-group { display: flex; align-items: baseline; gap: 8px; }
.accordion-title { font-size: .95rem; font-weight: 700; color: var(--accent); letter-spacing: .2px; }
.card.locked .accordion-title { color: var(--muted); }
.accordion-optional {
  font-size: .68rem; color: var(--muted); background: rgba(255,255,255,.06);
  border-radius: 5px; padding: 2px 7px;
}
.chevron { width: 16px; height: 16px; flex-shrink: 0; transition: transform .18s ease; color: var(--muted); }
.accordion-trigger[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.accordion-body { max-height: 0; overflow: hidden; transition: max-height .22s ease; }
.accordion-body-content { padding-top: 8px; }

/* ---- buttons ---- */
button.primary {
  background: var(--accent-soft); color: #201603; border: none;
  border-radius: 9px; padding: 11px; font-weight: 700; font-size: .92rem;
  cursor: pointer; width: 100%;
}
button.primary:hover    { filter: brightness(1.06); }
button.primary:disabled { opacity: .45; cursor: not-allowed; }
button.primary.alt { background: var(--ok); color: #fff; }

button.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  border-radius: 8px; padding: 7px 10px; font-size: .82rem; cursor: pointer; width: 100%;
}
button.ghost:hover        { color: var(--text); border-color: var(--accent2); }
button.ghost:disabled     { opacity: .45; cursor: not-allowed; }
button.ghost.danger:not(:disabled) { color: #fff; background: #d9534f; border-color: #d9534f; }
button.ghost.danger:not(:disabled):hover { filter: brightness(1.08); }
button.ghost.accent:not(:disabled) { color: var(--accent); border-color: var(--accent); border-width: 2px; }
button.ghost.accent:not(:disabled):hover { background: rgba(220,162,74,.1); }
#btn-add-base { margin-bottom: 8px; }

.btn-row { display: flex; gap: 6px; margin-top: 6px; }
.btn-row button { flex: 1; }

/* ---- file upload ---- */
.file-btn {
  display: flex; align-items: center; justify-content: center;
  min-height: 64px; border: 2px dashed var(--line); border-radius: 9px;
  cursor: pointer; color: var(--muted); text-align: center; font-size: .85rem;
  padding: 10px; transition: border-color .15s, color .15s;
}
.file-btn:hover { border-color: var(--accent); color: var(--text); }
.file-btn input { display: none; }
.file-btn.filled { border-style: solid; border-color: var(--ok); color: var(--text); }
.file-info { font-size: .78rem; color: var(--muted); margin-top: 6px; }
.sample-btn { margin-top: 8px; }

/* ---- fields ---- */
.field { margin-bottom: 8px; }
.field:last-child { margin-bottom: 0; }
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; }
.field label { display: block; font-size: .7rem; color: var(--muted); margin-bottom: 4px; }
.field input[type="number"] {
  width: 100%; background: var(--input); border: 1px solid var(--line);
  color: var(--text); border-radius: 7px; padding: 8px; font-size: .85rem;
  font-family: inherit;
}
.field input:focus { outline: none; border-color: var(--accent); }

/* select uses the exact same box as the number fields above, plus a custom arrow */
.field select {
  width: 100%; background: var(--input); border: 1px solid var(--line);
  color: var(--text); border-radius: 7px; padding: 8px 8px 8px 26px; font-size: .85rem;
  font-family: inherit; cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%2398a2b3' stroke-width='1.6' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: left 10px center;
}
.field select:focus { outline: none; border-color: var(--accent); }

/* ---- dim tiles (live placement readout) ---- */
.dims { display: flex; gap: 6px; margin-bottom: 8px; }
.dim       { flex: 1; background: var(--input); border: 1px solid var(--line);
             border-radius: 9px; padding: 6px; text-align: center; }
.dim-label { display: block; font-size: .68rem; color: var(--muted); margin-bottom: 3px; }
.dim-val   { display: block; font-size: .85rem; font-weight: 600; color: var(--text); }

/* ---- spinner ---- */
.spinner { position: absolute; inset: 0; display: flex; flex-direction: column;
           align-items: center; justify-content: center; gap: 14px;
           background: rgba(16,19,26,.6); color: var(--text); z-index: 5; }
.spin    { width: 44px; height: 44px; border: 4px solid var(--line);
           border-top-color: var(--accent); border-radius: 50%;
           animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- empty-state hint ---- */
.hint-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); text-align: center; padding: 20px; font-size: .95rem;
  pointer-events: none;
}

/* ---- bottom banners: dims + watermark notice, stacked above one another ---- */
#bottom-banners { position: absolute; bottom: 0; left: 0; right: 0; z-index: 4;
                   display: flex; flex-direction: column; }
#dims-banner {
  background: rgba(11,13,18,.9); color: var(--text);
  border-top: 1px solid var(--line);
  text-align: center; font-size: .85rem; font-family: inherit;
  padding: 9px 16px; pointer-events: none;
}
#watermark-banner {
  background: linear-gradient(180deg, #3a2c0c, #2c2109);
  color: var(--accent);
  border-top: 1px solid rgba(220, 162, 74, .5);
  text-align: center; font-size: .9rem; font-weight: 600; line-height: 1.5;
  padding: 9px 16px; pointer-events: none;
}
#watermark-banner[hidden] { display: none; }

/* ---- overlay tools ---- */
.overlay-tools        { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; }
.overlay-tools button { background: rgba(30,36,48,.8); color: var(--text);
                        border: 1px solid var(--line); border-radius: 8px;
                        padding: 6px 10px; font-size: .82rem; cursor: pointer; }
.overlay-tools button:hover { border-color: var(--accent2); }

/* "הדרכה" — data-driven guide-video link, brand-colored to stand out as a CTA */
.guide-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: #201603; font-weight: 700;
  font-family: inherit; border: 1px solid var(--accent-soft); border-radius: 8px;
  padding: 6px 18px; font-size: .82rem; text-decoration: none; white-space: nowrap;
  cursor: pointer;
}
.guide-btn:hover { filter: brightness(1.06); }
.guide-btn[hidden] { display: none; }

/* ---- status text ---- */
.status { font-size: .78rem; color: var(--muted); min-height: 16px; margin-top: 6px; }
.status.err { color: #ff7a90; }
.status.ok  { color: var(--ok); }

canvas { display: block; width: 100%; height: 100%; }

/* ---- WordPress-plugin-only additions: credit badge, balance, error dialog ---- */
/* Note: the guest login-note lives on the PARENT page (outside the iframe,
   rendered directly by class-nmg-shortcode.php with its own inline <style>),
   not here — this stylesheet only loads inside the logged-in-only app iframe. */

/* ---- msgbox: shared server/communication-error dialog (same across our apps) ---- */
.msgbox {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(8, 11, 20, .66);
}
.msgbox[hidden] { display: none; }

.msgbox-card {
  width: min(430px, 100%); box-sizing: border-box; text-align: center;
  background: #1e2438; border: 1px solid #2b3350;
  border-top: 4px solid #ff5c72;
  border-radius: 16px; padding: 26px 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  animation: msgbox-pop .16s ease-out;
  font-family: "Segoe UI", system-ui, sans-serif; direction: rtl;
}
.msgbox-icon  { font-size: 40px; line-height: 1; margin-bottom: 10px; }
.msgbox-title { margin: 0 0 8px; font-size: 18px; font-weight: 700; color: #e7eaf3; }
.msgbox-msg   { margin: 0 0 20px; font-size: 14px; line-height: 1.65; color: #9aa3bd; }
.msgbox-btn {
  min-width: 130px; padding: 10px 18px; border-radius: 10px; border: none;
  cursor: pointer; font-family: inherit; font-weight: 700; font-size: 14px; color: #fff;
  background: linear-gradient(90deg, #5b8cff, #7c5cff);
}
.msgbox-btn:hover { filter: brightness(1.08); }
@keyframes msgbox-pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .msgbox-card { animation: none; } }

#btn-download { display: flex; align-items: center; justify-content: center; gap: 8px; }
.nmg-dl-text { font-size: 1rem; font-weight: 700; line-height: 1; }
.nmg-cost { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-variant-numeric: tabular-nums; }
.nmg-cost-num { font-size: 1.05em; font-weight: 800; line-height: 1; }
.nmg-credit-ico { width: 20px; height: 20px; display: inline-block; }

/* ---- mobile layout ----
   Must stay the LAST block in this file: #main/#viewport/#panel already
   have unconditional rules above with the same specificity (plain #id), and
   with equal specificity the LATER rule in the file wins regardless of the
   @media condition — an earlier @media block here would be silently beaten
   by those base rules despite matching. */
@media (max-width: 768px) {
  #main { flex-direction: column; }
  /* #panel comes before #viewport in the markup (so it lands on the right
     in the RTL desktop row) — column direction alone would stack them in
     that same DOM order (panel on top). order: -1 forces the viewport
     first regardless, matching the rest of the site's mobile layout. */
  #viewport { order: -1; flex: 0 0 42vh; min-height: 220px; }
  #panel {
    width: 100%; flex: 1; min-height: 0;
    border-left: none; border-top: 1px solid var(--line);
  }
  #mobileNotice {
    display: block; text-align: center; font-weight: 700; font-size: 13px;
    background: var(--accent-soft); color: #201603;
    border-radius: 9px; padding: 8px 10px; margin-bottom: 10px;
  }
}
