/* ForestPDF page workspace. Colours come from the shell's design tokens via
   --pw-* aliases, so a redesigned :root restyles the workspace without edits. */
.pw {
  --pw-ink: var(--ink, #172b38);
  --pw-muted: var(--muted, #657682);
  --pw-accent: var(--accent, #146957);
  --pw-accent-strong: var(--accent-dark, #0b5142);
  --pw-line: var(--line, #dfe7e5);
  --pw-paper: var(--paper, #fff);
  --pw-bg: var(--bg, #f7f9f8);
  --pw-soft: var(--soft, #eaf4ef);
  --pw-danger: var(--danger, #b3261e);
  --pw-focus: var(--focus, #46a68a);
  --pw-part-a: var(--pw-soft);
  --pw-part-b: var(--soft-2, #fdf1dc);
  --pw-radius: 12px;
  margin: 18px 0 8px;
  color: var(--pw-ink);
  text-align: left;
}
.pw-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.pw-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pw-file { display: flex; align-items: center; gap: 8px; border: 1px solid var(--pw-line); border-radius: 999px; padding: 4px 6px 4px 4px; font-size: 13px; background: var(--pw-paper); max-width: 100%; }
.pw-file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22ch; }
.pw-file-info { color: var(--pw-muted); }
.pw-file.pw-error .pw-file-info, .pw-file.pw-locked .pw-file-info { color: var(--pw-danger); }
.pw-swatch { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; background: var(--pw-file-color); flex: none; }
.pw-status { margin: 0; font-size: 13px; color: var(--pw-muted); }
.pw-status.pw-warn, .pw-message { color: var(--pw-danger); }
.pw-message { font-size: 14px; margin: 10px 0 0; }

.pw [data-file="0"] { --pw-file-color: #146957; }
.pw [data-file="1"] { --pw-file-color: #2d5fa8; }
.pw [data-file="2"] { --pw-file-color: #a5522b; }
.pw [data-file="3"] { --pw-file-color: #7a4aa0; }
.pw [data-file="4"] { --pw-file-color: #8a7300; }
.pw [data-file="5"] { --pw-file-color: #b0306a; }

.pw-toolbar, .pw-mode-tools { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 12px; }
.pw-group { display: flex; flex-wrap: wrap; gap: 6px; }
.pw-mode-tools { font-size: 14px; padding: 10px 12px; border-radius: var(--pw-radius); background: var(--pw-bg); border: 1px solid var(--pw-line); }
.pw-mode-tools input[type="number"] { width: 5.5em; padding: 6px 8px; border: 1px solid var(--pw-line); border-radius: 8px; background: var(--pw-paper); color: var(--pw-ink); }
.pw-hint { flex-basis: 100%; margin: 0; color: var(--pw-muted); font-size: 13px; }
.pw-check-label { display: inline-flex; gap: 6px; align-items: center; }
.pw-button {
  min-height: 36px; min-width: 36px; padding: 6px 12px; border-radius: 9px; border: 1px solid var(--pw-line);
  background: var(--pw-paper); color: var(--pw-ink); font-size: 14px; font-weight: 500; line-height: 1.2;
}
.pw-button:hover:not(:disabled) { border-color: var(--pw-accent); color: var(--pw-accent-strong); }
.pw-button:disabled { opacity: .45; cursor: not-allowed; }
.pw-button.pw-danger:hover:not(:disabled) { border-color: var(--pw-danger); color: var(--pw-danger); }
.pw-button:focus-visible, .pw-viewport:focus-visible { outline: 3px solid var(--pw-focus); outline-offset: 2px; }

.pw-viewport {
  position: relative; margin-top: 12px; height: min(68vh, 680px); min-height: 260px; overflow-y: auto; overflow-x: hidden;
  border: 1px solid var(--pw-line); border-radius: var(--pw-radius); background: var(--pw-bg);
  overscroll-behavior: contain; -webkit-user-select: none; user-select: none;
}
.pw-canvas { position: relative; min-height: 100%; }
.pw-cell {
  position: absolute; left: 0; top: 0; width: var(--pw-cell-w); height: var(--pw-cell-h); padding: 6px 8px;
  border-radius: 10px; border: 2px solid transparent; background: transparent; cursor: grab;
  touch-action: pan-y; transition: transform .14s ease, opacity .14s ease; display: flex; flex-direction: column; gap: 4px;
}
.pw-is-dragging .pw-cell { cursor: grabbing; }
.pw-cell:hover { background: var(--pw-paper); }
.pw-cell.pw-active { border-color: var(--pw-line); background: var(--pw-paper); }
.pw-viewport:focus-visible .pw-cell.pw-active { border-color: var(--pw-focus); }
.pw-cell.pw-selected { background: var(--pw-soft); border-color: var(--pw-accent); }
.pw-cell.pw-dragging { opacity: .35; }
.pw-band { font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; border-radius: 6px; padding: 1px 6px; color: var(--pw-muted); background: var(--pw-part-a); align-self: flex-start; }
.pw-cell[data-part="1"] .pw-band { background: var(--pw-part-b); }
.pw-cell.pw-excluded .pw-band { background: transparent; border: 1px dashed var(--pw-muted); }
.pw-frame {
  position: relative; width: var(--pw-thumb); height: var(--pw-frame); display: flex; align-items: center; justify-content: center;
  border-radius: 6px; overflow: hidden; background: var(--pw-paper); box-shadow: 0 1px 3px rgba(0, 0, 0, .12), inset 0 0 0 1px var(--pw-line);
  border-bottom: 3px solid var(--pw-file-color);
}
.pw-frame img { max-width: 100%; max-height: 100%; display: block; pointer-events: none; }
.pw-loading .pw-frame::after {
  content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--pw-line); border-top-color: var(--pw-accent); animation: pw-spin .9s linear infinite;
}
.pw-excluded .pw-frame { opacity: .38; filter: grayscale(1); }
.pw-mark {
  position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; background: var(--pw-accent); opacity: 0; transform: scale(.7); transition: .12s ease;
}
.pw-selected .pw-mark { opacity: 1; transform: none; }
.pw-meta { display: flex; gap: 6px; align-items: baseline; font-size: 12px; color: var(--pw-muted); white-space: nowrap; overflow: hidden; }
.pw-pos { color: var(--pw-ink); font-size: 13px; }
.pw-rot { color: var(--pw-accent-strong); font-weight: 600; }
.pw-cut {
  position: absolute; right: calc(-1 * (7px + 14px)); top: 40%; width: 28px; height: 28px; border-radius: 50%; z-index: 2;
  display: flex; align-items: center; justify-content: center; font-size: 15px; cursor: pointer;
  background: var(--pw-paper); color: var(--pw-muted); border: 1px solid var(--pw-line); opacity: 0; transition: opacity .12s ease;
}
.pw-cell:hover .pw-cut, .pw-cell.pw-active .pw-cut, .pw-cut.pw-on { opacity: 1; }
.pw-cut.pw-on { background: var(--pw-accent); color: #fff; border-color: var(--pw-accent); }
@media (hover: none) { .pw-cut { opacity: .85; } }
.pw-cell.pw-cut-after::after {
  content: ""; position: absolute; top: 4px; bottom: 4px; right: -9px; border-right: 2px dashed var(--pw-accent);
}
.pw-insert { position: absolute; left: 0; top: 0; width: 4px; border-radius: 2px; background: var(--pw-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pw-accent) 25%, transparent); pointer-events: none; z-index: 3; }
.pw-ghost {
  position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; padding: 6px 12px; border-radius: 999px;
  background: var(--pw-ink); color: var(--pw-paper); font-size: 13px; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}
.pw-help { margin-top: 8px; font-size: 13px; color: var(--pw-muted); }
.pw-help summary { cursor: pointer; }
.pw-help p { margin: 6px 0 0; line-height: 1.6; }
.pw-toast {
  display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-top: 10px; padding: 10px 12px;
  border-radius: var(--pw-radius); background: var(--pw-ink); color: var(--pw-paper); font-size: 14px;
}
.pw-toast[hidden] { display: none; }
.pw-toast .pw-button { flex: none; white-space: nowrap; background: transparent; color: inherit; border-color: currentColor; }

/* Hide the typed page fields while the visual workspace drives the plan. */
form.pw-active #pages-field, form.pw-active #angle-field { display: none !important; }

@keyframes pw-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pw-cell, .pw-mark, .pw-cut { transition: none; } .pw-loading .pw-frame::after { animation-duration: 2.5s; } }
@media (max-width: 560px) {
  .pw-toolbar { gap: 6px; }
  .pw-group { gap: 4px; }
  .pw-button { padding: 6px 9px; font-size: 13px; }
  .pw-viewport { height: 62vh; }
}
