/* Magic Layers (uses the shared Bloom tokens from ../shared/theme.css) */
body { min-height: 100%; overflow-x: hidden; }
.app-title { font-size: 16px; margin: 0; font-weight: 700; color: var(--fg); }
.grow { flex: 1; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.big { padding: 11px 20px; font-size: 15px; }
main { max-width: 1240px; margin: 0 auto; padding: 18px 16px 40px; }

/* start */
.start { display: grid; gap: 16px; max-width: 760px; margin: 0 auto; }
.intro { text-align: center; }
.intro h2 { font-size: 26px; line-height: 1.2; margin: 8px 0 6px; letter-spacing: -.01em; }
.intro p { color: var(--muted); margin: 0 auto; max-width: 600px; }
.drop { display: grid; justify-items: center; gap: 12px; padding: 28px 18px; border: 2px dashed #cfc9ff; cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
.drop:hover, .drop:focus-visible, body.dragging .drop { border-color: var(--accent); background: #faf9ff; outline: none; }
.hint { color: var(--muted); font-size: 13px; }
.drop-art { position: relative; width: 120px; height: 84px; }
.drop-art span { position: absolute; border-radius: 10px; box-shadow: 0 6px 16px rgba(27, 33, 51, .12); }
.sheet-a { inset: 18px 0 0 22px; background: linear-gradient(135deg, #ffd9c9, #ffb199); transform: rotate(6deg); }
.sheet-b { inset: 9px 12px 9px 10px; background: linear-gradient(135deg, #c9f3ec, #7fd8c9); transform: rotate(-4deg); }
.sheet-c { inset: 0 24px 18px 0; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; font: 800 28px/1 Georgia, serif; color: var(--accent); }
.opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; margin: 0; }
.opts legend { font-weight: 700; padding: 0 6px; }
.opts label { display: flex; gap: 10px; align-items: flex-start; padding: 8px; border-radius: 10px; cursor: pointer; }
.opts label:hover { background: var(--hover); }
.opts label.dim { opacity: .5; }
.opts input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.opts b { display: block; font-weight: 650; }
.opts small { color: var(--muted); }
.note { text-align: center; color: var(--muted); font-size: 13px; margin: 0; }

/* work */
.work { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.preview { min-width: 0; }
.preview-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.preview-head b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.stage { position: relative; overflow: hidden; min-height: 200px; border-radius: 10px;
  background: repeating-conic-gradient(#eef0f6 0% 25%, #fff 0% 50%) 50% / 18px 18px; }
.sheet { position: absolute; top: 0; left: 0; transform-origin: 0 0; background: #fff; box-shadow: 0 4px 20px rgba(27, 33, 51, .15); }
.ly { position: absolute; margin: 0; box-sizing: border-box; }
img.ly { object-fit: fill; user-select: none; }
.ly-text { white-space: pre; overflow: visible; }
.ly.hl { outline: 3px solid var(--sel); outline-offset: 2px; z-index: 5; }
.side { position: sticky; top: 70px; display: grid; gap: 12px; max-height: calc(100vh - 90px); overflow: auto; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.steps li { display: grid; grid-template-columns: 18px 1fr; gap: 0 8px; align-items: center; padding: 5px 4px; color: var(--muted); }
.steps li .detail { grid-column: 2; font-size: 12px; }
.steps li .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #cdd2e2; }
.steps li.run { color: var(--fg); font-weight: 600; }
.steps li.run .dot { border-color: var(--accent); border-right-color: transparent; animation: spin .8s linear infinite; }
.steps li.done { color: var(--fg); }
.steps li.done .dot { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 2px #fff; }
.steps li.skip { opacity: .6; }
.steps li.skip .dot { border-style: dashed; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.track { height: 6px; border-radius: 99px; background: #eceef6; overflow: hidden; }
.fill { display: block; height: 100%; width: 0; background: var(--grad); transition: width .2s; }
.error { border: 1px solid #f3c2c2; background: #fff6f6; border-radius: 12px; padding: 10px 12px; }
.error p { margin: 0 0 8px; color: #8a1f1f; }
.layers-head { display: flex; align-items: center; justify-content: space-between; }
.layers-head h2 { font-size: 16px; margin: 0; }
.count { margin: 2px 0 6px; color: var(--muted); font-size: 13px; }
.layer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.layer-list .row { display: grid; grid-template-columns: auto 30px minmax(0, 1fr); gap: 8px; align-items: center; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.layer-list .row:hover { border-color: #cfc9ff; background: #faf9ff; }
.layer-list li.off .row { opacity: .55; }
.layer-list input { accent-color: var(--accent); width: 16px; height: 16px; }
.ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: #f1f0ff; color: var(--accent); }
.ic svg { width: 18px; height: 18px; }
.ic-subject { background: #fff0ea; color: #e2582f; }
.ic-image { background: #e7f8f5; color: #0f8f7c; }
.ic-bg { background: #eef1f7; color: #4b5570; }
.nm { min-width: 0; display: grid; }
.nm b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nm small { color: var(--muted); display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; }
.sw { width: 11px; height: 11px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .15); flex: none; }
.tip { color: var(--muted); font-size: 12px; margin: 6px 0 0; }

@media (max-width: 900px) {
  .work { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; max-height: none; }
}
@media (max-width: 640px) {
  main { padding: 12px 12px 96px; }
  .ad-bar { padding: 8px 10px; }
  .brand-word { display: none; }
  .intro h2 { font-size: 21px; }
  .opts { grid-template-columns: minmax(0, 1fr); }
  /* the main action sits in a bottom bar within thumb reach, like the PDF editor's tools */
  body[data-view="work"] #openStudio, body[data-view="work"] #newBtn { position: fixed; bottom: max(10px, env(safe-area-inset-bottom)); z-index: 30; box-shadow: 0 8px 24px rgba(27, 33, 51, .22); }
  body[data-view="work"] #openStudio { right: 12px; left: 40%; }
  body[data-view="work"] #newBtn { left: 12px; width: calc(40% - 20px); background: #fff; }
}

/* selection, layer list extras, text panel */
.layer-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px; align-items: center; }
.layer-list .repl { width: 32px; height: 32px; border: 1px solid var(--line); background: #fff; border-radius: 9px; display: grid; place-items: center; cursor: pointer; color: var(--muted); padding: 0; }
.layer-list .repl:hover { border-color: #cfc9ff; color: var(--accent); }
.layer-list .repl svg { width: 16px; height: 16px; }
/* colour popover (Colour button in the toolbar) */
.ly-pop { position: fixed; z-index: 60; width: 260px; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 32px rgba(27, 33, 51, .18); display: grid; gap: 6px; }
.ly-pop b { font-size: 14px; }
.ly-pop small { color: var(--muted); font-size: 12px; }
.ly-sws { display: flex; flex-wrap: wrap; gap: 6px; }
.ly-sw { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); background: var(--c); cursor: pointer; padding: 0; }
.ly-sw:hover, .ly-sw:focus-visible { box-shadow: 0 0 0 2px var(--accent); outline: none; }
.ly-cin { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.ly-cin input { width: 44px; height: 30px; border: 1px solid var(--line); border-radius: 8px; padding: 0; background: #fff; }
.layer-list .pick { width: 32px; height: 32px; border: 1px solid var(--line); background: #fff; border-radius: 9px; display: grid; place-items: center; cursor: pointer; color: var(--muted); padding: 0; }
.layer-list .pick:hover { border-color: #cfc9ff; color: var(--accent); }
.layer-list .pick svg { width: 16px; height: 16px; }
.layer-list li.picked .row, .layer-list li.picked .pick { border-color: var(--accent); color: var(--accent); }
.sheet .ly.picked { outline: 3px solid var(--accent); outline-offset: 2px; z-index: 4; }
.sheet .ly { cursor: pointer; }
.ly-bar { display: flex; align-items: center; gap: 4px; }
.ly-bar .btn { padding: 6px 10px; font-size: 13px; white-space: nowrap; box-shadow: none; }
.ly-bar .btn:not(.primary) { border-color: transparent; }
.ly-bar .btn:not(.primary):hover { border-color: #cfc9ff; }
.ly-sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; flex: none; }
.ly-tpanel { display: grid; gap: 10px; }
/* Design panel → Styles: font sets and colour palettes for the text layers */
.ly-styles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 6px 0 14px; }
.ly-style { display: grid; gap: 4px; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px; cursor: pointer; font: inherit; color: var(--fg); }
.ly-style:hover, .ly-style:focus-visible { border-color: var(--sel, #5b4cf0); }
.ly-style b { font-size: 16px; line-height: 1.15; }
.ly-style small { font-size: 11.5px; opacity: .75; }
.ly-sw { display: flex; gap: 4px; }
.ly-sw i { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); display: inline-block; }
.ly-addt { display: grid; gap: 8px; }
.ly-addt button { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; cursor: pointer; font: inherit; color: var(--fg); }
.ly-addt button:hover { border-color: #cfc9ff; background: #faf9ff; }
.ly-addt .h { font-size: 22px; font-weight: 800; }
.ly-addt .sh { font-size: 16px; font-weight: 700; }
.ly-addt .bd { font-size: 13px; }
.ly-tedit { border: 1px solid var(--line); border-radius: 10px; padding: 8px; display: grid; gap: 6px; background: #fff; }
.ly-tedit.picked { border-color: var(--accent); box-shadow: 0 0 0 2px #e6e3ff; }
.ly-tedit textarea { width: 100%; box-sizing: border-box; resize: vertical; min-height: 38px; font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.ly-trow { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ly-trow input[type=number] { width: 64px; padding: 5px 6px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.ly-trow select { padding: 5px 6px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
.ly-trow input[type=color] { width: 34px; height: 30px; padding: 0 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.ly-trow .btn.on { background: #ece9ff; border-color: var(--accent); font-weight: 800; }

/* move / resize: selection box with corner handles; sizes divided by the preview zoom (--inv = 1 / zoom) */
.sheet .ly.picked { outline: none; }
.ly-sel { position: absolute; box-sizing: border-box; pointer-events: none; z-index: 6; outline: calc(2px * var(--inv, 1)) solid var(--accent); outline-offset: calc(1px * var(--inv, 1)); }
.ly-sel.locked { outline-style: dashed; }
.ly-sel.locked .ly-handle { display: none; }
.ly-handle { position: absolute; width: calc(14px * var(--inv, 1)); height: calc(14px * var(--inv, 1)); box-sizing: border-box; background: #fff; border: calc(2px * var(--inv, 1)) solid var(--accent); border-radius: 50%; pointer-events: auto; touch-action: none; box-shadow: 0 1px 4px rgba(27, 33, 51, .3); }
.ly-handle::after { content: ""; position: absolute; inset: calc(-8px * var(--inv, 1)); }
.ly-handle[data-h="nw"] { left: calc(-8px * var(--inv, 1)); top: calc(-8px * var(--inv, 1)); cursor: nwse-resize; }
.ly-handle[data-h="ne"] { right: calc(-8px * var(--inv, 1)); top: calc(-8px * var(--inv, 1)); cursor: nesw-resize; }
.ly-handle[data-h="sw"] { left: calc(-8px * var(--inv, 1)); bottom: calc(-8px * var(--inv, 1)); cursor: nesw-resize; }
.ly-handle[data-h="se"] { right: calc(-8px * var(--inv, 1)); bottom: calc(-8px * var(--inv, 1)); cursor: nwse-resize; }
.sheet .ly.picked:not(.locked) { cursor: move; touch-action: none; }
.sheet .ly.locked { cursor: default; }
body.ly-dragging, body.ly-dragging * { user-select: none; -webkit-user-select: none; }
.layer-list li.locked .lk { color: #b45309; font-weight: 600; }
.ly-op { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); padding: 0 6px; white-space: nowrap; }
.ly-op input { width: 90px; accent-color: var(--accent); }
.ly-op output { min-width: 34px; font-variant-numeric: tabular-nums; color: var(--fg); }
.ly-bar .btn.icon { padding: 6px 7px; display: inline-grid; place-items: center; }
.ly-bar .btn[aria-pressed="true"] { background: #fff4e5; border-color: #f59e0b; }
.ly-align { display: inline-flex; gap: 2px; }
.ly-align .btn { padding: 4px 6px; display: inline-grid; place-items: center; }

/* inside the editor frame (shared/editor-shell.js): the frame's top bar replaces the old header */
html.ad-shell-on body > header.ad-bar { display: none !important; }
html.ad-shell-on main { max-width: none; width: 100%; margin: 0; padding: 14px 20px 24px; overflow: auto; box-sizing: border-box; }
html.ad-shell-on .start { padding-top: 6px; }
html.ad-shell-on .work { grid-template-columns: minmax(0, 1fr) 300px; }
html.ad-shell-on body[data-done="1"] .work { grid-template-columns: minmax(0, 1fr); }
html.ad-shell-on body[data-done="1"] .work > .side { display: none; }
html.ad-shell-on .side { position: static; max-height: none; }
html.ad-shell-on .preview { overflow: auto; background: transparent; border: 0; box-shadow: none; padding: 0; }
html.ad-shell-on .preview-head { margin-bottom: 8px; }
html.ad-shell-on .stage { background: transparent; overflow: visible; }
html.ad-shell-on .ads-pbody .layers { display: grid; gap: 6px; }
@media (max-width: 900px) {
  html.ad-shell-on .work { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  html.ad-shell-on main { padding: 10px 10px 16px; }
  html.ad-shell-on body[data-view="work"] #openStudio, html.ad-shell-on body[data-view="work"] #newBtn { position: static; left: auto; right: auto; width: auto; box-shadow: none; }
  html.ad-shell-on body[data-view="work"] #newBtn { background: #fff; }
}
/* effects popover (looks, light, blur, flips; text shadow) */
.ly-fx { width: 280px; max-height: min(78vh, 560px); overflow: auto; }
.ly-looks { display: flex; flex-wrap: wrap; gap: 5px; }
.ly-looks .chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 9px; font: 600 12px/1.1 system-ui, sans-serif; cursor: pointer; color: inherit; }
.ly-looks .chip:hover { border-color: #cfc9ff; }
.ly-fxr { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 8px; font-size: 12.5px; }
.ly-fxr input { width: 100%; }
.ly-fxb { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ly-fxb [aria-pressed="true"] { border-color: var(--accent, #5b4cf0); color: var(--accent, #5b4cf0); }
.ly-fxc { display: flex; align-items: center; gap: 8px; font-size: 13px; }
