/* Photo editor (Bloom look from ../shared/theme.css). Desktop: tools on the left, photo in the middle,
   settings on the right. Phones: photo on top, settings above a scrollable bottom tool bar. */
body { overflow: hidden; display: flex; flex-direction: column; height: 100dvh; }
.ad-bar { flex: none; }
.app-name { font-weight: 650; color: var(--fg); padding-left: 10px; border-left: 1px solid var(--line); }
.full-link-top { color: var(--accent); font-weight: 600; text-decoration: none; font-size: 13px; }
.spacer { flex: 1; }
.saved { color: var(--muted); font-size: 12px; }
.bar-actions { display: flex; gap: 6px; align-items: center; }
.btn.icon { padding: 6px 8px; display: inline-grid; place-items: center; }
.btn.danger { color: #c81e3c; }
.btn.wide { width: 100%; margin-top: 6px; }
.btn.subtle { background: transparent; color: var(--muted); }
.btn.big { padding: 13px 26px; font-size: 16px; border-radius: 14px; }
.btn[aria-pressed="true"] { background: #efedff; border-color: var(--sel); color: var(--accent); }
.linkish { border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 4px 0; }

/* start */
.start { flex: 1; overflow: auto; padding: 32px 16px 48px; }
.hero { text-align: center; max-width: 640px; margin: 0 auto 20px; }
.hero h1 { font-size: 34px; margin: 10px 0 8px; letter-spacing: -.02em; }
.hero p { color: var(--muted); margin: 0; font-size: 15px; }
.drop { max-width: 640px; margin: 0 auto; text-align: center; padding: 42px 18px; border: 2px dashed #cfc9ff; border-radius: 22px; background: linear-gradient(180deg, #fff, #f8f7ff); }
.drop p { color: var(--muted); margin: 10px 0 0; }
.drop .small { font-size: 12px; }
body.dragging .drop, body.dragging .stage { outline: 3px solid var(--sel); outline-offset: -6px; }
.start-soon { max-width: 720px; margin: 0 auto 18px; }
.soon-tools { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }
.recent { max-width: 900px; margin: 26px auto 0; }
.recent h2 { font-size: 16px; margin: 0 0 10px; }
.recent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.recent-card { position: relative; }
.recent-open { width: 100%; display: flex; flex-direction: column; gap: 4px; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 6px; cursor: pointer; font: inherit; color: var(--fg); }
.recent-open:hover { border-color: #cfc9ff; box-shadow: var(--shadow); }
.recent-open img, .recent-open .noimg { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 9px; background: #eef0f7; display: block; }
.rname { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rdate { font-size: 11px; color: var(--muted); }
.recent-del { position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(27, 33, 51, .6); color: #fff; cursor: pointer; font-size: 16px; line-height: 1; }

/* editor layout */
.editor { flex: 1; min-height: 0; display: grid; grid-template-columns: 84px minmax(0, 1fr) 330px; }
.tools { display: flex; flex-direction: column; gap: 4px; padding: 10px 8px; background: var(--bar); border-right: 1px solid var(--line); overflow-y: auto; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 4px; border: 0; border-radius: 12px; background: none; color: var(--muted); font: 600 11px/1.1 system-ui, sans-serif; cursor: pointer; }
.tool:hover { background: var(--hover); color: var(--fg); }
.tool.on { background: #efedff; color: var(--accent); }
.tool:focus-visible { outline: 2px solid var(--sel); }
.stage { position: relative; min-width: 0; min-height: 0; display: grid; place-items: center; overflow: hidden; background: radial-gradient(circle at 50% 40%, #eceefa, #e1e4f2); }
.canvas-wrap { position: relative; box-shadow: 0 12px 40px rgba(27, 33, 51, .18); touch-action: none; user-select: none; -webkit-user-select: none;
  background: repeating-conic-gradient(#e6e8f0 0% 25%, #fff 0% 50%) 0 0 / 16px 16px; }
.canvas-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#beforeView { pointer-events: none; }
#brush { opacity: .5; cursor: crosshair; }
.split-handle { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px solid #fff; box-shadow: 0 0 0 1px rgba(27, 33, 51, .25); cursor: ew-resize; z-index: 3; }
.split-handle::before { content: "‹ ›"; position: absolute; top: 50%; left: -19px; width: 36px; height: 36px; margin-top: -18px; border-radius: 50%; background: #fff; color: var(--fg); display: grid; place-items: center; font: 700 14px/1 system-ui; box-shadow: 0 2px 10px rgba(27, 33, 51, .3); }
.split-handle::after { content: ""; position: absolute; top: 0; bottom: 0; left: -14px; width: 28px; }
.crop-box { position: absolute; box-shadow: 0 0 0 9999px rgba(20, 22, 35, .5); border: 2px solid #fff; cursor: move; z-index: 4; outline: none; }
.canvas-wrap:has(.crop-box:not([hidden])) { overflow: hidden; }
.crop-box:focus-visible { border-color: var(--sel); }
.crop-box .grid { position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, transparent calc(33.33% - .5px), rgba(255,255,255,.55) 0 calc(33.33% + .5px), transparent 0 calc(66.66% - .5px), rgba(255,255,255,.55) 0 calc(66.66% + .5px), transparent 0),
              linear-gradient(transparent calc(33.33% - .5px), rgba(255,255,255,.55) 0 calc(33.33% + .5px), transparent 0 calc(66.66% - .5px), rgba(255,255,255,.55) 0 calc(66.66% + .5px), transparent 0); }
.crop-box b { position: absolute; width: 18px; height: 18px; background: #fff; border-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,.4); touch-action: none; }
.crop-box b::after { content: ""; position: absolute; inset: -10px; }
.crop-box [data-h=nw] { left: -9px; top: -9px; cursor: nwse-resize; } .crop-box [data-h=ne] { right: -9px; top: -9px; cursor: nesw-resize; }
.crop-box [data-h=se] { right: -9px; bottom: -9px; cursor: nwse-resize; } .crop-box [data-h=sw] { left: -9px; bottom: -9px; cursor: nesw-resize; }
.crop-box [data-h=n] { left: calc(50% - 9px); top: -9px; cursor: ns-resize; } .crop-box [data-h=s] { left: calc(50% - 9px); bottom: -9px; cursor: ns-resize; }
.crop-box [data-h=e] { right: -9px; top: calc(50% - 9px); cursor: ew-resize; } .crop-box [data-h=w] { left: -9px; top: calc(50% - 9px); cursor: ew-resize; }
.sel { position: absolute; border: 2px solid var(--sel); border-radius: 4px; z-index: 5; pointer-events: none; box-shadow: 0 0 0 1px rgba(255,255,255,.7); }
.sel b { position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--sel); pointer-events: auto; touch-action: none; }
.sel b::after { content: ""; position: absolute; inset: -10px; }
.sel .h-scale { right: -9px; bottom: -9px; cursor: nwse-resize; }
.sel .h-rot { left: calc(50% - 8px); top: -34px; cursor: grab; }
.sel .h-rot::before { content: ""; position: absolute; left: 6px; top: 14px; width: 2px; height: 18px; background: var(--sel); }

/* settings panel */
.panel { background: var(--bar); border-left: 1px solid var(--line); overflow-y: auto; padding: 14px 16px 24px; }
.psec { padding: 4px 0 12px; border-bottom: 1px solid #eef0f6; margin-bottom: 10px; }
.psec:last-of-type { border-bottom: 0; }
.psec h3 { margin: 4px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip { border: 1px solid var(--line); background: #fff; color: var(--fg); border-radius: 999px; padding: 6px 11px; font: 600 12.5px/1.1 system-ui, sans-serif; cursor: pointer; text-decoration: none; }
.chip:hover { border-color: #cfc9ff; }
.chip.on { background: #efedff; border-color: var(--sel); color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 2px; margin: 6px 0; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.slider { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 8px; margin: 8px 0; }
.slider label { font-size: 13px; font-weight: 600; cursor: default; }
.slider output { font: 600 12px/1 ui-monospace, monospace; color: var(--muted); min-width: 36px; text-align: right; }
.slider input { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); margin: 6px 0 0; height: 22px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0; }
.full-link { margin: 14px 0 0; }
.colour { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.colour input[type=color] { width: 34px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.text-input { width: 100%; resize: vertical; min-height: 54px; }
.ad-input.num { width: 110px; }
select.ad-input { max-width: 100%; }
.filter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ftile { border: 2px solid transparent; background: #fff; border-radius: 12px; padding: 4px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; font: 600 11.5px/1.15 system-ui, sans-serif; color: var(--fg); }
.ftile canvas { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; display: block; background: #eef0f7; }
.ftile.on { border-color: var(--sel); background: #f5f4ff; }
/* Floating toolbar above the selected item (Canva's order: colour, Edit, position | transparency, duplicate, delete) */
.ov-bar { position: fixed; z-index: 60; display: flex; align-items: center; gap: 4px; padding: 5px 6px; background: #fff; border: 1px solid var(--line, #e4e6ef); border-radius: 12px; box-shadow: 0 6px 22px rgba(27,33,51,.16); }
.ov-bar[hidden] { display: none; }
.ov-bar .btn { padding: 5px 9px; font-size: 12.5px; min-height: 30px; }
.ov-bar .pill-sep { width: 1px; align-self: stretch; background: var(--line, #e4e6ef); margin: 2px 3px; }
.ov-color { display: inline-flex; width: 30px; height: 30px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line, #e4e6ef); cursor: pointer; }
.ov-color input { width: 44px; height: 44px; margin: -7px; border: 0; padding: 0; cursor: pointer; }
.ov-op input { width: 76px; }
/* Design panel → Layouts (photo shapes) and Styles (looks) */
.design-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.dtile { display: flex; flex-direction: column; align-items: center; gap: 6px; border: 1px solid var(--line, #e4e6ef); background: #fff; border-radius: 12px; padding: 8px 6px; cursor: pointer; font: 600 11.5px/1.2 system-ui, sans-serif; color: var(--fg); text-align: center; }
.dtile:hover, .dtile:focus-visible { border-color: var(--sel, #5b4cf0); }
.dshape { display: block; height: 46px; max-width: 100%; border-radius: 4px; background: linear-gradient(135deg, #c9d4ff, #f3d1e6); border: 2px solid #5b4cf0; }
.dshape.orig { border-style: dashed; }
.design-grid.looks canvas, .dlook { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: linear-gradient(135deg, #f6d6a8, #8fb3e8); }
.sticker-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; max-height: 260px; overflow-y: auto; margin-top: 6px; }
.stile { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 6px; cursor: pointer; aspect-ratio: 1; display: grid; place-items: center; }
.stile img { width: 100%; height: 100%; object-fit: contain; }
.stile:hover { border-color: #cfc9ff; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.sw.on { box-shadow: 0 0 0 2px var(--sel); }
#panel .ad-soon { padding: 18px 12px; }

/* busy */
.busy { position: fixed; inset: 0; background: rgba(243, 244, 251, .72); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; }
.busy-card { background: #fff; border-radius: 18px; padding: 22px 26px; box-shadow: var(--shadow); text-align: center; width: min(360px, calc(100vw - 32px)); }
.busy-card p { margin: 12px 0 0; font-weight: 600; }
.spinner { width: 34px; height: 34px; margin: 0 auto; border-radius: 50%; border: 4px solid #e8e5fe; border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 6px; border-radius: 6px; background: #eef0f7; overflow: hidden; margin-top: 12px; }
.progress span { display: block; height: 100%; width: 0; background: var(--grad); transition: width .2s; }

/* simple modes (background remover, enhancer, AI) */
body:not([data-mode=full]) .tools { display: none; }
body:not([data-mode=full]) .editor { grid-template-columns: minmax(0, 1fr) 340px; }
body[data-mode=bg] #splitBtn, body[data-mode=ai] #splitBtn { display: none; }

/* phones */
@media (max-width: 760px) {
  .ad-bar { padding: 8px 10px; gap: 6px; }
  .brand-text, .saved, #compareBtn { display: none; }
  .app-name { font-size: 13px; padding-left: 8px; }
  .bar-actions { gap: 4px; }
  .bar-actions .btn { padding: 6px 8px; font-size: 13px; }
  .hero h1 { font-size: 26px; }
  .editor, body:not([data-mode=full]) .editor { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto auto; }
  .stage { grid-row: 1; }
  .panel { grid-row: 2; border-left: 0; border-top: 1px solid var(--line); max-height: 40dvh; padding: 10px 14px 12px; border-radius: 16px 16px 0 0; box-shadow: 0 -8px 24px rgba(27, 33, 51, .08); }
  .tools { grid-row: 3; flex-direction: row; overflow-x: auto; overflow-y: hidden; border-right: 0; border-top: 1px solid var(--line); padding: 6px 8px max(6px, env(safe-area-inset-bottom)); scrollbar-width: none; }
  .tools::-webkit-scrollbar { display: none; }
  .tool { flex: none; min-width: 64px; padding: 6px 4px; }
  .filter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sticker-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .ad-toast { bottom: 140px; }
}
@media (max-width: 400px) {
  .bar-actions #openBtn { display: none; }
  .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- inside the shared editor frame (../shared/editor-shell.js sets html.ad-shell-on) ---------- */
.photo-work { display: contents; }
html.ad-shell-on body > .ad-bar { display: none; }
html.ad-shell-on .photo-work { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; position: relative; }
html.ad-shell-on .start { flex: 1; min-height: 0; overflow: auto; padding: 28px 16px 32px; }
html.ad-shell-on .drop { background: #fff; box-shadow: 0 10px 30px rgba(27, 33, 51, .08); }
html.ad-shell-on .editor { flex: 1; min-height: 0; display: flex; }
html.ad-shell-on .editor > .panel, html.ad-shell-on .editor > .tools { display: none; }
/* the settings box waiting beside the photo (e.g. while the Templates panel is open) stays hidden: the id rule below must not show it there */
html.ad-shell-on .editor > #panel { display: none; }
html.ad-shell-on .stage { flex: 1; display: flex; overflow: auto; background: transparent; }
html.ad-shell-on .canvas-wrap { margin: auto; flex: none; }
/* the photo's settings, shown in the frame's side panel */
.ad-shell #panel { display: block; background: none; border: 0; padding: 0; overflow: visible; max-height: none; box-shadow: none; border-radius: 0; }
.ad-shell #panel .psec h3 { font-size: 12px; }
.ad-shell .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.text-add { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; margin: 0 0 8px; cursor: pointer; color: var(--fg); font-family: inherit; }
.text-add:hover { border-color: #cfc9ff; background: #faf9ff; }
.text-add.t-h { font-size: 22px; font-weight: 800; }
.text-add.t-s { font-size: 16px; font-weight: 700; }
.text-add.t-b { font-size: 13px; }
.style-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.style-tile { height: 64px; border: 0; border-radius: 10px; cursor: pointer; display: grid; place-items: center; font: 16px/1.1 system-ui, sans-serif; background: linear-gradient(135deg, #6c5bd4, #e0617a); }
.hub { display: flex; flex-direction: column; gap: 8px; }
.hub-item { display: flex; gap: 12px; align-items: center; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 12px; cursor: pointer; color: var(--fg); font: inherit; }
.hub-item:hover { border-color: #cfc9ff; background: #faf9ff; }
.hub-item b { display: block; font-size: 14px; }
.hub-item small { color: var(--muted); font-size: 12px; }
.hub-ic { width: 38px; height: 38px; border-radius: 10px; background: #efedff; color: var(--accent); display: grid; place-items: center; flex: none; }
/* floating toolbar */
.photo-pill { display: flex; align-items: center; gap: 2px; }
.photo-pill .tools { display: flex; flex-direction: row; gap: 1px; padding: 0; background: none; border: 0; overflow: visible; }
.photo-pill .tool { flex: none; flex-direction: row; min-width: 0; padding: 7px; border-radius: 10px; }
.photo-pill .tool svg { width: 20px; height: 20px; }
.photo-pill .tool span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.photo-pill .bar-actions { gap: 2px; }
.photo-pill .btn { padding: 6px 10px; font-size: 13px; }
.photo-pill .btn.icon { padding: 6px 7px; }
.photo-pill .btn.icon svg { width: 19px; height: 19px; }
.pill-group { display: flex; gap: 1px; }
.pill-sep { width: 1px; height: 24px; background: var(--line); margin: 0 6px; flex: none; }
.pill-start { display: none; align-items: center; gap: 10px; padding: 0 4px; }
.pill-start .hint { margin: 0; white-space: nowrap; }
body:not(.has-photo) .pill-start { display: flex; }
body:not(.has-photo) .photo-pill .tools, body:not(.has-photo) #quickTools, body:not(.has-photo) .pill-sep { display: none; }
body:not([data-mode=full]) .photo-pill .tools, body:not([data-mode=full]) #quickTools, body:not([data-mode=full]) .pill-sep:first-of-type { display: none; }
.pill-edit { font-weight: 700; margin-right: 4px; }
body:not(.has-photo) .pill-edit { display: none; }
/* Edit panel tabs (Effects / Filters / Adjust / Tools) */
.edit-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; padding: 3px; margin: 0 0 12px; background: #f1f2f8; border-radius: 12px; position: sticky; top: 0; z-index: 1; }
.edit-tab { border: 0; background: none; border-radius: 9px; padding: 8px 4px; font: 600 12.5px/1 system-ui, sans-serif; color: var(--muted); cursor: pointer; }
.edit-tab.on { background: #fff; color: var(--fg); box-shadow: 0 1px 4px rgba(27, 33, 51, .12); }
.duo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.duo { height: 56px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; display: flex; align-items: flex-end; padding: 4px 6px; color: #fff; font: 600 11.5px/1 system-ui, sans-serif; text-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
.duo.none { background: repeating-conic-gradient(#e6e8f0 0% 25%, #fff 0% 50%) 0 0 / 12px 12px; color: var(--fg); text-shadow: none; }
.duo.on { border-color: var(--sel); box-shadow: 0 0 0 2px #fff inset; }
.area-tools { margin-top: 6px; padding: 8px 10px; border-radius: 10px; background: #f7f6ff; }
.ai-msg { margin: 12px 0; padding: 12px 14px; border-radius: 12px; background: #fff8e6; border: 1px solid #f5d27a; }
.ai-msg p { margin: 6px 0 10px; font-size: 13px; color: var(--fg); }
/* a small progress card that leaves the photo visible (templates, effects) */
.busy.quiet { background: transparent; backdrop-filter: none; align-items: end; padding-bottom: 72px; }
.busy.quiet .busy-card { box-shadow: 0 10px 30px rgba(27, 33, 51, .22); padding: 14px 18px; width: min(320px, calc(100vw - 32px)); }
@media (max-width: 760px) {
  html.ad-shell-on .start { padding: 16px 12px 24px; }
  html.ad-shell-on .hero h1 { font-size: 22px; }
  html.ad-shell-on .drop { padding: 22px 14px; }
  .photo-pill .bar-actions .btn { padding: 6px 7px; }
  .pill-start .hint { display: none; }
  .ad-shell .filter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* round 3: bulk background removal, changed photo colours, copy/paste style */
.bulk-start { display: block; margin: 10px auto 0; font-size: 13px; }
body:not([data-mode="bg"]) .bulk-start { display: none; }
.sw.changed { position: relative; }
.sw.changed::after { content: ""; position: absolute; right: -3px; top: -3px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; }
#pasteStyle:disabled { display: none; }
@media (max-width: 760px) { #copyStyle, #pasteStyle { display: none; } }
