/* photoediti — editor layout */
body.editor { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; user-select: none; -webkit-user-select: none; font-size: 13px; overscroll-behavior: none; }
.mobile-only { display: none !important; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 6px; height: 48px; padding: 0 10px; background: var(--panel); border-bottom: 1px solid var(--line); flex-shrink: 0; }
.topbar .brand { margin-inline-end: 8px; }
.menubar { display: flex; gap: 2px; }
.menu-btn { background: none; border: 0; color: var(--soft); padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.menu-btn:hover, .menu-btn.open { background: var(--surface); color: var(--text); }
.menu-pop { position: fixed; z-index: 100; min-width: 240px; max-height: calc(100vh - 60px); overflow-y: auto; background: #1d2027; border: 1px solid var(--line); border-radius: 10px; padding: 6px; box-shadow: 0 18px 50px rgba(0,0,0,.5); }
.menu-item { display: flex; width: 100%; align-items: center; gap: 12px; background: none; border: 0; color: var(--text); text-align: start; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13.5px; min-height: 34px; }
.menu-item span:first-child { flex: 1; }
.menu-item:hover:not(:disabled) { background: var(--coral); color: var(--on-coral); }
.menu-item:hover:not(:disabled) kbd { color: var(--on-coral); border-color: transparent; background: rgba(0,0,0,.12); }
.menu-item:disabled { color: #6b7280; cursor: default; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.pro-badge { font-size: 10px; font-weight: 800; background: var(--coral); color: var(--on-coral); padding: 1px 5px; border-radius: 4px; }
.account { display: flex; align-items: center; }
.avatar { position: relative; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--surface); color: var(--text); font-weight: 800; cursor: pointer; }
.pro-dot { position: absolute; bottom: -4px; inset-inline-end: -6px; font-size: 8px; background: var(--coral); color: var(--on-coral); padding: 1px 3px; border-radius: 3px; font-weight: 800; }

/* options bar */
.optionsbar { display: flex; align-items: center; gap: 16px; min-height: 44px; padding: 4px 12px; background: #15181d; border-bottom: 1px solid var(--line); overflow-x: auto; flex-shrink: 0; scrollbar-width: thin; }
.optionsbar > * { flex-shrink: 0; }
.opt-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--text); padding-inline-end: 6px; border-inline-end: 1px solid var(--line); }
.opt { display: inline-flex; align-items: center; gap: 8px; color: var(--soft); }
.opt input[type=range] { width: 110px; }
.opt select { min-height: 32px; padding: 4px 8px; max-width: 200px; }
.num { width: 64px; min-height: 32px !important; padding: 4px 6px !important; font-family: var(--mono); font-size: 12px; }
.unit { color: var(--muted); font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--soft); }
.seg { display: inline-flex; background: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg-btn { background: none; border: 0; color: var(--soft); padding: 5px 10px; border-radius: 6px; cursor: pointer; min-height: 30px; font-size: 12.5px; }
.seg-btn.on { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }

/* tabs */
.tabs { display: flex; gap: 2px; height: 34px; padding: 0 8px; background: var(--ink); border-bottom: 1px solid var(--line); overflow-x: auto; flex-shrink: 0; }
.tabs[hidden] { display: none; }
.doc-tab { display: flex; align-items: center; gap: 2px; padding: 0 4px 0 10px; border-radius: 8px 8px 0 0; margin-top: 4px; color: var(--muted); max-width: 220px; }
.doc-tab.on { background: var(--panel); color: var(--text); }
.doc-tab-name { background: none; border: 0; color: inherit; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 6px 2px; }
.doc-tab-x { background: none; border: 0; color: inherit; width: 24px; height: 24px; border-radius: 5px; cursor: pointer; display: grid; place-items: center; }
.doc-tab-x:hover { background: var(--surface); }

/* workspace */
.workspace { flex: 1; display: flex; min-height: 0; }
.toolbar { width: 52px; flex-shrink: 0; background: var(--panel); border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; overflow-y: auto; scrollbar-width: none; }
.tool-btn { width: 40px; height: 40px; flex-shrink: 0; border: 0; border-radius: 9px; background: none; color: var(--soft); display: grid; place-items: center; cursor: pointer; }
.tool-btn:hover { background: var(--surface); color: var(--text); }
.tool-btn.on { background: var(--coral); color: var(--on-coral); }
.tool-sep { width: 28px; height: 1px; background: var(--line); margin: 5px 0; flex-shrink: 0; }
.chips { position: relative; width: 40px; height: 44px; flex-shrink: 0; margin-top: 4px; }
.chip { position: absolute; width: 24px; height: 24px; border-radius: 6px; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.chip-fg { left: 2px; top: 2px; z-index: 1; }
.chip-bg { left: 14px; top: 14px; }
.chip-swap { position: absolute; right: -2px; top: -2px; width: 16px; height: 16px; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; }
.viewport { position: relative; flex: 1; min-width: 0; overflow: hidden; background: var(--ink-2); touch-action: none; }
.viewport canvas { position: absolute; inset: 0; display: block; }
.text-box { position: absolute; z-index: 5; background: transparent; border: 0; outline: none; resize: none; overflow: hidden; white-space: pre; margin: 0; user-select: text; -webkit-user-select: text; }
.drop-hint { position: absolute; inset: 12px; border: 2px dashed var(--coral); border-radius: 16px; display: none; place-items: center; background: rgba(255,90,60,.08); z-index: 8; pointer-events: none; font-size: 20px; font-weight: 800; color: var(--coral-2); }
body.dropping .drop-hint { display: grid; }

/* dock */
.dock { position: relative; flex-shrink: 0; background: var(--panel); border-inline-start: 1px solid var(--line); display: flex; flex-direction: row; min-height: 0; }
.panel { padding: 10px 12px; }
#panel-color { border-bottom: 1px solid var(--line); }
.color-row { display: flex; gap: 12px; align-items: center; }
.big-chips { position: relative; width: 60px; height: 52px; flex-shrink: 0; }
.big-chip { position: absolute; width: 36px; height: 36px; border-radius: 8px; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.big-fg { left: 0; top: 0; z-index: 1; }
.big-bg { left: 20px; top: 14px; }
.color-meta { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.hex { font-family: var(--mono); font-size: 13px; width: 100%; text-transform: uppercase; }
.color-btns { display: flex; gap: 6px; }
.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; margin-top: 10px; }
.sw { aspect-ratio: 1; border-radius: 5px; border: 1px solid rgba(255,255,255,.12); cursor: pointer; padding: 0; min-height: 24px; }
.dock-tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 8px; }
.dock-tab { flex: 1; background: none; border: 0; color: var(--muted); padding: 10px 6px; cursor: pointer; font-weight: 700; border-bottom: 2px solid transparent; min-height: 40px; }
.dock-tab.on { color: var(--text); border-bottom-color: var(--coral); }
.dock-panel { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.dock-panel[hidden] { display: none; }
.layer-head { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.layer-head select { width: 100%; min-height: 32px; padding: 4px 8px; }
.op-wrap { display: flex; align-items: center; gap: 8px; color: var(--soft); }
.op-wrap input[type=range] { flex: 1; min-width: 0; }
.layer-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; min-height: 120px; }
.layer-row { display: flex; align-items: center; gap: 6px; padding: 4px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; min-height: 46px; }
.layer-row:hover { background: #20242b; }
.layer-row.on { background: #2a1a17; border-color: var(--coral); }
.layer-row.hidden-layer .layer-name, .layer-row.hidden-layer .thumb { opacity: .45; }
.layer-row.dragging { opacity: .4; }
.layer-row.drop-target { box-shadow: 0 -2px 0 var(--blue); }
.layer-row .eye { width: 28px; height: 28px; flex-shrink: 0; }
.thumb { border-radius: 4px; flex-shrink: 0; outline: 1px solid var(--line); }
.thumb.target { outline: 2px solid var(--soft); }
.mask-thumb { background: #000; }
.mask-thumb.disabled { opacity: .35; }
.layer-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.tbadge { display: inline-block; margin-inline-end: 4px; font-size: 10px; background: var(--surface); padding: 0 4px; border-radius: 3px; }
.fx-badge { font-style: italic; font-weight: 800; color: var(--coral-2); font-size: 12px; }
.lock-ic { color: var(--muted); display: inline-flex; }
.rename { flex: 1; min-width: 0; min-height: 28px !important; padding: 2px 6px !important; }
.layer-foot { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 6px; margin-top: 6px; }
.hist-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.hist-item { text-align: start; background: none; border: 0; color: var(--soft); padding: 8px 10px; border-radius: 6px; cursor: pointer; min-height: 34px; }
.hist-item:hover { background: var(--surface); }
.hist-item.on { background: var(--surface); color: var(--text); box-shadow: inset 3px 0 0 var(--coral); }
.hist-item.future { color: #6b7280; }
.looks-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.look { display: flex; flex-direction: column; gap: 4px; align-items: center; background: none; border: 1px solid transparent; border-radius: 10px; padding: 4px; cursor: pointer; color: var(--soft); font-size: 12px; }
.look:hover { border-color: var(--coral); color: var(--text); }
.look-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 7px; background: #2a2e36; }
.ad-rail { width: 300px; flex-shrink: 0; background: var(--ink-2); border-inline-start: 1px solid var(--line); padding: 8px; display: flex; flex-direction: column; overflow: hidden; }
.ad-rail[hidden] { display: none !important; }
.ad-rail > div { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.ad-rail .ad-box { flex: 1; display: flex; flex-direction: column; }
.ad-rail .ad-placeholder { flex: 1; min-height: 0; height: 100%; }
.ad-rail .ad-own { display: block; flex: 1; min-height: 0; }
.ad-rail .ad-own img { width: 100%; height: 100%; object-fit: contain; object-position: top; display: block; }
.ad-rail ins.adsbygoogle { width: 100%; height: 100%; min-height: 250px; }
body.has-doc.panels-hidden .ad-rail { display: none !important; }
@media (max-width: 1500px) { .ad-rail { width: 176px; } }
.ad-rail .ad-box, .ad-rail > div { min-height: 0; height: 100%; }
.house-ad { display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: 12px; background: linear-gradient(0deg, #2a1a17, #2a1a17); border: 1px solid #5a2a20; text-decoration: none; color: var(--text); }
.house-ad span { color: var(--soft); font-size: 13px; }
.house-ad .btn { align-self: flex-start; color: var(--on-coral); }
.statusbar { display: flex; gap: 18px; height: 26px; align-items: center; padding: 0 12px; background: var(--panel); border-top: 1px solid var(--line); font-family: var(--mono); font-size: 11.5px; color: var(--muted); flex-shrink: 0; }
body.panels-hidden .dock, body.panels-hidden .toolbar { display: none; }

/* top links (About / Report a bug / Learn) */
.top-links { display: flex; align-items: center; gap: 2px; margin-inline-end: 6px; }
.top-links a, .top-links button { color: var(--soft); text-decoration: none; background: none; border: 0; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.top-links a:hover, .top-links button:hover { background: var(--surface); color: var(--text); }
.account-btn { font-weight: 700; color: var(--text); display: inline-flex; align-items: center; gap: 8px; }
.avatar-sm { width: 22px; height: 22px; border-radius: 50%; background: var(--coral); color: var(--on-coral); display: inline-grid; place-items: center; font-size: 11px; font-weight: 800; }
body:not(.has-doc) .doc-only, body:not(.has-doc) .optionsbar, body:not(.has-doc) #btnUndo, body:not(.has-doc) #btnRedo { display: none !important; }
body:not(.has-doc) .dock, body:not(.has-doc) .toolbar, body:not(.has-doc) .statusbar, body:not(.has-doc) .mobilebar { display: none !important; }
body:not(.has-doc) .workspace { padding-bottom: 0; }

/* continue where you left off */
.cont { width: 100%; max-width: 820px; margin: 0 0 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.cont-main { display: flex; gap: 18px; align-items: center; background: none; border: 0; color: var(--text); text-align: start; cursor: pointer; padding: 0; border-radius: 12px; }
.cont-main:hover .cont-thumb { outline: 2px solid var(--coral); }
.cont-thumb { width: 200px; aspect-ratio: 4/3; flex-shrink: 0; border-radius: 10px; overflow: hidden; background: #2a2e36; display: grid; place-items: center; }
.cont-thumb img { width: 100%; height: 100%; object-fit: contain; }
.cont-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; align-items: flex-start; }
.cont-kicker { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--coral-2); }
.cont-name { font-size: 22px; letter-spacing: -0.02em; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cont-meta { color: var(--muted); font-size: 13px; }
.cont-btn { margin-top: 6px; pointer-events: none; }
.cont-row { display: flex; gap: 10px; overflow-x: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.cont-mini { flex: 0 0 120px; display: flex; flex-direction: column; gap: 3px; background: none; border: 1px solid transparent; border-radius: 10px; padding: 4px; color: var(--soft); cursor: pointer; text-align: start; font-size: 12px; }
.cont-mini:hover { border-color: var(--coral); color: var(--text); }
.cont-mini img { width: 100%; aspect-ratio: 4/3; object-fit: contain; background: #2a2e36; border-radius: 7px; }
.cont-mini span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cont-mini small { color: var(--muted); font-size: 11px; }
.cont-more { align-items: center; justify-content: center; background: var(--surface); }
.cont-more span { font-size: 20px; font-weight: 800; color: var(--text); }
.recent-open { display: flex; flex-direction: column; gap: 4px; background: none; border: 0; padding: 0; color: var(--text); text-align: start; cursor: pointer; }
.recent-open b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-x { align-self: flex-start; }

/* ads + announcement */
.ad-unit { min-height: 90px; }
.home-ad { width: 100%; max-width: 820px; margin-top: 32px; }
.home-note { align-self: stretch; max-width: 820px; margin: 0 auto 8px; background: #2a1a17; border: 1px solid #5a2a20; color: var(--text); border-radius: 10px; padding: 10px 14px; text-align: center; }

/* home screen */
.welcome.home { display: flex; padding: 0; }
.home-side { width: 250px; flex-shrink: 0; padding: 20px 0; border-inline-end: 1px solid var(--line); background: var(--ink); display: flex; flex-direction: column; gap: 2px; }
.home-nav { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 24px; background: none; border: 0; color: var(--soft); font-size: 15px; cursor: pointer; text-align: start; min-height: 48px; }
.home-nav:hover { background: var(--panel); color: var(--text); }
.home-nav.on { background: var(--panel); color: var(--text); box-shadow: inset 3px 0 0 var(--coral); }
[dir=rtl] .home-nav.on { box-shadow: inset -3px 0 0 var(--coral); }
.home-main { flex: 1; min-width: 0; overflow-y: auto; padding: clamp(24px, 5vw, 56px); display: flex; flex-direction: column; align-items: center; }
.home-logo { display: flex; align-items: center; gap: 28px; margin: 12px 0 40px; direction: ltr; }
.home-logo img { width: clamp(72px, 9vw, 128px); height: auto; }
.home-word { font-size: clamp(48px, 8vw, 112px); letter-spacing: -0.045em; line-height: 1; }
.home-word .w1 { font-weight: 500; color: var(--soft); }
.home-word .w2 { font-weight: 800; color: var(--text); }
.home-btns { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.home-btns.start { justify-content: flex-start; }
.home-btn { display: inline-flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px 22px; background: transparent; border: 1px solid #454b56; border-radius: 10px; color: var(--text); font-size: 16px; font-weight: 500; cursor: pointer; }
.home-btn:hover { border-color: var(--coral); background: rgba(255,90,60,.06); }
.home-btn svg { color: var(--soft); }
.home-drop { width: 100%; max-width: 820px; min-height: 190px; margin: 28px 0 32px; border: 1px dashed #454b56; border-radius: 12px; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; }
.home-drop:hover { border-color: var(--coral); color: var(--soft); }
body.dropping .home-drop { border-color: var(--coral); background: rgba(255,90,60,.06); }
.home-formats { display: flex; gap: clamp(14px, 3vw, 34px); flex-wrap: wrap; justify-content: center; }
.fmt { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--soft); font-size: 15px; font-weight: 500; }
.fmt-ic { width: 58px; height: 58px; border: 3px solid; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 12.5px; letter-spacing: -0.02em; background: var(--panel); }
.home-h2 { align-self: stretch; font-size: 16px; color: var(--soft); margin: 40px 0 12px; }
.home-title { align-self: stretch; font-size: 26px; margin: 0 0 16px; letter-spacing: -0.02em; }
.home-main .preset-grid, .home-main .recent-grid { align-self: stretch; }
.home-main > .hint { align-self: stretch; }
.preset-shape.dashed { border-style: dashed; }

/* welcome */
.welcome { position: absolute; inset: 0; display: flex; z-index: 4; background: var(--ink-2); user-select: none; }
.welcome[hidden] { display: none; }
.wel-hero { text-align: center; padding: 20px 0 32px; }
.wel-hero h1 { font-size: clamp(26px, 4vw, 40px); letter-spacing: -0.03em; margin: 0 0 18px; }
.wel-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.welcome h2 { font-size: 16px; color: var(--soft); margin: 28px 0 12px; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.preset { display: flex; flex-direction: column; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 10px; cursor: pointer; color: var(--text); }
.preset:hover { border-color: var(--coral); }
.preset-shape { display: block; border: 2px solid var(--soft); border-radius: 3px; margin-bottom: 4px; min-width: 10px; min-height: 10px; }
.preset small, .recent small { color: var(--muted); font-size: 12px; }
.recent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.recent { display: flex; flex-direction: column; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; cursor: pointer; color: var(--text); text-align: start; }
.recent:hover { border-color: var(--coral); }
.recent img { width: 100%; aspect-ratio: 4/3; object-fit: contain; background: #2a2e36; border-radius: 8px; }

/* modal */
.backdrop { position: fixed; inset: 0; z-index: 200; background: rgba(5,6,8,.6); display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 440px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,.6); user-select: text; }
.modal-wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 8px 16px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; color: var(--soft); }
.field-ctl { display: flex; align-items: center; gap: 10px; }
.field-ctl input[type=range] { flex: 1; min-width: 0; }
.field-check { flex-direction: row; }
.field select, .field input[type=text], .field input[type=email], .field input[type=password] { width: 100%; }
.field input[type=color] { width: 56px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--ink); padding: 2px; }
.anchor-grid { display: grid; grid-template-columns: repeat(3, 32px); gap: 4px; }
.anchor { width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--line); background: var(--ink); cursor: pointer; }
.anchor.on { background: var(--coral); border-color: var(--coral); }
.curve-wrap { display: flex; flex-direction: column; gap: 8px; }
.curve-top { display: flex; align-items: center; gap: 10px; }
.curve-canvas { width: 100%; max-width: 320px; aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--line); touch-action: none; align-self: center; }
.share-box { display: flex; flex-direction: column; gap: 10px; }
.share-url { width: 100%; font-family: var(--mono); font-size: 13px; }
.share-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.kbd-table { width: 100%; border-collapse: collapse; }
.kbd-table td { padding: 6px 4px; border-bottom: 1px solid var(--line); color: var(--soft); }
.adj-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.adj-item { background: var(--surface); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 12px; text-align: start; cursor: pointer; min-height: 48px; }

/* toasts */
.toasts { position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; background: #1d2027; border: 1px solid var(--line); color: var(--text); padding: 10px 14px; border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.5); display: flex; gap: 12px; align-items: center; transition: opacity .3s, transform .3s; max-width: min(520px, 92vw); }
.toast-error { border-color: #6b2b2b; }
.toast.out { opacity: 0; transform: translateY(8px); }
.toast-action { background: none; border: 0; color: var(--coral-2); font-weight: 800; cursor: pointer; padding: 4px; }

/* sheets */
.sheet-backdrop { position: fixed; inset: 0; z-index: 150; background: rgba(5,6,8,.45); display: flex; align-items: flex-end; }
.sheet { width: 100%; max-height: 78dvh; display: flex; flex-direction: column; background: var(--panel); border-radius: 18px 18px 0 0; border-top: 1px solid var(--line); transform: translateY(100%); transition: transform .22s ease; padding-bottom: env(safe-area-inset-bottom); }
.sheet-backdrop.open .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; position: relative; }
.sheet-head h2 { margin: 6px 0 0; font-size: 16px; }
.sheet-grip { position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--line); }
.sheet-body { overflow-y: auto; padding: 4px 12px 16px; }
.m-menu details { border-bottom: 1px solid var(--line); }
.m-menu summary { padding: 14px 4px; font-weight: 700; cursor: pointer; font-size: 15px; }
.m-menu .menu-pop { position: static; box-shadow: none; border: 0; background: none; max-height: none; padding: 0 0 8px; }
.m-menu .menu-item { min-height: 44px; font-size: 15px; }

/* ---------- mobile ---------- */
@media (max-width: 820px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }
  .topbar { height: 52px; gap: 2px; padding: 0 6px; }
  .topbar .brand-word { display: none; }
  .topbar .btn { padding: 6px 10px; }
  .optionsbar { gap: 12px; }
  .opt input[type=range] { width: 90px; }
  .workspace { padding-bottom: 112px; }
  .dock { position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-height: 72dvh; z-index: 120; border-radius: 18px 18px 0 0; border: 0; border-top: 1px solid var(--line);
    transform: translateY(105%); transition: transform .22s ease; box-shadow: 0 -20px 50px rgba(0,0,0,.5); padding-bottom: env(safe-area-inset-bottom); }
  body.dock-open .dock { transform: none; }
  .dock-mhead { position: relative; justify-content: flex-end; padding: 4px 8px 0; }
  .dock-mhead .sheet-grip { top: 10px; }
  .dock { flex-direction: column; }
  .dock-col { width: auto !important; min-height: 0; }
  .col-toggle { display: none !important; }
  .pgroup { display: none !important; }
  .pgroup.m-active { display: flex !important; flex: 1; }
  .dock-flyout { display: none !important; }
  .np-body { grid-template-columns: 1fr !important; height: auto !important; max-height: 78dvh; overflow-y: auto; }
  .np-cats { flex-direction: row !important; overflow-x: auto; border: 0 !important; border-bottom: 1px solid var(--line) !important; padding: 0 0 6px !important; }
  .np-cats button { flex-shrink: 0; }
  .np-grid { max-height: 34dvh; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important; }
  .np-form { border: 0 !important; padding: 0 !important; }
  .install-btn span { display: none; }
  .mods-bar { bottom: 8px; }
  .ad-rail { display: none !important; }
  .mobilebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 110; flex-direction: column; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .toolstrip { display: flex; gap: 2px; overflow-x: auto; padding: 6px 8px; scrollbar-width: none; }
  .toolstrip::-webkit-scrollbar { display: none; }
  .toolstrip .tool-btn { width: 44px; height: 44px; }
  .toolstrip .tool-sep { width: 1px; height: 28px; margin: 8px 4px; }
  .mtabs { display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--line); }
  .mtabs button { background: none; border: 0; color: var(--soft); min-height: 46px; font-weight: 700; cursor: pointer; }
  .toasts { bottom: 130px; }
  .modal { max-width: none; }
  .backdrop { place-items: end center; padding: 0; }
  .backdrop .modal { border-radius: 18px 18px 0 0; max-height: 88dvh; }
  .looks-grid { grid-template-columns: repeat(4, 1fr); }
  .layer-row { min-height: 52px; }
  .welcome { flex-direction: column; }
  .home-side { width: auto; flex-direction: row; overflow-x: auto; padding: 0; border-inline-end: 0; border-bottom: 1px solid var(--line); flex-shrink: 0; }
  .home-nav { width: auto; flex-shrink: 0; padding: 10px 14px; gap: 8px; font-size: 14px; }
  .home-nav.on, [dir=rtl] .home-nav.on { box-shadow: inset 0 -3px 0 var(--coral); }
  .home-main { padding: 20px 16px 32px; }
  .home-logo { gap: 14px; margin: 8px 0 24px; }
  .home-btns { gap: 10px; }
  .home-btn { min-height: 50px; padding: 10px 14px; font-size: 15px; flex: 1 1 140px; justify-content: center; }
  .home-drop { min-height: 120px; margin: 16px 0 20px; }
  .fmt-ic { width: 46px; height: 46px; font-size: 10.5px; }
  .cont-main { flex-direction: column; align-items: stretch; gap: 12px; }
  .cont-thumb { width: 100%; }
  .cont-btn { align-self: stretch; }
}

/* ---------- Photopea-style toolbar ---------- */
.tool-btn { position: relative; }
.tool-btn.has-group::after { content: ''; position: absolute; right: 4px; bottom: 4px; border: 3px solid transparent; border-right-color: currentColor; border-bottom-color: currentColor; opacity: .7; }
[dir=rtl] .tool-btn.has-group::after { right: auto; left: 4px; border-right-color: transparent; border-left-color: currentColor; }
.tool-fly { min-width: 220px; }
.tool-fly .menu-item { display: flex; align-items: center; gap: 10px; }
.tool-fly .fly-ic { display: inline-grid; place-items: center; width: 22px; color: var(--soft); }
.tool-fly .menu-item span:nth-child(2) { flex: 1; }
.kbd-btn { margin-top: 6px; }
.mods-bar { position: absolute; left: 12px; bottom: 12px; z-index: 9; display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.mods-bar .seg-btn { min-width: 56px; min-height: 36px; }

/* ---------- dock: strip + flyouts + groups ---------- */
.dock-strip { width: 42px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; border-inline-end: 1px solid var(--line); background: var(--panel); padding-bottom: 6px; }
.strip-toggle { width: 100%; height: 22px; border: 0; border-bottom: 1px solid var(--line); background: var(--ink); color: var(--muted); font: 700 11px var(--mono); cursor: pointer; flex-shrink: 0; letter-spacing: -1px; }
.strip-toggle:hover { color: var(--text); background: var(--surface); }
.strip-icons { display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 6px; }
.strip-btn { width: 34px; height: 34px; border: 0; border-radius: 8px; background: none; color: var(--soft); display: grid; place-items: center; cursor: pointer; }
.strip-btn:hover { background: var(--surface); color: var(--text); }
.strip-btn.on { background: var(--surface); color: var(--coral-2); box-shadow: inset 2px 0 0 var(--coral); }
.strip-sep { width: 22px; height: 1px; background: var(--line); margin: 4px 0; }
body.strip-hidden .strip-icons { display: none; }
body.strip-hidden .dock-strip { width: 22px; }
body.strip-hidden .strip-toggle { writing-mode: vertical-rl; height: 44px; border: 0; }
.dock-col { width: 286px; display: flex; flex-direction: column; min-height: 0; }
body.dock-narrow .dock-col { width: 220px; }
.col-toggle { border-bottom: 1px solid var(--line); text-align: end; padding: 0 10px; }
.pgroup { display: flex; flex-direction: column; min-height: 0; }
.pgroup-top { flex: 0 0 32%; border-bottom: 4px solid var(--ink-2); }
.pgroup-main { flex: 1; }
.pgroup .dock-tabs { padding: 0; background: var(--ink); }
.pgroup .dock-tab { flex: 0 0 auto; padding: 7px 12px; min-height: 32px; font-size: 12.5px; border-bottom: 0; border-inline-end: 1px solid var(--line); border-radius: 0; }
.pgroup .dock-tab.on { background: var(--panel); box-shadow: inset 0 2px 0 var(--coral); }
.pgroup .panel { padding: 8px 10px; }
.dock-flyout { position: absolute; top: 0; inset-inline-end: 100%; width: 270px; max-height: 100%; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-top: 0; box-shadow: -14px 10px 30px rgba(0,0,0,.45); z-index: 30; }
.dock-flyout[hidden] { display: none; }
.fly-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; background: var(--ink); border-bottom: 1px solid var(--line); font-size: 12.5px; }
.fly-head .icon-btn { width: 26px; height: 26px; }
.fly-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.fly-row { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--soft); }
.fly-row.check { flex-direction: row; align-items: center; }
.fly-ctl { display: flex; align-items: center; gap: 6px; }
.fly-ctl input[type=range] { flex: 1; min-width: 0; }
.fly-row select { width: 100%; }
.info-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 12.5px; }
.info-grid span { color: var(--muted); }
.info-grid b { font-family: var(--mono); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adj-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.adj-chip { background: var(--surface); border: 1px solid var(--line); color: var(--soft); border-radius: 8px; padding: 8px; font-size: 12px; cursor: pointer; text-align: start; }
.adj-chip:hover { border-color: var(--coral); color: var(--text); }
.brush-prev { width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.css-out { width: 100%; min-height: 200px; font: 12px/1.5 var(--mono); background: var(--ink-2); color: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 8px; resize: vertical; }
.prop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.prop-field { display: flex; align-items: center; gap: 6px; font: 600 12px var(--mono); color: var(--muted); }
.prop-field input { width: 100%; }
.fly-body .fly-row:has(> .btn) { flex-direction: row; flex-wrap: wrap; gap: 6px; }

/* swatches panel */
#panel-swatches .color-row { align-items: center; }
#panel-swatches .hex { flex: 1; }
.swatches { grid-template-columns: repeat(auto-fill, minmax(22px, 1fr)); gap: 4px; }
.sw-add { display: grid; place-items: center; background: var(--surface) !important; color: var(--soft); border-style: dashed; }

/* layers panel (Photopea style) */
.layer-head { gap: 6px; border-bottom: 1px solid var(--line); margin: 0 -10px 6px; padding: 0 10px 8px; }
.lh-row { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--soft); }
.lh-row select { flex: 1; min-width: 0; width: auto; min-height: 28px; font-size: 12.5px; }
.lh-lbl { margin-inline-end: 2px; }
.pct-wrap { display: inline-flex; align-items: center; background: var(--ink-2); border: 1px solid var(--line); border-radius: 6px; padding-inline-end: 4px; }
.pct-wrap .num.pct { width: 40px; border: 0; background: none; text-align: end; padding: 3px 2px; min-height: 26px; }
.pct-wrap .unit { font-size: 11px; color: var(--muted); }
.tri-btn { background: none; border: 0; color: var(--muted); cursor: pointer; width: 18px; height: 24px; padding: 0; }
.tri-btn:hover { color: var(--text); }
.range-pop { padding: 12px; width: 190px; }
.range-pop input { width: 100%; }
.lock-btn { width: 26px; height: 26px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--muted); display: grid; place-items: center; cursor: pointer; padding: 0; }
.lock-btn:hover { color: var(--text); background: var(--surface); }
.lock-btn.on { color: var(--coral-2); border-color: var(--coral); background: #2a1a17; }
.grow { flex: 1; }
.layer-list { gap: 1px; }
.layer-row { min-height: 40px; padding: 3px 4px; border-radius: 4px; gap: 5px; }
.layer-row.in-group { padding-inline-start: 26px; }
.layer-row.is-group .layer-name { font-weight: 700; }
.layer-row .caret { width: 18px; height: 18px; color: var(--muted); transition: transform .12s; }
.layer-row .caret.open { transform: rotate(90deg); }
[dir=rtl] .layer-row .caret:not(.open) { transform: rotate(180deg); }
.grp-ic { color: #F2B33D; display: inline-grid; place-items: center; width: 30px; }
.adj-thumb { width: 44px; height: 30px; border-radius: 4px; border: 0; outline: 1px solid var(--line); background: var(--ink-2); color: var(--soft); display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.lock-ic.partial { opacity: .55; }
.layer-foot { justify-content: flex-end; gap: 2px; }
.layer-foot .icon-btn { width: 30px; height: 30px; }
.chan-list { display: flex; flex-direction: column; gap: 1px; }
.chan-list kbd, .layer-row kbd { font-size: 10.5px; color: var(--muted); }
#panel-paths, #panel-layers { display: flex; flex-direction: column; }
#panel-paths[hidden], #panel-layers[hidden] { display: none; }

/* ---------- New Project dialog ---------- */
.np-modal { width: min(1040px, 96vw); max-width: none; }
.np-body { display: grid; grid-template-columns: 150px 1fr 250px; height: min(620px, 74vh); min-height: 0; }
.np-cats { display: flex; flex-direction: column; gap: 2px; padding: 12px 8px; border-inline-end: 1px solid var(--line); background: var(--ink); }
.np-cats button { background: none; border: 0; color: var(--soft); text-align: start; padding: 10px 12px; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 14px; }
.np-cats button:hover { background: var(--surface); color: var(--text); }
.np-cats button.on { background: var(--coral); color: var(--on-coral); }
.np-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; padding: 14px; overflow-y: auto; align-content: start; }
.np-card { display: flex; flex-direction: column; gap: 4px; align-items: center; background: var(--surface); border: 2px solid transparent; border-radius: 10px; padding: 10px 8px; cursor: pointer; color: var(--text); text-align: center; }
.np-card:hover { border-color: var(--line); }
.np-card.on { border-color: var(--coral); background: #2a1a17; }
.np-card b { font-size: 12.5px; line-height: 1.25; }
.np-card small { color: var(--muted); font: 11px var(--mono); }
.np-prev, .preset-prev { width: 120px; height: 90px; display: grid; place-items: center; }
.preset-prev { width: 64px; height: 50px; }
.tpl-shape { display: block; background: #fff; border-radius: 2px; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.tpl-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.np-form { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-inline-start: 1px solid var(--line); overflow-y: auto; }
.np-field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--soft); flex: 1; min-width: 0; }
.np-field input, .np-field select { width: 100%; }
.np-wh { display: flex; gap: 6px; align-items: flex-end; }
.np-wh .icon-btn { margin-bottom: 2px; }
.np-info { font-family: var(--mono); }
.np-create { margin-top: auto; min-height: 44px; font-size: 15px; }

/* home templates & install */
.tpl-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tpl-tabs button { background: var(--surface); border: 1px solid var(--line); color: var(--soft); border-radius: 999px; padding: 8px 16px; font-weight: 700; cursor: pointer; }
.tpl-tabs button.on { background: var(--coral); border-color: var(--coral); color: var(--on-coral); }
.install-btn { display: inline-flex; align-items: center; gap: 6px; border-color: var(--coral) !important; color: var(--coral-2) !important; margin-inline-end: 6px; }
.install-btn[hidden] { display: none !important; }
.install-help ol { padding-inline-start: 22px; display: flex; flex-direction: column; gap: 8px; color: var(--soft); }
.pct-wrap .num.pct { width: 34px; -moz-appearance: textfield; appearance: textfield; }
.pct-wrap .num.pct::-webkit-inner-spin-button, .pct-wrap .num.pct::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.top-links a, .top-links button { white-space: nowrap; }
@media (min-width: 821px) {
  .toolbar { gap: 1px; padding: 6px 0; }
  .toolbar .tool-btn { width: 38px; height: 34px; border-radius: 7px; }
  .toolbar .tool-btn svg { width: 19px; height: 19px; }
  .toolbar .tool-sep { margin: 3px 0; }
}
@media (max-width: 1400px) { .install-btn span { display: none; } .install-btn { padding-inline: 8px; } }
@media (max-width: 1180px) { .top-links a[href="/about"] { display: none; } }
.layer-row .caret { color: var(--soft); }
.account-btn { white-space: nowrap; }

.home-side-ad { margin: 18px 16px 0; width: auto !important; box-sizing: border-box; }
.home-side-ad .ad-placeholder { min-height: 200px; }
.home-side-ad .ad-own img { width: 100%; height: auto; display: block; border-radius: 8px; }
@media (max-width: 820px) { .home-side-ad { display: none; } }
.kbd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px 28px; }
.kbd-grid h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--coral-2); margin: 12px 0 6px; }
.kbd-grid .kbd-table { width: 100%; }
.kbd-grid .kbd-table td { padding: 4px 6px 4px 0; font-size: 13px; color: var(--soft); vertical-align: top; }
.kbd-grid .kbd-table td:first-child { white-space: nowrap; width: 1%; }
.kbd-grid > .hint { grid-column: 1 / -1; margin-top: 10px; }

/* top bar: keep items from squeezing into each other */
.topbar > * { flex-shrink: 0; }
.topbar > .grow { flex-shrink: 1; min-width: 8px; }
.topbar .brand { margin-inline-end: 14px; }
.topbar .brand-word { white-space: nowrap; }
.topbar .menubar { flex-shrink: 1; min-width: 0; overflow: hidden; }
.menu-btn { white-space: nowrap; padding: 7px 9px; }
.top-links .top-ic { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; }
@media (max-width: 1320px) { .menu-btn { padding: 7px 7px; } .topbar { gap: 4px; } }
