:root {
  color-scheme: dark;
  --bg: #0b0e14;
  --surface: #11151d;
  --surface-2: #171c26;
  --surface-3: #1d2330;
  --surface-4: #252c39;
  --border: #2b3342;
  --border-soft: #222936;
  --text: #f4f6fb;
  --text-2: #aeb6c7;
  --text-3: #737e91;
  --accent: #8678ff;
  --accent-2: #a298ff;
  --accent-soft: rgba(134, 120, 255, 0.16);
  --mint: #5fe0bc;
  --danger: #ff778c;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  letter-spacing: -0.005em;
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.svg-symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
.app-frame { height: 100vh; display: flex; flex-direction: column; min-width: 920px; }

.topbar {
  height: 64px;
  flex: 0 0 64px;
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 0 18px 0 20px;
  background: #0f131a;
  border-bottom: 1px solid var(--border-soft);
  z-index: 20;
}

.brand-lockup { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.brand-mark { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 10px; background: linear-gradient(145deg, #8d81ff, #5d50d9); box-shadow: 0 6px 18px rgba(117, 101, 255, .28); }
.brand-mark svg { width: 17px; height: 17px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.brand-name { font-size: 14px; font-weight: 750; letter-spacing: .01em; line-height: 15px; }
.brand-subtitle { color: var(--text-3); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; line-height: 14px; }

.document-strip { flex: 1; height: 100%; display: flex; align-items: center; }
.document-tab { height: 38px; min-width: 208px; display: flex; align-items: center; gap: 9px; padding: 0 12px; border: 1px solid var(--border); border-radius: 9px; background: rgba(30, 36, 48, .66); box-shadow: inset 0 1px 0 rgba(255,255,255,.025); }
.document-tab input { width: 120px; border: 0; outline: 0; padding: 0; background: transparent; color: var(--text); font-size: 12px; font-weight: 600; }
.document-tab input:focus { color: var(--accent-2); }
.status-dot, .live-dot { display: inline-block; width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 3px rgba(95, 224, 188, .11); }
.file-type { margin-left: auto; color: var(--text-3); font-size: 10px; font-weight: 700; letter-spacing: .08em; }

.top-actions { display: flex; align-items: center; gap: 8px; }
.top-divider, .toolbar-divider, .rail-divider { width: 1px; height: 24px; background: var(--border); margin: 0 5px; }
.icon-button, .tool-button { display: inline-grid; place-items: center; border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; transition: color .16s ease, background .16s ease, border-color .16s ease, transform .16s ease; }
.icon-button { width: 32px; height: 32px; border-radius: 7px; }
.icon-button.small { width: 27px; height: 27px; }
.icon-button.ghost { color: var(--text-3); }
.icon-button:hover, .tool-button:hover { color: var(--text); background: var(--surface-3); border-color: var(--border); }
.icon-button:active, .tool-button:active { transform: translateY(1px); }
.icon-button:disabled { opacity: .35; cursor: not-allowed; }
.icon-button svg, .tool-button svg, .secondary-button svg, .primary-button svg, .outline-button svg, .export-menu svg, .help-card svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.primary-button, .secondary-button, .outline-button { height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 7px; padding: 0 12px; border: 1px solid var(--border); cursor: pointer; font-size: 12px; font-weight: 650; transition: .16s ease; }
.primary-button { border-color: #8175f3; background: var(--accent); color: white; box-shadow: 0 6px 15px rgba(95, 80, 224, .2); }
.primary-button:hover { background: #978cff; border-color: #a097ff; transform: translateY(-1px); }
.secondary-button { background: var(--surface-3); color: var(--text-2); }
.secondary-button:hover, .outline-button:hover { border-color: var(--accent); color: var(--text); background: var(--surface-4); }
.button-caret { color: #d5d1ff; font-size: 16px; line-height: 8px; margin-left: 2px; }
.outline-button { height: 32px; background: transparent; color: var(--text-2); }
.outline-button.compact { height: 29px; padding: 0 9px; font-size: 11px; }
.outline-button:disabled, .transparent-button:disabled { opacity: .35; cursor: not-allowed; }

.main-shell { min-height: 0; flex: 1; display: grid; grid-template-columns: 64px minmax(0, 1fr) 318px; grid-template-rows: minmax(0, 1fr); overflow: hidden; }
.tool-rail { min-height: 0; overflow: hidden; display: flex; flex-direction: column; align-items: center; padding: 13px 0 14px; background: #10141b; border-right: 1px solid var(--border-soft); }
.tool-group { display: flex; flex-direction: column; gap: 5px; }
.tool-button { width: 39px; height: 39px; border-radius: 9px; }
.tool-button svg { width: 19px; height: 19px; }
.tool-button.active { color: #e9e7ff; background: var(--accent-soft); border-color: rgba(134, 120, 255, .3); box-shadow: inset 0 0 0 1px rgba(134, 120, 255, .06); }
.rail-divider { width: 28px; height: 1px; flex: 0 0 1px; margin: 13px 0; background: var(--border-soft); }
.rail-spacer { flex: 1; }
.profile-chip { width: 31px; height: 31px; display: grid; place-items: center; margin-top: 16px; border-radius: 50%; background: linear-gradient(135deg, #273040, #3c4860); color: #d6dcf4; font-size: 10px; font-weight: 800; border: 1px solid #4a5670; }

.editor-area { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #141921; }
.editor-toolbar { height: 48px; flex: 0 0 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; border-bottom: 1px solid var(--border-soft); background: rgba(18, 22, 30, .88); }
.toolbar-context, .toolbar-controls, .status-left, .status-right { display: flex; align-items: center; }
.toolbar-context { gap: 8px; color: var(--text-3); font-size: 11px; }
.context-label { color: var(--text-2); font-weight: 650; }
.context-separator { color: #4c566a; }
#selectionContext { color: var(--text-2); }
.toolbar-controls { gap: 7px; color: var(--text-3); font-size: 11px; }
.brush-controls { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; border: 1px solid rgba(134,120,255,.32); border-radius: 8px; background: rgba(134,120,255,.09); color: var(--text-2); }
.brush-controls[hidden] { display: none; }
.brush-title { color: var(--accent-2); font-size: 10px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.brush-select { display: inline-flex; align-items: center; gap: 5px; color: var(--text-3); font-size: 10px; }
.brush-select select { height: 22px; max-width: 92px; padding: 0 19px 0 5px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-2); color: var(--text-2); font-size: 10px; cursor: pointer; }
.brush-select select:focus { border-color: var(--accent); outline: none; }
.brush-color { width: 20px; height: 20px; padding: 2px; border: 1px solid var(--border); border-radius: 5px; background: transparent; cursor: pointer; }
.range-control { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 10px; }
.range-control input[type="range"] { width: 68px; accent-color: var(--accent); cursor: pointer; }
.range-control output { width: 35px; color: var(--text-2); font-size: 10px; font-variant-numeric: tabular-nums; text-align: right; }
.pressure-toggle { margin-left: 2px; }
.toggle-label { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.toggle-label input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-ui { position: relative; width: 26px; height: 15px; border: 1px solid #4b5569; border-radius: 999px; background: #272e3a; transition: .16s ease; }
.toggle-ui::after { content: ""; position: absolute; left: 2px; top: 2px; width: 9px; height: 9px; border-radius: 50%; background: #8993a6; transition: .16s ease; }
.toggle-label input:checked + .toggle-ui { border-color: var(--accent); background: rgba(134,120,255,.36); }
.toggle-label input:checked + .toggle-ui::after { left: 13px; background: #fff; }
.zoom-value { width: 39px; color: var(--text-2); text-align: center; font-variant-numeric: tabular-nums; }

.canvas-workspace { position: relative; min-height: 0; flex: 1; overflow: hidden; display: grid; place-items: center; background-color: #1a2029; background-image: radial-gradient(rgba(255,255,255,.07) .8px, transparent .8px); background-size: 16px 16px; touch-action: none; user-select: none; }
.canvas-stage { position: relative; display: grid; place-items: center; width: min(88%, 1100px); height: min(82%, 760px); transition: width .18s ease, height .18s ease; }
.stage-shadow { position: absolute; inset: 4% 2%; border-radius: 2px; box-shadow: 0 22px 45px rgba(0,0,0,.34), 0 3px 12px rgba(0,0,0,.22); pointer-events: none; }
#editorCanvas { position: relative; z-index: 1; width: 100%; height: 100%; display: block; overflow: visible; transform-origin: center center; transition: transform .18s ease; background: white; cursor: default; touch-action: none; user-select: none; }
#editorCanvas.is-panning { cursor: grabbing; }
#artboard { vector-effect: non-scaling-stroke; }
#canvasHitArea { cursor: default; }
#gridRect { opacity: .6; }
#gridRect.hidden { display: none; }

.empty-state { position: absolute; z-index: 5; left: 50%; top: 50%; width: 330px; padding: 24px; transform: translate(-50%, -50%); text-align: center; border: 1px solid rgba(139, 151, 178, .24); border-radius: 15px; background: rgba(23, 28, 38, .94); box-shadow: var(--shadow); backdrop-filter: blur(12px); }
.empty-state.hidden { display: none; }
.empty-icon { width: 44px; height: 44px; display: grid; place-items: center; margin: 0 auto 12px; border-radius: 13px; color: var(--accent-2); background: var(--accent-soft); }
.empty-icon svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.empty-state h2 { margin: 0 0 6px; font-size: 16px; letter-spacing: -.02em; }
.empty-state p { margin: 0 auto 17px; max-width: 250px; color: var(--text-3); font-size: 11px; line-height: 1.55; }
.empty-actions { display: flex; justify-content: center; gap: 8px; }
.empty-actions .primary-button, .empty-actions .secondary-button { height: 32px; font-size: 11px; }
.drop-overlay { position: absolute; inset: 0; z-index: 10; display: none; place-items: center; background: rgba(81, 72, 194, .17); border: 2px dashed rgba(164, 156, 255, .72); pointer-events: none; }
.drop-overlay.active { display: grid; }
.drop-card { display: grid; justify-items: center; gap: 7px; padding: 19px 25px; border: 1px solid rgba(176, 168, 255, .58); border-radius: 13px; background: rgba(20, 22, 33, .93); box-shadow: var(--shadow); }
.drop-card-icon { width: 36px; height: 36px; display: grid; place-items: center; color: var(--accent-2); background: var(--accent-soft); border-radius: 10px; }
.drop-card-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.drop-card span { color: var(--text-3); font-size: 11px; }

.statusbar { height: 30px; flex: 0 0 30px; display: flex; align-items: center; justify-content: space-between; padding: 0 17px; border-top: 1px solid var(--border-soft); background: #11151c; color: var(--text-3); font-size: 10px; }
.status-left, .status-right { gap: 7px; }
.status-right { font-variant-numeric: tabular-nums; }
.status-separator { color: #4b5463; }
.live-dot { width: 5px; height: 5px; flex-basis: 5px; box-shadow: 0 0 0 3px rgba(95,224,188,.08); }

.inspector { min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--border-soft); }
.panel-tabs { height: 48px; flex: 0 0 48px; display: flex; align-items: end; gap: 18px; padding: 0 18px; border-bottom: 1px solid var(--border-soft); }
.panel-tab { position: relative; height: 38px; border: 0; padding: 0 0 13px; background: transparent; color: var(--text-3); cursor: pointer; font-size: 12px; font-weight: 650; }
.panel-tab.active { color: var(--text); }
.panel-tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--accent); }
.count-badge { display: inline-grid; place-items: center; min-width: 18px; height: 17px; padding: 0 5px; margin-left: 4px; border-radius: 8px; background: var(--surface-3); color: var(--text-3); font-size: 10px; }
.inspector-scroll { min-height: 0; flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--surface-4) transparent; }
.inspector-section { padding: 16px 16px 15px; border-bottom: 1px solid var(--border-soft); }
.selection-summary { display: flex; align-items: center; gap: 10px; padding-top: 17px; padding-bottom: 17px; }
.summary-icon { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 34px; border-radius: 9px; background: var(--surface-3); color: var(--accent-2); }
.summary-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.summary-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.summary-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.summary-copy span { color: var(--text-3); font-size: 10px; }
.selection-summary .icon-button { margin-left: auto; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; color: var(--text-2); font-size: 11px; font-weight: 750; letter-spacing: .03em; text-transform: uppercase; }
.section-heading.no-margin { margin: 0; }
.section-collapse { width: 24px; height: 20px; border: 0; background: transparent; color: var(--text-3); cursor: pointer; }
.section-collapse:hover { color: var(--text); }
.field-grid { display: grid; gap: 8px; }
.field-grid.two { grid-template-columns: 1fr 1fr; }
.field-grid.four { grid-template-columns: 1fr 1fr 1fr 1fr; }
.field-row { display: flex; gap: 8px; margin-top: 10px; }
.field, .color-control { min-width: 0; display: flex; flex-direction: column; gap: 5px; color: var(--text-3); font-size: 10px; }
.field.grow { flex: 1; }
.field input, .field textarea, .field select, .color-input-wrap input[type="text"], .color-input-wrap input:not([type]) { width: 100%; border: 1px solid var(--border); border-radius: 6px; outline: none; background: var(--surface-2); color: var(--text); font-size: 11px; }
.field input, .field select { height: 31px; padding: 0 8px; }
.field textarea { min-height: 60px; resize: vertical; padding: 8px; line-height: 1.35; }
.section-help { margin: 9px 0 0; color: var(--text-3); font-size: 10px; line-height: 1.45; }
.field input:focus, .field textarea:focus, .field select:focus, .color-input-wrap input[type="text"]:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.field input:disabled, .field textarea:disabled, .field select:disabled { color: var(--text-3); background: #151922; cursor: not-allowed; }
.field-grid.four .field input { padding: 0 5px; text-align: center; }
.input-with-suffix { position: relative; }
.input-with-suffix input { padding-right: 27px; }
.input-with-suffix span { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 10px; pointer-events: none; }
.outline-button { align-self: end; }
.color-row { display: flex; align-items: end; gap: 8px; margin-bottom: 10px; }
.color-control { flex: 1; }
.color-input-wrap { display: flex; align-items: center; height: 31px; overflow: hidden; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }
.color-input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.color-input-wrap input[type="color"] { width: 32px; height: 29px; flex: 0 0 32px; padding: 4px; border: 0; border-right: 1px solid var(--border); background: transparent; cursor: pointer; }
.color-input-wrap input[type="text"], .color-input-wrap input:not([type]) { height: 29px; flex: 1; border: 0; border-radius: 0; padding: 0 8px; background: transparent; font-size: 10px; font-family: "SFMono-Regular", Consolas, monospace; text-transform: uppercase; }
.transparent-button { width: 31px; height: 31px; align-self: end; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: var(--text-3); cursor: pointer; font-size: 16px; }
.transparent-button:hover { border-color: var(--accent); color: var(--text); }

.layer-panel { padding-top: 15px; }
.layer-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.layers-list { display: flex; flex-direction: column; gap: 4px; }
.layer-row { display: grid; grid-template-columns: 23px minmax(0, 1fr) auto; align-items: center; gap: 5px; min-height: 37px; padding: 4px 5px; border: 1px solid transparent; border-radius: 7px; cursor: pointer; }
.layer-row:hover { background: var(--surface-2); }
.layer-row.selected { border-color: rgba(134,120,255,.35); background: var(--accent-soft); }
.layer-row.is-hidden { opacity: .5; }
.layer-icon { width: 22px; height: 25px; display: grid; place-items: center; color: var(--text-3); }
.layer-icon svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.layer-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.layer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-size: 11px; }
.layer-meta { color: var(--text-3); font-size: 9px; text-transform: uppercase; letter-spacing: .05em; }
.layer-row.selected .layer-name { color: var(--text); }
.layer-actions { display: flex; gap: 2px; }
.layer-action { width: 25px; height: 25px; display: grid; place-items: center; border: 0; border-radius: 5px; background: transparent; color: var(--text-3); cursor: pointer; }
.layer-action:hover { color: var(--text); background: var(--surface-4); }
.layer-action svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.layers-empty { display: grid; justify-items: center; gap: 8px; padding: 26px 20px 24px; color: var(--text-3); font-size: 10px; line-height: 1.5; text-align: center; }
.layers-empty svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.help-card { display: flex; gap: 10px; margin: 14px 16px; padding: 12px; border: 1px solid rgba(134,120,255,.18); border-radius: 9px; background: rgba(134,120,255,.07); }
.help-card-icon { width: 26px; height: 26px; display: grid; place-items: center; flex: 0 0 26px; border-radius: 7px; color: var(--accent-2); background: var(--accent-soft); }
.help-card-icon svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.help-card strong { display: block; margin-bottom: 4px; font-size: 10px; }
.help-card p { margin: 0; color: var(--text-3); font-size: 10px; line-height: 1.45; }
kbd { display: inline-block; padding: 1px 4px; border: 1px solid #465064; border-radius: 3px; background: #252d3b; color: var(--text-2); font-family: inherit; font-size: 9px; }

.selection-box { fill: rgba(134,120,255,.04); stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; pointer-events: none; }
.resize-handle { width: 8px; height: 8px; fill: #fff; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; pointer-events: all; cursor: nwse-resize; }
.resize-handle.n, .resize-handle.s { cursor: ns-resize; }
.resize-handle.e, .resize-handle.w { cursor: ew-resize; }
.resize-handle.ne, .resize-handle.sw { cursor: nesw-resize; }
.rotation-stem { stroke: var(--accent); stroke-width: 1.2; vector-effect: non-scaling-stroke; pointer-events: none; }
.rotation-handle { fill: var(--accent); stroke: #fff; stroke-width: 1.5; vector-effect: non-scaling-stroke; pointer-events: all; cursor: grab; }
.rotation-handle:active { cursor: grabbing; }

.toast-stack { position: fixed; right: 20px; bottom: 22px; z-index: 100; display: flex; flex-direction: column; align-items: end; gap: 8px; pointer-events: none; }
.toast { max-width: 320px; padding: 10px 13px; border: 1px solid var(--border); border-radius: 8px; background: #202733; color: var(--text); box-shadow: var(--shadow); font-size: 11px; animation: toast-in .22s ease both; }
.toast.success { border-color: rgba(95,224,188,.4); }
.toast.error { border-color: rgba(255,119,140,.45); color: #ffc5cf; }
@keyframes toast-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
.export-menu { position: fixed; top: 53px; right: 18px; z-index: 60; min-width: 192px; padding: 6px; border: 1px solid var(--border); border-radius: 9px; background: #1d2330; box-shadow: var(--shadow); }
.export-menu[hidden] { display: none; }
.export-menu button { width: 100%; display: flex; align-items: center; gap: 9px; padding: 9px 8px; border: 0; border-radius: 6px; background: transparent; color: var(--text-2); cursor: pointer; text-align: left; }
.export-menu button:hover { background: var(--surface-4); color: var(--text); }
.export-menu button svg { width: 17px; height: 17px; flex: 0 0 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.export-menu button span { display: flex; flex-direction: column; gap: 2px; }
.export-menu strong { color: inherit; font-size: 11px; }
.export-menu small { color: var(--text-3); font-size: 9px; }

@media (max-width: 1100px) {
  .main-shell { grid-template-columns: 58px minmax(0, 1fr) 286px; }
  .tool-button { width: 35px; height: 35px; }
  .inspector-section { padding-left: 13px; padding-right: 13px; }
  .brand-lockup { min-width: 156px; }
  .topbar { gap: 16px; }
  .secondary-button span, .primary-button span:not(.button-caret) { display: none; }
  .brush-title, .range-control > span, .pressure-toggle > span:last-child { display: none; }
  .brush-controls { gap: 5px; padding: 0 5px; }
  .brush-select > span { display: none; }
  .brush-select select { max-width: 71px; padding-left: 4px; }
  .range-control input[type="range"] { width: 55px; }
}
