.selected-file-card {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  gap: 10px;
  align-items: center;
  margin-top: 17px;
  padding: 12px;
  border: 1px solid var(--ink);
  background: rgba(205, 206, 201, .68);
}

.selected-file-info { min-width: 0; }
.selected-file-info strong { display: block; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.selected-file-info > span { display: block; margin-top: 4px; color: var(--muted); font-family: "DM Mono", monospace; font-size: 8px; }
.selected-file-card > button { width: 32px; height: 32px; padding: 0; border: 1px solid var(--line); background: transparent; font-family: "DM Mono", monospace; font-size: 17px; cursor: pointer; }
.selected-file-card > button:hover { border-color: var(--ink); background: var(--ink); color: var(--white); }

.preview-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 21px;
}

.preview-heading h2 { margin: 0; font-family: "DM Mono", monospace; font-size: 10px; letter-spacing: .08em; }
.preview-heading p { margin: 5px 0 0; color: var(--muted); font-size: 8px; line-height: 1.5; }
.preview-heading > span { flex: 0 0 auto; color: var(--muted); font-family: "DM Mono", monospace; font-size: 8px; }

.preview-actions { display: grid; grid-template-columns: 1fr 1fr; margin-top: 10px; border: 1px solid var(--ink); }
.preview-actions button { min-height: 34px; border: 0; background: transparent; color: var(--muted); font-family: "DM Mono", monospace; font-size: 8px; cursor: pointer; }
.preview-actions button + button { border-left: 1px solid var(--ink); }
.preview-actions button:hover { background: var(--ink); color: var(--white); }

.page-preview { margin-top: 13px; padding: 10px; border: 1px solid var(--ink); background: rgba(17, 18, 16, .055); }
.page-row { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }
.page-row + .page-row { margin-top: 0; }
.page-tile { min-width: 0; margin: 0; }
.page-paper { position: relative; min-height: 105px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); background: #e3e3df; cursor: zoom-in; }
.page-paper canvas { display: block; max-width: 100%; height: auto; background: white; }
.page-paper:hover, .page-paper:focus-visible { border-color: var(--ink); outline: 2px solid var(--ink); outline-offset: 2px; }
.page-paper::after { content: "ENLARGE"; position: absolute; right: 4px; bottom: 4px; padding: 3px 4px; border: 1px solid var(--ink); background: rgba(227,227,223,.92); color: var(--ink); font: 5px "DM Mono", monospace; letter-spacing: .04em; opacity: 0; transition: opacity .15s ease; }
.page-paper:hover::after, .page-paper:focus-visible::after { opacity: 1; }
.page-loading { padding: 6px; color: #858681; font-family: "DM Mono", monospace; font-size: 6px; letter-spacing: .04em; text-align: center; }
.page-label { display: block; margin-top: 5px; color: var(--muted); font-family: "DM Mono", monospace; font-size: 7px; text-align: center; }

.cut-control { position: relative; padding: 0; display: flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.cut-control::before { content: ""; position: absolute; background: var(--line); }
.cut-control span { position: relative; z-index: 1; border: 1px solid var(--line); background: #c3c4bf; font-family: "DM Mono", monospace; font-size: 6px; letter-spacing: .02em; text-align: center; white-space: nowrap; }
.cut-control:hover span,
.cut-control.active span { border-color: var(--ink); background: var(--ink); color: var(--white); }
.cut-control.active span::before { content: "✓ "; }

.cut-control.vertical { position: absolute; top: 0; bottom: 17px; z-index: 2; width: 18px; transform: translateX(-50%); }
.cut-control.vertical.slot-1 { left: 33.333%; }
.cut-control.vertical.slot-2 { left: 66.666%; }
.cut-control.vertical::before { top: 0; bottom: 0; left: 50%; width: 1px; }
.cut-control.vertical:hover::before,
.cut-control.vertical.active::before { width: 2px; background: var(--ink); }
.cut-control.vertical span { padding: 6px 3px; writing-mode: vertical-rl; }

.cut-control.between-rows { width: 100%; height: 42px; margin: 2px 0; }
.cut-control.between-rows::before { left: 0; right: 0; height: 1px; }
.cut-control.between-rows:hover::before,
.cut-control.between-rows.active::before { height: 2px; background: var(--ink); }
.cut-control.between-rows span { padding: 5px 9px; }

.edge-boundary { position: relative; height: 28px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-family: "DM Mono", monospace; font-size: 6px; letter-spacing: .08em; }
.edge-boundary::before { content: ""; position: absolute; left: 0; right: 0; height: 1px; background: var(--ink); }
.edge-boundary span { position: relative; padding: 3px 7px; background: #bfc0bb; }
.edge-boundary.start { margin-bottom: 9px; }
.edge-boundary.end { margin-top: 9px; }

.split-card .merge-status { margin-top: 19px; }
.single-page-notice {
  margin: 20px 0 28px;
  padding: 18px 20px;
  border: 2px solid var(--ink);
  background: #e5c85b;
  color: var(--ink);
}
.single-page-notice[hidden] { display: none; }
.single-page-notice span {
  display: block;
  margin-bottom: 7px;
  font: 500 8px "DM Mono", monospace;
  letter-spacing: .12em;
}
.single-page-notice strong {
  display: block;
  font: 700 13px/1.45 "DM Mono", monospace;
  letter-spacing: .025em;
}

body.preview-open { overflow: hidden; }
.pdf-preview-modal[hidden] { display: none; }
.pdf-preview-modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 14px; }
.pdf-preview-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(17, 18, 16, .78); cursor: zoom-out; }
.pdf-preview-dialog { position: relative; width: min(1120px, 100%); height: min(92vh, 920px); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; border: 1px solid var(--ink); background: #bfc0bb; box-shadow: 0 24px 80px rgba(0, 0, 0, .38); }
.pdf-preview-toolbar { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 13px; border-bottom: 1px solid var(--ink); }
.pdf-preview-toolbar div { min-width: 0; }
.pdf-preview-toolbar span { display: block; color: var(--muted); font: 7px "DM Mono", monospace; letter-spacing: .08em; }
.pdf-preview-toolbar strong { display: block; margin-top: 3px; font: 11px "DM Mono", monospace; letter-spacing: .05em; }
.pdf-preview-close { min-height: 32px; padding: 0 10px; border: 1px solid var(--ink); background: transparent; font: 8px "DM Mono", monospace; cursor: pointer; }
.pdf-preview-close:hover, .pdf-preview-close:focus-visible { background: var(--ink); color: var(--white); }
.pdf-preview-stage { position: relative; min-height: 0; overflow: auto; padding: 22px; display: grid; place-items: start center; background: #777873; overscroll-behavior: contain; }
.pdf-preview-stage canvas { display: block; max-width: none; background: white; box-shadow: 0 6px 24px rgba(0, 0, 0, .28); }
.pdf-preview-loading { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--white); background: rgba(119, 120, 115, .92); font: 9px "DM Mono", monospace; letter-spacing: .08em; }
.pdf-preview-loading[hidden] { display: none; }
.pdf-preview-controls { min-height: 50px; display: grid; grid-template-columns: 1fr auto 1fr; border-top: 1px solid var(--ink); }
.pdf-preview-controls > button, .pdf-preview-zoom button { border: 0; background: transparent; color: var(--ink); font: 8px "DM Mono", monospace; cursor: pointer; }
.pdf-preview-controls > button:first-child { border-right: 1px solid var(--ink); }
.pdf-preview-controls > button:last-child { border-left: 1px solid var(--ink); }
.pdf-preview-controls button:hover:not(:disabled), .pdf-preview-controls button:focus-visible { background: var(--ink); color: var(--white); }
.pdf-preview-controls button:disabled { color: #8a8b86; cursor: not-allowed; }
.pdf-preview-zoom { display: grid; grid-template-columns: 38px 54px 38px; align-items: stretch; }
.pdf-preview-zoom button + span, .pdf-preview-zoom span + button { border-left: 1px solid var(--line); }
.pdf-preview-zoom span { display: grid; place-items: center; font: 8px "DM Mono", monospace; }

@media (max-width: 560px) {
  .pdf-preview-modal { padding: 0; }
  .pdf-preview-dialog { width: 100%; height: 100dvh; border: 0; }
  .pdf-preview-stage { padding: 12px; }
  .pdf-preview-controls { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  .pdf-preview-zoom { grid-template-columns: 32px 46px 32px; }
}

@media (min-width: 520px) {
  .page-preview { padding: 12px; }
  .page-row { gap: 22px; }
  .page-paper { min-height: 125px; }
}
