/* SPDX-License-Identifier: GPL-3.0-or-later */
/* Thumbfish – thumbnail and social image studio. Copyright (C) 2026 Jan-Maurice Dahlmanns (Bugfish) */

:root {
  --bg: #0a0a0a;
  --bg-2: #0e0f11;
  --panel: #121315;
  --panel-2: #17191c;
  --panel-3: #1e2125;
  --well: #0b0c0d;
  --line: rgba(255, 255, 255, .075);
  --line-2: rgba(255, 255, 255, .13);
  --text: #e6e6e6;
  --dim: #aeaeae;
  --muted: #818181;
  --head: #fff;
  --accent: #ff5707;
  --accent-2: #ff7128;
  --accent-text: #ff7a3d;
  --accent-soft: rgba(255, 87, 7, .14);
  --accent-line: rgba(255, 87, 7, .5);
  --on-accent: #140800;
  --danger: #ff3b6b;
  --danger-text: #ff8aa6;
  --green: #2fcf7c;
  --warn: #ffd23f;
  --r: 10px;
  --r-sm: 7px;
  --shadow: 0 16px 40px -12px rgba(0, 0, 0, .75);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  --top-h: 54px;
  --status-h: 26px;
  --rail-w: 72px;
  --side-w: 300px;
  --right-w: 320px;
  --pages-h: 86px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.noscript { padding: 40px; text-align: center; }

.ic { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic .f { fill: currentColor; stroke: none; }

/* ------------------------------------------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; padding: 6px 12px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--panel-2); color: var(--text);
  white-space: nowrap; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover:not(:disabled) { background: var(--panel-3); border-color: rgba(255, 255, 255, .2); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.ghost { background: transparent; border-color: transparent; padding: 6px 8px; color: var(--dim); }
.btn.ghost:hover:not(:disabled) { background: rgba(255, 255, 255, .06); color: var(--text); }
.btn.ghost.on, .btn.on { color: var(--accent-text); border-color: var(--accent-line); background: var(--accent-soft); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.accent:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { color: var(--danger-text); }
.btn.danger:hover:not(:disabled) { border-color: var(--danger); background: rgba(255, 59, 107, .12); }
.btn.ghost.danger { color: var(--muted); }
.btn.ghost.danger:hover:not(:disabled) { color: var(--danger-text); }
.btn.sm { min-height: 28px; padding: 3px 8px; font-size: 13px; }
.btn.big { min-height: 44px; padding: 10px 18px; font-size: 15px; border-radius: var(--r); }
.btn.wide { flex: 1 1 auto; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row.mid { justify-content: center; }
.linkish { background: none; border: 0; padding: 0; color: var(--dim); text-decoration: underline; text-underline-offset: 3px; }
.only-narrow { display: none !important; }

/* ------------------------------------------------------------------------------------------------- app frame */
.app { display: grid; grid-template-rows: var(--top-h) 1fr var(--status-h); height: 100vh; height: 100dvh; }
.top { display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.exit { display: inline-flex; align-items: center; gap: 6px; color: var(--dim); text-decoration: none; padding: 6px 10px 6px 6px; border-radius: var(--r-sm); white-space: nowrap; }
.exit:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.brand { display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; padding: 4px 6px; font-weight: 700; font-size: 16px; color: var(--head); letter-spacing: .2px; }
.brand .ic { color: var(--accent); }
.top-editor { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; min-width: 0; }
.mode-start .top-editor { display: none; }
.top-sp { flex: 1 1 auto; }
.proj-name { min-width: 80px; width: 240px; max-width: 32vw; background: transparent; border: 1px solid transparent; border-radius: var(--r-sm); padding: 6px 9px; color: var(--head); font-weight: 600; text-overflow: ellipsis; }
.proj-name:hover { border-color: var(--line-2); }
.proj-name:focus { border-color: var(--accent-line); background: var(--well); outline: none; }
.zoom { display: flex; align-items: center; gap: 0; margin: 0 4px; }
.zoom-label { min-width: 62px; background: transparent; border: 0; color: var(--dim); padding: 6px 4px; border-radius: var(--r-sm); font-variant-numeric: tabular-nums; }
.zoom-label:hover { background: rgba(255, 255, 255, .06); color: var(--text); }

.start-view { overflow: auto; }
.mode-editor .start-view { display: none; }
.editor-view { display: none; min-height: 0; }
.mode-editor .editor-view { display: grid; grid-template-columns: var(--rail-w) var(--side-w) minmax(0, 1fr) var(--right-w); min-height: 0; }
.mode-editor.side-closed .editor-view { grid-template-columns: var(--rail-w) 0 minmax(0, 1fr) var(--right-w); }
.mode-editor.side-closed .side { display: none; }

.status { display: flex; align-items: center; gap: 14px; padding: 0 12px; background: var(--panel); border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; }
.status .st-sp { flex: 1; }
.mode-start .status > * { display: none; }

/* ------------------------------------------------------------------------------------------------- start */
.start-hero { padding: 34px 24px 10px; max-width: 1180px; margin: 0 auto; }
.start-drop {
  border: 2px dashed rgba(255, 255, 255, .16); border-radius: 18px; padding: 40px 24px 30px; text-align: center; cursor: pointer;
  background: radial-gradient(ellipse at 50% 0%, rgba(255, 87, 7, .12), transparent 60%), var(--bg-2); transition: border-color .15s, background .15s;
}
.start-drop:hover, .dropping .start-drop { border-color: var(--accent-line); }
.start-drop > .ic { color: var(--accent); }
.start-drop h2 { margin: 10px 0 6px; font-size: 26px; color: var(--head); letter-spacing: .2px; }
.start-drop p { margin: 0 auto 20px; max-width: 640px; color: var(--dim); }
.start-privacy { display: inline-flex; align-items: center; gap: 6px; margin: 18px 0 0 !important; font-size: 13px; color: var(--muted) !important; }
.start-sec { max-width: 1180px; margin: 0 auto; padding: 16px 24px; }
.start-sec h3 { margin: 0 0 12px; font-size: 15px; color: var(--head); }
.start-sec-head { display: flex; align-items: baseline; gap: 12px; }
.start-quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.quick-card { display: grid; grid-template-rows: 64px auto auto auto; justify-items: center; gap: 1px; padding: 12px 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); text-align: center; }
.quick-card:hover { border-color: var(--accent-line); background: var(--panel-2); }
.quick-card b { font-size: 12px; color: var(--accent-text); text-transform: uppercase; letter-spacing: .6px; }
.quick-card span { font-size: 13px; color: var(--text); }
.quick-card small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.quick-ic { display: grid; place-items: center; width: 64px; height: 60px; }
.quick-ic i { display: block; border: 2px solid var(--dim); border-radius: 4px; background: rgba(255, 255, 255, .04); }
.quick-card:hover .quick-ic i { border-color: var(--accent); }
.start-recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.recent-card { position: relative; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); overflow: hidden; }
.recent-card:hover { border-color: var(--line-2); }
.recent-open { display: grid; gap: 2px; width: 100%; padding: 0 0 10px; border: 0; background: none; text-align: left; }
.recent-open b, .recent-open small { padding: 0 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-open b { margin-top: 8px; color: var(--head); font-weight: 600; }
.recent-open small { color: var(--muted); font-size: 12px; }
.recent-img { aspect-ratio: 16 / 9; background: #1d2028; display: grid; place-items: center; overflow: hidden; }
.recent-img img { max-width: 100%; max-height: 100%; display: block; }
.recent-del { position: absolute; top: 6px; right: 6px; background: rgba(10, 10, 10, .75) !important; opacity: 0; }
.recent-card:hover .recent-del, .recent-del:focus-visible { opacity: 1; }
.start-storage { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.start-foot { max-width: 1180px; margin: 10px auto 40px; padding: 14px 24px; display: flex; gap: 18px; flex-wrap: wrap; border-top: 1px solid var(--line); font-size: 13px; }
.start-foot a { color: var(--dim); }

/* ------------------------------------------------------------------------------------------------- rail + side */
.rail { display: flex; flex-direction: column; gap: 4px; padding: 8px 6px; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; }
.rail-btn { display: grid; justify-items: center; gap: 3px; padding: 9px 2px 7px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font-size: 11px; }
.rail-btn:hover { color: var(--text); background: rgba(255, 255, 255, .05); }
.rail-btn.on { color: var(--accent-text); background: var(--accent-soft); }
.side { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding: 0 14px 24px; min-width: 0; }
.side-head { position: sticky; top: 0; z-index: 2; background: var(--panel); padding: 14px 0 8px; }
.side-head h2 { margin: 0; font-size: 16px; color: var(--head); }
.side-head p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.side-sub { margin: 14px 0 8px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.side-actions { margin: 6px 0 4px; }
.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tpl-card { display: grid; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-2); text-align: left; font-size: 12.5px; color: var(--dim); }
.tpl-card:hover { border-color: var(--accent-line); color: var(--text); }
.tpl-thumb { width: 100%; height: auto; border-radius: 5px; background: #23262c; display: block; }
.custom-size { display: flex; align-items: center; gap: 6px; margin: 10px 0 4px; font-size: 13px; color: var(--dim); }
.custom-size .num { width: 72px; }
.size-group { margin-bottom: 4px; }
.size-row { display: flex; align-items: center; gap: 2px; border-radius: var(--r-sm); }
.size-row:hover { background: rgba(255, 255, 255, .04); }
.size-row.on .size-main { color: var(--accent-text); }
.size-main { flex: 1 1 auto; display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 8px; padding: 6px 4px; border: 0; background: none; text-align: left; min-width: 0; color: var(--text); }
.size-ic { display: grid; place-items: center; width: 32px; height: 28px; }
.size-ic i { display: block; border: 1.5px solid var(--muted); border-radius: 2px; }
.size-main:hover .size-ic i { border-color: var(--accent); }
.size-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.size-dim { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.img-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.img-card { display: grid; gap: 4px; padding: 5px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel-2); font-size: 12px; color: var(--dim); text-align: left; }
.img-card span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-card:hover { border-color: var(--accent-line); }
.img-thumb { width: 100%; height: auto; display: block; background: repeating-conic-gradient(#2a2d33 0 25%, #33363d 0 50%) 0 0 / 12px 12px; border-radius: 4px; }
.style-grid { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 6px; }
.style-card { display: grid; grid-template-columns: 1fr; gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-2); font-size: 12px; color: var(--muted); text-align: left; }
.style-card:hover { border-color: var(--accent-line); color: var(--text); }
.style-thumb { width: 100%; height: auto; border-radius: 6px; display: block; }
.el-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.el-card { aspect-ratio: 1; padding: 4px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel-2); display: grid; place-items: center; }
.el-card:hover { border-color: var(--accent-line); background: var(--panel-3); }
.el-thumb { width: 100%; height: 100%; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji { aspect-ratio: 1; border: 0; background: transparent; border-radius: 6px; font-size: 22px; line-height: 1; padding: 0; font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; }
.emoji:hover { background: rgba(255, 255, 255, .08); }
.bg-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.bg-sw { aspect-ratio: 1; border: 1px solid var(--line-2); border-radius: 7px; background: var(--c); padding: 0; }
.bg-sw:hover { outline: 2px solid var(--accent); outline-offset: 1px; }
.pat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pat-card { display: grid; gap: 4px; padding: 5px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel-2); font-size: 12px; color: var(--dim); text-align: left; }
.pat-card:hover { border-color: var(--accent-line); }
.pat-thumb { width: 100%; height: auto; border-radius: 4px; display: block; }

/* ------------------------------------------------------------------------------------------------- center */
.center { position: relative; display: grid; grid-template-rows: minmax(0, 1fr) var(--pages-h); min-width: 0; min-height: 0; background: #17181b; }
.stage-host { position: relative; overflow: hidden; min-height: 0; background: radial-gradient(ellipse at 50% 40%, #202227, #141518 70%); touch-action: none; }
.stage-view, .stage-over { position: absolute; inset: 0; display: block; }
.stage-over { outline: none; }
.stage-over[data-tool="crop"] { cursor: grab; }
.stage-over[data-tool="brush"] { cursor: none; }
.stage-over[data-tool="pick"] { cursor: crosshair; }
.stage-empty { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: none; justify-items: center; gap: 6px; padding: 18px 26px; border-radius: 14px; background: rgba(10, 10, 10, .55); color: var(--dim); text-align: center; pointer-events: none; z-index: 3; }
.stage-empty.on { display: grid; }
.stage-empty .ic { color: var(--accent); }
.stage-empty b { color: var(--head); font-size: 16px; }
.stage-empty span { font-size: 13px; }
.tool-hint { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); display: none; align-items: center; gap: 10px; padding: 7px 8px 7px 14px; border: 1px solid var(--line-2); border-radius: 999px; background: rgba(14, 15, 17, .94); box-shadow: var(--shadow); font-size: 13px; z-index: 5; max-width: calc(100% - 24px); }
.tool-hint.on { display: flex; }
.tool-hint { width: max-content; }
.tool-hint span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tool-hint .ic { color: var(--accent-text); }
.pages { display: flex; align-items: center; gap: 8px; padding: 8px 12px; overflow-x: auto; border-top: 1px solid var(--line); background: var(--panel); }
.page-card { flex: none; display: grid; grid-template-rows: 50px auto auto; justify-items: center; gap: 1px; min-width: 76px; max-width: 130px; padding: 4px 8px 4px; border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; color: var(--dim); }
.page-card:hover { background: rgba(255, 255, 255, .04); }
.page-card.on { border-color: var(--accent-line); background: var(--accent-soft); color: var(--text); }
.page-frame { display: grid; place-items: center; height: 50px; }
.page-thumb { display: block; box-shadow: 0 0 0 1px rgba(255, 255, 255, .14); background: #2a2d33; }
.page-name { font-size: 11.5px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-card small { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.page-add { flex: none; display: grid; justify-items: center; gap: 2px; padding: 8px 12px; border: 1px dashed var(--line-2); border-radius: var(--r-sm); background: transparent; color: var(--muted); font-size: 12px; }
.page-add:hover { color: var(--accent-text); border-color: var(--accent-line); }

.text-edit { position: absolute; z-index: 8; min-height: 44px; max-height: 40%; padding: 9px 11px; border: 1px solid var(--accent); border-radius: var(--r-sm); background: rgba(10, 10, 10, .96); color: #fff; font: 15px/1.4 var(--font); resize: vertical; box-shadow: var(--shadow); outline: none; }
.text-edit-hint { position: absolute; z-index: 8; font-size: 11.5px; color: var(--muted); background: rgba(10, 10, 10, .85); padding: 2px 8px; border-radius: 5px; white-space: nowrap; }

/* ------------------------------------------------------------------------------------------------- right */
.right { display: grid; grid-template-rows: 44px minmax(0, 1fr); background: var(--panel); border-left: 1px solid var(--line); min-width: 0; min-height: 0; }
.rtabs { display: flex; align-items: stretch; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--line); }
.rtab { border: 0; background: none; padding: 0 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.rtab:hover { color: var(--text); }
.rtab.on { color: var(--head); border-bottom-color: var(--accent); }
.rtabs .btn { margin-left: auto; align-self: center; }
.inspector, .layers-host { overflow-y: auto; min-height: 0; padding: 0 0 30px; }
.layers-host { display: none; }
.tab-layers .inspector { display: none; }
.tab-layers .layers-host { display: block; }

.ins-head { padding: 12px 14px 8px; border-bottom: 1px solid var(--line); }
.ins-title { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--head); }
.ins-title > .ic { color: var(--accent-text); }
.ins-sub { margin-top: 3px; color: var(--muted); font-size: 12px; }
.ins-name { flex: 1 1 auto; min-width: 0; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; color: var(--head); font-weight: 600; }
.ins-name:hover { border-color: var(--line-2); }
.ins-name:focus { border-color: var(--accent-line); outline: none; background: var(--well); }
.ins-note { display: flex; gap: 7px; align-items: flex-start; margin: 10px 14px 0; padding: 8px 10px; border-radius: var(--r-sm); background: rgba(255, 255, 255, .04); color: var(--dim); font-size: 12.5px; }
.ins-note .ic { margin-top: 2px; color: var(--accent-text); }
.ins-empty { color: var(--muted); font-size: 13px; padding: 16px 14px; margin: 0; }
.hint { color: var(--muted); font-size: 12px; margin: 2px 0 0; line-height: 1.4; }

.sec { border-bottom: 1px solid var(--line); }
.sec-top { display: flex; align-items: center; }
.sec-head { flex: 1; display: flex; align-items: center; gap: 6px; padding: 11px 14px; border: 0; background: none; text-align: left; font-weight: 700; font-size: 12.5px; letter-spacing: .5px; text-transform: uppercase; color: var(--dim); }
.sec-head:hover { color: var(--text); }
.sec-head .ic { transition: transform .15s; transform: rotate(-90deg); }
.sec.open .sec-head .ic { transform: none; }
.sec-actions { padding-right: 8px; }
.sec-body { display: none; padding: 0 14px 14px; }
.sec.open .sec-body { display: grid; gap: 10px; }
.sub { display: grid; gap: 10px; padding: 10px 0 4px 12px; border-left: 2px solid var(--line-2); margin-left: 2px; }
.sub-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin-top: 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.row3 { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.icon-row { display: flex; flex-wrap: wrap; gap: 2px; }
.icon-row .btn { padding: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--dim); }
.chip:hover { border-color: var(--accent-line); color: var(--text); }
.stroke-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: end; }
.font-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--well); font-size: 16px; text-align: left; }
.font-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.font-btn:hover { border-color: rgba(255, 255, 255, .22); }

/* ------------------------------------------------------------------------------------------------- controls */
.ctl { display: grid; gap: 5px; min-width: 0; }
.ctl-label, .tg-label, .nf-label { font-size: 12.5px; color: var(--dim); user-select: none; }
.slider-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; --p: 50%; margin: 0; }
.range::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--accent) var(--p), rgba(255, 255, 255, .14) var(--p)); }
.range::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .14); }
.range::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); }
.range::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); }
.num-wrap { display: flex; align-items: center; gap: 3px; }
.num { width: 62px; padding: 4px 6px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--well); font-variant-numeric: tabular-nums; text-align: right; -moz-appearance: textfield; }
.num::-webkit-inner-spin-button { opacity: .5; }
.num:focus, .txt:focus, .sel:focus { border-color: var(--accent-line); outline: none; }
.unit { color: var(--muted); font-size: 12px; min-width: 14px; }
.numfield { grid-template-columns: auto 1fr auto; align-items: center; gap: 6px; }
.numfield .num { width: 100%; }
.nf-label { min-width: 14px; }
.toggle { grid-template-columns: 1fr auto; align-items: center; cursor: pointer; }
.switch { position: relative; width: 36px; height: 20px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch .knob { position: absolute; inset: 0; border-radius: 999px; background: rgba(255, 255, 255, .16); transition: background .15s; }
.switch .knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .knob { background: var(--accent); }
.switch input:checked + .knob::after { transform: translateX(16px); }
.switch input:focus-visible + .knob { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg { display: flex; flex-wrap: wrap; gap: 2px; padding: 2px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--well); }
.seg-btn { flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 28px; padding: 3px 8px; border: 0; border-radius: 5px; background: transparent; color: var(--dim); font-size: 12.5px; white-space: nowrap; }
.seg-btn:hover { color: var(--text); background: rgba(255, 255, 255, .05); }
.seg-btn.on { background: var(--panel-3); color: var(--head); box-shadow: inset 0 0 0 1px var(--accent-line); }
.sel, .txt { width: 100%; padding: 6px 9px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--well); }
.sel option, .sel optgroup { background: #16171a; color: var(--text); }
textarea.txt { resize: vertical; min-height: 64px; line-height: 1.4; }
.color { grid-template-columns: 1fr auto; align-items: center; }
.color.bare { display: inline-grid; }
.swatch { width: 44px; height: 28px; border-radius: 6px; border: 1px solid var(--line-2); padding: 0; background: linear-gradient(var(--c), var(--c)), repeating-conic-gradient(#888 0 25%, #ccc 0 50%) 0 0 / 10px 10px; }
.swatch.paint { width: 60px; background: var(--c), repeating-conic-gradient(#888 0 25%, #ccc 0 50%) 0 0 / 10px 10px; }
.swatch:hover { border-color: rgba(255, 255, 255, .35); }

/* ------------------------------------------------------------------------------------------------- popovers */
.popover { position: fixed; z-index: 60; display: grid; gap: 10px; width: 260px; padding: 12px; border: 1px solid var(--line-2); border-radius: var(--r); background: #141518; box-shadow: var(--shadow); }
.cp-sv { width: 100%; height: auto; aspect-ratio: 232 / 150; border-radius: 6px; cursor: crosshair; touch-action: none; display: block; }
.pe .cp-sv { aspect-ratio: 232 / 120; }
.cp-bars { display: grid; gap: 8px; }
.cp-hue, .cp-alpha { -webkit-appearance: none; appearance: none; width: 100%; height: 14px; border-radius: 7px; margin: 0; }
.cp-hue { background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.cp-alpha { background: linear-gradient(90deg, transparent, var(--c, #fff)), repeating-conic-gradient(#777 0 25%, #bbb 0 50%) 0 0 / 10px 10px; }
.cp-hue::-webkit-slider-thumb, .cp-alpha::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid #111; box-shadow: 0 0 0 1px #fff; }
.cp-hue::-moz-range-thumb, .cp-alpha::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid #111; }
.cp-row { display: flex; gap: 8px; align-items: center; }
.cp-prev { width: 34px; height: 30px; flex: none; border-radius: 6px; border: 1px solid var(--line-2); background: linear-gradient(var(--c), var(--c)), repeating-conic-gradient(#888 0 25%, #ccc 0 50%) 0 0 / 10px 10px; }
.cp-hex { flex: 1; min-width: 0; padding: 5px 8px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--well); font-family: var(--mono); font-size: 13px; text-transform: uppercase; }
.cp-drop { padding: 5px 8px; min-height: 30px; }
.cp-group { display: grid; gap: 5px; }
.cp-gtitle { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.cp-sw { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; }
.sw { aspect-ratio: 1; border-radius: 5px; border: 1px solid rgba(255, 255, 255, .16); padding: 0; background: linear-gradient(var(--c), var(--c)), repeating-conic-gradient(#888 0 25%, #ccc 0 50%) 0 0 / 8px 8px; }
.sw.grad { aspect-ratio: 1.4; }
.sw:hover { outline: 2px solid #fff; outline-offset: 1px; }
.pe-barwrap { display: grid; grid-template-columns: 1fr auto auto; gap: 4px; align-items: center; }
.pe-bar { position: relative; height: 26px; margin: 0 7px; }
.pe-track { position: absolute; inset: 4px 0; border-radius: 5px; cursor: copy; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2); }
.pe-stop { position: absolute; top: 0; width: 14px; height: 26px; margin-left: -7px; border-radius: 5px; border: 2px solid #fff; background: linear-gradient(var(--c), var(--c)), #888; box-shadow: 0 0 0 1px #000; padding: 0; cursor: ew-resize; touch-action: none; }
.pe-stop.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.pe-solid { display: grid; gap: 8px; }
.fontpop { width: 300px; }
.font-list { max-height: 320px; overflow-y: auto; display: grid; gap: 1px; margin: 0 -6px; }
.font-item { border: 0; background: none; padding: 6px 10px; text-align: left; font-size: 17px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.font-item:hover { background: rgba(255, 255, 255, .06); }
.font-item.on { color: var(--accent-text); background: var(--accent-soft); }

.menu { position: fixed; z-index: 70; min-width: 220px; padding: 5px; border: 1px solid var(--line-2); border-radius: var(--r); background: #141518; box-shadow: var(--shadow); }
.menu-item { display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 9px; width: 100%; padding: 7px 10px; border: 0; border-radius: 6px; background: none; text-align: left; font-size: 13.5px; }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: rgba(255, 255, 255, .07); outline: none; }
.menu-item:disabled { opacity: .4; cursor: default; }
.menu-item .ic { color: var(--dim); }
.menu-item.danger { color: var(--danger-text); }
.menu-item.danger .ic { color: var(--danger-text); }
.menu-key { color: var(--muted); font-size: 12px; }
.menu-sep { height: 1px; margin: 4px 6px; background: var(--line); }

/* ------------------------------------------------------------------------------------------------- layers */
.layer-list { display: grid; gap: 1px; padding: 6px; }
.layer-row { display: grid; grid-template-columns: 40px 1fr auto auto auto; align-items: center; gap: 8px; padding: 4px 4px 4px 6px; border-radius: var(--r-sm); border: 1px solid transparent; cursor: pointer; user-select: none; }
.layer-row:hover { background: rgba(255, 255, 255, .04); }
.layer-row.on { background: var(--accent-soft); border-color: var(--accent-line); }
.layer-row.hidden .layer-name, .layer-row.hidden .layer-thumb { opacity: .4; }
.layer-row.dragging { opacity: .4; }
.layer-row.drop-above { box-shadow: inset 0 2px 0 var(--accent); }
.layer-row.drop-below { box-shadow: inset 0 -2px 0 var(--accent); }
.layer-thumb { width: 40px; height: 28px; border-radius: 4px; background: repeating-conic-gradient(#2a2d33 0 25%, #33363d 0 50%) 0 0 / 8px 8px; }
.layer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.layer-badge { color: var(--muted); display: inline-flex; }
.layer-rename { width: 100%; padding: 2px 6px; border: 1px solid var(--accent-line); border-radius: 5px; background: var(--well); }

/* ------------------------------------------------------------------------------------------------- modals */
.modal-back { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .62); }
.modal { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; width: min(480px, 100%); max-height: calc(100dvh - 32px); border: 1px solid var(--line-2); border-radius: 14px; background: #121316; box-shadow: var(--shadow); }
.modal.wide { width: min(940px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; color: var(--head); }
.modal-body { overflow-y: auto; padding: 16px 20px; display: grid; gap: 14px; align-content: start; }
.modal-body p { margin: 0; }
.modal-lead { color: var(--dim); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.small { font-size: 12px; color: var(--muted); }
.fmt-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px 16px; }
.fmt-group { margin: 0; padding: 0; border: 0; min-width: 0; }
.fmt-group legend { padding: 0; margin-bottom: 4px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.fmt-item { display: grid; grid-template-columns: auto 34px 1fr; align-items: center; gap: 8px; padding: 5px 6px; border-radius: var(--r-sm); cursor: pointer; }
.fmt-item:hover { background: rgba(255, 255, 255, .04); }
.fmt-item input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.fmt-item.custom { grid-template-columns: auto 1fr 80px auto 80px; padding: 8px; border: 1px solid var(--line); background: var(--panel); }
.fmt-ic { display: grid; place-items: center; width: 34px; height: 32px; }
.fmt-ic i { display: block; border: 1.5px solid var(--muted); border-radius: 2px; }
.fmt-item input:checked ~ .fmt-ic i { border-color: var(--accent); background: var(--accent-soft); }
.fmt-text { display: grid; min-width: 0; }
.fmt-text b { font-weight: 500; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fmt-text small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.qc-top { display: grid; grid-template-columns: 260px 1fr; gap: 18px; align-items: start; }
.qc-prev { width: 260px; height: auto; border-radius: 8px; background: repeating-conic-gradient(#2a2d33 0 25%, #33363d 0 50%) 0 0 / 12px 12px; }
.qc-info { display: grid; gap: 8px; }
.qc-info b { color: var(--head); overflow: hidden; text-overflow: ellipsis; }
.qc-info > span { color: var(--muted); font-size: 13px; }
.qc-info p { color: var(--dim); font-size: 13px; }
.qc-bar { display: flex; align-items: center; gap: 10px; padding-top: 4px; border-top: 1px solid var(--line); }
.qc-count { color: var(--accent-text); font-size: 13px; margin-right: auto; }
.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px 24px; }
.key-group h3 { margin: 0 0 6px; font-size: 13px; color: var(--accent-text); text-transform: uppercase; letter-spacing: .7px; }
.key-group dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 0; font-size: 13px; }
.key-group dt { white-space: nowrap; }
.key-group dd { margin: 0; color: var(--dim); }
kbd { display: inline-block; padding: 1px 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; background: var(--panel-2); font: 12px var(--mono); }
.about-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.about-list li { display: grid; grid-template-columns: 18px 1fr; gap: 9px; color: var(--dim); font-size: 13.5px; }
.about-list .ic { color: var(--accent-text); margin-top: 2px; }

.exp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; align-items: start; }
.exp-grid > .ctl:first-child, .exp-pages { grid-column: 1 / -1; }
.exp-pages { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.exp-pages:empty { display: none; }
.exp-page { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }
.exp-page small { color: var(--muted); }
.exp-page input { accent-color: var(--accent); }
.lim { gap: 2px; }
.exp-limit { color: var(--muted); font-size: 12px; }
.exp-result:empty { display: none; }
.exp-result { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 8px; }
.exp-status { color: var(--accent-text); font-weight: 600; }
.exp-files { display: grid; gap: 4px; font-size: 12.5px; }
.exp-file { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 6px 8px; border-radius: 6px; background: var(--panel); color: var(--dim); font-variant-numeric: tabular-nums; }
.exp-file .n { color: var(--text); font-family: var(--mono); font-size: 12px; margin-right: auto; overflow-wrap: anywhere; }
.exp-file.warn { box-shadow: inset 2px 0 0 var(--warn); }
.exp-file .w { display: inline-flex; gap: 4px; align-items: center; color: var(--warn); }

/* ------------------------------------------------------------------------------------------------- preview */
.pv .modal-body { gap: 10px; }
.modal.pv { width: min(1180px, 100%); }
.pv-tools { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.pv-tools .seg { flex: 0 1 auto; }
.pv-field { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--dim); }
.pv-field .txt { width: 220px; padding: 4px 8px; }
.pv-field .range { width: 120px; }
.pv-field .sel { width: auto; padding: 4px 8px; }
.pv-stage { border-radius: 12px; padding: 22px; min-height: 360px; overflow: auto; }
.pv-stage.dark { background: #0f0f0f; color: #f1f1f1; }
.pv-stage.light { background: #ffffff; color: #0f0f0f; }
.pv-feed { display: flex; flex-wrap: wrap; gap: 26px 16px; }
.pv-card { display: grid; gap: 10px; align-content: start; }
.pv-thumb { position: relative; border-radius: 10px; overflow: hidden; background: #333; flex: none; }
.pv-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pv-thumb.blur img { filter: blur(3px); }
.pv-thumb.gray img { filter: grayscale(1); }
.pv-fake { position: absolute; inset: 0; }
.pv-thumb.mine { box-shadow: 0 0 0 2px var(--accent); }
.pv-dur { position: absolute; right: 5px; bottom: 5px; padding: 1px 4px; border-radius: 4px; background: rgba(0, 0, 0, .8); color: #fff; font-size: 12px; font-weight: 600; }
.pv-meta { display: grid; grid-template-columns: 36px 1fr; gap: 10px; }
.pv-meta > div, .pv-srow > div { display: grid; gap: 3px; align-content: start; min-width: 0; }
.pv-av { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); font-weight: 700; }
.pv-title { font-size: 15px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pv-stage small { font-size: 12.5px; opacity: .65; }
.pv-lines { display: grid; gap: 6px; padding-top: 4px; }
.pv-lines i { display: block; height: 10px; border-radius: 4px; background: currentColor; opacity: .14; }
.pv-side { display: grid; gap: 10px; max-width: 420px; }
.pv-srow { display: grid; grid-template-columns: 168px 1fr; gap: 10px; }
.pv-srow .pv-title { font-size: 13.5px; }
.pv-phone { width: 380px; max-width: 100%; margin: 0 auto; border-radius: 14px; padding: 0 0 12px; background: inherit; box-shadow: 0 0 0 1px rgba(127, 127, 127, .25); overflow: hidden; }
.pv-post-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.pv-post-head .pv-av { width: 30px; height: 30px; font-size: 13px; }
.pv-dots { margin-left: auto; opacity: .6; }
.pv-phone .pv-thumb { width: 100% !important; border-radius: 0; }
.pv-actions { display: flex; gap: 14px; padding: 10px 12px 4px; }
.pv-phone .pv-caption { margin: 2px 12px 0; font-size: 13.5px; }
.pv-phone .pv-thumb.mine { box-shadow: none; }
.pv-center { display: grid; justify-items: center; gap: 12px; }
.pv-story { position: relative; border-radius: 18px; overflow: hidden; background: #000; color: #fff; box-shadow: 0 0 0 1px rgba(127, 127, 127, .3); }
.pv-story img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pv-story img.blur { filter: blur(3px); }
.pv-story img.gray { filter: grayscale(1); }
.pv-story-top { position: absolute; left: 0; right: 0; top: 0; padding: 10px 10px 28px; background: linear-gradient(rgba(0, 0, 0, .45), transparent); }
.pv-bars { display: flex; gap: 3px; }
.pv-bars i { flex: 1; height: 2.5px; border-radius: 2px; background: rgba(255, 255, 255, .4); }
.pv-bars i.on { background: #fff; }
.pv-story-user { display: flex; align-items: center; gap: 8px; margin-top: 9px; font-size: 13px; }
.pv-story-user .pv-av { width: 28px; height: 28px; font-size: 12px; }
.pv-story-side { position: absolute; right: 10px; bottom: 90px; display: grid; gap: 18px; }
.pv-story-bottom { position: absolute; left: 10px; right: 10px; bottom: 12px; display: flex; align-items: center; gap: 10px; }
.pv-story-bottom span { flex: 1; padding: 9px 14px; border: 1px solid rgba(255, 255, 255, .6); border-radius: 999px; font-size: 13px; }
.pv-compare { display: flex; flex-wrap: wrap; gap: 18px; align-items: start; }
.pv-compare figure { margin: 0; display: grid; gap: 6px; }
.pv-compare figcaption { font-size: 12.5px; opacity: .7; }

/* ------------------------------------------------------------------------------------------------- toasts, drop */
.toasts { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: min(560px, calc(100% - 24px)); }
.toast { padding: 9px 16px; border-radius: var(--r); background: #1b1d21; border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: 13.5px; transition: opacity .3s, transform .3s; animation: toastIn .2s ease-out; text-align: center; }
.toast.ok { border-color: rgba(47, 207, 124, .5); }
.toast.warn { border-color: rgba(255, 210, 63, .5); }
.toast.error { border-color: rgba(255, 59, 107, .6); color: var(--danger-text); }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
.drop-overlay { position: fixed; inset: 0; z-index: 40; display: none; place-items: center; background: rgba(255, 87, 7, .1); border: 3px dashed var(--accent); pointer-events: none; }
.drop-overlay > div { display: grid; justify-items: center; gap: 6px; padding: 24px 32px; border-radius: 14px; background: rgba(14, 15, 17, .94); }
.drop-overlay .ic { color: var(--accent); }
.drop-overlay b { font-size: 18px; color: var(--head); }
.drop-overlay span { color: var(--dim); font-size: 13px; }
.mode-editor.dropping .drop-overlay { display: grid; }

/* ------------------------------------------------------------------------------------------------- responsive */
@media (max-width: 1240px) {
  :root { --side-w: 270px; --right-w: 296px; }
  .previewB-label { display: none; }
}
@media (max-width: 1100px) {
  .only-narrow { display: inline-flex !important; }
  .mode-editor .editor-view, .mode-editor.side-closed .editor-view { grid-template-columns: var(--rail-w) var(--side-w) minmax(0, 1fr); }
  .right { position: fixed; top: var(--top-h); right: 0; bottom: var(--status-h); width: min(340px, 92vw); z-index: 30; transform: translateX(105%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .right-open .right { transform: none; }
  .top .btn > span { display: none; }
  .top .btn.accent > span { display: inline; }
}
@media (max-width: 860px) {
  :root { --rail-w: 62px; }
  .rail { padding: 8px 4px; }
  .rail-btn { font-size: 9.5px; letter-spacing: -.1px; }
  .mode-editor .editor-view, .mode-editor.side-closed .editor-view { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  .side { position: fixed; top: var(--top-h); left: var(--rail-w); bottom: var(--status-h); width: min(320px, calc(100vw - var(--rail-w) - 10px)); z-index: 29; transform: translateX(-120%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .side-open .side { transform: none; }
  .mode-editor.side-closed .side { display: block; }
  .exit span, .brand span { display: none; }
  .proj-name { width: 120px; }
  .zoom .btn:not(:last-child) { display: none; }
  .qc-top { grid-template-columns: 1fr; }
  .qc-prev { width: 100%; max-width: 320px; }
  .exp-grid { grid-template-columns: 1fr; }
  .status .st-save { display: none; }
}
@media (max-width: 560px) {
  :root { --pages-h: 74px; --top-h: 50px; }
  .top { gap: 4px; padding: 0 6px; }
  .proj-name, .zoom-label { display: none; }
  .top .btn { padding: 6px; }
  .top .btn.accent > span { display: none; }
  .start-hero { padding: 16px 12px 6px; }
  .start-drop { padding: 26px 14px 20px; }
  .start-drop h2 { font-size: 21px; }
  .start-sec { padding: 12px; }
  .fmt-item.custom { grid-template-columns: auto 1fr 64px auto 64px; }
  .page-card { min-width: 64px; }
  .status .st-size { display: none; }
}
@media (max-width: 430px) {
  .zoom { display: none; }
  .top-editor { gap: 2px; }
  .exit { padding: 6px 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
