:root {
  --ink: #202020;
  --pencil: #747474;
  --paper: #fcfcfc;
  --line: #d5d5d5;
  --hand: "Chalkboard SE", "Chalkboard", "Bradley Hand", "Comic Sans MS", cursive;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-size: 12px;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html.dark-mode { filter: invert(1); }
/* Browser top-layer surfaces paint outside the root element's filter. */
html.dark-mode :is(dialog:modal, [popover]:popover-open),
html.dark-mode :is(dialog, [popover])::backdrop { filter: invert(1); }
canvas:focus { outline: none; }
canvas:focus-visible { outline: 1px dashed var(--ink); outline-offset: -3px; }
body {
  margin: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button, select, input, summary { outline-offset: 3px; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px dashed var(--ink);
}
button {
  border: 1.3px solid transparent;
  background: transparent;
  border-radius: 3px 5px 3px 4px;
  min-height: 33px;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { background: #ededed; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .35; cursor: default; }
button.primary {
  background: var(--ink);
  color: #fff;
  border: 1.5px solid var(--ink);
  border-radius: 4px 2px 6px 3px;
  box-shadow: 2px 2px 0 #fff, 3px 3px 0 var(--ink);
  padding-inline: 17px;
}
button.primary:hover { background: #444; }
button.outlined, button.wide {
  border-color: #4b4b4b;
  background: #fff;
  box-shadow: 1px 1px 0 #c5c5c5;
}
button.outlined:hover, button.wide:hover { background: #efefef; }
button.wide { margin-top: 8px; }
button.quiet { border-color: var(--line); color: #666; box-shadow: none; }
input[type=number], input[type=text], select {
  border: 1px solid #b0b0b0;
  border-radius: 2px 4px 2px 3px;
  background: #fff;
  min-height: 32px;
  padding: 5px 8px;
  min-width: 0;
}
input[type=number], input[type=text] { width: 100%; }
input[type=range] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 22px;
  margin: 7px 0 10px;
  background: transparent;
  accent-color: var(--ink);
  cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 3px;
  border: 1px solid #888;
  border-radius: 55% 40% 50% 45%;
  background: #fff;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 13px;
  width: 13px;
  margin-top: -6px;
  border: 1.5px solid var(--ink);
  border-radius: 45% 55% 47% 53%;
  background: #fff;
  box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 5px var(--ink);
}
input[type=range]::-moz-range-track { height: 2px; background: #777; }
input[type=range]::-moz-range-thumb { width: 11px; height: 11px; border: 2px solid var(--ink); background: #fff; }
input[type=checkbox] { accent-color: var(--ink); }
label { font-size: 11px; }
output { font-size: 11px; font-variant-numeric: tabular-nums; }
.wide { width: 100%; }
.muted { color: var(--pencil); line-height: 1.6; }
.small { font-size: 10px; line-height: 1.6; }
svg { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.app-header {
  min-height: 86px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  background: #fff;
  border-bottom: 2px solid var(--ink);
  gap: 16px;
  position: relative;
}
.app-header::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 0;
  right: 0;
  border-bottom: 1px solid #777;
  transform: rotate(-.12deg);
  pointer-events: none;
}
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 12px; }
.brand-mark { display: block; width: 106px; height: auto; flex-shrink: 0; }
.brand strong {
  display: block;
  font-family: var(--hand);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1.2px;
  line-height: 1.1;
}
.brand div > span {
  display: block;
  font-size: 8px;
  letter-spacing: 2.6px;
  margin-top: 5px;
  color: #666;
}
.file-actions { display: flex; gap: 9px; align-items: center; }
.file-actions button { display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 11px; }
.file-actions svg { width: 17px; height: 17px; }
.file-actions .primary { margin-left: 6px; }
.file-actions .primary span { font-size: 17px; line-height: 12px; }
.workspace-bar {
  min-height: 50px;
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding: 6px 26px;
  gap: 14px;
  background: #fff;
  border-bottom: 1px solid #c8c8c8;
}
.page-caption { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.workspace-name { min-width: 0; max-width: 220px; font-family: var(--hand); font-size: 15px; transform: rotate(-2deg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.caption-line { flex-shrink: 0; height: 1px; width: 27px; background: #a0a0a0; transform: rotate(-3deg); }
.badge { flex-shrink: 0; font-size: 9px; color: #777; letter-spacing: .2px; white-space: nowrap; }
.rename-button { display: inline-flex; flex: 0 0 24px; align-items: center; justify-content: center; width: 24px; min-width: 24px; height: 24px; min-height: 24px; padding: 0; border: 1px solid #d5d5d5; border-radius: 2px 4px 2px 3px; background: #fff; color: var(--ink); }
.rename-button:hover { border-color: #777; background: #f2f2f2; }
.rename-button svg { display: block; width: 14px; height: 14px; flex-shrink: 0; }
.name-input-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.name-input-row input { flex: 1; min-width: 0; }
.joint-field .name-input-row { margin-top: 5px; }
.joint-field .name-input-row input { margin-top: 0; }
.badge::before { content: "○"; margin-right: 5px; color: #777; }
.badge.dirty { color: #202020; }
.badge.dirty::before { content: "●"; color: #202020; }
.editing-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.edit-mode-field { display: flex; align-items: center; gap: 7px; white-space: nowrap; font-size: 10px; color: #666; }
.edit-mode-field select { min-height: 28px; padding: 4px 6px; font-size: 10px; color: var(--ink); border-radius: 2px 4px 2px 3px; }
#edit-mode-toggle { min-height: 28px; padding: 4px 8px; font-size: 10px; border: 1px solid #999; border-radius: 2px 4px 2px 3px; color: var(--ink); background: #fff; }
#edit-mode-menu { position: fixed; margin: 0; inset: auto; width: 270px; max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow: auto; overscroll-behavior: contain; padding: 6px; border: 2px solid #222; border-radius: 3px 5px 2px 4px; background: #fff; color: #222; box-shadow: 3px 3px 0 #0003; }
.mode-menu-row { display: flex; gap: 5px; align-items: center; }
.mode-menu-row + .mode-menu-row { margin-top: 3px; }
.mode-menu-group { margin: 5px 0; padding: 5px 0 5px 10px; border-block: 1px dashed var(--line); }
.mode-menu-group h3 { margin: 2px 8px 5px; color: #666; font-size: 10px; font-weight: 500; }
.mode-select { flex: 1; text-align: left; padding: 9px 8px; font-size: 12px; border: 1px solid transparent; }
.mode-select[aria-pressed="true"] { background: #222; color: white; border-color: #222; }
.mode-eye { display: grid; place-items: center; width: 32px; min-width: 32px; min-height: 32px; padding: 6px; border: 1px solid #ccc; }
.mode-eye svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.mode-eye[aria-pressed="false"] { color: #999; }
.mode-complete { display: flex; align-items: center; gap: 5px; font-size: 10px; white-space: nowrap; cursor: pointer; }
.mode-complete input { margin: 0; }
.history-actions { display: flex; gap: 4px; margin-left: 12px; padding-left: 16px; border-left: 1px solid var(--line); flex-shrink: 0; }
.history-actions button { min-height: 28px; padding: 3px 8px; font-size: 10px; border-color: #d0d0d0; background: #fff; }
.history-actions button span { margin-right: 3px; font-size: 16px; vertical-align: -1px; }
.view-bar { flex-shrink: 0; padding: 6px 26px; background: #f7f7f7; border-bottom: 1px dashed #aaa; }
.view-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.view-controls .site-menu-toggle { display: grid; place-items: center; width: 30px; height: 28px; padding: 4px; flex: 0 0 30px; }
.site-menu-toggle svg { width: 18px; height: 18px; }
#site-menu { position: fixed; inset: auto; margin: 0; width: 225px; max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow: auto; padding: 8px; border: 1.5px solid var(--ink); border-radius: 3px 5px 2px 4px; background: #fff; color: var(--ink); box-shadow: 3px 3px 0 #0002; }
#site-menu > p { margin: 4px 8px 9px; color: #777; font: 12px var(--hand); }
#site-menu a { display: flex; flex-direction: column; gap: 4px; padding: 11px 10px; color: inherit; text-decoration: none; border-radius: 3px; }
#site-menu a:hover { background: #eee; }
#site-menu a[aria-current="page"] { background: var(--ink); color: #fff; }
#site-menu strong { font-size: 12px; font-weight: 500; }
#site-menu a span { font-size: 10px; opacity: .65; }
.view-controls label { font-size: 10px; color: #666; }
.view-controls select { font-size: 10px; min-height: 28px; background: #fff; border: 1px solid #bcbcbc; padding-inline: 6px; }
.view-controls button { min-height: 28px; font-size: 10px; border-color: #bcbcbc; background: #fff; }
.view-controls button:hover { background: #ededed; }
.zoom-readout { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; white-space: nowrap; font-size: 10px; color: #666; }
.view-controls output { min-width: 0; text-align: right; font-family: ui-monospace, monospace; font-size: 10px; color: var(--ink); }
main { display: flex; min-height: 0; flex: 1; }
.sidebar {
  width: 268px;
  flex-shrink: 0;
  background: linear-gradient(90deg, transparent 13px, #e2e2e2 13px, #e2e2e2 14px, transparent 14px), #fff;
  border-right: 2px solid #333;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #bbb transparent;
}
.sidebar section { padding: 21px 20px 20px 26px; border-bottom: 1px dashed #aaa; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar h1, .sidebar h2 { font-family: var(--hand); font-weight: 500; margin: 0; }
.sidebar h1 { font-size: 23px; letter-spacing: -.8px; }
.sidebar h2 { font-size: 20px; line-height: 1.2; }
.section-number { font-family: var(--hand); font-size: 12px; color: #a0a0a0; border-bottom: 1px solid #bcbcbc; transform: rotate(4deg); }
.sidebar p { margin: 9px 0 12px; }
.sidebar .intro { font-size: 11px; margin-top: 6px; }
.sidebar .small { margin-bottom: 3px; }
.two-buttons { display: flex; gap: 8px; margin: 15px 0 13px; }
.two-buttons button { flex: 1; font-size: 10px; padding: 5px; min-height: 31px; }
.two-buttons button:first-child { transform: rotate(-.8deg); }
.two-buttons button:last-child { transform: rotate(.5deg); }
.tool-options { display: flex; gap: 7px; margin: 17px 0 18px; }
.tool-options button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 64px; padding: 9px 5px 7px; border: 1px solid #bbb; border-radius: 3px 6px 3px 5px; background: #fff; font-size: 10px; }
.tool-options button svg { width: 23px; height: 23px; stroke-width: 1.3; }
.tool-options button.active { background: var(--ink); color: white; border-color: var(--ink); box-shadow: 2px 2px 0 #fff, 3px 3px 0 #666; }
.tool-options button:not(.active):hover { border-color: var(--ink); background: #f3f3f3; }
.lasso-controls { display: flex; align-items: center; gap: 8px; margin: -6px 0 15px; }
.lasso-controls span { flex: 1; }
.lasso-controls button { flex-shrink: 0; font-size: 10px; padding: 4px 6px; min-height: 28px; border: 1px solid #bbb; }
.brush-options { display: flex; align-items: center; gap: 9px; }
.brush-options output { margin-left: auto; }
.brush-options output { min-width: 37px; text-align: right; font-family: ui-monospace, monospace; font-size: 10px; }
.shade-heading { display: flex; align-items: center; gap: 8px; }
.shade-heading output { margin-left: auto; font-family: ui-monospace, monospace; font-size: 10px; }
#shade-preview { width: 32px; height: 24px; border: 1px solid #999; image-rendering: pixelated; }
.shade-palette { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 4px; margin: 10px 0 16px; }
.shade-palette button { min-width: 0; min-height: 45px; padding: 3px 2px; border: 1px solid #bbb; border-radius: 2px 4px 2px 3px; display: flex; flex-direction: column; align-items: center; gap: 3px; font: 9px ui-monospace,monospace; background: #fff; }
.shade-palette canvas { width: 20px; max-width: 100%; height: 20px; image-rendering: pixelated; border: 1px solid #ddd; }
.shade-palette button[aria-pressed="true"] { color: white; background: #222; border-color: #222; outline: 1px solid #222; outline-offset: 1px; }
#preview-background { min-height: 28px; font-size: 10px; padding: 3px 7px; }
.stage[data-preview-background="black"] .stage-label { color: #ddd; }
.shade-endpoints { display: flex; justify-content: space-between; margin-top: 1px; color: #666; font-size: 9px; }
.shade-help { margin: 7px 0 14px; }
.image-treatment-control { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 12px 0; font-size: 11px; }
.image-treatment-control select { max-width: 125px; }
.tool-note { border-left: 1px solid #bcbcbc; padding-left: 9px; }
.layer-counter { color: #777; font-size: 9px; font-family: ui-monospace, monospace; }
.layer-note { margin: 3px 0 4px; }
.layer-list { display: grid; gap: 7px; max-height: 235px; overflow-y: auto; padding: 11px 2px 3px 0; }
.layer-row { display: flex; align-items: center; min-height: 43px; border: 1px solid #ccc; background: white; border-radius: 2px 5px 2px 3px; }
.layer-row.selected { border: 1.5px solid #333; box-shadow: 1px 1px 0 #999; background: repeating-linear-gradient(-45deg, #fff 0 5px, #f5f5f5 5px 6px); }
.layer-select { display: flex; align-items: center; gap: 5px; min-width: 0; flex: 1; text-align: left; padding: 5px 6px; }
.layer-select span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 10px; }
.layer-icon { width: 24px; height: 25px; border: 1px solid #aaa; border-radius: 2px; background: #fff; display: grid; place-items: center; color: #555; flex-shrink: 0; font-size: 12px; transform: rotate(-3deg); }
.mirror-toggle { flex: 0 0 27px; width: 27px; min-width: 27px; min-height: 27px; margin: 3px 2px; padding: 0; border: 1px solid #c3c3c3; border-radius: 3px 2px 4px 2px; background: #fff; color: #777; font-size: 16px; line-height: 1; }
.mirror-toggle:hover { border-color: var(--ink); color: var(--ink); }
.mirror-toggle[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.mirror-toggle[aria-pressed="true"]:hover { background: #444; }
.visibility { flex-shrink: 0; font-size: 9px; min-width: 28px; padding: 4px; color: #777; margin-right: 3px; }
.layer-actions { display: flex; justify-content: space-between; gap: 5px; margin: 10px 0 17px; }
.layer-actions button { border: 1px solid #d0d0d0; min-height: 28px; font-size: 10px; padding: 3px 9px; }
#layer-inspector { border-top: 1px solid #ddd; padding-top: 10px; }
#layer-inspector summary { font-family: var(--hand); font-size: 15px; margin-bottom: 14px; cursor: pointer; color: #555; }
#layer-inspector > label { display: block; margin-bottom: 5px; color: #777; font-size: 10px; }
#layer-inspector > .mirror-control { display: flex; align-items: flex-start; gap: 7px; margin: 12px 0 10px; color: var(--ink); font-size: 11px; line-height: 1.5; cursor: pointer; }
.mirror-control input { flex-shrink: 0; margin: 2px 0 0; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 10px 0; }
.field-grid label { font-size: 10px; color: #777; }
.field-grid input { margin-top: 5px; font-family: ui-monospace, monospace; font-size: 11px; }
.joint-list { display: grid; gap: 7px; max-height: 235px; overflow-y: auto; margin: 14px 0 12px; padding: 1px 2px 3px 0; }
.joint-row { display: flex; align-items: stretch; gap: 5px; min-width: 0; }
.joint-row > button { display: block; min-height: 35px; padding: 7px 9px; border: 1px solid #ccc; border-radius: 2px 5px 2px 3px; background: #fff; text-align: left; white-space: nowrap; }
.joint-row > .rename-button { display: inline-flex; flex: 0 0 24px; align-self: center; width: 24px; min-width: 24px; height: 24px; min-height: 24px; padding: 0; text-align: center; }
.joint-select { flex: 1 1 0; min-width: 0; font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.joint-row > .joint-reset { flex: 0 0 70px; width: 70px; padding-inline: 4px; color: #777; font-size: 9px; text-align: center; }
.joint-row > button:hover:not(:disabled) { border-color: #777; background: #f5f5f5; }
.joint-row > .joint-select[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; box-shadow: 1px 1px 0 #aaa; }
.joint-row > .joint-select[aria-pressed="true"]:hover { border-color: var(--ink); background: #333; color: #fff; }
.pose-preview-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 14px 0 8px; }
.pose-preview-controls label { display: flex; align-items: center; gap: 6px; font-size: 11px; cursor: pointer; }
.pose-preview-controls input { flex-shrink: 0; margin: 0; }
.pose-preview-controls button { min-height: 28px; padding: 4px 7px; border: 1px solid #ccc; border-radius: 3px 2px 4px 2px; background: #fff; color: #666; font-size: 10px; }
.skeleton-snap { display: flex; align-items: center; gap: 6px; margin-top: 12px; font-size: 11px; }
.subdivide-controls { display: flex; align-items: flex-end; gap: 8px; margin-top: 14px; }
.subdivide-controls label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; font-size: 11px; }
.subdivide-controls input { width: 100%; }
.subdivide-controls button { flex: 0 0 auto; padding-inline: 9px; }
.pose-preview-controls button:disabled { opacity: .4; }
.joint-pose-readout { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; padding: 8px 0; border-bottom: 1px dashed #d5d5d5; color: #777; font-size: 10px; }
.joint-pose-readout output { color: var(--ink); font-family: ui-monospace, monospace; font-size: 11px; white-space: nowrap; }
.joint-field { display: block; margin-top: 13px; color: #777; font-size: 10px; line-height: 1.5; }
.joint-field input, .joint-field select { display: block; width: 100%; margin-top: 5px; color: var(--ink); font-size: 11px; }
#joint-inspector .field-grid { margin-top: 14px; }
#joint-inspector .field-grid label { line-height: 1.5; }
#joint-settings > summary { cursor: pointer; }
#joint-settings > summary h2 { display: inline; }
#joint-settings[open] > summary { margin-bottom: 14px; }
.accessory-visible-control { display: flex; align-items: center; gap: 7px; margin: 15px 0 9px; font-size: 11px; cursor: pointer; }
.accessory-visible-control input { flex-shrink: 0; margin: 0; }
.accessory-motion-controls { padding: 0 0 10px; margin: 12px 0; border-top: 1px dashed #ccc; border-bottom: 1px dashed #ccc; }
#accessory-spring-controls > label { display: flex; justify-content: space-between; margin-top: 12px; }
#accessories-tools > .accessory-create-section { padding: 16px 12px; }
.accessory-create-section .intro { margin: 7px 0 12px; }
.accessory-parent-label { display: block; margin-bottom: 5px; color: #777; font-size: 10px; }
.accessory-create-row { display: flex; align-items: center; gap: 7px; }
.accessory-create-row select { flex: 1; min-width: 0; }
.accessory-create-row button { flex-shrink: 0; }
#accessories-tools > .accessory-tree-section { padding: 16px 12px; }
#accessory-tree { min-width: 0; margin-top: 13px; }
.accessory-joint { min-width: 0; margin-top: 13px; padding-left: clamp(0px, calc(var(--depth, var(--joint-depth, 0)) * 5px), 18px); }
.accessory-joint:first-child { margin-top: 0; }
.accessory-joint-name { display: flex; align-items: center; gap: 5px; min-width: 0; margin-bottom: 7px; font-family: var(--hand); font-size: 14px; line-height: 1.4; }
.accessory-joint-name > span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.accessory-children { min-width: 0; margin-top: 7px; padding-left: 7px; border-left: 1px solid #c4c4c4; }
.accessory-children .accessory-children { padding-left: 0; border-left: 0; }
.accessory-children .accessory-joint { padding-left: 0; }
.accessory-card { min-width: 0; margin: 8px 0; border: 1px solid #c3c3c3; border-radius: 3px 5px 2px 4px; background: #fff; }
.accessory-card.selected { border-color: var(--ink); box-shadow: 1px 1px 0 #aaa; }
.accessory-heading { display: flex; align-items: center; gap: 5px; min-width: 0; padding: 5px; }
.accessory-card.selected > .accessory-heading { position: sticky; top: 0; z-index: 1; background: #fff; }
.accessory-heading .accessory-delete { flex-shrink: 0; min-height: 28px; padding: 3px 5px; border-color: #d5d5d5; font-size: 10px; }
.accessory-heading .accessory-delete:hover { border-color: var(--ink); }
.accessory-card > #accessory-settings { padding: 8px; border-top: 1px dashed #ddd; border-bottom: 0; }
#accessory-settings summary { color: #666; font-size: 10px; cursor: pointer; }
.accessory-select { flex: 1; min-width: 0; min-height: 30px; padding: 5px 7px; font-size: 11px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.accessory-card.selected > .accessory-heading > .accessory-select, .accessory-select[aria-pressed="true"] { background: var(--ink); color: #fff; }
.accessory-card.selected > .accessory-heading > .accessory-select:hover, .accessory-select[aria-pressed="true"]:hover { background: #333; color: #fff; }
.accessory-card-options { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; padding: 6px 8px; border-top: 1px dashed #ddd; }
.accessory-card-options label { display: inline-flex; align-items: center; gap: 4px; font-size: 9px; cursor: pointer; }
.accessory-card-options input[type=checkbox] { flex-shrink: 0; margin: 0; }
.accessory-card-options select { flex: 1 1 90px; min-width: 0; max-width: 100%; min-height: 26px; padding: 3px 5px; font-size: 9px; }
.accessory-order-badge, .order-badge, .accessory-card-options small { padding: 2px 4px; border: 1px solid #ddd; border-radius: 2px 3px 2px 3px; color: #777; font-size: 8px; line-height: 1.3; white-space: nowrap; }
#accessory-hierarchy-tools > .accessory-order-section { padding: 16px 12px; }
#accessory-order-panel > summary { font-family: var(--hand); font-size: 18px; cursor: pointer; }
#accessory-draw-order { display: grid; gap: 8px; min-width: 0; margin-top: 12px; }
.accessory-order-row { display: flex; align-items: center; gap: 4px; min-width: 0; padding: 3px; border: 1px solid #d1d1d1; border-radius: 2px 4px 2px 3px; background: #fff; }
.accessory-order-row .order-select { flex: 1 1 0; min-width: 0; min-height: 28px; padding: 4px 5px; font-size: 10px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.accessory-order-row button:hover:not(:disabled) { border-color: #777; background: #f2f2f2; }
.accessory-order-row .order-select[aria-pressed="true"], .accessory-order-row.selected .order-select { background: var(--ink); color: #fff; }
.accessory-order-row .order-select[aria-pressed="true"]:hover, .accessory-order-row.selected .order-select:hover { background: #333; color: #fff; }
.accessory-order-row .order-select { white-space: normal; display: flex; flex-direction: column; gap: 3px; }
.order-name { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.order-parent { font-size: 9px; opacity: .65; }
#accessory-order-panel { max-height: 260px; overflow-y: auto; }
.selected-accessory-heading { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.selected-accessory-heading h2 { flex: 1; margin: 0; overflow-wrap: anywhere; font-family: var(--hand); font-size: 19px; }
#selected-accessory-actions { margin-top: 14px; padding-top: 12px; border-top: 1px dashed #aaa; }
#duplicate-selected-accessory, #delete-selected-accessory { font-size: 12px; padding: 8px 10px; min-height: 36px; border: 1px solid var(--ink); }
.behavior-equations textarea { display: block; width: 100%; resize: vertical; min-height: 64px; padding: 10px; border: 1px solid var(--ink); background: var(--paper, #fff); color: var(--ink); font: 13px/1.6 ui-monospace, monospace; }
.behavior-equations label { display: block; margin-top: 16px; }
.behavior-reference { margin-top: 20px; }
.behavior-reference code { overflow-wrap: anywhere; }
.live-equation-error { margin: 0; padding: 8px 16px; border-bottom: 1px dashed var(--ink); }
.accessory-shared-options { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.accessory-shared-options label { display: flex; gap: 5px; align-items: center; font-size: 11px; }
.accessory-shared-options select { font-size: 10px; min-height: 28px; padding: 3px; }
#accessory-editor-slot > div > section { padding: 16px 12px; }
.accessory-draw-settings { margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--line); }
.accessory-draw-settings h3 { margin: 0; font-family: var(--hand); font-size: 17px; }
.order-empty-helper, .order-emptyhelper, .order-empty { margin: 3px 0; color: #888; font-size: 10px; line-height: 1.5; }
.accessory-part { border-top: 1px dashed #d2d2d2; }
.accessory-part > summary { min-height: 33px; padding: 8px 10px; font-size: 11px; cursor: pointer; }
.accessory-part[open] > summary { border-bottom: 1px solid #ddd; background: #f8f8f8; }
.accessory-editor-slot { min-width: 0; }
.accessory-editor-slot:empty { display: none; }
#accessories-tools .accessory-editor-slot section { padding: 14px 10px; }
#accessories-tools .accessory-editor-slot section:last-child { border-bottom: 0; }
.accessory-editor-slot h1 { font-size: 20px; }
.accessory-editor-slot h2 { font-size: 18px; }
.accessory-editor-slot .section-heading { gap: 5px; }
.accessory-editor-slot .section-number { display: none; }
.accessory-editor-slot .brush-options { flex-wrap: wrap; gap: 5px; }
.accessory-editor-slot .layer-actions { flex-wrap: wrap; }
.accessory-editor-slot .layer-icon { display: none; }
.accessory-editor-slot .layer-select { gap: 0; padding-inline: 4px; }
.accessory-editor-slot .mirror-toggle { flex-basis: 24px; width: 24px; min-width: 24px; margin-inline: 1px; }
.accessory-editor-slot .visibility { width: 28px; min-width: 28px; padding-inline: 2px; font-size: 8px; }
.accessory-editor-slot .joint-row { gap: 3px; }
.accessory-editor-slot .joint-row > .joint-reset { flex-basis: 64px; width: 64px; padding-inline: 2px; }
.accessory-editor-slot button.wide { white-space: normal; }
.stage { flex: 1; position: relative; min-width: 0; overflow: hidden; background: #f4f4f4; }
.stage::before { content: ""; position: absolute; top: 0; bottom: 0; left: 5px; width: 11px; background: radial-gradient(circle at 5px 15px, #fff 0 3px, #b8b8b8 3.4px 4px, transparent 4.5px) 0 0 / 11px 36px; pointer-events: none; z-index: 1; }
#canvas { display: block; width: 100%; height: 100%; touch-action: none; outline-offset: -3px; }
.stage-label { position: absolute; top: 20px; left: 30px; right: 24px; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; color: #8a8a8a; font-size: 8px; letter-spacing: 1.8px; z-index: 2; }
.stage-label > span:first-child { display: flex; align-items: center; gap: 10px; }
.stage-label svg { width: 37px; height: 16px; stroke-width: 1; color: #999; margin-top: 3px; }
.stage-label span:last-child { letter-spacing: 0; font-size: 9px; }
.stage-hint { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%) rotate(-.4deg); max-width: calc(100% - 45px); padding: 9px 13px; border-radius: 2px 3px 2px 1px; background: #ffffffed; box-shadow: 1px 1px 0 #ddd; pointer-events: none; font-size: 9px; line-height: 1.5; color: #777; text-align: center; width: max-content; border: 1px solid #d4d4d4; }
footer { min-height: 31px; background: #fff; border-top: 1px solid #aaa; display: flex; justify-content: space-between; align-items: center; padding: 6px 22px; font-size: 9px; color: #888; gap: 16px; }
footer span:last-child { font-size: 8px; white-space: nowrap; letter-spacing: .2px; }
footer i { display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: #777; margin: 0 7px; }
footer a { color: #333; font-size: 9px; white-space: nowrap; }
#status { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.autosave-state { flex-shrink: 0; max-width: 55%; color: #666; font-size: 9px; line-height: 1.4; text-align: right; }
#clear-creature-dialog, #rename-dialog, #creature-import-dialog { width: min(420px, calc(100vw - 40px)); max-height: calc(100dvh - 40px); padding: 0; overflow-y: auto; border: 2px solid var(--ink); border-radius: 4px 2px 6px 3px; background: var(--paper); color: var(--ink); box-shadow: 5px 5px 0 #0003; }
#clear-creature-dialog::backdrop, #rename-dialog::backdrop, #creature-import-dialog::backdrop { background: #0006; }
#clear-creature-dialog form, #rename-dialog form, #creature-import-dialog form { padding: 24px; }
#clear-creature-dialog h2, #rename-dialog h2, #creature-import-dialog h2 { margin: 0; font-family: var(--hand); font-size: 26px; font-weight: 500; line-height: 1.2; }
#clear-creature-dialog p, #rename-dialog p, #creature-import-dialog p { margin: 14px 0 0; color: #666; font-size: 12px; line-height: 1.6; }
.rename-name-label { display: block; margin: 18px 0 6px; color: #666; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 24px; padding: 0 3px 3px 0; }
.dialog-actions button { min-height: 34px; }
#export-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 22px; overflow-y: auto; border: 2px solid var(--ink); border-radius: 4px 2px 6px 3px; background: var(--paper); color: var(--ink); box-shadow: 5px 5px 0 #0003; }
#export-dialog::backdrop { background: #0006; }
.export-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.export-heading h2 { margin: 0; font-family: var(--hand); font-size: 27px; font-weight: 500; }
#export-size { color: #666; font-family: ui-monospace, monospace; font-size: 11px; white-space: nowrap; }
#export-description { margin: 9px 0 18px; color: #666; line-height: 1.5; }
.export-layout { display: grid; grid-template-columns: minmax(0,1fr) 180px; align-items: start; gap: 20px; }
.export-preview-area { display: flex; justify-content: center; align-items: center; min-height: 280px; height: min(48vh,340px); padding: 12px; border: 1px dashed #bbb; background: #f2f2f2; }
#export-preview { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; border: 1px solid #666; background: conic-gradient(#e4e4e4 25%,#fff 0 50%,#e4e4e4 0 75%,#fff 0) 0 0 / 16px 16px; cursor: grab; touch-action: none; }
#export-preview.panning { cursor: grabbing; }
#export-empty { max-width: 240px; color: #777; text-align: center; line-height: 1.6; }
#export-controls h3 { margin: 1px 0 15px; font-family: var(--hand); font-size: 18px; font-weight: 500; }
.export-zoom-heading { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
#export-zoom-value { font-family: ui-monospace, monospace; font-size: 11px; }
#export-preview-help { margin: 10px 0 0; }
#export-dialog .dialog-actions { margin-top: 18px; }
#live-dialog { width: min(1120px, calc(100vw - 28px)); height: min(760px, calc(100dvh - 28px)); max-height: calc(100dvh - 28px); padding: 0; overflow: hidden; border: 2px solid var(--ink); border-radius: 4px 2px 6px 3px; background: var(--paper); color: var(--ink); box-shadow: 5px 5px 0 #0003; }
#live-dialog::backdrop { background: #0006; }
.live-test-shell { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.live-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 14px 16px; }
.live-title-line { display: flex; align-items: center; gap: 12px; }
.live-title-line h2 { margin: 0; font-family: var(--hand); font-size: 25px; font-weight: 500; }
#live-status { padding: 3px 7px; border: 1px dashed #aaa; border-radius: 3px; color: #666; font-size: 10px; }
#live-creature-name { margin: 3px 0 0; color: #777; font-size: 10px; }
.live-actions { display: flex; align-items: center; gap: 7px; }
.live-actions button { min-height: 32px; font-size: 11px; }
.live-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 8px 16px; border-block: 1px solid #ddd; background: #fff; }
.live-toolbar label { display: flex; align-items: center; gap: 5px; font-size: 10px; cursor: pointer; }
.live-toolbar input { margin: 0; }
.live-toolbar > span { margin-left: auto; color: #777; font-size: 10px; }
.live-world { position: relative; flex: 1; min-height: 150px; overflow: hidden; background: #fafafa; }
#live-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
#live-no-art { position: absolute; top: 10px; left: 14px; margin: 0; padding: 6px 8px; background: #ffffffdf; border: 1px dashed #ccc; color: #666; font-size: 10px; pointer-events: none; }
.live-footer { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)) minmax(90px,.6fr); gap: 12px; padding: 10px 16px; border-top: 1px solid #ccc; background: #fff; }
.live-readout { min-width: 0; }
.live-readout span { display: block; margin-bottom: 4px; color: #777; font-size: 9px; }
.live-readout output { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 11px ui-monospace, monospace; }
@media (max-width: 650px) {
  .live-header { padding: 10px 12px; }
  .live-title-line h2 { font-size: 21px; }
  .live-actions { gap: 5px; }
  .live-actions button { padding-inline: 7px; font-size: 10px; }
  .live-toolbar { padding-inline: 12px; gap: 10px; }
  .live-toolbar > span { width: 100%; margin-left: 0; }
  .live-footer { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; padding: 8px 12px; }
}
@media (max-width: 560px) {
  #export-dialog { padding: 16px; }
  .export-layout { grid-template-columns: 1fr; gap: 16px; }
  .export-heading { align-items: flex-start; flex-direction: column; gap: 5px; }
  .export-preview-area { min-height: 180px; height: 30vh; }
  #export-controls h3 { margin-bottom: 8px; }
}
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 900px) {
  .app-header { padding-inline: 19px; gap: 12px; }
  .brand strong { font-size: 25px; }
  .brand-mark { width: 76px; }
  .brand { gap: 9px; }
  .file-actions { gap: 4px; }
  .file-actions button { font-size: 10px; padding-inline: 7px; }
  .file-actions .primary { padding-inline: 11px; }
  .page-caption .badge, .page-caption .caption-line { display: none; }
  .sidebar { width: 244px; }
  .sidebar section { padding: 18px 15px 18px 23px; }
}
@media (max-width: 690px) {
  .view-bar { padding-inline: 12px; }
  .app-header { min-height: 74px; padding: 10px 12px; }
  .brand strong { font-size: 22px; }
  .brand-mark { width: 64px; }
  .brand div > span { font-size: 7px; letter-spacing: 1.4px; }
  .file-actions button { min-height: 30px; font-size: 9px; padding-inline: 5px; }
  .file-actions svg { display: none; }
  .file-actions .primary { margin-left: 2px; padding-inline: 8px; }
  .workspace-bar { padding-inline: 13px; gap: 8px; }
  .editing-controls { gap: 8px; }
  .history-actions { margin-left: 2px; padding-left: 8px; }
  .history-actions button { padding-inline: 5px; font-size: 9px; }
  .history-actions button span { font-size: 14px; }
  .page-caption { gap: 7px; }
  .caption-line { width: 12px; }
  .view-controls { gap: 3px; }
  .view-controls button, .view-controls select { font-size: 9px; }
  .view-controls output { font-size: 9px; }
  .sidebar { width: 210px; }
  .sidebar section { padding: 17px 12px 17px 21px; }
  .sidebar h1 { font-size: 21px; }
  .sidebar .intro { font-size: 10px; }
  .tool-options { gap: 5px; }
  .tool-options button { min-height: 58px; }
  .two-buttons { gap: 5px; }
  .two-buttons button { font-size: 9px; }
  .stage-label { left: 24px; right: 12px; }
  .stage-label span:last-child { display: none; }
  .stage-label svg { display: none; }
  footer span:last-child { display: none; }
}
@media (max-width: 470px) {
  .app-header { flex-wrap: wrap; justify-content: center; gap: 10px; padding-bottom: 12px; }
  .brand { width: 100%; justify-content: center; }
  .brand strong { font-size: 25px; }
  .brand div > span { text-align: center; }
  .file-actions { width: 100%; justify-content: center; gap: 7px; }
  .file-actions button { font-size: 10px; }
  .workspace-name { font-size: 13px; }
  .page-caption { flex-basis: 100%; }
  .badge, .caption-line { display: none; }
  .sidebar { width: 180px; }
  .sidebar section { padding: 15px 10px 15px 19px; }
  .layer-icon { display: none; }
  .layer-select { gap: 0; }
  .joint-row { gap: 3px; }
  .joint-row > .joint-reset { flex-basis: 64px; width: 64px; padding-inline: 2px; }
  .two-buttons { flex-direction: column; }
  .editing-controls { width: 100%; justify-content: space-between; }
  .history-actions { margin-left: 0; padding-left: 0; border-left: 0; }
  .brush-options { gap: 5px; }
  .tool-options { gap: 4px; }
  .tool-options button { font-size: 9px; min-height: 52px; padding-inline: 3px; }
  .tool-options button svg { width: 20px; height: 20px; }
  .stage-hint { font-size: 8px; padding: 7px 9px; }
}

/* Keep creature actions usable as the notebook header gets narrower. */
@media (max-width: 1200px) {
  .app-header { flex-wrap: wrap; }
  .file-actions { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
}

#input-settings-menu { position: fixed; inset: auto; margin: 0; width: 320px; max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow: auto; padding: 17px; border: 1.5px solid var(--ink); border-radius: 3px 6px 2px 4px; background: #fff; color: var(--ink); box-shadow: 3px 3px 0 #0002; }
.input-settings-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.input-settings-heading h2 { margin: 0; font: 24px var(--hand); }
.input-settings-heading button { min-height: 26px; padding: 3px 7px; border: 1px solid #ccc; }
#input-settings-menu p { font-size: 11px; line-height: 1.6; }
.input-profile-tabs { display: flex; gap: 5px; margin: 17px 0 20px; padding-bottom: 8px; border-bottom: 1px dashed #aaa; }
.input-profile-tabs button { flex: 1; font-size: 11px; border: 1px solid #aaa; }
.input-profile-tabs button[aria-selected="true"] { color: #fff; background: var(--ink); border-color: var(--ink); }
#input-profile-panel label { display: block; font-size: 12px; margin-top: 16px; }
#input-profile-panel output { float: right; font-variant-numeric: tabular-nums; }
#input-profile-panel input { display: block; width: 100%; margin: 11px 0 0; }
#input-profile-panel p { margin-top: 6px; }
#input-reset-profile { font-size: 11px; margin-top: 6px; }
#input-settings-status { min-height: 18px; margin-bottom: 0; }
.onion-skin-controls { margin: 12px 0; padding: 10px; border: 1px dashed #aaa; border-radius: 2px 4px 2px 3px; min-width: 0; }
.onion-skin-controls label { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; }
.onion-skin-controls input[type="checkbox"] { margin: 0; }
.onion-directions { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 12px; }
.onion-skin-controls .section-heading { margin-bottom: 4px; }
.onion-skin-controls p { margin-bottom: 0; }
