/* Layercake editor: a dark, compact app UI. */
@font-face { font-family: "Bricolage"; src: url("../fonts/bricolage-grotesque-var.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }

:root {
  --bg: #16131f; --panel: #1e1a2a; --panel2: #262036; --panel3: #2f2842; --line: #352d4a; --line2: #45395f;
  --text: #ece8f4; --muted: #a59cb8; --faint: #7a7192;
  --accent: #8b6cff; --accent2: #a48bff; --pink: #ff5c8a; --sun: #ffd23f; --mint: #3ddc97; --danger: #ff6b6b;
  --r: 10px; --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body.lc { background: var(--bg); color: var(--text); font: 13px/1.4 var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent2); }
.ic { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.lc-app { display: grid; grid-template-rows: 44px 40px 1fr 26px; height: 100vh; height: 100dvh; }

/* ---------- top bar */
.lc-top { display: flex; align-items: center; gap: 10px; padding: 0 10px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.lc-logo { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font: 800 15px "Bricolage", var(--font); letter-spacing: -.01em; flex: none; }
.lc-menubar { display: flex; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.lc-menubar::-webkit-scrollbar { display: none; }
.mb-btn { background: none; border: 0; padding: 6px 9px; border-radius: 7px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.mb-btn:hover, .mb-btn.is-open { background: var(--panel3); color: var(--text); }
.lc-docname { margin-left: auto; width: min(240px, 22vw); background: transparent; border: 1px solid transparent; border-radius: 7px; padding: 5px 8px; text-align: center; color: var(--text); }
.lc-docname:hover, .lc-docname:focus { border-color: var(--line2); background: var(--panel2); outline: none; }
.lc-top-right { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }
.lc-account { display: flex; align-items: center; gap: 8px; }
.acct { display: flex; align-items: center; gap: 6px; background: none; border: 0; cursor: pointer; padding: 0; }
.acct-av { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--pink), var(--accent)); color: #fff; font-weight: 700; }

.menu { position: fixed; z-index: 60; min-width: 250px; max-height: calc(100vh - 60px); overflow: auto; padding: 6px; background: var(--panel2); border: 1px solid var(--line2); border-radius: 10px; box-shadow: 0 18px 50px -10px rgba(0,0,0,.6); }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; text-align: left; padding: 7px 10px; border-radius: 6px; cursor: pointer; color: var(--text); }
.menu-item span:first-child { flex: 1; }
.menu-item:hover:not(:disabled) { background: var(--accent); color: #fff; }
.menu-item:disabled { color: var(--faint); cursor: default; }
.menu-item kbd { font: 11px var(--font); color: var(--faint); }
.menu-item:hover:not(:disabled) kbd { color: rgba(255,255,255,.8); }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }

/* ---------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-xs { padding: 3px 8px; font-size: 11.5px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-ghost { background: var(--panel2); border-color: var(--line2); color: var(--text); }
.btn-ghost:hover { background: var(--panel3); }
.btn-danger { background: var(--danger); color: #1a0505; }
.btn-pro { background: linear-gradient(135deg, var(--sun), var(--pink)); color: #1a0f0a; }
.btn-pro:hover { filter: brightness(1.08); }
.icon-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: none; border: 0; color: var(--muted); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--panel3); color: var(--text); }
.icon-btn.is-on { color: var(--sun); }
.mini-link { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 11.5px; text-decoration: underline; }
.pro-badge { display: inline-block; padding: 1px 5px; border-radius: 4px; background: linear-gradient(135deg, var(--sun), var(--pink)); color: #1a0f0a; font: 800 9.5px var(--font); letter-spacing: .06em; vertical-align: middle; }

/* ---------- options bar */
.lc-options { display: flex; align-items: center; gap: 14px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; white-space: nowrap; scrollbar-width: thin; }
.op-tool { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--text); padding-right: 12px; border-right: 1px solid var(--line); }
.op { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); }
.op-l { color: var(--muted); }
.op-check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; }
.op-hint { color: var(--faint); font-size: 12px; }
.op select, .fld select, .fld input:not([type=range]):not([type=checkbox]):not([type=color]), .p-text, .lt-rename {
  background: var(--panel2); border: 1px solid var(--line2); border-radius: 7px; padding: 4px 7px; color: var(--text); min-width: 0; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--panel2); border: 0; padding: 4px 10px; color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line2); }
.seg button.is-on { background: var(--accent); color: #fff; }
.rng { display: inline-flex; align-items: center; gap: 6px; }
.rng input[type=range] { width: 110px; accent-color: var(--accent); }
.rng-n { width: 56px; background: var(--panel2); border: 1px solid var(--line2); border-radius: 6px; padding: 2px 5px; color: var(--text); }
input[type=checkbox] { accent-color: var(--accent); }
input[type=color] { width: 34px; height: 26px; padding: 0; border: 1px solid var(--line2); border-radius: 6px; background: none; cursor: pointer; }

/* ---------- main area */
.lc-main { display: grid; grid-template-columns: 48px 1fr 300px; min-height: 0; }
.lc-tools { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; scrollbar-width: none; }
.tb-btn { display: grid; place-items: center; width: 36px; height: 34px; border-radius: 8px; background: none; border: 0; color: var(--muted); cursor: pointer; flex: none; }
.tb-btn:hover { background: var(--panel3); color: var(--text); }
.tb-btn.is-on { background: var(--accent); color: #fff; }
.lc-stage { position: relative; overflow: hidden; background: #0f0d16; background-image: radial-gradient(rgba(255,255,255,.04) 1px, transparent 1px); background-size: 18px 18px; }
.lc-view, .lc-overlay { position: absolute; inset: 0; display: block; }
.lc-overlay { touch-action: none; }
.lc-drop { position: absolute; inset: 12px; display: none; place-items: center; border: 2px dashed var(--accent); border-radius: 14px; background: rgba(139,108,255,.12); font-size: 16px; font-weight: 700; pointer-events: none; }
.lc-stage.is-drop .lc-drop { display: grid; }

.lc-side { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; }
.panel { border-bottom: 1px solid var(--line); padding: 10px 12px 12px; }
.panel-h { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); }
.panel-props { flex: 0 1 auto; }
.panel-layers { flex: 1 0 auto; }

/* colors */
.colors-main { display: flex; align-items: center; gap: 14px; }
.sw-stack { position: relative; width: 58px; height: 50px; }
.sw { position: absolute; width: 36px; height: 36px; border-radius: 8px; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line2); cursor: pointer; overflow: hidden; }
.sw input { opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.sw-fg { left: 0; top: 0; z-index: 1; }
.sw-bg { right: 0; bottom: 0; }
.colors-btns { display: flex; align-items: center; gap: 6px; }
.p-sub { margin: 10px 0 5px; font-size: 11px; color: var(--faint); }
.swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.chip-sw { width: 20px; height: 20px; border-radius: 5px; border: 1px solid rgba(255,255,255,.15); cursor: pointer; padding: 0; }
.chip-add { display: grid; place-items: center; background: var(--panel2); color: var(--muted); border-style: dashed; font-weight: 700; line-height: 1; }
.muted-xs { color: var(--faint); font-size: 11.5px; margin: 0; }

/* properties */
.p-sec { padding: 4px 0 10px; }
.p-sec + .p-sec { border-top: 1px solid var(--line); padding-top: 10px; }
.p-h { margin: 0 0 8px; font-size: 12px; font-weight: 700; color: var(--text); }
.fld { display: grid; grid-template-columns: 82px 1fr; align-items: center; gap: 8px; margin: 6px 0; color: var(--muted); }
.fld .rng input[type=range] { width: 100%; min-width: 60px; flex: 1; }
.fld .rng { display: flex; }
.fld-l { font-size: 12px; }
.p-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; }
.p-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.p-row2 .fld { grid-template-columns: 1fr; gap: 3px; }
.p-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.p-grid .fld { grid-template-columns: 44px 1fr; }
.p-grid input { width: 100%; }
.p-text { width: 100%; resize: vertical; min-height: 54px; font-size: 13px; }
.align-row { gap: 4px; }
.fx { padding: 4px 0; }
.fx-h { font-weight: 600; color: var(--text); }
.fx-body { padding: 2px 0 4px 22px; }

/* layers */
.layer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.lt { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; user-select: none; }
.lt:hover { background: var(--panel2); }
.lt.is-active { background: var(--panel3); border-color: var(--accent); }
.lt.is-hidden .lt-name, .lt.is-hidden .lt-thumbs { opacity: .45; }
.lt.is-drag { opacity: .4; }
.lt.is-over { box-shadow: inset 0 2px 0 var(--sun); }
.lt-thumbs { display: flex; gap: 3px; }
.lt-thumb { border-radius: 4px; background: repeating-conic-gradient(#d9d9e3 0 25%, #fff 0 50%) 0 0 / 8px 8px; border: 1px solid var(--line2); }
.lt-thumb.is-target { outline: 2px solid var(--sun); outline-offset: 1px; }
.lt-kind { font-weight: 800; color: var(--accent2); width: 12px; text-align: center; }
.lt-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lt-rename { flex: 1; min-width: 0; }
.lt-meta { color: var(--faint); font-size: 11px; }
.lt-lock { width: 22px; height: 22px; opacity: .55; }
.lt-lock.is-on { opacity: 1; }
.layer-actions { display: flex; gap: 2px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }

/* status */
.lc-status { display: flex; align-items: center; gap: 10px; padding: 0 10px; background: var(--panel); border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.lc-status .icon-btn { width: 22px; height: 22px; font-size: 15px; }
.st-zoom { background: none; border: 0; color: var(--text); cursor: pointer; min-width: 46px; }
.st-spacer { flex: 1; }

/* ---------- modals */
.md-wrap { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(8,6,14,.6); backdrop-filter: blur(3px); }
.md { width: min(440px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.7); }
.md-wide { width: min(860px, 100%); }
.md-side { margin-left: auto; margin-right: 320px; }
.md-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.md-head h2 { margin: 0; font: 700 17px "Bricolage", var(--font); }
.md-x { background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; }
.md-body { padding: 8px 16px 14px; overflow-y: auto; }
.md-body p { color: var(--muted); }
.md-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.lc-toast { position: fixed; left: 50%; bottom: 40px; transform: translate(-50%, 20px); z-index: 70; max-width: min(520px, 90vw); padding: 10px 16px; border-radius: 10px; background: #fff; color: #16131f; font-weight: 600; box-shadow: 0 12px 30px rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.lc-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.preset { display: grid; gap: 2px; justify-items: start; padding: 10px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line2); cursor: pointer; text-align: left; color: var(--text); }
.preset span:last-child { color: var(--faint); font-size: 11.5px; }
.preset.is-on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.preset-shape { display: block; height: 44px; margin-bottom: 6px; border-radius: 3px; background: linear-gradient(135deg, var(--accent), var(--pink)); }
.new-custom { margin-top: 12px; grid-template-columns: 1fr 1fr 1fr; }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.tpl { position: relative; display: grid; gap: 3px; padding: 8px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line2); cursor: pointer; text-align: left; color: var(--text); }
.tpl:hover { border-color: var(--accent); }
.tpl span { color: var(--faint); font-size: 11.5px; }
.tpl-thumb { display: grid; place-items: center; height: 150px; border-radius: 8px; overflow: hidden; background: var(--bg); margin-bottom: 4px; }
.tpl-thumb canvas, .tpl-thumb img { max-width: 100%; max-height: 150px; }
.tpl-thumb.is-locked { background: linear-gradient(135deg, #2b2340, #3a2550); }
.tpl-lock { display: grid; justify-items: center; gap: 6px; color: var(--muted); }
.tpl-del { position: absolute; top: 12px; right: 12px; background: rgba(0,0,0,.5); }

.start-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.start-card { display: grid; gap: 4px; justify-items: start; padding: 16px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line2); color: var(--text); text-align: left; cursor: pointer; }
.start-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.start-card .ic { color: var(--accent2); margin-bottom: 6px; }
.start-card span { color: var(--faint); font-size: 12px; }
.resume { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: rgba(139,108,255,.14); border: 1px solid rgba(139,108,255,.4); }
.usage { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; color: var(--muted); }
.anchor-grid { display: grid; grid-template-columns: repeat(3, 24px); gap: 4px; }
.anchor-grid button { width: 24px; height: 24px; border-radius: 5px; border: 1px solid var(--line2); background: var(--panel2); cursor: pointer; }
.anchor-grid button.is-on { background: var(--accent); }
.flt .fld { grid-template-columns: 110px 1fr; }
.curve-wrap { display: grid; justify-items: center; gap: 6px; margin: 6px 0; }
.curve { width: 220px; height: 220px; border-radius: 8px; border: 1px solid var(--line2); cursor: crosshair; touch-action: none; }
.kb-table { width: 100%; border-collapse: collapse; }
.kb-table td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
.kb-table kbd { font: 12px var(--font); color: var(--text); background: var(--panel2); border: 1px solid var(--line2); border-radius: 5px; padding: 2px 6px; }
.upsell-lead { font-size: 14px; color: var(--text) !important; }
.upsell-price { font-size: 14px; }
.upsell-price b { font: 800 30px "Bricolage", var(--font); color: var(--text); }
.upsell-list { list-style: none; padding: 0; margin: 8px 0 12px; display: grid; gap: 5px; }
.upsell-list li { display: flex; gap: 8px; align-items: center; }
.upsell-list .ic { color: var(--mint); }
.acct-menu .p-row { gap: 8px; }

.lc-small-screen { display: none; }

@media (max-width: 900px) {
  .lc-main { grid-template-columns: 44px 1fr; grid-template-rows: 1fr minmax(0, 38vh); }
  .lc-side { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
  .lc-docname { display: none; }
  .md-side { margin: auto; }
}
@media (max-width: 560px) {
  .lc-logo span, .lc-top .btn-pro { display: none; }
  .lc-small-screen { display: block; position: fixed; left: 8px; right: 8px; bottom: 34px; z-index: 5; padding: 6px 10px; border-radius: 8px; background: var(--panel2); color: var(--muted); font-size: 12px; pointer-events: none; opacity: .9; }
}
@keyframes lc-fade { to { opacity: 0; visibility: hidden; } }
.lc-small-screen { animation: lc-fade .6s 7s forwards; }
