:root { font: 14px/1.3 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: #27392f; background: #000; }
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
button, select, input[type=checkbox], input[type=range] { cursor: pointer; }
button, select { color: inherit; background: #fbfbf7; border: 1px solid #c6cec3; border-radius: 6px; min-height: 36px; padding: 4px 10px; }
button:not(:disabled):hover, select:hover { border-color: #778879; }
button:disabled { color: #919b92; background: transparent; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, .swatch:focus-within { outline: 2px solid #995833; outline-offset: 2px; }
.studio { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.surface { min-width: 0; min-height: 0; position: relative; display: grid; place-items: center; container-type: size; overflow: hidden; touch-action: none; overscroll-behavior: contain; }
canvas { display: block; width: min(100cqw, calc(100cqh * var(--ratio, 1))); height: auto; aspect-ratio: var(--ratio, 1); background: #fbfaf5; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: default; }
.notice { position: absolute; max-width: min(90%, 430px); text-align: center; padding: 12px; background: #fbfaf5; }
.controls { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; min-height: 48px; padding: max(4px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 4px max(10px, env(safe-area-inset-left)); color: #202220; background: #aaa; border-bottom: 1px solid #777; }
.controls > button, .controls > select, .controls > .layers > button, .history button { background: #d6d6d6; border-color: #898989; }
.controls > .layers > button[aria-expanded=true] { background: #304c3a; }
.history button:disabled { background: transparent; color: #5c5c5c; }
.size, .history, .readout, .property { display: flex; align-items: center; gap: 7px; }
.swatch { display: inline-block; position: relative; width: 34px; height: 34px; border: 1px solid #617165; border-radius: 6px; background: var(--ink); flex-shrink: 0; }
.swatch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
input[type=range], input[type=checkbox] { accent-color: #46634e; }
input[type=range] { height: 28px; margin: 0; }
.size input { width: clamp(55px, 10vw, 150px); }
output { min-width: 37px; font-variant-numeric: tabular-nums; font-size: 12px; }
.history { gap: 4px; }
.history button { padding-inline: 8px; }
.readout { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; column-gap: 12px; font-size: 12px; color: #333; }
.layers-button { white-space: nowrap; }
.layer-picker > .layers-button, .transform-controls strong {
  max-width: min(16em, 38vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.layers-button[aria-expanded=true] { background: #304c3a; border-color: #304c3a; color: #fff; }
.panel { position: absolute; z-index: 1; top: calc(100% + 5px); left: var(--panel-left, 6px); width: 254px; padding: 12px; border: 1px solid #b8c3b8; background: #f8f9f4; box-shadow: 0 4px 16px #25392f28; border-radius: 9px; }
.property { margin-top: 9px; justify-content: space-between; }
.property input { flex: 1; width: 70px; margin-left: 8px; }
.property output { text-align: right; }
@media(max-width: 650px) {
  .controls { gap: 5px; font-size: 12px; flex-wrap: wrap; }
  .readout { font-size: 10px; gap: 4px; }
}
@media(pointer: coarse) { .controls button, .controls select { min-height: 42px; } }

#surface-panel { width: min(264px, calc(100vw - 16px)); max-height: min(72dvh, var(--panel-room, 72dvh)); overflow-y: auto; }
.paper-settings { border-bottom: 1px solid #d6dbd1; padding-bottom: 12px; }
.paper-format { font-size: 14px; }
.paper-dimensions { font-size: 12px; color: #546657; margin-top: 3px; }
.fill-row, .fill-picker { display: flex; align-items: center; gap: 8px; }
.fill-row { justify-content: space-between; margin-top: 9px; }

.surface.move-mode, .surface.move-mode canvas { cursor: grab; }
.surface.dragging, .surface.dragging canvas { cursor: grabbing; }
#view-panel { overflow-y: auto; max-height: var(--panel-room, 72dvh); width: min(268px, calc(100vw - 16px)); }
.view-status, .view-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.view-status output { color: #546657; }
.view-row { display: grid; grid-template-columns: 1fr 60px 60px; align-items: center; gap: 6px; margin-top: 8px; }
.view-actions { margin-top: 10px; padding-top: 10px; border-top: 1px solid #d6dbd1; }

.file-panel { width: min(320px,calc(100vw - 24px)); padding: 16px; color: inherit; background: #f8f9f4; border: 1px solid #b8c3b8; border-radius: 9px; box-shadow: 0 8px 32px #25392f38; }
.file-panel::backdrop { background: #17251d35; }
.file-heading, .file-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.file-panel label { display: grid; gap: 4px; margin-top: 12px; }
.file-panel input:is([type=text],[type=number]) { min-width: 0; padding: 7px 9px; border: 1px solid #c6cec3; border-radius: 6px; color: inherit; }
.file-panel .pixel-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.new-canvas input { width: 100%; }
.new-canvas-link { margin-top: 8px; }
.file-actions { margin-top: 16px; }
.file-actions > :is(button, a) { flex: 1; text-align: center; }
.export-file { display: grid; place-items: center; min-height: 36px; padding: 4px 10px; border-radius: 6px; background: #304c3a; color: #fff; text-decoration: none; }
.file-panel p { margin: 9px 0 0; }
@media(pointer: coarse) { .export-file { min-height: 42px; } }

.studio > .surface, .transform-overlay { grid-area: 2 / 1; }
.studio > .controls { grid-area: 1 / 1; z-index: 2; }
.transform-overlay { position: relative; min-width: 0; min-height: 0; overflow: hidden; z-index: 1; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: grab; }
.transform-overlay:active { cursor: grabbing; }
.rectangle-overlay, .rectangle-overlay:active, .background-overlay, .background-overlay:active { cursor: crosshair; }
canvas.pixel-tool { image-rendering: pixelated; }
.drawing-surface canvas, .drawing-surface:active { cursor: none; }
.brush-cursor { position:absolute; z-index:1; left:0; top:0; width:0; height:0; pointer-events:none; user-select:none; }
.brush-outline { position:absolute; left:0; top:0; border-radius:50%; box-shadow:0 0 0 1px #161616,inset 0 0 0 1px white; }
.brush-outline[data-shape="square"] { border-radius:0; }
.brush-outline[data-shape="flat"] { border-radius:24% / 32%; }
.brush-outline[data-shape="soft-flat"] { border-radius:39%; }
.brush-cursor::after { position:absolute; left:5px; top:4px; color:white; font:bold 13px/15px system-ui,sans-serif; text-shadow:0 0 2px black,0 1px 2px black,0 -1px 2px black; }
.brush-cursor[data-action="erase"]::after { content:"−"; }
.brush-cursor[data-action="smudge"]::after { content:"≈"; }
.brush-cursor.fine-tip::before { content:""; position:absolute; left:-6px; top:-6px; width:10px; height:10px; border:1px dotted #333; border-radius:50%; box-shadow:0 0 0 1px #fffc; }
.cursor-choice { display:flex; align-items:center; gap:6px; min-height:32px; margin-top:7px; }
.transform-outline { position: absolute; outline: 1px dashed white; box-shadow: 0 0 0 2px #263b31; }
.transform-corner { position: absolute; display: grid; place-items: center; width: 34px; height: 34px; transform: translate(-50%,-50%); }
.transform-corner::after { content: ''; width: 12px; height: 12px; border: 2px solid #263b31; border-radius: 2px; background: white; }
.transform-release { color: #333; white-space: nowrap; }
.transform-controls { gap: 8px; flex-wrap: nowrap; min-width: 0; overflow-x: auto; white-space: nowrap; }
.transform-controls > :is(button, .transform-actions, small) { flex-shrink: 0; }
@media (max-width: 950px) { .transform-hint { display: none; } }
.transform-hint { color: #465b4c; margin-inline: 4px; }
.transform-actions { display: flex; gap: 6px; margin-left: auto; }
.apply-placement { color: white; background: #304c3a; }
@media(pointer: coarse) { .transform-corner { width: 44px; height: 44px; } }

#layers-panel { display: flex; flex-direction: column; width: min(294px, calc(100% - 12px)); padding: 4px;
  max-height: min(66dvh, var(--panel-room,66dvh)); }
.layer-list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.layer-row { display: flex; align-items: stretch; min-height: 26px; border-radius: 3px; }
#layers-panel .layer-row button { display: flex; align-items: center; min-height: 26px; margin: 0;
  border: 0; border-radius: 3px; background: transparent; color: inherit; }
.layer-row[data-current=true] { background: #304c3a; color: #fff; }
@media(hover:hover) { .layer-row[data-current=false]:hover { background: #e7ece4; } }
.layer-name-button, .layer-name-input { flex: 1; width: 0; min-width: 0; padding: 2px 5px 2px 8px; text-align: left; }
.layer-name-button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer-name-input { background: #fbfbf7; color: #27392f; border: 1px solid #46634e; border-radius: 3px; outline-offset: -2px; }
.layer-more { flex: 0 0 30px; justify-content: center; padding: 0; }
.layer-eye { flex: 0 0 32px; justify-content: center; padding: 0; }
.layer-eye[aria-pressed=false] { opacity: .68; }
.layer-thumb { flex: 0 0 42px; justify-content: center; padding: 0; }
.thumb-frame { display: block; width: 36px; height: 22px; overflow: hidden; border-radius: 2px;
  background: repeating-conic-gradient(#e7e7e4 0 25%, #c4c5c1 0 50%) 0 0 / 8px 8px;
  box-shadow: 0 0 0 1px #0004; }
.thumb-frame img { display: block; width: 100%; height: 100%; object-fit: contain; }
.thumb-frame img:not([src]) { opacity: 0; }
#layers-panel .layer-row button:focus-visible { outline-offset: -2px; outline-color: #b67743; }
.add-layer { flex: none; min-height: 30px; margin-top: 4px; }
.layer-properties { padding: 4px 5px 5px; border-bottom: 1px solid #c9d2c6; font-size: 13px; }
.layer-blend, .layer-opacity { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 3px; }
.layer-blend select { min-height: 28px; padding: 2px 4px; }
.layer-blend { margin-top: 4px; }
.layer-alpha-lock { display: flex; justify-content: space-between; align-items: center; min-height: 30px; cursor: pointer; }
.layer-alpha-lock input { margin: 0 4px; }
@media(pointer:coarse) { .layer-alpha-lock { min-height: 40px; } }
.layer-opacity input { grid-column: 1 / -1; display: block; width: 100%; }
.layer-opacity output { text-align: right; }
#layer-action-tray { position: fixed; z-index: 2; visibility: hidden; width: max-content; min-width: min(182px, calc(100vw - 12px)); max-width: calc(100vw - 12px); padding: 3px;
  border: 1px solid #b8c3b8; border-radius: 7px; background: #f8f9f4; box-shadow: 0 3px 12px #25392f26;
  max-height: min(74dvh,var(--panel-room,74dvh)); overflow-y: auto; overscroll-behavior: contain; }
#layer-action-tray[data-side] { visibility: visible; }
#layer-action-tray[data-side=left] { --tray-offset: 7px; }
#layer-action-tray[data-side=right] { --tray-offset: -7px; }
@media(prefers-reduced-motion:no-preference) {
  #layer-action-tray[data-side] { animation: layer-tray-in 110ms ease-out; }
  @keyframes layer-tray-in { from { opacity: 0; transform: translateX(var(--tray-offset)); } }
}
#layer-action-tray button { white-space: nowrap; display: flex; align-items: center; gap: 9px; width: 100%; min-height: 30px;
  background: transparent; border: 0; padding: 3px 7px; text-align: left; border-radius: 4px; }
#layer-action-tray button:not(:disabled):hover, #layer-action-tray button:focus-visible { background: #e7ece4; }
@media(pointer:coarse) {
  #layers-panel .layer-row button { min-height: 34px; }
  .layer-eye, .layer-more { flex-basis: 42px; }
  .layer-name-input { font-size: 16px; }
  #layers-panel .add-layer, .layer-blend select { min-height: 36px; }
  #layer-action-tray button { min-height: 40px; }
}

.mixer-panel { width: min(300px, calc(100vw - 16px)); max-height: min(75dvh, var(--panel-room, 75dvh)); overflow-y: auto; }
.mixer-head, .mixer-tools { display: flex; align-items: center; gap: 5px; }
.mixer-head { justify-content: space-between; margin-bottom: 7px; }
.mixer-palette-actions { display: flex; gap: 4px; margin-left: auto; }
.mixer-palette-actions button { min-height: 28px; padding: 3px 6px; font-size: 12px; }
.mixer-head > button { padding: 0 7px; min-height: 26px; font-size: 19px; line-height: 1; }
canvas.mixing-pad { width: 100%; height: auto; aspect-ratio: 272 / 160; border-radius: 4px; background: #878580; }
.mixer-tools { margin-top: 8px; }
.mixer-tools button { flex: 1; white-space: nowrap; padding-inline: 5px; }
.mixer-tools button[aria-pressed=true] { color: #fff; background: #304c3a; }
.mixer-hint { margin-top: 6px; font-size: 12px; color: #46534a; }

.pigment-button { display:inline-flex;align-items:center;gap:6px; }
.pigment-button::before { content:"";width:18px;height:18px;border:1px solid #666;border-radius:3px;background:var(--ink); }
.pigment-panel { width:min(275px,calc(100vw - 16px));max-height:min(72dvh, var(--panel-room,72dvh));overflow:auto; }
.pigment-panel label { display:flex;align-items:center;gap:8px;justify-content:space-between;margin-bottom:8px; }
.pigment-panel input,.pigment-panel select { min-width:0;max-width:65%; }
.freehand-trace { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; pointer-events: none;
  fill: none; stroke: #202020; stroke-width: 1.5; stroke-linejoin: round; }
.freehand-trace .trace-edge { vector-effect: non-scaling-stroke; }
.freehand-trace .trace-dashes { stroke: white; stroke-dasharray: 4 4; }

.tools-panel { width:min(352px,calc(100vw - 12px)); max-height:min(82dvh,var(--panel-room,82dvh)); overflow:auto; overscroll-behavior:contain; }
.tools-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:4px; }
.tools-head button { font-size:18px; min-width:36px; }
.tools-panel fieldset { min-width:0; border:0; padding:0; margin:6px 0 10px; }
.tools-panel legend, .brush-lists summary { font-weight:600; margin-bottom:5px; }
.tools-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:4px; }
.tools-panel button { padding-inline:5px; }
.tools-panel button[aria-pressed=true] { background:#304c3a; color:white; border-color:#304c3a; }
.brush-lists { border-block:1px solid #c7cec6; padding:5px 0; }
.brush-lists summary { cursor:pointer; padding:5px 0; margin:0; }

.media-families { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); column-gap:10px; }
.media-families .tools-grid { display:flex; flex-wrap:wrap; }
.media-families .tools-grid button { flex:1 0 auto; max-width:100%; }

.brush-sidebar {
  grid-area: 2 / 1; align-self: center; justify-self: start; position: relative; z-index: 1;
  display: grid; grid-template-rows: minmax(0, 1fr) 44px minmax(0, 1fr);
  height: min(292px, 92%); width: 44px; padding: 5px 0;
  margin-left: env(safe-area-inset-left); border: 1px solid #565656; border-left: 0;
  border-radius: 0 9px 9px 0; background: #303030; color: white;
  box-shadow: 1px 1px 5px #0004; touch-action: none; user-select: none; -webkit-user-select: none;
}
.brush-sidebar.right {
  justify-self: end; margin: 0 env(safe-area-inset-right) 0 0;
  border: 1px solid #565656; border-right: 0; border-radius: 9px 0 0 9px;
}
.sidebar-slider { min-height: 0; position: relative; display: grid; place-items: center; }
.sidebar-slider input[type=range] {
  appearance: none; -webkit-appearance: none; writing-mode: vertical-lr; direction: rtl;
  width: 100%; height: 100%; background: transparent; touch-action: none;
}
.sidebar-slider input::-webkit-slider-runnable-track { width: 22px; background: #535353; border-radius: 5px; }
.sidebar-slider input::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none; width: 22px; height: 10px; border-radius: 4px; background: #f4f4f4;
}
.sidebar-slider input::-moz-range-track { width: 22px; background: #535353; border-radius: 5px; }
.sidebar-slider input::-moz-range-thumb { width: 22px; height: 10px; border: 0; border-radius: 4px; background: #f4f4f4; }
.sidebar-slider output {
  display: none; position: absolute; left: calc(100% + 6px); pointer-events: none;
  width: max-content; min-width: 0; padding: 3px 7px; border-radius: 4px; color: white; background: #303030;
}
.brush-sidebar.right output { left: auto; right: calc(100% + 6px); }
.sidebar-slider input:is(:active,:focus-visible) + output { display: block; }
.sidebar-pick { display: grid; place-items: center; padding: 0; background: transparent; border: 0; }
.sidebar-pick span { width: 19px; height: 19px; background: var(--ink); border: 2px solid white; border-radius: 5px; }
