:root {
  --page: #e9e7f1; --bg: #fbfaff; --dot: #e0ddec;
  --panel: #ffffff; --line: #efedf6; --line2: #e5e2ef;
  --text: #211f2b; --muted: #8c8a99;
  --accent: #e75c5c; --accent2: #f57878; --accent-press: #cd4848; --accent-soft: #fdecec;
  --seg: #f1eff8; --pill: #f5f4fa; --danger: #e15a5a;
  --card-sh: 0 1px 2px rgba(40,30,80,.04), 0 8px 24px rgba(40,30,80,.06);
  --radius: 20px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: "Inter", "Segoe UI", system-ui, sans-serif; background: var(--page); color: var(--text); display: flex; flex-direction: column; gap: 12px; padding: 12px; overflow: hidden; -webkit-font-smoothing: antialiased; }

/* ---------- header ---------- */
header { position: relative; flex-shrink: 0; height: 64px; display: flex; align-items: center; gap: 16px; padding: 0 14px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--card-sh); }
.brand { display: flex; align-items: center; gap: 11px; flex-shrink: 0; padding-right: 4px; }
.logo { width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(135deg, #f57878, #e75c5c); display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(231,92,92,.35); }
.logo svg { width: 20px; height: 20px; }
/* black logo SVG rendered white, transparent background kept */
.brandmark { object-fit: contain; display: block; filter: brightness(0) invert(1); }
.logo .brandmark { width: 26px; height: 26px; }
.cs-logo .brandmark { width: 40px; height: 40px; }
.proj { display: flex; flex-direction: column; gap: 1px; }
.proj-row { display: flex; align-items: center; gap: 5px; }
.proj-name { font-size: 15px; font-weight: 700; letter-spacing: -.2px; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-caret { font-size: 10px; color: var(--muted); }
.proj-sub { font-size: 11.5px; color: var(--muted); }

.presets { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: calc(100% - 540px); display: flex; gap: 3px; background: var(--seg); border-radius: 13px; padding: 4px; overflow-x: auto; }
.preset { border: none; background: none; border-radius: 9px; padding: 7px 12px; font-size: 12.5px; font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap; display: flex; align-items: baseline; gap: 6px; transition: .12s; font-family: inherit; }
.preset:hover { color: var(--text); }
.preset:not(.active):hover .pg, .preset:not(.active):hover .pdim { color: var(--text); }
.preset.active { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(231,92,92,.32); }
.preset .pg { color: var(--muted); font-weight: 600; }
.preset .pn { font-weight: 600; }
.preset .pdim { font-size: 11px; color: var(--muted); font-weight: 500; }
.preset.active .pg, .preset.active .pdim { color: rgba(255,255,255,.75); }

.htools { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.zoom { display: flex; align-items: center; gap: 2px; border: 1px solid var(--line2); border-radius: 10px; padding: 2px; background: var(--panel); }
.zbtn { width: 28px; height: 28px; border: none; background: none; border-radius: 8px; font-size: 17px; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.zbtn:hover { background: var(--seg); color: var(--text); }
#zoomLabel { font-size: 12px; min-width: 42px; text-align: center; color: var(--text); font-weight: 500; cursor: text; }
.zoom-input { width: 44px; border: 1px solid var(--accent); border-radius: 6px; padding: 2px 2px; font-size: 12px; text-align: center; font-family: inherit; color: var(--text); outline: none; }
.selwrap { position: relative; }
.selwrap select { appearance: none; -webkit-appearance: none; background: var(--panel); border: 1px solid var(--line2); color: var(--text); border-radius: 10px; padding: 9px 28px 9px 13px; font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer; }
.selwrap .chev { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 10px; color: var(--muted); pointer-events: none; }
.dl { display: flex; align-items: center; gap: 8px; background: var(--accent); color: #fff; border: none; border-radius: 11px; padding: 10px 18px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; box-shadow: 0 4px 14px rgba(231,92,92,.34); transition: .12s; }
.dl:hover { background: var(--accent-press); }
.dl svg { width: 16px; height: 16px; }

/* ---------- layout ---------- */
.app { flex: 1; display: flex; gap: 12px; min-height: 0; }
.rail { flex-shrink: 0; width: 80px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--card-sh); display: flex; flex-direction: column; padding: 12px 10px; gap: 4px; }
.rnav { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 12px 4px; border-radius: 14px; font-size: 11px; font-weight: 500; color: var(--muted); cursor: pointer; transition: .12s; }
.rnav svg { width: 23px; height: 23px; }
.rnav:hover { color: var(--text); background: var(--seg); }
.rnav.active { color: var(--accent); background: var(--accent-soft); }
.rail.simple { width: 188px; padding: 14px 12px; gap: 6px; }
.rail.simple .rnav { flex-direction: row; justify-content: flex-start; align-items: center; gap: 0; padding: 13px 16px; font-size: 15px; font-weight: 600; border-radius: 12px; color: var(--text); }
.rail.simple .rnav:hover { background: var(--seg); color: var(--text); }
.rail.simple .rnav.active { background: var(--seg); color: var(--text); }

/* ---------- editor / stage ---------- */
.editor { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; gap: 12px; }
.stage { flex: 1; min-height: 0; min-width: 0; background-color: var(--bg); background-image: radial-gradient(var(--dot) 1.5px, transparent 1.5px); background-size: 24px 24px; border-radius: var(--radius); box-shadow: var(--card-sh); display: flex; align-items: center; justify-content: safe center; overflow: auto; padding: 40px 34px; position: relative; }
.stage-label { position: absolute; left: 18px; top: 12px; z-index: 6; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.shotrow { display: flex; align-items: center; gap: 28px; padding: 10px 8px; }
.shotframe { position: relative; flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; }
.shothead { display: flex; align-items: center; gap: 6px; height: 24px; cursor: grab; }
.shothead:active { cursor: grabbing; }
.shotnum { font-size: 11px; font-weight: 700; color: var(--muted); background: var(--seg); border-radius: 6px; padding: 2px 9px; }
.shotframe.active .shotnum { background: var(--accent-soft); color: var(--accent); }
.shot-active { font-size: 9.5px; font-weight: 800; letter-spacing: .5px; color: #fff; background: var(--accent); border-radius: 6px; padding: 3px 8px; }
.shot-del { margin-left: auto; width: 22px; height: 22px; border: none; background: none; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; border-radius: 6px; opacity: 0; transition: .12s; }
.shotframe:hover .shot-del { opacity: 1; }
.shot-del:hover { color: var(--danger); background: #fdecec; }
.shot-del svg { width: 15px; height: 15px; }
.shotframe canvas, .shotframe img.shotimg { display: block; border-radius: 6px; box-shadow: 0 4px 20px rgba(40,30,80,.13); background: #fff; }
.shotframe img.shotimg { cursor: pointer; }
.shotframe.active:not(.single) canvas, .shotframe.active:not(.single) img.shotimg { outline: 3px solid var(--accent); outline-offset: 2px; }
.shotframe.dragging { opacity: .5; }
.shotframe.drop-l::before, .shotframe.drop-r::before { content: ""; position: absolute; top: 30px; bottom: 0; width: 4px; border-radius: 2px; background: var(--accent); }
.shotframe.drop-l::before { left: -16px; }
.shotframe.drop-r::before { right: -16px; }
.shot-addframe { flex-shrink: 0; align-self: stretch; min-width: 96px; margin-top: 30px; border: 2px dashed var(--line2); border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); cursor: pointer; transition: .12s; }
.shot-addframe:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.shot-addframe span { font-size: 30px; line-height: 1; }
.shot-addframe small { font-size: 11px; font-weight: 600; }
.confirm-ov { position: fixed; inset: 0; z-index: 9999; background: rgba(20,16,40,.42); display: flex; align-items: center; justify-content: center; padding: 20px; animation: cf-in .15s ease; }
.confirm-box { background: #fff; border-radius: 18px; padding: 26px 24px 20px; max-width: 360px; width: 100%; box-shadow: 0 24px 70px rgba(20,16,40,.32); }
.confirm-box p { margin: 0 0 20px; font-size: 14.5px; color: var(--text); line-height: 1.55; }
.confirm-btns { display: flex; gap: 10px; justify-content: flex-end; }
.confirm-btns button { padding: 10px 20px; }
@keyframes cf-in { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: scale(1); } }
.rail-auth { margin-top: auto; padding-top: 10px; }
.auth-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 11px 14px; border: 1px solid var(--line2); background: #fff; border-radius: 12px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text); font-family: inherit; transition: .12s; }
.auth-btn:hover { border-color: var(--accent); color: var(--accent); }
.auth-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.auth-user { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 1px solid var(--line2); background: #fff; border-radius: 12px; cursor: pointer; font-family: inherit; transition: .12s; }
.auth-user:hover { border-color: var(--accent); }
.auth-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; }
.auth-avatar img { width: 100%; height: 100%; object-fit: cover; }
.auth-name { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auth-menu-ov { position: fixed; inset: 0; z-index: 9998; }
.auth-menu { position: fixed; background: #fff; border-radius: 12px; box-shadow: 0 12px 40px rgba(20,16,40,.25); padding: 7px; }
.auth-menu-email { font-size: 11.5px; color: var(--muted); padding: 6px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auth-menu-out { width: 100%; text-align: left; padding: 9px 10px; border: none; background: none; border-radius: 8px; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--danger); font-family: inherit; }
.auth-menu-out:hover { background: #fdecec; }
.auth-menu-admin { width: 100%; text-align: left; padding: 9px 10px; border: none; background: none; border-radius: 8px; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--text); font-family: inherit; }
.auth-menu-admin:hover { background: var(--accent-soft); color: var(--accent); }

/* admin dashboard */
.admin-ov { position: fixed; inset: 0; z-index: 9999; background: rgba(20,16,40,.45); display: flex; align-items: center; justify-content: center; padding: 24px; animation: cf-in .15s ease; }
.admin-card { background: #fff; border-radius: 18px; width: 100%; max-width: 880px; max-height: 86vh; display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(20,16,40,.34); overflow: hidden; }
.admin-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line2); }
.admin-head h2 { margin: 0; font-size: 18px; font-weight: 800; color: var(--text); }
.admin-close { border: none; background: none; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.admin-close:hover { color: var(--text); }
.admin-body { padding: 18px 22px 22px; overflow: auto; }
.admin-count { font-size: 12px; color: var(--muted); margin-bottom: 10px; font-weight: 600; }
.admin-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-tbl th { text-align: left; padding: 9px 12px; color: var(--muted); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; border-bottom: 2px solid var(--line2); white-space: nowrap; }
.admin-tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--text); white-space: nowrap; }
.admin-tbl tbody tr:hover { background: var(--pill); }
.admin-tbl .admin-num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.auth-ov { position: fixed; inset: 0; z-index: 9999; background: rgba(20,16,40,.45); display: flex; align-items: center; justify-content: center; padding: 20px; animation: cf-in .15s ease; }
.auth-card { position: relative; background: #fff; border-radius: 20px; padding: 32px 30px 26px; width: 100%; max-width: 380px; box-shadow: 0 24px 70px rgba(20,16,40,.34); }
.auth-close { position: absolute; right: 14px; top: 12px; border: none; background: none; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; }
.auth-brand { font-size: 15px; font-weight: 800; color: var(--accent); letter-spacing: -.3px; margin-bottom: 14px; }
.auth-title { margin: 0 0 4px; font-size: 22px; font-weight: 800; color: var(--text); }
.auth-sub { margin: 0 0 20px; font-size: 13.5px; color: var(--muted); }
.auth-note { background: #fff7e8; color: #946200; font-size: 12px; padding: 9px 12px; border-radius: 9px; margin-bottom: 16px; line-height: 1.5; }
.auth-google { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 12px; border: 1px solid var(--line2); background: #fff; border-radius: 12px; font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer; font-family: inherit; transition: .12s; }
.auth-google:hover { background: var(--seg); }
.auth-div { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--muted); font-size: 12px; }
.auth-div::before, .auth-div::after { content: ""; flex: 1; height: 1px; background: var(--line2); }
.auth-input { width: 100%; padding: 12px 14px; border: 1px solid var(--line2); border-radius: 11px; font-size: 14px; font-family: inherit; color: var(--text); margin-bottom: 10px; outline: none; box-sizing: border-box; }
.auth-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.auth-err { display: none; background: #fdecec; color: var(--danger); font-size: 12.5px; padding: 9px 12px; border-radius: 9px; margin-bottom: 10px; line-height: 1.45; }
.auth-primary { width: 100%; padding: 13px; border: none; border-radius: 12px; background: var(--accent); color: #fff; font-size: 14.5px; font-weight: 700; cursor: pointer; font-family: inherit; box-shadow: 0 4px 14px rgba(231,92,92,.34); transition: .12s; }
.auth-primary:hover { background: var(--accent-press); }
.auth-primary:disabled { opacity: .6; cursor: default; }
.auth-toggle { display: block; width: 100%; text-align: center; margin-top: 14px; border: none; background: none; color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; }
.stage-label b { color: var(--text); font-weight: 600; }
canvas#main { display: block; box-shadow: 0 14px 44px rgba(50,40,90,.20); border-radius: 6px; }

/* context toolbar over canvas */
.ctxbar { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 20; display: none; align-items: center; gap: 2px; background: var(--panel); border: 1px solid var(--line2); border-radius: 13px; padding: 5px; box-shadow: 0 6px 22px rgba(40,30,80,.16); }
.ctxbar button { width: 34px; height: 34px; border: none; background: none; border-radius: 9px; color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.ctxbar button svg { width: 19px; height: 19px; }
.ctxbar button:hover { background: var(--seg); }
.ctxbar button.on { background: var(--accent-soft); color: var(--accent); }
.ctxmore { position: relative; }
.ctxmenu { display: none; position: absolute; top: 42px; right: 0; background: var(--panel); border: 1px solid var(--line2); border-radius: 12px; box-shadow: 0 8px 24px rgba(40,30,80,.18); padding: 5px; min-width: 150px; }
.ctxmenu button { display: block; width: 100%; text-align: left; border: none; background: none; padding: 9px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--text); cursor: pointer; font-family: inherit; }
.ctxmenu button:hover { background: var(--seg); }
.ctxmenu .danger-item { color: var(--danger); }

.fitbtn { position: absolute; left: 16px; bottom: 16px; z-index: 15; display: flex; align-items: center; gap: 7px; background: var(--panel); border: 1px solid var(--line2); border-radius: 11px; padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; font-family: inherit; box-shadow: 0 4px 16px rgba(40,30,80,.12); }
.fitbtn:hover { border-color: var(--accent); color: var(--accent); }
.fitbtn svg { width: 16px; height: 16px; }

/* ---------- filmstrip (shots) ---------- */
.filmstrip { flex-shrink: 0; display: flex; align-items: center; gap: 10px; height: 138px; padding: 0 16px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--card-sh); overflow-x: auto; overflow-y: hidden; }
.shot { position: relative; flex-shrink: 0; height: 104px; border: 2px solid var(--line2); border-radius: 10px; overflow: hidden; cursor: pointer; background: #fff; transition: .12s; }
.shot:hover { border-color: var(--accent2); }
.shot.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.shot img { display: block; width: 100%; height: 100%; object-fit: cover; }
.shot-idx { position: absolute; left: 5px; top: 4px; background: rgba(20,16,40,.62); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 7px; }
.shot-ctrl { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 2px; padding: 3px; background: linear-gradient(transparent, rgba(20,16,40,.6)); opacity: 0; transition: .12s; }
.shot:hover .shot-ctrl { opacity: 1; }
.shot-ctrl button { width: 22px; height: 22px; padding: 0; border: none; border-radius: 6px; background: rgba(255,255,255,.92); color: var(--text); font-size: 12px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.shot-ctrl button:hover { background: #fff; }
.shot-ctrl button:disabled { opacity: .3; cursor: default; }
.shot-add { flex-shrink: 0; width: 64px; height: 104px; border: 2px dashed var(--line2); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); cursor: pointer; transition: .12s; }
.shot-add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.shot-add span { font-size: 24px; line-height: 1; }
.shot-add small { font-size: 10px; font-weight: 600; }

/* ---------- panel ---------- */
.panel { width: 322px; flex-shrink: 0; background: var(--panel); border-radius: var(--radius); box-shadow: var(--card-sh); overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.ptitle { font-size: 15px; font-weight: 700; margin: 0; }
.phead { display: flex; align-items: center; gap: 12px; }
.chip { width: 42px; height: 42px; border-radius: 13px; background: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 4px 12px rgba(231,92,92,.3); }
.chip svg { width: 21px; height: 21px; }
.pmeta { display: flex; flex-direction: column; gap: 1px; }
.psub { font-size: 12px; color: var(--muted); }

.slabel { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.psec { font-size: 12px; text-transform: uppercase; letter-spacing: .9px; font-weight: 800; color: var(--text); margin-top: 22px; padding-top: 16px; border-top: 1.5px solid var(--line2); }
.psec:first-child { margin-top: 4px; padding-top: 0; border-top: none; }
.sec { display: flex; flex-direction: column; gap: 12px; }
.divider { height: 1px; background: var(--line); margin: 4px 0; }

.fam-tabs { display: flex; gap: 4px; background: var(--seg); border-radius: 11px; padding: 4px; }
.fam-tab { flex: 1; border: none; background: none; border-radius: 8px; padding: 8px 4px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; font-family: inherit; transition: .12s; }
.fam-tab:hover { color: var(--text); }
.fam-tab.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(40,35,80,.12); }

.ctrl { display: flex; flex-direction: column; gap: 8px; }
.ctrl-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--text); }
.pill { width: 58px; text-align: center; background: var(--pill); border: 1px solid var(--line2); color: var(--text); border-radius: 8px; padding: 5px 6px; font-size: 12.5px; font-weight: 600; font-family: inherit; -moz-appearance: textfield; }
.pill::-webkit-outer-spin-button, .pill::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 6px; background: var(--seg); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 2.5px solid #fff; cursor: pointer; box-shadow: 0 2px 6px rgba(50,40,90,.3); }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 2.5px solid #fff; cursor: pointer; box-shadow: 0 2px 6px rgba(50,40,90,.3); }

textarea, select.field { background: #fff; border: 1px solid var(--line2); color: var(--text); border-radius: 10px; padding: 9px 11px; font-size: 13px; font-family: inherit; width: 100%; }
textarea { resize: vertical; min-height: 60px; }
select.field { appearance: none; -webkit-appearance: none; cursor: pointer; }

.crow { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--text); }
.cwrap { display: flex; align-items: center; gap: 8px; background: var(--pill); border: 1px solid var(--line2); border-radius: 9px; padding: 4px 4px 4px 10px; }
.chex { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; text-transform: uppercase; }
input[type=color] { width: 26px; height: 26px; padding: 0; border: 1px solid var(--line2); border-radius: 7px; background: none; cursor: pointer; flex-shrink: 0; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: none; border-radius: 5px; }

.trow { display: flex; align-items: center; justify-content: space-between; font-size: 13.5px; font-weight: 500; color: var(--text); cursor: pointer; }
.switch { position: relative; width: 44px; height: 25px; flex-shrink: 0; }
.switch input { display: none; }
.switch i { position: absolute; inset: 0; background: var(--line2); border-radius: 999px; transition: .15s; }
.switch i::after { content: ""; position: absolute; width: 19px; height: 19px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: .15s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { left: 22px; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { width: 38px; height: 38px; border-radius: 11px; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); transition: .12s; }
.sw.active { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }

button.add { display: flex; align-items: center; justify-content: center; gap: 8px; background: #fff; color: var(--text); border: 1.5px dashed var(--line2); border-radius: 12px; width: 100%; padding: 13px; font-size: 13.5px; font-weight: 600; cursor: pointer; font-family: inherit; transition: .12s; }
button.add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.gridadd { border-style: solid; }
button.primary { background: var(--accent); color: #fff; border: none; border-radius: 9px; padding: 10px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; }
button.primary:hover { background: var(--accent-press); }
button.ghost { background: #fff; color: var(--muted); border: 1px solid var(--line2); border-radius: 9px; padding: 10px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; transition: .12s; }
button.ghost:hover { color: var(--text); border-color: var(--accent); }
button.danger { background: #fff; color: var(--danger); border: 1px solid var(--line2); border-radius: 9px; padding: 10px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; }
button.danger:hover { border-color: var(--danger); background: #fdf2f2; }
.pills { display: flex; gap: 8px; }
.iconbtns { display: flex; gap: 6px; }
.iconbtns button { flex: 1; height: 38px; border: 1px solid var(--line2); background: #fff; border-radius: 9px; color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: .12s; }
.iconbtns button:hover { border-color: var(--accent); }
.iconbtns button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.iconbtns button svg { width: 18px; height: 18px; }
.pills button { flex: 1; }

.grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.gridbtn { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 20px; border: 1px solid var(--line2); border-radius: 9px; background: #fff; cursor: pointer; transition: .12s; overflow: hidden; }
.gridbtn:hover { border-color: var(--accent); background: var(--accent-soft); }
.svg-grid { grid-template-columns: repeat(4, 1fr); }
.svgbtn { padding: 7px; }
.svgbtn svg { width: 100%; height: 100%; }
.icon-search { width: 100%; background: var(--pill) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%238c8a99' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 14px center; border: 1px solid var(--line2); border-radius: 999px; padding: 11px 16px 11px 38px; font-size: 13px; font-family: inherit; color: var(--text); outline: none; transition: .12s; }
.icon-search::placeholder { color: var(--muted); }
.icon-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.icon-grid { grid-template-columns: repeat(6, 1fr); gap: 7px; }
.icon-grid .gridbtn { padding: 9px; border-radius: 11px; }
/* export format menu (logo: PNG / SVG) */
.exp-menu { position: fixed; z-index: 120; background: #fff; border: 1px solid var(--line2); border-radius: 14px; box-shadow: 0 14px 38px rgba(40,30,80,.18); padding: 6px; min-width: 200px; display: flex; flex-direction: column; gap: 2px; }
.exp-item { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; background: none; border: none; border-radius: 9px; padding: 9px 12px; cursor: pointer; font-family: inherit; text-align: left; width: 100%; }
.exp-item span { font-weight: 700; font-size: 13px; color: var(--text); }
.exp-item small { font-size: 11px; color: var(--muted); }
.exp-item:hover { background: var(--accent-soft); }
.exp-item:hover span, .exp-item:hover small { color: var(--accent); }

/* color picker (logo background) */
.cp { display: flex; flex-direction: column; gap: 10px; }
.cp-sv { position: relative; width: 100%; height: 150px; border-radius: 12px; cursor: crosshair; touch-action: none; }
.cp-sv-handle { position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35), 0 1px 4px rgba(0,0,0,.4); transform: translate(-50%, -50%); pointer-events: none; }
.cp-toprow { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.cp-seg { display: flex; flex: 1; background: var(--seg); border-radius: 9px; padding: 3px; }
.cp-seg button { flex: 1; border: none; background: none; border-radius: 7px; padding: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; font-family: inherit; transition: .12s; }
.cp-seg button.active { background: #fff; color: var(--accent); box-shadow: 0 1px 3px rgba(40,35,80,.12); }
.cp-eye { width: 40px; height: 36px; flex-shrink: 0; border: 1px solid var(--line2); border-radius: 9px; background: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.cp-eye:hover { border-color: var(--accent); color: var(--accent); }
.cp-eye svg { width: 18px; height: 18px; }
.cp-grad-stops { display: flex; gap: 8px; }
.cp-stop { flex: 1; height: 32px; border-radius: 9px; border: 2px solid var(--line2); cursor: pointer; }
.cp-stop.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.cp-dirs { display: flex; gap: 8px; }
.cp-dir { flex: 1; height: 34px; border-radius: 9px; border: 2px solid var(--line2); cursor: pointer; padding: 0; transition: .12s; }
.cp-dir:hover { border-color: var(--accent); }
.cp-dir.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.cp-bar { position: relative; height: 14px; border-radius: 8px; cursor: pointer; touch-action: none; }
.cp-hue { background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%); }
.cp-alpha-wrap { position: relative; height: 14px; border-radius: 8px; cursor: pointer; touch-action: none; background-image: linear-gradient(45deg, #ccc 25%, transparent 25%), linear-gradient(-45deg, #ccc 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ccc 75%), linear-gradient(-45deg, transparent 75%, #ccc 75%); background-size: 12px 12px; background-position: 0 0, 0 6px, 6px -6px, -6px 0; }
.cp-alpha { position: absolute; inset: 0; border-radius: 8px; }
.cp-bar-handle { position: absolute; top: 50%; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 1px solid rgba(0,0,0,.25); box-shadow: 0 1px 4px rgba(0,0,0,.35); transform: translate(-50%, -50%); pointer-events: none; }
.cp-inputs { display: grid; grid-template-columns: 1.7fr 1fr 1fr 1fr 1fr; gap: 5px; }
.cp-field { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.cp-field input { width: 100%; text-align: center; border: 1px solid var(--line2); border-radius: 8px; padding: 7px 2px; font-size: 12px; font-family: inherit; color: var(--text); }
.cp-field input:focus { outline: none; border-color: var(--accent); }
.cp-field label { font-size: 10px; color: var(--muted); font-weight: 700; }
.cp-sw { display: flex; gap: 10px; align-items: stretch; margin-top: 9px; }
.cp-swap { flex: 0 0 auto; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line2); border-radius: 9px; background: #fff; color: var(--muted); cursor: pointer; transition: .12s; }
.cp-swap:hover { border-color: var(--accent); color: var(--accent); }
.cp-swap svg { width: 16px; height: 16px; }
.cp-preview { width: 54px; flex-shrink: 0; border-radius: 10px; border: 1px solid var(--line2); }
.cp-palette { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; flex: 1; }
.cp-palette button { aspect-ratio: 1; border: 1px solid rgba(0,0,0,.08); border-radius: 6px; cursor: pointer; padding: 0; transition: transform .1s; }
.cp-palette button:hover { transform: scale(1.12); }
.cpf { margin-top: 14px; display: flex; flex-direction: column; gap: 9px; }
.cp-sm { gap: 8px; }
.cp-sm .cp-sv { height: 116px; }
.cp-inputs4 { grid-template-columns: 1.6fr 1fr 1fr 1fr; }
.phone-grid { grid-template-columns: repeat(3, 1fr); }
.phone-grid .gridbtn { aspect-ratio: 3/4; padding: 4px; background: var(--bg); }
.phone-grid img { width: 100%; height: 100%; object-fit: contain; }

.layers { display: flex; flex-direction: column; gap: 6px; }
.layer { display: flex; align-items: center; gap: 8px; padding: 10px 11px; border: 1px solid var(--line2); border-radius: 11px; font-size: 13px; cursor: pointer; background: #fff; transition: .12s; }
.layer.sel { border-color: var(--accent); background: var(--accent-soft); }
.lgrip { width: 10px; height: 16px; color: var(--muted); flex-shrink: 0; cursor: grab; }
.lgrip:active { cursor: grabbing; }
.layer.dragging { opacity: .45; }
.layer.drop-before { box-shadow: inset 0 2px 0 0 var(--accent); }
.layer.drop-after { box-shadow: inset 0 -2px 0 0 var(--accent); }
.layer .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer .x { color: var(--muted); cursor: pointer; padding: 0 4px; }
.layer .x:hover { color: var(--danger); }
.layer .lk { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; color: var(--muted); cursor: pointer; opacity: 0; flex-shrink: 0; transition: .12s; }
.layer .lk svg { width: 15px; height: 15px; }
.layer:hover .lk { opacity: .45; }
.layer .lk:hover { opacity: 1; color: var(--text); }
.layer .lk.on { opacity: 1; color: var(--accent); }
.hintbox { font-size: 13px; color: var(--muted); line-height: 1.55; }
input[type=file] { display: none; }

/* ---------- coming-soon gate ---------- */
.cs-overlay { position: fixed; inset: 0; z-index: 99999; display: flex; align-items: center; justify-content: center; padding: 24px; background: linear-gradient(135deg, #e75c5c, #f57878 55%, #ffc1c1); animation: cs-fade .35s ease; }
.cs-overlay[hidden] { display: none; }
@keyframes cs-fade { from { opacity: 0; } to { opacity: 1; } }
.cs-card { width: min(520px, 100%); background: #fff; border-radius: 26px; padding: 40px 34px; text-align: center; box-shadow: 0 30px 80px rgba(30,20,70,.45); }
.cs-logo { width: 58px; height: 58px; margin: 0 auto 16px; border-radius: 17px; background: linear-gradient(135deg, #f57878, #e75c5c); display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 22px rgba(231,92,92,.4); }
.cs-logo svg { width: 30px; height: 30px; }
.cs-brand { font-size: 13px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--accent); margin-bottom: 14px; }
.cs-title { font-size: 27px; font-weight: 800; margin: 0 0 10px; color: var(--text); letter-spacing: -.5px; }
.cs-sub { font-size: 15px; line-height: 1.55; color: var(--muted); margin: 0 auto 26px; max-width: 400px; }
.cs-count { display: flex; gap: 10px; justify-content: center; }
.cs-box { flex: 1; max-width: 92px; background: var(--seg); border-radius: 14px; padding: 14px 6px; }
.cs-box b { display: block; font-size: 30px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1; }
.cs-box span { display: block; margin-top: 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
@media (max-width: 480px) { .cs-card { padding: 32px 20px; } .cs-title { font-size: 23px; } .cs-box b { font-size: 24px; } }

/* sticky footer in properties */
.pfooter { position: sticky; bottom: 0; margin: 8px -18px -18px; padding: 14px 18px; background: var(--panel); border-top: 1px solid var(--line); display: flex; gap: 8px; }
.pfooter button { flex: 1; }
