body {
      display: flex;
      flex-direction: column;
      height: 100dvh;
      max-height: 100dvh;
      overflow: hidden;
    }

    /* Header chrome comes from app.css (.app-header) — keep local control styles */
    .controls {
      display: flex;
      align-items: center;
      gap: 12px;
      flex-wrap: wrap;
      min-width: 0;
    }

    #fileInput { display: none; }

    .size-control {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 0.85rem;
      letter-spacing: 0.01em;
      color: var(--muted);
      flex-shrink: 0;
      font-family: var(--font-ui);
    }

    .size-control input[type=range] {
      -webkit-appearance: none;
      appearance: none;
      width: 120px;
      height: 3px;
      background: var(--border);
      border-radius: 2px;
      outline: none;
      cursor: pointer;
    }

    .size-control input[type=range]::-webkit-slider-thumb {
      -webkit-appearance: none;
      width: 14px; height: 14px;
      border-radius: 50%;
      background: var(--accent);
      cursor: pointer;
    }

    #sizeLabel {
      min-width: 42px;
      text-align: right;
      color: var(--cream);
      font-variant-numeric: tabular-nums;
    }

    :root {
      --preview-mobile-bar-height: 48px;
    }

    /* ── Mobile preview bar (File details + Seam) ── */
    .preview-mobile-bar {
      display: none;
      position: fixed;
      left: 0;
      right: 0;
      bottom: calc(var(--studio-tool-tabs-height, 56px) + var(--studio-safe-bottom, 0px));
      z-index: 93;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
      min-height: var(--preview-mobile-bar-height);
      padding: 6px 10px;
      background: color-mix(in srgb, var(--panel-bg) 94%, transparent);
      backdrop-filter: blur(12px);
      border-top: 1px solid var(--border);
      box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    }

    body.preview-active.preview-mobile-ui .preview-mobile-bar {
      display: grid;
    }

    .preview-mobile-details-btn,
    .preview-mobile-seam-btn {
      min-height: 40px;
      width: 100%;
      justify-content: center;
      font-size: 0.82rem;
      font-weight: 650;
      border-radius: 10px;
    }

    .preview-mobile-details-btn {
      background: var(--surface);
      border-color: var(--border);
      color: var(--cream);
    }

    #preview.preview-touch-active {
      touch-action: none;
      cursor: grab;
    }

    #preview.preview-touch-active.preview-touch-dragging {
      cursor: grabbing;
    }

    /* ── Preview canvas ── */
    #preview {
      flex: 1 1 auto;
      min-height: 0;
      background-color: var(--navy);
      position: relative;
      overflow: hidden;
    }

    #previewPaint {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      display: block;
      pointer-events: none;
      z-index: 0;
    }

    /* ── Drop overlay (legacy; chooser replaces empty state) ── */
    #dropOverlay {
      display: none !important;
    }

    body.dragging #preview {
      outline: 2px dashed var(--accent);
      outline-offset: -4px;
    }

    /* ── Preview chooser (idle start) ── */
    body:not(.preview-active) .preview-work-controls,
    body:not(.preview-active) .preview-stage-ui {
      display: none !important;
    }

    body:not(.preview-active) #preview {
      display: none !important;
    }

    body:not(.preview-active) .studio-bottom-dock.preview-dock {
      display: none !important;
    }

    body.preview-active #previewChooser {
      display: none !important;
    }

    body.preview-active {
      background: var(--navy);
    }

    body.preview-active .app-header {
      background: color-mix(in srgb, var(--panel-bg) 88%, transparent);
      backdrop-filter: blur(12px);
    }

    /* Floating stage chrome on the tiled canvas */
    .preview-stage-ui {
      position: absolute;
      inset: 0;
      z-index: 20;
      pointer-events: none;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      padding: 14px 16px 16px;
      gap: 12px;
    }

    .preview-stage-ui > * {
      pointer-events: auto;
    }

    .preview-stage-top {
      display: grid;
      grid-template-columns: minmax(140px, 1fr) auto minmax(140px, 1fr);
      align-items: start;
      gap: 12px;
    }

    .preview-details-block {
      justify-self: start;
      max-width: min(320px, 100%);
    }

    .preview-chip {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      min-height: 36px;
      padding: 0 12px;
      border: 1px solid var(--border);
      border-radius: 999px;
      background: var(--surface);
      box-shadow: var(--shadow-soft);
      color: var(--cream);
      font-family: var(--font-ui);
      font-size: 0.82rem;
      font-weight: 600;
      cursor: pointer;
    }

    html[data-theme="dark"] .preview-chip {
      background: var(--surface-elevated);
    }

    .preview-chip:hover {
      border-color: var(--accent);
    }

    .preview-details-summary {
      margin: 8px 0 0;
      padding: 0 4px;
      color: var(--muted);
      font-family: var(--font-ui);
      font-size: 0.75rem;
      line-height: 1.35;
      text-shadow: 0 1px 2px rgba(0,0,0,0.25);
    }

    html[data-theme="light"] .preview-details-summary {
      text-shadow: none;
    }

    #tileFileInfo {
      position: static;
      margin-top: 10px;
      width: min(300px, calc(100vw - 48px));
    }

    .preview-adjust-section-title {
      margin: 0 0 8px;
      font-family: var(--font-ui);
      font-size: 0.78rem;
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      color: var(--muted);
    }

    .preview-adjust-tile-details-btn {
      width: 100%;
      justify-content: center;
    }

    .preview-adjust-patterns {
      width: 100%;
    }

    .preview-details-backdrop {
      display: none;
    }

    .preview-float-toolbar {
      justify-self: center;
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: center;
      gap: 8px 10px;
      max-width: min(920px, calc(100vw - 32px));
      padding: 8px 10px;
      border: 1px solid var(--border);
      border-radius: 999px;
      /* Solid surface — translucent card-bg vanishes on busy tiles in dark mode */
      background: var(--surface);
      box-shadow: var(--shadow-soft);
      z-index: 25;
    }

    html[data-theme="dark"] .preview-float-toolbar {
      background: var(--surface-elevated);
      box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    }

    .preview-repeat-control {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 0 4px 0 8px;
      color: var(--muted);
      font-family: var(--font-ui);
      font-size: 0.78rem;
      font-weight: 600;
    }

    .preview-repeat-control input[type=range] {
      -webkit-appearance: none;
      appearance: none;
      width: 110px;
      height: 3px;
      background: var(--border);
      border-radius: 2px;
      outline: none;
      cursor: pointer;
    }

    .preview-repeat-control input[type=range]::-webkit-slider-thumb {
      -webkit-appearance: none;
      width: 14px;
      height: 14px;
      border-radius: 50%;
      background: var(--accent);
      cursor: pointer;
    }

    .preview-size-input {
      width: 4.2rem;
      min-height: 32px;
      padding: 0 8px;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: var(--panel-bg);
      color: var(--cream);
      font-family: var(--font-ui);
      font-size: 0.8rem;
      font-variant-numeric: tabular-nums;
      text-align: right;
    }

    .preview-size-input.preview-size-pct {
      width: 3.4rem;
    }

    .preview-size-unit {
      color: var(--muted);
      font-size: 0.75rem;
      margin-right: 2px;
    }

    .preview-size-unit + .preview-size-input {
      margin-left: 4px;
    }

    .preview-layout-presets {
      display: inline-flex;
      gap: 4px;
      padding: 0 4px;
      border-left: 1px solid var(--border);
      border-right: 1px solid var(--border);
    }

    .preview-layout-btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 34px;
      height: 34px;
      border: 1px solid transparent;
      border-radius: 8px;
      background: transparent;
      color: var(--muted);
      cursor: pointer;
    }

    .preview-layout-btn:hover,
    .preview-layout-btn.is-active {
      color: var(--cream);
      border-color: var(--border);
      background: var(--ghost-hover-bg);
    }

    .preview-layout-btn.is-active {
      color: var(--accent);
      border-color: var(--accent);
    }

    .preview-toolbar-btn {
      min-height: 36px;
      gap: 6px;
    }

    .preview-export-btn {
      min-height: 36px;
      text-decoration: none;
    }

    .preview-stage-actions {
      justify-self: end;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .preview-more {
      position: relative;
    }

    .preview-more-btn {
      min-width: 36px;
      justify-content: center;
      letter-spacing: 0.08em;
    }

    .preview-more-menu {
      position: absolute;
      top: calc(100% + 6px);
      right: 0;
      min-width: 160px;
      padding: 6px;
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      background: var(--surface);
      box-shadow: var(--shadow-soft);
      z-index: 30;
    }

    html[data-theme="dark"] .preview-more-menu {
      background: var(--surface-elevated);
    }

    .preview-more-menu button {
      display: block;
      width: 100%;
      padding: 10px 12px;
      border: none;
      border-radius: 8px;
      background: transparent;
      color: var(--cream);
      font-family: var(--font-ui);
      font-size: 0.84rem;
      text-align: left;
      cursor: pointer;
    }

    .preview-more-menu button:hover {
      background: var(--ghost-hover-bg);
    }

    .preview-more-menu button.is-danger {
      color: var(--danger, #b44);
    }

    .preview-stage-bottom {
      display: flex;
      align-items: flex-end;
      justify-content: center;
      gap: 12px;
      position: relative;
    }

    .preview-pattern-strip {
      display: flex;
      align-items: center;
      gap: 10px;
      max-width: min(640px, calc(100vw - 120px));
      padding: 10px 12px;
      border: 1px solid var(--border);
      border-radius: 18px;
      background: color-mix(in srgb, var(--card-bg) 94%, transparent);
      box-shadow: 0 12px 32px rgba(20, 16, 12, 0.14);
    }

    .preview-pattern-count {
      flex: 0 0 auto;
      color: var(--muted);
      font-family: var(--font-ui);
      font-size: 0.72rem;
      font-weight: 600;
      white-space: nowrap;
    }

    .preview-pattern-thumbs {
      display: flex;
      align-items: center;
      gap: 8px;
      overflow-x: auto;
      min-width: 0;
      padding: 2px;
      scrollbar-width: thin;
    }

    .preview-pattern-thumbs:empty + .preview-pattern-add {
      margin-left: 0;
    }

    .preview-pattern-add {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 48px;
      height: 48px;
      flex: 0 0 auto;
      border: 1.5px dashed var(--accent);
      border-radius: 10px;
      color: var(--accent);
      font-size: 1.4rem;
      font-weight: 500;
      cursor: pointer;
      background: var(--panel-bg);
    }

    .preview-pattern-add:hover {
      background: var(--ghost-hover-bg);
    }

    .preview-fullscreen-btn {
      position: absolute;
      right: 0;
      bottom: 0;
      display: inline-flex;
      flex-direction: column;
      align-items: center;
      gap: 6px;
      padding: 0;
      border: none;
      background: transparent;
      color: var(--cream);
      font-family: var(--font-ui);
      font-size: 0.68rem;
      font-weight: 600;
      cursor: pointer;
    }

    .preview-fullscreen-btn svg {
      display: block;
      padding: 10px;
      border: 1px solid var(--border);
      border-radius: 12px;
      background: color-mix(in srgb, var(--card-bg) 94%, transparent);
      box-shadow: 0 8px 24px rgba(20, 16, 12, 0.12);
    }

    .preview-fullscreen-btn span {
      padding: 4px 10px;
      border-radius: 999px;
      background: color-mix(in srgb, var(--accent-contrast, #1a1510) 72%, transparent);
      color: var(--accent-contrast, #faf8f4);
      background: rgba(26, 21, 16, 0.72);
      color: #faf8f4;
    }

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

    @media (max-width: 980px) {
      .preview-stage-top {
        grid-template-columns: 1fr;
        justify-items: stretch;
      }

      .preview-details-block,
      .preview-stage-actions,
      .preview-float-toolbar {
        justify-self: stretch;
      }

      .preview-float-toolbar {
        border-radius: 18px;
      }

      .preview-stage-actions {
        display: flex;
        justify-content: flex-end;
      }

      .preview-fullscreen-btn {
        position: static;
      }

      .preview-stage-bottom {
        flex-wrap: wrap;
        justify-content: center;
      }

      .preview-pattern-strip {
        max-width: 100%;
      }
    }

    #previewChooser {
      flex: 1 1 auto;
      min-height: 0;
      overflow: auto;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: clamp(20px, 4vh, 48px) clamp(16px, 4vw, 40px);
      background: var(--navy);
    }

    .preview-chooser-head {
      text-align: center;
      margin-bottom: 22px;
    }

    .preview-chooser-title {
      margin: 0;
      font-family: var(--font-display);
      font-size: clamp(1.85rem, 3.2vw, 2.55rem);
      font-weight: 600;
      color: var(--cream);
      line-height: 1.1;
    }

    .preview-chooser-copy {
      margin: 10px auto 0;
      max-width: 28rem;
      color: var(--muted);
      font-family: var(--font-ui);
      font-size: 0.98rem;
      line-height: 1.55;
    }

    .preview-chooser-card {
      width: min(100%, 880px);
      padding: 28px 26px 22px;
      border: 1px solid var(--border);
      border-radius: calc(var(--radius) + 4px);
      background: var(--card-bg);
      box-shadow: 0 14px 36px rgba(20, 16, 12, 0.07);
    }

    .preview-chooser-split {
      display: grid;
      grid-template-columns: 1fr auto 1fr;
      gap: 18px;
      align-items: stretch;
    }

    .preview-chooser-pane {
      display: flex;
      flex-direction: column;
      min-width: 0;
      text-align: center;
    }

    .preview-chooser-pane h2 {
      margin: 0 0 14px;
      font-family: var(--font-display);
      font-size: 1.18rem;
      font-weight: 600;
      color: var(--cream);
    }

    .preview-chooser-pane-blurb {
      margin: 12px 0 16px;
      color: var(--muted);
      font-family: var(--font-ui);
      font-size: 0.88rem;
      line-height: 1.45;
    }

    .preview-chooser-thumb-wrap {
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: 168px;
      padding: 14px;
      border: 1px solid var(--border);
      border-radius: var(--radius);
      background:
        repeating-conic-gradient(var(--canvas-check-a) 0% 25%, var(--canvas-check-b) 0% 50%)
        0 0 / 12px 12px;
    }

    .preview-chooser-thumb-wrap img {
      display: block;
      width: min(100%, 160px);
      height: min(100%, 160px);
      object-fit: contain;
      border-radius: var(--radius-sm);
      border: 1px solid var(--border);
      background: var(--card-bg);
    }

    .preview-chooser-empty {
      max-width: 14rem;
      color: var(--muted);
      font-family: var(--font-ui);
      font-size: 0.86rem;
      line-height: 1.45;
    }

    .preview-chooser-or {
      display: flex;
      align-items: center;
      justify-content: center;
      position: relative;
      width: 28px;
    }

    .preview-chooser-or::before {
      content: '';
      position: absolute;
      top: 8%;
      bottom: 8%;
      left: 50%;
      width: 1px;
      background: var(--border);
      transform: translateX(-50%);
    }

    .preview-chooser-or span {
      position: relative;
      z-index: 1;
      padding: 6px 0;
      background: var(--card-bg);
      color: var(--muted);
      font-family: var(--font-ui);
      font-size: 0.78rem;
      font-weight: 600;
    }

    .preview-chooser-drop {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 6px;
      min-height: 168px;
      padding: 24px 18px;
      border: 1.5px dashed var(--accent);
      border-radius: var(--radius);
      background: var(--panel-bg);
      color: var(--cream);
      cursor: pointer;
      text-align: center;
      transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    }

    .preview-chooser-drop:hover,
    .preview-chooser-drop.is-dragover {
      border-color: var(--accent-strong);
      background: var(--ghost-hover-bg);
      box-shadow: inset 0 0 0 1px rgba(154, 123, 82, 0.12);
    }

    .preview-chooser-drop-icon {
      color: var(--accent);
      margin-bottom: 2px;
    }

    .preview-chooser-drop-title {
      font-family: var(--font-ui);
      font-size: 0.92rem;
      font-weight: 600;
    }

    .preview-chooser-drop-meta {
      color: var(--muted);
      font-family: var(--font-ui);
      font-size: 0.74rem;
    }

    .preview-chooser-drop .btn {
      margin-top: 10px;
      min-width: 142px;
      min-height: 40px;
      justify-content: center;
    }

    .preview-chooser-pane .btn-primary {
      width: 100%;
      min-height: 44px;
      justify-content: center;
      margin-top: auto;
    }

    .preview-chooser-foot {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      margin: 20px 0 0;
      padding-top: 16px;
      border-top: 1px solid var(--border);
      color: var(--muted);
      font-family: var(--font-ui);
      font-size: 0.82rem;
      line-height: 1.45;
      text-align: center;
    }

    .preview-chooser-foot svg {
      flex: 0 0 auto;
      color: var(--accent);
      opacity: 0.85;
    }

    .preview-chooser-back {
      margin-top: 22px;
      color: var(--accent);
      font-family: var(--font-ui);
      font-size: 0.9rem;
      text-decoration: none;
    }

    .preview-chooser-back:hover {
      color: var(--cream);
      text-decoration: underline;
      text-underline-offset: 2px;
    }

    @media (max-width: 720px) {
      .preview-chooser-split {
        grid-template-columns: 1fr;
        gap: 16px;
      }

      .preview-chooser-or {
        width: auto;
        height: 28px;
      }

      .preview-chooser-or::before {
        top: 50%;
        bottom: auto;
        left: 8%;
        right: 8%;
        width: auto;
        height: 1px;
        transform: translateY(-50%);
      }
    }

    /* ── History strip (now floating pattern strip) ── */
    #history:empty::before { content: none; }

    .thumb {
      position: relative;
      display: block;
      width: 48px;
      height: 48px;
      padding: 0;
      border-radius: 10px;
      border: 2px solid var(--border);
      cursor: pointer;
      flex-shrink: 0;
      overflow: hidden;
      transition: border-color 0.2s, transform 0.15s, box-shadow 0.15s;
      background: repeating-conic-gradient(var(--canvas-check-a) 0% 25%, var(--canvas-check-b) 0% 50%) 0 0 / 8px 8px;
    }

    .thumb img {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .thumb:hover { border-color: var(--accent); transform: scale(1.04); }

    .thumb.active {
      border-color: var(--accent);
      box-shadow: 0 0 0 2px rgba(154, 123, 82, 0.25);
    }

    .thumb.active::after {
      content: '✓';
      position: absolute;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(26, 21, 16, 0.35);
      color: #fff;
      font-size: 0.95rem;
      font-weight: 700;
      border-radius: 8px;
    }

    /* ── Spinner ── */
    #spinner {
      position: fixed;
      top: 50%; left: 50%;
      transform: translate(-50%, -50%);
      display: none;
      z-index: 200;
    }

    #spinner.visible { display: block; }

    .spinner-ring {
      width: 40px; height: 40px;
      border: 3px solid var(--border);
      border-top-color: var(--accent);
      border-radius: 50%;
      animation: spin 0.7s linear infinite;
    }

    @keyframes spin { to { transform: rotate(360deg); } }

    /* ── Toast ── */
    #toast {
      position: fixed;
      bottom: 84px; left: 50%;
      transform: translateX(-50%) translateY(12px);
      background: var(--accent);
      color: var(--navy);
      padding: 8px 20px;
      border-radius: 20px;
      font-size: 0.78rem;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      opacity: 0;
      transition: opacity 0.3s, transform 0.3s;
      pointer-events: none;
      z-index: 300;
      white-space: nowrap;
      max-width: calc(100vw - 24px);
      overflow: hidden;
      text-overflow: ellipsis;
    }

    #toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

    /* ════════════════════════════════════════════════
       PROOF OVERLAY
    ════════════════════════════════════════════════ */
    #proofOverlay {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 400;
      overflow: hidden;
    }

    #proofOverlay.visible { display: block; }

    /* The tiling surface inside the proof overlay */
    #proofCanvas {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      background-color: var(--navy);
      overflow: hidden;
      touch-action: none;
    }

    #proofPaint {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      display: block;
      pointer-events: none;
    }

    /* Seam guide frame — single clean line */
    #proofBox {
      --seam-frame: #b08a55;
      position: absolute;
      border: 2px solid var(--seam-frame);
      pointer-events: none;
      box-shadow: none;
      outline: none;
      filter: none;
      background: transparent;
      transition: opacity 0.45s ease, border-color 0.2s ease;
    }

    #proofBox.hidden { opacity: 0; }

    /* Auto: pick light or dark frame from tile background */
    #proofOverlay[data-seam-frame="auto"][data-seam-resolved="light"] #proofBox {
      --seam-frame: #2a2420;
    }
    #proofOverlay[data-seam-frame="auto"][data-seam-resolved="dark"] #proofBox {
      --seam-frame: #f5f0e6;
    }
    #proofOverlay[data-seam-frame="auto"]:not([data-seam-resolved]) #proofBox,
    #proofOverlay[data-seam-frame="gold"] #proofBox {
      --seam-frame: #b08a55;
    }

    #proofOverlay[data-seam-frame="light"] #proofBox {
      --seam-frame: #f5f0e6;
    }

    #proofOverlay[data-seam-frame="dark"] #proofBox {
      --seam-frame: #2a2420;
    }

    /* Corner marks removed — kept the frame as one clean stroke for seam QC */

    #proofCrosshair {
      position: absolute;
      width: 24px; height: 24px;
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.4s 0.6s;
    }

    #proofCrosshair.visible { opacity: 1; }

    #proofCrosshair::before,
    #proofCrosshair::after {
      content: '';
      position: absolute;
      background: var(--seam-frame, #b08a55);
      box-shadow: none;
    }

    #proofOverlay[data-seam-frame="auto"][data-seam-resolved="light"] #proofCrosshair::before,
    #proofOverlay[data-seam-frame="auto"][data-seam-resolved="light"] #proofCrosshair::after,
    #proofOverlay[data-seam-frame="dark"] #proofCrosshair::before,
    #proofOverlay[data-seam-frame="dark"] #proofCrosshair::after {
      background: #2a2420;
    }

    #proofOverlay[data-seam-frame="auto"][data-seam-resolved="dark"] #proofCrosshair::before,
    #proofOverlay[data-seam-frame="auto"][data-seam-resolved="dark"] #proofCrosshair::after,
    #proofOverlay[data-seam-frame="light"] #proofCrosshair::before,
    #proofOverlay[data-seam-frame="light"] #proofCrosshair::after {
      background: #f5f0e6;
    }

    #proofOverlay[data-seam-frame="gold"] #proofCrosshair::before,
    #proofOverlay[data-seam-frame="gold"] #proofCrosshair::after,
    #proofOverlay[data-seam-frame="auto"]:not([data-seam-resolved]) #proofCrosshair::before,
    #proofOverlay[data-seam-frame="auto"]:not([data-seam-resolved]) #proofCrosshair::after {
      background: #b08a55;
    }

    #proofCrosshair::before { width: 1px; height: 100%; left: 50%; top: 0; }
    #proofCrosshair::after  { width: 100%; height: 1px; top: 50%; left: 0; }

    #proofVignette { display: none; }

    /* Seam check — one page, top chrome */
    .seam-topbar {
      position: absolute;
      top: max(14px, env(safe-area-inset-top));
      left: 50%;
      transform: translateX(-50%);
      z-index: 12;
      display: none;
      flex-direction: column;
      align-items: stretch;
      gap: 8px;
      width: min(1200px, calc(100vw - 20px));
      padding: 10px 14px;
      border: 1px solid rgba(20, 16, 12, 0.08);
      border-radius: 16px;
      background: rgba(255, 255, 255, 0.94);
      box-shadow: 0 10px 28px rgba(20, 16, 12, 0.14);
      color: #1a1f28;
      font-family: var(--font-ui);
      pointer-events: auto;
    }

    html[data-theme="dark"] .seam-topbar {
      background: rgba(26, 34, 44, 0.94);
      border-color: var(--border);
      color: var(--cream);
      box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    }

    .seam-topbar.visible { display: flex; }

    .seam-topbar,
    .seam-topbar input,
    .seam-topbar button,
    .seam-topbar select {
      touch-action: manipulation;
    }

    .seam-zoom-control input[type=range] {
      touch-action: pan-x;
    }

    .seam-topbar-main,
    .seam-topbar-secondary {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 10px 12px;
      justify-content: center;
      min-width: 0;
    }

    /* Desktop: one compact bar like the seam-check mock */
    @media (min-width: 1025px) {
      .seam-topbar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        gap: 10px 12px;
      }

      .seam-topbar-main,
      .seam-topbar-secondary {
        display: contents;
      }

      .seam-jump-row,
      .seam-mobile-extras-panel {
        display: contents;
      }

      .seam-topbar-brand {
        order: 0;
      }

      .seam-jump-group {
        order: 1;
      }

      .seam-frame-group {
        order: 2;
      }

      .seam-frame-select {
        order: 2;
      }

      .seam-zoom-control {
        order: 3;
      }

      .seam-topbar-actions {
        order: 4;
        margin-left: 4px;
      }
    }

    .seam-topbar-brand {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      font-size: 0.92rem;
      font-weight: 600;
      white-space: nowrap;
      flex-shrink: 0;
    }

    .seam-topbar-brand svg { flex-shrink: 0; opacity: 0.85; }

    .seam-jump-group {
      display: inline-flex;
      flex-wrap: wrap;
      gap: 4px;
      padding: 3px;
      border-radius: 999px;
      background: rgba(20, 16, 12, 0.04);
      flex-shrink: 0;
    }

    html[data-theme="dark"] .seam-jump-group {
      background: rgba(255, 255, 255, 0.06);
    }

    .seam-jump-btn {
      appearance: none;
      border: 1px solid transparent;
      border-radius: 999px;
      background: transparent;
      color: inherit;
      font-family: inherit;
      font-size: 0.78rem;
      font-weight: 500;
      padding: 7px 12px;
      cursor: pointer;
      white-space: nowrap;
      transition: background 0.15s, border-color 0.15s, color 0.15s;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    .seam-label-short { display: none; }

    .seam-jump-btn:hover {
      background: rgba(20, 16, 12, 0.05);
    }

    html[data-theme="dark"] .seam-jump-btn:hover {
      background: rgba(255, 255, 255, 0.08);
    }

    .seam-jump-btn.is-active {
      background: var(--accent);
      border-color: var(--accent);
      color: var(--accent-contrast);
    }

    .seam-frame-select {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      flex-shrink: 0;
      font-size: 0.78rem;
      font-weight: 500;
      color: inherit;
    }

    .seam-frame-select .seam-frame-label {
      padding: 0;
      font-size: 0.72rem;
      font-weight: 600;
      opacity: 0.7;
      white-space: nowrap;
    }

    .seam-frame-select select {
      appearance: auto;
      min-height: 36px;
      min-width: 7.5rem;
      padding: 6px 28px 6px 10px;
      border: 1px solid rgba(20, 16, 12, 0.14);
      border-radius: 10px;
      background: #fff;
      color: #1a1f28;
      font-family: inherit;
      font-size: 0.8rem;
      font-weight: 500;
      cursor: pointer;
    }

    html[data-theme="dark"] .seam-frame-select select {
      background: var(--card-bg);
      border-color: var(--border);
      color: var(--cream);
    }

    .seam-frame-group {
      display: none;
    }

    .seam-zoom-control {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-size: 0.78rem;
      color: inherit;
      opacity: 0.9;
      white-space: nowrap;
      flex-shrink: 0;
    }

    .seam-zoom-control .preview-size-input {
      width: 3.6rem;
      min-height: 28px;
      padding: 0 6px;
      border-color: rgba(20, 16, 12, 0.14);
      background: #fff;
      color: #1a1f28;
      font-size: 0.75rem;
    }

    .seam-zoom-control .preview-size-pct {
      width: 3rem;
    }

    html[data-theme="dark"] .seam-zoom-control .preview-size-input {
      background: var(--card-bg);
      border-color: var(--border);
      color: var(--cream);
    }

    .seam-zoom-control .preview-size-unit {
      margin-right: 0;
      opacity: 0.75;
    }

    .seam-zoom-control input[type=range] {
      -webkit-appearance: none;
      appearance: none;
      width: 88px;
      height: 3px;
      background: rgba(20, 16, 12, 0.15);
      border-radius: 2px;
      outline: none;
      cursor: pointer;
      accent-color: var(--accent);
    }

    html[data-theme="dark"] .seam-zoom-control input[type=range] {
      background: rgba(255, 255, 255, 0.2);
    }

    .seam-zoom-control input[type=range]::-webkit-slider-thumb {
      -webkit-appearance: none;
      width: 12px; height: 12px;
      border-radius: 50%;
      background: var(--accent);
      cursor: pointer;
    }

    .seam-zoom-step {
      appearance: none;
      width: 26px;
      height: 26px;
      border: 1px solid rgba(20, 16, 12, 0.12);
      border-radius: 8px;
      background: #fff;
      color: inherit;
      font-size: 1rem;
      line-height: 1;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    html[data-theme="dark"] .seam-zoom-step {
      background: var(--card-bg);
      border-color: var(--border);
    }

    #proofZoomLabel {
      display: none;
    }

    .seam-topbar-actions {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      margin-left: auto;
    }

    .seam-export-btn {
      background: #fff;
      border-color: var(--accent);
      color: #1a1f28;
    }

    html[data-theme="dark"] .seam-export-btn {
      background: transparent;
      color: var(--cream);
    }

    .seam-tip {
      position: absolute;
      top: calc(max(14px, env(safe-area-inset-top)) + 108px);
      left: 50%;
      transform: translateX(-50%);
      z-index: 13;
      display: flex;
      align-items: flex-start;
      gap: 10px;
      max-width: min(360px, calc(100vw - 32px));
      padding: 10px 12px 10px 14px;
      border-radius: 12px;
      background: rgba(255, 255, 255, 0.96);
      border: 1px solid rgba(20, 16, 12, 0.08);
      box-shadow: 0 8px 22px rgba(20, 16, 12, 0.12);
      color: #1a1f28;
      font-family: var(--font-ui);
      font-size: 0.84rem;
      line-height: 1.35;
    }

    html[data-theme="dark"] .seam-tip {
      background: rgba(26, 34, 44, 0.96);
      border-color: var(--border);
      color: var(--cream);
    }

    .seam-tip[hidden] { display: none !important; }

    .seam-tip p { margin: 0; }

    .seam-tip-close {
      appearance: none;
      border: none;
      background: transparent;
      color: inherit;
      opacity: 0.55;
      font-size: 1.1rem;
      line-height: 1;
      cursor: pointer;
      padding: 0 2px;
      flex-shrink: 0;
    }

    .seam-tip-close:hover { opacity: 1; }

    @media (max-width: 1024px) {
      .seam-topbar {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        transform: none;
        gap: 8px;
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
        border-radius: 16px 16px 0 0;
        width: 100%;
        max-height: none;
        overflow: visible;
        border-left: none;
        border-right: none;
        border-bottom: none;
      }

      .seam-topbar-main {
        display: contents;
      }

      .seam-topbar-secondary {
        order: 2;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
      }

      .seam-topbar-brand {
        display: none;
      }

      .seam-label-full { display: none; }
      .seam-label-short { display: inline; }

      .seam-jump-row {
        order: 1;
        display: flex;
        align-items: stretch;
        gap: 8px;
        width: 100%;
      }

      .seam-jump-group {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        flex: 1 1 auto;
        min-width: 0;
        gap: 6px;
        padding: 4px;
        border-radius: 12px;
        flex-shrink: 0;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
      }

      .seam-jump-group::-webkit-scrollbar {
        display: none;
      }

      .seam-jump-btn {
        flex: 1 1 0;
        min-width: 0;
        min-height: 40px;
        padding: 8px 6px;
        font-size: 0.76rem;
        border-radius: 10px;
      }

      .seam-mobile-extras {
        display: none !important;
      }

      .seam-mobile-extras-panel.seam-mobile-extras {
        order: 3;
        flex-direction: column;
        gap: 8px;
        width: 100%;
      }

      .seam-topbar.seam-mobile-expanded .seam-mobile-extras-panel.seam-mobile-extras {
        display: flex !important;
      }

      .seam-topbar-actions {
        order: 4;
        margin-left: 0;
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        align-items: center;
      }

      .seam-topbar-actions .btn-primary {
        min-height: 44px;
        width: 100%;
        justify-content: center;
      }

      .seam-mobile-more-btn {
        flex: 0 0 auto;
        min-height: 40px;
        min-width: 52px;
        padding: 8px 10px;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        font-size: 0.78rem;
        border-radius: 10px;
      }

      .seam-mobile-extras-panel .seam-frame-select {
        width: 100%;
        justify-content: space-between;
        min-height: 44px;
      }

      .seam-mobile-extras-panel .seam-frame-select select {
        flex: 1 1 auto;
        min-height: 44px;
        font-size: 0.9rem;
      }

      .seam-mobile-extras-panel .seam-export-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
      }

      .seam-zoom-control {
        width: 100%;
        white-space: nowrap;
        flex-wrap: nowrap;
        gap: 8px;
        justify-content: stretch;
        align-items: center;
      }

      .seam-zoom-control > span:first-of-type {
        width: auto;
        flex: 0 0 auto;
        font-weight: 600;
        opacity: 0.75;
        font-size: 0.72rem;
      }

      .seam-zoom-control .preview-size-input,
      .seam-zoom-control .preview-size-unit {
        display: none !important;
      }

      .seam-zoom-control input[type=range] {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
        min-height: 36px;
        touch-action: pan-x;
      }

      .seam-zoom-step {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        flex-shrink: 0;
      }

      .seam-tip {
        top: max(12px, env(safe-area-inset-top));
        bottom: auto;
        left: 50%;
        transform: translateX(-50%);
        max-width: min(340px, calc(100vw - 24px));
      }
    }

    /* Keep the preview dock out of the way while seam checking */
    body.seam-check-open .preview-dock,
    body:has(#proofOverlay.visible) .preview-dock {
      display: none !important;
    }

    /* File / quality info — main preview + seam check */
    .file-info-panel {
      width: min(300px, calc(100vw - 40px));
      padding: 14px 16px 12px;
      border: 1px solid var(--border);
      border-radius: 2px;
      background: var(--panel-bg);
      backdrop-filter: blur(16px) saturate(1.05);
      -webkit-backdrop-filter: blur(16px) saturate(1.05);
      color: var(--cream);
      opacity: 0;
      pointer-events: none;
      transform: translateY(8px);
      transition: opacity 0.35s ease, transform 0.35s ease;
      box-shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
    }

    .file-info-panel.visible {
      opacity: 1;
      pointer-events: auto;
      transform: translateY(0);
    }

    .file-info-panel .proof-info-kicker {
      font-size: 0.65rem;
      letter-spacing: 0.16em;
      text-transform: uppercase;
      color: var(--accent);
      margin: 0 0 6px;
    }

    .file-info-panel .proof-info-title {
      font-family: Georgia, 'Times New Roman', serif;
      font-size: 1.05rem;
      font-weight: 500;
      margin: 0 0 12px;
      line-height: 1.25;
      color: var(--cream);
    }

    .file-info-panel .proof-info-body {
      margin: 0 0 4px;
      padding-right: 4px;
      /* Expand to fit content; only scroll when the viewport is short */
      max-height: none;
      overflow-y: visible;
    }

    /* Short screens: cap height so the panel doesn’t eat the whole preview */
    @media (max-height: 780px) {
      .file-info-panel .proof-info-body {
        max-height: min(52vh, 420px);
        overflow-y: auto;
      }
    }

    @media (max-height: 560px) {
      .file-info-panel .proof-info-body {
        max-height: 36vh;
        overflow-y: auto;
      }
    }

    .file-info-panel dl {
      display: grid;
      grid-template-columns: auto 1fr;
      gap: 5px 10px;
      margin: 0 0 12px;
      font-size: 0.78rem;
      line-height: 1.35;
    }

    .file-info-panel dt {
      color: var(--accent);
      letter-spacing: 0.04em;
    }

    .file-info-panel dd {
      margin: 0;
      color: var(--cream);
      word-break: break-word;
      white-space: pre-wrap;
    }

    .file-info-panel dt.is-low,
    .file-info-panel dd.is-low {
      color: #e8a0ad;
    }

    .file-info-panel dt.is-bad,
    .file-info-panel dd.is-bad {
      color: #ff8a9a;
      font-weight: 600;
    }

    html[data-theme="light"] .file-info-panel dt.is-low,
    html[data-theme="light"] .file-info-panel dd.is-low {
      color: #a33d4e;
    }

    html[data-theme="light"] .file-info-panel dt.is-bad,
    html[data-theme="light"] .file-info-panel dd.is-bad {
      color: #8b1e2d;
    }

    .file-info-panel dd.truncated {
      display: -webkit-box;
      -webkit-line-clamp: 4;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    .file-info-panel .proof-info-flags {
      list-style: none;
      margin: 0;
      padding: 0;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .file-info-panel .proof-info-flags li {
      font-size: 0.74rem;
      line-height: 1.4;
      padding: 7px 9px;
      border: 1px solid var(--border);
      background: var(--card-bg);
    }

    .file-info-panel .proof-info-flags li.ok {
      border-color: rgba(120, 170, 120, 0.45);
      color: #b8d4b8;
    }

    .file-info-panel .proof-info-flags li.warn {
      border-color: rgba(224, 184, 78, 0.55);
      color: var(--tile-outline);
    }

    .file-info-panel .proof-info-flags li.bad {
      border-color: rgba(200, 90, 110, 0.55);
      color: #e8a0ad;
    }

    .file-info-panel .proof-info-flags li.note {
      color: var(--accent);
    }

    html[data-theme="light"] .file-info-panel .proof-info-flags li.ok { color: #2f6b3a; }
    html[data-theme="light"] .file-info-panel .proof-info-flags li.bad { color: #a33d4e; }

    #tileFileInfo {
      /* Positioned in the floating details block */
      z-index: 5;
    }

    #tileFileInfo .file-info-cta {
      margin-top: 10px;
      font-size: 0.72rem;
      letter-spacing: 0.06em;
      color: var(--accent);
      line-height: 1.4;
    }

    #proofBtn.has-warn {
      border-color: var(--tile-outline);
      color: var(--tile-outline);
    }

    #proofBtn.has-bad {
      border-color: #e8a0ad;
      color: #e8a0ad;
    }

    @media (max-width: 560px) {
      .size-control span:first-child {
        display: none;
      }
      .size-control input[type=range] {
        width: 72px;
      }
    }

    @media (min-width: 1025px) {
      body.preview-active .preview-stage-ui {
        position: relative;
      }

      body.preview-active .preview-adjust-patterns {
        position: absolute;
        left: 16px;
        right: 96px;
        bottom: 16px;
        z-index: 22;
        pointer-events: auto;
      }

      body.preview-active .preview-adjust-patterns .preview-pattern-strip {
        max-width: min(640px, calc(100vw - 140px));
      }

      body.preview-active #tileFileInfo.file-info-panel.visible {
        position: absolute;
        top: 48px;
        left: 16px;
        z-index: 30;
        margin-top: 0;
      }
    }

    #proofCanvas {
      cursor: zoom-in;
    }

    #proofCanvas.zoomed { cursor: grab; }
    #proofCanvas.dragging { cursor: grabbing; }

    /* ── Adjust panel / toolbar split (desktop default) ── */
    .preview-adjust-panel {
      display: contents;
    }

    .preview-toolbar-actions {
      display: contents;
    }

    .preview-adjust-title {
      display: none;
    }

    .preview-adjust-extras {
      display: inline-flex;
      align-items: center;
      gap: 8px;
    }

    .preview-compact-only {
      display: none !important;
    }

    .preview-desktop-only {
      display: inline-flex;
    }

    .preview-adjust-backdrop {
      display: none;
    }

    /* ── Compact Preview — mobile-native (≤1024) ── */
    @media (max-width: 1024px) {
      .preview-compact-only {
        display: block !important;
      }

      .preview-adjust-extras .preview-compact-only {
        display: inline-flex !important;
      }

      .preview-desktop-only {
        display: none !important;
      }

      /* Hide legacy adjust sheet + preview rail — replaced by mobile bar */
      body.preview-active .studio-bottom-dock.preview-dock {
        display: none !important;
      }

      body.preview-active.preview-mobile-ui {
        padding-bottom: calc(
          var(--studio-tool-tabs-height, 56px) +
          var(--preview-mobile-bar-height, 48px) +
          var(--studio-safe-bottom, 0px)
        ) !important;
      }

      body.preview-active.preview-mobile-ui #preview {
        padding-bottom: 0;
      }

      body.preview-active .preview-adjust-panel,
      body.preview-active.preview-adjust-open .preview-adjust-panel,
      body.preview-active .preview-adjust-backdrop {
        display: none !important;
      }

      body.seam-check-open .preview-mobile-bar {
        display: none !important;
      }

      /* preview-compact-only sets display:block — keep action bar side-by-side */
      body.preview-active.preview-mobile-ui .preview-mobile-bar.preview-compact-only {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        align-items: stretch;
      }

      .preview-mobile-bar .preview-mobile-details-btn,
      .preview-mobile-bar .preview-mobile-seam-btn {
        display: inline-flex !important;
        align-items: center;
      }

      /* Canvas owns the viewport — hide floats, keep sheet hosts alive */
      body.preview-active .preview-stage-ui {
        padding: 0;
        pointer-events: none;
      }

      body.preview-active .preview-stage-top {
        display: block;
        height: 0;
        overflow: visible;
        padding: 0;
        margin: 0;
      }

      body.preview-active .preview-details-block,
      body.preview-active .preview-stage-bottom {
        display: none !important;
      }

      body.preview-active .preview-float-toolbar {
        display: block;
        height: 0;
        overflow: visible;
        padding: 0;
        margin: 0;
        border: none;
        background: transparent;
        box-shadow: none;
      }

      body.preview-active .preview-toolbar-actions {
        display: none !important;
      }

      body.preview-active #previewFullscreenBtn,
      body.preview-active .preview-fullscreen-btn {
        display: none !important;
      }

      /* Sheets re-enable pointer events */
      body.preview-active .preview-adjust-panel,
      body.preview-active #tileFileInfo.file-info-panel.visible,
      body.preview-active .preview-adjust-backdrop:not([hidden]),
      body.preview-active .preview-details-backdrop:not([hidden]) {
        pointer-events: auto;
      }

      body.preview-active .preview-adjust-panel {
        display: none;
        position: fixed;
        left: 0;
        right: 0;
        bottom: calc(var(--studio-dock-height, 108px) + var(--studio-safe-bottom, 0px));
        z-index: 95;
        flex-direction: column;
        gap: 10px;
        max-height: min(42vh, calc(100dvh - var(--studio-chrome-top, 52px) - var(--studio-dock-height, 108px) - 96px));
        margin: 0;
        padding: 0 14px 16px;
        border-radius: var(--radius, 12px) var(--radius, 12px) 0 0;
        border: 1px solid var(--border);
        border-bottom: none;
        background: var(--panel-bg);
        box-shadow: var(--shadow-soft);
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        pointer-events: auto;
      }

      body.preview-active.preview-adjust-open .preview-adjust-panel {
        display: flex;
      }

      body.preview-active .preview-adjust-title {
        display: block;
        margin: 0;
        padding: 4px 0 0;
        font-family: var(--font-display, Georgia, serif);
        font-size: 1.2rem;
        font-weight: 600;
        color: var(--cream);
      }

      body.preview-active .preview-adjust-live-hint {
        margin: 0;
        font-size: 0.78rem;
        line-height: 1.35;
        color: var(--muted);
      }

      body.preview-active .preview-adjust-panel .studio-drawer-close {
        display: block;
        width: calc(100% + 28px);
        flex-shrink: 0;
        margin: 0 -14px;
        padding: 12px 14px;
        border: none;
        border-bottom: 1px solid var(--border);
        background: var(--card-bg, var(--surface));
        color: var(--cream);
        font-family: var(--font-ui);
        font-size: 0.85rem;
        font-weight: 600;
        text-align: right;
        cursor: pointer;
      }

      body.preview-active .preview-repeat-control {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
        gap: 10px;
        padding: 4px 0;
      }

      body.preview-active .preview-repeat-control input[type="range"] {
        flex: 1 1 100%;
        width: 100%;
        min-width: 0;
      }

      body.preview-active .preview-layout-presets {
        justify-content: flex-start;
      }

      body.preview-active .preview-adjust-patterns .preview-pattern-strip {
        max-width: none;
        width: 100%;
        box-shadow: none;
        border-radius: var(--radius-sm);
        padding: 8px 10px;
      }

      body.preview-active .preview-adjust-extras {
        display: flex;
        width: 100%;
        justify-content: space-between;
        align-items: center;
        padding-top: 4px;
        gap: 8px;
      }

      body.preview-active .preview-adjust-backdrop:not([hidden]),
      body.preview-active .preview-details-backdrop:not([hidden]) {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 94;
        border: none;
        margin: 0;
        padding: 0;
        background: var(--gate-scrim, rgba(0, 0, 0, 0.45));
        opacity: 0.22;
        cursor: pointer;
        pointer-events: auto;
      }

      body.preview-active #preview {
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
      }

      body.preview-active #studioViewPreview {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
      }

      /* Tile details sheet */
      body.preview-active #tileFileInfo.file-info-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: calc(var(--studio-dock-height, 108px) + var(--studio-safe-bottom, 0px));
        z-index: 96;
        width: auto;
        max-width: none;
        max-height: min(50vh, calc(100dvh - var(--studio-chrome-top, 52px) - var(--studio-dock-height, 108px) - 80px));
        margin: 0;
        padding: 14px 16px 16px;
        border-radius: var(--radius, 12px) var(--radius, 12px) 0 0;
        border: 1px solid var(--border);
        border-bottom: none;
        background: var(--panel-bg);
        overflow-y: auto;
        transform: none;
        opacity: 0;
        pointer-events: none;
      }

      body.preview-active #tileFileInfo.file-info-panel.visible {
        opacity: 1;
        pointer-events: auto;
      }

      body.preview-active #tileFileInfo .studio-drawer-close {
        display: block;
        width: calc(100% + 32px);
        margin: -14px -16px 12px;
        padding: 12px 14px;
        border: none;
        border-bottom: 1px solid var(--border);
        background: var(--card-bg, var(--surface));
        color: var(--cream);
        font-family: var(--font-ui);
        font-size: 0.85rem;
        font-weight: 600;
        text-align: right;
        cursor: pointer;
      }

      /* Slimmer Preview panel rail — icon + label */
      body[data-studio-step="preview"].preview-active .studio-bottom-dock.preview-dock {
        gap: 4px;
        padding: 6px 8px 6px;
        min-height: var(--studio-panel-rail-height, 48px);
      }

      body[data-studio-step="preview"].preview-active .studio-bottom-dock.preview-dock .studio-dock-btn {
        flex-direction: column;
        gap: 2px;
        min-height: 44px;
        padding: 6px 8px;
        font-size: 0.72rem;
        font-weight: 650;
        letter-spacing: 0.02em;
      }

      /* Immersive seam — hide dual chrome */
      body.seam-check-open .studio-tool-tabs,
      body.seam-check-open .preview-stage-ui,
      body.seam-check-open .preview-adjust-backdrop,
      body.seam-check-open .preview-details-backdrop {
        display: none !important;
      }

      body.seam-check-open {
        padding-bottom: 0 !important;
      }

      /* Chooser compact polish */
      .preview-chooser {
        padding: 16px 14px calc(24px + var(--studio-tool-tabs-height, 56px) + var(--studio-safe-bottom, 0px));
        justify-content: flex-start;
      }

      .preview-chooser-card {
        width: 100%;
        max-width: 440px;
      }

      .preview-chooser-split {
        flex-direction: column;
        gap: 16px;
      }

      .preview-chooser-or {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        margin: 0;
      }

      .preview-chooser-or::before,
      .preview-chooser-or::after {
        content: '';
        flex: 1;
        height: 1px;
        background: var(--border);
      }

      .preview-chooser-or span {
        padding: 0 10px;
      }

      .preview-chooser-back {
        margin-top: 16px;
        font-size: 0.9rem;
        font-weight: 600;
        color: var(--accent);
        text-decoration: none;
      }

      .preview-chooser-pane-primary .btn-primary {
        width: 100%;
        justify-content: center;
      }
    }
