:root {
  color-scheme: light;
  --ink: #17151d;
  --muted: #706c7d;
  --panel: #fffaf0;
  --panel-glass: rgba(255, 250, 240, 0.96);
  --paper: #fdfbf6;
  --line: #ded7ca;
  --accent: #2ec4b6;
  --coral: #f25f5c;
  --app-bg: #ece7dc;
  --surface-wash: #f7f0e4;
  --button-bg: #f7f0e4;
  --button-hover: #ffffff;
  --button-border: #bfb6a8;
  --active-text: #fffaf0;
  --input-bg: #fffdf8;
  --progress-bg: #d9d0c0;
  --checker-bg: #cfc8bc;
  --checker-mark: rgba(0, 0, 0, 0.045);
  --selection-stroke: #15131b;
  --selection-fill: rgba(46, 196, 182, 0.14);
  --shadow: 0 18px 44px rgba(31, 28, 42, 0.16);
  --soft-highlight: rgba(255, 255, 255, 0.74);
}

body[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f7f2e8;
  --muted: #b9b0c8;
  --panel: #211e2a;
  --panel-glass: rgba(33, 30, 42, 0.96);
  --paper: #fdfbf6;
  --line: #423b51;
  --app-bg: #15131b;
  --surface-wash: #211e2a;
  --button-bg: #2a2634;
  --button-hover: #373142;
  --button-border: #5d536d;
  --active-text: #101015;
  --input-bg: #191620;
  --progress-bg: #3a3347;
  --checker-bg: #2b2634;
  --checker-mark: rgba(255, 255, 255, 0.055);
  --selection-stroke: #f7f2e8;
  --selection-fill: rgba(46, 196, 182, 0.2);
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
  --soft-highlight: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 8%, rgba(46, 196, 182, 0.18), transparent 28%),
    radial-gradient(circle at 88% 16%, rgba(242, 95, 92, 0.16), transparent 26%),
    linear-gradient(135deg, var(--app-bg), var(--surface-wash));
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 10px var(--studio-width, 292px);
  gap: 8px;
  width: 100vw;
  height: 100dvh;
  padding: 12px;
}

.app-shell.panel-floating {
  grid-template-columns: 72px minmax(0, 1fr);
}

.panel-splitter {
  align-self: stretch;
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 0 3px, var(--line) 3px 7px, transparent 7px 10px);
  cursor: ew-resize;
  touch-action: none;
}

.panel-splitter:hover,
.panel-splitter.active {
  background:
    linear-gradient(90deg, transparent 0 2px, var(--accent) 2px 8px, transparent 8px 10px);
}

.tool-rail,
.settings-panel,
.top-bar {
  background: var(--panel-glass);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.12);
}

.tool-rail {
  display: grid;
  align-content: start;
  gap: 10px;
  max-height: calc(100dvh - 24px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px;
  border-radius: 8px;
  scrollbar-width: thin;
  touch-action: pan-y;
}

.tool-rail::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.tool-rail::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 42%, var(--line));
}

.tool,
.icon-button {
  --tool-accent: var(--accent);
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border: 1px solid color-mix(in srgb, var(--tool-accent) 18%, var(--line));
  border-radius: 8px;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--tool-accent) 16%, var(--button-bg)), var(--button-bg));
  color: var(--tool-accent);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  box-shadow: inset 0 1px 0 var(--soft-highlight), 0 6px 18px rgba(31, 28, 42, 0.08);
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.tool:hover,
.icon-button:hover,
.canvas-actions button:hover,
.shape-actions button:hover,
.selection-actions button:hover,
.panel-tab:hover,
.section-head button:hover,
.brush-preset:hover,
.layer-actions button:hover,
.layer-row:hover {
  transform: translateY(-1px);
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--tool-accent, var(--accent)) 24%, var(--button-hover)), var(--button-hover));
  border-color: color-mix(in srgb, var(--tool-accent, var(--accent)) 48%, var(--button-border));
  box-shadow: inset 0 1px 0 var(--soft-highlight), 0 10px 22px rgba(31, 28, 42, 0.13);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
  transform: none;
}

.tool.active {
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--tool-accent) 88%, #ffffff 8%), var(--tool-accent));
  color: #fffdf8;
  border-color: color-mix(in srgb, var(--tool-accent) 70%, var(--ink));
  box-shadow: 0 10px 26px color-mix(in srgb, var(--tool-accent) 36%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.icon-button.danger {
  color: var(--coral);
}

.tool[data-tool="brush"] { --tool-accent: #2ec4b6; }
.tool[data-tool="eraser"] { --tool-accent: #ff8fab; }
.tool[data-tool="smudge"] { --tool-accent: #8b5cf6; }
.tool[data-tool="liquify"] { --tool-accent: #4dabf7; }
.tool[data-tool="eyedropper"] { --tool-accent: #ffbf46; }
.tool[data-tool="fill"] { --tool-accent: #0ead69; }
.tool[data-tool="line"] { --tool-accent: #f25f5c; }
.tool[data-tool="rect"] { --tool-accent: #7057ff; }
.tool[data-tool="ellipse"] { --tool-accent: #ff7a00; }
.tool[data-tool="selectRect"] { --tool-accent: #1f7a8c; }
.tool[data-tool="lasso"] { --tool-accent: #b388ff; }
.tool[data-tool="moveSelection"] { --tool-accent: #6bcf63; }
.rail-action { --tool-accent: #f25f5c; }

.tool-icon {
  position: relative;
  display: block;
  width: 26px;
  height: 26px;
}

.tool-icon::before,
.tool-icon::after {
  content: "";
  position: absolute;
  display: block;
}

.icon-brush::before {
  left: 10px;
  top: 1px;
  width: 7px;
  height: 22px;
  border-radius: 7px;
  background: currentColor;
  transform: rotate(38deg);
}

.icon-brush::after {
  left: 2px;
  bottom: 1px;
  width: 12px;
  height: 8px;
  border-radius: 8px 8px 3px 3px;
  background: currentColor;
  transform: rotate(38deg);
}

.icon-eraser::before {
  left: 4px;
  top: 7px;
  width: 18px;
  height: 12px;
  border-radius: 4px;
  background: currentColor;
  transform: rotate(-24deg);
}

.icon-eraser::after {
  left: 14px;
  top: 14px;
  width: 9px;
  height: 4px;
  border-radius: 3px;
  background: var(--button-bg);
  transform: rotate(-24deg);
}

.icon-smudge::before,
.icon-liquify::before {
  inset: 4px;
  border: 3px solid currentColor;
  border-left-color: transparent;
  border-radius: 50%;
}

.icon-smudge::after,
.icon-liquify::after {
  left: 6px;
  top: 11px;
  width: 15px;
  height: 4px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 7px 0 currentColor;
}

.icon-liquify::before {
  border-radius: 45% 55% 50% 50%;
  transform: rotate(24deg);
}

.icon-eyedropper::before {
  left: 11px;
  top: 1px;
  width: 6px;
  height: 23px;
  border-radius: 999px;
  background: currentColor;
  transform: rotate(42deg);
}

.icon-eyedropper::after {
  left: 2px;
  bottom: 2px;
  width: 10px;
  height: 7px;
  border-radius: 0 0 8px 8px;
  border: 3px solid currentColor;
  border-top: 0;
  transform: rotate(42deg);
}

.bucket-icon {
  position: relative;
  display: block;
  width: 25px;
  height: 22px;
  transform: rotate(-24deg);
}

.bucket-icon::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 5px;
  width: 15px;
  height: 13px;
  border: 3px solid currentColor;
  border-top-width: 4px;
  border-radius: 3px 3px 6px 6px;
}

.bucket-icon::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 9px;
  height: 9px;
  border-radius: 50% 50% 50% 0;
  background: currentColor;
  transform: rotate(-18deg);
}

.icon-line::before {
  left: 4px;
  top: 12px;
  width: 20px;
  height: 4px;
  border-radius: 999px;
  background: currentColor;
  transform: rotate(-38deg);
}

.icon-rect::before,
.icon-select::before {
  inset: 5px;
  border: 3px solid currentColor;
  border-radius: 4px;
}

.icon-select::before {
  border-style: dashed;
}

.icon-ellipse::before {
  inset: 5px 4px;
  border: 3px solid currentColor;
  border-radius: 50%;
}

.icon-lasso::before {
  left: 3px;
  top: 5px;
  width: 18px;
  height: 13px;
  border: 3px solid currentColor;
  border-radius: 58% 42% 52% 48%;
  transform: rotate(-12deg);
}

.icon-lasso::after {
  right: 3px;
  bottom: 3px;
  width: 9px;
  height: 3px;
  border-radius: 999px;
  background: currentColor;
  transform: rotate(42deg);
}

.icon-move::before {
  left: 12px;
  top: 3px;
  width: 3px;
  height: 20px;
  border-radius: 999px;
  background: currentColor;
}

.icon-move::after {
  left: 3px;
  top: 12px;
  width: 20px;
  height: 3px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 999px transparent;
}

.icon-deselect::before,
.icon-deselect::after {
  left: 4px;
  top: 11px;
  width: 19px;
  height: 4px;
  border-radius: 999px;
  background: currentColor;
}

.icon-deselect::before {
  transform: rotate(45deg);
}

.icon-deselect::after {
  transform: rotate(-45deg);
}

.stage-wrap {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  gap: 12px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 10px 14px;
  border-radius: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mascot-logo {
  --tool-accent: #ff8fab;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid color-mix(in srgb, #ff8fab 42%, var(--line));
  border-radius: 8px;
  background:
    radial-gradient(circle at 62% 26%, rgba(255, 255, 255, 0.68), transparent 22%),
    linear-gradient(145deg, #ffd166, #ff8fab);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 10px 24px rgba(255, 143, 171, 0.22);
  cursor: pointer;
}

.starfish {
  position: relative;
  display: block;
  width: 31px;
  height: 31px;
  background:
    radial-gradient(circle at 33% 34%, #ffd166 0 6%, transparent 7%),
    radial-gradient(circle at 66% 30%, #ffd166 0 5%, transparent 6%),
    radial-gradient(circle at 54% 63%, #ffd166 0 5%, transparent 6%),
    #ff8fab;
  clip-path: polygon(50% 0, 64% 31%, 99% 16%, 76% 48%, 97% 84%, 59% 71%, 31% 100%, 35% 62%, 0 54%, 34% 39%);
  filter: drop-shadow(0 2px 0 rgba(111, 51, 78, 0.18));
}

.starfish::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: #ffb3c8;
}

.starfish.big {
  width: 96px;
  height: 96px;
  background:
    radial-gradient(circle at 30% 30%, #ffd166 0 5%, transparent 6%),
    radial-gradient(circle at 64% 28%, #ffd166 0 4%, transparent 5%),
    radial-gradient(circle at 72% 58%, #ffd166 0 4%, transparent 5%),
    radial-gradient(circle at 42% 70%, #ffd166 0 4%, transparent 5%),
    radial-gradient(circle at 50% 42%, #ffc2d2 0 20%, transparent 21%),
    #ff8fab;
}

.starfish-eye {
  position: absolute;
  z-index: 1;
  top: 12px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #3b2430;
}

.starfish.big .starfish-eye {
  top: 38px;
  width: 9px;
  height: 9px;
}

.eye-left {
  left: 12px;
}

.eye-right {
  right: 11px;
}

.starfish.big .eye-left {
  left: 37px;
}

.starfish.big .eye-right {
  right: 34px;
}

.starfish-smile {
  position: absolute;
  z-index: 1;
  left: 12px;
  top: 17px;
  width: 9px;
  height: 5px;
  border-bottom: 2px solid #3b2430;
  border-radius: 0 0 999px 999px;
}

.starfish.big .starfish-smile {
  left: 38px;
  top: 52px;
  width: 23px;
  height: 12px;
  border-bottom-width: 4px;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.05;
}

p {
  color: var(--muted);
  font-size: 13px;
}

.file-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.top-tool,
.top-save {
  display: grid;
  place-items: center;
  min-width: 72px;
  height: 50px;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--line));
  border-radius: 8px;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--accent) 76%, #ffffff 8%), var(--accent));
  color: #fffdf8;
  cursor: pointer;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.36), 0 8px 20px rgba(46, 196, 182, 0.16);
}

.top-tool {
  border-color: var(--line);
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--coral) 12%, var(--button-bg)), var(--button-bg));
  color: var(--ink);
  box-shadow: inset 0 1px 0 var(--soft-highlight);
}

.top-tool:hover,
.top-save:hover {
  transform: translateY(-1px);
  background: var(--button-hover);
  color: var(--ink);
}

.proof-toggle.recording {
  border-color: var(--coral);
  background: color-mix(in srgb, var(--coral) 18%, var(--button-bg));
  color: var(--ink);
  box-shadow: 0 0 0 3px rgba(242, 95, 92, 0.16);
}

.file-select {
  appearance: auto;
  padding: 0 26px 0 12px;
}

.file-hidden-input {
  display: none;
}

.theme-toggle {
  min-width: 72px;
  height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(145deg, color-mix(in srgb, #7057ff 14%, var(--button-bg)), var(--button-bg));
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  background: var(--button-hover);
  border-color: var(--button-border);
}

.tour-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: block;
  padding: 18px;
  background: transparent;
  pointer-events: none;
}

.tour-backdrop[hidden] {
  display: none;
}

.tour-card {
  position: fixed;
  left: 50%;
  top: 50%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px;
  width: min(620px, calc(100vw - 28px));
  padding: 18px;
  border: 1px solid color-mix(in srgb, #ff8fab 36%, var(--line));
  border-radius: 8px;
  background:
    radial-gradient(circle at 16% 12%, rgba(255, 191, 70, 0.26), transparent 32%),
    var(--panel-glass);
  box-shadow: 0 26px 70px rgba(23, 21, 29, 0.26);
  transition: left 220ms ease, top 220ms ease, transform 220ms ease;
  animation: tourHop 260ms ease both;
  pointer-events: auto;
}

.tour-card::before {
  content: "";
  position: absolute;
  left: 42px;
  top: -12px;
  width: 24px;
  height: 24px;
  border-left: 1px solid color-mix(in srgb, #ff8fab 36%, var(--line));
  border-top: 1px solid color-mix(in srgb, #ff8fab 36%, var(--line));
  background: var(--panel-glass);
  transform: rotate(45deg);
}

@keyframes tourHop {
  from {
    transform: translateY(10px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.tour-highlight {
  position: relative;
  z-index: 45;
  outline: 3px solid #ffbf46;
  outline-offset: 5px;
  box-shadow: 0 0 0 10px rgba(255, 191, 70, 0.22), 0 0 34px rgba(255, 143, 171, 0.42) !important;
  animation: tourPulse 900ms ease-in-out infinite alternate;
}

@keyframes tourPulse {
  from {
    outline-offset: 4px;
  }
  to {
    outline-offset: 8px;
  }
}

.tour-mascot {
  display: grid;
  place-items: center;
  width: 120px;
  min-height: 132px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 65% 25%, rgba(255, 255, 255, 0.82), transparent 18%),
    linear-gradient(145deg, rgba(255, 191, 70, 0.34), rgba(255, 143, 171, 0.28));
  animation: starbyBob 1500ms ease-in-out infinite alternate;
}

@keyframes starbyBob {
  from {
    transform: rotate(-1deg) translateY(0);
  }
  to {
    transform: rotate(1deg) translateY(-4px);
  }
}

.tour-copy {
  display: grid;
  align-content: center;
  gap: 8px;
  min-width: 0;
}

.tour-kicker {
  color: var(--coral);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.tour-copy h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.05;
}

.tour-copy p {
  font-size: 15px;
  line-height: 1.45;
}

.tour-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
}

.tour-actions button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.tour-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

#tourNext {
  border-color: color-mix(in srgb, var(--accent) 54%, var(--line));
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--accent) 76%, #ffffff 8%), var(--accent));
  color: #fffdf8;
}

.flow-backdrop {
  position: fixed;
  inset: 0;
  z-index: 38;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(23, 21, 29, 0.12);
}

.flow-backdrop[hidden],
.flow-panel[hidden] {
  display: none;
}

.flow-orbit {
  position: relative;
  width: min(340px, calc(100vw - 36px));
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--panel-glass) 0 34%, transparent 35%),
    conic-gradient(from -18deg, rgba(46, 196, 182, 0.24), rgba(255, 191, 70, 0.26), rgba(242, 95, 92, 0.23), rgba(112, 87, 255, 0.24), rgba(46, 196, 182, 0.24));
  box-shadow: var(--shadow);
}

.flow-center,
.flow-choice {
  position: absolute;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel-glass);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(31, 28, 42, 0.16);
}

.flow-center {
  inset: 50%;
  width: 92px;
  height: 92px;
  transform: translate(-50%, -50%);
}

.flow-choice {
  width: 82px;
  height: 82px;
}

.flow-color { left: 50%; top: 3%; transform: translateX(-50%); }
.flow-canvas { right: 8%; top: 18%; }
.flow-export { right: 8%; bottom: 18%; }
.flow-layers { left: 50%; bottom: 3%; transform: translateX(-50%); }
.flow-brushes { left: 8%; bottom: 18%; }
.flow-focus { left: 8%; top: 18%; }

.flow-panel {
  position: fixed;
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-glass);
  box-shadow: var(--shadow);
}

.flow-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.flow-panel-head h2,
.flow-panel-head p {
  margin: 0;
}

.flow-panel-head p {
  color: var(--coral);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.flow-panel-head button,
.flow-grid button,
#flowResizeCanvas,
#estimateExport,
#flowDownloadExport {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.flow-panel-body,
.flow-section {
  display: grid;
  gap: 12px;
}

.flow-section[hidden] {
  display: none;
}

.flow-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.flow-section label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.flow-section label > span,
.flow-section label > output {
  color: var(--ink);
}

.flow-section input,
.flow-section select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--ink);
  padding: 0 10px;
}

.flow-section input[type="range"] {
  min-height: auto;
  padding: 0;
}

.flow-check {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.flow-check input {
  width: 20px;
  min-height: 20px;
}

.export-presets button:nth-child(1) { border-color: rgba(46, 196, 182, 0.48); }
.export-presets button:nth-child(2) { border-color: rgba(255, 191, 70, 0.52); }
.export-presets button:nth-child(3) { border-color: rgba(112, 87, 255, 0.45); }
.export-presets button:nth-child(4) { border-color: rgba(242, 95, 92, 0.42); }
.export-presets button:nth-child(5) { border-color: rgba(34, 153, 84, 0.38); }
.export-presets button:nth-child(6) { border-color: rgba(13, 138, 188, 0.38); }

.export-estimate {
  margin: 0;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--button-bg) 76%, transparent);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.flow-color-wheel {
  justify-self: center;
  width: min(220px, 70vw);
  aspect-ratio: 1;
  border: 8px solid var(--button-bg);
  border-radius: 50%;
  background:
    radial-gradient(circle, #ffffff 0 8%, transparent 9%),
    conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
  cursor: crosshair;
  box-shadow: inset 0 0 0 1px var(--line), 0 14px 30px rgba(31, 28, 42, 0.14);
}

.flow-hex-readout {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
}

.flow-hex-readout span {
  width: 42px;
  height: 42px;
  border: 1px solid var(--button-border);
  border-radius: 8px;
  background: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.flow-hex-readout output {
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.flow-adjust {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--input-bg) 86%, transparent);
}

.flow-adjust button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.flow-adjust-status {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.flow-adjust-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

body.focus-mode .tool-rail,
body.focus-mode .settings-panel,
body.focus-mode .panel-splitter {
  display: none;
}

body.focus-mode .app-shell {
  grid-template-columns: minmax(0, 1fr);
  padding: 0;
}

body.focus-mode .stage-wrap {
  gap: 0;
}

.file-pick input {
  display: none;
}

.canvas-frame {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(45deg, var(--checker-mark) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-mark) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-mark) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-mark) 75%);
  background-color: var(--checker-bg);
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
  box-shadow: inset 0 0 0 1px rgba(23, 21, 29, 0.2);
}

canvas {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  max-width: none;
  background: var(--paper);
  box-shadow: 0 22px 64px rgba(31, 28, 42, 0.25);
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
  transform-origin: center center;
}

.selection-overlay {
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}

.cursor-preview {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 1.5px solid rgba(23, 21, 29, 0.75);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%);
  mix-blend-mode: multiply;
}

.selection-box {
  position: absolute;
  border: 2px dashed var(--selection-stroke);
  background: var(--selection-fill);
  box-shadow: 0 0 0 1px rgba(255, 250, 240, 0.85), inset 0 0 0 1px rgba(255, 250, 240, 0.85);
  pointer-events: none;
}

.settings-panel {
  position: relative;
  display: grid;
  align-content: start;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  overflow: auto;
  padding: 14px;
  border-radius: 8px;
  min-width: 260px;
}

.settings-panel.floating {
  position: fixed;
  z-index: 18;
  left: calc(100vw - 340px);
  top: 84px;
  width: 320px;
  height: min(720px, calc(100dvh - 108px));
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px);
}

.app-shell.panel-floating .panel-splitter {
  display: none;
}

.settings-panel.floating .panel-resize-handle {
  display: grid;
}

.panel-resize-handle {
  display: none;
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 4;
  place-items: center;
  width: 54px;
  height: 54px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  border-radius: 8px 0 8px 0;
  background: var(--button-bg);
  color: var(--muted);
  cursor: nwse-resize;
  touch-action: none;
  font-size: 12px;
  font-weight: 900;
}

.panel-resize-handle::before {
  content: "";
  width: 22px;
  height: 22px;
  background:
    linear-gradient(135deg, transparent 0 48%, currentColor 49% 53%, transparent 54%),
    linear-gradient(135deg, transparent 0 62%, currentColor 63% 67%, transparent 68%),
    linear-gradient(135deg, transparent 0 76%, currentColor 77% 81%, transparent 82%);
}

.panel-dock-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 0 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  cursor: grab;
  touch-action: none;
}

.panel-dock-bar:active {
  cursor: grabbing;
}

.panel-dock-bar div {
  display: flex;
  gap: 6px;
}

.panel-dock-bar button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--ink);
  cursor: pointer;
}

.panel-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--input-bg) 78%, transparent);
}

.panel-tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.panel-tab.active {
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--accent) 82%, #ffffff 8%), var(--accent));
  color: #fffdf8;
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line));
  box-shadow: 0 8px 18px rgba(46, 196, 182, 0.18);
}

.tab-panel {
  display: none;
  min-height: 0;
}

.tab-panel.active {
  display: grid;
  align-content: start;
  gap: 18px;
  min-height: 0;
  overflow: auto;
  padding-bottom: 8px;
}

.component-tray {
  position: relative;
  min-height: 56px;
  max-height: min(420px, 42dvh);
  overflow: auto;
  scrollbar-width: thin;
  padding-bottom: 38px;
}

.tray-resize-handle {
  position: sticky;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  min-height: 36px;
  margin: 10px -2px -32px;
  border-top: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--muted);
  cursor: ns-resize;
  touch-action: none;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
}

.tray-resize-handle span {
  display: grid;
  grid-template-columns: 36px auto 36px;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.tray-resize-handle span::before,
.tray-resize-handle span::after {
  content: "";
  height: 4px;
  border-top: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  opacity: 0.72;
}

.tray-resize-handle:hover,
.tray-resize-handle.active,
.panel-resize-handle:hover {
  background: var(--button-hover);
  color: var(--ink);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 14px;
}

.section-head button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
}

.mini-actions {
  display: flex;
  gap: 6px;
}

.brush-panel {
  display: grid;
  gap: 10px;
  min-height: 112px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
}

.brush-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  max-height: none;
  overflow: auto;
}

.brush-library-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-height: 0;
  overflow: auto;
}

.brush-library-tools {
  display: grid;
  gap: 10px;
}

.brush-library-tools input {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--ink);
}

.brush-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.brush-filter-row button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.brush-filter-row button.active {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line));
  background: var(--accent);
  color: #fffdf8;
}

.brush-library-list .brush-preset {
  min-height: 74px;
}

.brush-preset {
  display: grid;
  gap: 4px;
  min-height: 52px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.brush-preset.active {
  border-color: var(--accent);
  background: var(--button-hover);
  box-shadow: inset 3px 0 0 var(--accent);
}

.brush-preset.rich {
  grid-template-columns: minmax(0, 1fr) auto;
}

.brush-preset.rich .brush-meta,
.brush-preset.rich .brush-tags {
  grid-column: 1 / -1;
}

.brush-favorite {
  grid-row: 1;
  grid-column: 2;
  align-self: start;
  padding: 4px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, #ffbf46 22%, var(--button-bg));
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
}

.brush-favorite.active {
  background: #ffbf46;
  color: #17151d;
}

.brush-tags {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.brush-empty {
  grid-column: 1 / -1;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}

.brush-name {
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brush-meta {
  color: var(--muted);
  font-size: 11px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 21, 29, 0.38);
}

.modal-backdrop[hidden] {
  display: none;
}

.brush-modal,
.brush-library-modal,
.proof-modal {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 14px;
  width: min(620px, 100%);
  max-height: min(720px, 92dvh);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 30px 90px rgba(23, 21, 29, 0.34);
}

.brush-library-modal {
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(720px, 100%);
}

.proof-modal {
  grid-template-rows: auto auto auto auto auto;
  width: min(520px, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.modal-head h2,
.wizard-step h3 {
  margin: 0;
}

.modal-head h2 {
  font-size: 22px;
}

.modal-head p,
.proof-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.proof-clock {
  display: grid;
  gap: 4px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
}

.proof-clock strong {
  color: var(--coral);
  font-size: 42px;
  line-height: 1;
}

.proof-clock span,
.proof-stats {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.proof-meter {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: var(--progress-bg);
}

.proof-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--sun), var(--coral));
  transition: width 180ms ease;
}

.proof-stats {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.wizard-progress {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.wizard-progress span {
  height: 6px;
  border-radius: 999px;
  background: var(--progress-bg);
}

.wizard-progress span.active {
  background: var(--accent);
}

.wizard-step {
  display: none;
  gap: 14px;
}

.wizard-step.active {
  display: grid;
}

.wizard-step input[type="text"],
.wizard-step select,
.wizard-step input[type="file"],
#colorHex {
  grid-column: 1 / -1;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--ink);
}

.wizard-step input[type="file"] {
  padding: 10px;
}

.file-row {
  align-items: center;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.choice-grid button,
.modal-actions button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--ink);
  cursor: pointer;
}

.choice-grid button.active,
.choice-grid button:hover,
.modal-actions button:hover {
  background: var(--button-hover);
  border-color: var(--accent);
}

.creator-preview {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
}

.creator-preview canvas {
  position: static;
  width: 100%;
  height: auto;
  background: transparent;
  box-shadow: none;
  transform: none;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 8px;
}

.proof-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 560px) {
  .proof-actions {
    grid-template-columns: 1fr 1fr;
  }
}

.brush-library-actions {
  grid-template-columns: 1fr 1fr;
}

.color-tray {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
}

.color-tray-head {
  display: grid;
  grid-template-columns: auto 34px 34px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.swatch-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, 26px);
  gap: 6px;
}

.recent-colors {
  display: grid;
  grid-template-columns: repeat(auto-fill, 26px);
  gap: 6px;
}

.palette-tools,
.harmony-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
}

.palette-tools input,
.palette-tools select,
#layerBlendMode {
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--ink);
}

.palette-tools select {
  grid-column: 1 / -1;
}

.swatch,
.recent-color,
#color,
.palette-pipette {
  width: 26px;
  aspect-ratio: 1;
  min-height: 26px;
  border: 1px solid var(--button-border);
  border-radius: 5px;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  cursor: pointer;
}

.swatch.active,
.recent-color.active,
.palette-pipette.active,
#color:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.palette-pipette {
  display: grid;
  place-items: center;
  padding: 0;
  background: var(--button-bg);
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

#color {
  padding: 0;
  overflow: hidden;
}

#colorHex {
  min-height: 34px;
  padding: 0 10px;
}

label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

output {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--accent);
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.toggle-line input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.canvas-actions,
.shape-actions,
.selection-actions,
.nudge-pad {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.canvas-actions,
.shape-actions,
.selection-actions {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
}

.canvas-actions {
  grid-template-columns: 1fr 1fr;
}

.shape-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.transform-panel,
.symmetry-panel,
.liquify-panel,
.upscale-panel {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
}

.compact-head h2 {
  font-size: 13px;
}

.nudge-pad {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.canvas-actions #download,
.canvas-actions #downloadTransparent,
.canvas-actions #downloadJpeg,
.canvas-actions #downloadWebp {
  grid-column: 1 / -1;
}

.canvas-actions button,
.shape-actions button,
.selection-actions button,
.transform-panel button,
.symmetry-panel button,
.liquify-panel button,
.harmony-tools button,
.palette-tools button,
.layer-actions button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--ink);
  cursor: pointer;
}

.shape-actions button.active {
  background: var(--ink);
  color: var(--active-text);
  border-color: var(--ink);
}

.selection-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
  transform: none;
}

.transform-panel button:disabled,
.transform-panel input:disabled,
.symmetry-panel input:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.symmetry-panel select,
.liquify-panel select,
.upscale-panel select {
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--ink);
}

.upscale-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.upscale-options button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.upscale-options button.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 22%, var(--button-hover));
}

.upscale-result {
  margin: 0;
  padding: 9px 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--button-bg) 64%, transparent);
  color: var(--muted);
  font-weight: 800;
}

.upscale-gauge {
  display: grid;
  gap: 6px;
}

.upscale-gauge-bar {
  overflow: hidden;
  height: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--progress-bg);
}

.upscale-gauge-bar span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--sun, #ffbf46), var(--coral));
  transition: width 180ms ease;
}

#upscaleGaugeText {
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.layers-panel {
  display: grid;
  gap: 10px;
  min-height: 260px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
}

.layers-panel .section-head {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 8px;
}

.layer-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.layer-actions button {
  width: auto;
  min-height: 34px;
  padding: 0 6px;
  font-size: 12px;
}

.layer-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
  transform: none;
}

.layer-list {
  display: grid;
  gap: 6px;
  min-height: 92px;
  max-height: min(260px, 28dvh);
  overflow: auto;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 36%, transparent);
}

.layer-row {
  display: grid;
  grid-template-columns: 34px 52px minmax(0, 1fr);
  grid-template-areas:
    "vis thumb name"
    "vis thumb meta";
  align-items: center;
  column-gap: 9px;
  row-gap: 2px;
  min-height: 64px;
  padding: 7px;
  border: 1px solid color-mix(in srgb, var(--line) 78%, var(--ink) 12%);
  border-radius: 8px;
  background: color-mix(in srgb, var(--button-bg) 86%, var(--panel) 14%);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.layer-thumb {
  grid-area: thumb;
  display: block;
  width: 52px;
  height: 40px;
  border: 1px solid color-mix(in srgb, var(--line) 72%, var(--ink) 14%);
  border-radius: 6px;
  background:
    linear-gradient(45deg, rgba(0, 0, 0, 0.06) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(0, 0, 0, 0.06) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(0, 0, 0, 0.06) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(0, 0, 0, 0.06) 75%);
  background-color: var(--input-bg);
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  background-size: 12px 12px;
  object-fit: contain;
}

.layer-row.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, var(--button-hover));
  box-shadow: inset 4px 0 0 var(--accent), 0 0 0 1px color-mix(in srgb, var(--accent) 42%, transparent);
}

.layer-row.clipping {
  border-color: color-mix(in srgb, #ffbf46 62%, var(--line));
  box-shadow: inset 4px 0 0 #ffbf46;
}

.layer-row.active.clipping {
  box-shadow: inset 4px 0 0 #ffbf46, inset 8px 0 0 var(--accent);
}

.visibility-toggle {
  grid-area: vis;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid color-mix(in srgb, var(--line) 74%, var(--ink) 14%);
  border-radius: 8px;
  background: color-mix(in srgb, var(--input-bg) 78%, var(--button-hover));
  color: var(--ink);
  cursor: pointer;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.layer-name {
  grid-area: name;
  overflow: hidden;
  min-width: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-properties {
  display: grid;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--button-bg) 62%, transparent);
}

.layer-name-input {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

.layer-meta {
  grid-area: meta;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

body[data-theme="dark"] .layers-panel {
  background: #121019;
  border-color: #665b78;
}

body[data-theme="dark"] .layer-list {
  background: #0d0c12;
  border-color: #6d627e;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

body[data-theme="dark"] .layer-row {
  border-color: #746784;
  background: #302a3b;
  color: #fff7ea;
}

body[data-theme="dark"] .layer-row.active {
  border-color: #40e0d0;
  background: #23423f;
  box-shadow: inset 5px 0 0 #40e0d0, 0 0 0 1px rgba(64, 224, 208, 0.5);
}

body[data-theme="dark"] .layer-thumb,
body[data-theme="dark"] .visibility-toggle {
  border-color: #807391;
  background-color: #1a1722;
}

body[data-theme="dark"] .visibility-toggle {
  color: #fff7ea;
  background: #252030;
}

body[data-theme="dark"] .layer-name {
  color: #fff7ea;
}

body[data-theme="dark"] .layer-meta {
  color: #d4cbe2;
}

body[data-theme="dark"] .layer-properties {
  background: #181520;
  border-color: #665b78;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 64px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .panel-splitter {
    display: none;
  }

  .settings-panel {
    grid-column: 1 / -1;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr);
    align-items: stretch;
    padding: 10px;
  }

  .settings-panel.floating {
    grid-column: auto;
    width: min(360px, calc(100vw - 16px));
    height: min(620px, calc(100dvh - 16px));
  }

  .swatch-row,
  .recent-colors {
    grid-template-columns: repeat(auto-fill, 26px);
  }

  .canvas-actions {
    grid-template-columns: 1fr 1fr;
  }

  .shape-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

.selection-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.selection-feather {
  grid-column: 1 / -1;
}

  .tab-panel,
  .layers-panel {
    grid-column: 1 / -1;
  }

  .layer-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: min(300px, 32dvh);
  }

  .brush-panel {
    grid-column: 1 / -1;
  }

  .brush-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    max-height: none;
  }

  .brush-library-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tour-card {
    grid-template-columns: 1fr;
  }

  .tour-mascot {
    width: 100%;
    min-height: 104px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 8px;
    padding: 8px;
  }

  .tool-rail {
    grid-row: 1;
    grid-template-columns: repeat(14, 48px);
    justify-content: center;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
    padding: 8px;
    touch-action: pan-x;
  }

  .tool,
  .icon-button {
    width: 48px;
    height: 48px;
  }

  .tour-card {
    gap: 12px;
    padding: 14px;
  }

  .tour-copy h2 {
    font-size: 23px;
  }

  .tour-actions {
    grid-template-columns: 1fr 1fr;
  }

  #tourSkip {
    grid-column: 1 / -1;
  }

  .stage-wrap {
    grid-row: 2;
    gap: 8px;
  }

  .top-bar {
    min-height: 62px;
    padding: 8px;
  }

  h1 {
    font-size: 17px;
  }

  .settings-panel {
    grid-row: 3;
    grid-template-columns: 1fr;
    max-height: 45dvh;
    overflow: auto;
  }

  .settings-panel.floating {
    grid-row: auto;
    max-height: calc(100dvh - 16px);
    left: 8px;
    top: 72px;
  }

  .swatch-row,
  .brush-panel,
  .canvas-actions,
  .shape-actions,
  .selection-actions,
  .tab-panel,
  .layers-panel {
    grid-column: 1 / -1;
  }

  .brush-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
  }

  .brush-library-list {
    grid-template-columns: 1fr;
  }

  .layer-list {
    grid-template-columns: 1fr;
    max-height: min(280px, 30dvh);
  }
}
