/* ===================================================================
   Inkora — styles
   Palette: deep indigo chrome, neutral stage, brand violet-magenta accent (from the logo).
   One typeface (IBM Plex Sans Arabic) for English and Arabic.
   =================================================================== */
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 400; font-display: swap; src: url(../fonts/plex-latin-400.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 500; font-display: swap; src: url(../fonts/plex-latin-500.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 600; font-display: swap; src: url(../fonts/plex-latin-600.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 400; font-display: swap; src: url(../fonts/plex-arabic-400.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 500; font-display: swap; src: url(../fonts/plex-arabic-500.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 600; font-display: swap; src: url(../fonts/plex-arabic-600.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }

:root {
  --bg: #1d1a2e;
  --stage: #2c2e38;
  --chrome: rgba(31, 34, 51, .93);
  --surface: #272b3f;
  --surface-2: #31364d;
  --line: #3c4159;
  --text: #ecebf4;
  --muted: #9ba1b9;
  --accent: #9333ea;
  --accent-ink: #ffffff;
  --accent-text: #d6a6ff;
  --brand-grad: linear-gradient(100deg, #7e22ce, #e0359a 55%, #ffa63d);
  --danger: #f0604f;
  --focus: #7fb0ff;
  --ink-trail: rgba(150, 160, 215, .5);
  --shadow: 0 10px 34px rgba(8, 10, 20, .45);
  --r-s: 8px; --r-m: 12px; --r-l: 18px;
  --font: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --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);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #eceef5;
  --stage: #d7d9e1;
  --chrome: rgba(255, 255, 255, .94);
  --surface: #ffffff;
  --surface-2: #f1f2f7;
  --line: #dcdfe8;
  --text: #1f2233;
  --muted: #5f6680;
  --accent: #9333ea;
  --accent-ink: #ffffff;
  --accent-text: #7e22ce;
  --brand-grad: linear-gradient(100deg, #7e22ce, #e0359a 55%, #ffa63d);
  --danger: #d6402f;
  --focus: #2f6fe0;
  --ink-trail: rgba(50, 60, 120, .28);
  --shadow: 0 10px 30px rgba(30, 34, 60, .16);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 400 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { opacity: .4; cursor: default; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.ic { width: 22px; height: 22px; flex: none; display: block; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

#splash { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 100; }
.splash-mark { width: 96px; height: 96px; object-fit: contain; animation: pulse 1.2s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.06); } }

.screen { position: fixed; inset: 0; }

/* ---------- buttons & fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px; border-radius: 999px; background: var(--surface-2); color: var(--text); font-weight: 500; border: 1px solid var(--line); white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn.primary { background: var(--brand-grad); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 0 14px; font-size: 13px; }
.btn.wide { width: 100%; }
.field { width: 100%; min-height: 44px; padding: 10px 14px; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--surface-2); color: var(--text); }
.field:focus { outline: none; border-color: var(--focus); }
textarea.field { resize: vertical; min-height: 90px; }
input[type="range"] { accent-color: var(--accent); width: 100%; }
.link { color: var(--accent-text); font-weight: 500; padding: 6px 0; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 44px; height: 44px; object-fit: contain; }
.brand-word { height: 30px; width: auto; }
.wm-light { display: none; }
:root:not([data-theme="light"]) .wm-dark { display: none; }
:root:not([data-theme="light"]) .wm-light { display: block; }
.brand-auth { flex-direction: column; gap: 6px; }
.brand-auth .brand-mark { width: 120px; height: 120px; }
.brand-auth .brand-word { height: 44px; }
.auth-card .auth-tag { text-align: center; }
.brand.small .brand-mark { width: 38px; height: 38px; }
.brand.small .brand-word { height: 24px; }
.auth-announce { margin: 0 0 14px !important; }
.announce { margin: 14px calc(22px + var(--sar)) 0 calc(22px + var(--sal)); padding: 12px 16px; border-radius: var(--r-m); background: var(--brand-grad); color: #fff; font-weight: 500; }

/* ================= Auth ================= */
#auth { display: grid; place-items: center; padding: calc(24px + var(--sat)) 18px calc(24px + var(--sab)); overflow-y: auto; }
#authInk { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; }
.auth-card { position: relative; width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 30px 28px 22px; box-shadow: var(--shadow); }
.auth-tag { margin: 10px 0 22px; color: var(--muted); font-size: 16px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 999px; padding: 4px; margin-bottom: 18px; }
.auth-tabs button { min-height: 38px; border-radius: 999px; font-weight: 500; color: var(--muted); }
.auth-tabs button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.social { display: grid; gap: 10px; }
.social-btn { width: 100%; background: var(--surface); }
.social-btn.apple { background: var(--text); color: var(--surface); border-color: transparent; }
.g-logo, .a-logo { display: inline-flex; }
.g-host { min-height: 44px; display: flex; justify-content: center; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 18px 0 14px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-f { display: grid; gap: 12px; }
.auth-h { font-size: 20px; margin: 0; font-weight: 600; }
.f { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.f .field { color: var(--text); font-size: 15px; }
.auth-err { color: var(--danger); font-size: 13px; margin: 0; min-height: 1em; }
.auth-err:empty { display: none; }
.legal { color: var(--muted); font-size: 12px; margin: 14px 0 0; }
.auth-lang { position: fixed; top: calc(14px + var(--sat)); inset-inline-end: 16px; padding: 8px 14px; border-radius: 999px; background: var(--chrome); border: 1px solid var(--line); font-weight: 500; }

/* ================= Gallery ================= */
#gallery { display: flex; flex-direction: column; }
.g-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(14px + var(--sat)) calc(22px + var(--sar)) 14px calc(22px + var(--sal)); border-bottom: 1px solid var(--line); }
.g-actions { display: flex; align-items: center; gap: 10px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); font-weight: 600; flex: none; }
.avatar.pro { border: 2px solid #e0359a; }
.avatar.big { width: 56px; height: 56px; font-size: 22px; }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.sync .ic { width: 20px; height: 20px; }
.sync.syncing .ic { color: var(--accent-text); }
.sync.error { color: var(--danger); }
.g-grid { flex: 1; overflow-y: auto; padding: 26px calc(22px + var(--sar)) calc(30px + var(--sab)) calc(22px + var(--sal)); display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 28px 22px; align-content: start; }
.g-card { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.g-thumb { aspect-ratio: 4 / 3.4; background: var(--stage); border-radius: var(--r-s); display: grid; place-items: center; padding: 14px; overflow: hidden; }
.g-thumb img { max-width: 100%; max-height: 100%; width: auto; height: auto; display: block; box-shadow: 0 2px 10px rgba(0,0,0,.28); background: #fff; }
.g-thumb:hover img { transform: translateY(-2px); transition: transform .15s; }
.g-nothumb { width: 60%; aspect-ratio: 1; background: #fff; opacity: .4; }
.g-info { display: flex; align-items: flex-start; gap: 6px; }
.g-text { flex: 1; min-width: 0; }
.g-name { margin: 0; font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-meta { margin: 2px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; white-space: nowrap; font-size: 12px; color: var(--muted); }
.g-state .ic { width: 16px; height: 16px; }
.g-more { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); flex: none; }
.g-more:hover { background: var(--surface-2); color: var(--text); }
.g-empty { grid-column: 1 / -1; text-align: center; padding: 12vh 20px; display: grid; justify-items: center; gap: 4px; }
.g-empty-title { font-size: 22px; font-weight: 600; margin: 0; }
.g-empty .btn { margin-top: 14px; }
.pop { position: fixed; z-index: 60; width: 210px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--shadow); padding: 6px; }
.pop-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-s); text-align: start; }
.pop-item:hover { background: var(--surface-2); }
.pop-item.danger { color: var(--danger); }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.preset { display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; text-align: start; padding: 12px; border-radius: var(--r-m); border: 1px solid var(--line); background: var(--surface-2); }
.preset:hover { border-color: var(--accent); }
.preset-shape { grid-row: span 2; justify-self: center; max-width: 30px; max-height: 34px; width: 30px; border: 2px solid var(--muted); border-radius: 3px; }
.preset-name { font-weight: 500; }
.preset-dim { font-size: 12px; color: var(--muted); }
.custom { align-items: end; }

/* ================= Modal & toast ================= */
.modal-back { position: fixed; inset: 0; z-index: 96; background: rgba(10, 12, 22, .55); display: grid; place-items: center; padding: 18px; animation: fade .15s; }
.modal { width: min(440px, 100%); max-height: calc(100vh - 36px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 22px; box-shadow: var(--shadow); animation: rise .18s ease-out; }
.modal.wide { width: min(680px, 100%); }
.modal-title { margin: 0 0 14px; font-size: 19px; font-weight: 600; }
.modal-text { margin: 0; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.form { display: grid; gap: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row.custom { grid-template-columns: 1fr 1fr auto; }
.form label > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.form label.check { display: flex; align-items: center; gap: 10px; }
.form label.check > span { margin: 0; color: var(--text); font-size: 15px; }
.form label.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.toasts { position: fixed; z-index: 98; left: 50%; bottom: calc(96px + var(--sab)); transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow); transition: opacity .3s, transform .3s; }
.toast.error { background: var(--danger); color: #fff; }
.toast.warn { background: var(--accent); color: var(--accent-ink); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ================= Account / upsell ================= */
.acct { display: grid; gap: 16px; }
.acct-top { display: flex; align-items: center; gap: 14px; }
.acct-name { font-size: 18px; font-weight: 600; }
.acct-plan { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.plan-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: var(--surface-2); font-weight: 500; font-size: 13px; }
.plan-pill.pro { background: var(--brand-grad); color: #fff; }
.plan-pill .ic { width: 16px; height: 16px; }
.storage { display: grid; gap: 6px; font-size: 13px; }
.storage-bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.storage-bar span { display: block; height: 100%; background: var(--accent); }
.upsell { display: grid; gap: 10px; }
.upsell-crown { color: var(--accent-text); }
.upsell-crown .ic { width: 38px; height: 38px; }
.upsell-reason { margin: 0; font-weight: 500; }
.upsell ul { list-style: none; margin: 4px 0; padding: 0; display: grid; gap: 8px; }
.upsell li { display: flex; gap: 10px; align-items: center; }
.upsell li .ic { color: var(--accent-text); width: 18px; height: 18px; }
.pro-badge { color: var(--accent-text); display: inline-flex; margin-inline-start: 6px; vertical-align: -3px; }
.pro-badge .ic { width: 15px; height: 15px; }

/* ================= Editor ================= */
#editor { background: var(--stage); overflow: hidden; user-select: none; -webkit-user-select: none; }
#stage { position: absolute; inset: 0; }
#view, #overlay { position: absolute; inset: 0; display: block; }
#overlay { touch-action: none; cursor: crosshair; }

.ed-top { position: absolute; top: 0; left: 0; right: 0; z-index: 13; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: calc(6px + var(--sat)) calc(8px + var(--sar)) 6px calc(8px + var(--sal)); background: var(--chrome); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.ed-grp { display: flex; align-items: center; gap: 2px; }
.ed-txt { height: 40px; padding: 0 12px; border-radius: var(--r-s); font-weight: 500; }
.ed-txt:hover { background: var(--surface-2); }
.ed-ib, .side-btn { width: 42px; height: 42px; border-radius: var(--r-s); display: grid; place-items: center; color: var(--text); }
.ed-ib:hover, .side-btn:hover { background: var(--surface-2); }
.ed-ib.on, .side-btn.on { color: var(--accent-text); background: var(--surface-2); }
.ed-ib.open { background: var(--surface-2); }
.ed-color { width: 42px; height: 42px; display: grid; place-items: center; }
.ed-color span { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--text); box-shadow: 0 0 0 2px var(--chrome) inset; }

.sidebar { position: absolute; z-index: 13; top: 50%; transform: translateY(-50%); inset-inline-start: calc(8px + var(--sal)); width: 50px; padding: 10px 4px; display: flex; flex-direction: column; align-items: center; gap: 8px; background: var(--chrome); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: 26px; }
#editor.right-handed .sidebar { inset-inline-start: auto; inset-inline-end: calc(8px + var(--sar)); }
.vslider { position: relative; width: 40px; height: 150px; display: flex; justify-content: center; cursor: ns-resize; touch-action: none; }
.vs-track { position: relative; width: 8px; height: 100%; border-radius: 4px; background: var(--surface-2); }
.vs-fill { position: absolute; bottom: 0; left: 0; right: 0; border-radius: 4px; background: var(--muted); }
.vs-thumb { position: absolute; left: 50%; width: 22px; height: 22px; margin-left: -11px; border-radius: 50%; background: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.vs-bubble { position: absolute; inset-inline-start: 50px; top: 50%; transform: translateY(-50%); background: var(--surface); border: 1px solid var(--line); padding: 4px 10px; border-radius: var(--r-s); font-size: 13px; font-weight: 500; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; box-shadow: var(--shadow); }
#editor.right-handed .vs-bubble { inset-inline-start: auto; inset-inline-end: 50px; }
.vslider.active .vs-bubble { opacity: 1; }

#scrim { position: absolute; inset: 0; z-index: 11; }
#panelHost.panel { position: absolute; z-index: 14; width: 350px; max-height: min(72vh, 640px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow); padding-bottom: 8px; animation: rise .16s ease-out; }
#panelHost.panel-brushes { width: 420px; }
#panelHost.panel.sheet { left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 74vh; border-radius: var(--r-l) var(--r-l) 0 0; padding-bottom: calc(10px + var(--sab)); }
.p-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.p-head h3 { margin: 0; font-size: 17px; font-weight: 600; }
.p-head-actions { display: flex; gap: 4px; }
.p-ib { width: 38px; height: 38px; border-radius: var(--r-s); display: grid; place-items: center; }
.p-ib:hover, .p-ib.on { background: var(--surface-2); }
.p-ib.on { color: var(--accent-text); }
.p-foot { padding: 8px 16px 4px; font-size: 12px; color: var(--muted); }

/* brush library */
.lib-body { display: grid; grid-template-columns: 118px 1fr; min-height: 300px; border-top: 1px solid var(--line); }
.lib-cats { display: flex; flex-direction: column; padding: 8px; gap: 2px; border-inline-end: 1px solid var(--line); }
.lib-cat { text-align: start; padding: 9px 10px; border-radius: var(--r-s); font-size: 14px; color: var(--muted); }
.lib-cat.on { background: var(--surface-2); color: var(--text); font-weight: 500; }
.lib-list { padding: 8px; display: grid; gap: 4px; align-content: start; }
.lib-item { display: grid; gap: 2px; text-align: start; padding: 8px 10px 4px; border-radius: var(--r-m); border: 1px solid transparent; }
.lib-item:hover { background: var(--surface-2); }
.lib-item.on { border-color: var(--accent); background: var(--surface-2); }
.lib-name { font-size: 13px; font-weight: 500; }
.lib-prev { width: 100%; height: 46px; display: block; }
.bs { padding: 4px 16px 10px; display: grid; gap: 8px; }
.bs-name { font-weight: 600; }
.bs-prev { width: 100%; height: 60px; background: var(--surface-2); border-radius: var(--r-s); }
.bs-row { display: grid; grid-template-columns: 112px 1fr 46px; align-items: center; gap: 10px; font-size: 13px; }
.bs-row output { text-align: end; color: var(--muted); font-variant-numeric: tabular-nums; }

/* layers */
.ly-list { padding: 0 8px; }
.ly-row { display: grid; grid-template-columns: 22px 44px 1fr auto 38px; align-items: center; gap: 8px; padding: 6px; border-radius: var(--r-m); cursor: pointer; border: 1px solid transparent; }
.ly-row:hover { background: var(--surface-2); }
.ly-row.on { background: var(--surface-2); border-color: var(--accent); }
.ly-row.clipped { padding-inline-start: 22px; }
.ly-row.dragging { opacity: .5; }
.ly-row.drop-above { box-shadow: 0 -2px 0 var(--accent); }
.ly-row.drop-below { box-shadow: 0 2px 0 var(--accent); }
.ly-handle { color: var(--muted); cursor: grab; touch-action: none; display: grid; place-items: center; height: 38px; }
.ly-handle .ic { width: 18px; height: 18px; }
.ly-thumb { width: 44px; height: 44px; border-radius: 4px; background: repeating-conic-gradient(#ffffff 0% 25%, #d9dbe2 0% 50%) 50% / 10px 10px; }
.ly-name { display: grid; min-width: 0; font-size: 14px; }
.ly-name > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ly-flags { display: flex; gap: 4px; color: var(--muted); }
.ly-flags .ic { width: 14px; height: 14px; }
.ly-blend { min-width: 30px; height: 30px; padding: 0 6px; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface); border: 1px solid var(--line); }
.ly-vis { width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; border: 1.5px solid var(--line); color: transparent; justify-self: center; }
.ly-vis.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ly-vis .ic { width: 18px; height: 18px; }
.ly-bg { margin-top: 6px; border-top: 1px solid var(--line); border-radius: 0; cursor: default; }
.ly-swatch { width: 44px; height: 44px; border-radius: 4px; border: 1px solid var(--line); }
.ly-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 6px; margin: 2px 0 8px; background: var(--surface-2); border-radius: var(--r-m); }
.lm-item { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: var(--r-s); font-size: 13px; text-align: start; }
.lm-item:hover { background: var(--surface); }
.lm-item .ic { width: 18px; height: 18px; color: var(--muted); }
.lm-item.on .ic { color: var(--accent-text); }
.ly-menu.blend { grid-template-columns: 1fr; padding: 10px; }
.blend-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 6px; }
.blend-btn { padding: 7px 6px; border-radius: 6px; font-size: 12px; background: var(--surface); }
.blend-btn.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* color */
.cp-chips { display: flex; align-items: center; gap: 8px; padding: 0 16px 12px; }
.cp-chip { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--line); flex: none; cursor: pointer; }
.cp-hex { min-height: 36px; padding: 6px 12px; font-variant-numeric: tabular-nums; text-transform: lowercase; }
.cp-svwrap, .cp-huewrap { position: relative; margin: 0 16px; touch-action: none; cursor: crosshair; }
.cp-sv { width: 100%; height: 190px; display: block; border-radius: var(--r-m); }
.cp-huewrap { margin-top: 12px; }
.cp-hue { width: 100%; height: 22px; display: block; border-radius: 11px; }
.cp-dot { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.4); pointer-events: none; }
.cp-hdot { position: absolute; top: 50%; width: 24px; height: 24px; margin: -12px 0 0 -12px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.4); pointer-events: none; }
[dir="rtl"] .cp-svwrap, [dir="rtl"] .cp-huewrap { direction: ltr; }
.cp-label { margin: 14px 16px 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.cp-row, .cp-pal { display: grid; grid-template-columns: repeat(auto-fill, minmax(30px, 1fr)); gap: 6px; padding: 0 16px; }
.sw { aspect-ratio: 1; border-radius: 6px; border: 1px solid rgba(128,128,128,.35); min-width: 0; }
.sw.add { display: grid; place-items: center; background: var(--surface-2); }
.sw.add .ic { width: 16px; height: 16px; }

/* actions */
.act-tabs { display: grid; grid-template-columns: repeat(6, 1fr); padding: 8px; gap: 2px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.act-tab { display: grid; justify-items: center; gap: 3px; padding: 8px 2px 6px; border-radius: var(--r-s); font-size: 11px; color: var(--muted); }
.act-tab.on { background: var(--surface-2); color: var(--text); }
.act-tab.on .ic { color: var(--accent-text); }
.act-body { padding: 6px 8px; display: grid; gap: 2px; }
.act-row { display: flex; align-items: center; gap: 12px; padding: 11px 10px; border-radius: var(--r-s); text-align: start; width: 100%; }
.act-row:hover { background: var(--surface-2); }
.act-row .ic { color: var(--muted); }
.act-row.danger, .act-row.danger .ic { color: var(--danger); }
.act-label { flex: 1; }
.act-info { padding: 8px 10px; color: var(--muted); font-size: 13px; }
.act-seg { padding: 8px 10px; display: grid; gap: 8px; }
.act-slider { padding: 8px 10px; grid-template-columns: 1fr 1.4fr 60px; }
.switch { width: 40px; height: 24px; border-radius: 12px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: inset-inline-start .15s; }
.switch.on { background: var(--accent); }
.switch.on::after { inset-inline-start: 19px; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 10px; }
.seg button { flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 10px; border-radius: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.seg button .ic { width: 18px; height: 18px; }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.help { margin: 0; padding: 6px 14px 10px 30px; display: grid; gap: 8px; font-size: 14px; }
[dir="rtl"] .help { padding: 6px 30px 10px 14px; }

/* tool option bar */
.toolopts { position: absolute; z-index: 9; left: 50%; transform: translateX(-50%); bottom: calc(16px + var(--sab)); max-width: calc(100% - 140px); display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--chrome); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: 16px; overflow-x: auto; scrollbar-width: none; }
.toolopts::-webkit-scrollbar { display: none; }
.toolopts .seg { flex-wrap: nowrap; }
.to-btn { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; min-width: 56px; padding: 6px 6px 4px; border-radius: var(--r-s); font-size: 11px; color: var(--muted); white-space: nowrap; }
.to-btn:hover { background: var(--surface-2); color: var(--text); }
.to-btn.primary { color: var(--accent-text); }
.to-btn .ic { color: var(--text); }
.to-btn.primary .ic { color: var(--accent-text); }
.to-sep { width: 1px; align-self: stretch; background: var(--line); flex: none; }
.to-slider { display: flex; align-items: center; gap: 10px; font-size: 13px; min-width: 240px; flex: none; }
.to-slider input { width: 140px; }
.to-slider output { min-width: 36px; color: var(--muted); font-variant-numeric: tabular-nums; }
.to-title { font-weight: 600; font-size: 14px; white-space: nowrap; padding: 0 6px; }
.to-actions { display: flex; gap: 6px; flex: none; }
.to-hint { font-size: 13px; color: var(--muted); padding: 0 8px; white-space: nowrap; }

/* time-lapse */
.tl { display: grid; gap: 10px; }
.tl-canvas { width: 100%; max-height: 60vh; object-fit: contain; background: var(--stage); border-radius: var(--r-m); }
.tl-bar { display: flex; align-items: center; gap: 10px; }

/* ================= Phone layout ================= */
@media (max-width: 699px) {
  .g-head { flex-wrap: wrap; padding-left: calc(14px + var(--sal)); padding-right: calc(14px + var(--sar)); }
  .g-actions { gap: 6px; }
  .g-actions .btn { padding: 0 12px; min-height: 38px; font-size: 14px; }
  .sync span { display: none; }
  .g-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 14px; padding: 18px 14px calc(24px + var(--sab)); }
  .g-thumb { padding: 8px; }

  .ed-top { padding-top: calc(4px + var(--sat)); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .ed-ib, .side-btn, .ed-color { width: 40px; height: 40px; }
  #toolbar { position: fixed; left: 0; right: 0; bottom: 0; justify-content: space-around; padding: 6px calc(6px + var(--sar)) calc(6px + var(--sab)) calc(6px + var(--sal)); background: var(--chrome); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
  #panelHost.panel.sheet { bottom: calc(57px + var(--sab)); padding-bottom: 10px; max-height: calc(100% - 130px - var(--sab) - var(--sat)); }
  .sidebar { top: auto; bottom: calc(66px + var(--sab)); transform: none; width: 46px; padding: 8px 3px; gap: 6px; }
  .vslider { height: 110px; }
  .toolopts { bottom: calc(66px + var(--sab)); max-width: calc(100% - 76px); left: auto; transform: none; inset-inline-end: 8px; }
  #editor.right-handed .toolopts { inset-inline-end: auto; inset-inline-start: 8px; }
  .toasts { bottom: calc(130px + var(--sab)); }
  .form-row.custom { grid-template-columns: 1fr 1fr; }
  .form-row.custom .btn { grid-column: span 2; }
  .lib-body { grid-template-columns: 100px 1fr; }
  .auth-card { padding: 24px 20px 18px; }
  .wordmark { font-size: 30px; }
}
@media (max-width: 380px) {
  .ed-ib, .ed-color { width: 36px; }
  .ed-txt { padding: 0 8px; }
}

/* elements panel */
#panelHost.panel-elements { width: 400px; }
.el-tabs { margin: 0 16px 10px; }
.el-opts { display: flex; align-items: center; gap: 10px; padding: 0 16px 10px; flex-wrap: wrap; }
.el-hint { font-size: 12px; color: var(--muted); }
.el-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; padding: 0 16px 10px; }
.el-tile { aspect-ratio: 1; display: grid; place-items: center; padding: 8px; border-radius: var(--r-m); background: var(--surface-2); border: 1px solid transparent; }
.el-tile:hover { border-color: var(--accent-text); }
.el-tile.wide { grid-column: 1 / -1; aspect-ratio: auto; height: 64px; padding: 0; }
.el-prev { width: 100%; height: 100%; object-fit: contain; display: block; }
.text-prev { width: 100%; height: 110px; background: repeating-conic-gradient(#ffffff 0% 25%, #e6e7ee 0% 50%) 50% / 16px 16px; border-radius: var(--r-s); }
.swatch-input { width: 34px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; }
.form label.check .swatch-input { margin-inline-start: auto; }
/* templates */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 8px; }
.tpl { display: grid; gap: 6px; text-align: start; padding: 8px; border-radius: var(--r-m); border: 1px solid var(--line); background: var(--surface-2); }
.tpl:hover { border-color: var(--accent-text); }
.tpl-img { height: 120px; display: grid; place-items: center; }
.tpl-img canvas { max-width: 100%; max-height: 120px; box-shadow: 0 2px 8px rgba(0,0,0,.25); border-radius: 3px; }
.tpl-name { font-size: 13px; font-weight: 500; }
.tpl-dim { font-size: 11px; color: var(--muted); }
.pw-wrap { position: relative; display: block; }
.pw-wrap .field { padding-inline-end: 48px; }
.eye-btn { position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); }
.eye-btn:hover { color: var(--text); background: var(--surface); }
.eye-btn .ic { width: 20px; height: 20px; }

/* animation timeline */
.animbar { position: absolute; z-index: 12; left: calc(70px + var(--sal)); right: calc(12px + var(--sar)); bottom: calc(12px + var(--sab)); background: var(--chrome); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: 16px; padding: 8px; display: grid; gap: 8px; }
.af-ctl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.af-ctl .to-slider { min-width: 170px; }
.af-ctl .to-slider input { width: 90px; }
.af-hold { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.af-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.af { position: relative; flex: none; width: 62px; border-radius: 8px; border: 2px solid transparent; padding: 1px; background: var(--surface-2); }
.af canvas { display: block; width: 56px; height: 56px; border-radius: 6px; }
.af span { position: absolute; left: 4px; bottom: 3px; font-size: 10px; font-weight: 600; background: rgba(0,0,0,.55); color: #fff; padding: 0 4px; border-radius: 4px; }
.af.on { border-color: var(--accent-text); }
.af.play { border-color: #e0359a; }
.af.hold { opacity: .8; }
.af.add { display: grid; place-items: center; height: 62px; }
#editor:has(.animbar:not([hidden])) .toolopts { bottom: calc(150px + var(--sab)); }
/* layers additions */
.ly-tag { font-size: 10px; font-weight: 600; padding: 0 5px; border-radius: 4px; background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.ly-mask { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.ly-mask.on { background: var(--accent); color: #fff; border-color: transparent; }
.ly-mask.off { text-decoration: line-through; opacity: .6; }
.ly-group { grid-template-columns: 22px 44px 1fr auto 38px; background: var(--surface-2); }
.ly-caret { display: grid; place-items: center; width: 22px; height: 30px; color: var(--muted); }
.ly-caret .ic { width: 16px; height: 16px; transition: transform .15s; }
.ly-caret.open .ic { transform: rotate(90deg); }
.ly-gicon { display: grid; place-items: center; color: var(--muted); }
.ly-row.in-group { margin-inline-start: 14px; }
.lib-actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.btn.small.danger { background: transparent; color: var(--danger); border-color: var(--line); }
.cp-harm { display: flex; gap: 6px; align-items: center; padding: 0 16px; }
.cp-hsel { width: auto; min-height: 32px; padding: 4px 8px; font-size: 13px; flex: none; }
.cp-harm .sw { width: 32px; flex: none; }
.mask-hint { color: var(--accent-text); font-weight: 500; }
@media (max-width: 699px) { .animbar { left: 8px; right: 8px; bottom: calc(66px + var(--sab)); } .af-ctl .to-slider { min-width: 140px; } }

/* ===== Home screen ===== */
.g-grid { display: block; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 6px 0 18px; }
.hero-title { margin: 0; font-size: clamp(24px, 3.2vw, 34px); font-weight: 600; letter-spacing: -.02em; }
.hero.small .hero-title { font-size: clamp(22px, 2.6vw, 28px); }
.hero p { margin: 2px 0 0; }
.g-search { max-width: 320px; min-height: 40px; border-radius: 999px; padding-inline: 16px; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 26px; }
.quick-btn { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: var(--r-l); background: var(--surface); border: 1px solid var(--line); font-weight: 500; text-align: start; }
.quick-btn .ic { width: 26px; height: 26px; color: var(--accent-text); }
.quick-btn:hover { border-color: var(--accent-text); }
.quick-btn.primary { background: var(--brand-grad); border-color: transparent; color: #fff; }
.quick-btn.primary .ic { color: #fff; }
.g-section { font-size: 17px; font-weight: 600; margin: 0 0 12px; }
.g-section-row { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.g-section-row .g-section { margin: 0; }
.recent-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(170px, 200px); gap: 16px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 22px; scrollbar-width: thin; }
.p-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; margin-top: 12px; }
.p-card { display: grid; gap: 4px; text-align: start; padding: 0; }
.p-collage { aspect-ratio: 4 / 3; border-radius: var(--r-l); background: var(--surface); border: 1px solid var(--line); overflow: hidden; display: grid; gap: 3px; padding: 3px; border-top: 4px solid var(--pc, var(--line)); }
.p-collage.n2, .p-collage.n4 { grid-template-columns: 1fr 1fr; }
.p-collage.n3 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.p-collage.n3 img:first-child { grid-row: span 2; }
.p-collage.n4 { grid-template-rows: 1fr 1fr; }
.p-collage img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; background: #fff; }
.p-empty { display: grid; place-items: center; color: var(--muted); }
.p-empty .ic { width: 34px; height: 34px; }
.p-card:hover .p-collage { border-color: var(--accent-text); }
.p-name { font-weight: 500; font-size: 15px; margin-top: 6px; }
.p-count { font-size: 12px; color: var(--muted); }
.p-titlebar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.p-back { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); }
[dir="rtl"] .p-back .ic { transform: scaleX(-1); }
.p-actions { display: flex; gap: 6px; }
.btn.ghost.danger { color: var(--danger); }
.g-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 28px 22px; }
.p-colors { display: flex; gap: 8px; }
.p-colors .sw { width: 34px; height: 34px; border-radius: 50%; }
.p-colors .sw.on { outline: 3px solid var(--text); outline-offset: 2px; }
.act-row.on { background: var(--surface-2); }
.act-row.on .ic { color: var(--accent-text); }

/* ===== Layer swipe actions ===== */
.ly-swipe { position: relative; overflow: hidden; border-radius: var(--r-m); }
.ly-swipe .ly-row { position: relative; background: var(--surface); transition: transform .18s ease-out; touch-action: pan-y; }
.ly-swipe .ly-row.on { background: var(--surface-2); }
.ly-swipe .ly-row[data-swiping] { transition: none; }
.ly-swipe-actions { position: absolute; inset-block: 0; inset-inline-end: 0; display: flex; width: 210px; }
.sa { flex: 1; font-size: 12px; font-weight: 600; color: #fff; }
.sa.lock { background: #5b6178; } .sa.dup { background: #2f5fd0; } .sa.del { background: var(--danger); }

/* ===== QuickMenu ===== */
.qm { position: fixed; z-index: 70; width: 0; height: 0; }
.qm-item { position: absolute; left: -32px; top: -32px; width: 64px; height: 64px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; place-items: center; align-content: center; gap: 0; animation: fade .12s; }
.qm-item .ic { width: 22px; height: 22px; }
.qm-item span { font-size: 9px; max-width: 58px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

/* ===== Full screen (four-finger tap) ===== */
#editor.fs .ed-top, #editor.fs .sidebar, #editor.fs .toolopts, #editor.fs #toolbar { display: none !important; }

/* stop iOS callouts / magnifier while drawing */
#editor, #editor * { -webkit-touch-callout: none; }
#overlay { -webkit-user-select: none; user-select: none; }

@media (max-width: 699px) {
  .quick { grid-template-columns: 1fr 1fr; gap: 10px; }
  .quick-btn { padding: 12px; }
  .g-search { max-width: none; width: 100%; }
  .p-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .g-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 14px; }
  .recent-row { grid-auto-columns: 150px; }
}

/* ===== v1.3: brush library, studio, color panel ===== */
.lib-searchrow { padding: 0 16px 10px; }
.lib-search { min-height: 36px; border-radius: 999px; padding: 6px 14px; }
.lib-cat.add { color: var(--accent-text); }
.lib-cats { max-height: 420px; overflow-y: auto; }
.bs-tabs { margin: 4px 0; }
.bs-tabs button { padding: 6px 6px; font-size: 12px; }
.bs-select { min-height: 32px; padding: 4px 8px; font-size: 13px; }
.cp-tabs { margin: 0 16px 10px; }
.cp-tabs button { font-size: 12px; padding: 6px 4px; }
.cp-body { padding-bottom: 4px; }
.cp-classic { display: grid; }
.cp-discwrap { position: relative; width: 260px; max-width: calc(100% - 32px); margin: 0 auto; touch-action: none; }
.cp-disc { width: 100%; height: auto; display: block; }
.cp-hdot.ring { top: 0; margin: -12px 0 0 -12px; }
.cp-values { display: grid; gap: 6px; padding: 0 16px; }
.cp-vrow { display: grid; grid-template-columns: 18px 1fr 64px; align-items: center; gap: 10px; }
.cp-vlab { font-weight: 600; color: var(--muted); }
.cp-num { min-height: 32px; padding: 4px 8px; font-variant-numeric: tabular-nums; }
.cp-label { display: flex; align-items: center; justify-content: space-between; }
.link.small { font-size: 12px; padding: 0; }
.sw.big { width: 40px; height: 40px; flex: none; }
.pal-view { display: grid; gap: 10px; padding: 0 16px; }
.pal-card { border: 1px solid var(--line); border-radius: var(--r-m); padding: 8px 0 10px; }
.pal-card.on { border-color: var(--accent-text); }
.pal-card .cp-pal { padding: 0 10px; }
.pal-head { display: flex; align-items: center; gap: 6px; padding: 0 6px 6px 12px; }
.pal-name { font-weight: 600; flex: 1; text-align: start; }
.pal-default { font-size: 11px; color: var(--accent-text); font-weight: 600; }
.cd-ghost { position: fixed; z-index: 90; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 4px 16px rgba(0,0,0,.4); pointer-events: none; }

/* ===== v1.4 ===== */
.ly-multibar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; margin: 0 8px 8px; border-radius: var(--r-m); background: var(--surface-2); font-size: 13px; font-weight: 600; }
.ly-row.multi { outline: 2px dashed var(--accent-text); outline-offset: -2px; }
.to-num { width: 84px; min-height: 34px; padding: 4px 8px; }
.ref-win { position: absolute; z-index: 12; top: 70px; inset-inline-end: 16px; width: 252px; background: var(--chrome); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; }
.ref-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; cursor: move; touch-action: none; padding-bottom: 6px; }
.ref-head .seg button { padding: 4px 10px; font-size: 12px; }
.ref-canvas { display: block; width: 100%; height: auto; border-radius: 8px; background: var(--stage); }
.ref-grip { position: absolute; inset-inline-end: 2px; bottom: 2px; width: 18px; height: 18px; cursor: nwse-resize; touch-action: none; background: linear-gradient(135deg, transparent 50%, var(--muted) 50%); border-radius: 0 0 10px 0; }
.af-mode { width: auto; min-height: 32px; padding: 4px 8px; font-size: 13px; }
.af-holdctl { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.af-holdctl .btn.small { min-height: 28px; padding: 0 10px; }
.af.held::after { content: attr(data-hold); position: absolute; right: 4px; top: 3px; font-size: 10px; font-weight: 700; background: var(--accent); color: #fff; padding: 0 4px; border-radius: 4px; }
.g-thumb { position: relative; }
.g-thumb.picked { outline: 3px solid var(--accent-text); outline-offset: 2px; }
.g-check { position: absolute; top: 8px; inset-inline-start: 8px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 1; }
.g-check.on { background: var(--accent); }
.g-check .ic { width: 16px; height: 16px; color: #fff; }
.g-selbar { position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: 16px; border-radius: var(--r-l); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.g-selcount { font-weight: 600; margin-inline-end: 6px; }
.pv { position: fixed; inset: 0; z-index: 85; background: rgba(8, 8, 14, .96); display: grid; place-items: center; touch-action: pan-y; }
.pv-img { max-width: 92vw; max-height: 82vh; object-fit: contain; box-shadow: 0 10px 40px rgba(0,0,0,.6); background: #fff; }
.pv-name { position: fixed; top: calc(16px + var(--sat)); left: 0; right: 0; text-align: center; color: #fff; font-weight: 500; }
.pv-btn { position: fixed; width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; display: grid; place-items: center; }
.pv-close { top: calc(10px + var(--sat)); inset-inline-end: 14px; }
.pv-prev { top: 50%; inset-inline-start: 14px; transform: translateY(-50%); }
.pv-next { top: 50%; inset-inline-end: 14px; transform: translateY(-50%); }
[dir="rtl"] .pv-prev .ic, [dir="rtl"] .pv-next .ic { transform: scaleX(-1); }
.pv-open { position: fixed; bottom: calc(24px + var(--sab)); left: 50%; transform: translateX(-50%); }

/* ===== v1.5: tabs, home, templates, explore, logo maker ===== */
#gallery { padding-bottom: calc(64px + var(--sab)); }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px calc(8px + var(--sar)) calc(6px + var(--sab)) calc(8px + var(--sal)); background: var(--chrome); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tabbar button { display: grid; justify-items: center; gap: 2px; padding: 6px 4px; font-size: 12px; color: var(--muted); border-radius: 12px; }
.tabbar button .ic { width: 24px; height: 24px; }
.tabbar button.on { color: var(--text); }
.tabbar button.on .ic { color: var(--accent-text); }
@media (min-width: 900px) { .tabbar { left: 50%; right: auto; transform: translateX(-50%); bottom: 14px; width: 460px; border-radius: 20px; border: 1px solid var(--line); box-shadow: var(--shadow); padding-bottom: 6px; } #gallery { padding-bottom: 90px; } }
.home-cards { display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; margin-bottom: 26px; }
.prompt-card, .tip-card { border-radius: var(--r-l); padding: 18px 20px; display: grid; gap: 8px; align-content: start; }
.prompt-card { background: var(--brand-grad); color: #fff; }
.prompt-card .btn { justify-self: start; background: #fff; color: #1d1530; border: 0; }
.tip-card { background: var(--surface); border: 1px solid var(--line); }
.pc-kicker { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; opacity: .85; }
.pc-text { margin: 0; font-size: 22px; font-weight: 600; line-height: 1.25; }
.tip-text { margin: 0; color: var(--text); }
.tpl-row, .ex-row { display: grid; grid-auto-flow: column; grid-auto-columns: 170px; gap: 16px; overflow-x: auto; padding-bottom: 12px; margin-bottom: 22px; scrollbar-width: thin; }
.ex-row { grid-auto-columns: 200px; }
.tc { display: grid; gap: 4px; text-align: start; padding: 0; min-width: 0; }
.tc-frame { aspect-ratio: 1; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; padding: 10px; overflow: hidden; }
.tc:hover .tc-frame { border-color: var(--accent-text); }
.tc-img { max-width: 100%; max-height: 100%; display: block; box-shadow: 0 2px 10px rgba(0,0,0,.25); border-radius: 3px; background: #fff; }
.logo-frame { background: #fff; }
.logo-frame canvas { width: 100%; height: 100%; }
.tc-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; }
.tc-dim { font-size: 12px; color: var(--muted); }
.tpl-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tpl-tools .chips { margin: 0; }
.chip { padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; font-weight: 500; }
.chip.on { background: var(--text); color: var(--bg); border-color: transparent; }
.chips.small .chip { padding: 5px 10px; font-size: 12px; }
.tpl-grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 20px 16px; }
.ex-grid { columns: 4 220px; column-gap: 16px; }
.ex-card { break-inside: avoid; margin-bottom: 16px; border-radius: var(--r-l); overflow: hidden; background: var(--surface); border: 1px solid var(--line); cursor: pointer; position: relative; }
.ex-card img { width: 100%; display: block; background: #fff; }
.ex-meta { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.ex-text { flex: 1; min-width: 0; display: grid; }
.ex-text b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-text span { font-size: 12px; color: var(--muted); }
.ex-like { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); padding: 6px 8px; border-radius: 999px; }
.ex-like .ic { width: 18px; height: 18px; }
.ex-like.on, .ex-like.on .ic { color: #e0359a; }
.ex-like.on .ic path { fill: #e0359a; }
.ex-feat { position: absolute; top: 8px; inset-inline-start: 8px; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--brand-grad); color: #fff; }
.ex-card.compact .ex-meta { padding: 8px 10px; }
.ex-empty { grid-column: 1 / -1; padding: 20px; border-radius: var(--r-l); border: 1px dashed var(--line); color: var(--muted); }
.ex-more { display: flex; justify-content: center; margin: 10px 0 30px; }
.pv-actions { position: fixed; bottom: calc(24px + var(--sab)); left: 50%; transform: translateX(-50%); display: flex; gap: 10px; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; max-height: 60vh; overflow-y: auto; }
.pick { display: grid; gap: 4px; font-size: 12px; text-align: start; }
.pick img { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--stage); border-radius: 8px; }
.browse-tpl { margin-top: 18px; }
.logo-maker { display: grid; gap: 10px; }
.logo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.logo-opt { display: grid; gap: 4px; justify-items: center; padding: 8px; border-radius: var(--r-m); border: 1px solid var(--line); background: #fff; color: #333; font-size: 12px; font-weight: 500; }
.logo-opt canvas { width: 100%; height: auto; }
.logo-opt:hover, .logo-opt.on { border-color: var(--accent-text); box-shadow: 0 0 0 3px var(--accent-text) inset; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; max-height: 180px; overflow-y: auto; }
.ic-btn { aspect-ratio: 1; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); border: 1px solid transparent; }
.ic-btn canvas { width: 36px; height: 36px; }
.ic-btn.on { border-color: var(--accent-text); }
.pal-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pal-sw { display: flex; border-radius: 8px; overflow: hidden; border: 2px solid transparent; }
.pal-sw span { width: 14px; height: 28px; }
.pal-sw.on { border-color: var(--text); }
@media (max-width: 699px) { .home-cards { grid-template-columns: 1fr; } .ex-grid { columns: 2; column-gap: 10px; } .tpl-grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .tpl-row { grid-auto-columns: 140px; } }

.ex-row .ex-empty { width: min(520px, 80vw); }
