:root {
  --bg: #141416; --bg-2: #1a1a1e; --card: #26262a; --card-2: #34343a; --line: rgba(255,255,255,.1);
  --tx: #fff; --tx-2: #c7c7cf; --tx-3: #a8a8b0; --tx-4: #9a9aa2; --tx-off: #5e5e66;
  --accent: #2997ff; --accent-soft: rgba(41,151,255,.12); --accent-fill: #0071e3;
  --cta: #8fcbff; --cta-tx: #10314f; --purple: linear-gradient(135deg,#b07dff,#6a4dff);
  --green: #5fe3b4; --pink: #ff9fb4; --amber: #ffc24d; --red: #ff6b6b;
  --font: system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  --r-pill: 9999px; --r-xs: 6px; --r-sm: 10px; --r-md: 14px; --r-lg: 20px;
  --panel-w: 340px; --top-h: 52px; --film-h: 118px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--tx); font: 13px/1.4 var(--font); overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
button:disabled { opacity: .4; cursor: default; }
.hidden { display: none !important; }
.spacer { flex: 1; }
svg.i { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[data-icon] { display: inline-flex; align-items: center; justify-content: center; }

/* Topbar */
.topbar { height: var(--top-h); display: flex; align-items: center; gap: 12px; padding: 0 14px; border-bottom: 1px solid var(--line); background: var(--bg); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; margin-right: 6px; }
.brand img { width: 24px; height: 24px; border-radius: 6px; }
.tb-group { display: flex; gap: 2px; }
.icon-btn { width: 34px; height: 34px; border-radius: var(--r-pill); color: var(--tx-2); display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover:not(:disabled) { background: var(--card); color: var(--tx); }
.icon-btn.sm { width: 28px; height: 28px; }
.seg { display: flex; background: var(--card); border-radius: var(--r-pill); padding: 3px; }
.seg button { padding: 5px 14px; border-radius: var(--r-pill); color: var(--tx-3); font-weight: 600; }
.seg button.on { background: #fff; color: #111; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--r-pill); font-weight: 600; white-space: nowrap; }
.btn.primary { background: var(--accent-fill); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #0a84ff; }
.btn.cta { background: var(--cta); color: var(--cta-tx); }
.btn.big { height: 50px; padding: 0 30px; font-size: 16px; }
.btn.soft { background: var(--card); color: var(--tx); }
.btn.soft:hover:not(:disabled) { background: var(--card-2); }
.btn.ghost { color: var(--tx-2); }
.btn.ghost:hover { background: var(--card); }
.btn.outline { border: 1px solid var(--accent); color: var(--accent); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.pill-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px 0 8px; border-radius: var(--r-pill); background: var(--card); color: var(--tx-2); font-weight: 600; font-size: 12px; }
.pill-btn:hover { background: var(--card-2); }
.ai-status.on { color: var(--green); }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border-radius: var(--r-pill); color: var(--tx-2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip:hover { background: var(--card); color: var(--tx); }
.chip.on { background: var(--accent-soft); color: var(--accent); }
.chip.accent { background: var(--accent-fill); color: #fff; }
.chip b { font-weight: 700; color: var(--amber); }
.chip svg.i { width: 14px; height: 14px; }

/* Welcome */
.welcome { height: calc(100% - var(--top-h)); overflow: auto; display: flex; flex-direction: column; align-items: center; padding: 40px 16px; gap: 16px;
  background: radial-gradient(1200px 600px at 10% 0%, rgba(41,151,255,.08), transparent), radial-gradient(900px 500px at 100% 100%, rgba(122,77,255,.1), transparent); }
.dropzone { width: min(720px, 100%); border: 2px dashed rgba(255,255,255,.22); border-radius: var(--r-lg); padding: 44px 24px 30px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; background: rgba(20,20,22,.6); transition: .15s; }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon { width: 64px; height: 64px; border-radius: 16px; background: var(--purple); color: #fff; }
.dz-icon svg.i { width: 28px; height: 28px; }
.dropzone h1 { margin: 8px 0 0; font-size: 32px; }
.dropzone p { margin: 0; color: var(--tx-3); font-size: 15px; max-width: 460px; }
.formats { color: var(--tx-2); font-size: 12px; margin-top: 6px; }
.formats.sub { color: var(--tx-4); font-size: 11px; margin: 0; }
.privacy { display: inline-flex; gap: 8px; align-items: center; padding: 8px 14px; border-radius: var(--r-sm); background: rgba(95,227,180,.1); border: 1px solid rgba(95,227,180,.35); color: var(--green); font-size: 12px; max-width: 560px; text-align: left; }
.welcome-cards { display: flex; gap: 10px; }
.wcard { display: flex; gap: 8px; align-items: center; padding: 12px 18px; border-radius: var(--r-pill); border: 1px solid var(--line); color: var(--tx-3); }
.wcard b { color: var(--tx); }
.wcard:hover { background: var(--card); }
#fileInput, #folderInput { display: none; }

/* Editor layout */
.editor { height: calc(100% - var(--top-h)); display: flex; }
.stage-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.stage { flex: 1; min-height: 0; position: relative; }
.viewer { position: absolute; inset: 0; overflow: auto; display: flex; padding: 22px; }
.canvas-box { position: relative; margin: auto; flex: none; line-height: 0; box-shadow: 0 8px 40px rgba(0,0,0,.45); }
#glCanvas { display: block; }
.photo-label { position: absolute; z-index: 3; top: 8px; left: 12px; padding: 4px 10px; border-radius: var(--r-xs); background: rgba(0,0,0,.55); font-size: 11px; color: var(--tx-2); font-weight: 600; pointer-events: none; }
.mask-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.split-line { position: absolute; top: 0; bottom: 0; width: 0; left: 50%; cursor: ew-resize; touch-action: none; }
.split-line i { position: absolute; top: 0; bottom: 0; left: -1px; width: 2px; background: #fff; box-shadow: 0 0 6px rgba(0,0,0,.6); }
.split-line::after { content: ""; position: absolute; top: 50%; left: -16px; width: 32px; height: 32px; margin-top: -16px; border-radius: 50%; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.5); }
.split-line span { position: absolute; top: 10px; line-height: 1; font-size: 11px; font-weight: 700; padding: 4px 8px; border-radius: var(--r-xs); background: rgba(0,0,0,.6); white-space: nowrap; }
.split-line span:first-child { right: 10px; } .split-line span:nth-child(3) { left: 10px; }
.busy { position: absolute; inset: 0; z-index: 10; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; background: rgba(10,10,12,.6); backdrop-filter: blur(3px); font-weight: 600; }
.spin { width: 38px; height: 38px; border-radius: 50%; border: 3px solid rgba(255,255,255,.15); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; flex-wrap: wrap; }
.zoom { display: flex; align-items: center; gap: 2px; color: var(--tx-3); font-size: 12px; }
.zoom #zoomLabel { min-width: 42px; text-align: center; }
.stars { display: flex; gap: 2px; }
.stars button { color: var(--tx-off); font-size: 18px; line-height: 1; padding: 2px; }
.stars button.on { color: var(--amber); }
.stars .flag { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: var(--r-pill); margin-left: 6px; }
.stars .flag.pick { background: rgba(95,227,180,.15); color: var(--green); }
.stars .flag.rej { background: rgba(255,107,107,.15); color: var(--red); }

/* Filmstrip */
.filmbar { border-top: 1px solid var(--line); background: var(--bg-2); }
.cull-bar { display: flex; align-items: center; gap: 4px; padding: 6px 10px 0; overflow-x: auto; }
.film-info { color: var(--tx-4); font-size: 11px; padding-left: 8px; white-space: nowrap; }
.filmstrip { display: flex; gap: 8px; padding: 8px 12px 10px; overflow-x: auto; height: 96px; }
.thumb { position: relative; flex: none; height: 76px; border-radius: 8px; overflow: hidden; outline: 2px solid transparent; outline-offset: 1px; background: var(--card); cursor: pointer; }
.thumb canvas, .thumb img { height: 100%; display: block; }
.thumb.sel { outline-color: rgba(41,151,255,.55); }
.thumb.cur { outline-color: var(--accent); }
.thumb.rej canvas { opacity: .35; }
.thumb .badges { position: absolute; left: 3px; bottom: 3px; display: flex; gap: 2px; flex-wrap: wrap; }
.thumb .bd { font-size: 9px; font-weight: 700; padding: 1px 4px; border-radius: 4px; background: rgba(0,0,0,.7); color: var(--amber); line-height: 1.3; }
.thumb .bd.ok { color: var(--green); } .thumb .bd.bad { color: var(--red); }
.thumb .tstar { position: absolute; right: 4px; top: 3px; font-size: 10px; color: var(--amber); text-shadow: 0 1px 2px #000; }
.thumb .edited { position: absolute; right: 4px; bottom: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.thumb .vc { position: absolute; left: 4px; top: 3px; font-size: 9px; font-weight: 700; color: #fff; background: var(--accent-fill); border-radius: 4px; padding: 0 4px; }

/* Panel */
.panel { width: var(--panel-w); flex: none; border-left: 1px solid var(--line); overflow-y: auto; overflow-x: hidden; padding: 10px 10px 30px; background: var(--bg); scrollbar-width: thin; }
.histo { position: relative; background: var(--bg-2); border-radius: var(--r-sm); padding: 6px 6px 2px; }
.histo canvas { width: 100%; height: 70px; display: block; }
.histo-labels { display: flex; justify-content: space-between; font-size: 9px; color: var(--tx-4); padding: 0 2px; }
.search { display: flex; align-items: center; gap: 8px; margin: 8px 0; padding: 0 12px; height: 34px; border-radius: var(--r-pill); background: var(--card); color: var(--tx-4); }
.search input { flex: 1; background: none; border: 0; outline: 0; font-size: 12px; }
.notice { border-radius: var(--r-sm); background: rgba(122,77,255,.12); border: 1px solid rgba(176,125,255,.3); padding: 8px 10px; margin-bottom: 8px; font-size: 12px; }
.notice b { display: flex; gap: 6px; align-items: center; color: #d6c2ff; margin-bottom: 4px; }
.notice .nrow { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 2px 0; color: var(--tx-2); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 6px 0; }
.row2 .btn { width: 100%; }
.hint { font-size: 11px; color: var(--tx-4); margin: 0 4px 8px; }
.block { border-radius: var(--r-md); background: var(--bg-2); padding: 10px; margin-bottom: 10px; }
.block-title { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 12px; margin-bottom: 8px; }
.block-title em, .looks-head em { font-style: normal; color: var(--tx-4); font-weight: 500; font-size: 11px; margin-left: auto; }
.types { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.types button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px; border-radius: var(--r-sm); background: var(--card); font-size: 10px; color: var(--tx-2); }
.types button:hover { background: var(--card-2); }
.types button.on { background: var(--accent-soft); color: var(--accent); }
.types svg.i { width: 15px; height: 15px; color: var(--amber); }
.looks-block { background: linear-gradient(180deg, rgba(106,77,255,.22), var(--bg-2) 60px); }
.looks-head { display: flex; align-items: center; gap: 6px; font-weight: 700; margin-bottom: 8px; }
.sub-title { font-size: 11px; color: var(--tx-3); display: flex; align-items: center; gap: 5px; margin-bottom: 6px; }
.looks { display: grid; grid-auto-flow: column; grid-auto-columns: 92px; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.look { display: flex; flex-direction: column; gap: 4px; text-align: center; font-size: 10px; color: var(--tx-3); }
.look canvas { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; outline: 2px solid transparent; background: var(--card); }
.look.on canvas { outline-color: var(--accent); }
.look.on { color: var(--accent); }
.look .lock { color: var(--amber); }

/* Sections (tools) */
.sec-cat { font-size: 12px; font-weight: 700; color: var(--tx-3); margin: 14px 4px 6px; }
.sec { border-radius: var(--r-md); margin-bottom: 2px; }
.sec-head { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-md); cursor: pointer; user-select: none; }
.sec-head:hover { background: var(--bg-2); }
.sec-head .ico { color: var(--amber); }
.sec-head b { flex: 1; font-weight: 600; }
.sec-head .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: none; }
.sec.changed .sec-head .dot { display: block; }
.sec-head .chev { color: var(--tx-4); transition: transform .15s; }
.sec.open { background: var(--bg-2); }
.sec.open .sec-head { background: rgba(255,194,77,.12); border-radius: var(--r-md) var(--r-md) 0 0; }
.sec.open .chev { transform: rotate(90deg); }
.sec-body { display: none; padding: 6px 12px 12px; }
.sec.open .sec-body { display: block; }
.sec-body .subhead { font-size: 11px; font-weight: 700; color: var(--tx-3); margin: 10px 0 2px; text-transform: uppercase; letter-spacing: .04em; }
.slider-row { padding: 4px 0; }
.slider-row .lbl { display: flex; justify-content: space-between; font-size: 12px; color: var(--tx-2); }
.slider-row .lbl input { width: 52px; text-align: right; background: none; border: 0; color: var(--tx-2); outline: 0; padding: 0; }
.slider-row .lbl input:focus { color: var(--accent); }
.slider-row .desc { font-size: 10.5px; color: var(--tx-4); }
body.simple .slider-row .desc { display: block; }
body:not(.simple) .slider-row .desc { display: none; }
.slider-row.changed .lbl span { color: var(--tx); font-weight: 600; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; margin: 2px 0; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: var(--track, var(--card-2)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #e8e8ee; margin-top: -5.5px; box-shadow: 0 1px 3px rgba(0,0,0,.5); }
input[type=range]::-moz-range-track { height: 3px; border-radius: 2px; background: var(--track, var(--card-2)); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #e8e8ee; }
.tabs { display: flex; gap: 2px; background: var(--card); padding: 2px; border-radius: var(--r-pill); margin: 4px 0 8px; }
.tabs button { flex: 1; padding: 4px 0; border-radius: var(--r-pill); font-size: 11px; color: var(--tx-3); font-weight: 600; }
.tabs button.on { background: var(--card-2); color: var(--tx); }
.curve-box { position: relative; }
.curve-box canvas { width: 100%; aspect-ratio: 1; display: block; border-radius: 8px; background: #101012; touch-action: none; cursor: crosshair; }
.curve-tip { font-size: 10.5px; color: var(--tx-4); margin-top: 4px; }
.hsl-dots { display: flex; gap: 4px; margin: 4px 0 6px; }
.hsl-dots button { width: 22px; height: 22px; border-radius: 50%; outline: 2px solid transparent; outline-offset: 2px; }
.hsl-dots button.on { outline-color: #fff; }
.sec-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.sec-note { font-size: 11px; color: var(--tx-4); margin-top: 6px; }

/* AI block */
.ai-block { background: linear-gradient(180deg, rgba(41,151,255,.14), var(--bg-2) 70px); }
.ai-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ai-tool { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 9px 10px; border-radius: var(--r-sm); background: var(--card); text-align: left; font-size: 11px; color: var(--tx-3); }
.ai-tool b { color: var(--tx); font-size: 12px; display: flex; align-items: center; gap: 5px; }
.ai-tool:hover { background: var(--card-2); }
.ai-tool .lk { position: absolute; top: 7px; right: 7px; color: var(--amber); }
body.ai-on .ai-tool .lk, body.ai-on .ai-feature .lk { display: none; }
.ai-feature .lk { color: var(--amber); }
.panel-foot { font-size: 10.5px; color: var(--tx-4); text-align: center; padding: 8px; }

/* Bars */
.brushbar { position: fixed; z-index: 20; left: 50%; top: calc(var(--top-h) + 10px); transform: translateX(calc(-50% - var(--panel-w) / 2)); display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 16px; background: rgba(38,38,42,.96); border: 1px solid var(--line); border-radius: var(--r-pill); box-shadow: 0 8px 30px rgba(0,0,0,.5); white-space: nowrap; }
.brushbar label { display: flex; align-items: center; gap: 6px; color: var(--tx-3); font-size: 12px; }
.brushbar input[type=range] { width: 110px; }
.brushbar select { background: var(--card-2); border: 0; border-radius: var(--r-pill); padding: 5px 10px; }
.crop-overlay { position: absolute; inset: 0; touch-action: none; }
.crop-rect { position: absolute; border: 1px solid rgba(255,255,255,.9); box-shadow: 0 0 0 9999px rgba(0,0,0,.55); cursor: move; }
.crop-rect::before, .crop-rect::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(to right, transparent 33.1%, rgba(255,255,255,.35) 33.3%, transparent 33.5%, transparent 66.5%, rgba(255,255,255,.35) 66.7%, transparent 66.9%); }
.crop-rect::after { background-image: linear-gradient(to bottom, transparent 33.1%, rgba(255,255,255,.35) 33.3%, transparent 33.5%, transparent 66.5%, rgba(255,255,255,.35) 66.7%, transparent 66.9%); }
.crop-h { position: absolute; width: 16px; height: 16px; border: 3px solid #fff; }
.crop-h[data-h=nw] { left: -3px; top: -3px; border-right: 0; border-bottom: 0; cursor: nwse-resize; }
.crop-h[data-h=ne] { right: -3px; top: -3px; border-left: 0; border-bottom: 0; cursor: nesw-resize; }
.crop-h[data-h=sw] { left: -3px; bottom: -3px; border-right: 0; border-top: 0; cursor: nesw-resize; }
.crop-h[data-h=se] { right: -3px; bottom: -3px; border-left: 0; border-top: 0; cursor: nwse-resize; }

.bar-note { color: var(--tx-4); font-size: 11px; }
.tool-overlay { position: absolute; inset: 0; touch-action: none; cursor: crosshair; overflow: hidden; }
.tool-overlay.warp { cursor: default; }
.tool-overlay.hide-spots .spot { opacity: 0; }
.spot { position: absolute; border: 1.5px solid #5fe3b4; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 0 1px rgba(0,0,0,.5); cursor: pointer; }
.spot.auto { border-color: #ffc24d; }
.spot:hover { border-color: #ff6b6b; background: rgba(255,107,107,.2); }
.warp-el { position: absolute; border: 1.5px dashed rgba(255,255,255,.85); border-radius: 50%; transform: translate(-50%, -50%); cursor: move; box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
.warp-el.cur { border-color: var(--accent); border-style: solid; background: rgba(41,151,255,.08); }
.warp-el .wh { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.6); }
.warp-el .wh[data-h=x] { right: -7px; top: 50%; margin-top: -7px; cursor: ew-resize; }
.warp-el .wh[data-h=y] { bottom: -7px; left: 50%; margin-left: -7px; cursor: ns-resize; }
.warp-el::after { content: ""; position: absolute; left: 50%; top: 8%; bottom: 8%; border-left: 1px dotted rgba(255,255,255,.5); }
.warp-row { display: flex; align-items: center; gap: 6px; }
.warp-row .slider-row { flex: 1; }

/* Dialogs */
.dlg { background: var(--bg-2); color: var(--tx); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 40px); box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.dlg.wide { width: min(1100px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(2px); }
.dlg[open] { display: flex; flex-direction: column; }
.dlg-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 10px 18px; font-size: 15px; }
.dlg-sub { color: var(--tx-4); font-size: 12px; }
.dlg-note { color: var(--tx-3); font-size: 12px; margin: 0 18px 10px; }
.dlg-foot { display: flex; align-items: center; gap: 8px; padding: 12px 14px 14px 18px; border-top: 1px solid var(--line); }
.dlg-foot .dlg-note { margin: 0; }
.form { padding: 4px 18px 12px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--tx-3); }
.form input:not([type=checkbox]):not([type=range]), .form select, .form textarea, .acc-pref select, .acc-card input, .acc-card select {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; color: var(--tx); outline: 0; font-size: 13px; }
.form textarea { min-height: 70px; resize: vertical; font: inherit; }
.form input:focus, .form select:focus, .form textarea:focus, .acc-card input:focus { border-color: var(--accent); }
.form fieldset { border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px 12px 12px; min-width: 0; }
.form input[type=file] { max-width: 100%; min-width: 0; }
.form label { min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label.check { flex-direction: row !important; align-items: center; gap: 8px; color: var(--tx-2) !important; font-size: 13px; cursor: pointer; }
#dlgSync label.check { margin: 0 18px 12px; }
.choice-list { display: flex; flex-wrap: wrap; gap: 6px; }
.choice-list button { padding: 6px 12px; border-radius: var(--r-pill); background: var(--card); color: var(--tx-2); font-size: 12px; }
.choice-list button.on { background: var(--accent-soft); color: var(--accent); outline: 1px solid var(--accent); }
.ex-dest { font-size: 12px; color: var(--tx-3); }

/* Account dialog */
.acc-cards { display: flex; flex-direction: column; gap: 10px; padding: 0 18px; }
.acc-card { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.acc-card.on { border-color: rgba(95,227,180,.5); }
.acc-top { display: flex; align-items: center; gap: 10px; }
.acc-logo { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; }
.acc-logo.openai { background: #fff; color: #000; }
.acc-logo.gemini { background: linear-gradient(135deg,#4285f4,#9b72cb,#d96570); color: #fff; }
.acc-top .nm { flex: 1; }
.acc-top .nm b { display: block; font-size: 14px; }
.acc-top .nm span { font-size: 11px; color: var(--tx-4); }
.acc-badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: var(--r-pill); background: var(--card); color: var(--tx-3); }
.acc-card.on .acc-badge { background: rgba(95,227,180,.15); color: var(--green); }
.acc-row { display: flex; gap: 6px; }
.acc-row input { flex: 1; min-width: 0; }
.acc-links { font-size: 11px; color: var(--tx-4); display: flex; gap: 12px; flex-wrap: wrap; }
.acc-links a { color: var(--accent); }
.acc-models { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.acc-models label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--tx-4); }
.acc-err { color: var(--red); font-size: 11px; }
.acc-help { margin: 12px 18px 0; font-size: 12px; color: var(--tx-3); }
.acc-help summary { cursor: pointer; color: var(--tx-2); }
.acc-pref { padding: 12px 18px 16px; }
.acc-pref label { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--tx-3); }

/* Looks dialog */
.look-cats { display: flex; gap: 4px; padding: 0 16px 8px; flex-wrap: wrap; }
.look-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; padding: 4px 16px 18px; overflow-y: auto; }
.look-grid .look { font-size: 12px; cursor: pointer; }
.look-grid .look canvas { border-radius: 10px; }
.look .del { font-size: 10px; color: var(--red); }

.hist-list { margin: 0; padding: 0 18px 16px 40px; max-height: 60vh; overflow: auto; }
.hist-list li { padding: 5px 6px; border-radius: 6px; cursor: pointer; color: var(--tx-2); }
.hist-list li:hover { background: var(--card); }
.hist-list li.cur { color: var(--accent); font-weight: 600; }

.toasts { position: fixed; z-index: 100; left: 50%; bottom: 140px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: rgba(38,38,42,.97); border: 1px solid var(--line); padding: 9px 16px; border-radius: var(--r-pill); font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.5); animation: tin .2s; max-width: 80vw; }
.toast.err { border-color: rgba(255,107,107,.5); color: #ffb3b3; }
.toast.ok { border-color: rgba(95,227,180,.4); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* Mobile / tablet */
/* Màn hình cảm ứng, tai thỏ, thanh Home (iPhone / iPad / Android) */
:root { --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px); }
body { -webkit-tap-highlight-color: transparent; touch-action: manipulation; -webkit-text-size-adjust: 100%; }
.topbar { height: calc(var(--top-h) + var(--sat)); padding-top: var(--sat); padding-left: calc(14px + var(--sal)); padding-right: calc(14px + var(--sar)); }
.welcome, .editor { height: calc(100vh - var(--top-h) - var(--sat)); height: calc(100dvh - var(--top-h) - var(--sat)); }
.editor { padding-left: var(--sal); padding-right: var(--sar); }
.filmbar { padding-bottom: var(--sab); }
.panel { padding-bottom: calc(30px + var(--sab)); }
.brushbar { top: calc(var(--top-h) + var(--sat) + 10px); }
body.ios #btnChooseFolder, body.touch #btnChooseFolder { display: none; }
body.touch input[type=range]::-webkit-slider-thumb { width: 20px; height: 20px; margin-top: -8.5px; }
body.touch input[type=range] { height: 26px; }
body.touch .crop-h { width: 26px; height: 26px; }
body.touch .warp-el .wh { width: 24px; height: 24px; }
body.touch .warp-el .wh[data-h=x] { right: -12px; margin-top: -12px; }
body.touch .warp-el .wh[data-h=y] { bottom: -12px; margin-left: -12px; }
body.touch .chip { height: 32px; }
body.touch .cull-bar, body.touch .viewer-bar, body.touch .filmstrip, body.touch .looks { scrollbar-width: none; }

/* Điện thoại, máy tính bảng dọc: ảnh cố định phía trên, bảng công cụ cuộn bên dưới kiểu iOS */
@media (max-width: 900px) {
  :root { --panel-w: 100%; --top-h: 48px; }
  .editor { flex-direction: column; }
  .stage-wrap { flex: none; height: 56%; }
  .viewer { padding: 6px; }
  .photo-label { display: none; }
  .viewer-bar { gap: 2px; padding: 2px 6px; flex-wrap: nowrap; overflow-x: auto; }
  .viewer-bar .zoom, .viewer-bar #btnAdd { display: none; }
  .cull-bar { padding: 4px 8px 0; }
  .filmstrip { height: 66px; padding: 6px 10px; gap: 6px; }
  .thumb { height: 54px; }
  .filmbar { padding-bottom: 0; }
  .panel { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    border-left: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; margin-top: -2px; background: var(--bg-2);
    padding: 6px 10px calc(30px + var(--sab)); position: relative; }
  .panel::before { content: ""; display: block; width: 38px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.25); margin: 0 auto 8px; }
  .panel .block, .panel .sec.open { background: var(--bg); }
  .topbar { gap: 6px; }
  .brand span, .tb-group #btnHistory { display: none; }
  .seg button { padding: 5px 9px; font-size: 12px; }
  .ai-status #aiStatusText { display: none; }
  .ai-status { padding: 0 8px; }
  .topbar .btn.primary { padding: 0 10px; font-size: 12px; }
  .welcome { padding: 20px 12px calc(20px + var(--sab)); }
  .dropzone { padding: 32px 16px 24px; }
  .dropzone h1 { font-size: 26px; }
  /* Thanh công cụ nằm ở đáy (đè lên bảng công cụ), không che ảnh */
  .brushbar { top: auto; bottom: calc(10px + var(--sab)); left: 8px; right: 8px; transform: none; max-width: none;
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px; padding: 8px 10px; border-radius: var(--r-md); }
  .brushbar > b { display: none; }
  .brushbar .bar-note { display: none; }
  .brushbar .btn.primary { margin-left: auto; flex: none; position: sticky; right: 0; box-shadow: -10px 0 12px rgba(38,38,42,.95); }
  .brushbar input[type=range] { width: 90px; }
  .toasts { top: auto; bottom: calc(84px + var(--sab)); }
  .types { grid-template-columns: repeat(5, 1fr); }
  .dlg { max-height: calc(100dvh - var(--sat) - var(--sab) - 24px); }
  .grid2 { grid-template-columns: 1fr; }
  /* iOS phóng to khi chữ trong ô nhập nhỏ hơn 16px */
  .form input:not([type=checkbox]):not([type=range]), .form select, .form textarea, .search input, .brushbar select { font-size: 16px; }
}

/* Điện thoại xoay ngang: ảnh bên trái, bảng công cụ bên phải */
@media (max-width: 1000px) and (max-height: 520px) and (orientation: landscape) {
  :root { --panel-w: 300px; }
  .editor { flex-direction: row; }
  .stage-wrap { flex: 1; height: 100%; }
  .panel { flex: none; width: var(--panel-w); border-radius: 0; border-top: 0; border-left: 1px solid var(--line); }
  .panel::before { display: none; }
  .cull-bar { display: none; }
}

/* ---------- Vùng chỉnh riêng, cọ có sẵn, kéo chân, cọ nắn ---------- */
.local-overlay { position: absolute; inset: 0; touch-action: none; overflow: hidden; z-index: 3; }
.local-overlay[data-mode=brush], .local-overlay[data-mode=liquify] { cursor: none; }
.local-overlay[data-mode=linear], .local-overlay[data-mode=radial], .local-overlay[data-mode=legs] { cursor: default; }
.lo-cursor { position: absolute; border: 1.5px solid #fff; border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none; box-shadow: 0 0 0 1px rgba(0,0,0,.55), inset 0 0 0 1px rgba(0,0,0,.35); }
.lo-cursor.erase { border-style: dashed; border-color: #ff8a8a; }
.lo-cursor.hidden { display: none; }
.lo-h { position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid rgba(0,0,0,.35); transform: translate(-50%, -50%); cursor: grab; box-shadow: 0 1px 5px rgba(0,0,0,.6); z-index: 2; }
.lo-h.start { background: #ff9a3c; }
.lo-line { position: absolute; height: 0; border-top: 2px dashed rgba(255,255,255,.9); transform-origin: 0 0; cursor: move; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.lo-line::after { content: ""; position: absolute; left: 0; right: 0; top: -9px; height: 16px; }
.lo-perp { position: absolute; width: 2000px; height: 0; border-top: 1px dotted rgba(255,255,255,.55); pointer-events: none; }
.lo-perp.start { border-top-color: rgba(255,154,60,.8); }
.lo-ellipse { position: absolute; border: 2px dashed rgba(255,255,255,.9); border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none; box-shadow: 0 0 0 1px rgba(0,0,0,.3); }
.lo-legs { position: absolute; left: 0; right: 0; height: 0; border-top: 2px dashed #ff9a3c; cursor: ns-resize; }
.lo-legs::after { content: ""; position: absolute; left: 0; right: 0; top: -12px; height: 24px; }
.lo-legs span { position: absolute; left: 50%; top: -30px; transform: translateX(-50%); padding: 3px 10px; border-radius: var(--r-pill); background: rgba(255,154,60,.92); color: #1b1203; font-size: 11px; font-weight: 700; white-space: nowrap; cursor: ns-resize; }
.lb-ctrls { display: flex; align-items: center; gap: 8px; }
.lb-ctrls label span { min-width: 24px; color: var(--tx-2); }
.lo-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.lo-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: var(--card); cursor: pointer; font-size: 12px; }
.lo-row b { flex: 1; font-weight: 600; }
.lo-row .ico svg { width: 14px; height: 14px; }
.lo-row.on { background: var(--accent-soft); color: var(--accent); outline: 1px solid var(--accent); }
.lo-ctrls { margin-top: 8px; }
.lo-ctrls .check { margin: 6px 0; }
.sec-actions.wrap .btn { flex: 0 0 auto; }
.film-styles { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.film-styles .chip { background: var(--card); }
.film-styles .chip.on { background: var(--accent-soft); color: var(--accent); }
.match-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; padding: 4px 16px 12px; max-height: 50vh; overflow-y: auto; }
.match-item { padding: 0; border-radius: 8px; overflow: hidden; outline: 2px solid transparent; background: var(--card); }
.match-item:hover { outline-color: var(--accent); }
.match-item canvas { width: 100%; display: block; }
@media (max-width: 900px) { .brushbar .lb-ctrls { flex-wrap: wrap; } .brushbar { white-space: normal; max-width: calc(100vw - 20px); } }

/* 0.4.0: nút mắt bật / tắt xem trước từng mục, công cụ to mắt, xoá vật thể, ảnh thẻ */
.sec-eye { position: relative; display: none; width: 26px; height: 26px; border-radius: 50%; align-items: center; justify-content: center; color: var(--tx-3); }
.sec-eye svg.i { width: 15px; height: 15px; }
.sec-eye:hover { background: var(--card); color: var(--tx); }
.sec.changed .sec-eye, .sec.off .sec-eye { display: inline-flex; }
.sec.off .sec-eye { color: var(--tx-4); }
.sec.off .sec-eye::after { content: ''; position: absolute; left: 5px; right: 5px; top: 50%; height: 1.5px; background: currentColor; transform: rotate(-40deg); }
.sec.off .sec-head b { color: var(--tx-3); }
.sec.off .sec-head .dot { opacity: .35; }
.local-overlay[data-mode=heal] { cursor: none; }
.local-overlay[data-mode=bulge] { cursor: copy; }
.local-overlay[data-mode=pick] { cursor: crosshair; }
.lo-heal { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.id-swatch { display: inline-block; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--bg-2); box-shadow: 0 0 0 1px var(--line, rgba(128,128,128,.4)); vertical-align: middle; }

/* 0.4.1: bấm vào ảnh để phóng to / thu nhỏ, kéo để di chuyển khi đang phóng to */
.viewer #glCanvas { cursor: zoom-in; touch-action: manipulation; }
.viewer.zoomed #glCanvas { cursor: zoom-out; }
.viewer.zoomed.panning, .viewer.zoomed.panning #glCanvas { cursor: grabbing; user-select: none; }
