.whiteboard-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  padding: 16px;
  background: rgba(255, 251, 244, 0.94);
  border: 1px solid rgba(102, 82, 56, 0.18);
  border-radius: 18px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.32);
}

.whiteboard-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(248px, 26vw, 320px);
  gap: 16px;
  flex: 1 1 auto;
  min-height: 0;
}

.whiteboard-stage-shell {
  display: grid;
  place-items: center;
  min-height: 0;
}

.whiteboard-sidebar {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
}

.panel-head__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-head__actions button,
.icon-button {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 12px;
}

#clear-canvas {
  color: var(--warn);
  border-color: rgba(211, 102, 80, 0.28);
}

.whiteboard-toolbar {
  display: grid;
  gap: 10px;
  flex: 0 0 auto;
  min-height: 0;
}

.panel-head__actions .whiteboard-tools-toggle {
  display: none;
  width: auto;
  min-width: 0;
  padding: 0 14px;
}

.panel-head__actions button.whiteboard-tools-toggle.is-active,
.panel-head__actions button.whiteboard-tools-toggle.is-active:hover:not(:disabled) {
  background: var(--green);
  color: #fffdf8;
  border-color: rgba(78, 120, 89, 0.64);
}

.tool-select-shell--hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.whiteboard-toolbar__actions button {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 12px;
}

.whiteboard-primary-controls {
  display: grid;
  gap: 10px;
}

.whiteboard-primary-controls__top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.whiteboard-quick-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.whiteboard-quick-actions button {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 12px;
}

.palette-shell {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(237, 228, 214, 0.82);
  border: 1px solid rgba(102, 82, 56, 0.12);
}

.whiteboard-toolbar__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.whiteboard-toolbar__swatches {
  display: grid;
  gap: 8px;
}

.whiteboard-toolbar__label {
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tool-button-rail {
  display: flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  padding: 4px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.6);
}

.tool-button {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text-soft);
}

.tool-button:hover:not(:disabled) {
  background: rgba(92, 138, 103, 0.09);
}

.tool-button.is-active {
  background: var(--green);
  border-color: rgba(78, 120, 89, 0.64);
  color: #fffdf8;
}

.palette {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0;
}

.palette--menu {
  gap: 8px;
}

.color-picker-shell {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 172px;
  min-height: 52px;
  padding: 10px 12px;
  border: 1px solid rgba(102, 82, 56, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.76);
  overflow: hidden;
}

.color-picker-shell input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.color-preview {
  width: 30px;
  min-width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid rgba(47, 38, 29, 0.12);
  background: #7a4026;
}

.color-picker-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.color-picker-copy strong {
  font-size: 12px;
  line-height: 1;
}

.color-picker-copy span {
  font-size: 11px;
  color: var(--text-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.swatch {
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  background: var(--swatch-color);
  box-shadow: 0 0 0 1px rgba(47, 38, 29, 0.08);
}

.swatch.active {
  box-shadow:
    0 0 0 2px rgba(47, 38, 29, 0.9),
    0 0 0 5px rgba(255, 255, 255, 0.62);
}

.palette-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tool-item {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid rgba(102, 82, 56, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.tool-item.is-disabled,
.whiteboard-toolbar__swatches.is-disabled,
.color-picker-shell.is-disabled {
  opacity: 0.62;
}

.tool-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text-soft);
}

.tool-label-row label {
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tool-label-row output {
  color: var(--text);
  font-weight: 700;
}

.slider-shell {
  padding: 2px 0 0;
}

.canvas-stage {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: none;
  aspect-ratio: 1;
  align-self: stretch;
  min-height: 0;
  border: 1px solid rgba(102, 82, 56, 0.18);
  border-radius: 16px;
  background: var(--canvas-paper);
  overflow: hidden;
  touch-action: none;
}

.canvas-stage .canvas-container,
.canvas-stage canvas,
.stroke-preview-layer {
  position: absolute !important;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

.canvas-stage .canvas-container,
.canvas-stage .lower-canvas,
.canvas-stage .upper-canvas {
  z-index: 1;
}

.stroke-preview-layer {
  pointer-events: none;
  z-index: 2;
}

#stroke-preview-path {
  fill: transparent;
}

.brush-preview {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  border: 1.5px solid rgba(92, 138, 103, 0.68);
  border-radius: 999px;
  background: var(--preview-fill, rgba(92, 138, 103, 0.1));
  pointer-events: none;
  opacity: 1;
  z-index: 3;
}

.brush-preview.is-hidden {
  opacity: 0;
}

.brush-preview--eraser {
  background: rgba(255, 255, 255, 0.2);
}
