:root {
  --ink: #202822;
  --muted: #687168;
  --paper: #f4efe3;
  --board: #ded3bd;
  --cream: #fbf8ef;
  --line: rgba(32, 40, 34, 0.17);
  --line-strong: rgba(32, 40, 34, 0.35);
  --orange: #c95c35;
  --green: #385b48;
  --white: #fffdf7;
  --shadow: 0 18px 55px rgba(44, 36, 26, 0.16);
  --dock-height: 72px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--paper); }
body {
  min-height: 100vh; margin: 0; color: var(--ink); background: var(--paper);
  font-family: Inter, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { min-height: 44px; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(201, 92, 53, .35); outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .42; }
.eyebrow { color: var(--muted); font-size: .62rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.primary-button {
  color: var(--white) !important; background: var(--ink) !important; border-color: var(--ink) !important;
}
.quiet-button { background: transparent; border: 1px solid var(--line); }
.danger-button { color: #923e2d; }
.wide-button { width: 100%; }

.topbar {
  position: relative; z-index: 30; display: flex; align-items: center; justify-content: space-between;
  min-height: 64px; padding: 10px clamp(16px, 3vw, 42px); background: rgba(244, 239, 227, .92);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(12px);
}
.brand { display: flex; gap: 11px; align-items: center; color: inherit; font-family: Georgia, serif; font-size: 1.06rem; text-decoration: none; }
.brand-mark { position: relative; display: block; width: 34px; height: 32px; }
.brand-mark i { position: absolute; width: 19px; height: 19px; border: 1px solid rgba(32,40,34,.6); border-radius: 50%; mix-blend-mode: multiply; }
.brand-mark i:nth-child(1) { top: 0; left: 7px; background: #e6bf31; }
.brand-mark i:nth-child(2) { bottom: 0; left: 0; background: #c5443d; }
.brand-mark i:nth-child(3) { right: 0; bottom: 0; background: #3f68a0; }
.top-actions { display: flex; gap: 9px; align-items: center; }
.top-actions > span { margin-right: 8px; color: var(--muted); font-size: .72rem; }
.top-actions button { min-height: 36px; padding: 0 12px; border-radius: 99px; font-size: .7rem; }

.studio { width: 100%; padding: clamp(14px, 2.4vw, 34px) clamp(12px, 2.8vw, 42px) calc(var(--dock-height) + 30px); }
.palette-workspace { position: relative; max-width: 1540px; margin: auto; }
.workspace-heading { display: flex; gap: 30px; align-items: end; justify-content: space-between; margin: 0 4px 16px; }
.workspace-heading h1 { margin: 4px 0 0; font-family: Georgia, serif; font-size: clamp(1.55rem, 2.6vw, 2.6rem); font-weight: 400; letter-spacing: -.035em; }
.workspace-heading p { max-width: 360px; margin: 0 0 4px; color: var(--muted); font-family: Georgia, serif; font-size: .9rem; line-height: 1.45; text-align: right; }

.palette-board {
  position: relative; min-height: calc(100vh - 190px); overflow: hidden; isolation: isolate;
  background: var(--board); border: 1px solid var(--line-strong); border-radius: 28px 24px 31px 22px;
  box-shadow: inset 0 2px 18px rgba(255,255,255,.45), inset 0 -12px 30px rgba(80,60,34,.06), var(--shadow);
}
.board-grain {
  position: absolute; z-index: -1; inset: 0; pointer-events: none; opacity: .35;
  background:
    radial-gradient(circle at 15% 25%, rgba(255,255,255,.34) 0 1px, transparent 2px),
    radial-gradient(circle at 72% 61%, rgba(65,48,30,.14) 0 1px, transparent 2px),
    repeating-linear-gradient(8deg, transparent 0 19px, rgba(62,48,32,.035) 20px 21px);
  background-size: 21px 19px, 29px 31px, auto;
}
.palette-daubs { position: absolute; inset: 0; }
.palette-empty {
  position: absolute; top: 50%; left: 50%; display: grid; justify-items: center; width: min(420px, 82%);
  text-align: center; transform: translate(-50%, -50%);
}
.empty-mark { display: grid; place-items: center; width: 62px; height: 62px; margin-bottom: 16px; color: var(--muted); font-size: 2rem; border: 1px dashed var(--line-strong); border-radius: 50%; }
.palette-empty strong { font-family: Georgia, serif; font-size: 1.45rem; }
.palette-empty p { margin: 7px 0 16px; color: var(--muted); font-family: Georgia, serif; line-height: 1.45; }
.palette-empty button { padding: 0 18px; background: var(--cream); border: 1px solid var(--ink); border-radius: 99px; }

.paint-daub {
  position: absolute; z-index: var(--z, 1); width: clamp(86px, 8.5vw, 128px); min-height: 92px; padding: 0;
  touch-action: none; user-select: none; background: transparent; border: 0;
  transform: translate(-50%, -50%) rotate(var(--tilt, 0deg));
}
.paint-daub::before {
  position: absolute; inset: 3px 10px 27px 8px; content: ""; background: var(--paint);
  border: 1px solid rgba(32,40,34,.27); border-radius: 46% 54% 43% 58% / 55% 41% 59% 45%;
  box-shadow: inset 9px 11px 16px rgba(255,255,255,.17), inset -9px -8px 14px rgba(0,0,0,.13), 0 8px 12px rgba(47,35,22,.16);
  transition: transform 130ms ease, box-shadow 130ms ease;
}
.paint-daub::after {
  position: absolute; top: 15px; left: 27px; width: 30%; height: 12px; content: "";
  background: rgba(255,255,255,.2); border-radius: 50%; filter: blur(3px); transform: rotate(-18deg);
}
.paint-daub:hover::before { transform: scale(1.035); }
.paint-daub.selected::before, .paint-daub.mix-selected::before {
  box-shadow: inset 9px 11px 16px rgba(255,255,255,.17), inset -9px -8px 14px rgba(0,0,0,.13), 0 0 0 4px var(--cream), 0 0 0 7px var(--ink), 0 10px 16px rgba(47,35,22,.2);
}
.paint-daub.mix-selected::before { box-shadow: inset 9px 11px 16px rgba(255,255,255,.17), inset -9px -8px 14px rgba(0,0,0,.13), 0 0 0 4px var(--cream), 0 0 0 7px var(--orange), 0 10px 16px rgba(47,35,22,.2); }
.paint-daub.dragging { cursor: grabbing; }
.paint-daub.dragging::before { transform: scale(1.08); }
.daub-label {
  position: absolute; right: 50%; bottom: 0; max-width: 122px; padding: 4px 7px; overflow: hidden;
  color: var(--ink); font-size: .62rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap;
  background: rgba(251,248,239,.91); border: 1px solid rgba(32,40,34,.25); transform: translateX(50%);
}
.daub-number {
  position: absolute; top: 3px; right: 5px; z-index: 2; display: grid; place-items: center; width: 22px; height: 22px;
  color: var(--ink); font-size: .58rem; font-weight: 850; background: var(--cream); border: 1px solid var(--ink); border-radius: 50%;
}
.drop-target::before { animation: drop-pulse 650ms infinite alternate; }

.daub-inspector {
  position: absolute; z-index: 16; right: 24px; bottom: calc(var(--dock-height) + 28px); left: 24px; display: grid;
  grid-template-columns: 58px minmax(180px, 1fr) auto 112px; gap: 14px; align-items: center; min-height: 84px; padding: 10px 12px;
  background: rgba(251,248,239,.94); border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: 0 10px 35px rgba(39,31,21,.18); backdrop-filter: blur(12px);
}
.inspector-swatch { width: 56px; height: 56px; background: var(--paint); border: 1px solid var(--line-strong); border-radius: 48% 42% 54% 45%; box-shadow: inset 6px 7px 10px rgba(255,255,255,.14), inset -5px -5px 9px rgba(0,0,0,.11); }
.inspector-copy { min-width: 0; }
.inspector-copy > strong, .inspector-copy > small { display: block; }
.inspector-copy > strong { margin: 2px 0 3px; overflow: hidden; font-family: Georgia, serif; font-size: 1.04rem; text-overflow: ellipsis; white-space: nowrap; }
.inspector-copy > small { color: var(--muted); font-size: .65rem; }
.compact-recipe { display: flex; flex-wrap: wrap; gap: 3px 9px; margin-top: 5px; }
.compact-recipe span { font-size: .61rem; white-space: nowrap; }
.compact-recipe i { display: inline-block; width: 7px; height: 7px; margin-right: 4px; background: var(--part); border-radius: 50%; }
.inspector-actions { display: flex; gap: 6px; }
.inspector-actions button, .mix-handle { padding: 0 13px; background: transparent; border: 1px solid var(--line-strong); border-radius: 99px; font-size: .68rem; font-weight: 750; }
.mix-handle { display: flex; gap: 7px; align-items: center; justify-content: center; min-width: 108px; border-style: dashed; touch-action: none; }
.mix-handle span { display: grid; place-items: center; width: 25px; height: 25px; color: white; background: var(--orange); border-radius: 50%; }
.mix-handle small { font-size: .59rem; line-height: 1.05; }

.mix-selection-bar {
  position: absolute; z-index: 17; top: 18px; left: 50%; display: flex; gap: 13px; align-items: center;
  padding: 8px 9px 8px 16px; background: var(--cream); border: 1px solid var(--line-strong); border-radius: 99px;
  box-shadow: 0 9px 25px rgba(45,35,23,.17); transform: translateX(-50%);
}
.mix-selection-bar span { font-size: .72rem; white-space: nowrap; }
.mix-selection-help { color: var(--muted); }
.mix-selection-bar button { min-height: 38px; padding: 0 15px; background: transparent; border: 1px solid var(--line); border-radius: 99px; font-size: .68rem; }
.drag-ghost {
  position: fixed; z-index: 80; padding: 9px 13px; pointer-events: none; color: var(--white); font-size: .68rem; font-weight: 750;
  background: var(--orange); border-radius: 99px; box-shadow: var(--shadow); transform: translate(14px, 14px);
}

.tool-dock {
  position: fixed; z-index: 40; right: 50%; bottom: max(12px, env(safe-area-inset-bottom)); display: grid;
  grid-template-columns: repeat(5, minmax(76px, 112px)); height: var(--dock-height); padding: 7px;
  background: rgba(30,38,32,.95); border: 1px solid rgba(255,255,255,.18); border-radius: 18px; box-shadow: 0 13px 40px rgba(25,20,16,.32);
  backdrop-filter: blur(14px); transform: translateX(50%);
}
.tool-dock button { display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center; min-width: 0; color: rgba(255,255,255,.82); font-size: .61rem; background: transparent; border: 0; border-radius: 12px; }
.tool-dock button:hover, .tool-dock button.active { color: white; background: rgba(255,255,255,.12); }
.tool-dock button span { font-size: 1.18rem; line-height: 1; }

.sheet-backdrop { position: fixed; z-index: 50; inset: 0; background: rgba(26,29,25,.42); backdrop-filter: blur(2px); }
body.sheet-open { overflow: hidden; }
.tool-sheet {
  position: fixed; z-index: 60; top: 0; right: 0; bottom: 0; width: min(560px, 94vw); overflow: hidden;
  background: var(--cream); border-left: 1px solid var(--line-strong); box-shadow: -18px 0 50px rgba(35,29,21,.22); animation: sheet-in 220ms ease both;
}
.tool-sheet[data-sheet="wheel"] { width: min(940px, 96vw); }
.sheet-handle { display: none; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; height: 86px; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.sheet-header h2 { margin: 3px 0 0; font-family: Georgia, serif; font-size: 1.8rem; font-weight: 400; letter-spacing: -.03em; }
.close-button { width: 44px; padding: 0; color: var(--muted); font-family: Georgia, serif; font-size: 1.9rem; background: transparent; border: 1px solid var(--line); border-radius: 50%; }
.sheet-panel { height: calc(100% - 86px); padding: 22px 24px 36px; overflow-y: auto; overscroll-behavior: contain; }
.panel-intro { margin: 0 0 18px; color: var(--muted); font-family: Georgia, serif; font-size: .93rem; line-height: 1.5; }

.paintbox-intro { display: flex; gap: 18px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.paintbox-intro p { margin: 0; color: var(--muted); font-size: .73rem; line-height: 1.45; }
.paintbox-intro strong { color: var(--ink); }
.paintbox-intro button { flex: 0 0 auto; padding: 0 12px; border-radius: 99px; font-size: .65rem; }
.search-field { display: grid; grid-template-columns: 35px 1fr; align-items: center; height: 48px; background: white; border: 1px solid var(--line-strong); }
.search-field span { text-align: center; }
.search-field input { height: 100%; padding: 0 12px 0 0; background: transparent; border: 0; outline: 0; }
.filter-row { display: flex; gap: 6px; margin: 12px 0 15px; padding-bottom: 4px; overflow-x: auto; scrollbar-width: thin; }
.filter-row button { flex: 0 0 auto; min-height: 36px; padding: 0 11px; background: transparent; border: 1px solid var(--line); border-radius: 99px; font-size: .62rem; }
.filter-row button.active { color: white; background: var(--ink); border-color: var(--ink); }
.tube-list { display: grid; gap: 7px; }
.tube-row { display: grid; grid-template-columns: 42px minmax(0,1fr) auto; gap: 11px; align-items: center; min-height: 62px; padding: 7px 8px; background: rgba(244,239,227,.58); border: 1px solid var(--line); }
.tube-checkbox { position: relative; display: grid; place-items: center; width: 42px; height: 42px; cursor: pointer; }
.tube-checkbox input { position: absolute; opacity: 0; }
.tube-dot { width: 35px; height: 35px; background: var(--paint); border: 1px solid var(--line-strong); border-radius: 48% 43% 53% 45%; box-shadow: inset 4px 5px 7px rgba(255,255,255,.17), inset -4px -4px 7px rgba(0,0,0,.11); }
.tube-checkbox input:checked + .tube-dot { box-shadow: inset 4px 5px 7px rgba(255,255,255,.17), inset -4px -4px 7px rgba(0,0,0,.11), 0 0 0 3px var(--cream), 0 0 0 5px var(--ink); }
.tube-info { min-width: 0; }
.tube-info strong, .tube-info small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tube-info strong { font-family: Georgia, serif; font-size: .87rem; }
.tube-info small { margin-top: 3px; color: var(--muted); font-size: .59rem; }
.squeeze-button { min-width: 76px; padding: 0 10px; background: white; border: 1px solid var(--line-strong); border-radius: 99px; font-size: .63rem; font-weight: 750; }
.squeeze-button:disabled { visibility: hidden; }

.mix-ratio-list { display: grid; gap: 10px; }
.ratio-row { display: grid; grid-template-columns: 38px minmax(0,1fr) 112px; gap: 11px; align-items: center; padding: 10px; background: var(--paper); border: 1px solid var(--line); }
.ratio-swatch { width: 38px; height: 38px; background: var(--paint); border: 1px solid var(--line-strong); border-radius: 50%; }
.ratio-info strong, .ratio-info small { display: block; }
.ratio-info strong { overflow: hidden; font-family: Georgia, serif; font-size: .84rem; text-overflow: ellipsis; white-space: nowrap; }
.ratio-info small { margin-top: 3px; color: var(--muted); font-size: .58rem; }
.parts-control { display: grid; grid-template-columns: 32px 42px 32px; height: 36px; border: 1px solid var(--line-strong); border-radius: 99px; overflow: hidden; }
.parts-control button { min-height: 34px; padding: 0; background: white; border: 0; }
.parts-control output { display: grid; place-items: center; font-size: .68rem; font-weight: 850; border-right: 1px solid var(--line); border-left: 1px solid var(--line); }
.mix-preview-card { display: grid; grid-template-columns: 92px 1fr; gap: 16px; align-items: center; min-height: 116px; margin-top: 18px; padding: 12px; background: #ede6d8; border: 1px solid var(--line-strong); }
.mix-preview { width: 92px; height: 92px; background: var(--paint); border: 1px solid var(--line-strong); border-radius: 47% 52% 43% 56%; box-shadow: inset 8px 9px 13px rgba(255,255,255,.15), inset -7px -7px 12px rgba(0,0,0,.11); }
.mix-preview-card strong, .mix-preview-card small { display: block; }
.mix-preview-card strong { margin: 5px 0; font-family: Georgia, serif; font-size: 1.3rem; }
.mix-preview-card small { color: var(--muted); }
.recipe-list { margin-top: 14px; background: white; border: 1px solid var(--line); }
.recipe-item { display: grid; grid-template-columns: 14px minmax(0,1fr) auto; gap: 9px; align-items: center; min-height: 38px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.recipe-item:last-child { border: 0; }
.recipe-item i { width: 12px; height: 12px; background: var(--part); border: 1px solid rgba(0,0,0,.15); border-radius: 50%; }
.recipe-item span { overflow: hidden; font-size: .69rem; text-overflow: ellipsis; white-space: nowrap; }
.recipe-item b { font-size: .7rem; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1.3fr; gap: 8px; margin-top: 16px; }
.sheet-actions button { padding: 0 12px; background: transparent; border: 1px solid var(--line-strong); font-size: .7rem; font-weight: 750; }

.target-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.target-controls > * { min-height: 48px; background: white; border: 1px solid var(--line-strong); }
.target-color-control { display: flex; gap: 10px; align-items: center; padding: 5px 10px; font-size: .7rem; font-weight: 750; cursor: pointer; }
.target-color-control input { width: 38px; height: 36px; padding: 0; border: 0; }
.hex-field { display: flex; gap: 9px; align-items: center; padding-left: 10px; color: var(--muted); font-size: .6rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.hex-field input { min-width: 0; width: 100%; height: 100%; padding: 0 8px; color: var(--ink); font-size: .78rem; background: transparent; border: 0; outline: 0; text-transform: uppercase; }
.target-controls button { font-size: .67rem; font-weight: 750; }
.source-choice { display: flex; gap: 18px; margin: 17px 0 14px; padding: 12px 14px; border: 1px solid var(--line); }
.source-choice legend { padding: 0 5px; color: var(--muted); font-size: .6rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.source-choice label { display: flex; gap: 6px; align-items: center; font-size: .7rem; }
.match-empty { display: grid; place-items: center; min-height: 150px; margin-top: 14px; color: var(--muted); font-family: Georgia, serif; text-align: center; border: 1px dashed var(--line-strong); }
.match-result { margin-top: 16px; }
.match-swatches { display: grid; grid-template-columns: 1fr 1fr; height: 105px; overflow: hidden; border: 1px solid var(--line-strong); }
.match-swatches div { position: relative; }
.match-swatches span { position: absolute; z-index: 1; bottom: 8px; left: 9px; padding: 3px 6px; color: var(--ink); font-size: .56rem; font-weight: 800; background: rgba(255,255,255,.8); }
.match-swatches i { display: block; width: 100%; height: 100%; background: var(--paint); }
.match-score { display: flex; align-items: baseline; justify-content: space-between; margin-top: 10px; }
.match-score span { font-family: Georgia, serif; font-size: 1.05rem; }
.match-score small { color: var(--muted); font-size: .62rem; }

.wheel-panel { overflow: hidden; }
.wheel-toolbar { display: flex; gap: 20px; align-items: center; justify-content: space-between; }
.wheel-toolbar > div { display: grid; grid-template-columns: auto 38px 44px 38px; align-items: center; height: 40px; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 99px; }
.wheel-toolbar span { padding: 0 13px; color: var(--muted); font-size: .6rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.wheel-toolbar button { min-height: 38px; padding: 0; background: white; border: 0; border-left: 1px solid var(--line); }
.wheel-toolbar output { display: grid; place-items: center; height: 100%; font-size: .72rem; font-weight: 850; background: white; border-left: 1px solid var(--line); }
.wheel-toolbar p { max-width: 310px; margin: 0; color: var(--muted); font-family: Georgia, serif; font-size: .76rem; line-height: 1.4; text-align: right; }
.wheel-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 22px; align-items: center; min-height: calc(100% - 55px); }
.color-wheel { display: block; width: min(100%, 650px); margin: auto; overflow: visible; filter: drop-shadow(0 16px 19px rgba(39,34,28,.13)); }
.wheel-registration { fill: none; stroke: rgba(30,40,36,.25); stroke-dasharray: 1 7; stroke-linecap: round; stroke-width: 1.5; }
.wheel-segment { transform-origin: 300px 300px; stroke: var(--cream); stroke-width: 3; transition: transform 130ms ease, filter 130ms ease; }
.wheel-segment:hover, .wheel-segment:focus-visible { filter: brightness(1.06) saturate(1.06); transform: scale(1.025); }
.wheel-segment.selected { stroke: var(--ink); stroke-width: 5; transform: scale(1.018); }
.wheel-center { pointer-events: none; }
.wheel-center circle { fill: var(--cream); stroke: var(--ink); stroke-width: 1.5; }
.wheel-center text { fill: var(--ink); font-family: Georgia, serif; font-size: 16px; text-anchor: middle; }
.wheel-center text:first-of-type { fill: var(--muted); font-family: Inter, sans-serif; font-size: 8px; font-weight: 800; letter-spacing: .13em; }
.wheel-choice { padding: 18px; background: var(--paper); border: 1px solid var(--line); }
.large-swatch { width: 100%; aspect-ratio: 1.2; margin-bottom: 16px; background: var(--paint); border: 1px solid var(--line-strong); border-radius: 50% 44% 52% 46%; box-shadow: inset 10px 12px 15px rgba(255,255,255,.16), inset -9px -9px 14px rgba(0,0,0,.1); }
.wheel-choice h3 { margin: 6px 0; font-family: Georgia, serif; font-size: 1.25rem; font-weight: 400; }
.wheel-choice p { min-height: 32px; margin: 0 0 14px; color: var(--muted); font-size: .64rem; line-height: 1.4; }
.wheel-choice button { width: 100%; margin-top: 7px; background: white; border: 1px solid var(--line-strong); font-size: .68rem; font-weight: 750; }

.toast {
  position: fixed; z-index: 100; top: 78px; left: 50%; max-width: min(420px, calc(100vw - 30px)); padding: 11px 16px;
  pointer-events: none; color: white; font-size: .72rem; font-weight: 750; text-align: center; background: var(--ink);
  border-radius: 99px; box-shadow: var(--shadow); opacity: 0; transform: translate(-50%, -10px); transition: opacity 160ms ease, transform 160ms ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes sheet-in { from { opacity: .5; transform: translateX(24px); } }
@keyframes drop-pulse { to { transform: scale(1.12); filter: brightness(1.1); } }

@media (max-width: 820px) {
  :root { --dock-height: 64px; }
  .topbar { min-height: 56px; }
  .brand { font-size: .95rem; }
  .brand-mark { width: 29px; height: 27px; }
  .brand-mark i { width: 16px; height: 16px; }
  .top-actions > span, #clear-palette { display: none; }
  .top-actions button { min-height: 34px; }
  .studio { padding: 12px 9px calc(var(--dock-height) + 24px); }
  .workspace-heading { align-items: start; margin: 0 7px 10px; }
  .workspace-heading h1 { font-size: 1.35rem; }
  .workspace-heading p { display: none; }
  .palette-board { min-height: calc(100svh - 145px); border-radius: 21px 17px 24px 16px; }
  .paint-daub { width: 92px; min-height: 88px; }
  .tool-dock { right: 8px; bottom: max(7px, env(safe-area-inset-bottom)); left: 8px; grid-template-columns: repeat(5, 1fr); height: var(--dock-height); border-radius: 16px; transform: none; }
  .tool-dock button { font-size: .57rem; }
  .tool-dock button span { font-size: 1.05rem; }
  .daub-inspector {
    position: fixed; z-index: 35; right: 8px; bottom: calc(var(--dock-height) + 14px + env(safe-area-inset-bottom)); left: 8px;
    grid-template-columns: 45px minmax(0,1fr) auto; gap: 9px; min-height: 72px; padding: 8px;
  }
  .inspector-swatch { width: 44px; height: 44px; }
  .inspector-copy > strong { font-size: .88rem; }
  .compact-recipe { max-height: 20px; overflow: hidden; }
  .inspector-actions { gap: 4px; }
  .inspector-actions button { min-width: 44px; padding: 0 10px; font-size: .62rem; }
  #inspector-match, #inspector-delete { width: 44px; padding: 0; overflow: hidden; color: transparent; }
  #inspector-match::before { color: var(--ink); content: "◎"; font-size: 1rem; }
  #inspector-delete::before { color: #923e2d; content: "×"; font-size: 1.2rem; }
  .mix-handle { display: none; }
  .mix-selection-bar { top: 10px; gap: 5px; width: calc(100% - 16px); padding: 6px 6px 6px 11px; }
  .mix-selection-help { display: none; }
  .mix-selection-bar span { margin-right: auto; }
  .mix-selection-bar button { padding: 0 11px; }
  .tool-sheet, .tool-sheet[data-sheet="wheel"] {
    top: auto; width: 100%; height: min(90svh, 780px); border-top: 1px solid var(--line-strong); border-left: 0;
    border-radius: 22px 22px 0 0; animation-name: sheet-up;
  }
  .sheet-handle { display: block; width: 42px; height: 4px; margin: 8px auto 0; background: var(--line-strong); border-radius: 99px; }
  .sheet-header { height: 70px; padding: 10px 16px; }
  .sheet-header h2 { font-size: 1.45rem; }
  .sheet-panel { height: calc(100% - 82px); padding: 15px 14px calc(24px + env(safe-area-inset-bottom)); }
  .wheel-layout { grid-template-columns: 1fr; gap: 0; }
  .wheel-toolbar { display: block; }
  .wheel-toolbar > div { width: max-content; margin: auto; }
  .wheel-toolbar p { max-width: none; margin-top: 8px; font-size: .67rem; text-align: center; }
  .color-wheel { width: min(100%, 420px); }
  .wheel-choice { display: grid; grid-template-columns: 58px 1fr 1fr; gap: 6px 11px; align-items: center; padding: 10px; }
  .large-swatch { grid-row: span 3; width: 58px; margin: 0; }
  .wheel-choice .eyebrow, .wheel-choice h3, .wheel-choice p { grid-column: 2 / -1; margin: 0; min-height: 0; }
  .wheel-choice h3 { font-size: 1rem; }
  .wheel-choice button { grid-column: 2 / -1; margin: 0; }
  @keyframes sheet-up { from { opacity: .6; transform: translateY(25px); } }
}

@media (max-width: 520px) {
  .topbar { padding-inline: 12px; }
  .workspace-heading .eyebrow { font-size: .55rem; }
  .workspace-heading h1 { font-size: 1.16rem; }
  .palette-board { min-height: calc(100svh - 137px); }
  .daub-inspector { grid-template-columns: 40px minmax(0,1fr) auto; }
  .inspector-swatch { width: 40px; height: 40px; }
  .inspector-copy > small, .compact-recipe { display: none; }
  .inspector-actions #inspector-mix { width: 48px; padding: 0; }
  .target-controls { grid-template-columns: 1fr 1fr; }
  .source-choice { gap: 9px; justify-content: space-between; }
  .source-choice label { font-size: .65rem; }
  .ratio-row { grid-template-columns: 34px minmax(0,1fr) 106px; padding: 8px; }
  .mix-preview-card { grid-template-columns: 76px 1fr; min-height: 98px; }
  .mix-preview { width: 76px; height: 76px; }
  .sheet-actions { grid-template-columns: 1fr; }
  .paintbox-intro { align-items: start; }
  .paintbox-intro button { min-height: 38px; }
  .tube-row { grid-template-columns: 40px minmax(0,1fr) 68px; }
  .squeeze-button { min-width: 66px; padding: 0 5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}


/* Refined interface controls */
:root {
  --control: #27362e;
  --control-hover: #1d2923;
  --soft-surface: #efebe1;
  --raised-surface: rgba(255, 253, 248, .96);
  --focus: rgba(201, 92, 53, .32);
}
button { transition: color 150ms ease, background 150ms ease, border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease; }
button:active:not(:disabled) { transform: translateY(1px); }
.primary-button {
  color: #fff !important; background: var(--control) !important; border: 1px solid var(--control) !important;
  border-radius: 11px !important; box-shadow: 0 5px 14px rgba(39, 54, 46, .16);
}
.primary-button:hover { background: var(--control-hover) !important; box-shadow: 0 7px 18px rgba(39, 54, 46, .22); }
.quiet-button { background: rgba(255,255,255,.38); border-color: transparent; border-radius: 9px; }
.quiet-button:hover { background: rgba(32,40,34,.08); }

.topbar { min-height: 68px; background: rgba(247, 243, 234, .9); }
.top-actions button { border-radius: 9px; }
.workspace-heading { align-items: center; margin-bottom: 14px; }
.workspace-heading h1 { margin-top: 2px; font-family: Inter, "Helvetica Neue", Arial, sans-serif; font-size: clamp(1.25rem, 1.8vw, 1.7rem); font-weight: 650; letter-spacing: -.025em; }
.workspace-heading p { font-family: Inter, "Helvetica Neue", Arial, sans-serif; font-size: .74rem; }
.palette-board { background-color: #ded5c4; border-color: rgba(32,40,34,.24); border-radius: 22px; box-shadow: inset 0 1px 12px rgba(255,255,255,.52), 0 16px 46px rgba(44,36,26,.13); }

.palette-empty { width: min(380px, 86%); }
.palette-empty strong { font-size: 1.3rem; }
.palette-empty p { max-width: 330px; margin-bottom: 20px; font-family: Inter, "Helvetica Neue", Arial, sans-serif; font-size: .74rem; }
.palette-empty .empty-primary {
  display: inline-flex; gap: 22px; align-items: center; min-height: 50px; padding: 0 9px 0 18px;
  color: #fff; font-size: .72rem; font-weight: 750; background: var(--control); border: 0; border-radius: 12px;
  box-shadow: 0 8px 20px rgba(39,54,46,.2);
}
.palette-empty .empty-primary:hover { background: var(--control-hover); box-shadow: 0 10px 24px rgba(39,54,46,.26); }
.palette-empty .empty-primary b { display: grid; place-items: center; width: 32px; height: 32px; color: var(--control); font-size: 1rem; background: #fff; border-radius: 9px; }

.tool-dock {
  grid-template-columns: repeat(5, minmax(72px, 104px)); height: 70px; padding: 6px;
  background: rgba(255, 253, 248, .92); border: 1px solid rgba(32,40,34,.17); border-radius: 19px;
  box-shadow: 0 12px 38px rgba(31,27,22,.2); backdrop-filter: blur(18px);
}
.tool-dock button {
  gap: 4px; color: #59625c; font-size: inherit; font-weight: 700; border-radius: 13px;
}
.tool-dock button svg {
  width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.tool-dock button span { font-size: .61rem; line-height: 1; }
.tool-dock button:hover { color: var(--ink); background: var(--soft-surface); }
.tool-dock button.active { color: #fff; background: var(--control); box-shadow: 0 4px 12px rgba(39,54,46,.2); }

.daub-inspector {
  background: var(--raised-surface); border-color: rgba(32,40,34,.2); border-radius: 18px;
  box-shadow: 0 12px 32px rgba(39,31,21,.15);
}
.inspector-actions { gap: 3px; padding: 3px; background: var(--soft-surface); border-radius: 13px; }
.inspector-actions button {
  min-height: 40px; background: transparent; border: 0; border-radius: 10px; font-weight: 700;
}
.inspector-actions button:hover { background: rgba(255,255,255,.8); }
.inspector-actions .primary-button { min-height: 40px; box-shadow: none; }
.inspector-actions .danger-button:hover { color: #fff; background: #a34838; }
.mix-handle {
  min-height: 46px; color: #7f3b25; background: rgba(201,92,53,.1); border: 0; border-radius: 12px;
}
.mix-handle:hover { background: rgba(201,92,53,.16); }
.mix-handle span { width: 27px; height: 27px; background: var(--orange); border-radius: 9px; }

.mix-selection-bar { padding: 7px 7px 7px 15px; border: 0; border-radius: 15px; box-shadow: 0 10px 28px rgba(45,35,23,.17); }
.mix-selection-bar button { min-height: 38px; background: transparent; border: 0; border-radius: 9px; font-weight: 700; }
.mix-selection-bar button:hover { background: var(--soft-surface); }

.sheet-backdrop { background: rgba(27,31,27,.32); backdrop-filter: blur(4px); }
.tool-sheet { background: #fbfaf6; border-color: rgba(32,40,34,.14); border-radius: 24px 0 0 24px; box-shadow: -18px 0 55px rgba(35,29,21,.17); }
.sheet-header { height: 88px; padding-inline: 27px; }
.close-button { color: #56615a; background: var(--soft-surface); border: 0; border-radius: 12px; }
.close-button:hover { color: var(--ink); background: #e4dfd4; }
.sheet-panel { padding-inline: 27px; }

.paintbox-intro button { border: 0; }
.search-field { height: 50px; background: #fff; border-color: rgba(32,40,34,.14); border-radius: 13px; box-shadow: 0 2px 7px rgba(32,40,34,.04); }
.search-field input { border-radius: 13px; }
.filter-row { gap: 7px; margin-top: 14px; }
.filter-row button {
  min-height: 34px; padding-inline: 12px; background: var(--soft-surface); border-color: transparent; border-radius: 9px; font-weight: 700;
}
.filter-row button:hover { background: #e4dfd5; }
.filter-row button.active { color: #fff; background: var(--control); border-color: var(--control); }
.tube-list { gap: 8px; }
.tube-row {
  min-height: 66px; padding: 9px; background: #f3f0e8; border-color: transparent; border-radius: 14px;
}
.tube-row:hover { background: #eeeadf; }
.squeeze-button {
  min-width: 78px; color: #fff; background: var(--control); border: 0; border-radius: 10px; box-shadow: 0 3px 9px rgba(39,54,46,.13);
}
.squeeze-button:hover { background: var(--control-hover); }

.ratio-row { padding: 11px; background: #f2efe7; border: 0; border-radius: 14px; }
.parts-control { height: 38px; background: #fff; border-color: rgba(32,40,34,.15); border-radius: 10px; }
.parts-control button { background: transparent; }
.parts-control button:hover { background: var(--soft-surface); }
.mix-preview-card { background: #f1ede4; border: 0; border-radius: 16px; }
.recipe-list { overflow: hidden; border-color: rgba(32,40,34,.12); border-radius: 13px; }
.sheet-actions button { border-color: transparent; border-radius: 11px; font-weight: 700; }
.sheet-actions button:first-child { background: var(--soft-surface); }
.sheet-actions button:first-child:hover { background: #e4dfd4; }

.target-controls > * { background: #f3f0e8; border-color: transparent; border-radius: 12px; }
.target-controls button { font-weight: 700; }
.target-controls button:hover { background: #e7e2d8; }
.target-color-control input { border-radius: 8px; overflow: hidden; }
.source-choice { background: #f3f0e8; border: 0; border-radius: 13px; }
.match-empty { border-color: rgba(32,40,34,.19); border-radius: 14px; }
.match-swatches { border: 0; border-radius: 15px; }
.wheel-toolbar > div { background: var(--soft-surface); border: 0; border-radius: 12px; }
.wheel-toolbar button, .wheel-toolbar output { background: transparent; border-color: rgba(32,40,34,.1); }
.wheel-toolbar button:hover { background: rgba(255,255,255,.8); }
.wheel-choice { background: #f2efe7; border: 0; border-radius: 16px; }
.wheel-choice button { border-color: transparent; border-radius: 11px; font-weight: 700; }
.wheel-choice button:not(.primary-button) { background: #fff; }
.toast { border-radius: 12px; box-shadow: 0 10px 28px rgba(31,27,22,.22); }

@media (max-width: 820px) {
  .topbar { min-height: 58px; }
  .workspace-heading h1 { font-size: 1.18rem; }
  .palette-board { border-radius: 18px; }
  .tool-dock {
    right: 8px; left: 8px; grid-template-columns: repeat(5, 1fr); height: 64px;
    background: rgba(255,253,248,.94); border-radius: 17px;
  }
  .tool-dock button { gap: 3px; }
  .tool-dock button svg { width: 19px; height: 19px; }
  .tool-dock button span { font-size: .56rem; }
  .tool-sheet, .tool-sheet[data-sheet="wheel"] { border-radius: 22px 22px 0 0; }
  .sheet-header { height: 70px; padding-inline: 18px; }
  .sheet-panel { padding-inline: 16px; }
  .daub-inspector { background: rgba(255,253,248,.96); border-radius: 16px; }
  .inspector-actions { background: transparent; padding: 0; }
  .inspector-actions button { background: var(--soft-surface); }
  .mix-selection-bar { border-radius: 14px; }
}

button, a, label { -webkit-tap-highlight-color: transparent; }
.paintbox-intro button { padding-inline: 12px; background: var(--soft-surface); border-radius: 10px; }
.paintbox-intro button:hover { background: #e4dfd4; }


/* Selected-color exploration */
.tool-sheet[data-sheet="explore"] { width: min(650px, 95vw); }
.explore-source {
  display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 13px; align-items: center;
  margin-bottom: 17px; padding: 11px; background: #f2efe7; border-radius: 15px;
}
.explore-base-swatch {
  width: 58px; height: 58px; background: var(--paint); border: 1px solid rgba(32,40,34,.2);
  border-radius: 47% 53% 45% 55%; box-shadow: inset 6px 7px 10px rgba(255,255,255,.15), inset -5px -5px 9px rgba(0,0,0,.1);
}
.explore-source strong, .explore-source small { display: block; }
.explore-source strong { margin: 3px 0; font-family: Georgia, serif; font-size: 1.04rem; }
.explore-source small { overflow: hidden; color: var(--muted); font-size: .62rem; text-overflow: ellipsis; white-space: nowrap; }

.explore-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px;
  background: var(--soft-surface); border-radius: 13px;
}
.explore-tabs button {
  min-height: 40px; color: var(--muted); font-size: .67rem; font-weight: 780;
  background: transparent; border: 0; border-radius: 10px;
}
.explore-tabs button:hover { color: var(--ink); background: rgba(255,255,255,.65); }
.explore-tabs button.active { color: #fff; background: var(--control); box-shadow: 0 3px 10px rgba(39,54,46,.16); }
.explore-description { min-height: 0; margin: 12px 2px 14px; font-family: Inter, "Helvetica Neue", Arial, sans-serif; font-size: .71rem; }

.explore-directions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.explore-direction {
  position: relative; display: grid; grid-template-columns: 42px minmax(0,1fr); gap: 10px; align-items: center;
  min-height: 86px; padding: 9px; text-align: left; background: #f4f1e9; border: 1px solid transparent; border-radius: 14px;
}
.explore-direction:hover { background: #eeeadf; }
.explore-direction.active { background: #fff; border-color: var(--control); box-shadow: 0 5px 15px rgba(39,54,46,.09); }
.explore-direction-swatch {
  width: 42px; height: 42px; background: var(--paint); border: 1px solid rgba(32,40,34,.2); border-radius: 50%;
  box-shadow: inset 4px 5px 7px rgba(255,255,255,.14), inset -4px -4px 7px rgba(0,0,0,.1);
}
.explore-direction-copy { min-width: 0; }
.explore-direction-copy strong, .explore-direction-copy small, .explore-direction-copy em { display: block; }
.explore-direction-copy strong { margin-bottom: 2px; font-family: Georgia, serif; font-size: .82rem; }
.explore-direction-copy small { color: var(--muted); font-size: .56rem; line-height: 1.25; }
.explore-direction-copy em { margin-top: 4px; overflow: hidden; color: #3d4c44; font-size: .54rem; font-style: normal; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.explore-direction-status {
  position: absolute; top: 6px; right: 7px; padding: 2px 5px; color: #40614d; font-size: .46rem;
  font-weight: 850; letter-spacing: .06em; text-transform: uppercase; background: #dfeadf; border-radius: 5px;
}
.explore-direction-status.suggested { color: #875035; background: #f2dfd2; }

.explore-result-section { margin-top: 19px; padding-top: 17px; border-top: 1px solid var(--line); }
.explore-ratio-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.explore-ratio-heading label { font-size: .63rem; font-weight: 820; letter-spacing: .09em; text-transform: uppercase; }
.explore-ratio-heading output {
  min-width: 52px; padding: 6px 8px; color: #fff; font-size: .65rem; font-weight: 850; text-align: center;
  background: var(--control); border-radius: 8px;
}
.explore-ratio {
  width: 100%; height: 24px; margin: 0; appearance: none; background: transparent;
}
.explore-ratio::-webkit-slider-runnable-track {
  height: 5px; background: linear-gradient(90deg, var(--orange) var(--range-progress, 10%), #ddd8cd var(--range-progress, 10%)); border-radius: 99px;
}
.explore-ratio::-moz-range-track { height: 5px; background: #ddd8cd; border-radius: 99px; }
.explore-ratio::-moz-range-progress { height: 5px; background: var(--orange); border-radius: 99px; }
.explore-ratio::-webkit-slider-thumb {
  width: 21px; height: 21px; margin-top: -8px; appearance: none; background: #fff; border: 2px solid var(--control);
  border-radius: 50%; box-shadow: 0 2px 6px rgba(32,40,34,.2);
}
.explore-ratio::-moz-range-thumb {
  width: 18px; height: 18px; background: #fff; border: 2px solid var(--control); border-radius: 50%;
  box-shadow: 0 2px 6px rgba(32,40,34,.2);
}
.explore-ratio-ends, .explore-path-heading {
  display: flex; justify-content: space-between; color: var(--muted); font-size: .53rem;
}
.explore-ratio-ends { margin-top: -2px; }
.explore-ratio-ends span { max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.explore-path-heading { margin: 16px 0 6px; font-weight: 720; letter-spacing: .05em; text-transform: uppercase; }
.explore-path { display: grid; grid-template-columns: repeat(9, 1fr); gap: 3px; }
.explore-path-step {
  position: relative; min-width: 0; height: 40px; padding: 0; background: var(--paint); border: 0; border-radius: 7px;
}
.explore-path-step:hover { transform: translateY(-2px); }
.explore-path-step.current::after {
  position: absolute; inset: 3px; content: ""; border: 2px solid #fff; border-radius: 5px; box-shadow: 0 0 0 1px var(--control);
}
.explore-preview-card {
  display: grid; grid-template-columns: 82px minmax(0,1fr); gap: 14px; align-items: center;
  min-height: 104px; margin-top: 14px; padding: 11px; background: #f1ede4; border-radius: 15px;
}
.explore-preview-swatch {
  width: 82px; height: 82px; background: var(--paint); border: 1px solid rgba(32,40,34,.2); border-radius: 48% 52% 44% 56%;
  box-shadow: inset 7px 8px 12px rgba(255,255,255,.15), inset -7px -7px 11px rgba(0,0,0,.1);
}
.explore-preview-card strong, .explore-preview-card small { display: block; }
.explore-preview-card strong { margin: 4px 0; font-family: Georgia, serif; font-size: 1.08rem; }
.explore-preview-card small { color: var(--muted); font-size: .62rem; }
.explore-setup { min-height: 50px; margin-top: 13px; }

.parts-control { grid-template-columns: 32px 54px 32px; }

@media (max-width: 820px) {
  .tool-sheet[data-sheet="explore"] { width: 100%; }
  #inspector-explore, #inspector-delete { width: 44px; padding: 0; overflow: hidden; color: transparent; }
  #inspector-explore::before { color: var(--ink); content: "◐"; font-size: 1rem; }
  .explore-source { grid-template-columns: 48px minmax(0,1fr); margin-bottom: 12px; }
  .explore-base-swatch { width: 48px; height: 48px; }
  .explore-description { margin-block: 10px; }
  .explore-directions {
    display: grid; grid-auto-flow: column; grid-auto-columns: min(82vw, 310px); grid-template-columns: none;
    gap: 8px; margin-inline: -2px; padding: 2px 2px 8px; overflow-x: auto; scroll-snap-type: x proximity;
  }
  .explore-direction { scroll-snap-align: start; }
  .explore-result-section { margin-top: 10px; padding-top: 13px; }
  .explore-path-step { height: 36px; }
  .explore-preview-card { grid-template-columns: 68px minmax(0,1fr); min-height: 88px; }
  .explore-preview-swatch { width: 68px; height: 68px; }
}

/* Finish previews, explicit saves, and reference studies */
.reference-note { display: block; margin-top: 5px; font-size: .61rem; }
.reference-note a { color: var(--control); font-weight: 750; }
.tube-info .tube-note { overflow: visible; color: #785b3f; line-height: 1.35; text-overflow: clip; white-space: normal; }

.paint-daub::before {
  background:
    repeating-radial-gradient(ellipse at 38% 44%, rgb(255 255 255 / var(--finish-texture, .05)) 0 1px, transparent 2px 7px),
    var(--paint);
  box-shadow:
    inset 9px 11px 16px rgb(255 255 255 / calc(.08 + var(--finish-ridge, .16))),
    inset -9px -8px 14px rgb(0 0 0 / calc(.05 + var(--finish-ridge, .16))),
    0 8px 12px rgba(47,35,22,.16);
}
.paint-daub::after { background: #fff; opacity: var(--finish-highlight, .2); }
.inspector-swatch, .surface-preview, .surface-option i, .saved-swatch {
  background:
    linear-gradient(145deg, rgb(255 255 255 / var(--finish-highlight, .2)) 3%, transparent 38%),
    repeating-radial-gradient(ellipse at 38% 44%, rgb(255 255 255 / var(--finish-texture, .05)) 0 1px, transparent 2px 7px),
    var(--paint);
  box-shadow:
    inset 7px 8px 12px rgb(255 255 255 / calc(.08 + var(--finish-ridge, .16))),
    inset -6px -6px 11px rgb(0 0 0 / calc(.04 + var(--finish-ridge, .16)));
}

.library-section + .library-section { margin-top: 28px; padding-top: 23px; border-top: 1px solid rgba(32,40,34,.12); }
.library-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 11px; }
.library-heading h3 { margin: 3px 0 0; font-family: Georgia, serif; font-size: 1.2rem; font-weight: 400; }
.save-palette-form { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; margin-bottom: 10px; }
.save-palette-form input { min-width: 0; min-height: 48px; padding: 0 12px; background: #fff; border: 1px solid rgba(32,40,34,.15); border-radius: 11px; }
.save-palette-form button { padding-inline: 14px; }
.saved-list { display: grid; gap: 8px; }
.saved-empty { padding: 22px 14px; color: var(--muted); font-family: Georgia, serif; font-size: .82rem; text-align: center; border: 1px dashed rgba(32,40,34,.2); border-radius: 13px; }
.saved-item { display: grid; grid-template-columns: 46px minmax(0,1fr) auto; gap: 11px; align-items: center; min-height: 64px; padding: 9px; background: #f3f0e8; border-radius: 13px; }
.saved-swatch { display: block; width: 44px; height: 44px; border: 1px solid rgba(32,40,34,.18); border-radius: 48% 43% 52% 45%; }
.saved-info { min-width: 0; }
.saved-info strong, .saved-info small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-info strong { font-family: Georgia, serif; font-size: .88rem; }
.saved-info small { margin-top: 3px; color: var(--muted); font-size: .59rem; }
.saved-actions { display: flex; gap: 4px; }
.saved-actions button { min-height: 38px; padding: 0 9px; background: #fff; border: 0; border-radius: 9px; font-size: .61rem; font-weight: 750; }
.saved-palette-strip { display: flex; width: 46px; height: 44px; overflow: hidden; border: 1px solid rgba(32,40,34,.18); border-radius: 9px; }
.saved-palette-strip i { flex: 1 1 0; min-width: 3px; background: var(--paint); }

.surface-preview-card { display: grid; grid-template-columns: 108px minmax(0,1fr); gap: 16px; align-items: center; padding: 13px; background: #f1ede4; border-radius: 15px; }
.surface-preview { width: 108px; height: 94px; border: 1px solid rgba(32,40,34,.2); border-radius: 48% 52% 44% 56%; }
.surface-preview-card strong, .surface-preview-card small { display: block; }
.surface-preview-card strong { margin: 5px 0; font-family: Georgia, serif; font-size: 1.1rem; }
.surface-preview-card small { color: var(--muted); font-size: .64rem; }
.surface-heading { display: flex; align-items: end; justify-content: space-between; margin: 22px 0 9px; }
.surface-heading small { color: var(--muted); font-size: .58rem; }
.surface-options { display: grid; gap: 8px; }
.surface-option { display: grid; grid-template-columns: 54px minmax(0,1fr); gap: 12px; align-items: center; width: 100%; min-height: 72px; padding: 8px; text-align: left; background: #f3f0e8; border: 1px solid transparent; border-radius: 13px; }
.surface-option:hover { background: #eeeadf; }
.surface-option.active { background: #fff; border-color: var(--control); box-shadow: 0 5px 15px rgba(39,54,46,.08); }
.surface-option i { display: block; width: 52px; height: 52px; border: 1px solid rgba(32,40,34,.18); border-radius: 47% 53% 45% 55%; }
.surface-option strong, .surface-option small, .surface-option em { display: block; }
.surface-option strong { font-family: Georgia, serif; font-size: .9rem; }
.surface-option small { margin-top: 2px; color: #3d4c44; font-size: .6rem; font-weight: 750; }
.surface-option em { margin-top: 3px; color: var(--muted); font-size: .56rem; font-style: normal; }
.surface-caveat { margin: 14px 2px 0; color: var(--muted); font-size: .61rem; line-height: 1.45; }

.reference-pin {
  position: absolute; z-index: 24; top: 16px; right: 17px; width: clamp(118px, 15vw, 210px); min-height: 0; padding: 7px 7px 25px;
  overflow: visible; background: #fffdf8; border: 1px solid rgba(32,40,34,.36); border-radius: 3px; box-shadow: 0 8px 20px rgba(35,28,20,.25);
  transform: rotate(1.3deg);
}
.reference-pin:hover { transform: rotate(.4deg) scale(1.02); }
.reference-pin img { display: block; width: 100%; max-height: 150px; object-fit: contain; background: #ddd7cc; }
.reference-pin > span:last-child { position: absolute; right: 7px; bottom: 6px; left: 7px; overflow: hidden; font-size: .55rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.reference-pin .pin-mark { position: absolute; z-index: 2; top: -9px; left: 50%; color: #9c4934; font-size: 1rem; text-shadow: 0 2px 2px rgba(0,0,0,.24); transform: translateX(-50%); }

.reference-upload { display: grid; justify-items: center; padding: 24px 16px; cursor: pointer; text-align: center; background: #f3f0e8; border: 1px dashed rgba(32,40,34,.3); border-radius: 15px; }
.reference-upload:hover { background: #eeeadf; }
.reference-upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.reference-upload span { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 8px; color: #fff; font-size: 1.25rem; background: var(--control); border-radius: 12px; }
.reference-upload strong { font-family: Georgia, serif; font-size: 1rem; }
.reference-upload small { margin-top: 5px; color: var(--muted); font-size: .6rem; }
#reference-workspace { margin-top: 14px; }
.reference-canvas { display: block; width: 100%; max-height: 360px; object-fit: contain; background: #d8d2c7; border: 1px solid rgba(32,40,34,.2); border-radius: 13px; image-rendering: pixelated; }
.reference-heatmap { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 8px; padding: 8px 10px; background: #eef3f8; border: 1px solid rgba(40,92,148,.2); border-radius: 10px; }
.reference-heatmap-copy { display: grid; min-width: 0; }
.reference-heatmap-copy span { color: var(--muted); font-size: .5rem; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.reference-heatmap-copy strong { overflow: hidden; font-family: Georgia,serif; font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.reference-heatmap-scale { display: grid; grid-template-columns: auto minmax(56px,90px) auto; align-items: center; gap: 5px; flex: 0 1 180px; }
.reference-heatmap-scale i { height: 8px; background: linear-gradient(90deg,#8b8b88,#1476f2); border-radius: 999px; }
.reference-heatmap-scale small { color: var(--muted); font-size: .45rem; font-weight: 700; }
.reference-mode { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 13px 0 18px; padding: 4px; background: #ebe7dd; border-radius: 12px; }
.reference-mode button, .value-step-options button { min-height: 40px; background: transparent; border: 0; border-radius: 9px; font-size: .65rem; font-weight: 750; }
.reference-mode button.active, .value-step-options button.active { color: #fff; background: var(--control); }
.range-heading { display: flex; align-items: baseline; justify-content: space-between; margin: 15px 1px 7px; }
.range-heading label { font-size: .68rem; font-weight: 750; }
.range-heading output { color: var(--muted); font-size: .63rem; font-weight: 750; }
.reference-range { width: 100%; accent-color: var(--control); }
.range-ends { display: flex; justify-content: space-between; margin-top: 2px; color: var(--muted); font-size: .54rem; }
.value-step-options { display: grid; grid-template-columns: repeat(3,1fr); gap: 5px; margin-top: 7px; padding: 4px; background: #ebe7dd; border-radius: 12px; }
.value-color-heading { display: block; margin-top: 17px; }
.value-color-options { display: grid; grid-template-columns: repeat(auto-fit,minmax(92px,1fr)); gap: 6px; margin-top: 7px; }
.value-color-options button { display: grid; grid-template-columns: 16px 1fr; grid-template-rows: auto auto; min-height: 48px; padding: 7px 8px; text-align: left; background: #f3f0e8; border: 1px solid rgba(32,40,34,.16); border-radius: 10px; }
.value-color-options button:hover { background: #ebe7dd; }
.value-color-options button.active { background: #fffdf8; border-color: var(--control); box-shadow: 0 0 0 1px var(--control); }
.value-color-options i { grid-row: 1 / 3; align-self: center; width: 13px; height: 24px; background: var(--study-color); border: 1px solid rgba(32,40,34,.25); border-radius: 5px; }
.value-color-options span { align-self: end; overflow: hidden; font-size: .59rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.value-color-options small { align-self: start; color: var(--muted); font-size: .48rem; }
.reference-swatches { display: grid; grid-template-columns: repeat(auto-fit,minmax(64px,1fr)); gap: 5px; margin: 17px 0 13px; }
.reference-swatches div { display: flex; flex-direction: column; justify-content: end; min-height: 58px; padding: 5px; color: #fff; background: var(--paint); border: 1px solid rgba(32,40,34,.22); border-radius: 8px; box-shadow: inset 0 -24px 18px rgba(0,0,0,.2); text-shadow: 0 1px 2px rgba(0,0,0,.7); }
.reference-swatches span { font-size: .51rem; font-weight: 800; }
.reference-swatches small { font-size: .48rem; }
.reference-remove { margin-top: 8px; background: transparent; border: 1px solid rgba(146,62,45,.25); border-radius: 11px; }

@media (max-width: 820px) {
  .tool-dock { grid-template-columns: repeat(5, 1fr); }
  .tool-dock button span { font-size: .55rem; }
  .reference-pin { top: 10px; right: 10px; width: 112px; }
  .reference-pin img { max-height: 92px; }
  .inspector-actions { gap: 2px; }
  #inspector-explore, #inspector-surface, #inspector-save, #inspector-delete { width: 40px; min-width: 40px; padding: 0; overflow: hidden; color: transparent; }
  #inspector-explore::before { color: var(--ink); content: "◐"; font-size: .92rem; }
  #inspector-surface::before { color: var(--ink); content: "✦"; font-size: .92rem; }
  #inspector-save::before { color: var(--ink); content: "☆"; font-size: 1rem; }
  #inspector-delete::before { color: #923e2d; content: "×"; font-size: 1.1rem; }
}

@media (max-width: 520px) {
  .inspector-actions button, #inspector-explore, #inspector-surface, #inspector-save, #inspector-delete { width: 34px; min-width: 34px; padding: 0; }
  .inspector-actions #inspector-mix { width: 40px; min-width: 40px; font-size: .56rem; }
  .save-palette-form { grid-template-columns: 1fr; }
  .saved-item { grid-template-columns: 42px minmax(0,1fr); }
  .saved-actions { grid-column: 2; }
  .surface-preview-card { grid-template-columns: 80px minmax(0,1fr); }
  .surface-preview { width: 80px; height: 72px; }
  .surface-heading { display: block; }
  .surface-heading small { display: block; margin-top: 4px; }
}


/* Paint Plan workspace */
.workspace-switcher {
  display: flex; gap: 3px; padding: 3px; background: rgba(32,40,34,.07);
  border: 1px solid var(--line); border-radius: 11px;
}
.workspace-switcher button {
  min-height: 36px; padding: 0 15px; color: var(--muted); font-size: .68rem; font-weight: 800;
  background: transparent; border: 0; border-radius: 8px;
}
.workspace-switcher button.active { color: #fff; background: var(--control, var(--ink)); box-shadow: 0 3px 10px rgba(32,40,34,.16); }
.plan-workspace { max-width: 1760px; margin: auto; }
.plan-heading p { max-width: 540px; }
.paint-plan { min-height: 520px; }
.plan-upload { min-height: min(62vh, 620px); place-content: center; background: rgba(255,253,247,.42); }
.plan-upload span { width: 58px; height: 58px; font-size: 1.7rem; }
.plan-upload strong { font-size: 1.35rem; }
.plan-upload small { max-width: 360px; font-size: .68rem; line-height: 1.45; }
#reference-workspace.plan-layout {
  display: grid; grid-template-columns: minmax(220px, 280px) minmax(360px, 1fr) minmax(310px, 390px);
  gap: 14px; align-items: start; margin-top: 0;
}
.plan-controls, .plan-results { display: grid; gap: 12px; }
.plan-control-card, .plan-summary-card, .plan-tubes-card, .plan-family-section, .plan-stage-panel {
  background: rgba(255,253,247,.64); border: 1px solid var(--line); border-radius: 16px;
}
.plan-control-card, .plan-summary-card, .plan-tubes-card, .plan-family-section { padding: 14px; }
.plan-control-card h2, .plan-summary-card h2, .plan-card-heading h2 {
  margin: 4px 0 12px; font-family: Georgia, serif; font-size: 1.08rem; font-weight: 400;
}
.choice-stack { display: grid; gap: 6px; }
.choice-stack button {
  display: grid; min-height: 54px; padding: 8px 10px; text-align: left; background: rgba(244,239,227,.62);
  border: 1px solid transparent; border-radius: 10px;
}
.choice-stack button:hover { background: rgba(244,239,227,.95); }
.choice-stack button.active { background: #fff; border-color: var(--control, var(--ink)); box-shadow: 0 3px 12px rgba(32,40,34,.08); }
.choice-stack strong, .choice-stack small { display: block; }
.choice-stack strong { font-family: Georgia, serif; font-size: .84rem; }
.choice-stack small { margin-top: 2px; color: var(--muted); font-size: .55rem; }
.plan-select-label {
  display: grid; gap: 6px; margin-top: 12px; color: var(--muted); font-size: .61rem; font-weight: 800;
}
.plan-select-label select {
  min-height: 42px; padding: 0 9px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 9px;
}
.plan-select-label select:focus-visible { outline: 3px solid rgba(201,92,53,.35); outline-offset: 2px; }
.control-note { margin: 9px 1px 0; color: var(--muted); font-size: .58rem; line-height: 1.45; }
.plan-control-card > button, .plan-tubes-card > button, .plan-family-section > button {
  min-height: 42px; padding: 0 10px; background: transparent; border: 1px solid var(--line-strong); border-radius: 10px; font-size: .65rem; font-weight: 800;
}
.plan-file-card { display: grid; gap: 7px; }
.plan-file-card strong { margin-bottom: 5px; overflow: hidden; font-family: Georgia, serif; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.plan-stage-panel { position: sticky; top: 14px; padding: 12px; }
.reference-canvas-wrap { position: relative; display: grid; place-items: center; min-height: 320px; overflow: hidden; background: #d8d2c7; border-radius: 12px; }
.reference-canvas-wrap .reference-canvas {
  width: 100%; max-height: min(62vh, 720px); cursor: crosshair; object-fit: contain; background: transparent; border: 0; border-radius: 0; image-rendering: auto;
}
.canvas-hint {
  position: absolute; right: 9px; bottom: 9px; margin: 0; padding: 7px 9px; pointer-events: none;
  color: #fff; font-size: .55rem; font-weight: 750; background: rgba(25,32,27,.78); border-radius: 8px;
}
.plan-view-tabs { grid-template-columns: repeat(5, minmax(0,1fr)); margin: 10px 0; }
.plan-view-tabs button { min-width: 0; padding: 0 5px; font-size: .57rem; }
.plan-inline-controls {
  display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 14px;
  margin-bottom: 10px; padding: 10px 12px; background: rgba(244,239,227,.65); border-radius: 11px;
}
.plan-inline-controls .range-heading { margin-top: 0; }
.plan-blur-control { padding: 0 2px; }
.plan-blur-control .range-heading { margin-top: 10px; }
.compact-value-options { grid-template-columns: repeat(auto-fit,minmax(76px,1fr)); }
.compact-value-options button { grid-template-rows: auto; min-height: 42px; }
.compact-value-options button i { grid-row: 1; }
.reference-swatches:empty { display: none; }
.reference-heatmap { margin-top: 10px; }
.plan-card-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.plan-card-heading > span {
  display: grid; place-items: center; min-width: 29px; height: 29px; padding: 0 8px;
  color: #fff; font-size: .61rem; font-weight: 850; background: var(--control, var(--ink)); border-radius: 99px;
}
.plan-card-heading h2 { margin-bottom: 8px; }
.coverage-meter { height: 8px; margin: 10px 0 7px; overflow: hidden; background: rgba(32,40,34,.1); border-radius: 99px; }
.coverage-meter i { display: block; width: 0; height: 100%; background: var(--orange); border-radius: inherit; transition: width 220ms ease; }
.plan-summary-card > small { color: var(--muted); font-size: .57rem; line-height: 1.4; }
.plan-placeholder { margin: 6px 0; padding: 14px 8px; color: var(--muted); font-family: Georgia, serif; font-size: .72rem; line-height: 1.45; text-align: center; }
.plan-tube-list { display: grid; gap: 5px; margin-bottom: 10px; }
.plan-tube {
  display: grid; grid-template-columns: 31px minmax(0,1fr); gap: 8px; align-items: center;
  min-height: 45px; padding: 5px 6px; background: rgba(244,239,227,.62); border-radius: 9px;
}
.plan-tube > i { width: 29px; height: 29px; background: var(--paint); border: 1px solid var(--line-strong); border-radius: 50%; }
.plan-tube strong, .plan-tube small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-tube strong { font-family: Georgia, serif; font-size: .72rem; }
.plan-tube small { margin-top: 2px; color: var(--muted); font-size: .51rem; }
.plan-tubes-card > button + button { margin-top: 6px; }
.plan-family-list { display: grid; gap: 9px; max-height: min(58vh, 640px); padding: 2px; overflow: auto; }
.plan-family-card {
  padding: 9px; background: rgba(244,239,227,.66); border: 1px solid transparent; border-radius: 12px;
}
.plan-family-card.selected { background: #fff; border-color: var(--control, var(--ink)); box-shadow: 0 4px 14px rgba(32,40,34,.08); }
.family-card-header { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 7px; align-items: center; }
.family-card-header > input {
  min-width: 0; height: 36px; padding: 0 7px; font-family: Georgia, serif; font-size: .8rem; background: transparent; border: 0; border-bottom: 1px solid var(--line);
}
.family-accept { display: flex; gap: 4px; align-items: center; font-size: .55rem; font-weight: 800; }
.family-gradient { width: 100%; min-height: 28px; margin-top: 7px; border: 1px solid rgba(32,40,34,.24); border-radius: 8px; }
.family-anchors { display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; margin-top: 6px; }
.family-anchors span { display: grid; grid-template-columns: 8px 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 4px; min-width: 0; }
.family-anchors i { grid-row: 1 / 3; width: 8px; height: 22px; background: var(--anchor); border-radius: 4px; }
.family-anchors b { color: var(--muted); font-size: .48rem; text-transform: capitalize; }
.family-anchors small { font-size: .46rem; }
.family-meta { display: block; margin: 7px 0; color: var(--muted); font-size: .49rem; }
.family-recipes { display: grid; grid-template-columns: auto 1fr; gap: 5px 7px; margin: 9px 0; padding-top: 8px; border-top: 1px solid var(--line); }
.family-recipes > strong { color: var(--muted); font-size: .5rem; text-transform: uppercase; }
.plan-recipe p { margin: 0; font-size: .56rem; line-height: 1.35; }
.plan-recipe small { display: block; margin-top: 2px; color: var(--muted); font-size: .48rem; line-height: 1.3; }
.family-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.family-actions button {
  min-height: 32px; padding: 0 8px; background: #fff; border: 1px solid var(--line); border-radius: 7px; font-size: .52rem; font-weight: 750;
}
.plan-family-section > .wide-button { margin-top: 10px; }
.paint-family-rail {
  position: absolute; z-index: 0; height: 18px; min-width: 80px; pointer-events: none;
  border: 2px solid rgba(255,253,247,.82); border-radius: 99px; box-shadow: 0 0 0 1px rgba(32,40,34,.34), 0 5px 12px rgba(32,40,34,.15);
  transform: translateY(-50%);
}
.paint-family-rail::after { position: absolute; top: 50%; right: -6px; width: 10px; height: 10px; content: ""; background: inherit; border: 2px solid #fff; border-radius: 50%; transform: translateY(-50%); }
.paint-family-rail span {
  position: absolute; top: 20px; left: 50%; max-width: 150px; padding: 2px 6px; overflow: hidden;
  color: var(--muted); font-size: .48rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; background: rgba(251,248,239,.8); transform: translateX(-50%);
}

@media (max-width: 1240px) {
  #reference-workspace.plan-layout { grid-template-columns: 230px minmax(350px,1fr); }
  .plan-results { grid-column: 1 / -1; grid-template-columns: minmax(200px,.65fr) minmax(260px,1fr) minmax(360px,1.35fr); }
  .plan-family-list { max-height: 440px; }
}

@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; gap: 6px 10px; }
  .workspace-switcher { order: 3; width: 100%; }
  .workspace-switcher button { flex: 1; }
  #reference-workspace.plan-layout { grid-template-columns: 1fr; }
  .plan-controls, .plan-results { grid-column: auto; grid-template-columns: 1fr; }
  .plan-stage-panel { position: static; grid-row: 1; }
  .plan-controls { grid-row: 2; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .plan-file-card { grid-column: 1 / -1; }
  .plan-results { grid-row: 3; }
  .plan-view-tabs { grid-template-columns: repeat(5,minmax(72px,1fr)); overflow-x: auto; }
  .plan-stage-panel { overflow: hidden; }
  .reference-canvas-wrap { min-height: 240px; }
  .plan-family-list { max-height: none; }
}

@media (max-width: 560px) {
  .brand > span:last-child { display: none; }
  .top-actions { margin-left: auto; }
  .plan-heading { display: block; }
  .plan-heading p { margin-top: 7px; text-align: left; }
  .plan-controls { grid-template-columns: 1fr; }
  .plan-file-card { grid-column: auto; }
  .plan-control-card, .plan-summary-card, .plan-tubes-card, .plan-family-section { padding: 11px; }
  .plan-stage-panel { padding: 8px; }
  .plan-view-tabs { margin-inline: -2px; }
  .reference-heatmap { display: grid; }
  .reference-heatmap-scale { width: 100%; }
  .reference-canvas-wrap { min-height: 200px; }
  .canvas-hint { right: 6px; bottom: 6px; max-width: calc(100% - 12px); }
}

.intent-preview-toggle {
  display: grid; grid-template-columns: auto minmax(0,1fr); gap: 9px; align-items: center;
  margin-top: 10px; padding: 9px; cursor: pointer; background: rgba(244,239,227,.68); border: 1px solid var(--line); border-radius: 10px;
}
.intent-preview-toggle input { width: 17px; height: 17px; accent-color: var(--control, var(--ink)); }
.intent-preview-toggle strong, .intent-preview-toggle small { display: block; }
.intent-preview-toggle strong { font-family: Georgia, serif; font-size: .72rem; }
.intent-preview-toggle small { margin-top: 2px; color: var(--muted); font-size: .51rem; line-height: 1.35; }
.reference-heatmap[data-kind="family"], .reference-heatmap[data-kind="planned"] { background: #f5f0e5; border-color: var(--line); }

.paint-daub.plan-guide .daub-label, .paint-daub.plan-guide .daub-number { display: none; }
.palette-axis-label {
  position: absolute; z-index: 1; pointer-events: none; color: rgba(32,40,34,.7); font-size: .56rem; font-weight: 850;
  letter-spacing: .04em; text-transform: uppercase;
}
.palette-axis-x { top: 3%; padding: 4px 8px; background: rgba(251,248,239,.76); border-radius: 99px; transform: translateX(-50%); }
.palette-axis-y {
  left: 1.5%; max-width: 15%; padding: 4px 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: rgba(251,248,239,.76); border-radius: 5px; transform: translateY(-50%);
}
.paintbox-workspace { max-width: 1180px; margin: auto; }
.paintbox-main-panel { padding: clamp(14px,2.5vw,28px); background: rgba(255,253,247,.68); border: 1px solid var(--line); border-radius: 18px; }
.paintbox-main-panel .tube-list { grid-template-columns: repeat(auto-fit,minmax(330px,1fr)); }
.reference-fullscreen {
  position: absolute; z-index: 4; top: 9px; right: 9px; min-height: 34px; padding: 0 10px;
  color: #fff; font-size: .58rem; font-weight: 800; background: rgba(25,32,27,.78); border: 1px solid rgba(255,255,255,.3); border-radius: 8px;
}
.reference-focus-toolbar {
  display: none; grid-template-columns: repeat(2,minmax(180px,1fr)); gap: 9px; margin: 10px 0; padding: 9px;
  background: rgba(244,239,227,.85); border: 1px solid var(--line); border-radius: 11px;
}
.reference-focus-toolbar label { display: grid; gap: 4px; color: var(--muted); font-size: .53rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.reference-focus-toolbar select { min-height: 40px; padding: 0 8px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; }
#reference-stage:fullscreen, #reference-stage.fullsize-fallback {
  z-index: 100; display: grid; grid-template-rows: minmax(0,1fr) auto auto auto auto; width: 100vw; height: 100vh;
  padding: clamp(10px,2vw,24px); overflow: auto; background: var(--paper); border: 0; border-radius: 0;
}
#reference-stage.fullsize-fallback { position: fixed; inset: 0; }
#reference-stage:fullscreen .reference-focus-toolbar, #reference-stage.fullsize-fallback .reference-focus-toolbar { display: grid; }
#reference-stage:fullscreen .reference-canvas-wrap, #reference-stage.fullsize-fallback .reference-canvas-wrap { min-height: 0; height: min(72vh,900px); }
#reference-stage:fullscreen .reference-canvas, #reference-stage.fullsize-fallback .reference-canvas { width: 100%; height: 100%; max-height: none; }
#reference-stage:fullscreen .canvas-hint, #reference-stage.fullsize-fallback .canvas-hint { display: none; }
@media (max-width: 620px) {
  .paintbox-main-panel .tube-list { grid-template-columns: 1fr; }
  .reference-focus-toolbar { grid-template-columns: 1fr; }
  .palette-axis-y { max-width: 19%; font-size: .48rem; }
  .palette-axis-x { font-size: .48rem; }
}

.reference-pin { width: clamp(160px, 19vw, 280px); }
.reference-pin img { max-height: 210px; }
@media (max-width: 820px) {
  .reference-pin { width: 145px; }
  .reference-pin img { max-height: 125px; }
}


/* Studio drawer and contextual selection shelf */
:root { --dock-height: 86px; }
.studio { padding-top: clamp(14px, 2vw, 28px); padding-bottom: calc(var(--dock-height) + 26px); }
.toast { top: 18px; }
.tool-dock {
  right: 50%; left: auto; bottom: max(10px, env(safe-area-inset-bottom));
  display: grid; grid-template-columns: minmax(150px, auto) minmax(0, 1fr) auto; gap: 7px;
  width: min(1040px, calc(100vw - 24px)); height: 76px; padding: 7px;
  background: rgba(255,253,248,.94); border: 1px solid rgba(32,40,34,.2); border-radius: 20px;
  box-shadow: 0 14px 42px rgba(31,27,22,.22); backdrop-filter: blur(18px); transform: translateX(50%);
}
.dock-identity {
  display: flex; gap: 9px; align-items: center; min-width: 0; padding: 0 9px 0 5px;
  border-right: 1px solid var(--line);
}
.dock-identity .brand-mark { flex: 0 0 auto; width: 31px; height: 29px; }
.dock-identity .brand-mark i { width: 17px; height: 17px; }
.dock-title { min-width: 0; }
.dock-title strong, .dock-title small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-title strong { font-family: Georgia, serif; font-size: .82rem; font-weight: 500; }
.dock-title small { margin-top: 3px; color: var(--muted); font-size: .52rem; }
.dock-navigation { display: grid; grid-template-columns: repeat(7, minmax(62px, 1fr)); gap: 3px; min-width: 0; }
.tool-dock .dock-navigation button, .tool-dock .dock-actions button {
  display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center;
  min-width: 0; min-height: 60px; padding: 0 5px; color: #59625c; background: transparent; border: 0; border-radius: 13px;
}
.tool-dock .dock-navigation button:hover, .tool-dock .dock-actions button:hover { color: var(--ink); background: var(--soft-surface); }
.tool-dock .dock-navigation button.active { color: #fff; background: var(--control); box-shadow: 0 4px 12px rgba(39,54,46,.2); }
.tool-dock .dock-navigation button svg, .tool-dock .dock-actions button svg {
  width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.tool-dock .dock-navigation button span, .tool-dock .dock-actions button span { font-size: .54rem; font-weight: 750; line-height: 1; }
.dock-actions { display: flex; gap: 3px; padding-left: 7px; border-left: 1px solid var(--line); }
.tool-dock .dock-actions button { width: 48px; }
.palette-board { min-height: calc(100svh - 176px); }

@media (min-width: 1081px) {
  .palette-workspace.inspector-visible {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 320px); gap: 14px; align-items: start;
  }
  .palette-workspace.inspector-visible .workspace-heading { grid-column: 1 / -1; }
  .palette-workspace.inspector-visible .palette-board { grid-column: 1; grid-row: 2; }
  .palette-workspace.inspector-visible .daub-inspector {
    position: sticky; z-index: 16; top: 14px; right: auto; bottom: auto; left: auto; grid-column: 2; grid-row: 2;
    grid-template-columns: 58px minmax(0,1fr); gap: 13px; min-height: 0; margin: 0; padding: 14px;
  }
  .palette-workspace.inspector-visible .inspector-actions {
    grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 5px; width: 100%;
  }
  .palette-workspace.inspector-visible .inspector-actions #inspector-mix { grid-column: 1 / -1; }
  .palette-workspace.inspector-visible .inspector-actions button { width: 100%; }
  .palette-workspace.inspector-visible .mix-handle { grid-column: 1 / -1; width: 100%; }
}

@media (max-width: 1080px) {
  .palette-workspace.inspector-visible .daub-inspector {
    position: relative; z-index: 16; right: auto; bottom: auto; left: auto; margin: 12px 0 0;
  }
}

@media (max-width: 820px) {
  :root { --dock-height: 118px; }
  .studio { padding: 10px 9px calc(var(--dock-height) + 18px); }
  .tool-dock {
    right: 8px; bottom: max(7px, env(safe-area-inset-bottom)); left: 8px;
    grid-template-columns: minmax(0,1fr) auto; grid-template-rows: 36px 60px; gap: 4px;
    width: auto; height: 108px; padding: 5px; border-radius: 17px; transform: none;
  }
  .dock-identity { grid-column: 1; grid-row: 1; padding: 0 6px; border-right: 0; }
  .dock-identity .brand-mark { width: 26px; height: 24px; }
  .dock-identity .brand-mark i { width: 14px; height: 14px; }
  .dock-title strong { font-size: .72rem; }
  .dock-title small { margin-top: 1px; font-size: .48rem; }
  .dock-navigation { grid-column: 1 / -1; grid-row: 2; grid-template-columns: repeat(7, minmax(42px,1fr)); gap: 2px; }
  .tool-dock .dock-navigation button { min-height: 58px; padding: 0 2px; border-radius: 11px; }
  .tool-dock .dock-navigation button svg { width: 18px; height: 18px; }
  .tool-dock .dock-navigation button span { font-size: .47rem; }
  .dock-actions { grid-column: 2; grid-row: 1; gap: 2px; padding: 0 0 0 4px; }
  .tool-dock .dock-actions button { flex-direction: row; gap: 3px; width: 45px; min-height: 34px; padding: 0 3px; border-radius: 9px; }
  .tool-dock .dock-actions button svg { width: 15px; height: 15px; }
  .tool-dock .dock-actions button span { font-size: .45rem; }
  .palette-board { min-height: calc(100svh - 180px); }
  .palette-workspace.inspector-visible .daub-inspector {
    grid-template-columns: 44px minmax(0,1fr) auto; gap: 9px; min-height: 72px; padding: 8px;
  }
}

@media (max-width: 520px) {
  .dock-title strong { font-size: .68rem; }
  .dock-navigation { grid-template-columns: repeat(7, minmax(38px,1fr)); }
  .tool-dock .dock-navigation button span { font-size: .43rem; }
  .palette-workspace.inspector-visible .daub-inspector { grid-template-columns: 40px minmax(0,1fr) auto; }
}


/* Focused family mixing graph */
.palette-heading-tools { display: grid; gap: 8px; justify-items: end; }
.palette-heading-tools > p { margin: 0; }
.palette-family-focus {
  display: flex; gap: 8px; align-items: center; padding: 6px;
  background: rgba(255,253,247,.72); border: 1px solid var(--line); border-radius: 12px;
}
.family-focus-toggle {
  display: flex; gap: 7px; align-items: center; min-height: 38px; padding: 0 9px;
  font-size: .61rem; font-weight: 800; cursor: pointer;
}
.family-focus-toggle input { width: 16px; height: 16px; accent-color: var(--control, var(--ink)); }
.family-focus-picker { display: grid; gap: 2px; min-width: min(240px, 32vw); }
.family-focus-picker > span { color: var(--muted); font-size: .46rem; font-weight: 850; letter-spacing: .07em; text-transform: uppercase; }
.family-focus-picker select {
  min-width: 0; min-height: 34px; padding: 0 28px 0 8px;
  color: var(--ink); font-family: Georgia, serif; font-size: .72rem;
  background: #fff; border: 1px solid var(--line); border-radius: 7px;
}
.palette-recipe-links, .palette-recipe-labels {
  position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none;
}
.palette-recipe-links { z-index: 0; overflow: visible; }
.palette-recipe-labels { z-index: 8; }
#recipe-input-arrow path { fill: #466352; }
#recipe-adjust-arrow path { fill: #a84f31; }
.recipe-link {
  fill: none; stroke: #466352; stroke-width: .55; stroke-linecap: round;
  opacity: .82; vector-effect: non-scaling-stroke;
}
.recipe-link.adjustment {
  stroke: #a84f31; stroke-width: .82; stroke-dasharray: 2 1.15; opacity: .95;
}
.recipe-link.adjustment-input { stroke: #8b6834; stroke-dasharray: 1.4 1.1; }
.recipe-link-label {
  position: absolute; max-width: 150px; padding: 3px 6px; overflow: hidden;
  color: #32443a; font-size: .49rem; font-weight: 850; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap;
  background: rgba(255,253,247,.91); border: 1px solid rgba(50,68,58,.25); border-radius: 99px;
  box-shadow: 0 2px 7px rgba(32,40,34,.09); transform: translate(-50%,-50%);
}
.recipe-link-label.adjustment { color: #7b3825; border-color: rgba(168,79,49,.32); }
.recipe-link-label.adjustment-input { color: #6b4b20; border-color: rgba(139,104,52,.3); }
.family-focus-active .paint-family-rail { opacity: .45; }
.paint-daub.family-hidden { opacity: .035; pointer-events: none; }
.paint-daub.family-muted { opacity: .13; filter: grayscale(.65); }
.paint-daub.family-chain::before {
  box-shadow: inset 9px 11px 16px rgba(255,255,255,.17), inset -9px -8px 14px rgba(0,0,0,.13),
    0 0 0 3px rgba(255,253,247,.72), 0 0 0 5px rgba(168,79,49,.55), 0 8px 12px rgba(47,35,22,.16);
}
.paint-daub.family-source::before {
  box-shadow: inset 9px 11px 16px rgba(255,255,255,.17), inset -9px -8px 14px rgba(0,0,0,.13),
    0 0 0 3px rgba(255,253,247,.75), 0 0 0 5px rgba(70,99,82,.62), 0 8px 12px rgba(47,35,22,.16);
}
.tube-row { min-height: 76px; }
.tube-identity { color: #40594b !important; font-weight: 700; }

@media (max-width: 820px) {
  .palette-heading-tools { width: 100%; justify-items: stretch; }
  .palette-family-focus { justify-content: space-between; }
  .family-focus-picker { min-width: 0; flex: 1; }
  .recipe-link-label { max-width: 105px; font-size: .43rem; }
}
@media (max-width: 520px) {
  .family-focus-toggle span { display: none; }
  .family-focus-picker { min-width: 0; }
  .recipe-link-label.base-input { display: none; }
}
