/* Lenci Studio Pro — Editor (text, stickers, effects, crops, post). Extends studio.css tokens; glass panels, energy gradient for primary states.
   Layout: rail | tools | stage | post. Under 900 px the rail becomes a bottom tab bar and the tools / post panels become bottom sheets. */
.ed-app { height: 100vh; height: 100dvh; grid-template-rows: auto minmax(0, 1fr); }
.ed-app .top { flex-wrap: nowrap; z-index: 40; }
.ed-brand { text-decoration: none; color: inherit; }
.ed-pro { background: linear-gradient(180deg, rgba(34,211,238,.2), rgba(34,211,238,.05)); border-color: rgba(34,211,238,.5); color: #c6f6ff; }
.ed-back { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.ed-back::before { content: ""; width: 7px; height: 7px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin-inline-end: 2px; flex: none; }
[dir="rtl"] .ed-back::before { transform: rotate(-135deg); }
.ed-app .top-actions { flex-wrap: nowrap; }
.ed-save { display: inline-flex; align-items: center; gap: 7px; }
.ed-save-icon { width: 12px; height: 12px; flex: none; border: 1.5px solid currentColor; border-radius: 3px; position: relative; }
.ed-save-icon::after { content: ""; position: absolute; left: 3px; right: 3px; top: -1px; height: 4px; border-bottom: 1.5px solid currentColor; }
.ed-save.busy { opacity: .6; pointer-events: none; }
.ed-reset { display: inline-flex; align-items: center; gap: 6px; }
.ed-reset-icon { font-size: 14px; line-height: 1; font-family: var(--latin); }
.ed-app:has(#hint.toast) .ed-stage-hint { opacity: 0; }
.ed-stage-hint { transition: opacity var(--t); }
.ed-export-wrap { position: relative; }
.ed-export { padding: 9px 18px; }
.ed-pop { position: absolute; top: calc(100% + 10px); inset-inline-end: 0; z-index: 60; width: 300px; max-width: calc(100vw - 24px); padding: 14px; border-radius: 16px; background: linear-gradient(180deg, rgba(24,24,38,.98), rgba(16,16,26,.98)); border: 1px solid rgba(255,255,255,.1); box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(139,92,246,.18), inset 0 1px 0 rgba(255,255,255,.06); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); display: flex; flex-direction: column; gap: 12px; animation: panelIn .22s var(--ease); }
.ed-pop-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-family: var(--display); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.ed-pop-row select { background: #0b0b12; border: 1px solid var(--line-2); border-radius: 9px; padding: 7px 10px; color: var(--ink); font-size: 12px; max-width: 170px; }
.ed-pop-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ed-pop .primary { padding: 9px 16px; font-size: 11.5px; }
.ed-pop .primary::after { display: none; }
.mono { font-family: var(--mono); font-size: 10.5px; letter-spacing: .02em; }

/* ------------------------------------------------------------------ main grid */
.ed-main { display: grid; grid-template-columns: 76px 292px minmax(0, 1fr) 340px; grid-template-areas: "rail tools stage post"; min-height: 0; }
.ed-rail { grid-area: rail; display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 12px 8px; border-inline-end: 1px solid var(--line); background: linear-gradient(180deg, #11111a, #0c0c13); box-shadow: inset -1px 0 0 rgba(255,255,255,.03); animation: bootInRail .5s var(--ease) both; }
@keyframes bootInRail { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
.ed-tool { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px 8px; border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--muted); font-family: var(--display); font-size: 9px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; transition: color var(--t), background var(--t), border-color var(--t), transform var(--t) var(--ease); }
.ed-tool { min-width: 0; } .ed-tool > span:not(.ed-badge) { max-width: 100%; overflow-wrap: anywhere; hyphens: auto; text-align: center; line-height: 1.2; } /* long tool names (de "Zuschneiden") wrap inside the rail */
:lang(de) .ed-tool, :lang(fr) .ed-tool, :lang(pt) .ed-tool, :lang(es) .ed-tool, :lang(it) .ed-tool { letter-spacing: .03em; }
.ed-tool svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--t) var(--ease), filter var(--t); }
.ed-tool:hover { color: var(--ink); background: rgba(255,255,255,.04); }
.ed-tool:hover svg { transform: translateY(-1px) scale(1.06); }
.ed-tool[aria-pressed="true"] { color: #fff; border-color: rgba(168,85,247,.45); background: linear-gradient(180deg, rgba(139,92,246,.26), rgba(139,92,246,.08)); box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 0 18px rgba(139,92,246,.25); }
.ed-tool[aria-pressed="true"] svg { filter: drop-shadow(0 0 6px rgba(217,70,239,.8)); }
.ed-tool[aria-pressed="true"]::before { content: ""; position: absolute; inset-inline-start: -8px; top: 22%; bottom: 22%; width: 3px; border-radius: 3px; background: var(--energy); box-shadow: 0 0 10px rgba(217,70,239,.8); }
.ed-tool .ed-badge { position: absolute; top: 6px; inset-inline-end: 8px; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 999px; background: var(--energy); color: #fff; font-size: 8.5px; line-height: 15px; text-align: center; box-shadow: 0 0 8px rgba(217,70,239,.7); }
.ed-tool.ed-tool-post { display: none; }

/* ------------------------------------------------------------------ tools panel */
.ed-tools { grid-area: tools; min-height: 0; display: flex; flex-direction: column; border-inline-end: 1px solid var(--line); background: linear-gradient(180deg, #13131c, #0e0e15); box-shadow: inset -1px 0 0 rgba(255,255,255,.03); animation: bootIn .5s var(--ease) .08s both; }
[dir="rtl"] .ed-tools { animation-name: bootInRtl; }
.ed-tools-head, .ed-post-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; font-family: var(--display); font-size: 12px; letter-spacing: .04em; }
.ed-tools-head strong, .ed-post-head strong { font-size: 13px; font-weight: 700; background: linear-gradient(90deg, #fff, #c9c3ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ed-post-head .muted { font-size: 11px; font-family: var(--latin); }
[dir="rtl"] .ed-post-head .muted { font-family: var(--arabic); }
.ed-tools-close { display: none; margin-inline-start: auto; width: 30px; height: 30px; padding: 0; border-radius: 50%; font-size: 16px; line-height: 1; }
.ed-tools-body { min-height: 0; overflow: auto; padding: 4px 14px 28px; display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; }
.ed-group { display: flex; flex-direction: column; gap: 8px; }
.ed-label { font-family: var(--display); font-weight: 600; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); display: flex; align-items: center; gap: 8px; }
.ed-label .val { margin-inline-start: auto; font-family: var(--mono); font-size: 10px; letter-spacing: 0; text-transform: none; color: var(--muted); }
.ed-card { border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(180deg, #191927, #13131c); box-shadow: inset 0 1px 0 rgba(255,255,255,.05); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.ed-card.active { border-color: rgba(139,92,246,.35); box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 0 0 1px rgba(139,92,246,.08), 0 10px 30px rgba(0,0,0,.25); }
.ed-empty { padding: 20px 12px; text-align: center; color: var(--dim); font-size: 12px; border: 1px dashed var(--line-2); border-radius: 14px; line-height: 1.5; }
.ed-add { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 12px; border-radius: 12px; border: 1px solid rgba(168,85,247,.45); background: linear-gradient(180deg, rgba(139,92,246,.22), rgba(139,92,246,.08)); color: #ebe5ff; font-family: var(--display); font-weight: 600; font-size: 11.5px; letter-spacing: .03em; transition: transform var(--t) var(--ease), box-shadow var(--t), background var(--t); }
.ed-add:hover { transform: translateY(-1px); background: linear-gradient(180deg, rgba(139,92,246,.32), rgba(139,92,246,.12)); box-shadow: 0 0 16px rgba(139,92,246,.3); }
.ed-add .plus { font-size: 15px; line-height: 1; }
.ed-tools textarea, .ed-tools input[type="text"], .ed-tools input[type="number"], .ed-tools select { background: #0b0b12; border: 1px solid var(--line-2); border-radius: 9px; padding: 8px 10px; color: var(--ink); width: 100%; font-size: 12.5px; line-height: 1.5; box-shadow: inset 0 1px 2px rgba(0,0,0,.4); transition: border-color var(--t), box-shadow var(--t); }
.ed-tools textarea:focus, .ed-tools input:focus, .ed-tools select:focus { outline: none; border-color: rgba(139,92,246,.7); box-shadow: inset 0 1px 2px rgba(0,0,0,.4), 0 0 0 3px rgba(139,92,246,.2); }
.ed-tools textarea { resize: vertical; min-height: 56px; }
.ed-tools textarea[dir="rtl"] { font-family: var(--arabic); }
.ed-tools .slider { grid-template-columns: 78px 1fr 40px; }
.ed-tools .slider .val { min-width: 40px; }
.ed-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 2px; border-radius: 10px; border: 1px solid var(--line-2); background: rgba(0,0,0,.35); }
.ed-seg button { border: 0; background: transparent; color: var(--muted); border-radius: 8px; padding: 6px 4px; font-family: var(--display); font-size: 10.5px; font-weight: 600; transition: color var(--t), background var(--t); }
.ed-seg button:hover { color: var(--ink); }
.ed-seg button[aria-pressed="true"] { color: #fff; background: var(--active); box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 2px 8px rgba(139,92,246,.4); }
.ed-colors { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.ed-color { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,.12); padding: 0; box-shadow: inset 0 1px 1px rgba(255,255,255,.25), 0 2px 6px rgba(0,0,0,.5); transition: transform var(--t) var(--ease), border-color var(--t), box-shadow var(--t); }
.ed-color:hover { transform: scale(1.12); border-color: rgba(255,255,255,.4); }
.ed-color[aria-pressed="true"] { border-color: #fff; box-shadow: 0 0 0 2px #0a0a0f, 0 0 0 4px #a855f7, 0 0 14px rgba(217,70,239,.7); }
.ed-color.custom { position: relative; overflow: hidden; background: conic-gradient(#f87171, #fbbf24, #4ade80, #22d3ee, #8b5cf6, #f472b6, #f87171); }
.ed-color.custom input { position: absolute; inset: -8px; opacity: 0; cursor: pointer; width: 200%; height: 200%; }
.ed-fonts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ed-font { border: 1px solid var(--line); border-radius: 10px; background: var(--panel-3); color: var(--ink); padding: 9px 8px; font-size: 14px; line-height: 1.1; text-align: center; transition: border-color var(--t), transform var(--t) var(--ease), box-shadow var(--t); }
.ed-font:hover { border-color: rgba(255,255,255,.22); transform: translateY(-1px); }
.ed-font[aria-pressed="true"] { border-color: rgba(168,85,247,.7); background: linear-gradient(180deg, rgba(139,92,246,.24), rgba(139,92,246,.08)); box-shadow: 0 0 14px rgba(139,92,246,.25); }
.ed-font small { display: block; font-family: var(--display); font-size: 8.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); margin-top: 3px; }
.ed-toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); }
.ed-switch { position: relative; width: 36px; height: 20px; border-radius: 999px; border: 1px solid var(--line-2); background: rgba(0,0,0,.4); padding: 0; transition: background var(--t), border-color var(--t); flex: none; }
.ed-switch::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.5); }
.ed-switch[aria-checked="true"] { background: var(--active); border-color: transparent; }
.ed-switch[aria-checked="true"]::after { transform: translateX(16px); }
[dir="rtl"] .ed-switch[aria-checked="true"]::after { transform: translateX(-16px); }
.ed-crops { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ed-crop { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 10px 6px 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-3); color: var(--muted); font-family: var(--display); font-size: 10px; font-weight: 600; letter-spacing: .04em; transition: border-color var(--t), transform var(--t) var(--ease), box-shadow var(--t), color var(--t); }
.ed-crop i { display: block; border: 1.5px solid currentColor; border-radius: 3px; width: var(--cw, 22px); height: var(--ch, 22px); }
.ed-crop small { font-family: var(--latin); font-size: 9px; letter-spacing: 0; color: var(--dim); text-align: center; line-height: 1.25; }
.ed-crop:hover { color: var(--ink); border-color: rgba(255,255,255,.22); transform: translateY(-1px); }
.ed-crop[aria-pressed="true"] { color: #fff; border-color: transparent; background: var(--active); box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 4px 14px rgba(139,92,246,.4); }
.ed-crop[aria-pressed="true"] small { color: rgba(255,255,255,.75); }
.ed-emojis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.ed-emoji { font-size: 22px; line-height: 1; padding: 6px 0; border-radius: 9px; border: 1px solid transparent; background: transparent; transition: background var(--t), transform var(--t) var(--ease), border-color var(--t); font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.ed-emoji:hover { background: rgba(255,255,255,.07); border-color: var(--line); transform: scale(1.15); }
.ed-emoji:active { transform: scale(.95); }
.ed-shapes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ed-shape { display: grid; place-items: center; gap: 5px; padding: 9px 4px 7px; border-radius: 11px; border: 1px solid var(--line); background: var(--panel-3); color: var(--muted); font-family: var(--display); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; transition: border-color var(--t), transform var(--t) var(--ease), color var(--t); }
.ed-shape svg { width: 28px; height: 20px; fill: currentColor; stroke: currentColor; }
.ed-shape:hover { color: var(--ink); border-color: rgba(255,255,255,.22); transform: translateY(-1px); }
.ed-logo-btn { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-3); color: var(--ink); font-size: 12px; text-align: start; transition: border-color var(--t), transform var(--t) var(--ease); }
.ed-logo-btn img { width: 36px; height: 36px; border-radius: 8px; object-fit: contain; background: #0a0a0f; flex: none; }
.ed-logo-btn:hover { border-color: rgba(168,85,247,.5); transform: translateY(-1px); }
.ed-price-row { display: grid; grid-template-columns: 1fr 86px auto; gap: 6px; align-items: center; }
.ed-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.ed-preset { position: relative; padding: 0; border-radius: 11px; overflow: hidden; border: 1px solid var(--line); background: var(--panel-3); color: #fff; aspect-ratio: 1 / 1; text-align: start; transition: border-color var(--t), transform var(--t) var(--ease), box-shadow var(--t); isolation: isolate; }
.ed-preset canvas, .ed-preset img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ed-preset span { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 7px 6px; font-family: var(--display); font-size: 8.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; background: linear-gradient(transparent, rgba(8,8,14,.92) 72%); text-shadow: 0 1px 2px rgba(0,0,0,.85); }
.ed-preset:hover { border-color: rgba(255,255,255,.25); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.4); }
.ed-preset[aria-pressed="true"] { border-color: transparent; box-shadow: 0 0 0 1px rgba(217,70,239,.3), 0 0 22px rgba(139,92,246,.38); }
.ed-preset[aria-pressed="true"]::after { content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1.5px; background: var(--energy); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; }
.ed-layers { display: flex; flex-direction: column; gap: 5px; }
.ed-layer { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-3); cursor: pointer; transition: border-color var(--t), background var(--t); }
.ed-layer:hover { border-color: rgba(255,255,255,.2); }
.ed-layer[aria-selected="true"] { border-color: rgba(168,85,247,.6); background: linear-gradient(180deg, rgba(139,92,246,.2), rgba(139,92,246,.06)); }
.ed-layer .ico { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: rgba(255,255,255,.05); font-size: 15px; }
.ed-layer .name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; unicode-bidi: plaintext; }
.ed-layer .name small { display: block; font-family: var(--display); font-size: 8.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.ed-layer .acts { display: flex; gap: 2px; }
.ed-layer .acts button { width: 26px; height: 26px; padding: 0; border: 0; background: transparent; color: var(--muted); border-radius: 7px; font-size: 13px; transition: background var(--t), color var(--t); }
.ed-layer .acts button:hover { background: rgba(255,255,255,.08); color: var(--ink); }
.ed-layer .acts button[aria-pressed="true"] { color: var(--gold); }
.ed-layer .acts button.del:hover { color: #f87171; }
.ed-layer.locked { opacity: .75; }
.ed-brand-frame { display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; border: 1px solid rgba(201,184,255,.3); background: linear-gradient(135deg, rgba(139,92,246,.16), rgba(34,211,238,.08)); color: var(--ink); text-align: start; transition: transform var(--t) var(--ease), box-shadow var(--t); }
.ed-brand-frame:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(139,92,246,.3); }
.ed-brand-frame .mini { width: 56px; height: 56px; border-radius: 8px; border: 2px solid var(--fc, #c9a66b); position: relative; background: linear-gradient(135deg, #2a2a3a, #15151f); }
.ed-brand-frame .mini::after { content: ""; position: absolute; right: 4px; bottom: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--fc, #c9a66b); }
.ed-brand-frame strong { display: block; font-family: var(--display); font-size: 12px; }
.ed-brand-frame span { font-size: 11px; color: var(--muted); }
.ed-link { color: #a5b4fc; text-decoration: none; font-weight: 600; }
.ed-link:hover { text-decoration: underline; }
.ed-tools .ghost.small { padding: 5px 9px; font-size: 10.5px; }

/* ------------------------------------------------------------------ stage */
.ed-stagepane { grid-area: stage; min-width: 0; min-height: 0; display: grid; padding: 18px; position: relative; }
.ed-stagepane::before { content: ""; position: absolute; z-index: 0; left: 8%; right: 8%; top: 6%; bottom: 6%; border-radius: 50%; background: radial-gradient(closest-side at 30% 40%, rgba(139,92,246,.3), transparent), radial-gradient(closest-side at 72% 58%, rgba(217,70,239,.2), transparent), radial-gradient(closest-side at 50% 88%, rgba(34,211,238,.16), transparent); opacity: .7; animation: aurora 16s ease-in-out infinite alternate; pointer-events: none; }
.ed-stage { position: relative; z-index: 1; min-width: 0; min-height: 0; display: grid; place-items: center; border-radius: 18px; background: radial-gradient(120% 90% at 50% 0%, rgba(30,30,46,.6), rgba(10,10,15,.2) 60%), rgba(8,8,13,.55); border: 1px solid var(--line); box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 30px 80px rgba(0,0,0,.45); overflow: hidden; touch-action: none; }
.ed-canvas-wrap { position: relative; max-width: 100%; max-height: 100%; line-height: 0; filter: drop-shadow(0 24px 60px rgba(0,0,0,.6)); }
#stage-canvas { display: block; border-radius: 4px; background: #000; user-select: none; -webkit-user-select: none; touch-action: none; cursor: crosshair; box-shadow: 0 0 0 1px rgba(255,255,255,.1); }
.ed-app[data-tool="crop"] #stage-canvas { cursor: move; }
.ed-overlay { position: absolute; inset: 0; pointer-events: none; }
.ed-sel { position: absolute; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(139,92,246,.9), 0 0 14px rgba(139,92,246,.6); pointer-events: none; border-radius: 2px; }
.ed-sel.locked { border-style: dashed; box-shadow: 0 0 0 1px rgba(245,176,65,.9); }
.ed-h { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 1.5px solid #8b5cf6; box-shadow: 0 0 0 2px rgba(10,10,15,.8), 0 0 10px rgba(168,85,247,.9); pointer-events: auto; transform: translate(-50%, -50%); transition: transform var(--t) var(--ease); }
.ed-h:hover { transform: translate(-50%, -50%) scale(1.25); }
.ed-h.nw { left: 0; top: 0; cursor: nwse-resize; } .ed-h.ne { left: 100%; top: 0; cursor: nesw-resize; } .ed-h.sw { left: 0; top: 100%; cursor: nesw-resize; } .ed-h.se { left: 100%; top: 100%; cursor: nwse-resize; }
.ed-h.rot { left: 50%; top: -28px; cursor: grab; background: var(--energy); border-color: #fff; }
.ed-h.rot::before { content: ""; position: absolute; left: 50%; top: 100%; width: 1px; height: 14px; background: rgba(255,255,255,.7); transform: translateX(-50%); }
.ed-cropbox { position: absolute; border: 1.5px solid #fff; box-shadow: 0 0 0 9999px rgba(5,5,10,.62), 0 0 0 1px rgba(34,211,238,.8); pointer-events: none; }
.ed-cropbox::before, .ed-cropbox::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.ed-cropbox::before { background: linear-gradient(90deg, transparent calc(33.33% - .5px), rgba(255,255,255,.35) calc(33.33% - .5px), rgba(255,255,255,.35) calc(33.33% + .5px), transparent calc(33.33% + .5px), transparent calc(66.66% - .5px), rgba(255,255,255,.35) calc(66.66% - .5px), rgba(255,255,255,.35) calc(66.66% + .5px), transparent calc(66.66% + .5px)); }
.ed-cropbox::after { background: linear-gradient(180deg, transparent calc(33.33% - .5px), rgba(255,255,255,.35) calc(33.33% - .5px), rgba(255,255,255,.35) calc(33.33% + .5px), transparent calc(33.33% + .5px), transparent calc(66.66% - .5px), rgba(255,255,255,.35) calc(66.66% - .5px), rgba(255,255,255,.35) calc(66.66% + .5px), transparent calc(66.66% + .5px)); }
.ed-cropbox .ed-h { background: #fff; border-color: #22d3ee; box-shadow: 0 0 0 2px rgba(10,10,15,.8), 0 0 10px rgba(34,211,238,.9); }
.ed-cropbox .ed-tag { position: absolute; left: 50%; bottom: -30px; transform: translateX(-50%); white-space: nowrap; font-family: var(--mono); font-size: 10px; letter-spacing: .06em; color: #fff; background: rgba(10,10,15,.7); border: 1px solid rgba(255,255,255,.15); border-radius: 999px; padding: 3px 9px; }
.ed-hud { z-index: 3; }
.ed-stage .vf { z-index: 2; }
.ed-stage-hint { bottom: 12px; z-index: 3; }
.ed-loading { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; background: rgba(10,10,15,.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); color: #fff; font-family: var(--display); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; transition: opacity .3s var(--ease); }
.ed-loading.off { opacity: 0; pointer-events: none; }
.ed-loading span { padding-top: 76px; position: relative; }
.ed-loading span::before { content: ""; position: absolute; top: 0; left: 50%; width: 56px; height: 56px; margin-left: -28px; border-radius: 50%; background: conic-gradient(from 0deg, transparent 0 18%, #8b5cf6 42%, #d946ef 70%, #22d3ee 100%); -webkit-mask: radial-gradient(farthest-side, transparent 0 55%, #000 56% 66%, transparent 67% 91%, #000 92%); mask: radial-gradient(farthest-side, transparent 0 55%, #000 56% 66%, transparent 67% 91%, #000 92%); animation: spin 1.1s linear infinite; }
.ed-loading.error span::before { display: none; }
.ed-loading.error span { padding-top: 0; text-transform: none; letter-spacing: 0; font-family: var(--latin); max-width: 420px; text-align: center; line-height: 1.5; padding-inline: 24px; }

/* ------------------------------------------------------------------ post panel */
.ed-post { grid-area: post; min-height: 0; display: flex; flex-direction: column; border-inline-start: 1px solid var(--line); background: linear-gradient(180deg, #13131c, #0e0e15); box-shadow: inset 1px 0 0 rgba(255,255,255,.03); animation: bootIn .5s var(--ease) .16s both; }
[dir="rtl"] .ed-post { animation-name: bootInRtl; }
.ed-post-body { min-height: 0; overflow: auto; padding: 4px 16px 24px; display: flex; flex-direction: column; gap: 14px; scrollbar-width: thin; }
.ed-platforms { gap: 6px; }
.ed-platforms .chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; text-transform: none; font-size: 11px; letter-spacing: .01em; }
.ed-platforms .chip svg { width: 13px; height: 13px; fill: currentColor; }
.ed-caption-wrap { position: relative; display: flex; flex-direction: column; gap: 8px; }
#caption { background: #0b0b12; border: 1px solid var(--line-2); border-radius: 12px; padding: 11px 12px; color: var(--ink); width: 100%; font-size: 13px; line-height: 1.55; resize: vertical; min-height: 110px; box-shadow: inset 0 1px 2px rgba(0,0,0,.4); transition: border-color var(--t), box-shadow var(--t); unicode-bidi: plaintext; font-family: var(--latin); }
#caption:focus { outline: none; border-color: rgba(139,92,246,.7); box-shadow: inset 0 1px 2px rgba(0,0,0,.4), 0 0 0 3px rgba(139,92,246,.2); }
#caption[dir="rtl"], [dir="rtl"] #caption { font-family: var(--arabic); }
.ed-caption-bar { display: flex; align-items: center; gap: 6px; }
.ed-emoji-btn { padding: 6px 9px; font-size: 15px; line-height: 1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.ed-write { display: inline-flex; align-items: center; gap: 6px; border-color: rgba(168,85,247,.5); background: linear-gradient(180deg, rgba(139,92,246,.22), rgba(139,92,246,.08)); color: #ebe5ff; }
.ed-write:hover { background: linear-gradient(180deg, rgba(139,92,246,.32), rgba(139,92,246,.12)); box-shadow: 0 0 14px rgba(139,92,246,.3); color: #fff; }
.ed-write.busy { opacity: .7; pointer-events: none; }
.ed-write-icon { font-size: 13px; animation: fxTwinkle 2.2s ease-in-out infinite; display: inline-block; }
.ed-cost { font-family: var(--mono); font-size: 9.5px; padding: 1px 6px; border-radius: 999px; background: rgba(255,255,255,.1); color: #fff; }
.ed-counter { margin-inline-start: auto; color: var(--dim); }
.ed-counter.over { color: #f87171; font-weight: 600; }
.ed-emoji-pop { position: absolute; top: calc(100% - 36px); inset-inline-start: 0; z-index: 20; width: 272px; max-width: 100%; max-height: 230px; overflow: auto; padding: 8px; border-radius: 14px; background: rgba(20,20,32,.98); border: 1px solid rgba(255,255,255,.1); box-shadow: 0 24px 60px rgba(0,0,0,.6); display: flex; flex-direction: column; gap: 6px; animation: panelIn .2s var(--ease); }
.ed-emoji-pop .ed-emojis { grid-template-columns: repeat(8, 1fr); }
.ed-emoji-pop .ed-emoji { font-size: 19px; padding: 4px 0; }
.ed-emoji-pop .ed-label { padding: 2px 4px 0; }
.ed-variants { display: flex; flex-direction: column; gap: 7px; }
.ed-variant { text-align: start; padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(201,184,255,.25); background: linear-gradient(180deg, rgba(139,92,246,.12), rgba(139,92,246,.03)); color: var(--ink); font-size: 12.5px; line-height: 1.5; unicode-bidi: plaintext; transition: transform var(--t) var(--ease), border-color var(--t), box-shadow var(--t); animation: bootUp .35s var(--ease) both; }
.ed-variant:nth-child(2) { animation-delay: .06s; } .ed-variant:nth-child(3) { animation-delay: .12s; }
.ed-variant:hover { transform: translateY(-1px); border-color: rgba(168,85,247,.6); box-shadow: 0 8px 22px rgba(139,92,246,.25); }
.ed-variant[lang="ar"] { direction: rtl; font-family: var(--arabic); }
.ed-variant small { display: block; margin-top: 5px; font-family: var(--mono); font-size: 9.5px; color: #a5b4fc; direction: ltr; text-align: start; }
.ed-tags-wrap { display: flex; flex-direction: column; gap: 7px; }
.ed-tags .chip { text-transform: none; letter-spacing: 0; font-family: var(--latin); font-size: 11px; unicode-bidi: plaintext; }
.ed-tags .chip[aria-pressed="true"] { background: linear-gradient(135deg, rgba(139,92,246,.4), rgba(34,211,238,.3)); border-color: rgba(201,184,255,.4); }
.ed-tag-add input { width: 100%; background: transparent; border: 1px dashed var(--line-2); border-radius: 999px; padding: 6px 12px; color: var(--ink); font-size: 11.5px; }
.ed-tag-add input:focus { outline: none; border-color: rgba(139,92,246,.7); border-style: solid; }
.ed-post-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ed-post-actions .primary { grid-column: 1 / -1; padding: 12px 18px; }
.ed-post-actions .ghost { padding: 9px 10px; text-align: center; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-schedule { grid-column: 1 / -1; border-color: rgba(165,243,252,.35); color: #c6f6ff; background: linear-gradient(180deg, rgba(34,211,238,.14), rgba(34,211,238,.04)); }
.ed-schedule:hover { color: #fff; border-color: rgba(165,243,252,.6); box-shadow: 0 0 16px rgba(34,211,238,.3); }
.ed-schedule .nawaa-icon { width: 14px; height: 14px; }
.ed-share-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; animation: bootUp .35s var(--ease) both; }
.ed-step { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border-radius: 12px; border: 1px solid rgba(201,184,255,.25); background: rgba(139,92,246,.08); font-size: 10.5px; text-align: center; color: var(--muted); line-height: 1.3; }
.ed-step b { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--energy); color: #fff; font-family: var(--display); font-size: 11px; box-shadow: 0 0 10px rgba(217,70,239,.6); }
.ed-step a { color: #c6f6ff; font-weight: 700; text-decoration: none; }
.ed-step.done { border-color: rgba(52,211,153,.4); color: var(--ink); }
.ed-step.done b { background: #34d399; box-shadow: 0 0 10px rgba(52,211,153,.6); }

/* ------------------------------------------------------------------ toast, modal extras */
.ed-toast { position: fixed; bottom: 18px; left: 50%; z-index: 90; display: none; }
.ed-toast.toast { display: block; pointer-events: auto; }
.ed-toast a { color: #fff; font-weight: 700; margin-inline-start: 8px; text-decoration: underline; }
.ed-grid2 { margin-top: 10px; }
#sched-modal .field { margin-top: 10px; }
#sched-modal .row { margin-top: 14px; }
#sched-modal a.ghost { text-decoration: none; }
#sched-modal .status:empty { display: none; }

/* ------------------------------------------------------------------ AI edit (v3/editor-ai/ui.js) */
.ed-app[data-tool="ai"] .ed-overlay { overflow: hidden; }
.ed-app[data-tool="ai"] #stage-canvas { cursor: none; }
.ed-ai-mask { position: absolute; left: 0; top: 0; pointer-events: none; opacity: .5; }
.ed-ai-cursor { position: absolute; left: 0; top: 0; width: 56px; height: 56px; border-radius: 50%; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(10,10,15,.7), inset 0 0 0 1px rgba(10,10,15,.4), 0 0 12px rgba(232,121,249,.55); transform: translate(-50%, -50%); pointer-events: none; }
.ed-ai-cursor.erase { border-style: dashed; box-shadow: 0 0 0 1px rgba(10,10,15,.7); }
.ed-ai-cursor[hidden] { display: none; }
.ed-ai-badge { position: absolute; top: 10px; inset-inline-start: 10px; padding: 4px 10px; border-radius: 999px; background: rgba(10,10,15,.72); border: 1px solid rgba(255,255,255,.18); color: #fff; font-family: var(--display); font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; line-height: 1.4; pointer-events: none; }
.ed-ai-busy { z-index: 5; bottom: var(--ai-cover, 0px); } /* --ai-cover: the part of the stage under the phone sheet (editor.js sheetCover) */
.ed-ai-busy span { text-transform: none; letter-spacing: .02em; font-size: 12.5px; text-align: center; padding-inline: 16px; }
.ed-ai-intro, .ed-ai-hint { margin: 0; font-size: 11.5px; line-height: 1.5; }
.ed-ai-na { margin: 0; padding: 12px; }
.ed-ai-row { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-ai-cov { margin: 0; font-size: 11px; line-height: 1.45; color: var(--dim); }
.ed-ai-cov.on { color: #f0abfc; }
.ed-ai-quick .chip { text-transform: none; letter-spacing: .01em; font-size: 11px; padding: 6px 10px; }
.ed-tools .ed-ai-quick + textarea { margin-top: 2px; }
.ed-ai-ref { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 12px; border: 1px solid rgba(168,85,247,.4); background: var(--panel-3); }
.ed-ai-ref img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; background: #0a0a0f; display: block; }
.ed-ai-ref span { min-width: 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: plaintext; }
.ed-tools .ed-ai-x { width: 28px; height: 28px; padding: 0; border-radius: 50%; font-size: 15px; line-height: 1; display: inline-grid; place-items: center; }
.ed-ai-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.ed-ai-grid .muted { grid-column: 1 / -1; margin: 0; }
.ed-ai-pick { padding: 0; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #0a0a0f; transition: border-color var(--t), transform var(--t) var(--ease); }
.ed-ai-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ed-ai-pick:hover { border-color: rgba(168,85,247,.6); transform: translateY(-1px); }
.ed-ai-result { gap: 8px; }
.ed-ai-strip { display: flex; gap: 6px; overflow-x: auto; padding: 2px; scrollbar-width: thin; }
.ed-ai-thumb { position: relative; flex: none; padding: 0; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #0a0a0f; transition: box-shadow var(--t), border-color var(--t); }
.ed-ai-thumb canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.ed-ai-thumb span { position: absolute; inset-inline-start: 5px; bottom: 3px; font-family: var(--mono); font-size: 10px; color: #fff; text-shadow: 0 1px 2px #000, 0 0 4px #000; }
.ed-ai-thumb[aria-pressed="true"] { border-color: transparent; box-shadow: 0 0 0 2px #e879f9, 0 0 14px rgba(217,70,239,.55); }
.ed-ai-compare { user-select: none; -webkit-user-select: none; touch-action: none; }
.ed-ai-compare[aria-pressed="true"] { color: #fff; border-color: rgba(232,121,249,.7); background: rgba(217,70,239,.18); }
.ed-tools .ed-ai-gen { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 12px 16px; flex: none; }
.ed-ai-gen::after { animation: none; opacity: .45; }
.ed-ai-gen .lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-ai-spark { display: inline-block; font-size: 13px; line-height: 1; }
.ed-ai-gen.busy .ed-ai-spark { animation: spin 1.1s linear infinite; }
.ed-ai-gen[disabled] { cursor: not-allowed; }
.ed-ai-gen.busy[disabled] { cursor: progress; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1360px) { .ed-main { grid-template-columns: 72px 272px minmax(0, 1fr) 316px; } }
@media (max-width: 1180px) { .ed-main { grid-template-columns: 68px 256px minmax(0, 1fr) 296px; } .ed-stagepane { padding: 12px; } .ed-tools-body, .ed-post-body { padding-inline: 12px; } }
@media (max-width: 1000px) and (min-width: 901px) { .ed-main { grid-template-columns: 64px 240px minmax(0, 1fr); grid-template-areas: "rail tools stage"; } .ed-post { display: none; position: fixed; inset: auto 12px 12px 12px; } .ed-tool.ed-tool-post { display: flex; } .ed-app[data-sheet="post"] .ed-post { display: flex; z-index: 45; max-height: 70vh; border-radius: 18px; border: 1px solid rgba(255,255,255,.1); box-shadow: 0 30px 80px rgba(0,0,0,.7); } .ed-app[data-sheet="post"] .ed-post .ed-tools-close { display: inline-grid; place-items: center; } }
@media (max-width: 900px) {
  body { overflow: hidden; }
  .ed-app { grid-template-rows: auto minmax(0, 1fr); }
  .ed-app .top { flex-wrap: wrap; gap: 6px 10px; padding: 8px 12px; }
  .ed-app .top-actions { margin-inline-start: 0; flex-wrap: wrap; gap: 6px; width: 100%; }
  .ed-save span:last-child, .ed-reset span:last-child { display: none; }
  .ed-reset { padding: 7px 10px; }
  .ed-app .acct-pill { padding: 3px 8px 3px 3px; gap: 6px; }
  .ed-app .acct-credits { font-size: 0; }
  .ed-app .acct-credits b { font-size: 12px; }
  .ed-app .lang-btn { padding: 7px 9px; font-size: 11px; }
  .ed-app .cmd-group .ghost.icon { padding: 6px 8px; }
  .ed-toast { bottom: auto; top: calc(10px + env(safe-area-inset-top)); max-width: calc(100% - 24px); }
  .ed-save { padding: 7px 10px; }
  .ed-back span { display: none; }
  .ed-back { padding: 7px 9px; }
  .ed-pro { display: none; }
  .ed-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "stage" "rail"; }
  .ed-stagepane { padding: 8px 8px 0; }
  .ed-stagepane::before { display: none; }
  .ed-stage { border-radius: 14px; }
  .ed-stage-hint { display: none; }
  .ed-rail { flex-direction: row; justify-content: space-around; gap: 2px; height: calc(64px + env(safe-area-inset-bottom)); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-inline-end: 0; border-top: 1px solid var(--line); background: linear-gradient(180deg, rgba(18,18,28,.96), rgba(10,10,15,.98)); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: 0 -10px 30px rgba(0,0,0,.4); animation: none; z-index: 50; }
  .ed-tool { flex: 1 1 0; min-width: 0; padding: 7px 2px 5px; gap: 4px; font-size: 8px; letter-spacing: .06em; }
  .ed-tool svg { width: 20px; height: 20px; }
  .ed-tool[aria-pressed="true"]::before { inset-inline-start: 25%; top: -7px; bottom: auto; width: 50%; height: 3px; }
  .ed-tool.ed-tool-post { display: flex; }
  .ed-rail.has-ai { gap: 0; padding-inline: 4px; } .ed-rail.has-ai .ed-tool { padding-inline: 0; letter-spacing: .02em; } /* eight tools (AI edit): the labels keep the width they had with seven */
  .ed-tools, .ed-post { position: fixed; left: 8px; right: 8px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 48; max-height: min(52vh, 440px); border-radius: 18px; border: 1px solid rgba(255,255,255,.1); box-shadow: 0 30px 80px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.06); background: linear-gradient(180deg, rgba(22,22,34,.98), rgba(14,14,22,.98)); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); animation: sheetUp .26s var(--ease) both; display: none; }
  .ed-app[data-sheet="tools"] .ed-tools { display: flex; }
  .ed-app[data-sheet="post"] .ed-post { display: flex; }
  .ed-app[data-tool="ai"] .ed-tools { max-height: min(42vh, 360px); } /* AI edit: a shorter sheet; the photo is fitted above it (editor.js sheetCover) */
  .ed-tools-close { display: inline-grid; place-items: center; }
  .ed-tools-head, .ed-post-head { padding: 12px 14px 8px; }
  .ed-tools-head::before, .ed-post-head::before { content: ""; position: absolute; top: 6px; left: 50%; width: 38px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.18); transform: translateX(-50%); }
  .ed-tools, .ed-post { position: fixed; }
  .ed-tools-head, .ed-post-head { position: relative; }
  .ed-pop { position: fixed; top: auto; bottom: calc(72px + env(safe-area-inset-bottom)); left: 8px; right: 8px; width: auto; }
  .ed-emoji-pop { width: 100%; }
  .ed-hud { top: 8px; inset-inline-start: 8px; font-size: 9px; padding: 4px 9px; }
  .ed-h { width: 18px; height: 18px; }
  .ed-post-actions .ghost { white-space: normal; }
  @keyframes sheetUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
}
@media (max-width: 440px) {
  .ed-app .top { padding: 8px 10px; }
  .ed-app .brand .arabic { display: none; }
  .ed-export { padding: 8px 12px; font-size: 11px; }
  .ed-app .ghost { padding: 7px 9px; }
  .ed-tool { font-size: 7.5px; }
  .ed-emojis { grid-template-columns: repeat(7, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .ed-rail, .ed-tools, .ed-post, .ed-pop, .ed-variant, .ed-share-steps, .ed-emoji-pop, .ed-stagepane::before, .ed-write-icon, .ed-ai-gen.busy .ed-ai-spark { animation: none !important; }
  .ed-h, .ed-tool, .ed-tool svg, .ed-color, .ed-font, .ed-crop, .ed-preset, .ed-add, .ed-variant { transition: none !important; }
}
