html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f7f7f7;
  display: flex;
  flex-direction: column;
  color: #222;
}

#toolbar {
  padding: 8px 10px;
  background: linear-gradient(#ffffff, #f2f2f2);
  border-bottom: 1px solid #cfcfcf;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 0 0 auto;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  font-weight: 700;
  font-size: 15px;
  color: #222;
  white-space: nowrap;
}

.brand-logo {
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
}

.brand-logo path {
  fill: #d5c3a6;
  stroke: #222222;
  stroke-width: 1.15;
  vector-effect: non-scaling-stroke;
}

.toolbar-section {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  background: #ffffff;
  border: 1px solid #dddddd;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  box-sizing: border-box;
  flex: 0 0 auto;
}

/* Keep every toolbar group self-contained; no final control should protrude past its rounded panel. */
#toolbar .toolbar-section {
  box-sizing: border-box !important;
  flex: 0 0 auto !important;
  width: max-content !important;
  max-width: 100% !important;
  padding-left: 6px !important;
  padding-right: 6px !important;
  overflow: visible !important;
}

#toolbar .toolbar-section > :not(.style-popover) {
  flex: 0 0 auto;
  box-sizing: border-box;
}

.scale-tool-button {
  font-weight: 700;
  justify-content: center;
}

.scale-tool-button { padding: 5px !important; }
.reset-scale-glyph { font-size: 11px; font-weight: 700; }

.scale-expand-icon {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: #25313c;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.scale-toolbar-control {
  gap: 5px;
  min-height: 34px;
  height: 34px;
  padding: 0 3px;
}

.scale-slider-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 92px;
  height: 20px;
}

.scale-slider-wrap input[type="range"] {
  width: 92px;
  height: 20px;
  margin: 0;
  position: relative;
  z-index: 2;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
}

.scale-slider-wrap input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border: 1px solid #aeb8c2;
  border-radius: 999px;
  background: #dfe4e8;
}

.scale-slider-wrap input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border: 2px solid #667482;
  border-radius: 50%;
  background: #ffffff;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
}

.scale-slider-wrap input[type="range"]::-moz-range-track {
  height: 5px;
  border: 1px solid #aeb8c2;
  border-radius: 999px;
  background: #dfe4e8;
  box-sizing: border-box;
}

.scale-slider-wrap input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 2px solid #667482;
  border-radius: 50%;
  background: #ffffff;
  box-sizing: border-box;
}

.scale-one-marker {
  position: absolute;
  left: calc(23.08% + 3.77px);
  top: calc(50% + 1px);
  z-index: 1;
  width: 26px;
  height: 26px;
  box-sizing: border-box;
  border-radius: 50%;
  background: transparent;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.scale-one-marker::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  box-sizing: border-box;
  border: 2px solid #aeb8c2;
  border-radius: 50%;
  background: #dfe4e8;
  transform: translate(-50%, -50%);
}

.scale-toolbar-control.scale-at-one .scale-one-marker,
.menu-scale-control.scale-at-one .scale-one-marker {
  opacity: 0;
}

.scale-toolbar-control.scale-at-one .scale-slider-wrap input[type="range"]::-webkit-slider-thumb,
.menu-scale-control.scale-at-one .scale-slider-wrap input[type="range"]::-webkit-slider-thumb {
  background: #0877d1;
  border-color: #0877d1;
}

.scale-toolbar-control.scale-at-one .scale-slider-wrap input[type="range"]::-moz-range-thumb,
.menu-scale-control.scale-at-one .scale-slider-wrap input[type="range"]::-moz-range-thumb {
  background: #0877d1;
  border-color: #0877d1;
}

#toolbar .scale-factor-input {
  width: 54px;
  min-width: 54px;
  text-align: center;
  padding-left: 4px;
  padding-right: 4px;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 2px;
  white-space: nowrap;
}

button {
  border: 1px solid #cfcfcf;
  background: #f9f9f9;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  color: #222;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.05s ease;
}

button:hover:not(:disabled) {
  background: #eef5ff;
  border-color: #8db9e8;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.icon-button {
  min-width: 32px;
  justify-content: center;
  padding: 5px 7px;
}

.degree-input {
  width: 58px;
  box-sizing: border-box;
  min-height: 30px;
  border: 1px solid #cfcfcf;
  border-radius: 8px;
  padding: 4px 6px;
  font-size: 13px;
}

.danger-button:hover:not(:disabled) {
  background: #fff0f0;
  border-color: #d98b8b;
}

.reflect-button {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 4px 7px;
  gap: 5px;
}

.reflect-icon {
  width: 38px;
  height: 25px;
  flex: 0 0 auto;
}

.reflect-icon .mirror-line {
  stroke: #00856f;
  stroke-width: 3;
  stroke-dasharray: 5 4;
  fill: none;
}

.reflect-icon .mirror-object {
  fill: #ffffff;
  stroke: #111111;
  stroke-width: 2;
}

.reflect-icon .mirror-arrow,
.reflect-icon .mirror-arrow-head {
  stroke: #111111;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

label.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 4px 7px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

label.toggle:hover {
  background: #f5f5f5;
}

#helpText {
  color: #666;
  font-size: 12px;
  white-space: nowrap;
}

#layoutPanel {
  display: none;
  padding: 8px 10px;
  background: #ffffff;
  border-bottom: 1px solid #ccc;
  flex: 0 0 auto;
}

#layoutText {
  width: 100%;
  height: 110px;
  box-sizing: border-box;
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
  resize: vertical;
}

#appShell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  background: #ffffff;
  overflow: hidden;
}

#tileTray {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 218px;
  flex: 0 0 auto;
  background: linear-gradient(#ffffff, #f6f6f6);
  border-right: 1px solid #d0d0d0;
  box-shadow: 1px 0 4px rgba(0,0,0,0.07);
  transition: width 0.16s ease;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
  height: 100%;
  overscroll-behavior: contain;
  z-index: 3;
}

.tray-header {
  height: 43px;
  box-sizing: border-box;
  padding: 7px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid #dddddd;
  background: linear-gradient(#ffffff, #f6f6f6);
  position: sticky;
  top: 0;
  z-index: 2;
}

.tray-title {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}

.tray-toggle {
  flex: 0 0 auto;
}

.collapsed-tray-label {
  display: none;
}

.tray-content {
  padding: 10px 9px 24px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex: 0 0 auto;
  min-height: auto;
  overflow: visible;
}

.palette-tile {
  width: 100%;
  justify-content: flex-start;
  gap: 10px;
  min-height: 48px;
  padding: 7px 9px;
  background: #ffffff;
  border-radius: 12px;
  text-align: left;
}

.palette-tile:hover {
  background: #f4f9ff;
}

.palette-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.1;
}

.palette-text strong {
  font-size: 13px;
}

.palette-text small {
  font-size: 11px;
  color: #777;
}

.shape-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 2px solid rgba(0,0,0,0.55);
  box-sizing: border-box;
}

.triangle {
  clip-path: polygon(50% 5%, 96% 92%, 4% 92%);
}

.square {
  clip-path: polygon(8% 8%, 92% 8%, 92% 92%, 8% 92%);
}

.pentagon {
  clip-path: polygon(50% 4%, 96% 38%, 79% 94%, 21% 94%, 4% 38%);
}

.hex {
  clip-path: polygon(25% 5%, 75% 5%, 98% 50%, 75% 95%, 25% 95%, 2% 50%);
}

.heptagon {
  clip-path: polygon(50% 3%, 88% 20%, 99% 60%, 72% 96%, 28% 96%, 1% 60%, 12% 20%);
}

.octagon {
  clip-path: polygon(30% 3%, 70% 3%, 97% 30%, 97% 70%, 70% 97%, 30% 97%, 3% 70%, 3% 30%);
}

.h2a {
  background: #f4c542;
}

.h5 {
  background: #8ecae6;
}

.tri {
  background: #f08080;
}

.square-color {
  background: #90be6d;
}

.pent {
  background: #b388eb;
}

.hex-color {
  background: #ffb703;
}

.hept {
  background: #48cae4;
}

.oct {
  background: #f8961e;
}

#appShell.tray-collapsed #tileTray {
  position: relative;
  display: flex;
  flex-direction: column;
  display: flex;
  flex-direction: column;
  width: 48px;
}

#appShell.tray-collapsed .tray-title,
#appShell.tray-collapsed .tray-content {
  display: none;
}

#appShell.tray-collapsed .tray-header {
  justify-content: center;
  padding-left: 6px;
  padding-right: 6px;
}

#appShell.tray-collapsed #toggleTray {
  transform: rotate(180deg);
}

#appShell.tray-collapsed .collapsed-tray-label {
  display: block;
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%) rotate(180deg);
  writing-mode: vertical-rl;
  font-size: 13px;
  font-weight: 700;
  color: #666;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  user-select: none;
}

#workspace {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  position: relative;
}

#statusBar {
  flex: 0 0 auto;
  min-height: 30px;
  box-sizing: border-box;
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  background: linear-gradient(#ffffff, #f2f2f2);
  border-top: 1px solid #cfcfcf;
  box-shadow: 0 -1px 4px rgba(0,0,0,0.08);
  color: #555;
  font-size: 12px;
  z-index: 5;
}

#copyrightNotice {
  flex: 0 0 218px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  padding: 6px 12px;
  white-space: nowrap;
  color: #444;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-divider {
  width: 1px;
  min-height: 30px;
  flex: 0 0 auto;
  background: #cfcfcf;
}

#status {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 6px 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#biteBumpTotals {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 6px 12px;
  white-space: nowrap;
  color: #333;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

body.tray-is-collapsed #copyrightNotice {
  flex-basis: 48px;
  justify-content: center;
  padding-left: 4px;
  padding-right: 4px;
}

svg {
  display: block;
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  min-height: 0;
  background: #ffffff;
  touch-action: none;
  cursor: default;
}

svg.panning {
  cursor: grabbing;
}

.tile {
  cursor: grab;
}

.tile:active {
  cursor: grabbing;
}

.tile polygon,
.tile path {
  stroke: #222;
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-miterlimit: 2;
}

.tile.selected polygon,
.tile.selected path {
  stroke: #0066cc;
  stroke-width: 6;
}

.snap-preview {
  pointer-events: none;
  opacity: 0.45;
  display: none;
}

.snap-preview polygon,
.snap-preview path {
  fill: #cccccc;
  stroke: #777777;
  stroke-width: 3;
  stroke-dasharray: 8 6;
}

.snap-preview text {
  fill: #555555;
}

.selection-box {
  display: none;
  fill: rgba(0, 102, 204, 0.10);
  stroke: #0066cc;
  stroke-width: 2;
  stroke-dasharray: 7 5;
  pointer-events: none;
}

.rotation-handle {
  display: none;
  cursor: grab;
}

.rotation-handle:active {
  cursor: grabbing;
}

.rotation-handle line {
  stroke: #0066cc;
  stroke-width: 3;
  stroke-dasharray: 5 5;
  pointer-events: none;
}

.rotation-handle circle {
  fill: #ffffff;
  stroke: #0066cc;
  stroke-width: 4;
}

text {
  font-size: 14px;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  font-weight: bold;
}

@media (max-width: 1200px) {
  #helpText {
    display: none;
  }
}

@media (max-width: 980px) {
  .section-label {
    display: none;
  }

  button {
    font-size: 12px;
    padding: 5px 7px;
  }

  #tileTray {
    width: 190px;
  }

  .degree-input {
    width: 50px;
  }
}


#importJsonFile {
  display: none;
}


.bubble-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.bubble-palette-tile {
  min-height: 66px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 7px 5px;
  text-align: center;
}

.bubble-palette-tile .palette-text {
  align-items: center;
}

.bubble-palette-tile .palette-text small {
  display: none;
}

.bubble-icon-slot {
  width: 42px;
  height: 42px;
  border: 0;
  clip-path: none;
  box-sizing: border-box;
}

.bubble-icon-svg {
  width: 42px;
  height: 42px;
  display: block;
  overflow: visible;
}

.bubble-icon-svg path {
  stroke: #222222;
  stroke-width: 1.15;
  vector-effect: non-scaling-stroke;
}


.tray-section {
  border: 1px solid #dddddd;
  border-radius: 12px;
  background: rgba(255,255,255,0.65);
  overflow: hidden;
}

.tray-section summary {
  cursor: pointer;
  user-select: none;
  padding: 8px 9px;
  font-size: 11px;
  font-weight: 700;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #e5e5e5;
}

.tray-section:not([open]) summary {
  border-bottom: none;
}

.tray-section .palette-tile {
  margin: 7px 7px 0;
  width: calc(100% - 14px);
}

.tray-section .palette-tile:last-child {
  margin-bottom: 7px;
}

.tray-section .bubble-grid {
  padding: 7px;
}


.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  z-index: 50;
}

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

.about-dialog {
  width: min(620px, 100%);
  max-height: min(80vh, 560px);
  overflow: auto;
  background: #ffffff;
  border: 1px solid #cfcfcf;
  border-radius: 16px;
  box-shadow: 0 16px 50px rgba(0,0,0,0.24);
}

.about-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #e5e5e5;
}

.about-header h2 {
  margin: 0;
  font-size: 18px;
}

.about-body {
  padding: 14px 16px 18px;
  line-height: 1.5;
  font-size: 14px;
}

.about-body p {
  margin: 0 0 12px;
}

.about-body p:last-child {
  margin-bottom: 0;
}

.about-body a {
  color: #0066cc;
  font-weight: 700;
}

.device-warning-dialog {
  width: min(480px, 100%);
}

.ngon-dialog {
  width: min(360px, 100%);
}

.ngon-input-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
}

#ngonSidesInput {
  box-sizing: border-box;
  width: 100%;
  min-height: 38px;
  padding: 6px 9px;
  border: 1px solid #aebdcb;
  border-radius: 8px;
  font: inherit;
}

.ngon-range-note {
  margin: 6px 0 14px;
  color: #596773;
  font-size: 12px;
}

.ngon-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.ngon-dialog-actions button {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid #aebdcb;
  border-radius: 8px;
  background: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

#confirmNgon {
  border-color: #1667a8;
  background: #1976bd;
  color: #ffffff;
}

.device-warning-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.device-warning-actions button {
  padding: 9px 14px;
  border: 1px solid #1667a8;
  border-radius: 9px;
  background: #1976bd;
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.device-warning-actions button:hover,
.device-warning-actions button:focus-visible {
  background: #125f99;
  outline: 2px solid #0d4f82;
  outline-offset: 2px;
}


.palette-tile {
  user-select: none;
}

.palette-tile.dragging-from-tray {
  opacity: 0.65;
}


#tileTray::-webkit-scrollbar {
  width: 10px;
}

#tileTray::-webkit-scrollbar-thumb {
  background: #bdbdbd;
  border-radius: 8px;
  border: 2px solid #f6f6f6;
}

#tileTray::-webkit-scrollbar-track {
  background: #f6f6f6;
}


.add-all-button {
  width: 100%;
  justify-content: center;
  margin: 6px 0 8px;
  background: #f4f9ff;
  border-color: #9fc3e8;
  font-weight: 700;
  font-size: 12px;
}

#trayDragGhost {
  display: none;
  position: fixed;
  width: 74px;
  height: 74px;
  pointer-events: none;
  z-index: 100;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.24));
}

#trayDragGhost svg {
  width: 74px;
  height: 74px;
  display: block;
  background: transparent;
}

#trayDragGhost path,
#trayDragGhost polygon {
  stroke: #222222;
  stroke-width: 4;
  fill-opacity: 0.9;
}

.palette-tile {
  user-select: none;
}

.palette-tile.dragging-from-tray {
  opacity: 0.65;
}


.tile.overlapping polygon,
.tile.overlapping path,
.tile.selected.overlapping polygon,
.tile.selected.overlapping path {
  stroke: #d00000;
  stroke-width: 7;
}

.tile.overlapping text {
  fill: #d00000;
}


body.space-pan-mode svg {
  cursor: grab;
}

body.space-pan-mode svg.panning {
  cursor: grabbing;
}

body.ctrl-pan-mode svg {
  cursor: grab;
}

body.ctrl-pan-mode svg.panning {
  cursor: grabbing;
}

.frame-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.frame-icon-slot {
  width: 52px;
  height: 38px;
  border: 0;
  clip-path: none;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.frame-icon-slot svg {
  width: 52px;
  height: 38px;
  display: block;
  background: transparent;
  overflow: visible;
}

.frame-icon-slot .bubble-icon-svg {
  width: 52px;
  height: 38px;
}


.bubble-icon-svg polygon {
  stroke: #222222;
  stroke-width: 1.15;
  vector-effect: non-scaling-stroke;
}


.frame-icon-slot .bubble-icon-svg path {
  fill: var(--tile-fill, #c7aa72);
  stroke: var(--tile-stroke, #6f5736);
  stroke-width: max(2.2px, var(--tile-stroke-width, 2.2));
  vector-effect: non-scaling-stroke;
  paint-order: stroke fill;
}


/* Aperiodic tile icons are polygon-based; keep them readable in the tray. */
.bubble-icon-svg polygon {
  stroke: #222222;
  stroke-width: 1.15;
  vector-effect: non-scaling-stroke;
}


.toolbar-menu {
  position: relative;
}

.toolbar-menu summary {
  list-style: none;
  cursor: pointer;
  min-height: 30px;
  box-sizing: border-box;
  padding: 5px 10px;
  border: 1px solid #cfcfcf;
  border-radius: 9px;
  background: linear-gradient(#ffffff, #f4f4f4);
  font-weight: 700;
  font-size: 13px;
  user-select: none;
}

.toolbar-menu summary::-webkit-details-marker {
  display: none;
}

.menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 210px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 7px;
  background: #ffffff;
  border: 1px solid #cfcfcf;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.18);
  z-index: 10010;
}

.toolbar-menu[open] .menu-panel {
  z-index: 10010;
}

.menu-panel button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  border-radius: 8px;
}

.toolbar-svg-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
}

.rotate-icon .rotate-arc,
.rotate-icon .rotate-head,
.flip-icon .flip-arrow,
.flip-icon .flip-head,
.group-icon .group-frame,
.group-icon .group-node,
.group-icon .group-small {
  stroke: #202529;
  stroke-width: 4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rotate-icon .rotate-head {
  fill: none;
}

.flip-icon {
  width: 34px;
}

.flip-icon .flip-mirror {
  stroke: #4b454b;
  stroke-width: 4;
  stroke-dasharray: 4 5;
  stroke-linecap: round;
}

.flip-icon .flip-shape {
  stroke: #202529;
  stroke-width: 3.5;
  stroke-linejoin: round;
}

.flip-icon .flip-shape.light {
  fill: #f7f5f2;
}

.flip-icon .flip-shape.dark {
  fill: #d8d8d8;
}

.flip-icon .flip-head {
  fill: #202529;
}

.flip-icon .flip-arrow {
  stroke-width: 3.5;
}

.group-icon {
  width: 24px;
}

.group-icon .group-frame {
  stroke-width: 4;
}

.group-icon .group-node {
  fill: #202529;
}

.group-icon .group-small {
  stroke-width: 4;
}


.lattice-layer {
  pointer-events: none;
}

.lattice-copy {
  pointer-events: none;
  opacity: 0.62;
}

.lattice-copy polygon,
.lattice-copy path {
  stroke: #222222;
  stroke-width: 3;
}

.lattice-preview {
  pointer-events: none;
}

.lattice-edit-overlay {
  pointer-events: none;
}

.lattice-preview-copy {
  pointer-events: none;
  opacity: 0.42;
}

.lattice-preview-copy polygon,
.lattice-preview-copy path {
  stroke: #0066cc;
  stroke-width: 4;
  stroke-dasharray: 9 7;
}

.lattice-preview-a {
  opacity: 0.26;
}

.lattice-preview-b {
  opacity: 0.46;
}

.lattice-vector-line {
  stroke: #0066cc;
  stroke-width: 4;
  stroke-dasharray: 10 8;
  marker-end: url(#latticeArrow);
  pointer-events: none;
}

.lattice-edit-icon .lattice-edit-vector {
  fill: none;
  stroke: #235b8f;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lattice-edit-icon .lattice-edit-vector.secondary {
  stroke: #4d8e42;
}

.lattice-edit-icon .lattice-edit-origin {
  fill: #263645;
}

.lattice-edit-icon .lattice-edit-endpoint {
  fill: #ffd54a;
  stroke: #263645;
  stroke-width: 1.8;
}

#latticeFill.is-active,
[data-command="latticeFill"].is-active {
  border-color: #1f75cb;
  background: #dceeff;
  box-shadow: 0 0 0 2px rgba(31, 117, 203, 0.2);
}

.lattice-edit-vector-line {
  fill: none;
  stroke-width: 4;
  stroke-dasharray: 10 7;
  pointer-events: none;
}

.lattice-edit-vector-line.vector-a {
  stroke: #176fc1;
}

.lattice-edit-vector-line.vector-b {
  stroke: #3d8a35;
}

.lattice-edit-handle {
  fill: #fff7b8;
  stroke-width: 4;
  cursor: grab;
  pointer-events: all;
}

.lattice-edit-handle.vector-a {
  stroke: #176fc1;
}

.lattice-edit-handle.vector-b {
  stroke: #3d8a35;
}

.lattice-edit-handle:hover {
  fill: #ffd54a;
  stroke-width: 5;
}

.lattice-edit-handle:active {
  cursor: grabbing;
}

.lattice-edit-origin-marker {
  fill: #263645;
  stroke: #fff;
  stroke-width: 2;
  pointer-events: none;
}

.lattice-edit-label {
  font-size: 16px;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 4px;
  stroke-linejoin: round;
  pointer-events: none;
}

.lattice-edit-label.vector-a {
  fill: #176fc1;
}

.lattice-edit-label.vector-b {
  fill: #3d8a35;
}


/* Polished toolbar additions */
.file-menu-wrap {
  display: flex;
  align-items: center;
  padding-right: 8px;
}

.file-menu-wrap .toolbar-menu summary {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 6px 4px;
  border-radius: 6px;
}

.file-menu-wrap .toolbar-menu summary:hover {
  background: #f0f0f0;
}

.rotate-symbol-button {
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
  min-width: 34px;
}

.reflect-button span {
  display: none;
}

.color-control {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #444;
}

.color-control input[type="color"] {
  width: 28px;
  height: 24px;
  padding: 0;
  border: 1px solid #bfbfbf;
  border-radius: 5px;
  background: #ffffff;
}

.lattice-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(760px, calc(100% - 40px));
  box-sizing: border-box;
  padding: 9px 38px 9px 14px;
  background: #fff3b0;
  border: 1px solid #d7b84f;
  border-radius: 12px;
  box-shadow: 0 5px 18px rgba(0,0,0,0.14);
  color: #3f3300;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 600;
  z-index: 8;
  pointer-events: auto;
}

.lattice-hint-content a {
  color: #715600;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.lattice-hint-close {
  position: absolute;
  top: 5px;
  right: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 25px;
  padding: 0;
  border: 1px solid rgba(95, 74, 0, 0.4);
  border-radius: 7px;
  background: #fff3b0;
  color: #3f3300;
  font: 800 19px/1 Arial, sans-serif;
  cursor: pointer;
}

.lattice-hint-close:hover,
.lattice-hint-close:focus-visible {
  background: #ffe98a;
  outline: 2px solid #715600;
  outline-offset: 1px;
}

.lattice-hint[hidden] {
  display: none;
}

.copy-confirmation-toast {
  position: fixed;
  left: 50%;
  bottom: 44px;
  z-index: 3000;
  transform: translate(-50%, 8px);
  padding: 9px 14px;
  border: 1px solid #b68c17;
  border-radius: 9px;
  background: #fff3b0;
  box-shadow: 0 5px 18px rgba(0,0,0,0.18);
  color: #3f3300;
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.copy-confirmation-toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.copy-confirmation-toast[hidden] {
  display: none;
}


/* Additional icon/menu polish */
.file-menu-wrap .toolbar-menu summary {
  border: 1px solid #cfcfcf;
  background: linear-gradient(#ffffff, #f4f4f4);
  box-shadow: none;
  padding: 6px 10px;
  border-radius: 9px;
}

.clipboard-icon .clipboard-back {
  fill: #dce9ff;
  stroke: #335f9e;
  stroke-width: 3;
}

.clipboard-icon .clipboard-front {
  fill: #ffffff;
  stroke: #202529;
  stroke-width: 3;
}

.clipboard-icon .clipboard-clip {
  fill: #ffd166;
  stroke: #202529;
  stroke-width: 3;
}

.clipboard-icon .clipboard-mark {
  fill: none;
  stroke: #202529;
  stroke-width: 3;
  stroke-linecap: round;
}

.clear-lattice-button {
  position: relative;
  min-width: 36px;
}

.lattice-mini {
  font-size: 22px;
  line-height: 1;
}

.lattice-x {
  position: absolute;
  right: 3px;
  top: 1px;
  color: #d00000;
  font-weight: 900;
  font-size: 18px;
  line-height: 1;
}

.penrose-decoration {
  fill: none;
  stroke: #ffffff;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.lattice-copy .penrose-decoration {
  stroke-width: 3.2;
}

.bubble-icon-svg .penrose-decoration {
  stroke-width: 6;
}

.bubble-icon-svg.penrose-thumbnail-svg polygon {
  stroke-width: 0.85;
  stroke-linejoin: round;
}

.bubble-icon-svg.penrose-thumbnail-svg .penrose-decoration {
  stroke-width: 3.2;
  stroke-linecap: butt;
}

.help-dialog {
  width: min(760px, 100%);
}

.help-body h3 {
  margin: 14px 0 6px;
  font-size: 15px;
}

.help-body h3:first-child {
  margin-top: 0;
}


.export-dialog { width: min(860px, 100%); }
.export-body { padding: 14px 16px 18px; }
.export-instructions { margin: 0 0 10px; font-size: 13px; color: #444; }
.export-preview-wrap { height: min(58vh, 520px); border: 1px solid #cccccc; border-radius: 12px; overflow: hidden; background: #ffffff; }
#exportAreaPreview { width: 100%; height: 100%; display: block; cursor: crosshair; }
.export-area-rect { fill: rgba(255,245,120,0.18); stroke: #0066cc; stroke-width: 4; stroke-dasharray: 12 8; pointer-events: none; }
.export-controls { margin-top: 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.export-controls label { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.export-controls select { min-height: 30px; border: 1px solid #bbbbbb; border-radius: 8px; padding: 3px 8px; background: #ffffff; }

.help-tool { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: start; padding: 7px 0; border-bottom: 1px solid #eeeeee; }
.help-tool:last-child { border-bottom: none; }
.help-icon { width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: #f4f7fb; border: 1px solid #d9e2ef; font-size: 17px; }

.export-picture-icon {
  fill: none;
  stroke: #244f7d;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.export-picture-icon .export-picture-sun {
  fill: #f5c84c;
  stroke: #244f7d;
}

.export-picture-icon .export-picture-arrow {
  stroke: #0875cf;
  stroke-width: 2.4;
}

.help-export-picture-icon {
  box-sizing: border-box;
  padding: 2px;
  flex: 0 0 28px;
}
.polyomino-tile path { shape-rendering: crispEdges; }


/* Consistent toolbar control sizing */
#toolbar button,
#toolbar .toolbar-menu summary,
#toolbar .degree-input,
#toolbar label.toggle {
  min-height: 34px;
  height: 34px;
  box-sizing: border-box;
  align-items: center;
}

#toolbar button {
  padding-top: 5px;
  padding-bottom: 5px;
}

#toolbar .toolbar-svg-icon {
  width: 24px;
  height: 24px;
}

#toolbar .flip-icon {
  width: 34px;
  height: 24px;
}

#toolbar input[type="color"] {
  width: 30px;
  height: 24px;
}

#toolbar .color-control {
  min-height: 34px;
  box-sizing: border-box;
  align-items: center;
}

.clear-lattice-button {
  min-width: auto;
}

.lattice-clear-icon {
  position: relative;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.lattice-clear-icon .lattice-mini {
  font-size: 22px;
  line-height: 1;
}

.lattice-clear-icon .lattice-x {
  position: absolute;
  right: -4px;
  top: -5px;
  color: #d00000;
  font-weight: 900;
  font-size: 17px;
  line-height: 1;
}


/* Compact dropdown toolbar pass */
#toolbar {
  gap: 7px;
}

#toolbar > .toolbar-section {
  border-right: none;
  padding-right: 0;
}

.toolbar-menu {
  position: relative;
  flex: 0 0 auto;
}

.toolbar-menu summary {
  min-height: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
}

.menu-panel {
  min-width: 220px;
  z-index: 60;
}

.menu-panel button,
.menu-panel .menu-toggle,
.menu-panel .menu-row {
  width: 100%;
  min-height: 34px;
  height: auto;
  box-sizing: border-box;
}

.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #444;
}

.button-row {
  justify-content: stretch;
}

.button-row button {
  flex: 1 1 0;
}

.style-panel .color-control {
  justify-content: space-between;
  min-height: 34px;
}

.quick-toggles {
  display: flex;
  gap: 6px;
}

.tray-family-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  margin: 2px 0 4px;
  border-radius: 11px;
  background: #edf4ff;
  border: 1px solid #c9ddf5;
  color: #1f3550;
}

.tray-family-heading strong {
  display: block;
  font-size: 12px;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.tray-family-heading small {
  display: block;
  font-size: 10px;
  color: #52677d;
  margin-top: 1px;
}

.family-heading-icon,
.summary-icon {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.family-heading-icon svg,
.summary-icon svg {
  width: 26px;
  height: 26px;
  display: block;
}

.tray-section summary {
  display: flex;
  align-items: center;
  gap: 7px;
}

.tray-section summary .summary-icon + span {
  line-height: 1.1;
}

.lattice-copy {
  opacity: 1;
}

body.lattice-highlight-source .lattice-copy {
  opacity: 0.62;
}

.export-dialog {
  width: min(880px, calc(100vw - 36px));
  max-height: calc(100vh - 48px);
  overflow: visible;
}

.export-body {
  padding: 10px 14px 14px;
}

.export-instructions {
  margin-bottom: 8px;
}

.export-preview-wrap {
  height: min(43vh, 390px);
}

.export-controls {
  margin-top: 9px;
}

#toolbar .degree-input {
  width: 68px;
}

.clear-lattice-button {
  display: flex;
  gap: 7px;
}

.bubble-icon-svg .penrose-decoration,
.penrose-decoration {
  stroke: #222222;
}

.polyomino-tile path {
  shape-rendering: crispEdges;
}


/* Tile tray family headers: plain, compact labels */
.tray-family-heading.tray-family-plain {
  display: block;
  padding: 8px 4px 3px;
  margin: 4px 0 2px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #4d5b66;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Keep set headers compact but still visibly expandable. */
.tray-section summary {
  min-height: 34px;
  padding-top: 5px;
  padding-bottom: 5px;
}

.summary-icon {
  width: 22px;
  height: 22px;
}

.summary-icon svg {
  width: 22px;
  height: 22px;
}

/* Menubar-style File/View/Edit controls. */
.menu-strip {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-right: 2px;
}

.toolbar-menu summary,
.file-menu-wrap .toolbar-menu summary {
  border: 0;
  background: transparent;
  box-shadow: none;
  min-height: 32px;
  height: 32px;
  padding: 6px 7px;
  border-radius: 6px;
}

.toolbar-menu summary:hover,
.file-menu-wrap .toolbar-menu summary:hover {
  background: #e9eef5;
}

/* Shared toolbar sizing */
#toolbar button,
#toolbar .degree-input,
#toolbar label.toggle,
#toolbar .color-control {
  min-height: 34px;
  height: 34px;
  box-sizing: border-box;
  align-items: center;
}

.toolbar-inline-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  height: 34px;
  font-size: 12px;
  color: #444;
}

.compact-degree-input {
  width: 54px;
}

/* Zoom icons with plus/minus inside the lens. */
.zoom-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: #202529;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Make selected tiles visible without hiding the user's chosen stroke color. */
.tile.selected polygon,
.tile.selected path {
  stroke-width: 5;
  filter: drop-shadow(0 0 2px #0066cc);
}

/* Overlap red still wins. */
.tile.overlapping polygon,
.tile.overlapping path,
.tile.selected.overlapping polygon,
.tile.selected.overlapping path {
  stroke: #d00000;
  stroke-width: 7;
  filter: none;
}

/* Export dialog compact proportion controls */
.export-controls {
  gap: 10px;
}

.export-controls select {
  max-width: 130px;
}


/* Clearer top shortcut guide */
.shortcut-help {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.shortcut-help span {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-left: 1px solid #d2d8e0;
  color: #42515f;
  line-height: 1.25;
}

.shortcut-help span:first-child {
  border-left: 0;
}

.shortcut-help strong {
  color: #111827;
  font-weight: 700;
}

/* Help menu organization */
.help-section-title {
  margin: 14px 0 6px;
  padding: 5px 8px;
  border-radius: 8px;
  background: #eef4fb;
  color: #35506a;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.help-section-title:first-child {
  margin-top: 0;
}

.help-tool {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid #eeeeee;
}

.help-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f4f7fb;
  border: 1px solid #d9e2ef;
  color: #202529;
  font-size: 17px;
  font-weight: 700;
}

.zoom-help-icon {
  font-size: 21px;
}


.help-body code {
  background: #eef4fb;
  border: 1px solid #d8e3ef;
  border-radius: 5px;
  padding: 1px 4px;
  font-family: Consolas, Monaco, monospace;
  font-size: 0.92em;
}


.range-control {
  min-height: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-sizing: border-box;
  font-size: 12px;
  color: #444;
  white-space: nowrap;
}

.range-control input[type="range"] {
  width: 88px;
  accent-color: #0066cc;
}

body {
  --lattice-copy-opacity: 0.62;
}

.lattice-copy {
  opacity: var(--lattice-copy-opacity, 0.62);
}

body:not(.lattice-highlight-source) .lattice-copy {
  opacity: 1;
}


/* Lattice copies are controlled only by the Opacity slider. */
.lattice-copy,
body.lattice-highlight-source .lattice-copy,
body:not(.lattice-highlight-source) .lattice-copy {
  opacity: var(--lattice-copy-opacity, 0.62);
}

body.guided-lattice-intro-fade .lattice-copy {
  transition: opacity 1.8s ease-in-out;
}


#arcDual {
  font-weight: 700;
}


.select-control {
  min-height: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-sizing: border-box;
  font-size: 12px;
  color: #444;
  white-space: nowrap;
}

.select-control select {
  height: 26px;
  border: 1px solid #bbbbbb;
  border-radius: 6px;
  background: #ffffff;
  font-size: 12px;
  padding: 2px 5px;
}

.stroke-width-input {
  width: 50px;
}

.lattice-hint {
  white-space: normal;
}


/* Stroke style fix: use per-tile CSS variables everywhere on the live canvas. */
.tile polygon,
.tile path,
.lattice-copy polygon,
.lattice-copy path {
  stroke: var(--tile-stroke, #222222);
  stroke-width: var(--tile-stroke-width, 3);
  stroke-dasharray: var(--tile-stroke-dasharray, none);
  stroke-linecap: var(--tile-stroke-linecap, butt);
}

.tile.selected polygon,
.tile.selected path {
  stroke: var(--tile-stroke, #222222);
  stroke-width: var(--tile-stroke-width, 3);
  stroke-dasharray: var(--tile-stroke-dasharray, none);
  stroke-linecap: var(--tile-stroke-linecap, butt);
  filter: drop-shadow(0 0 2.5px #0066cc) drop-shadow(0 0 1px #0066cc);
}

/* Overlap warning still overrides every ordinary stroke style, including
   tile-level stroke variables and selected-tile glow. */
.tile.overlapping polygon,
.tile.overlapping path,
.tile.selected.overlapping polygon,
.tile.selected.overlapping path {
  stroke: #d00000 !important;
  stroke-width: 7 !important;
  stroke-dasharray: none !important;
  stroke-linecap: butt !important;
  filter: none !important;
}


/* Tile tray tabs and examples */
.tray-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 8px 10px 4px;
  border-bottom: 1px solid #dde5ef;
  background: #f7f9fc;
}

.tray-tab {
  min-height: 32px;
  height: 32px;
  border: 1px solid #c9d6e4;
  border-radius: 9px;
  background: #ffffff;
  color: #3d5369;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.tray-tab.active {
  background: #dfefff;
  border-color: #8dbbe9;
  color: #123b61;
  box-shadow: inset 0 0 0 1px rgba(0,102,204,0.10);
}

.tray-panel[hidden] {
  display: none;
}

.examples-panel {
  padding-top: 6px;
}

.examples-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
}

.example-category {
  min-width: 0;
  border: 1px solid #d6e0eb;
  border-radius: 11px;
  background: #ffffff;
  overflow: hidden;
}

.example-category > summary {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 7px 9px;
  background: #f5f8fc;
  color: #29465f;
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  font-weight: 850;
}

.example-category > summary::-webkit-details-marker {
  display: none;
}

.example-category > summary::before {
  content: "▸";
  color: #497796;
  font-size: 13px;
  line-height: 1;
  transition: transform 0.15s ease;
}

.example-category[open] > summary::before {
  transform: rotate(90deg);
}

.example-category > summary:hover,
.example-category > summary:focus-visible {
  background: #eaf4ff;
  color: #173f62;
  outline: none;
}

.example-category-title {
  min-width: 0;
  flex: 1;
}

.example-category-count {
  min-width: 22px;
  padding: 2px 6px;
  border: 1px solid #cad8e7;
  border-radius: 999px;
  background: #ffffff;
  color: #536c82;
  font-size: 10px;
  line-height: 1.2;
  text-align: center;
}

.example-category-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
  padding: 7px;
  border-top: 1px solid #e1e8f0;
}

.example-card {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  width: 100%;
  height: auto;
  border: 1px solid #d6e0eb;
  border-radius: 12px;
  background: #ffffff;
  padding: 6px;
  box-shadow: 0 1px 4px rgba(20, 40, 60, 0.06);
  text-align: left;
  cursor: pointer;
}

.example-card:hover,
.example-card:focus-visible {
  border-color: #78aee0;
  background: #f7fbff;
  box-shadow: 0 2px 7px rgba(20, 70, 115, 0.14);
}

.example-card.paper-example-card {
  grid-template-columns: minmax(0, 1fr);
  min-height: 42px;
  padding: 9px 10px;
}

.paper-example-context-menu {
  width: max-content;
  min-width: 0;
}

.example-card-title {
  display: flex;
  gap: 7px;
  align-items: center;
  margin: 2px 1px;
  color: #1f2933;
  font-weight: 850;
  font-size: 12px;
  line-height: 1.2;
}

.example-card-title sub {
  font-size: 0.76em;
  line-height: 0;
  vertical-align: -0.32em;
}

.example-preview {
  display: block;
  width: 58px;
  height: 58px;
  border-radius: 7px;
  overflow: hidden;
  background: #fafafa;
}

.example-preview-tile {
  pointer-events: none;
}

.example-preview .example-preview-tile path,
.example-preview .example-preview-tile polygon,
.example-preview .example-preview-tile rect,
.example-preview .example-preview-tile circle,
.example-preview .example-preview-tile ellipse {
  stroke-width: 0.7px !important;
  filter: none !important;
}

.tray-section[data-tray-set="otherPolygons"] .bubble-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  padding: 6px 4px 7px;
}

.tray-section[data-tray-set="otherPolygons"] .bubble-grid .palette-tile {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 6px 2px;
}

.tray-section[data-tray-set="otherPolygons"] .palette-text strong {
  max-width: 100%;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.example-card-icon,
.example-card-description,
.example-card-meta {
  display: none;
}

.example-card-icon {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: #eef6ff;
  border: 1px solid #cde0f4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #154f83;
  font-weight: 900;
}

.example-card-description {
  margin: 0 0 7px;
  color: #4b5f72;
  font-size: 12px;
  line-height: 1.35;
}

.example-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.example-tag {
  padding: 2px 6px;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid #d9e2ec;
  color: #516477;
  font-size: 10px;
  font-weight: 700;
}

.example-card-actions {
  display: block;
}

.example-card-actions button {
  width: 100%;
  justify-content: center;
  min-height: 26px;
  height: 26px;
  font-size: 11px;
}


.locate-parents-button {
  font-weight: 700;
}

.tile.lattice-parent-flash {
  animation: latticeParentFlash 1.6s ease-in-out 1;
}

@keyframes latticeParentFlash {
  0%, 100% {
    filter: none;
  }
  18%, 58% {
    filter: drop-shadow(0 0 10px #ffd21f) drop-shadow(0 0 5px #ff8f00);
  }
}


/* Closed/collapsed tray cleanup */
#appShell.tray-collapsed .tray-tabs,
#appShell.tray-collapsed .tray-panel,
#appShell.tray-collapsed .examples-panel {
  display: none !important;
}

#appShell.tray-collapsed #tileTray {
  overflow: hidden;
}

.lattice-icon-button,
.layer-button {
  min-width: 34px;
  width: 34px;
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
  font-weight: 850;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: #d1d5db;
  margin: 0 2px;
}

.context-menu {
  position: fixed;
  z-index: 2000;
  width: 166px;
  min-width: 0;
  max-width: calc(100vw - 16px);
  box-sizing: border-box;
  padding: 6px;
  border: 1px solid #c8d2dc;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 14px 32px rgba(0,0,0,0.22);
}

.context-menu button {
  width: 100%;
  justify-content: flex-start;
  min-height: 31px;
  height: 31px;
  padding: 5px 9px;
  border: 0;
  border-radius: 8px;
  background: #ffffff;
  font-size: 13px;
  text-align: left;
  gap: 8px;
  white-space: nowrap;
}

.context-menu-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
}

.office-duplicate-plus {
  fill: none;
  stroke: #1565c0;
  stroke-width: 3.4;
  stroke-linecap: round;
}

.context-menu button:hover {
  background: #eef6ff;
}

.context-menu button.context-danger:hover {
  background: #fff0f0;
  color: #b00020;
}

.context-menu-separator {
  height: 1px;
  margin: 5px 3px;
  background: #e2e8f0;
}


/* Top-row dropdown menus with icon toolbars beneath. */
#toolbar {
  align-items: flex-start;
}

#toolbar .brand {
  order: 1;
}

#toolbar .menu-strip {
  order: 1;
  flex: 1 0 calc(100% - 230px);
  min-width: 420px;
  align-self: center;
}

#toolbar .toolbar-section {
  order: 2;
}

.toolbar-section[hidden] {
  display: none !important;
}

.menu-separator {
  height: 1px;
  margin: 5px 3px;
  background: #e2e8f0;
}

.menu-subheading {
  margin: 5px 4px 2px;
  color: #536274;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.menu-check,
.menu-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 30px;
  padding: 4px 7px;
  border-radius: 8px;
  color: #25313b;
  font-size: 12px;
  white-space: nowrap;
}

.menu-check:hover,
.menu-control:hover {
  background: #f3f7fb;
}

.menu-control input[type="number"] {
  width: 64px;
}

.menu-control input[type="range"] {
  width: 110px;
}

.menu-scale-control {
  display: grid;
  grid-template-columns: auto 110px 54px;
  gap: 8px;
  padding: 7px;
}

.menu-scale-heading {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
}

.menu-scale-slider-wrap,
.menu-scale-slider-wrap input[type="range"] {
  width: 110px;
}

.menu-scale-factor-input {
  width: 54px !important;
  min-width: 54px;
  text-align: center;
}

.menu-control select {
  min-width: 110px;
  height: 26px;
  border: 1px solid #bbbbbb;
  border-radius: 6px;
  background: #ffffff;
  font-size: 12px;
}

.style-menu-panel {
  min-width: 230px;
}

@media (max-width: 900px) {
  #toolbar .menu-strip {
    flex-basis: 100%;
    min-width: 0;
  }
}


/* Menu polish: menus left, brand/logo right, icon row beneath. */
#toolbar .menu-strip {
  order: 1;
  flex: 1 1 auto;
  min-width: 420px;
}

#toolbar .brand {
  order: 2;
  margin-left: auto;
}

#toolbar .toolbar-section {
  order: 3;
}

.menu-panel button {
  justify-content: flex-start;
}

.menu-svg-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.menu-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  min-width: 22px;
  margin-right: 5px;
  text-align: center;
}

.menu-check {
  justify-content: flex-start;
}

.menu-check input[type="checkbox"] {
  margin-right: 2px;
}

.menu-control > span {
  display: inline-flex;
  align-items: center;
}

@media (max-width: 900px) {
  #toolbar .brand {
    order: 1;
    margin-left: 0;
  }

  #toolbar .menu-strip {
    order: 2;
    flex-basis: 100%;
    min-width: 0;
  }

  #toolbar .toolbar-section {
    order: 3;
  }
}


/* Layout polish: menus and brand stay on the top row; icon toolbars begin below. */
#toolbar .menu-strip {
  order: 1;
  flex: 1 1 auto;
  min-width: 420px;
  align-self: center;
}

#toolbar .brand {
  order: 2;
  margin-left: auto;
  align-self: center;
}

.toolbar-row-break {
  order: 3;
  flex: 0 0 100%;
  width: 100%;
  height: 0;
  padding: 0;
  margin: 0;
}

#toolbar .toolbar-section {
  order: 4;
}

@media (max-width: 900px) {
  #toolbar .menu-strip {
    order: 1;
    flex-basis: 100%;
    min-width: 0;
  }

  #toolbar .brand {
    order: 2;
    margin-left: 0;
  }

  .toolbar-row-break {
    order: 3;
  }

  #toolbar .toolbar-section {
    order: 4;
  }
}


/* Office-style compact styling controls */
.style-dropdown-wrap {
  position: relative;
  display: inline-flex;
}

.office-style-button {
  gap: 5px;
  min-height: 34px;
  height: 34px;
  padding: 5px 8px;
  font-weight: 650;
}

.office-style-icon {
  width: 23px;
  height: 23px;
  flex: 0 0 auto;
}

.office-icon-stroke,
.office-icon-outline {
  fill: none;
  stroke: #1f2933;
  stroke-width: 1.8;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.office-icon-fill {
  fill: #f4c542;
  opacity: 0.85;
}

.office-fill-swatch {
  fill: #ffd21f;
  stroke: #1f2933;
  stroke-width: 0.6;
}

.office-outline-swatch {
  fill: #222222;
}

.dropdown-caret {
  font-size: 11px;
  color: #394b59;
  margin-left: 1px;
}

.vertices-tool-icon {
  width: 23px;
  height: 23px;
  flex: 0 0 auto;
  overflow: visible;
}

.vertices-tool-icon path {
  fill: none;
  stroke: #34495e;
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.vertices-tool-icon circle {
  fill: #1565c0;
  stroke: #ffffff;
  stroke-width: 0.8;
}

.vertex-menu-dot {
  width: 11px;
  height: 11px;
  margin-right: 7px;
  border-radius: 50%;
  background: #1565c0;
  box-shadow: 0 0 0 1px #16466f;
}

.vertices-popover {
  min-width: 180px;
}

.tile-vertices,
.tile-vertex {
  pointer-events: none;
}

.style-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 1500;
  min-width: min(215px, calc(100vw - 16px));
  max-width: calc(100vw - 16px);
  overflow: auto;
  box-sizing: border-box;
  padding: 8px;
  border: 1px solid #c8d2dc;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 14px 30px rgba(0,0,0,0.20);
}

.style-popover.style-popover-align-right {
  right: 0;
  left: auto;
}

.style-popover-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  min-height: 32px;
  padding: 4px 5px;
  color: #263645;
  font-size: 12px;
}

.style-popover-control select {
  min-width: 112px;
  height: 27px;
  border: 1px solid #bbbbbb;
  border-radius: 7px;
  background: #ffffff;
}

.style-popover-control input[type="number"] {
  width: 74px;
}

.compact-canvas-control {
  width: 42px;
  min-width: 42px;
  min-height: 34px;
  height: 34px;
  justify-content: center;
  padding: 0;
  border: 1px solid #cfcfcf;
  border-radius: 8px;
  background: #f9f9f9;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  position: relative;
}

.compact-canvas-control:hover,
.compact-canvas-control:focus-within {
  border-color: #8db9e8;
  background: #eef5ff;
}

#toolbar .compact-canvas-control input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.format-painter-icon {
  width: 21px;
  height: 21px;
  overflow: visible;
}

.format-painter-roller {
  fill: #f4c542;
  stroke: #263645;
  stroke-width: 1.6;
}

.format-painter-frame {
  fill: none;
  stroke: #263645;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.format-painter-handle {
  fill: #263645;
}

.help-style-tool-image {
  width: 23px;
  height: 23px;
  object-fit: contain;
}

.help-format-painter-icon {
  width: 24px;
  height: 24px;
}

.canvas-color-icon {
  width: 24px;
  height: 24px;
  overflow: visible;
}

.canvas-icon-surface {
  fill: #ffffff;
  stroke: #3c4a57;
  stroke-width: 1.5;
}

.canvas-icon-fold {
  fill: #ffffff;
  stroke: #3c4a57;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.serif-text-icon {
  width: 22px;
  height: 22px;
}

.format-painter-button.is-active {
  border-color: #1f75cb;
  background: #dceeff;
  box-shadow: 0 0 0 2px rgba(31, 117, 203, 0.2);
}

.custom-style-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tile-text-button svg {
  width: 21px;
  height: 21px;
}

.custom-image-search-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  font-size: 12px;
  font-weight: 700;
}

.custom-image-search-filter select {
  min-width: 150px;
  padding: 5px 7px;
  border: 1px solid #bac8d7;
  border-radius: 7px;
  background: #fff;
}

.tile-text-dialog {
  width: min(580px, calc(100vw - 28px));
}

.tile-text-body {
  display: grid;
  gap: 12px;
  padding: 14px 18px 18px;
}

.tile-text-preview-wrap {
  height: 260px;
  border: 1px solid #c8d6e5;
  border-radius: 10px;
  background: #fafcff;
  overflow: hidden;
}

#tileTextPreview {
  width: 100%;
  height: 100%;
}

.tile-text-body > label,
.tile-text-controls label {
  display: grid;
  gap: 5px;
  color: #243547;
  font-size: 12px;
  font-weight: 700;
}

#tileTextContent {
  box-sizing: border-box;
  width: 100%;
  resize: vertical;
  min-height: 58px;
  padding: 7px 9px;
  border: 1px solid #bac8d7;
  border-radius: 8px;
  font: inherit;
  font-weight: 400;
}

.tile-text-controls {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) 78px 72px auto;
  gap: 10px;
  align-items: end;
}

.tile-text-emphasis {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 34px;
}

.tile-text-emphasis label {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  cursor: pointer;
}

.tile-text-emphasis input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.tile-text-controls select,
.tile-text-controls input {
  box-sizing: border-box;
  height: 34px;
  width: 100%;
  border: 1px solid #bac8d7;
  border-radius: 8px;
  background: #fff;
  padding: 4px 7px;
}

.tile-text-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
}

@media (max-width: 560px) {
  .tile-text-controls { grid-template-columns: 1fr 1fr; }
  .tile-text-controls label:first-child { grid-column: 1 / -1; }
  .tile-text-preview-wrap { height: 210px; }
}

.custom-style-dialog {
  width: min(660px, calc(100vw - 24px));
  max-height: min(92vh, 680px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.custom-style-body {
  padding: 16px 18px 18px;
  overflow: auto;
}

.custom-style-body > p {
  margin: 0 0 12px;
  color: #334155;
  line-height: 1.4;
}

.custom-style-preview-wrap {
  display: grid;
  place-items: center;
  min-height: 330px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  overflow: hidden;
  background-color: #f8fafc;
  background-image:
    linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
    linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.custom-style-preview-wrap.is-file-dragover {
  border-color: #1769c2;
  box-shadow: inset 0 0 0 3px rgba(23, 105, 194, 0.22);
  background-color: #eaf4ff;
}

.custom-image-search-panel {
  height: 330px;
  box-sizing: border-box;
  overflow: auto;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 12px;
  background: #f8fafc;
}

.custom-style-preview-wrap[hidden],
.custom-image-search-panel[hidden] {
  display: none;
}

.custom-image-search-form label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
  color: #27364d;
}

.custom-image-search-form > div {
  display: flex;
  gap: 7px;
}

.custom-image-search-form input {
  min-width: 0;
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #aebed1;
  border-radius: 7px;
  font: inherit;
}

.custom-image-search-form button {
  padding: 7px 13px;
  border: 1px solid #1769c2;
  border-radius: 7px;
  background: #1769c2;
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.custom-image-search-status {
  min-height: 20px;
  margin: 8px 0;
  color: #52647c;
  font-size: 13px;
}

.custom-image-search-results {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.custom-image-search-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.custom-image-search-pagination[hidden] {
  display: none;
}

.custom-image-search-pagination button {
  min-width: 78px;
  padding: 6px 10px;
  border: 1px solid #9fb2c8;
  border-radius: 7px;
  background: #f7faff;
  color: #1f4f7f;
  font-weight: 700;
  cursor: pointer;
}

.custom-image-search-pagination button:disabled {
  opacity: 0.45;
  cursor: default;
}

.custom-image-search-pagination span {
  min-width: 92px;
  color: #52647c;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.custom-image-result {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #c8d3e1;
  border-radius: 8px;
  background: #ffffff;
}

.custom-image-result img {
  display: block;
  width: 100%;
  height: 82px;
  object-fit: cover;
  background: #e2e8f0;
}

.custom-image-result img.preview-unavailable {
  background: #eef2f6;
  color: #607080;
  font-size: 11px;
  object-fit: contain;
}

.custom-image-result-details {
  padding: 7px;
  font-size: 11px;
  line-height: 1.25;
}

.custom-image-result-title {
  display: block;
  overflow: hidden;
  margin-bottom: 3px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-image-result-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  margin-top: 6px;
}

.custom-image-result-actions button {
  padding: 4px 7px;
  border: 1px solid #1769c2;
  border-radius: 5px;
  background: #eef6ff;
  color: #14589f;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.custom-image-result-actions a,
.custom-image-attribution a {
  color: #14589f;
}

.custom-image-attribution {
  margin: 8px 0 0 !important;
  font-size: 12px;
}

#customStylePreview {
  display: block;
  width: 100%;
  height: 330px;
  touch-action: none;
  cursor: grab;
}

#customStylePreview.is-dragging {
  cursor: grabbing;
}

.custom-style-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.custom-style-controls button,
.custom-style-actions button {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid #b8c5d6;
  border-radius: 7px;
  background: #ffffff;
  color: #172033;
  font: inherit;
  cursor: pointer;
}

.custom-style-controls button:disabled,
.custom-style-actions button:disabled {
  opacity: 0.48;
  cursor: default;
}

.custom-style-zoom {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1 1 190px;
  min-width: 180px;
}

.custom-style-zoom input {
  width: 100%;
}

.custom-style-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.custom-style-actions .primary-action {
  border-color: #1769c2;
  background: #1769c2;
  color: #ffffff;
  font-weight: 700;
}

@media (max-width: 620px) {
  .custom-style-preview-wrap,
  #customStylePreview {
    min-height: 260px;
    height: 260px;
  }

  .custom-image-search-panel {
    height: 260px;
  }

  .custom-image-search-results {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

body.format-painter-mode #canvas {
  cursor: copy;
}

/* Bubble-tile outlines are split into edges so matching shared boundaries can
   be rendered once instead of stacking joins from both neighboring tiles. */
#tilesLayer .per-edge-border-fill,
#latticeLayer .per-edge-border-fill {
  stroke: none !important;
}

#tilesLayer .tile .tile-border-edge,
#latticeLayer .lattice-copy .tile-border-edge {
  fill: none;
  stroke: var(--edge-stroke) !important;
  stroke-width: var(--edge-width) !important;
  stroke-dasharray: var(--edge-dash) !important;
  stroke-linecap: var(--edge-cap) !important;
  stroke-linejoin: round;
  stroke-miterlimit: 2;
  pointer-events: none;
}

#tilesLayer .tile.selected .tile-border-edge {
  filter: drop-shadow(0 0 2px #0066cc);
}

#tilesLayer .tile.overlapping .tile-border-edge {
  stroke: #d00000 !important;
  stroke-width: 7 !important;
  filter: none;
}

/* Guided tutorial */
.guided-tutorial {
  position: fixed;
  right: 20px;
  bottom: 36px;
  z-index: 1800;
  width: min(360px, calc(100vw - 36px));
  padding: 14px 15px 13px;
  border: 1px solid #e0b11a;
  border-radius: 14px;
  background: #fff7cc;
  color: #222;
  box-shadow: 0 14px 36px rgba(0,0,0,0.24);
}

.guided-eyebrow {
  color: #805a00;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.guided-tutorial h3 {
  margin: 4px 0 6px;
  font-size: 17px;
}

.guided-tutorial p {
  margin: 0 0 10px;
  color: #3f3a22;
  line-height: 1.4;
  font-size: 13px;
}

.guided-choice {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}

.guided-choice[hidden],
.guided-task-status[hidden],
.guided-exit-actions[hidden] {
  display: none;
}

.guided-choice button {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  text-align: left;
  border-color: #d5aa22;
  background: #fffdf1;
}

.guided-choice button span {
  color: #675d37;
  font-size: 12px;
}

.guided-choice .guided-recommendation {
  margin: 0 0 2px;
  color: #5d4700;
}

.guided-choice button.recommended-tour {
  border-color: #d79f00;
  background: #fff0a8;
  box-shadow: inset 0 0 0 2px rgba(215, 159, 0, 0.34);
}

.guided-task-status {
  margin: 8px 0;
  padding: 7px 9px;
  border-radius: 8px;
  background: rgba(224, 177, 26, 0.16);
  color: #715900;
  font-size: 12px;
  font-weight: 700;
}

.guided-task-status.is-complete {
  background: #dff3df;
  color: #245f2b;
}

.guided-exit-actions {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(128, 90, 0, 0.25);
}

.guided-exit-actions p {
  margin-bottom: 7px;
  font-weight: 700;
}

.guided-exit-actions button {
  margin: 3px 4px 0 0;
}

.guided-progress {
  margin-bottom: 9px;
  color: #7b6400;
  font-size: 12px;
  font-weight: 700;
}

.guided-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
}

.guided-actions button {
  min-height: 30px;
}

.guided-highlight {
  outline: 4px solid #ffd000;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(255, 208, 0, 0.58), 0 0 22px rgba(255, 208, 0, 0.72);
  border-radius: 10px;
}

.guided-highlight-pulse {
  animation: guided-highlight-pulse 1.45s ease-in-out infinite;
}

@keyframes guided-highlight-pulse {
  0% {
    outline-color: #ffcf00;
    box-shadow: 0 0 0 5px rgba(255, 207, 0, 0.82), 0 0 26px rgba(255, 207, 0, 0.92);
  }
  50% {
    outline-color: #b98500;
    box-shadow: 0 0 0 12px rgba(255, 207, 0, 0.12), 0 0 3px rgba(185, 133, 0, 0.28);
  }
  100% {
    outline-color: #ffcf00;
    box-shadow: 0 0 0 5px rgba(255, 207, 0, 0.82), 0 0 26px rgba(255, 207, 0, 0.92);
  }
}

@media (prefers-reduced-motion: reduce) {
  .guided-highlight-pulse {
    animation: none;
  }
}

.tutorial-confetti {
  position: fixed;
  inset: 0;
  z-index: 12000;
  overflow: hidden;
  pointer-events: none;
}

.tutorial-confetti i {
  position: absolute;
  display: block;
  opacity: 0;
  transform: translate3d(0, 0, 0) rotate(0deg);
  animation-name: tutorial-confetti-burst;
  animation-timing-function: cubic-bezier(0.16, 0.72, 0.28, 1);
  animation-fill-mode: both;
  will-change: transform, opacity, filter;
}

@keyframes tutorial-confetti-burst {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0deg) scale(0.35);
    filter: blur(0);
  }
  8% {
    opacity: 1;
  }
  46% {
    opacity: 1;
    transform: translate3d(var(--confetti-mid-x), var(--confetti-mid-y), 0) rotate(var(--confetti-mid-spin)) scale(1);
    filter: blur(0);
  }
  82% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--confetti-end-x), var(--confetti-end-y), 0) rotate(var(--confetti-spin)) scale(0.35);
    filter: blur(2px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tutorial-confetti {
    display: none;
  }
}

/* Keep menus left, brand right, and all toolbars below the dropdown row. */
#toolbar {
  align-items: flex-start;
}

#toolbar .menu-strip {
  order: 1;
  flex: 1 1 auto;
  min-width: 420px;
  align-self: center;
}

#toolbar .brand {
  order: 2;
  margin-left: auto;
  align-self: center;
}

#toolbar::after {
  content: "";
  order: 2;
  flex-basis: 100%;
  height: 0;
}

#toolbar .toolbar-section {
  order: 3;
}


/* Extra disclosure arrow for tile-tray sets, beyond the browser default. */
.tray-section summary {
  position: relative;
  padding-right: 30px;
}

.tray-section summary::after {
  content: "▸";
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: #51677c;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  transition: transform 0.14s ease;
}

.tray-section[open] summary::after {
  content: "▾";
}


.flip-icon .flip-head {
  fill: #111111;
}


/* Word-free icon toolbar refinements */
#viewToolbar,
#editToolbar,
#selectionToolbar,
#transformToolbar,
#bubbleToolbar,
#latticeToolbar,
#styleToolbar,
#togglesToolbar {
  gap: 5px;
}

.toolbar-icon-only {
  min-width: 42px;
  width: 42px;
  padding-left: 5px;
  padding-right: 5px;
}

.toolbar-icon-only .dropdown-caret {
  margin-left: -2px;
}

.toolbar-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  font-weight: 850;
}

.icon-range-control {
  gap: 5px;
}

.icon-range-control input[type="range"] {
  width: 92px;
}

.icon-only-color-control {
  gap: 5px;
  padding-left: 7px;
  padding-right: 7px;
}

.icon-only-color-control input[type="color"] {
  width: 30px;
}

.icon-toggle {
  gap: 5px;
  min-width: 47px;
  justify-content: center;
}

.overlap-toolbar-icon {
  position: relative;
  width: 22px;
  height: 19px;
  display: inline-block;
  flex: 0 0 auto;
}

.overlap-box {
  position: absolute;
  width: 13px;
  height: 13px;
  border: 2px solid #d00000;
  border-radius: 3px;
  background: rgba(208, 0, 0, 0.08);
  box-sizing: border-box;
}

.overlap-box-a {
  left: 1px;
  top: 1px;
}

.overlap-box-b {
  left: 7px;
  top: 5px;
  background: rgba(208, 0, 0, 0.18);
}


/* Tighten the menu-to-toolbar spacing. */
#toolbar {
  row-gap: 3px !important;
  column-gap: 6px;
  padding-top: 5px;
  padding-bottom: 5px;
}

#toolbar::after {
  flex-basis: 100%;
  height: 0;
  margin: 0;
}

#toolbar .menu-strip {
  margin-bottom: 0;
}

/* Tray header: tabs + arrow, no separate title. */
.tray-header {
  gap: 6px;
}

.tray-header-tabs {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
  border-bottom: 0;
  background: transparent;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.tray-header-tabs .tray-tab {
  min-height: 31px;
  height: 31px;
  padding-left: 6px;
  padding-right: 6px;
}

/* Collapsed tray recent-set icon rail. */
.collapsed-tray-icons {
  display: none;
}

#appShell.tray-collapsed .tray-header {
  height: auto;
  min-height: 43px;
  padding: 6px 5px;
  justify-content: center;
  position: relative;
}

#appShell.tray-collapsed .tray-header-tabs,
#appShell.tray-collapsed .tray-title,
#appShell.tray-collapsed .collapsed-tray-label,
#appShell.tray-collapsed .tray-panel,
#appShell.tray-collapsed .examples-panel {
  display: none !important;
}

#appShell.tray-collapsed .tray-toggle {
  width: 36px;
  min-width: 36px;
  height: 32px;
  padding-left: 0;
  padding-right: 0;
  justify-content: center;
}

#appShell.tray-collapsed .collapsed-tray-icons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 8px 5px;
}

.collapsed-tray-icon-button {
  width: 37px;
  height: 37px;
  min-height: 37px;
  padding: 3px;
  border-radius: 10px;
  justify-content: center;
  background: #ffffff;
}

.collapsed-tray-icon-button:hover {
  background: #eef6ff;
}

.collapsed-tray-icon-svg {
  width: 27px;
  height: 27px;
  display: block;
}

#appShell.tray-collapsed #tileTray {
  overflow-y: hidden;
}


/* Optional View/Edit toolbars are hidden by default and can be shown from View → Show toolbar. */
#viewToolbar,
#editToolbar {
  gap: 5px;
}

#viewToolbar .icon-button,
#editToolbar .icon-button {
  min-width: 34px;
  width: 34px;
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}


/* Collapsed tray now shows the tiles from the most recently used family. */
#appShell.tray-collapsed .collapsed-tray-icons {
  gap: 4px;
  padding: 6px 4px 10px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  scrollbar-width: thin;
}

.collapsed-tray-icon-heading {
  width: 32px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #53677c;
  font-size: 12px;
  font-weight: 900;
  opacity: 0.75;
}

#appShell.tray-collapsed .collapsed-tray-icon-button {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 2px;
  border-radius: 9px;
}

#appShell.tray-collapsed .collapsed-tray-icon-svg {
  width: 25px;
  height: 25px;
}

#appShell.tray-collapsed .collapsed-tray-icons {
  flex: 1 1 auto;
  max-height: calc(100% - 45px);
}


/* View menu toolbar submenu */
.toolbar-submenu {
  margin: 2px 0;
}

.toolbar-submenu > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 7px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  list-style: none;
}

.toolbar-submenu > summary::-webkit-details-marker {
  display: none;
}

.toolbar-submenu > summary::after {
  content: "▸";
  margin-left: auto;
  color: #536274;
  font-weight: 900;
}

.toolbar-submenu[open] > summary::after {
  content: "▾";
}

.toolbar-submenu > summary:hover {
  background: #f3f7fb;
}

.submenu-panel {
  margin: 3px 0 4px 10px;
  padding-left: 5px;
  border-left: 2px solid #e0e7ef;
}

/* Closed rail Add All button and dragging feedback */
.collapsed-tray-icon-heading {
  width: 37px;
  height: 27px;
  min-height: 27px;
  padding: 2px;
  border-radius: 8px;
  justify-content: center;
  background: #eef6ff;
  border: 1px solid #b8d4ef;
  color: #16466f;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.collapsed-tray-icon-button.dragging-from-tray {
  opacity: 0.55;
}

#appShell.tray-collapsed #tileTray {
  overflow-y: auto;
}


/* Playful upper-right Bubble Tiles brand treatment. */
#toolbar .brand {
  font-family: "Bangers", "Cooper Black", "Arial Black", "Impact", "Trebuchet MS", fantasy;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.045em;
  color: #202124;
  text-shadow: 0 1px 0 #ffffff, 0 2px 0 rgba(0, 0, 0, 0.08);
}

#toolbar .brand .logo {
  transform: rotate(-8deg);
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.18));
}


/* BANGERS-like brand: bold, slanted, condensed, red display lettering. */
#toolbar .brand {
  font-family: "Franklin Gothic Heavy", "Arial Black", Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 22px;
  font-weight: 950;
  font-style: italic;
  letter-spacing: -0.035em;
  color: #b82422;
  text-transform: none;
  text-shadow: 0 1px 0 #ffffff, 1px 2px 0 rgba(0, 0, 0, 0.12);
  transform: skewX(-8deg);
  transform-origin: right center;
}

#toolbar .brand .logo {
  transform: rotate(-8deg) skewX(8deg);
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.18));
}


.toolbar-menu > summary.guided-highlight {
  outline-offset: 4px;
  border-radius: 8px;
}


/* Handwritten-style Bubble Tiles brand, using system fonts only. */
#toolbar .brand {
  font-family: "Segoe Script", "Lucida Handwriting", "Brush Script MT", "Bradley Hand", "Segoe Print", cursive;
  font-size: 22px;
  font-weight: 700;
  font-style: normal;
  letter-spacing: 0.005em;
  color: #111111;
  text-transform: none;
  text-shadow: none;
  transform: rotate(-2deg);
  transform-origin: right center;
}

#toolbar .brand .logo {
  transform: rotate(-8deg);
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.16));
}


#fillPatternPicker,
#menuFillPatternPicker {
  min-width: 128px;
}


/* --- Refresh: comic handwriting brand, clearer icons, and neutral delete button --- */
#toolbar .brand {
  font-family: "Comic Sans MS", "Comic Neue", "Chalkboard SE", "Marker Felt", "Segoe Print", sans-serif;
  color: #111;
  font-weight: 700;
  font-style: normal;
  text-transform: none;
  letter-spacing: 0.02em;
  transform: none;
}
#toolbar .brand .logo, #toolbar .brand .brand-logo { filter: none; }

.neutral-delete-button { color: #444 !important; }
.neutral-delete-button:hover { color: #222 !important; }

.trash-icon {
  width: 21px;
  height: 21px;
  stroke: #444;
  fill: #d7dce1;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.trash-icon path:nth-child(1) { fill: #d8dde3; }
.trash-icon path:nth-child(2), .trash-icon path:nth-child(3), .trash-icon path:nth-child(4), .trash-icon path:nth-child(5) { fill: none; }

.broom-icon {
  width: 25px;
  height: 25px;
  overflow: visible;
}
.broom-icon .broom-handle {
  fill: none;
  stroke: #6f4b2d;
  stroke-width: 5;
  stroke-linecap: round;
}
.broom-icon .broom-collar {
  fill: none;
  stroke: #56616b;
  stroke-width: 5;
  stroke-linecap: round;
}
.broom-icon .broom-head {
  fill: #e2a72e;
  stroke: #7b5a16;
  stroke-width: 2.4;
  stroke-linejoin: round;
}
.broom-icon .broom-bristle {
  fill: none;
  stroke: #7b5a16;
  stroke-width: 2;
  stroke-linecap: round;
}

.fill-tool-icon, .outline-tool-icon { width: 20px; height: 20px; }
.fill-tool-icon .bucket-body { fill: #d6dce3; stroke: #555; stroke-width: 1.7; stroke-linejoin: round; }
.fill-tool-icon .bucket-rim { stroke: #777; stroke-width: 1.6; stroke-linecap: round; fill: none; }
.fill-tool-icon .bucket-handle { stroke: #777; stroke-width: 1.5; stroke-linecap: round; fill: none; }
.fill-tool-icon .paint-drip { fill: #f1c40f; stroke: #b88400; stroke-width: 1.2; }
.fill-tool-icon .office-fill-swatch { fill: var(--icon-fill-swatch, #f1c40f); stroke: #666; stroke-width: 0.8; }

.outline-tool-icon .outline-shape { fill: #ffffff; stroke: #4a4a4a; stroke-width: 1.7; }
.outline-tool-icon .outline-pencil-body { fill: none; stroke: #f39c12; stroke-width: 3.1; stroke-linecap: round; stroke-linejoin: round; }
.outline-tool-icon .outline-pencil-tip { fill: #c78d52; stroke: #80592f; stroke-width: 0.9; }
.outline-tool-icon .office-outline-swatch { fill: var(--icon-outline-swatch, #222); stroke: #666; stroke-width: 0.8; }

.reflect-icon {
  width: 22px;
  height: 18px;
}
.reflect-icon .reflect-mirror {
  stroke: #7d7d7d;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: 3 3;
}
.reflect-icon .reflect-shape.light {
  fill: #d9d9d9;
  stroke: #767676;
  stroke-width: 1.5;
  stroke-linejoin: round;
}
.reflect-icon .reflect-shape.dark {
  fill: #2f2f2f;
  stroke: #111;
  stroke-width: 1.5;
  stroke-linejoin: round;
}
.reflect-button .toolbar-svg-icon, .reflect-button svg { width: 22px; height: 18px; }
#locateLatticeParents { font-size: 1.18rem; }
.degree-text-input { text-align: center; min-width: 60px; }


/* final polish overrides */
#toolbar .brand {
  display:flex;
  align-items:center;
  gap:10px;
  font-family: "Bangers", Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif !important;
  color:#111;
  font-weight:400;
  letter-spacing:0.04em;
  transform:none !important;
  rotate:0deg !important;
  skew:none !important;
}
#toolbar .brand-wordmark {
  font-family: inherit;
  font-size: 1.85rem;
  line-height:1;
  color:#111;
  display:inline-block;
  transform:none !important;
  font-style:normal !important;
  text-decoration:none;
}
#toolbar .brand-logo-image {
  height:40px;
  width:auto;
  display:block;
  transform:none !important;
  filter:none !important;
}
#toolbar .brand .logo,
#toolbar .brand .brand-logo,
#toolbar .brand .brand-logo-image,
#toolbar .brand span {
  transform:none !important;
  rotate:0deg !important;
}

/* food assets and icons */
.fill-tool-image {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display:block;
}
.eye-icon { width: 19px; height: 19px; }
.eye-icon path, .eye-icon circle {
  stroke:#2c5b88; fill:none; stroke-width:2.1; stroke-linecap:round; stroke-linejoin:round;
}
.eye-icon circle { fill:#2c5b88; stroke-width:1.6; }

.locate-icon { width: 20px; height: 20px; }
.locate-icon circle, .locate-icon line {
  stroke:#333; fill:none; stroke-width:2.2; stroke-linecap:round;
}
.locate-icon circle:last-of-type { fill:#333; stroke:none; }
#locateLatticeParents .locate-icon { width: 21px; height: 21px; }

.reflect-icon { width: 24px; height: 19px; }
.reflect-icon .reflect-mirror { stroke:#8b8b8b; stroke-width:2.2; stroke-dasharray:3 3; stroke-linecap:round; }
.reflect-icon .reflect-shape.light { fill:#dadada; stroke:#777; stroke-width:1.35; }
.reflect-icon .reflect-shape.dark { fill:#1f1f1f; stroke:#111; stroke-width:1.35; }

.outline-tool-icon { width: 19px; height: 19px; }
.outline-tool-icon .outline-shape { fill:#fff; stroke:#4a4a4a; stroke-width:1.8; }
.outline-tool-icon .outline-pencil-body { fill:none; stroke:#f39c12; stroke-width:3.0; stroke-linecap:round; stroke-linejoin:round; }
.outline-tool-icon .outline-pencil-tip { fill:#d0a26b; stroke:#7c5a35; stroke-width:0.9; }
.outline-tool-icon .outline-trace { stroke:#4a4a4a; stroke-width:1.6; stroke-linecap:round; }
.outline-tool-icon .office-outline-swatch { fill: var(--icon-outline-swatch, #222); stroke:#666; stroke-width:0.8; }

/* use neutral delete icon colors */
.neutral-delete-button .trash-icon { width:22px; height:22px; }



/* final dropdown/icon/donut polish */
#toolbar {
  row-gap: 1px !important;
  padding-top: 3px !important;
  padding-bottom: 3px !important;
}
#toolbar .toolbar-section {
  margin-top: 0 !important;
}
#toolbar .brand {
  font-family: 'Patrick Hand', 'Trebuchet MS', Arial, sans-serif !important;
  letter-spacing: 0.02em !important;
}
#toolbar .brand-wordmark {
  font-family: 'Patrick Hand', 'Trebuchet MS', Arial, sans-serif !important;
  font-size: 2rem !important;
  letter-spacing: 0.02em !important;
  transform: none !important;
  rotate: 0deg !important;
}
.menu-icon-image,
.outline-tool-image,
.fill-tool-image {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: inline-block;
  vertical-align: middle;
  flex: 0 0 auto;
}
#toolbar .icon-button svg,
#toolbar .icon-button img,
.menu-panel button svg,
.menu-panel button img,
.menu-control .menu-svg-icon,
.menu-control .menu-icon-image {
  margin-right: 6px;
}
#toolbar .icon-button > svg,
#toolbar .icon-button > img {
  margin-right: 0;
}
.office-page,
.office-clipboard,
.office-paper,
.office-clip {
  stroke: #263442;
  stroke-width: 2.2;
  stroke-linejoin: round;
}
.office-page.back { fill: #b8d3f0; }
.office-page.front,
.office-paper { fill: #ffffff; }
.office-clipboard { fill: #d5e6f8; }
.office-clip { fill: #7faee0; }
.office-page-line { fill: none; stroke: #4d78a4; stroke-width: 2; stroke-linecap: round; }

.layer-stack-icon .layer-sheet {
  stroke: #304253;
  stroke-width: 1.8;
  stroke-linejoin: round;
}
.layer-sheet-back { fill: #b8c9d9; }
.layer-sheet-mid { fill: #d8e4ef; }
.layer-sheet-front { fill: #ffffff; }
.layer-stack-icon .layer-arrow,
.layer-stack-icon .layer-stop {
  fill: none;
  stroke: #1769aa;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lattice-vectors-icon .lattice-seed {
  fill: #ffffff;
  stroke: #25394c;
  stroke-width: 2;
}
.lattice-vectors-icon .lattice-ghost {
  fill: #bcd8f3;
  stroke: #4b7398;
  stroke-width: 1.6;
  stroke-dasharray: 2 2;
}
.lattice-vectors-icon .lattice-vector {
  fill: none;
  stroke: #1769aa;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.menu-panel button,
.menu-panel .menu-control > span:first-child {
  display: flex;
  align-items: center;
  gap: 6px;
}
.menu-panel .menu-control > span:first-child > span:last-child { display: inline-block; }
.reflect-icon .reflect-mirror {
  stroke: #4a4a4a;
  stroke-width: 2.2;
  stroke-dasharray: 4 4;
  stroke-linecap: round;
}
.reflect-icon .reflect-shape.light {
  fill: #d7d7d7;
  stroke: #787878;
  stroke-width: 1.5;
  stroke-linejoin: round;
}
.reflect-icon .reflect-shape.dark {
  fill: #2f2f2f;
  stroke: #111;
  stroke-width: 1.5;
  stroke-linejoin: round;
}
.tile-hit-area {
  fill: #ffffff;
  fill-opacity: 0.001;
  stroke: none;
  pointer-events: all;
}


/* Final requested polish: restore Bangers wordmark and enlarge only the Outline icon. */
#toolbar .brand,
#toolbar .brand-wordmark {
  font-family: "Bangers", Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif !important;
  font-weight: 400 !important;
  font-style: normal !important;
  color: #111 !important;
  letter-spacing: 0.045em !important;
  transform: none !important;
  rotate: 0deg !important;
  skew: none !important;
}

#toolbar .brand-wordmark {
  font-size: 2rem !important;
  line-height: 1 !important;
}

#shapeOutlineButton .outline-tool-image {
  width: 24px !important;
  height: 24px !important;
  object-fit: contain;
}

.menu-control .outline-menu-image {
  width: 23px !important;
  height: 23px !important;
  object-fit: contain;
}


/* Final requested pass: keep Bangers, tighten the menu-to-toolbar gap, and enlarge only Outline. */
#toolbar {
  row-gap: 0 !important;
  padding-top: 2px !important;
  padding-bottom: 2px !important;
}

#toolbar .menu-strip {
  margin-bottom: -3px !important;
}

.toolbar-row-break {
  height: 0 !important;
  margin: -4px 0 0 0 !important;
  padding: 0 !important;
  line-height: 0 !important;
}

#toolbar .toolbar-section {
  margin-top: -3px !important;
}

#toolbar .brand,
#toolbar .brand-wordmark {
  font-family: "Bangers", Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif !important;
  font-weight: 400 !important;
  font-style: normal !important;
  color: #111 !important;
  letter-spacing: 0.045em !important;
  transform: none !important;
  rotate: 0deg !important;
  skew: none !important;
}

#toolbar .brand-wordmark {
  font-size: 1.82rem !important;
  line-height: 1 !important;
}

#toolbar .brand-logo-image {
  height: 34px !important;
  width: auto !important;
}

#shapeOutlineButton .outline-tool-image {
  width: 29px !important;
  height: 29px !important;
  object-fit: contain !important;
}

.menu-control .outline-menu-image {
  width: 25px !important;
  height: 25px !important;
  object-fit: contain !important;
}


/* Requested final spacing/alignment pass. */
#shortcutsToolbar {
  margin-top: 5px !important;
}

/* Roll the Outline icon back from the oversized pass. */
#shapeOutlineButton .outline-tool-image {
  width: 22px !important;
  height: 22px !important;
}

#shapeFillButton .fill-tool-image {
  width: 16px !important;
  height: 16px !important;
  object-fit: contain !important;
}

.menu-control .outline-menu-image {
  width: 23px !important;
  height: 23px !important;
}

.outline-pencil-icon {
  display: block;
  overflow: visible;
  flex: 0 0 auto;
}

.outline-pencil-line,
.outline-pencil-body,
.outline-pencil-tip,
.outline-pencil-band {
  stroke: #26323d;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.outline-pencil-line,
.outline-pencil-band {
  fill: none;
}

.outline-pencil-body {
  fill: #f5c84c;
}

.outline-pencil-tip {
  fill: #f4eee3;
}

#shapeOutlineButton {
  gap: 2px !important;
  justify-content: center;
  padding: 5px 5px 5px 4px !important;
}

#shapeOutlineButton .dropdown-caret {
  margin-left: 0 !important;
  font-size: 10px;
  transform: translateX(-1px);
}

/* Align all dropdown labels to a consistent text tab. */
.menu-panel > button,
.menu-panel > label.menu-control > span:first-child,
.menu-panel > label.menu-check,
.toolbar-submenu > summary,
.submenu-panel > label.menu-check {
  display: grid !important;
  grid-template-columns: 26px minmax(0, 1fr) !important;
  align-items: center !important;
  column-gap: 8px !important;
  text-align: left !important;
}

.menu-panel > button > svg:first-child,
.menu-panel > button > img:first-child,
.menu-panel > button > .menu-item-icon:first-child,
.menu-panel > label.menu-control > span:first-child > svg:first-child,
.menu-panel > label.menu-control > span:first-child > img:first-child,
.menu-panel > label.menu-control > span:first-child > .menu-item-icon:first-child,
.menu-panel > label.menu-check > .menu-item-icon:first-of-type,
.toolbar-submenu > summary > .menu-item-icon:first-child,
.submenu-panel > label.menu-check > .menu-item-icon:first-of-type {
  grid-column: 1 !important;
  justify-self: center !important;
  width: 22px !important;
  max-width: 22px !important;
  margin-right: 0 !important;
  text-align: center !important;
}

.menu-panel > button > span:last-child,
.menu-panel > label.menu-control > span:first-child > span:last-child,
.toolbar-submenu > summary > span:last-child,
.menu-panel > label.menu-check > span:last-child,
.submenu-panel > label.menu-check > span:last-child {
  grid-column: 2 !important;
  justify-self: start !important;
  min-width: 0 !important;
}

.menu-icon-spacer {
  visibility: hidden !important;
}


/* Final tiny polish pass: space shortcuts a touch lower, keep menu checks on one line, fix submenu arrow placement. */
#shortcutsToolbar {
  margin-top: 9px !important;
}

.menu-panel > label.menu-check,
.submenu-panel > label.menu-check {
  display: grid !important;
  grid-template-columns: 18px 26px minmax(0, 1fr) !important;
  align-items: center !important;
  column-gap: 8px !important;
  white-space: nowrap !important;
}

.menu-panel > label.menu-check > input[type="checkbox"],
.submenu-panel > label.menu-check > input[type="checkbox"] {
  grid-column: 1 !important;
  margin: 0 !important;
  justify-self: center !important;
}

.menu-panel > label.menu-check > .menu-item-icon:first-of-type,
.submenu-panel > label.menu-check > .menu-item-icon:first-of-type {
  grid-column: 2 !important;
  justify-self: center !important;
  width: 22px !important;
  max-width: 22px !important;
  margin-right: 0 !important;
  text-align: center !important;
}

.menu-panel > label.menu-check > span:last-child,
.submenu-panel > label.menu-check > span:last-child {
  grid-column: 3 !important;
  justify-self: start !important;
  min-width: 0 !important;
}

.toolbar-submenu > summary {
  display: grid !important;
  grid-template-columns: 26px minmax(0, 1fr) 14px !important;
  align-items: center !important;
  column-gap: 8px !important;
}

.toolbar-submenu > summary > .menu-item-icon:first-child {
  grid-column: 1 !important;
  justify-self: center !important;
  width: 22px !important;
  max-width: 22px !important;
  margin-right: 0 !important;
  text-align: center !important;
}

.toolbar-submenu > summary > span:last-child {
  grid-column: 2 !important;
  justify-self: start !important;
  min-width: 0 !important;
}

.toolbar-submenu > summary::after {
  grid-column: 3 !important;
  justify-self: end !important;
  margin-left: 0 !important;
}


/* Deploy UI fixes: dropdown gap, shortcut spacing, custom-angle row, guided tutorial layering. */
.toolbar-menu .menu-panel {
  top: calc(100% + 1px) !important;
}

.menu-panel > label.custom-angle-control {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 92px !important;
  align-items: center !important;
  column-gap: 10px !important;
}

.menu-panel > label.custom-angle-control > span:first-child {
  grid-column: 1 !important;
  justify-self: start !important;
  padding-left: 26px !important;
}

.menu-panel > label.custom-angle-control > input {
  grid-column: 2 !important;
  justify-self: end !important;
  width: 82px !important;
  text-align: left !important;
}

#shortcutsToolbar {
  margin-top: 14px !important;
}

#toolbar .toolbar-section.help-section,
#shortcutsToolbar {
  transform: translateY(4px);
}

.guided-highlight {
  position: relative !important;
  z-index: 10000 !important;
  outline-offset: 4px !important;
}

.guided-highlight::after {
  z-index: 10001 !important;
}

#guidedTutorialPanel,
.guided-tutorial-panel,
.guided-panel {
  z-index: 10020 !important;
}


/* Final polish: keep shortcut bar separated without overlapping the canvas. */
#shortcutsToolbar {
  margin-top: 9px !important;
  margin-bottom: 5px !important;
  transform: none !important;
}

#toolbar .toolbar-section.help-section {
  transform: none !important;
}

/* Hide example tags to make the Examples tray denser. */
.example-tags,
.example-card-tags,
.example-tag,
.example-tags-list {
  display: none !important;
}

.example-card .tag-list,
.example-card .tags,
.example-card [class*="tag"] {
  display: none !important;
}

.example-card-icon,
.example-card-description,
.example-card-meta {
  display: none !important;
}


/* Ensure invisible tile hit areas never render a visible outline. */
.tile .tile-hit-area {
  stroke: none !important;
  stroke-width: 0 !important;
  stroke-dasharray: none !important;
  filter: none !important;
  fill: #ffffff !important;
  fill-opacity: 0.001 !important;
  pointer-events: all !important;
}

.tile .canvas-image-shape {
  pointer-events: none;
}

.tile.selected .canvas-image-shape {
  filter: drop-shadow(0 0 3px #0066cc) drop-shadow(0 0 3px #0066cc);
}

.tile.overlapping .canvas-image-shape {
  filter: drop-shadow(0 0 3px #d40000) drop-shadow(0 0 3px #d40000);
}


/* Style toolbar preview grids */
.style-preview-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  padding: 4px 5px 8px;
}

.stroke-preview-grid {
  grid-template-columns: repeat(4, 1fr);
}

.style-preview-button {
  width: 30px;
  height: 28px;
  border: 1px solid #c5ced8;
  border-radius: 7px;
  background: #f8fafc;
  padding: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.style-preview-button:hover,
.style-preview-button.is-active {
  border-color: #1f75cb;
  box-shadow: 0 0 0 2px rgba(31,117,203,0.18);
}

.fill-preview,
.stroke-preview {
  width: 23px;
  height: 19px;
  border-radius: 5px;
  border: 1.4px solid var(--preview-stroke, #222);
  background-color: var(--preview-fill, #f5eecf);
  display: block;
  overflow: hidden;
}

.fill-preview-solid { background: var(--preview-fill, #f5eecf); }
.fill-preview-dots { background: radial-gradient(var(--preview-stroke, #222) 1.5px, transparent 1.8px) 0 0 / 9px 9px, var(--preview-fill, #f5eecf); }
.fill-preview-dense-dots { background: radial-gradient(var(--preview-stroke, #222) 1.2px, transparent 1.5px) 0 0 / 5px 5px, var(--preview-fill, #f5eecf); }
.fill-preview-crosshatch { background: repeating-linear-gradient(45deg, transparent 0 5px, var(--preview-stroke, #222) 5px 6.5px), repeating-linear-gradient(-45deg, transparent 0 5px, var(--preview-stroke, #222) 5px 6.5px), var(--preview-fill, #f5eecf); }
.fill-preview-lines { background: repeating-linear-gradient(0deg, var(--preview-fill, #f5eecf) 0 5px, var(--preview-stroke, #222) 5px 6.5px); }
.fill-preview-dense-lines { background: repeating-linear-gradient(0deg, var(--preview-fill, #f5eecf) 0 3px, var(--preview-stroke, #222) 3px 4px); }
.fill-preview-brick { background: linear-gradient(var(--preview-stroke, #222) 1px, transparent 1px) 0 0 / 14px 7px, linear-gradient(90deg, var(--preview-stroke, #222) 1px, transparent 1px) 0 0 / 14px 7px, var(--preview-fill, #f5eecf); }
.fill-preview-herringbone { background: repeating-linear-gradient(45deg, transparent 0 6px, var(--preview-stroke, #222) 6px 7.5px, transparent 7.5px 12px), repeating-linear-gradient(-45deg, transparent 0 6px, var(--preview-stroke, #222) 6px 7.5px, transparent 7.5px 12px), var(--preview-fill, #f5eecf); }
.fill-preview-cookie { background-image: url("assets/food-cookie.jpg"); background-size: cover; background-position: center; }
.fill-preview-oreo { background-image: url("assets/food-oreo.jpg"); background-size: cover; background-position: center; }
.fill-preview-donut { background-image: url("assets/food-donut-sprinkle.png"); background-size: cover; background-position: center; }
.fill-preview-donut-chocolate { background-image: url("assets/food-donut-chocolate.png"); background-size: cover; background-position: center; background-color: #e7d7c5; }
.fill-preview-donut-glazed { background-image: url("assets/food-donut-glazed.png"); background-size: cover; background-position: center; background-color: #e7d7c5; }
.fill-preview-clouds { background-image: url("assets/texture-clouds.jpg"); background-size: cover; background-position: center; }
.fill-preview-white-marble { background-image: url("assets/texture-white-marble.jpg"); background-size: cover; background-position: center; }
.fill-preview-green-marble { background-image: url("assets/texture-green-marble.jpg"); background-size: cover; background-position: center; }
.fill-preview-light-wood { background-image: url("assets/texture-light-wood.jpg"); background-size: cover; background-position: center; }
.fill-preview-dark-wood { background-image: url("assets/texture-dark-wood.jpg"); background-size: cover; background-position: center; }

.stroke-preview {
  background: #fff;
  border-width: 3px;
}
.stroke-preview-solid { border-style: solid; }
.stroke-preview-dashed { border-style: dashed; }
.stroke-preview-dotted { border-style: dotted; }
.stroke-preview-none { border-style: none; position: relative; background: linear-gradient(135deg, transparent 0 44%, #b43333 45% 55%, transparent 56% 100%), #fff; }


/* Preview-only style popovers: keep the selects as hidden state controls, but remove the old text-only dropdowns from the visible UI. */
.style-popover-hidden-select {
  display: none !important;
}

.style-preview-grid {
  margin-top: 2px;
}

.style-preview-button {
  cursor: pointer;
}


.arc-reverse-overlay .arc-reverse-hit-arc {
  vector-effect: non-scaling-stroke;
  pointer-events: stroke;
}

.arc-reverse-overlay .arc-reverse-hit-arc:hover {
  opacity: 0.72;
}


/* Reverse-one-arc tool icon and arc-hover affordance. */
.arc-reverse-tool-button {
  padding: 4px;
}

.arc-reverse-tool-icon {
  width: 24px;
  height: 24px;
  display: block;
  overflow: visible;
}

.menu-svg-icon.arc-reverse-tool-icon {
  width: 22px;
  height: 22px;
}

.arc-reverse-tool-icon .arc-dots {
  fill: none;
  stroke: #1463ff;
  stroke-width: 4.2;
  stroke-linecap: round;
  stroke-dasharray: 1 11;
}

.arc-reverse-tool-icon .arc-dot {
  fill: #1463ff;
}

.arc-reverse-tool-icon .arc-arrow,
.arc-reverse-tool-icon .arc-arrow-head {
  fill: none;
  stroke: #e0262e;
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.arc-reverse-overlay .arc-reverse-hit-arc {
  vector-effect: non-scaling-stroke;
  pointer-events: stroke;
  transition: opacity 120ms ease, stroke 120ms ease, filter 120ms ease;
}

.arc-reverse-overlay .arc-reverse-hit-arc:hover {
  stroke: #ffd21f !important;
  opacity: 0.92 !important;
  filter: drop-shadow(0 0 5px rgba(255, 210, 31, 0.95));
}


/* Reverse One Arc: larger sketch-style icon, vertex dots, and true hover glow. */
.arc-reverse-tool-icon {
  width: 28px;
  height: 28px;
  display: block;
  overflow: visible;
}

.menu-svg-icon.arc-reverse-tool-icon {
  width: 24px;
  height: 24px;
}

.arc-reverse-tool-icon .arc-dots {
  fill: none;
  stroke: #1463ff;
  stroke-width: 4.8;
  stroke-linecap: round;
  stroke-dasharray: 0.5 11;
}

.arc-reverse-tool-icon .arc-dot {
  fill: #1463ff;
  stroke: none;
}

.arc-reverse-tool-icon .arc-arrow,
.arc-reverse-tool-icon .arc-arrow-head {
  fill: none;
  stroke: #e0262e;
  stroke-width: 5.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.arc-reverse-overlay .arc-reverse-hit-arc {
  vector-effect: non-scaling-stroke;
  pointer-events: stroke;
}

.arc-reverse-overlay .arc-reverse-glow-arc {
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 5px rgba(255, 210, 31, 0.95)) drop-shadow(0 0 11px rgba(255, 210, 31, 0.65));
  transition: opacity 100ms ease;
}

.arc-reverse-overlay .arc-reverse-vertex-dot {
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.9));
}



/* Reverse One Arc icon cleanup: mirrored arcs, one dotted and one solid. */
.arc-reverse-tool-icon .arc-solid {
  fill: none;
  stroke: #1463ff;
  stroke-width: 4.8;
  stroke-linecap: round;
}
.arc-reverse-tool-icon .arc-dots {
  fill: none;
  stroke: #1463ff;
  stroke-width: 4.8;
  stroke-linecap: round;
  stroke-dasharray: 0.5 10;
}
.arc-reverse-tool-icon .arc-dot { display: none; }
.arc-reverse-tool-icon .arc-arrow,
.arc-reverse-tool-icon .arc-arrow-head {
  fill: none;
  stroke: #e0262e;
  stroke-width: 5.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Reverse One Arc hover: only a glow, not a replacement stroke color. */
.arc-reverse-overlay .arc-reverse-hit-arc,
.arc-reverse-overlay .arc-reverse-hit-arc:hover {
  opacity: 0 !important;
  stroke: #000000 !important;
  filter: none !important;
  vector-effect: non-scaling-stroke;
  pointer-events: stroke;
}
.arc-reverse-overlay .arc-reverse-glow-arc {
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 4px rgba(255, 218, 40, 0.95)) drop-shadow(0 0 12px rgba(255, 218, 40, 0.75));
  transition: opacity 80ms ease;
}
.arc-reverse-overlay .arc-reverse-edge-cover {
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

/* Edge decoration toolbar and rendered edge motifs. */
.edge-decoration-tool-icon {
  width: 24px;
  height: 24px;
  display: block;
}
.edge-decoration-icon-edge {
  fill: none;
  stroke: #222;
  stroke-width: 3.2;
  stroke-linecap: round;
}
.edge-decoration-icon-arc {
  fill: none;
  stroke: #2477d4;
  stroke-width: 3.2;
  stroke-linecap: round;
}
.edge-decoration-icon-node {
  fill: #222;
}
.edge-decoration-preview-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.edge-decoration-preview {
  width: 36px;
  height: 28px;
  display: block;
  position: relative;
}
.edge-decoration-preview::before,
.edge-decoration-preview::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
}
.edge-decoration-preview-none::before {
  top: 14px;
  border-top: 3px solid #222;
}
.edge-decoration-preview-none::after {
  top: 4px;
  bottom: 4px;
  left: 16px;
  right: auto;
  width: 3px;
  background: #b43333;
  transform: rotate(45deg);
}
.edge-decoration-preview-arc60::before {
  top: 15px;
  border-top: 3px solid #222;
}
.edge-decoration-preview-arc60::after {
  left: 6px;
  right: 6px;
  top: 4px;
  height: 18px;
  border-top: 4px solid #2477d4;
  border-radius: 50% 50% 0 0;
}
.edge-decoration-preview-puzzle::before {
  top: 15px;
  border-top: 3px solid #222;
}
.edge-decoration-preview-puzzle::after {
  left: 12px;
  top: 6px;
  width: 12px;
  height: 12px;
  border: 3px solid #9b5aa5;
  border-bottom-color: transparent;
  border-radius: 50%;
}
.edge-decoration-mark {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}
.edge-decoration-arc60 {
  stroke: #2477d4;
  stroke-width: 3.6;
}
.edge-decoration-puzzle {
  stroke: #9b5aa5;
  stroke-width: 3.4;
}

/* Arc Dual icon: curved triangular bubble shape with outward swap arrows. */
.arc-dual-tool-button {
  padding: 3px;
}

.arc-dual-tool-icon {
  width: 28px;
  height: 28px;
  display: block;
  overflow: visible;
}

.menu-svg-icon.arc-dual-tool-icon {
  width: 24px;
  height: 24px;
}

.arc-dual-tool-icon .arc-dual-outer {
  fill: #f6f1e5;
  stroke: #222222;
  stroke-width: 4.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.arc-dual-tool-icon .arc-dual-inner {
  fill: #b28baa;
  stroke: #222222;
  stroke-width: 4.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.arc-dual-tool-icon .arc-dual-arrow {
  fill: none;
  stroke: #e0262e;
  stroke-width: 4.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.arc-dual-tool-icon .arc-dual-arrow-head {
  fill: #e0262e;
  stroke: none;
}


/* Bubble menu and toolbar icons. */
#bubbleToolbar {
  gap: 5px;
}

.bubble-reverse-tool-icon,
.to-bubble-tool-icon,
.to-polygon-tool-icon {
  width: 28px;
  height: 28px;
  display: block;
  overflow: visible;
}

.menu-svg-icon.bubble-reverse-tool-icon,
.menu-svg-icon.to-bubble-tool-icon,
.menu-svg-icon.to-polygon-tool-icon {
  width: 24px;
  height: 24px;
}

.bubble-tool-outer,
.to-bubble-shape {
  fill: #f6b6be;
  stroke: #222222;
  stroke-width: 4.4;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.bubble-tool-outer {
  fill: #f6f1e5;
}

.bubble-tool-inner {
  fill: #b28baa;
  stroke: #222222;
  stroke-width: 4.4;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.bubble-tool-arrow {
  fill: none;
  stroke: #e0262e;
  stroke-width: 4.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bubble-tool-arrow-head {
  fill: #e0262e;
  stroke: none;
}

.to-polygon-shape {
  fill: #f27d86;
  stroke: #222222;
  stroke-width: 4.4;
  stroke-linejoin: round;
}

.to-bubble-tool-button,
.to-polygon-tool-button {
  padding: 3px;
}

#bubbleToolbar .style-dropdown-wrap {
  display: inline-flex;
  align-items: center;
}

#bubbleToolbar .office-style-button {
  height: 34px;
}


/* Clearer Bubble Style toolbar/menu icon and preview swatches. */
.edge-decoration-tool-icon .bubble-style-icon-polygon,
.edge-decoration-tool-icon .bubble-style-icon-arc,
.edge-decoration-tool-icon .bubble-style-icon-puzzle {
  fill: none;
  stroke: #202529;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.edge-decoration-tool-icon .bubble-style-icon-arc {
  stroke: #2477d4;
}
.edge-decoration-tool-icon .bubble-style-icon-puzzle {
  stroke: #8e54d6;
}
.edge-decoration-preview-svg {
  width: 44px;
  height: 30px;
  display: block;
}
.edge-decoration-preview-svg path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.edge-preview-straight,
.edge-preview-chord {
  stroke: #202529;
  stroke-width: 3.5;
}
.edge-preview-slash {
  stroke: #c1121f;
  stroke-width: 3.2;
}
.edge-preview-arc {
  stroke: #2477d4;
  stroke-width: 4.2;
}
.edge-preview-puzzle {
  stroke: #8e54d6;
  stroke-width: 4.2;
}


/* Bubble toolbar reference-image icons. */
.bubble-toolbar-raster-icon {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
  pointer-events: none;
}

.menu-bubble-raster-icon {
  width: 24px;
  height: 24px;
}


/* Help uses the same locked Bubble toolbar raster icons as the Bubble menu/toolbar. */
.help-bubble-raster-icon {
  width: 30px;
  height: 30px;
  object-fit: contain;
  flex: 0 0 30px;
  border-radius: 6px;
}

/* Locked Bubble toolbar icons: preserve these raster-image icons unless John explicitly requests a change. */


/* Bubble Style menu/toolbar preview images. Main Bubble toolbar raster icons are locked; do not modify unless John asks. */
.bubble-style-raster-icon,
.edge-decoration-preview-image {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
}

.style-preview-button .edge-decoration-preview-image {
  width: 42px;
  height: 42px;
}


/* Bubble Style options: two image-only choices, using John's provided icon images without stretching/cropping. */
.edge-decoration-preview-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.edge-decoration-preview-grid .style-preview-button {
  width: 52px;
  height: 52px;
  padding: 3px;
}
.edge-decoration-preview-grid .edge-decoration-preview-image {
  width: 46px;
  height: 46px;
  object-fit: contain;
  display: block;
}
.menu-bubble-raster-icon.bubble-style-raster-icon {
  width: 30px;
  height: 30px;
  object-fit: contain;
}


/* Bubble Style icon hotfix: show John's supplied PNG icons exactly, centered and uncropped. */
.edge-decoration-preview-grid {
  grid-template-columns: repeat(2, 72px) !important;
  gap: 12px !important;
  padding: 10px 12px 12px !important;
  justify-content: center;
}

.edge-decoration-preview-grid .style-preview-button {
  width: 72px !important;
  height: 72px !important;
  padding: 9px !important;
  overflow: visible !important;
}

.edge-decoration-preview-grid .edge-decoration-preview-image {
  width: 100% !important;
  height: 100% !important;
  max-width: 54px !important;
  max-height: 54px !important;
  object-fit: contain !important;
  object-position: center center !important;
  display: block !important;
}


.menu-bubble-raster-icon.bubble-style-raster-icon {
  width: 30px !important;
  height: 30px !important;
  object-fit: contain !important;
  object-position: center center !important;
}


/* Narrow Bubble Style icon hotfix: use the supplied PNG files as-is, but display them at normal toolbar/menu size. */
.edge-decoration-preview-grid {
  grid-template-columns: repeat(2, 44px) !important;
  gap: 8px !important;
  padding: 8px !important;
  justify-content: center !important;
}
.edge-decoration-preview-grid .style-preview-button {
  width: 44px !important;
  height: 44px !important;
  padding: 4px !important;
  overflow: hidden !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.edge-decoration-preview-grid .edge-decoration-preview-image {
  width: 32px !important;
  height: 32px !important;
  max-width: 32px !important;
  max-height: 32px !important;
  object-fit: contain !important;
  object-position: center center !important;
  display: block !important;
}
.menu-bubble-raster-icon.bubble-style-raster-icon {
  width: 22px !important;
  height: 22px !important;
  max-width: 22px !important;
  max-height: 22px !important;
  object-fit: contain !important;
  object-position: center center !important;
}


/* Final Bubble Style icon lock: these two assets are John's supplied images. Display them as normal icons, not stretched preview art. */
.edge-decoration-preview-grid {
  grid-template-columns: repeat(2, 46px) !important;
  gap: 8px !important;
  padding: 8px !important;
  justify-content: center !important;
}
.edge-decoration-preview-grid .style-preview-button {
  width: 46px !important;
  height: 46px !important;
  padding: 5px !important;
  overflow: hidden !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.edge-decoration-preview-grid .edge-decoration-preview-image,
.menu-bubble-raster-icon.bubble-style-raster-icon {
  object-fit: contain !important;
  object-position: center center !important;
  display: block !important;
}
.edge-decoration-preview-grid .edge-decoration-preview-image {
  width: 36px !important;
  height: 36px !important;
  max-width: 36px !important;
  max-height: 36px !important;
}
.menu-bubble-raster-icon.bubble-style-raster-icon {
  width: 24px !important;
  height: 24px !important;
  max-width: 24px !important;
  max-height: 24px !important;
}

/* Bubble Style Spike option: keep John's existing Arc/Puzzle icons locked and add a matching third option. */
.edge-decoration-preview-grid {
  grid-template-columns: repeat(3, 46px) !important;
  gap: 8px !important;
  padding: 8px !important;
  justify-content: center !important;
}
.edge-decoration-preview-grid .style-preview-button {
  width: 46px !important;
  height: 46px !important;
  padding: 5px !important;
}
.edge-decoration-preview-grid .edge-decoration-preview-image {
  width: 36px !important;
  height: 36px !important;
  max-width: 36px !important;
  max-height: 36px !important;
  object-fit: contain !important;
  object-position: center center !important;
}
.menu-bubble-raster-icon.bubble-style-raster-icon {
  width: 24px !important;
  height: 24px !important;
  max-width: 24px !important;
  max-height: 24px !important;
  object-fit: contain !important;
  object-position: center center !important;
}

/* Release refinement: Chrome-style right-aligned keyboard shortcuts in dropdown menus. */
.menu-panel {
  min-width: 255px !important;
}

.menu-panel > button {
  box-sizing: border-box !important;
  display: grid !important;
  grid-template-columns: 28px minmax(110px, 1fr) max-content !important;
  align-items: center !important;
  column-gap: 8px !important;
  width: 100% !important;
}

.menu-panel > button > svg:first-child,
.menu-panel > button > img:first-child,
.menu-panel > button > .menu-item-icon:first-child {
  grid-column: 1 !important;
  justify-self: center !important;
  margin-right: 0 !important;
}

.menu-panel > button > .menu-label,
.menu-panel > button > span:not(.menu-item-icon):not(.menu-shortcut):not(.menu-label) {
  grid-column: 2 !important;
  justify-self: start !important;
  min-width: 0 !important;
  white-space: nowrap !important;
}

.menu-panel > button > .menu-shortcut,
.menu-panel > label.menu-check.has-menu-shortcut > .menu-shortcut {
  grid-column: 3 !important;
  justify-self: end !important;
  color: #667085 !important;
  font-size: 10px !important;
  font-weight: 650 !important;
  line-height: 1 !important;
  white-space: nowrap !important;
  margin-left: 18px !important;
}

.recent-json-section {
  padding: 2px 0 3px;
}

.recent-json-heading {
  padding: 3px 10px 5px;
  color: #667085;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.recent-json-empty {
  padding: 5px 12px 6px 46px;
  color: #8a8f98;
  font-size: 11px;
  font-style: italic;
  white-space: nowrap;
}

#recentJsonFiles > button.recent-json-file {
  box-sizing: border-box !important;
  display: grid !important;
  grid-template-columns: 28px minmax(0, 1fr) !important;
  column-gap: 8px !important;
  width: 100% !important;
}

#recentJsonFiles > button.recent-json-file > .menu-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-panel > label.menu-check.has-menu-shortcut {
  display: grid !important;
  grid-template-columns: 18px 28px minmax(110px, 1fr) max-content !important;
  align-items: center !important;
  column-gap: 8px !important;
  min-width: 100% !important;
  box-sizing: border-box !important;
}

.menu-panel > label.menu-check.has-menu-shortcut > input[type="checkbox"] {
  grid-column: 1 !important;
}

.menu-panel > label.menu-check.has-menu-shortcut > .menu-item-icon:first-of-type {
  grid-column: 2 !important;
  justify-self: center !important;
  margin-right: 0 !important;
}

.menu-panel > label.menu-check.has-menu-shortcut > .menu-label {
  grid-column: 3 !important;
  justify-self: start !important;
  white-space: nowrap !important;
}

/* Help icon alignment: use the same toolbar/menu artwork without changing the toolbar icons. */
.help-toolbar-svg-icon,
.help-overlap-icon,
.help-lattice-clear-icon {
  width: 30px !important;
  height: 30px !important;
  box-sizing: border-box !important;
  padding: 4px !important;
  border-radius: 9px !important;
  background: #f4f7fb !important;
  border: 1px solid #d9e2ef !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 0 0 30px !important;
}

.help-toolbar-svg-icon.zoom-icon {
  padding: 3px !important;
}

.help-toolbar-svg-icon.group-icon {
  padding: 2px !important;
}

.help-toolbar-svg-icon.reflect-icon {
  padding: 3px 2px !important;
}

.help-toolbar-svg-icon.eye-icon,
.help-toolbar-svg-icon.locate-icon {
  padding: 5px !important;
}

.help-overlap-icon .overlap-toolbar-icon,
.help-lattice-clear-icon .lattice-clear-icon {
  margin: 0 !important;
}

.help-bubble-style-menu-icon {
  width: 30px !important;
  height: 30px !important;
  object-fit: contain !important;
  object-position: center center !important;
}


/* Final narrow patch: soft tile tray spacing, robust shortcut alignment, and exact Spike icon display. */
.tray-section[data-tray-set="soft"] .soft-bubble-grid {
  gap: 11px 9px !important;
  padding: 9px !important;
}

.tray-section[data-tray-set="soft"] .soft-bubble-grid .palette-tile {
  min-height: 72px !important;
}

/* Keep keyboard shortcuts right-justified in menu rows without changing the shortcut keys themselves. */
#toolbar .menu-panel {
  min-width: 292px !important;
}

#toolbar .menu-panel > button {
  display: grid !important;
  grid-template-columns: 28px minmax(0, 1fr) max-content !important;
  align-items: center !important;
  column-gap: 8px !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

#toolbar .menu-panel > button > svg:first-child,
#toolbar .menu-panel > button > img:first-child,
#toolbar .menu-panel > button > .menu-item-icon:first-child {
  grid-column: 1 !important;
  justify-self: center !important;
  margin-right: 0 !important;
}

#toolbar .menu-panel > button > .menu-label,
#toolbar .menu-panel > button > span:not(.menu-item-icon):not(.menu-shortcut):not(.menu-label) {
  grid-column: 2 !important;
  justify-self: start !important;
  min-width: 0 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

#toolbar .menu-panel > button > .menu-shortcut {
  grid-column: 3 !important;
  justify-self: end !important;
  margin-left: 20px !important;
  color: #667085 !important;
  font-size: 10px !important;
  font-weight: 650 !important;
  white-space: nowrap !important;
}

#toolbar .menu-panel > label.menu-check.has-menu-shortcut {
  display: grid !important;
  grid-template-columns: 18px 28px minmax(0, 1fr) max-content !important;
  align-items: center !important;
  column-gap: 8px !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

#toolbar .menu-panel > label.menu-check.has-menu-shortcut > input[type="checkbox"] {
  grid-column: 1 !important;
  justify-self: center !important;
  margin: 0 !important;
}

#toolbar .menu-panel > label.menu-check.has-menu-shortcut > .menu-item-icon:first-of-type {
  grid-column: 2 !important;
  justify-self: center !important;
  margin-right: 0 !important;
}

#toolbar .menu-panel > label.menu-check.has-menu-shortcut > .menu-label {
  grid-column: 3 !important;
  justify-self: start !important;
  min-width: 0 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

#toolbar .menu-panel > label.menu-check.has-menu-shortcut > .menu-shortcut {
  grid-column: 4 !important;
  justify-self: end !important;
  margin-left: 20px !important;
  color: #667085 !important;
  font-size: 10px !important;
  font-weight: 650 !important;
  white-space: nowrap !important;
}

/* The Spike Bubble Style icon is now the user's exact exported PNG. Do not regenerate it. */
.edge-decoration-preview-image[src$="bubble-style-spike.png"],
.menu-bubble-raster-icon.bubble-style-raster-icon[src$="bubble-style-spike.png"] {
  object-fit: contain !important;
  object-position: center center !important;
}


/* Final Bubble Style popover layout: keep all four style buttons in one row. */
.edge-decoration-preview-grid {
  grid-template-columns: repeat(4, 46px) !important;
  gap: 8px !important;
  padding: 8px 10px !important;
  justify-content: center !important;
  align-items: center !important;
}
.edge-decoration-preview-grid .style-preview-button {
  width: 46px !important;
  height: 46px !important;
  padding: 5px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.edge-decoration-preview-grid .edge-decoration-preview-image {
  width: 36px !important;
  height: 36px !important;
  max-width: 36px !important;
  max-height: 36px !important;
  object-fit: contain !important;
  object-position: center center !important;
  display: block !important;
}

/* Final toolbar layout: remove legacy negative offsets and give flex rows real separation. */
#toolbar {
  row-gap: 3px !important;
  column-gap: 7px !important;
  padding-top: 4px !important;
  padding-bottom: 5px !important;
  align-items: flex-start !important;
  align-content: flex-start !important;
}

#toolbar .menu-strip {
  margin-bottom: -1px !important;
}

/* The toolbar pseudo-element already creates the menu/toolbar row break. */
.toolbar-row-break {
  display: none !important;
  margin: 0 !important;
}

#toolbar .toolbar-section,
#toolbar .toolbar-section.help-section,
#shortcutsToolbar {
  margin: 0 !important;
  transform: none !important;
}

/* Decompose: John's supplied three-piece SVG, kept legible at toolbar size. */
.decompose-tool-icon {
  width: 23px;
  height: 23px;
  object-fit: contain;
  object-position: center;
}

.menu-bubble-raster-icon.decompose-tool-icon {
  width: 22px;
  height: 22px;
}

.decompose-popover {
  min-width: 218px;
}

.decompose-apply-button {
  width: 100%;
  margin-top: 8px;
}
