:root { color-scheme: light; --app: #f3f4f6; --panel: #fff; --surface: #f5f6f8; --hover: #e9edf2; --canvas: #e4e7ec; --checker: #dce0e6; --text: #252a34; --muted: #626c7e; --line: #d9dfe7; --accent: #7458d9; --accent-hover: #6345ca; --accent-soft: #eee9fc; --accent-text: #6345ca; --on-accent: #fff; --track: #cbd2df; --shadow: #18203320; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: var(--text); background: var(--app); font-size: 12px; }
:root[data-theme="dark"] { color-scheme: dark; --app: #191919; --panel: #202020; --surface: #282828; --hover: #303030; --canvas: #181818; --checker: #1e1e1e; --text: #e4e4e4; --muted: #a1a1a1; --line: #303030; --accent: #9b87f2; --accent-hover: #ad9bf7; --accent-soft: #383048; --accent-text: #dfd6ff; --on-accent: #191422; --track: #484848; --shadow: #0006; }
* { box-sizing: border-box; }
button, input, select { font: inherit; }
button, select, input[type="color"], input[type="range"], summary { cursor: pointer; }
button { color: var(--text); }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button:disabled { opacity: .4; cursor: default; }
[hidden] { display: none !important; }
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand strong { font-size: 14px; font-weight: 650; letter-spacing: -.3px; }
.toolbar-actions { display: flex; align-items: center; gap: 8px; }
.toolbar-button, .primary { border: 1px solid transparent; border-radius: 5px; background: transparent; padding: 8px 12px; font-size: 12px; font-weight: 550; white-space: nowrap; min-height: 32px; }
.toolbar-button:hover { background: var(--hover); }
.primary { color: var(--on-accent); border-color: var(--accent); background: var(--accent); }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.controls section { padding: 16px 20px; }
.source-section { padding-bottom: 0 !important; }
.source-section .section-title { margin: 0; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
#theme { font-size: 18px; width: 34px; padding: 4px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 8px; font-size: 12px; font-weight: 650; }
.text-button { padding: 0; background: none; border: none; color: var(--accent-text); font-size: 11px; }
.text-button:hover { text-decoration: underline; }
.file-info { color: var(--muted); overflow-wrap: anywhere; margin: 8px 0 0; font-size: 10px; line-height: 1.5; }
.presets { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 4px; }
.presets button { background: transparent; border: none; border-radius: 4px; padding: 6px 8px; font-size: 11px; color: var(--muted); text-align: left; }
.presets button:hover { background: var(--hover); }
.presets button.active { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); }
.control-group { border: none; padding: 0 20px; }
.control-group summary { font-size: 12px; font-weight: 550; padding: 16px 0; user-select: none; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.control-group summary::-webkit-details-marker { display: none; }
.control-group summary::after { content: '›'; color: var(--muted); font-size: 16px; }
.control-group[open] summary::after { transform: rotate(90deg); }
.control-group[open] { padding-bottom: 16px; }
.slider { display: block; margin: 0 0 12px; }
.slider:last-child { margin-bottom: 0; }
.slider-head { display: flex; justify-content: space-between; align-items: center; font-size: 11px; margin-bottom: 4px; }
.slider output { min-width: 42px; border: none; background: transparent; padding: 2px 0; border-radius: 3px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 10px; }
input[type="range"] { width: 100%; height: 16px; margin: 0; appearance: none; background: transparent; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; background: var(--track); border-radius: 3px; }
input[type="range"]::-webkit-slider-thumb { appearance: none; height: 11px; width: 11px; border-radius: 50%; background: var(--accent); margin-top: -4px; }
input[type="range"]::-moz-range-track { height: 3px; background: var(--track); border-radius: 3px; }
input[type="range"]::-moz-range-thumb { border: none; height: 11px; width: 11px; border-radius: 50%; background: var(--accent); }
.field { display: block; font-size: 11px; margin-bottom: 12px; }
select, input[type="number"] { display: block; width: 100%; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--text); margin-top: 6px; padding: 7px 8px; font-size: 11px; }
.check { display: flex; align-items: center; gap: 7px; font-size: 11px; margin: 12px 0; }
.check input { accent-color: var(--accent); width: 14px; height: 14px; margin: 0; }
.check:last-child { margin-bottom: 0; }
.color-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.color-row label { display: flex; align-items: center; justify-content: space-between; font-size: 11px; }
input[type="color"] { width: 32px; height: 24px; padding: 2px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.help { font-size: 10px; line-height: 1.6; color: var(--muted); margin: 0; }
.reset { display: block; width: calc(100% - 40px); border: none; border-radius: 4px; padding: 8px; margin: 20px; background: transparent; color: var(--muted); font-size: 11px; }
.reset:hover { background: var(--hover); color: var(--text); }
#documentName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-switch { display: flex; gap: 4px; background: transparent; border: none; border-radius: 4px; padding: 2px; }
.view-switch button { background: none; border: none; border-radius: 2px; padding: 4px 8px; font-size: 10px; color: var(--muted); }
.view-switch button[aria-pressed="true"] { background: var(--hover); color: var(--text); }
.empty { text-align: center; }
h1 { font-size: 20px; font-weight: 600; letter-spacing: -.5px; margin: 0 0 10px; }
.empty p { font-size: 12px; line-height: 1.6; color: var(--muted); margin-bottom: 20px; }
.empty .text-button { display: block; margin: 14px auto 0; }
.export-bar strong { font-size: 10px; font-weight: 550; font-variant-numeric: tabular-nums; }
.export-bar p { margin: 4px 0 0; font-size: 10px; color: var(--muted); line-height: 1.5; }

.brush-history { display: flex; gap: 5px; margin: 12px 0; }
.brush-history button { flex: 1; }
#brushOverlay { z-index: 1; box-shadow: none; image-rendering: auto; }

@media (pointer: coarse) { .brush-tools button, .brush-history button { min-height: 40px; } input[type="range"] { height: 26px; } }

body { margin: 0; height: 100dvh; overflow: hidden; display: grid; grid-template-areas: 'viewport'; }
main { grid-area: viewport; min-width: 0; min-height: 0; display: grid; grid-template-areas: 'viewport'; }
.masthead { grid-area: viewport; z-index: 30; place-self: start stretch; margin: 16px; min-height: 48px; display: flex; align-items: center; gap: 16px; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 4px 16px var(--shadow); }
.app-mark { background: var(--accent); color: var(--on-accent); padding: 5px 6px; border-radius: 7px; font-weight: 750; font-size: 13px; letter-spacing: -1px; }
.document-tab { color: var(--muted); font-size: 11px; overflow: hidden; min-width: 0; max-width: 30%; margin-right: auto; }
.toolbar-actions { margin-left: auto; }
.controls { grid-area: viewport; z-index: 10; place-self: start; width: 256px; margin: 80px 0 0 16px; max-height: calc(100dvh - 170px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px var(--shadow); scrollbar-width: thin; scrollbar-color: var(--track) transparent; }
.controls-hidden .controls { display: none; }
.controls section { border-bottom: 1px solid var(--line); }
.controls .source-section { padding: 16px 20px !important; }
.control-group { border-bottom: 1px solid var(--line); }
.workspace { grid-area: viewport; min-width: 0; min-height: 0; display: grid; grid-template-areas: 'viewport'; }
.stage { grid-area: viewport; min-width: 0; min-height: 0; position: relative; overflow: hidden; background-color: var(--canvas); background-image: radial-gradient(var(--track) .65px, transparent .65px); background-size: 24px 24px; display: grid; place-items: center; touch-action: none; cursor: grab; }
.stage:focus-visible { outline-offset: -4px; }
.stage.panning, .stage.panning * { cursor: grabbing !important; }
.stage.pan-ready, .stage.pan-ready * { cursor: grab !important; }
.artboard { position: absolute; left: 0; top: 0; transform-origin: 0 0; display: grid; grid-template-areas: 'image'; box-shadow: 0 8px 32px var(--shadow); background: var(--panel); }
.artboard canvas, .artboard img { grid-area: image; width: 100%; height: 100%; min-width: 0; min-height: 0; display: block; }
#preview { image-rendering: pixelated; }
#sourcePreview { object-fit: fill; }
#brushOverlay { cursor: grab; }
#brushOverlay.painting { cursor: none; touch-action: none; }
.artboard.transparent { background-color: var(--panel); background-image: linear-gradient(45deg,var(--checker) 25%,transparent 25%),linear-gradient(-45deg,var(--checker) 25%,transparent 25%),linear-gradient(45deg,transparent 75%,var(--checker) 75%),linear-gradient(-45deg,transparent 75%,var(--checker) 75%); background-size: 16px 16px; background-position: 0 0,0 8px,8px -8px,-8px 0; }
.empty { z-index: 1; justify-self: center; margin-left: 256px; padding: 24px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 8px 24px var(--shadow); }
.controls-hidden .empty { margin-left: 0; }
.canvas-dock { grid-area: viewport; z-index: 20; place-self: end center; margin: 0 16px 16px; display: flex; gap: 6px; align-items: center; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px var(--shadow); }
.brush-tools { display: flex; gap: 4px; }
.brush-tools button, .dock-history button { border: none; border-radius: 6px; background: none; color: var(--muted); font-size: 11px; min-height: 36px; padding: 8px 10px; }
.brush-tools button:hover:not(:disabled), .dock-history button:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.brush-tools button[aria-pressed="true"] { color: var(--accent-text); background: var(--accent-soft); }
.dock-history { display: flex; padding-left: 6px; border-left: 1px solid var(--line); }
.dock-history button { font-size: 20px; width: 36px; padding: 4px; }
.zoom-dock { grid-area: viewport; z-index: 20; place-self: end; margin: 16px; display: flex; align-items: center; gap: 4px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 4px 16px var(--shadow); }
.zoom-dock button { min-width: 28px; min-height: 32px; border: none; border-radius: 5px; background: none; font-size: 12px; }
.zoom-dock button:hover { background: var(--hover); }
#zoomValue { min-width: 42px; text-align: center; font-variant-numeric: tabular-nums; font-size: 11px; color: var(--muted); }
#fitCanvas { border-left: 1px solid var(--line); border-radius: 0; margin-left: 4px; padding-left: 12px; }
.canvas-help { grid-area: viewport; z-index: 5; place-self: end center; margin-bottom: 80px; color: var(--muted); font-size: 10px; pointer-events: none; }
.export-bar { grid-area: viewport; z-index: 10; place-self: end start; width: 256px; margin: 16px; padding: 0 4px; pointer-events: none; }
.export-bar p { font-size: 9px; }
@media (max-width: 1100px) { .zoom-dock { place-self: start end; margin-top: 80px; } .document-tab { max-width: 18%; } }
@media (max-width: 760px) { .masthead { margin: 12px; min-height: 48px; padding: 6px; gap: 4px; } .brand, .document-tab { display: none; } .toolbar-actions { width: 100%; margin: 0; gap: 3px; justify-content: space-between; } .toolbar-button, .primary { padding: 7px 8px; font-size: 11px; } .view-switch { gap: 0; } .view-switch button { padding: 6px; } .controls { margin: 76px 12px 0; max-height: calc(100dvh - 180px); width: min(280px,calc(100vw - 24px)); } .canvas-dock { margin: 0 12px 12px; width: calc(100vw - 24px); flex-wrap: wrap; justify-content: center; gap: 0; } .brush-tools { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 0; width: 100%; } .brush-tools button { font-size: 10px; padding: 5px 3px; min-height: 38px; } .dock-history { border-left: none; border-top: 1px solid var(--line); width: 100%; justify-content: center; padding-left: 0; } .dock-history button { height: 28px; min-height: 28px; } .zoom-dock { margin: 76px 12px 0; } .canvas-help { display: none; } .export-bar { margin: 0 12px 98px; width: calc(100vw - 24px); } .export-bar p { max-width: 280px; } .empty { margin-left: 0; max-width: calc(100vw - 48px); } }

.brush-history button { border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--muted); min-height: 28px; font-size: 11px; }
