/* Studio AR: one dark, warm theme. Phone first; from 900px the editor opens into three columns. */
@font-face { font-family: Heebo; src: url(fonts/heebo-hebrew.woff2) format("woff2"); font-weight: 400 800; font-display: swap; unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: Heebo; src: url(fonts/heebo-latin.woff2) format("woff2"); font-weight: 400 800; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #0e0d12; --surface: #17161d; --surface-2: #1f1e27; --surface-3: #292733; --line: #2c2a36; --line-2: #3b3848;
  --text: #f3f1ec; --muted: #9a97a6; --accent: #8b6cff; --accent-soft: rgba(139,108,255,.16); --accent-2: #ff8f6b;
  --ok: #4cd4a0; --warn: #ffc857; --danger: #ff6b7a;
  --r: 14px; --r-s: 10px; --shadow: 0 18px 50px rgba(0,0,0,.5);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.5 Heebo, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .4; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ic { display: inline-flex; flex: none; line-height: 0; }
.ic-trash { color: #ff4d5e; }
.grow { flex: 1; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface-2); font-weight: 600; white-space: nowrap; transition: background .15s, border-color .15s, transform .08s; }
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, #9a7dff, #7a5cf5); border-color: transparent; color: #fff; box-shadow: 0 6px 18px rgba(122,92,245,.35); }
.btn.primary:hover:not(:disabled) { background: linear-gradient(135deg, #a78dff, #8468ff); }
.btn.ghost { background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn.danger { background: rgba(255,107,122,.12); border-color: rgba(255,107,122,.4); color: var(--danger); }
.btn.small { min-height: 34px; padding: 0 12px; border-radius: 10px; font-size: 13.5px; gap: 6px; }
.btn.big { min-height: 50px; padding: 0 22px; font-size: 16px; border-radius: 14px; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; padding: 0; border: 0; border-radius: 11px; background: transparent; color: var(--text); transition: background .15s; }
.icon-btn:hover:not(:disabled) { background: var(--surface-2); }
.icon-btn.on { background: var(--accent-soft); color: #b9a6ff; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row > .btn { flex: 1 1 auto; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---------- gallery ---------- */
#home { min-height: 100%; background: radial-gradient(900px 480px at 85% -10%, rgba(139,108,255,.20), transparent 60%), radial-gradient(700px 420px at 0% 0%, rgba(255,143,107,.10), transparent 60%); }
.home-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(14px + var(--safe-t)) 18px 14px; max-width: 1180px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: conic-gradient(from 210deg, #8b6cff, #ff8f6b, #ffd166, #8b6cff); box-shadow: inset 0 0 0 6px var(--bg), 0 0 0 1px var(--line-2); }
.home-actions { display: flex; gap: 8px; }
.home-main { max-width: 1180px; margin: 0 auto; padding: 18px 18px calc(60px + var(--safe-b)); }
.home-title { display: flex; align-items: baseline; gap: 12px; margin: 10px 0 20px; }
.home-title h1 { font-size: clamp(28px, 6vw, 42px); font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
#home-count { color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 14px; }
.card { position: relative; display: flex; flex-direction: column; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; transition: transform .18s, border-color .18s, box-shadow .18s; }
.card:hover { transform: translateY(-3px); border-color: var(--line-2); box-shadow: var(--shadow); }
.card-open { display: block; padding: 0; border: 0; background: none; width: 100%; }
.card-pic { display: grid; place-items: center; aspect-ratio: 4 / 5; background: #0a090d; overflow: hidden; }
.card-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-noart { display: grid; justify-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.card-foot { display: flex; align-items: center; gap: 4px; padding: 10px 12px 10px 4px; }
.card-text { flex: 1; min-width: 0; display: grid; }
.card-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { color: var(--muted); font-size: 12.5px; }
.card-new { align-items: center; justify-content: center; gap: 10px; min-height: 180px; border: 1.5px dashed var(--line-2); background: transparent; color: var(--text); }
.card-new:hover { border-color: var(--accent); background: var(--accent-soft); }
.card-plus { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; background: var(--accent-soft); color: #b9a6ff; }
#home-empty { display: grid; justify-items: center; text-align: center; gap: 14px; padding: 6vh 10px; }
#home-empty h2 { font-size: clamp(24px, 5vw, 34px); font-weight: 800; letter-spacing: -.02em; }
#home-empty p { color: var(--muted); max-width: 440px; font-size: 16px; }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 8px; }
.empty-art { position: relative; width: 170px; height: 190px; margin-bottom: 10px; }
.empty-art i { position: absolute; inset: 0; border-radius: 20px; border: 1px solid var(--line-2); }
.empty-art i:nth-child(1) { background: linear-gradient(160deg, #2a2440, #17161d); transform: rotate(-9deg) translate(16px, 6px); }
.empty-art i:nth-child(2) { background: linear-gradient(160deg, #ff8f6b, #c9527a); transform: rotate(5deg) translate(-10px, 0); opacity: .9; }
.empty-art i:nth-child(3) { background: linear-gradient(160deg, #9a7dff, #5a3fd6); transform: translateY(-8px); box-shadow: 0 20px 40px rgba(90,63,214,.45); animation: bob 4s ease-in-out infinite; }
.empty-art.small { width: 110px; height: 124px; }
@keyframes bob { 50% { transform: translateY(-18px) rotate(-2deg); } }

/* ---------- editor frame ---------- */
#editor { position: fixed; inset: 0; display: grid; grid-template-columns: 100%; grid-template-rows: auto minmax(200px, 44dvh) auto minmax(0, 1fr); background: var(--bg); }
#topbar { display: flex; align-items: center; gap: 4px; padding: calc(6px + var(--safe-t)) 8px 6px; border-bottom: 1px solid var(--line); background: var(--surface); min-width: 0; }
#rec-name { flex: 0 1 220px; min-width: 60px; height: 38px; padding: 0 10px; border: 1px solid transparent; border-radius: 10px; background: transparent; font-weight: 700; font-size: 16px; text-overflow: ellipsis; }
#rec-name:hover { border-color: var(--line); }
#rec-name:focus { border-color: var(--accent); background: var(--bg); outline: 0; }
#save-pill { flex: none; font-size: 12px; color: var(--muted); padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
#save-pill::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); margin-inline-end: 6px; vertical-align: 1px; }
#save-pill[data-state="saving"]::before { background: var(--warn); animation: pulse 1s infinite; }
#save-pill[data-state="error"] { color: var(--danger); background: rgba(255,107,122,.12); }
#save-pill[data-state="error"]::before { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }
.top-btn { min-height: 38px; padding: 0 12px; border-radius: 11px; }

#stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background-color: #0a090d; background-image: radial-gradient(rgba(255,255,255,.055) 1px, transparent 1px); background-size: 18px 18px; }
#canvas-wrap { position: absolute; inset: 0; min-height: 0 !important; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#preview { display: block; touch-action: none; }
#stage-empty { position: absolute; inset: 0; z-index: 3; display: grid; align-content: center; justify-items: center; gap: 10px; padding: 16px; text-align: center; background: var(--bg); }
#stage-art { position: absolute; inset: 0; z-index: 3; display: grid; align-content: center; justify-items: center; gap: 10px; padding: 16px; text-align: center; background: var(--bg); }
#stage-art p { color: var(--muted); max-width: 300px; font-size: 14px; margin: 0 0 4px; }
#stage-art[data-state="loading"] .btn { display: none; }
#stage-empty h2 { font-size: 20px; font-weight: 800; }
#stage-empty p { color: var(--muted); max-width: 320px; font-size: 14px; margin-bottom: 6px; }
#stage-tools { position: absolute; z-index: 7; inset-inline: 8px; bottom: 8px; display: flex; align-items: center; gap: 8px; pointer-events: none; }
#stage-tools > * { pointer-events: auto; }
#stage-tools .zoom { margin-inline-start: auto; }
#stage-tools .icon-btn { width: 36px; height: 36px; background: rgba(23,22,29,.86); border: 1px solid var(--line-2); backdrop-filter: blur(8px); color: var(--muted); }
#stage-tools .icon-btn.on { color: #b9a6ff; border-color: rgba(139,108,255,.5); }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: rgba(23,22,29,.86); border: 1px solid var(--line-2); backdrop-filter: blur(8px); }
.seg button { display: inline-grid; place-items: center; min-width: 30px; height: 28px; padding: 0 10px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; }
.seg button.on { background: var(--accent); color: #fff; }
.seg.zoom button { padding: 0 6px; }
#zoom-label { min-width: 46px; font-variant-numeric: tabular-nums; }
#sel-bar { position: absolute; z-index: 7; top: 8px; inset-inline-start: 8px; width: max-content; max-width: calc(100% - 16px); display: flex; flex-wrap: wrap; justify-content: flex-start; align-items: center; gap: 2px; padding: 3px 3px 3px 3px; padding-inline-start: 12px; border-radius: 12px; background: rgba(23,22,29,.9); border: 1px solid var(--line-2); backdrop-filter: blur(8px); }
#sel-bar .sel-name { font-size: 13px; font-weight: 600; flex: 0 1 auto; min-width: 0; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-inline-end: 6px; }
#sel-bar .icon-btn { flex: none; width: 32px; height: 32px; border-radius: 9px; }
#sel-bar .sel-grip { flex: none; display: grid; place-items: center; width: 28px; height: 32px; margin-inline: -8px 2px; padding: 0; border: 0; border-radius: 9px; background: none; color: var(--muted); cursor: grab; touch-action: none; }
#sel-bar.moved { inset-inline-start: auto; z-index: 12; }
#sel-bar.min { padding: 3px; }
#sel-bar.min > :not(.sel-grip) { display: none; }
#sel-bar.min .sel-grip { margin: 0; width: 32px; color: var(--text, #fff); }
.crop-dlg .dlg-body { justify-items: center; }
.crop-box { position: relative; display: inline-block; max-width: 100%; line-height: 0; overflow: hidden; border-radius: 8px; touch-action: none; user-select: none; -webkit-user-select: none; }
.crop-box img { display: block; max-width: 100%; max-height: min(52dvh, 460px); }
.crop-frame { position: absolute; box-sizing: border-box; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.6); cursor: move; touch-action: none; }
.crop-h { position: absolute; width: 36px; height: 36px; touch-action: none; }
.crop-h::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: #fff; border: 2px solid var(--accent, #8b6cff); }
.crop-h[data-c="nw"] { left: -10px; top: -10px; cursor: nwse-resize; } .crop-h[data-c="ne"] { right: -10px; top: -10px; cursor: nesw-resize; }
.crop-h[data-c="sw"] { left: -10px; bottom: -10px; cursor: nesw-resize; } .crop-h[data-c="se"] { right: -10px; bottom: -10px; cursor: nwse-resize; }
.crop-tools { display: flex; align-items: center; justify-content: center; gap: 14px; width: 100%; }
.crop-turn { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.08); border: 1px solid var(--line-2); }
.crop-turn.left svg { transform: scaleX(-1); }
.crop-size { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; direction: ltr; }
.stage-hint { position: absolute; z-index: 9; inset-inline: 8px; top: 8px; margin-inline: auto; max-width: 460px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 14px; background: rgba(23,22,29,.94); border: 1px solid rgba(139,108,255,.6); box-shadow: 0 6px 24px rgba(0,0,0,.45); font-size: 14px; font-weight: 600; backdrop-filter: blur(8px); }
.stage-hint > span { flex: 1 1 160px; line-height: 1.35; }
.stage-hint > svg { color: #b9a6ff; flex: none; }
.stage-hint.multi > span { flex-basis: 50px; white-space: nowrap; }
.stage-hint .btn { min-height: 36px;  pointer-events: auto; }
.stage-hint { pointer-events: none; } /* the line can be drawn right through the hint; only its buttons take a touch */
#time-chip { position: absolute; z-index: 7; top: 8px; inset-inline-end: 8px; display: flex; align-items: center; gap: 8px; padding: 3px; padding-inline-start: 12px; border-radius: 12px; background: rgba(255,200,87,.14); border: 1px solid rgba(255,200,87,.45); color: var(--warn); font-size: 13px; font-weight: 600; backdrop-filter: blur(8px); }
#time-chip button { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border: 0; border-radius: 9px; background: var(--warn); color: #201a05; font-weight: 700; font-size: 13px; }
/* the 3D tools sit on the left edge, so the name of the picked layer and the time chip keep to the right */
#stage.is-3d #time-chip { top: 54px; inset-inline-end: auto; inset-inline-start: 8px; }
#stage.is-3d #stage-tools .zoom { display: none; }
#stage.is-3d #sel-bar .sel-name { max-width: 15vw; }
@media (max-width: 440px) { #stage.is-3d #sel-bar .sel-name { display: none; } } /* a narrow phone in 3D: the buttons keep clear of the 3D tools */
#stage.is-3d #sel-bar:not(.moved) { top: 52px; max-width: calc(100% - 76px); } /* under the move / turn buttons, beside the three turn circles */
#stage.is-crop { box-shadow: inset 0 0 0 2px var(--warn); }
#editor.dropping #stage::after { content: "משחררים כאן כדי להוסיף"; position: absolute; inset: 10px; z-index: 20; display: grid; place-items: center; border: 2px dashed var(--accent); border-radius: 16px; background: rgba(139,108,255,.18); font-weight: 700; font-size: 18px; pointer-events: none; }

#tabs { display: flex; gap: 2px; padding: 4px 6px; background: var(--surface); border-block: 1px solid var(--line); }
.tab { flex: 1; display: grid; justify-items: center; gap: 1px; min-width: 0; padding: 6px 2px 5px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.tab.on { color: #fff; background: var(--accent-soft); }
.tab.on .ic { color: #b9a6ff; }
.tab.dim { opacity: .45; }

#layers-pane, #inspector { grid-row: 4; grid-column: 1; min-height: 0; overflow-y: auto; background: var(--surface); overscroll-behavior: contain; }
#layers-pane { display: flex; flex-direction: column; }
body[data-pane="layers"] #inspector, body[data-pane="inspector"] #layers-pane { display: none; }
#inspector { padding: 12px 14px calc(28px + var(--safe-b)); }
.pane-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--surface); }
.pane-head h2 { font-size: 15px; font-weight: 700; }
#layer-count { color: var(--muted); font-weight: 500; margin-inline-start: 4px; }

/* ---------- layers ---------- */
#layer-list { display: flex; flex-direction: column; gap: 6px; padding: 2px 10px 10px; flex: 1; }
.layer-row { position: relative; display: flex; align-items: center; gap: 8px; min-height: 54px; padding: 6px 4px; border-radius: 13px; border: 1px solid transparent; background: var(--surface-2); cursor: pointer; user-select: none; -webkit-user-select: none; transition: background .12s, border-color .12s; }
.layer-row:hover { background: var(--surface-3); }
.layer-row.on { background: var(--accent-soft); border-color: rgba(139,108,255,.55); }
.layer-row.dragging { z-index: 5; box-shadow: var(--shadow); background: var(--surface-3); transition: none; cursor: grabbing; }
#layer-list.sorting .layer-row:not(.dragging) { transition: transform .15s; }
.row-grip { display: grid; place-items: center; width: 26px; height: 40px; color: var(--muted); cursor: grab; touch-action: none; }
.layer-thumb { --tint: var(--accent); display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 10px; overflow: hidden; color: var(--tint); background: color-mix(in srgb, var(--tint) 16%, var(--surface)); }
.layer-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.layer-thumb.art { border-radius: 8px; background: #0a090d; }
.layer-thumb-text { font-weight: 800; font-size: 20px; line-height: 1; }
.layer-text { flex: 1; min-width: 0; display: grid; }
.layer-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-more { width: 36px; height: 36px; color: var(--muted); }
.row-lock { width: 36px; height: 36px; color: var(--warn); }
.layer-row.locked .layer-thumb, .layer-row.locked .layer-text { opacity: .55; }
.layer-row.member { margin-inline-start: 18px; min-height: 48px; }
.member-mark { color: var(--muted); opacity: .6; cursor: default; transform: scaleX(-1); }
.layer-row.choosing { padding-inline-start: 8px; }
.layer-row.cannot { opacity: .45; }
.row-check { display: grid; place-items: center; flex: none; width: 24px; height: 24px; margin-inline-end: 2px; border-radius: 7px; border: 2px solid var(--line-2); color: #fff; }
.row-check.on { background: var(--accent); border-color: var(--accent); }
.pane-head { gap: 8px; }
.pane-head { justify-content: flex-start; }
.pane-head h2 { flex: none; }
.pane-head .multi-head { flex: 1; }
.multi-head { display: flex; gap: 6px; }
.layers-empty { display: grid; justify-items: center; gap: 12px; padding: 22px 16px; text-align: center; color: var(--muted); }
.layers-empty p { max-width: 280px; font-size: 14px; }
.pane-head #btn-add[hidden] { display: none; }
#art-card { display: flex; align-items: center; gap: 10px; margin: 0 10px calc(12px + var(--safe-b)); padding: 8px 10px; border-radius: 13px; border: 1px dashed var(--line-2); }

/* ---------- inspector ---------- */
.insp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.name-field { flex: 1; min-width: 0; font-weight: 700; }
.in-group { display: flex; align-items: center; gap: 6px; margin: -4px 0 12px; padding: 4px 8px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 13px; }
.in-group > span:not(.ic) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.in-group .btn.small { min-height: 30px; padding: 0 8px; }
.group { padding: 14px; margin-bottom: 10px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); display: grid; gap: 14px; }
.group-title { font-size: 12.5px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.ctl { display: grid; gap: 7px; min-width: 0; }
.ctl-label { font-size: 13.5px; font-weight: 600; }
.ctl-hint { display: block; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.ctl-hint.bad { color: var(--danger); }
.field { width: 100%; min-height: 42px; padding: 8px 12px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--bg); color: var(--text); }
.field:focus { border-color: var(--accent); outline: 0; box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.field { resize: vertical; min-height: 78px; line-height: 1.45; }
select.field { appearance: none; -webkit-appearance: none; padding-inline-end: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%239a97a6' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 13px center; }
.slider-row { display: flex; align-items: center; gap: 10px; }
.range { --fill: 0%; flex: 1; min-width: 0; height: 28px; margin: 0; background: transparent; appearance: none; -webkit-appearance: none; direction: ltr; touch-action: pan-y; }
.range::-webkit-slider-runnable-track { height: 6px; border-radius: 6px; background: linear-gradient(to right, var(--accent) var(--fill), var(--line-2) var(--fill)); }
.range::-moz-range-track { height: 6px; border-radius: 6px; background: linear-gradient(to right, var(--accent) var(--fill), var(--line-2) var(--fill)); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 2px 8px rgba(0,0,0,.5); }
.range::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 2px 8px rgba(0,0,0,.5); }
.num-wrap { display: inline-flex; align-items: center; gap: 3px; flex: none; height: 34px; padding: 0 8px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--bg); direction: ltr; }
.num-wrap:focus-within { border-color: var(--accent); }
.num { width: 44px; border: 0; background: transparent; text-align: center; font-variant-numeric: tabular-nums; outline: 0; padding: 0; -moz-appearance: textfield; }
.num::-webkit-outer-spin-button, .num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.unit { color: var(--muted); font-size: 12px; }
.ctl-toggle { grid-template-columns: 1fr auto; align-items: center; cursor: pointer; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.knob { position: absolute; inset: 0; border-radius: 28px; background: var(--line-2); transition: background .15s; pointer-events: none; }
.knob::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .knob { background: var(--accent); }
.switch input:checked + .knob::after { transform: translateX(-18px); }
.switch input:focus-visible + .knob { outline: 2px solid var(--accent); outline-offset: 2px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 1px; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 36px; padding: 0 13px; border-radius: 20px; border: 1px solid var(--line-2); background: var(--bg); color: var(--text); font-size: 13.5px; font-weight: 500; white-space: nowrap; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.font-chip { font-size: 17px; min-height: 40px; }
.swatches .chip { padding: 4px; border-radius: 12px; }
.swatches .chip.on { background: var(--bg); box-shadow: 0 0 0 2px var(--accent); }
.swatch { display: inline-flex; width: 54px; height: 28px; border-radius: 8px; overflow: hidden; }
.swatch i { flex: 1; }
.looks .chip { flex-direction: column; gap: 5px; padding: 5px 5px 6px; border-radius: 12px; font-size: 12px; }
.look-pic { width: 60px; height: 60px; border-radius: 8px; background: var(--bg) center / cover; }
.ctl-color { grid-template-columns: 1fr auto; align-items: center; }
.color-wrap { display: inline-flex; align-items: center; gap: 8px; padding: 4px; padding-inline-start: 10px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg); }
.color-hex { font-size: 12.5px; color: var(--muted); direction: ltr; font-variant-numeric: tabular-nums; }
.color { width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px; background: none; cursor: pointer; }
.color::-webkit-color-swatch-wrapper { padding: 0; }
.color::-webkit-color-swatch { border: 1px solid var(--line-2); border-radius: 8px; }
.color-trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.color-trio .ctl-color { grid-template-columns: 1fr; }
.color-trio .color-hex { display: none; }
.color-trio .color-wrap { justify-content: center; padding: 4px; }
.color-trio .color { width: 100%; }
.note { display: flex; gap: 8px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.note .ic { margin-top: 1px; color: var(--accent-2); }
.art-big { display: block; width: 100%; max-height: 220px; object-fit: contain; border-radius: 10px; background: #0a090d; }
.stat-row { display: flex; justify-content: space-between; font-size: 14px; }
.stat-row span { color: var(--muted); }
.meter { height: 6px; border-radius: 6px; background: var(--line-2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.tips { margin: 0; padding: 0; padding-inline-start: 18px; display: grid; gap: 6px; color: var(--muted); font-size: 13.5px; }

/* ---------- motion ---------- */
.tl { display: grid; }
.tl-bar { display: flex; align-items: center; gap: 10px; }
.tl-play { background: var(--accent); color: #fff; border-radius: 50%; }
.tl-play:hover:not(:disabled) { background: #9a7dff; }
.tl-time { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 62px; }
.tl-step { color: var(--muted); font-size: 13px; margin-inline-start: auto; }
.tl-track { position: relative; height: 64px; margin: 0 9px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line-2); touch-action: none; cursor: pointer; user-select: none; -webkit-user-select: none; }
.tl-ticks, .tl-keys { position: absolute; inset: 0; pointer-events: none; }
.tl-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.tl-tick i { position: absolute; bottom: 3px; left: 4px; font-style: normal; font-size: 10.5px; color: var(--muted); }
.tl-key { position: absolute; top: 14px; width: 22px; height: 22px; margin-left: -11px; padding: 0; border: 2px solid #fff; border-radius: 5px; background: var(--accent); transform: rotate(45deg); pointer-events: auto; touch-action: none; cursor: grab; }
.tl-key::before { content: ""; position: absolute; inset: -10px; }
.tl-key.on { background: var(--warn); box-shadow: 0 0 0 4px rgba(255,200,87,.3); }
.tl-key.hide { background: var(--surface-3); border-style: dashed; }
.tl-head { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--accent-2); border-radius: 2px; pointer-events: none; }
.tl-head::before { content: ""; position: absolute; top: -3px; left: -5px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent-2); }

/* ---------- dialogs, menus, toasts ---------- */
dialog { color: var(--text); }
dialog::backdrop { background: rgba(6,5,10,.66); backdrop-filter: blur(3px); }
.dlg { width: min(440px, calc(100vw - 28px)); max-height: min(86dvh, 720px); padding: 0; border: 1px solid var(--line-2); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.dlg[open] { display: flex; flex-direction: column; animation: pop .18s ease-out; }
.dlg.wide { width: min(760px, calc(100vw - 28px)); }
@keyframes pop { from { opacity: 0; scale: .96; } }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 12px 8px 18px; padding-inline: 18px 10px; }
.dlg-head h2 { font-size: 18px; font-weight: 800; }
.dlg-body { padding: 6px 18px 18px; overflow-y: auto; display: grid; gap: 12px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px calc(14px + var(--safe-b)); border-top: 1px solid var(--line); }
.dlg-text { color: var(--muted); }
@media (max-width: 899px) {
  .dlg.sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; max-height: 88dvh; border-radius: 22px 22px 0 0; border-width: 1px 0 0; }
  .dlg.sheet[open] { animation: rise .22s ease-out; }
  .dlg.sheet .dlg-body { padding-bottom: calc(22px + var(--safe-b)); }
}
@keyframes rise { from { translate: 0 40px; opacity: 0; } }
.menu { position: fixed; z-index: 1000; min-width: 190px; padding: 6px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface-2); box-shadow: var(--shadow); animation: pop .12s ease-out; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; text-align: start; font-weight: 500; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-3); outline: 0; }
.menu-item.danger { color: var(--danger); }
.menu-sep { height: 1px; margin: 5px 8px; background: var(--line); }
#toasts { position: fixed; z-index: 2000; inset-inline: 0; bottom: calc(18px + var(--safe-b)); display: grid; justify-items: center; gap: 8px; padding: 0 14px; pointer-events: none; }
.toast, .busy { display: flex; align-items: center; gap: 12px; max-width: min(460px, 100%); padding: 11px 16px; border-radius: 14px; background: #f3f1ec; color: #17161d; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); pointer-events: auto; animation: rise .2s ease-out; }
.toast.error { background: #ff6b7a; color: #2a0509; }
.toast.warn { background: var(--warn); color: #201a05; }
.toast.out { opacity: 0; translate: 0 10px; transition: opacity .2s, translate .2s; }
.toast-act { flex: none; padding: 5px 12px; border: 0; border-radius: 9px; background: #17161d; color: #fff; font-weight: 700; font-size: 13px; }
.spinner { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 2.5px solid rgba(23,22,29,.25); border-top-color: #17161d; animation: spin .7s linear infinite; }
@keyframes spin { to { rotate: 360deg; } }

/* ---------- add sheet, share ---------- */
.add-library, .share-tile { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line-2); background: var(--surface-2); text-align: start; transition: background .15s, border-color .15s; }
.add-library { background: linear-gradient(135deg, rgba(139,108,255,.22), rgba(255,143,107,.14)); border-color: rgba(139,108,255,.45); }
.add-library > span:nth-child(2) { flex: 1; display: grid; }
.add-library:hover, .share-tile:hover:not(:disabled) { border-color: var(--accent); }
.add-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.add-tile { --tint: var(--accent); display: grid; justify-items: start; gap: 2px; padding: 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface-2); text-align: start; transition: border-color .15s, transform .08s; }
.add-tile:hover { border-color: var(--tint); }
.part-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.part-tile { display: grid; gap: 6px; padding: 6px 6px 8px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface-2); text-align: center; transition: border-color .15s, transform .08s; }
.part-tile:hover { border-color: var(--accent); }
.part-tile:active { transform: scale(.97); }
.part-pic { display: grid; place-items: center; aspect-ratio: 1; border-radius: 11px; overflow: hidden; background: #17161d; color: var(--muted); }
.part-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.part-name { font-size: 13px; font-weight: 600; line-height: 1.25; }
.add-tile:active { transform: scale(.97); }
.add-ic, .share-ic { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 12px; color: var(--tint, #b9a6ff); background: color-mix(in srgb, var(--tint, #8b6cff) 18%, var(--surface)); margin-bottom: 4px; }
.add-library .add-ic, .share-ic { margin-bottom: 0; }
.add-name { font-weight: 700; }
.add-hint { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.share-list { display: grid; gap: 8px; }
.share-text { display: grid; }
.share-text span, .share-state { color: var(--muted); font-size: 13px; }

/* ---------- starter library (built by library.js) ---------- */
#starter-library { width: min(880px, calc(100vw - 20px)); max-height: 90dvh; padding: 16px; border: 1px solid var(--line-2); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
#starter-library .library-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#starter-library h2 { font-size: 20px; font-weight: 800; }
#starter-library .library-section { grid-column: 1 / -1; margin: 10px 2px 0; font-size: 15px; font-weight: 800; }
#starter-library .library-section[hidden] { display: none; }
#starter-library .library-section:first-child { margin-top: 0; }
#starter-library .library-side { display: flex; align-items: center; gap: 6px; }
#starter-library .library-import { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; }
#starter-library .library-import[hidden] { display: none; }
#starter-library .hint { color: var(--muted); font-size: 12.5px; }
#starter-library > .hint, #starter-library > p { margin: 6px 0; }
#starter-library button.ghost { min-height: 36px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line-2); background: var(--bg); color: var(--text); font-weight: 600; font-size: 13.5px; }
#starter-library .library-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 12px; }
#starter-library .library-filters button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
#starter-library .library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
#starter-library .library-card { display: grid; gap: 4px; padding: 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); text-align: start; transition: border-color .15s, transform .08s; }
#starter-library .library-card:hover { border-color: var(--accent); }
#starter-library .library-card:active { transform: scale(.97); }
#starter-library .library-thumb { display: grid; place-items: center; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #0a090d; font-size: 34px; }
#starter-library .library-thumb img, #starter-library .library-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
#starter-library .library-name { font-weight: 700; font-size: 14px; }

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  #editor { grid-template-columns: 290px minmax(0, 1fr) 350px; grid-template-rows: auto auto minmax(0, 1fr); }
  #topbar { grid-column: 1 / -1; padding: 8px 14px; gap: 6px; }
  #layers-pane { grid-column: 1; grid-row: 2 / 4; border-inline-end: 1px solid var(--line); }
  #stage { grid-column: 2; grid-row: 2 / 4; }
  #tabs { grid-column: 3; grid-row: 2; border-top: 0; border-inline-start: 1px solid var(--line); padding: 8px 10px; }
  #inspector { grid-column: 3; grid-row: 3; border-inline-start: 1px solid var(--line); }
  body[data-pane] #layers-pane { display: flex; }
  body[data-pane] #inspector { display: block; }
  .tab[data-tab="layers"] { display: none; }
  .tab { grid-auto-flow: column; justify-content: center; align-items: center; gap: 6px; font-size: 13px; padding: 8px 4px; }
  #stage-tools { inset-inline: 14px; bottom: 14px; }
  #sel-bar { top: 14px; inset-inline-start: 14px; }
  #time-chip { top: 14px; inset-inline-end: 14px; }
  .home-top, .home-main { padding-inline: 32px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 20px; }
}
@media (max-width: 899px) {
  .top-btn span:not(.ic) { display: none; }
  .top-btn { width: 40px; padding: 0; }
  #btn-import span:not(.ic) { display: none; }
  #btn-import { width: 42px; padding: 0; }
  #save-pill { font-size: 0; padding: 0 4px; }
  #save-pill::before { margin: 0; width: 8px; height: 8px; }
}
@media (max-height: 520px) and (max-width: 899px) { #editor { grid-template-rows: auto minmax(140px, 38dvh) auto minmax(0, 1fr); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* viewer portal: the publish part of the share sheet, token steps, QR, and the gallery marks */
.portal-box { display: grid; gap: 10px; margin: 6px 0; padding: 14px 0 4px; border-top: 1px solid var(--line); }
.portal-box:empty { display: none; }
.portal-head { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; }
.portal-head .ic { color: var(--accent-2); }
.share-tile.danger .share-ic { --tint: var(--danger); }
.portal-steps { margin: 0; padding-inline-start: 22px; display: grid; gap: 7px; font-size: 14px; line-height: 1.5; }
.portal-steps b, .portal-steps a { font-weight: 700; overflow-wrap: anywhere; color: #d9cfff; }
.portal-steps a { color: #b9a6ff; }
.portal-link { display: grid; justify-items: center; gap: 10px; }
.portal-qr { width: min(240px, 70vw); aspect-ratio: 1; border-radius: 14px; image-rendering: pixelated; }
.portal-link code { max-width: 100%; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; word-break: break-all; }
.card-badges { position: absolute; top: 8px; inset-inline-start: 8px; display: flex; flex-wrap: wrap; gap: 5px; pointer-events: none; }
.badge { display: inline-flex; align-items: center; gap: 4px; min-height: 24px; padding: 0 9px; border-radius: 999px; background: rgba(14,13,18,.78); color: #fff; font-size: 12px; font-weight: 600; backdrop-filter: blur(4px); }
.badge.pub { background: rgba(76,212,160,.9); color: #062a1d; }
.card-pic { position: relative; }
.portal-msg { margin: 0; color: var(--muted); font-size: 13px; }
/* the portal tiles keep one height whatever their text says (title + two lines), so the sheet never jumps while it checks */
.portal-box .share-text span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; min-height: calc(2 * 1.45em); line-height: 1.45; }
.portal-other { min-height: calc(3 * 1.5em); }
.portal-other span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.portal-room { display: grid; gap: 6px; padding: 2px 2px 0; }
.portal-private { margin-top: 10px; }
.portal-check { display: flex; align-items: center; gap: 10px; padding: 10px 2px; font-size: 15px; cursor: pointer; }
.portal-check input { width: 20px; height: 20px; flex: none; accent-color: var(--accent, #7c5cff); }
.portal-room label { display: grid; gap: 2px; font-size: 14px; }
.portal-room label span { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.portal-room-row { display: flex; gap: 8px; align-items: center; }
.portal-room-row .field { flex: 1; min-width: 0; }
.portal-room-row .btn[hidden] { display: none; }
.portal-status { min-height: calc(2 * 1.45em); margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.portal-status:empty { visibility: hidden; }
.linkish { padding: 0; border: 0; background: none; color: var(--accent-2); font: inherit; text-decoration: underline; cursor: pointer; }

/* design page: groups that fold at a tap on their title */
.group-title .group-fold { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: start; cursor: pointer; }
.group-title .group-fold svg { transition: transform .15s; opacity: .7; }
.group.folded > :not(.group-title) { display: none; }
.group.folded > .group-title { margin-bottom: 0; }
.group.folded .group-fold svg { transform: rotate(90deg); }
.bg-swatch { display: block; width: 100%; height: 100%; border-radius: inherit; }
.wx-pic { background: linear-gradient(180deg, #4f74a3, #b9c6d6 60%, #8c7a5a); }

/* "פירוק לשכבות" */
.split-view { display: flex; justify-content: center; background: #0d0f14; border-radius: 14px; padding: 8px; }
.split-canvas { display: block; max-width: 100%; max-height: 46vh; width: auto; height: auto; border-radius: 8px; touch-action: manipulation; cursor: crosshair; }
@media (max-width: 700px) { .split-canvas { max-height: 26vh; } }
.split-status { margin: 8px 2px 4px; font-size: 14px; color: var(--muted, #9aa3b2); flex-shrink: 0; }
.split-claude-err { color: var(--danger, #ff6b6b); }
.split-cut-tools[hidden], .split-cuts[hidden] { display: none; }
.split-cut-tools { display: grid; gap: 8px; margin-top: 8px; }
