/* The editor owns the whole screen: bar, canvas, contextual actions, tool dock, sheet. */
.editor{
  --bg:#0b0f24;--surface:#161c3a;--surface-2:#222b52;--ink:#f2f4ff;--mute:#b9c2e8;--line:#34407a;--brand:#a9baff;--brand-ink:#0b0f24;--soft:#27315f;--danger:#ff7a90;color-scheme:dark;color:var(--ink)}
.editor button.on{border-color:var(--accent);box-shadow:inset 0 0 0 1.5px var(--accent);color:var(--ink)}
.editor .chip.on{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
.editor .seg button.on{box-shadow:none;background:var(--soft)}
.editor .dock button.on{box-shadow:none;background:var(--soft);color:#fff}
.editor{position:fixed;inset:0;z-index:10;display:flex;flex-direction:column;background:var(--bg);padding-top:env(safe-area-inset-top)}
.editor-bar{display:flex;align-items:center;gap:2px;padding:6px 8px}
.editor-bar button.primary{min-height:38px}
.stage{flex:1;min-height:0;position:relative;touch-action:none;overflow:hidden;display:grid;place-items:center}
.frame{position:relative;box-shadow:var(--shadow);border-radius:10px;touch-action:none}
.frame canvas{display:block;width:100%;height:100%;border-radius:10px;touch-action:none;background:repeating-conic-gradient(#d8d7e0 0 25%,#fff 0 50%) 0 0/18px 18px}
.overlay{position:absolute;inset:0;pointer-events:none;overflow:visible}
.selbox{position:absolute;border:1.5px solid #fff;outline:1.5px solid #1d3fbb;border-radius:4px}
.handle{position:absolute;width:30px;height:30px;min-height:0;padding:0;border-radius:50%;background:#fff;color:#1d3fbb;border:0;box-shadow:0 2px 8px #0005;pointer-events:auto;touch-action:none}
.handle .ic{width:16px;height:16px;stroke-width:2.2}
.handle.del{top:-15px;left:-15px}
.handle.dup{top:-15px;right:-15px}
.handle.grow-h{bottom:-15px;right:-15px;cursor:nwse-resize}
.handle.edit{bottom:-15px;left:-15px}
.guide{position:absolute;background:#f6a821;opacity:.95}
.guide.v{top:0;bottom:0;left:50%;width:1px}
.guide.h{left:0;right:0;top:50%;height:1px}
.safe-zone{position:absolute;left:0;right:0;background:#ff2d5526;border:0 dashed #ff2d55}
.safe-zone.top{top:0;height:13%;border-bottom-width:1px}
.safe-zone.bottom{bottom:0;height:17%;border-top-width:1px}
.pager{display:flex;align-items:center;justify-content:center;gap:4px;font-size:13px;color:var(--mute);padding:2px 0}
.pager button{min-height:34px}
.pager button.icon{width:38px}
.dock{display:flex;gap:2px;overflow-x:auto;padding:6px 8px calc(6px + env(safe-area-inset-bottom));background:var(--surface);border-top:1px solid var(--line);scrollbar-width:none}
.dock::-webkit-scrollbar{display:none}
.dock button{flex:1 0 60px;flex-direction:column;gap:3px;border:0;background:none;font-size:11px;font-weight:500;min-height:52px;padding:4px 2px;color:var(--mute);white-space:nowrap}
.dock button.on{background:var(--soft);color:var(--brand);box-shadow:none}
.sheet{display:flex;flex-direction:column;background:var(--surface);border-top:1px solid var(--line);border-radius:var(--r-l) var(--r-l) 0 0;box-shadow:0 -8px 24px #0001;height:min(34dvh,330px);min-height:190px;animation:sheet-in .22s cubic-bezier(.2,.8,.3,1)}
@keyframes sheet-in{from{transform:translateY(30px);opacity:0}}
.sheet-head{display:flex;align-items:center;gap:8px;padding:6px 8px 4px 16px;padding-inline:16px 8px}
.sheet-head b{flex:1}
.sheet-head button{min-height:34px;width:34px}
.panel{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;display:grid;grid-template-columns:minmax(0,1fr);grid-auto-rows:max-content;align-content:start;gap:12px;padding:6px 16px 16px}
.panel h3{font-size:12px;font-weight:700;color:var(--mute);text-transform:uppercase;letter-spacing:.04em}
.field{display:grid;grid-template-columns:96px 1fr 44px;align-items:center;gap:10px;font-size:13px}
.field output{font-size:12px;color:var(--mute);text-align:end;font-variant-numeric:tabular-nums}
.tiles{display:grid;grid-template-columns:repeat(auto-fill,minmax(74px,1fr));gap:8px}
.tiles button{flex-direction:column;gap:4px;padding:6px 2px;min-height:64px;font-size:12px;min-width:0;overflow:hidden}
.tiles canvas{width:100%;height:auto;border-radius:8px;display:block}
.emoji{display:grid;grid-template-columns:repeat(auto-fill,minmax(48px,1fr));gap:4px}
.emoji button{font-size:28px;padding:0;min-height:48px;border:0;background:none}
.words{display:flex;flex-wrap:wrap;gap:6px}
.words button.styled{border-style:dashed;border-color:var(--brand-2)}
.fontchip{font-size:18px;min-width:76px}
.seg{display:flex;background:var(--surface-2);border-radius:var(--r-s);padding:3px;gap:3px}
.seg button{flex:1;border:0;background:none;min-height:34px;padding:2px 8px}
.seg button.on{background:var(--surface);box-shadow:var(--shadow)}
.export-preview{display:block;max-height:34dvh;max-width:100%;margin:auto;border-radius:14px;box-shadow:var(--shadow)}
.hint{position:absolute;top:8px;white-space:nowrap;max-width:calc(100% - 24px);overflow:hidden;text-overflow:ellipsis;inset-inline:12px;margin:auto;width:fit-content;background:#0e1430e6;color:#fff;font-size:12px;padding:5px 12px;border-radius:999px;pointer-events:none;animation:hint 4.5s forwards}
@keyframes hint{0%,100%{opacity:0}10%,80%{opacity:1}}
/* Wide screens: tools sit beside the canvas. */
@media (min-width:900px){
  .editor{display:grid;grid-template-columns:minmax(0,1fr) 380px;grid-template-rows:auto minmax(0,1fr) auto auto}
  .editor-bar{grid-column:1/-1}
  .stage{grid-column:1;grid-row:2}
  .pager{grid-column:1;grid-row:3}
  .dock{grid-column:1;grid-row:4}
  .sheet{grid-column:2;grid-row:2/-1;height:auto;border-radius:0;border-inline-start:1px solid var(--line);animation:none}
}
/* Fonts, motions and doodles */
.tiles.fonts{grid-template-columns:repeat(auto-fill,minmax(106px,1fr))}
.fonts .fontchip{font-size:19px}
.fonts .fontchip span{white-space:nowrap;max-width:100%;overflow:hidden;line-height:1.7}
.fonts small,.motions button{font-size:11px;color:var(--mute)}
.tiles.motions{grid-template-columns:repeat(auto-fill,minmax(96px,1fr))}
.motions canvas,.motions .still{width:100%;aspect-ratio:5/3;background:#39324f;border-radius:8px;display:grid;place-items:center;color:#fff}
.tiles.doodles{grid-template-columns:repeat(auto-fill,minmax(58px,1fr))}
.doodles button{padding:4px;min-height:58px;background:#39447a;border:0}
.timing{display:grid;gap:8px;position:sticky;bottom:-16px;background:var(--surface);padding:8px 0 12px;border-top:1px solid var(--line)}
progress{width:100%;height:8px;accent-color:var(--brand)}
/* Layouts and layer rows */
.layout{width:52px;height:78px;padding:5px}
.diagram{position:relative;display:block;width:100%;height:100%}
.diagram i{position:absolute;background:var(--mute);border:1.5px solid var(--surface);border-radius:2px}
.layer{display:flex;gap:6px}
.layer .grow{justify-content:flex-start;min-width:0;overflow:hidden;white-space:nowrap}
/* Type pairs and palettes */
.tiles.combos{grid-template-columns:repeat(auto-fill,minmax(150px,1fr))}
.combos button{padding:3px}
.combos canvas{aspect-ratio:3/2;background:#2a3358}
.tiles.palettes{grid-template-columns:repeat(auto-fill,minmax(96px,1fr))}
.palettes button{flex-direction:row;gap:0;padding:4px;min-height:44px}
.palettes i{flex:1;height:34px}
.palettes i:first-child{flex:2;border-radius:7px 0 0 7px}
.palettes i:last-child{border-radius:0 7px 7px 0}
/* Instagram preview */
.safe-zone i{position:absolute;display:block}
.safe-zone .bars{top:6px;left:6px;right:6px;height:2.5px;border-radius:2px;background:linear-gradient(90deg,#fff 40%,#ffffff66 40%)}
.safe-zone .face{top:14px;left:8px;width:20px;height:20px;border-radius:50%;background:#ffffffd0}
.safe-zone .name{top:20px;left:34px;width:56px;height:7px;border-radius:4px;background:#ffffffb0}
.safe-zone .reply{bottom:10px;left:8px;right:44px;height:24px;border:1.5px solid #ffffffc0;border-radius:14px}
.safe-zone .like{bottom:12px;right:12px;width:20px;height:20px;border:1.5px solid #fff;border-radius:50% 50% 4px 50%;transform:rotate(45deg)}
/* Font browser */
.dialog.tall{height:92dvh;grid-template-rows:auto auto auto minmax(0,1fr) auto}
.dialog.tall .search{margin:0}
.fontlist{overflow-y:auto;display:grid;align-content:start;grid-auto-rows:max-content;gap:6px;overscroll-behavior:contain}
.fontrow{display:flex;align-items:center;gap:4px;border:1px solid var(--line);border-radius:var(--r);padding-inline-end:4px}
.fontrow.on{border-color:var(--brand);box-shadow:inset 0 0 0 1.5px var(--brand)}
.fontrow .pick{flex:1;min-width:0;display:grid;justify-items:start;justify-content:stretch;text-align:start;gap:0;border:0;background:none;padding:8px 14px;min-height:68px}
.fontrow .face{font-size:25px;line-height:1.8;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.fontrow small{font-size:11px;color:var(--mute)}
.heart.on{color:var(--rose);box-shadow:none}
.heart.on .ic{fill:currentColor}
/* Working spinner over the page */
.working{position:absolute;inset:0;display:grid;place-content:center;justify-items:center;gap:10px;background:#0b0f24a6;color:#fff;border-radius:10px;font-size:13px}
.working i{width:34px;height:34px;border-radius:50%;border:3px solid #ffffff40;border-top-color:var(--accent);animation:turn .8s linear infinite}
@keyframes turn{to{transform:rotate(360deg)}}
[data-act=compare]{touch-action:none}
/* Category tabs stay reachable while the list under them scrolls. */
.panel>.pinned{position:sticky;top:-6px;z-index:3;background:var(--surface);padding-block:6px}
.retouch{display:block;max-width:100%;max-height:52dvh;margin:auto;border-radius:12px;touch-action:none}
/* Camera and video editor */
.camera{--bg:#0b0f24;--surface:#161c3a;--surface-2:#222b52;--ink:#f2f4ff;--mute:#b9c2e8;--line:#34407a;--brand:#a9baff;--brand-ink:#0b0f24;--soft:#27315f;color-scheme:dark;position:fixed;inset:0;z-index:10;display:flex;flex-direction:column;gap:8px;background:#000;color:#fff;padding:env(safe-area-inset-top) 8px calc(10px + env(safe-area-inset-bottom))}
.cam-top{display:flex;justify-content:space-between;gap:2px;overflow-x:auto;scrollbar-width:none}
.cam-tool{flex-direction:column;gap:1px;border:0;background:none;min-width:48px;padding:4px 2px;color:#fff}
.cam-tool small{font-size:10px;white-space:nowrap}
.cam-tool.on{color:var(--accent);box-shadow:none}
.finder-wrap{position:relative;height:100%;max-width:100%;display:grid;place-items:center}
.finder{display:block;max-width:100%;max-height:100%;border-radius:12px;background:#111}
.finder.flash{filter:brightness(2.4)}
.camera .stage .finder{position:absolute;inset:0;margin:auto}
.camera .finder-wrap{width:100%;position:absolute;inset:0}
.finder-grid{position:absolute;inset:0;pointer-events:none;background:linear-gradient(90deg,transparent 33.2%,#ffffff80 33.4%,transparent 33.6%,transparent 66.4%,#ffffff80 66.6%,transparent 66.8%),linear-gradient(transparent 33.2%,#ffffff80 33.4%,transparent 33.6%,transparent 66.4%,#ffffff80 66.6%,transparent 66.8%)}
.countdown{position:absolute;inset:0;display:grid;place-items:center;font-size:96px;font-weight:800;text-shadow:0 4px 24px #000}
.prompter{position:absolute;top:8px;left:8px;right:8px;max-height:38%;overflow:hidden;background:#000000a8;border-radius:12px;padding:10px 14px;font-size:21px;line-height:1.9;white-space:pre-wrap}
.prompter p{margin:0 0 40%}
.finder-message{position:absolute;inset:16px;display:grid;place-content:center;justify-items:center;gap:12px;text-align:center}
.camera .scroll{color:#fff}
.camera button.chip,.camera .seg button{color:#fff}
.camera .chip.on{background:var(--accent);border-color:var(--accent);color:#1c1300}
.camera .seg{background:#ffffff1a}
.camera .seg button.on{background:#fff;color:#000}
.cam-bar{display:flex;align-items:center;justify-content:space-around}
.cam-bar .icon{background:#ffffff1f;border:0;color:#fff;width:48px;height:48px;border-radius:50%}
.shutter{width:74px;height:74px;border-radius:50%;border:5px solid #fff;background:#ffffff40;padding:0}
.shutter.recording{background:#e11d48;border-radius:22px}
.video-editor .stage canvas{position:absolute;inset:4px 12px;margin:auto;max-width:calc(100% - 24px);max-height:calc(100% - 8px);border-radius:10px}
.video-editor .sheet{height:min(30dvh,300px);min-height:150px;animation:none}
.video-editor .sheet .panel{padding-top:10px}
.transport{display:flex;align-items:center;gap:8px;padding:2px 12px}
.transport input{flex:1}
.transport span{font-size:12px;white-space:nowrap}
.timeline{display:flex;gap:4px;overflow-x:auto;padding:2px 12px 8px;direction:ltr;flex:0 0 auto}
.timeline .clip{flex:0 0 auto;flex-direction:column;gap:0;min-height:48px;padding:2px;background:var(--soft)}
.timeline .clip small{font-size:11px}
.timeline .add{background:none;border-style:dashed;min-width:64px}
.timeline .add.pulse{border-color:var(--accent);color:var(--accent)}
.panel input[type=number]{width:100%;background:var(--surface-2);border:0;border-radius:10px;padding:8px}
.dialog input[type=number]{width:100%;background:var(--surface-2);border:0;border-radius:10px;padding:8px}
@media (min-width:900px){.video-editor{display:flex}.video-editor .sheet{border-inline-start:0}}
/* Fun lines */
.dialog.tall .funlist{overflow-y:auto;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));grid-auto-rows:max-content;align-content:start;gap:8px;overscroll-behavior:contain}
.funcard{padding:0;overflow:hidden;border:0;border-radius:14px;min-height:0;background:#3a4370}
.funcard canvas{display:block;width:100%;height:auto}
@media (min-width:620px){.dialog.tall .funlist{grid-template-columns:repeat(3,minmax(0,1fr))}}
/* Background removal */
.cutwrap{position:relative;display:grid;place-items:center}
.cutout{display:block;max-width:100%;max-height:42dvh;border-radius:12px;touch-action:none;background:repeating-conic-gradient(#d8d7e0 0 25%,#fff 0 50%) 0 0/18px 18px}
.cutwrap .working{text-align:center;padding:12px}
/* Large preset collections */
.looksets{display:grid;gap:6px;min-width:0}
.chip.small{min-height:28px;font-size:12px;padding:2px 10px}
.swatchgrid{display:flex;flex-wrap:wrap;gap:8px;max-height:150px;overflow-y:auto;padding:3px;overscroll-behavior:contain}
.tiles.borderset button{gap:3px;min-height:70px}
.borderset i{display:block;width:34px;height:44px;border:4px solid;border-radius:4px;background:#39447a}
.borderset small{font-size:10px;color:var(--mute)}
