/* freedesign.studio · Paint desk.
   Chrome uses the studio tokens (Paper / Graphite). The document, checkerboard and paper
   keep their own colors because they are content. Every class is prefixed pt-. */

#view-paint:not([hidden]) {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 304px;
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  color: var(--ink);
  --pt-hit: 36px;
  --pt-check-a: #f7f5f1;
  --pt-check-b: #e6e2da;
  --pt-active-icon: var(--focus);
}
html.has-pen #view-paint { --pt-hit: 44px; }
@media (pointer: coarse) { #view-paint { --pt-hit: 44px; } }
html[data-theme="graphite"] #view-paint {
  --pt-check-a: #2a2c32;
  --pt-check-b: #222429;
}
#view-paint [hidden] { display: none !important; }
.pt-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- tool rail ---------- */
.pt-rail {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  min-height: 0;
  overflow: auto;
  padding: 10px 8px 12px;
  border-right: 1px solid var(--line);
  scrollbar-width: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.pt-rail::-webkit-scrollbar { width: 0; height: 0; }
.pt-tools, .pt-rail-foot { display: flex; flex-direction: column; gap: 2px; }
.pt-tool {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  width: 100%;
  min-height: 46px;
  padding: 5px 4px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.1;
  letter-spacing: 0.01em;
}
.pt-tool .ico { width: 22px; height: 22px; }
.pt-tool:hover { background: var(--hover); color: var(--ink); }
.pt-tool[aria-pressed="true"] {
  background: var(--raised);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}
.pt-tool[aria-pressed="true"] .ico { color: var(--pt-active-icon); }
.pt-tool:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.pt-rail-sep { display: block; height: 1px; margin: 6px 12px; background: var(--line); }

/* ---------- stage and document ---------- */
.pt-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--well);
}
.pt-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  outline: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.pt-viewport:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.pt-viewport.is-brush { cursor: none; }
.pt-viewport.is-cross, .pt-viewport.is-picking { cursor: crosshair; }
.pt-viewport.is-space { cursor: grab; }
.pt-viewport.is-panning { cursor: grabbing; }
.pt-doc {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
  background: transparent;
  box-shadow:
    0 0 0 calc(1px / var(--z, 1)) rgba(23, 24, 29, 0.1),
    0 calc(20px / var(--z, 1)) calc(56px / var(--z, 1)) rgba(30, 24, 16, 0.2);
}
html[data-theme="graphite"] .pt-doc {
  box-shadow:
    0 0 0 calc(1px / var(--z, 1)) rgba(255, 255, 255, 0.07),
    0 calc(22px / var(--z, 1)) calc(64px / var(--z, 1)) rgba(0, 0, 0, 0.55);
}
.pt-checker, .pt-stack, .pt-paper, .pt-stack canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pt-checker {
  background:
    repeating-conic-gradient(var(--pt-check-b) 0 25%, var(--pt-check-a) 0 50%)
    0 0 / calc(20px / var(--z, 1)) calc(20px / var(--z, 1));
}
.pt-stack { isolation: isolate; }
.pt-paper { background: #f6f3ed; }
.pt-doc.is-pixel canvas { image-rendering: pixelated; }
.pt-axis {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0;
  border-left: calc(1.5px / var(--z, 1)) dashed rgba(25, 211, 238, 0.95);
  pointer-events: none;
}
.pt-cursor {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.92);
  will-change: transform;
}
.pt-cursor i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 3px;
  margin: -1.5px 0 0 -1.5px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
}
.pt-cursor.is-tiny { box-shadow: none; }
.pt-cursor.is-tiny i { width: 5px; height: 5px; margin: -2.5px 0 0 -2.5px; }
.pt-viewport.is-space .pt-cursor,
.pt-viewport.is-panning .pt-cursor,
.pt-viewport.is-picking .pt-cursor { display: none; }

.pt-drop {
  position: absolute;
  inset: 14px;
  display: grid;
  place-items: center;
  border: 2px dashed var(--focus);
  border-radius: 22px;
  background: color-mix(in srgb, var(--paper) 55%, transparent);
  pointer-events: none;
}
.pt-drop p {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--glass-bg);
  box-shadow: var(--shadow-2);
  font-size: 13px;
}
.pt-drop .ico { width: 18px; height: 18px; }

/* floating glass islands */
.pt-float {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: var(--glass-bg);
  box-shadow: var(--shadow-2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  backdrop-filter: blur(18px) saturate(1.2);
  color: var(--ink);
}
.pt-dock { left: 14px; bottom: 14px; }
.pt-float button {
  display: grid;
  place-items: center;
  min-width: var(--pt-hit);
  height: var(--pt-hit);
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.pt-float button:hover:not(:disabled) { background: var(--hover); }
.pt-float button:disabled { opacity: 0.36; }
.pt-float button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.pt-float .ico { width: 18px; height: 18px; }
.pt-zoom-pct { min-width: 56px !important; font-family: var(--font-num); letter-spacing: 0.02em; }
.pt-float-sep { width: 1px; height: 20px; margin: 0 4px; background: var(--line-strong); }
.pt-chip {
  right: 14px;
  bottom: 14px;
  gap: 8px;
  height: calc(var(--pt-hit) + 10px);
  padding: 0 14px;
  font-size: 12px;
  color: var(--muted);
  pointer-events: none;
}
.pt-chip .ico { width: 16px; height: 16px; color: var(--pt-active-icon); }

/* ---------- side panel ---------- */
.pt-panel {
  min-height: 0;
  overflow: auto;
  padding: 14px 14px 28px;
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-wash), transparent 160px);
}
.pt-sec + .pt-sec { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.pt-sec-head { display: flex; align-items: center; gap: 8px; min-height: 30px; margin: 0 0 10px; }
.pt-sec-title {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.pt-sec-meta { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pt-mini { font-size: 12px; color: var(--muted); }
.pt-note { margin: 0; font-size: 12px; line-height: 1.5; color: var(--muted); }

/* color */
.pt-color { display: flex; align-items: center; gap: 12px; }
.pt-well {
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  cursor: pointer;
}
.pt-well input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}
.pt-well-chip {
  position: absolute;
  inset: 5px;
  border-radius: 9px;
  background: var(--pt-color, #17181d);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  pointer-events: none;
}
.pt-well:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.pt-color-text { display: grid; gap: 2px; }
.pt-hex { font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.02em; }
.pt-color-name { font-size: 12px; color: var(--muted); }
.pt-swatches { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
.pt-recents-row { display: grid; gap: 6px; margin-top: 12px; }
.pt-recents-row .pt-swatches { margin-top: 0; }
.pt-swatch {
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--sw);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.16);
}
html[data-theme="graphite"] .pt-swatch { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3); }
html[data-theme="graphite"] .pt-well-chip { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.26); }
.pt-swatch:hover { transform: scale(1.08); }
.pt-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--focus); }
.pt-swatch:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* sliders, toggles, segments */
.pt-controls { display: grid; gap: 12px; margin-top: 16px; }
.pt-slider { display: grid; gap: 4px; font-size: 12px; }
.pt-slider-top { display: flex; justify-content: space-between; gap: 12px; color: var(--ink); }
.pt-slider output { color: var(--muted); font-variant-numeric: tabular-nums; }
.pt-slider input[type="range"] { height: 22px; margin: 0; background: transparent; }
#view-paint input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent) var(--pct, 50%), var(--track) var(--pct, 50%));
}
#view-paint input[type="range"]::-moz-range-track { height: 3px; border-radius: 99px; background: var(--track); }
#view-paint input[type="range"]::-moz-range-progress { height: 3px; border-radius: 99px; background: var(--accent); }
#view-paint input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 1px solid rgba(23, 24, 29, 0.18);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
}
#view-paint input[type="range"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
.pt-toggles { display: grid; gap: 6px; }
.pt-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  font-size: 12px;
  cursor: pointer;
}
.pt-toggle input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.pt-toggle-track {
  position: relative;
  flex: 0 0 auto;
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: var(--track);
  transition: background-color 160ms ease;
}
.pt-toggle-track::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 160ms ease;
}
.pt-toggle input:checked + .pt-toggle-track { background: var(--focus); }
.pt-toggle input:checked + .pt-toggle-track::after { transform: translateX(14px); }
.pt-toggle input:focus-visible + .pt-toggle-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.pt-stackline { display: grid; gap: 6px; }
.pt-seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--chip);
  box-shadow: inset 0 0 0 1px var(--line);
}
.pt-seg button {
  min-height: calc(var(--pt-hit) - 6px);
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.pt-seg button:hover { color: var(--ink); }
.pt-seg button[aria-checked="true"] { background: var(--raised); color: var(--ink); box-shadow: var(--shadow-1); }
.pt-seg button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* layers */
.pt-icon-btn {
  display: grid;
  place-items: center;
  width: var(--pt-hit);
  height: var(--pt-hit);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--chip);
  color: var(--ink);
}
.pt-icon-btn:hover:not(:disabled) { background: var(--raised); box-shadow: var(--shadow-1); }
.pt-icon-btn:disabled { opacity: 0.36; }
.pt-icon-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.pt-icon-btn .ico { width: 18px; height: 18px; }
.pt-sec-head .pt-icon-btn { margin-left: 4px; }
.pt-layer-list {
  display: grid;
  gap: 4px;
  max-height: 312px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}
.pt-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid transparent;
  border-radius: 14px;
}
.pt-row.is-active { background: var(--raised); border-color: var(--line); box-shadow: var(--shadow-1); }
.pt-eye {
  display: grid;
  place-items: center;
  width: var(--pt-hit);
  height: var(--pt-hit);
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
}
.pt-eye:hover { background: var(--hover); color: var(--ink); }
.pt-eye[aria-pressed="false"] { color: var(--muted); opacity: 0.7; }
.pt-eye .ico { width: 18px; height: 18px; }
.pt-eye:focus-visible, .pt-pick:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.pt-pick {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: max(40px, var(--pt-hit));
  padding: 3px 8px 3px 3px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}
.pt-row:not(.is-active) .pt-pick:hover { background: var(--hover); }
.pt-row.is-hidden .pt-pick { opacity: 0.55; }
.pt-thumb-slot {
  display: grid;
  place-items: center;
  width: 52px;
  height: 34px;
  border-radius: 7px;
  overflow: hidden;
  background:
    repeating-conic-gradient(var(--pt-check-b) 0 25%, var(--pt-check-a) 0 50%) 0 0 / 8px 8px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.pt-thumb { display: block; }
.pt-row-text { display: grid; min-width: 0; }
.pt-name { overflow: hidden; font-size: 13px; font-weight: 560; text-overflow: ellipsis; white-space: nowrap; }
.pt-row-meta { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pt-rename {
  width: 100%;
  min-height: 34px;
  padding: 4px 10px;
  border: 1px solid var(--focus);
  border-radius: 10px;
  background: var(--field);
  color: var(--ink);
  font-size: 13px;
}
.pt-layer-tune { display: grid; gap: 10px; margin-top: 12px; }
.pt-field { display: grid; gap: 4px; font-size: 12px; }
.pt-field > span { color: var(--ink); }
.pt-field select {
  width: 100%;
  min-height: var(--pt-hit);
  padding-top: 0;
  padding-bottom: 0;
  border-radius: 12px;
  background-color: var(--field);
  color: var(--ink);
  font-size: 13px;
}
.pt-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }
.pt-actions .pt-clear { margin-left: auto; min-height: var(--pt-hit); font-size: 12px; }

/* canvas section */
.pt-sec .pt-stackline + .pt-new, .pt-new + .pt-confirm, .pt-confirm + .pt-file, .pt-new + .pt-file, .pt-file + .pt-stackline { margin-top: 12px; }
.pt-new { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.pt-new .btn { min-height: var(--pt-hit); font-size: 12px; white-space: nowrap; }
.pt-confirm {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--raised);
  box-shadow: var(--shadow-1);
  font-size: 13px;
  line-height: 1.45;
}
.pt-confirm p { margin: 0; }
.pt-confirm-row { display: flex; gap: 8px; margin-top: 10px; }
.pt-confirm .btn { min-height: var(--pt-hit); font-size: 12px; }
.pt-file { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.pt-file .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--pt-hit);
  padding: 0 6px;
  font-size: 12px;
  white-space: nowrap;
}
.pt-file .ico { width: 16px; height: 16px; flex: 0 0 auto; }
.pt-status { display: flex; align-items: center; gap: 8px; margin: 18px 0 0; font-size: 12px; color: var(--muted); }
.pt-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--focus); }
.pt-status.is-warn .pt-status-dot { background: #e4572e; }

@media (prefers-reduced-motion: no-preference) {
  .pt-tool, .pt-swatch, .pt-icon-btn, .pt-seg button { transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease; }
}
html.motion-off .pt-tool, html.motion-off .pt-swatch, html.motion-off .pt-icon-btn, html.motion-off .pt-seg button { transition: none; }

/* bigger targets for pen and touch */
html.has-pen .pt-swatches { grid-template-columns: repeat(5, 44px); justify-content: space-between; gap: 8px; }
@media (pointer: coarse) { .pt-swatches { grid-template-columns: repeat(5, 44px); justify-content: space-between; gap: 8px; } }

/* ---------- narrower and shorter screens ---------- */
@media (max-width: 1280px) {
  #view-paint:not([hidden]) { grid-template-columns: 80px minmax(0, 1fr) 284px; }
}
/* short laptop screens: the rail keeps every tool visible by dropping its captions */
@media (min-width: 1101px) and (max-height: 800px) {
  .pt-rail .pt-tool > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .pt-tool { min-height: 44px; }
  .pt-rail-sep { margin: 4px 12px; }
}
@media (max-width: 1100px) {
  #view-paint:not([hidden]) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto clamp(340px, 60dvh, 760px) auto;
    height: auto;
    min-height: 0;
  }
  .pt-rail {
    flex-direction: row;
    gap: 6px;
    padding: 6px 8px;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .pt-tools, .pt-rail-foot { flex-direction: row; }
  .pt-tool { flex: 0 0 auto; width: 58px; }
  .pt-rail-sep { width: 1px; height: auto; margin: 8px 4px; }
  .pt-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
    gap: 20px 28px;
    overflow: visible;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .pt-sec + .pt-sec { margin-top: 0; padding-top: 0; border-top: 0; }
  .pt-status { grid-column: 1 / -1; margin-top: 0; }
  .pt-layer-list { max-height: 260px; }
}
@media (max-width: 860px) {
  .pt-rail .pt-tool > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .pt-tool { width: 46px; min-height: 46px; }
}
@media (max-width: 720px) {
  #view-paint:not([hidden]) { grid-template-rows: auto clamp(320px, 58dvh, 640px) auto; }
  .pt-chip { display: none; }
  .pt-dock { left: 10px; right: 10px; bottom: 10px; justify-content: space-between; overflow-x: auto; }
}
