    @font-face {
      font-family: 'Chicago';
      src: local('Chicago'), local('Monaco'), local('Courier New');
      font-weight: normal;
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    :root {
      --mac-white: #ffffff;
      --mac-black: #000000;
      --mac-gray-light: #c0c0c0;
      --mac-gray-mid: #808080;
      --mac-gray-dark: #404040;
      --mac-pattern: url("data:image/svg+xml,%3Csvg width='2' height='2' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='0' y='0' width='1' height='1' fill='%23000'/%3E%3Crect x='1' y='1' width='1' height='1' fill='%23000'/%3E%3C/svg%3E");
    }

    html, body {
      height: 100%;
      overflow: hidden;
    }

    body {
      font-family: 'Chicago', 'Monaco', 'Courier New', monospace;
      font-size: 12px;
      background: var(--mac-pattern);
      background-size: 2px 2px;
      display: flex;
      align-items: center;
      justify-content: center;
      user-select: none;
      -webkit-user-select: none;
    }

    /* Mac Window Chrome */
    .mac-window {
      background: var(--mac-white);
      border: 2px solid var(--mac-black);
      box-shadow: 2px 2px 0 var(--mac-black);
      display: flex;
      flex-direction: column;
      width: calc(100vw - 72px);
      height: calc(100vh - 72px);
    }

    /* Title Bar */
    .mac-titlebar {
      background: var(--mac-white);
      border-bottom: 1px solid var(--mac-black);
      height: 20px;
      display: flex;
      align-items: center;
      padding: 0 4px;
      gap: 6px;
    }

    .mac-close-box {
      width: 13px;
      height: 11px;
      border: 1px solid var(--mac-black);
      background: var(--mac-white);
      cursor: pointer;
      flex-shrink: 0;
      display: block;
      text-decoration: none;
    }

    .mac-close-box:hover {
      background: var(--mac-black);
    }

    .mac-title {
      flex: 1;
      text-align: center;
      font-weight: bold;
      font-size: 12px;
      padding: 0 8px;
    }

    .mac-titlebar-stripes {
      flex: 0 0 80px;
      height: 11px;
      background: repeating-linear-gradient(
        to bottom,
        var(--mac-white) 0px,
        var(--mac-white) 1px,
        var(--mac-black) 1px,
        var(--mac-black) 2px
      );
    }

    /* Menu Bar */
    .mac-menubar {
      background: var(--mac-white);
      border-bottom: 1px solid var(--mac-black);
      height: 20px;
      display: flex;
      align-items: center;
      padding: 0 8px;
      gap: 16px;
      font-size: 12px;
      position: relative;
      z-index: 50;
    }

    .mac-menu-item {
      cursor: default;
      padding: 2px 4px;
      position: relative;
    }

    .mac-menu-item:hover {
      background: var(--mac-black);
      color: var(--mac-white);
    }

    .mac-menu-item.menu-open {
      background: var(--mac-black);
      color: var(--mac-white);
    }

    .mac-menu-apple {
      font-size: 14px;
    }

    /* Mac-style dropdown menus */
    .mac-menu-dropdown {
      display: none;
      position: absolute;
      top: 100%;
      left: -4px;
      background: var(--mac-white);
      border: 1px solid var(--mac-black);
      box-shadow: 2px 2px 0 var(--mac-black);
      min-width: 160px;
      z-index: 50;
      color: var(--mac-black);
    }

    .mac-menu-dropdown.open {
      display: block;
    }

    .mac-menu-dropdown-item {
      padding: 3px 16px;
      cursor: default;
      white-space: nowrap;
      font-size: 12px;
    }

    .mac-menu-dropdown-item:hover {
      background: var(--mac-black);
      color: var(--mac-white);
    }

    .mac-menu-dropdown-divider {
      height: 1px;
      background: var(--mac-black);
      margin: 2px 0;
    }

    .mac-menu-dropdown-item .menu-check {
      display: inline-block;
      width: 16px;
      text-align: center;
      margin-left: -14px;
    }

    /* Main Content Area */
    .mac-content {
      display: flex;
      flex: 1;
      min-height: 0;
      background: var(--mac-white);
    }

    /* Toolbox */
    .toolbox {
      width: 100px;
      border-right: 1px solid var(--mac-black);
      padding: 6px;
      display: flex;
      flex-direction: column;
      gap: 3px;
      background: var(--mac-white);
    }

    .tool-row {
      display: flex;
      gap: 3px;
    }

    .tool-btn {
      width: 46px;
      height: 38px;
      border: 1px solid var(--mac-black);
      background: var(--mac-white);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 14px;
      padding: 0;
      color: var(--mac-black);
    }

    .tool-btn:hover {
      background: var(--mac-gray-light);
    }

    .tool-btn.active {
      background: var(--mac-black);
      color: var(--mac-white);
    }

    .tool-btn svg {
      width: 32px;
      height: 26px;
      fill: currentColor;
    }

    .tool-btn svg path,
    .tool-btn svg rect,
    .tool-btn svg circle,
    .tool-btn svg ellipse,
    .tool-btn svg line,
    .tool-btn svg polygon {
      fill: currentColor;
    }

    .tool-btn svg [fill="none"] {
      fill: none;
    }

    .tool-btn svg [stroke="none"] {
      stroke: none;
    }

    .tool-separator {
      height: 1px;
      background: var(--mac-black);
      margin: 4px 0;
    }

    /* Brush size preview */
    .brush-preview {
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 4px;
      border: 1px solid var(--mac-black);
      margin-top: 4px;
    }

    .brush-preview-label {
      font-size: 9px;
      margin-bottom: 4px;
    }

    .brush-sizes {
      display: flex;
      gap: 4px;
    }

    .brush-size {
      border: 1px solid var(--mac-black);
      background: var(--mac-white);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .brush-size.active {
      background: var(--mac-gray-light);
    }

    .brush-size-dot {
      background: var(--mac-black);
      border-radius: 50%;
    }

    /* Canvas Area */
    .canvas-area {
      flex: 1;
      display: flex;
      flex-direction: column;
      background: var(--mac-white);
      min-width: 0;
      min-height: 0;
    }

    .canvas-container {
      position: relative;
      flex: 1;
      overflow: auto;
      background: var(--mac-gray-light);
      /* Flexbox for centering, works with overflow:auto for scrolling */
      display: flex;
      padding: 4px;
      /* Touch: the finger draws — never scrolls or pinches the document.
         Panning stays on the grabber tool, as in the original (story-3).
         Also suppress long-press callout/selection on the canvas stack. */
      touch-action: none;
      -webkit-user-select: none;
      user-select: none;
      -webkit-touch-callout: none;
    }

    .canvas-container canvas {
      touch-action: none;
    }

    /* Tap targets respond immediately (no double-tap-zoom delay) */
    .tool-btn,
    .mac-menu-item,
    .mac-menu-dropdown-item,
    .palette-color,
    .pattern-item,
    .line-width-btn,
    .eraser-size-btn,
    .confirm-dialog-buttons button {
      touch-action: manipulation;
    }

    .canvas-wrapper {
      position: relative;
      background: var(--mac-white);
      box-shadow: 1px 1px 0 var(--mac-black);
      border: 1px solid var(--mac-black);
      /* margin:auto in flex container centers both axes */
      margin: auto;
      /* Prevent shrinking below content size */
      flex-shrink: 0;
    }

    .canvas-layer {
      position: absolute;
      top: 0;
      left: 0;
      image-rendering: pixelated;
      image-rendering: crisp-edges;
    }

    #gridCanvas {
      z-index: 1;
      pointer-events: none;
    }

    #drawingCanvas {
      z-index: 2;
      cursor: crosshair;
    }

    #previewCanvas {
      z-index: 3;
      pointer-events: none;
    }

    /* Palette Panel */
    .palette-panel {
      width: 88px;
      border-left: 1px solid var(--mac-black);
      padding: 6px;
      background: var(--mac-white);
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .palette-section {
      border: 1px solid var(--mac-black);
      padding: 4px;
    }

    .palette-section-title {
      font-size: 9px;
      font-weight: bold;
      margin-bottom: 4px;
      text-align: center;
    }

    /* FG/BG Color Display */
    .color-display {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      padding: 2px;
    }

    .color-stack {
      position: relative;
      width: 32px;
      height: 32px;
    }

    .color-swatch {
      position: absolute;
      width: 22px;
      height: 22px;
      border: 2px solid var(--mac-black);
    }

    .fg-color {
      top: 0;
      left: 0;
      z-index: 2;
    }

    .bg-color {
      bottom: 0;
      right: 0;
      z-index: 1;
    }

    .swap-btn {
      width: 20px;
      height: 20px;
      border: 1px solid var(--mac-black);
      background: var(--mac-white);
      font-size: 10px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 2px;
    }

    .swap-btn:hover {
      background: var(--mac-gray-light);
    }

    .swap-btn:active {
      background: var(--mac-black);
      color: var(--mac-white);
    }

    /* Palette Grid */
    .palette-grid {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 2px;
      padding: 2px;
      background: var(--mac-black);
    }

    .palette-color {
      aspect-ratio: 1;
      cursor: pointer;
      border: none;
      min-width: 14px;
      min-height: 14px;
    }

    .palette-color:hover {
      outline: 2px solid var(--mac-white);
      outline-offset: -2px;
      z-index: 1;
    }

    .palette-color.selected-fg {
      outline: 3px solid var(--mac-black);
      outline-offset: -1px;
      z-index: 2;
    }

    /* Status Bar */
    .status-bar {
      border-top: 1px solid var(--mac-black);
      padding: 4px 8px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
      background: var(--mac-white);
      min-height: 28px;
    }

    .zoom-controls {
      display: flex;
      gap: 1px;
      background: var(--mac-black);
      padding: 1px;
    }

    .zoom-btn {
      padding: 3px 8px;
      border: none;
      background: var(--mac-white);
      cursor: pointer;
      font-family: inherit;
      font-size: 11px;
    }

    .zoom-btn:hover {
      background: var(--mac-gray-light);
    }

    .zoom-btn.active {
      background: var(--mac-black);
      color: var(--mac-white);
    }

    .status-info {
      display: flex;
      gap: 16px;
      font-size: 11px;
      color: var(--mac-black);
    }

    .status-coords {
      min-width: 60px;
    }

    .status-size {
      opacity: 0.7;
    }

    .action-buttons {
      display: flex;
      gap: 6px;
    }

    .mac-btn {
      padding: 4px 14px;
      border: 2px solid var(--mac-black);
      border-radius: 8px;
      background: var(--mac-white);
      cursor: pointer;
      font-family: inherit;
      font-size: 11px;
      font-weight: bold;
    }

    .mac-btn:hover {
      background: var(--mac-gray-light);
    }

    .mac-btn:active {
      background: var(--mac-black);
      color: var(--mac-white);
    }

    .mac-btn:disabled {
      opacity: 0.4;
      cursor: not-allowed;
    }

    .mac-btn.primary {
      background: var(--mac-black);
      color: var(--mac-white);
    }

    .mac-btn.primary:hover {
      background: var(--mac-gray-dark);
    }

    /* Help dialog (Short Cuts - Goodies menu) */
    .help-overlay {
      display: none;
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      z-index: 200;
    }

    .help-overlay.visible {
      display: block;
    }

    .help-window {
      background: var(--mac-white);
      border: 2px solid var(--mac-black);
      box-shadow: 4px 4px 0 var(--mac-black);
      max-width: 400px;
      max-height: calc(100vh - 180px);
      overflow-y: auto;
    }

    .help-titlebar {
      background: var(--mac-white);
      border-bottom: 1px solid var(--mac-black);
      padding: 4px 8px;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .help-close {
      width: 13px;
      height: 11px;
      border: 1px solid var(--mac-black);
      background: var(--mac-white);
      cursor: pointer;
    }

    .help-close:hover {
      background: var(--mac-black);
    }

    .help-title {
      flex: 1;
      font-weight: bold;
      font-size: 12px;
    }

    .help-content {
      padding: 16px;
      font-size: 11px;
      line-height: 1.5;
    }

    .help-section {
      margin-bottom: 12px;
    }

    .help-section h3 {
      font-size: 12px;
      margin-bottom: 6px;
      border-bottom: 1px solid var(--mac-black);
      padding-bottom: 2px;
    }

    .help-shortcuts {
      display: grid;
      grid-template-columns: auto 1fr;
      gap: 4px 12px;
    }

    .help-key {
      font-weight: bold;
      background: var(--mac-gray-light);
      padding: 1px 4px;
      border: 1px solid var(--mac-gray-mid);
      font-size: 10px;
    }

    /* Accessibility */
    .sr-only {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      white-space: nowrap;
      border: 0;
    }

    [role="status"] {
      position: absolute;
      left: -9999px;
    }

    /* Reduced motion */
    @media (prefers-reduced-motion: reduce) {
      * {
        transition: none !important;
        animation: none !important;
      }
    }

    /* Responsive */
    /* Print (File > Print): show only the rendered artwork, not the UI */
    #printContainer { display: none; }
    @media print {
      body > *:not(#printContainer) { display: none !important; }
      #printContainer {
        display: flex !important;
        align-items: center;
        justify-content: center;
      }
      #printContainer img {
        max-width: 100%;
        max-height: 100vh;
        image-rendering: pixelated;
      }
    }

    @media (max-width: 700px) {
      .mac-menubar {
        display: none;
      }

      .toolbox {
        width: 72px;
        padding: 4px;
      }

      .tool-btn {
        width: 32px;
        height: 28px;
      }

      .palette-panel {
        width: 64px;
        padding: 3px;
      }

      .palette-color {
        min-width: 12px;
        min-height: 12px;
      }

      .mac-btn {
        padding: 3px 8px;
        font-size: 10px;
      }

      .mac-menu-dropdown {
        font-size: 10px;
      }
    }

    /* Brush Selector Dialog */
    .brush-selector {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.5);
      z-index: 200;
      align-items: center;
      justify-content: center;
    }

    .brush-selector.visible {
      display: flex;
    }

    .brush-selector-window {
      background: var(--mac-white);
      border: 2px solid var(--mac-black);
      box-shadow: 4px 4px 0 var(--mac-black);
    }

    .brush-selector-titlebar {
      background: var(--mac-white);
      border-bottom: 1px solid var(--mac-black);
      padding: 4px 8px;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .brush-selector-close {
      width: 13px;
      height: 11px;
      border: 1px solid var(--mac-black);
      background: var(--mac-white);
      cursor: pointer;
    }

    .brush-selector-close:hover {
      background: var(--mac-black);
    }

    .brush-selector-title {
      flex: 1;
      font-weight: bold;
      font-size: 12px;
    }

    .brush-selector-content {
      padding: 12px;
    }

    .brush-grid {
      display: grid;
      grid-template-columns: repeat(8, 24px);
      gap: 2px;
    }

    .brush-item {
      width: 24px;
      height: 24px;
      border: 1px solid var(--mac-gray-mid);
      background: var(--mac-white);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .brush-item:hover {
      background: var(--mac-gray-light);
    }

    .brush-item.selected {
      border: 2px solid var(--mac-black);
      background: var(--mac-gray-light);
    }

    .brush-preview {
      background: var(--mac-black);
    }

    /* Mirror Selector Dialog (from MacPaint.p:2040-2074 SymBrush) */
    /* Right-aligned command-key labels in dropdown items (MacPaint menu style) */
    .menu-cmd {
      float: right;
      margin-left: 24px;
      color: inherit;
    }

    .mac-menu-dropdown-item.disabled {
      color: #888;
      pointer-events: none;
    }

    /* New-document confirmation (MacPaint alert style; no window.confirm —
       native dialogs block automation) */
    .confirm-dialog {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.3);
      z-index: 1002;
      align-items: center;
      justify-content: center;
    }

    .confirm-dialog.visible {
      display: flex;
    }

    .confirm-dialog-window {
      background: var(--mac-white);
      border: 2px solid var(--mac-black);
      box-shadow: 2px 2px 0 var(--mac-black);
      min-width: 260px;
      padding: 14px 16px 12px;
      text-align: center;
    }

    .confirm-dialog-message {
      margin-bottom: 14px;
    }

    .confirm-dialog-buttons {
      display: flex;
      gap: 10px;
      justify-content: center;
    }

    .confirm-dialog-buttons button {
      font-family: inherit;
      font-size: inherit;
      background: var(--mac-white);
      border: 1px solid var(--mac-black);
      border-radius: 8px;
      padding: 3px 14px;
      cursor: pointer;
    }

    .confirm-dialog-buttons button.default {
      box-shadow: 0 0 0 2px var(--mac-white), 0 0 0 3px var(--mac-black);
    }

    .mirror-selector {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.3);
      z-index: 1001;
      align-items: center;
      justify-content: center;
    }

    .mirror-selector.visible {
      display: flex;
    }

    .mirror-selector-window {
      background: var(--mac-white);
      border: 2px solid var(--mac-black);
      box-shadow: 2px 2px 0 var(--mac-black);
      min-width: 220px;
    }

    .mirror-selector-titlebar {
      background: var(--mac-white);
      border-bottom: 1px solid var(--mac-black);
      padding: 2px 6px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-weight: bold;
      font-size: 12px;
    }

    .mirror-selector-close {
      width: 11px;
      height: 11px;
      border: 1px solid var(--mac-black);
      background: var(--mac-white);
      cursor: pointer;
    }

    .mirror-selector-close:active {
      background: var(--mac-black);
    }

    .mirror-selector-content {
      padding: 16px;
    }

    .mirror-grid {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    .mirror-item {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 6px 8px;
      border: 1px solid var(--mac-gray-mid);
      background: var(--mac-white);
      cursor: pointer;
      font-size: 11px;
    }

    .mirror-item:hover {
      background: var(--mac-gray-light);
    }

    .mirror-item.selected {
      border: 2px solid var(--mac-black);
      background: var(--mac-gray-light);
    }

    .mirror-preview {
      width: 40px;
      height: 40px;
      border: 1px solid var(--mac-gray-mid);
      background: var(--mac-white);
      flex-shrink: 0;
    }

    .mirror-label {
      flex-grow: 1;
    }

    /* Tool Options Section */
    .tool-options {
      margin-top: auto;
    }

    .tool-options.has-options {
      border-top: 1px solid var(--mac-black);
      padding-top: 4px;
    }

    .tool-option-panel {
      display: none;
    }

    .tool-option-panel.visible {
      display: block;
    }

    .tool-options-label {
      font-size: 9px;
      text-align: center;
      padding: 2px 0;
      color: var(--mac-black);
    }

    /* Pattern Palette (from MacPaint.p:275 patterns array) */
    .pattern-palette {
      margin-top: 2px;
    }

    /* Brush shape preview in tool options */
    .brush-shape-preview {
      width: 32px;
      height: 32px;
      margin: 4px auto;
      border: 1px solid var(--mac-black);
      background: var(--mac-white);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .brush-shape-preview:hover {
      background: var(--mac-gray-light);
    }

    .brush-shape-preview canvas {
      image-rendering: pixelated;
      image-rendering: crisp-edges;
    }

    /* Line width options */
    .line-width-options {
      display: flex;
      flex-direction: column;
      gap: 2px;
      padding: 4px;
    }

    .line-width-btn {
      width: 100%;
      height: 16px;
      border: 1px solid var(--mac-black);
      background: var(--mac-white);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0 4px;
    }

    #fatbitsInset {
      display: none;
      position: fixed;
      top: 84px;
      right: 24px;
      border: 2px solid var(--mac-black);
      background: var(--mac-white);
      box-shadow: 2px 2px 0 var(--mac-black);
      pointer-events: none;
      z-index: 900;
      image-rendering: pixelated;
    }

    .line-preview-none {
      background: repeating-linear-gradient(90deg, var(--mac-gray-dark) 0 2px, transparent 2px 4px) !important;
    }

    .line-width-btn:hover {
      background: var(--mac-gray-light);
    }

    .line-width-btn.active {
      background: var(--mac-black);
    }

    .line-width-btn.active .line-preview {
      background: var(--mac-white);
    }

    .line-preview {
      width: 100%;
      background: var(--mac-black);
    }

    /* Eraser size options */
    .eraser-size-options {
      display: flex;
      justify-content: center;
      gap: 4px;
      padding: 4px;
    }

    .eraser-size-btn {
      width: 24px;
      height: 24px;
      border: 1px solid var(--mac-black);
      background: var(--mac-white);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .eraser-size-btn:hover {
      background: var(--mac-gray-light);
    }

    .eraser-size-btn.active {
      background: var(--mac-gray-light);
      border-width: 2px;
    }

    .eraser-preview {
      background: var(--mac-black);
    }

    .pattern-grid {
      display: grid;
      /* Fit as many fixed 16px swatches as the ~88px toolbox column allows
         (5 across) and wrap the 38 patterns down. repeat(19,1fr) forced a
         304px row that overflowed the narrow container. */
      grid-template-columns: repeat(auto-fill, 16px);
      justify-content: center;
      gap: 0;
      border: 1px solid var(--mac-black);
      width: 100%;
    }

    .pattern-item {
      width: 16px;
      height: 16px;
      border: none;
      padding: 0;
      cursor: pointer;
      background: var(--mac-white);
    }

    .pattern-item:hover {
      outline: 1px solid var(--mac-gray-mid);
      outline-offset: -1px;
    }

    .pattern-item.selected {
      outline: 2px solid var(--mac-black);
      outline-offset: -2px;
      z-index: 1;
    }

    .pattern-row {
      display: contents;
    }

    .pattern-preview {
      width: 16px;
      height: 16px;
      display: block;
      image-rendering: pixelated;
      image-rendering: crisp-edges;
    }

    /* Pattern Editor Dialog */
    .pattern-editor {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.3);
      z-index: 1002;
      align-items: center;
      justify-content: center;
    }

    .pattern-editor.visible {
      display: flex;
    }

    .pattern-editor-window {
      background: var(--mac-white);
      border: 2px solid var(--mac-black);
      box-shadow: 2px 2px 0 var(--mac-black);
      min-width: 200px;
    }

    .pattern-editor-titlebar {
      background: var(--mac-white);
      border-bottom: 1px solid var(--mac-black);
      padding: 2px 6px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-weight: bold;
      font-size: 12px;
    }

    .pattern-editor-close {
      width: 11px;
      height: 11px;
      border: 1px solid var(--mac-black);
      background: var(--mac-white);
      cursor: pointer;
    }

    .pattern-editor-close:active {
      background: var(--mac-black);
    }

    .pattern-editor-content {
      padding: 16px;
      display: flex;
      gap: 16px;
      align-items: flex-start;
    }

    .pattern-edit-grid {
      display: grid;
      grid-template-columns: repeat(8, 12px);
      gap: 0;
      border: 1px solid var(--mac-black);
    }

    .pattern-edit-cell {
      width: 12px;
      height: 12px;
      border: 1px solid var(--mac-gray-mid);
      background: var(--mac-white);
      cursor: pointer;
    }

    .pattern-edit-cell.filled {
      background: var(--mac-black);
    }

    .pattern-edit-preview {
      display: flex;
      flex-direction: column;
      gap: 8px;
      align-items: center;
    }

    .pattern-edit-preview-canvas {
      width: 64px;
      height: 64px;
      border: 1px solid var(--mac-black);
      image-rendering: pixelated;
      image-rendering: crisp-edges;
    }

    .pattern-editor-buttons {
      display: flex;
      gap: 8px;
      margin-top: 12px;
    }

    .pattern-editor-btn {
      padding: 4px 12px;
      border: 1px solid var(--mac-black);
      background: var(--mac-white);
      font-size: 11px;
      cursor: pointer;
    }

    .pattern-editor-btn:active {
      background: var(--mac-gray-light);
    }
