/* Image tools (P2): shared stage, file rows, layouts, swatches and readouts. */
.p2im { position: relative; min-width: 0; }
.p2im [hidden] { display: none !important; }
.p2im-hint { margin: 0; color: var(--text-3); font-size: 0.85rem; }
.p2im-kicker { margin: 0; font-weight: 650; }
.p2im-stage { display: flex; justify-content: center; max-width: 100%; min-width: 0; }
.p2im-stage canvas,
.p2im-loupe {
  display: block;
  max-width: 100%;
  height: auto;
  background:
    repeating-conic-gradient(var(--bg-2) 0% 25%, var(--bg) 0% 50%) 50% / 16px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  touch-action: none;
  user-select: none;
}
.p2im-stage canvas { max-height: 70vh; width: auto; cursor: crosshair; }
.p2im-files { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; min-width: 0; }
.p2im-files:empty { display: none; }
.p2im-file {
  display: flex; flex-wrap: wrap; gap: 0.4rem 0.6rem; align-items: center;
  padding: 0.4rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg);
  min-width: 0;
}
.p2im-file img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; background: var(--bg-2); flex: none; }
.p2im-name { flex: 1 1 8rem; min-width: 0; overflow-wrap: anywhere; font-size: 0.85rem; }
.p2im-out { display: flex; flex-wrap: wrap; gap: 0.5rem; min-width: 0; }
.p2im-out a { min-height: 44px; max-width: 100%; overflow-wrap: anywhere; text-align: center; }
.p2im-layouts { display: flex; flex-wrap: wrap; gap: 6px; }
.p2im-lay, .p2im-mini {
  min-width: 44px; min-height: 44px; padding: 4px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); cursor: pointer;
}
.p2im-lay[aria-pressed="true"], .p2im-mini[aria-pressed="true"] { border-color: var(--accent); outline: 2px solid var(--accent); }
.p2im-lay svg { width: 36px; height: 36px; display: block; }
.p2im-lay svg rect { fill: var(--text-3); }
.p2im-pos { display: grid; grid-template-columns: repeat(3, 44px); gap: 4px; }
.p2im-pos .p2im-mini { padding: 0; font-size: 0.72rem; line-height: 1.1; }
.p2im-pal { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 8px; min-width: 0; }
.p2im-sw {
  display: flex; flex-direction: column; justify-content: space-between; min-height: 132px;
  border-radius: 12px; padding: 8px; border: 1px solid var(--border); min-width: 0;
}
.p2im-sw button {
  min-height: 44px; border: 0; background: transparent; color: inherit; font: inherit; font-weight: 650;
  cursor: pointer; text-align: left; padding: 0;
}
.p2im-read { margin: 0; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.p2im-meta { margin: 0; color: var(--text-2); overflow-wrap: anywhere; }
.p2im-pick { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; min-width: 0; }
.p2im-sample { width: 64px; height: 64px; border-radius: 12px; border: 1px solid var(--border); flex: none; }
.p2im-loupe { width: 96px; height: 96px; border-radius: 12px; image-rendering: pixelated; flex: none; }
.p2im-chip { display: flex; flex-wrap: wrap; gap: 8px; }
.p2im-chip button {
  min-height: 44px; border-radius: 10px; border: 1px solid var(--border); padding: 0.35rem 0.7rem;
  font: inherit; cursor: pointer; color: inherit;
}
.p2im-sr {
  position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important;
  margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important; border: 0 !important;
}
.p2im-table { overflow-x: auto; max-width: 100%; min-width: 0; }
.p2im-dpi { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.p2im-dpi th, .p2im-dpi td {
  text-align: left; padding: 0.35rem 0.4rem; border-bottom: 1px solid var(--border);
  vertical-align: top; overflow-wrap: anywhere;
}
.p2im textarea[data-out] { min-height: 8rem; }
@media (max-width: 420px) {
  .p2im-file .btn { flex: 1 1 calc(50% - 0.6rem); }
  .p2im-pos { grid-template-columns: repeat(3, minmax(44px, 1fr)); }
  .p2im-pal { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
