/* PDF Gripper. Colors are set in :root. */

:root {
  --paper: #f6f5fa;
  --surface: #ffffff;
  --ink: #1d1830;
  --muted: #625c74;
  --line: #ddd9e8;
  --accent: #6d3fd8;
  --accent-hover: #5a30bd;
  --accent-ink: #ffffff;
  --accent-soft: #efe9fc;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --logo-fold: #c4b2f3;
  --canvas: #e9e7ef;
  --scroll-thumb: #b4adc6;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius-sm: 6px;
  --radius: 12px;
  --wrap: 960px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14111d;
    --surface: #1d1928;
    --ink: #ece9f4;
    --muted: #a49db8;
    --line: #312b42;
    --accent: #a58bff;
    --accent-hover: #b9a4ff;
    --accent-ink: #140f24;
    --accent-soft: #2a2145;
    --danger: #ff8a80;
    --danger-soft: #3a1c1c;
    --logo-fold: #e1d7ff;
    --canvas: #0f0c16;
    --scroll-thumb: #4d4563;
    color-scheme: dark;
  }
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

[hidden] { display: none !important; }

/* Headings get focus from script when a view changes; no ring for that. */
h1[tabindex="-1"]:focus { outline: none; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.55 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 16px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

.site-header { border-bottom: 1px solid var(--line); }

/* The header spans the whole window on every page. */
.site-header .wrap {
  max-width: none;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 750;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
}

.brand .logo { width: 30px; height: 30px; flex: none; }
.logo-page { fill: var(--accent); }
.logo-fold { fill: var(--logo-fold); }
.logo-clip { fill: var(--ink); }
.logo-slot { fill: var(--accent); }
.brand-name { font-weight: 600; }
.brand-name b { font-weight: 800; }

.site-nav { display: flex; gap: 20px; font-size: 0.9375rem; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover,
.site-nav a[aria-current="page"] { color: var(--ink); }

main { flex: 1; padding: 48px 0 64px; }

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
  padding: 20px 0;
}
.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--ink); text-decoration: underline; }
.copyright { margin: 0; }

.privacy { margin: 14px 0 0; color: var(--muted); font-size: 0.875rem; }

h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
  font-weight: 780;
  margin: 0 0 16px;
  max-width: 16ch;
}

.tool-page h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); max-width: none; }

.lede {
  font-size: 1.125rem;
  color: var(--muted);
  max-width: 56ch;
  margin: 0 0 40px;
}

h2 {
  font-size: 1.125rem;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
}

.tools {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.tool {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
}

a.tool:hover { border-color: var(--accent); }

.tool svg {
  width: 44px; height: 44px;
  padding: 9px;
  margin-bottom: 8px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 10px;
}

.tool strong { font-size: 1.0625rem; }
.tool span { color: var(--muted); font-size: 0.9375rem; }

.tool.is-soon { background: transparent; border-style: dashed; }
.tool.is-soon svg { color: var(--muted); background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.tool .soon {
  position: absolute;
  top: 18px; right: 18px;
  font-size: 0.75rem;
  color: var(--muted);
}

.promise {
  margin-top: 48px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
}
.promise h2 { font-size: 1rem; margin-bottom: 4px; }
.promise p { margin: 0; color: var(--muted); font-size: 0.9375rem; }

.dropzone {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 40px 16px;
  text-align: center;
  background: var(--surface);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.dropzone:hover,
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }

.dropzone svg { width: 40px; height: 40px; color: var(--accent); }
.dropzone p { margin: 0; color: var(--muted); }
.dropzone .hint { font-size: 0.875rem; }

.cards {
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, 160px);
  justify-content: center;
  gap: 14px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 14px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

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

.card.is-static { cursor: default; user-select: auto; -webkit-user-select: auto; }
.num.is-small { font-size: 1.125rem; }
.card-action { width: 100%; min-height: 40px; margin-top: 10px; padding: 0 12px; }
.card.is-static .name { word-break: break-all; }
.card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.page {
  position: relative;
  width: 64px;
  height: 82px;
  margin-bottom: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border-radius: 4px;
  clip-path: polygon(0 0, 72% 0, 100% 22%, 100% 100%, 0 100%);
}

.page::after {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 28%; height: 22%;
  background: var(--accent);
  opacity: 0.35;
  border-bottom-left-radius: 4px;
}

.num {
  font-size: 1.75rem;
  font-weight: 780;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.card .name {
  width: 100%;
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card .size { color: var(--muted); font-size: 0.8125rem; }

/* Page preview: the plain page icon until the real page is drawn. */
.thumb {
  width: 100%;
  height: 150px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb .page { margin: 0; }
.thumb img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: 0 2px 8px rgb(29 24 48 / 0.12);
}

.page-picker { display: grid; gap: 4px; }
.page-picker-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 16px;
}
.page-picker h2 { margin: 0; font-size: 1.125rem; }
.page-picker .status { margin: 2px 0 0; }
.page-picker-tools { display: flex; gap: 16px; }
.page-grid { margin-top: 12px; }

.link-btn:disabled { opacity: 0.4; cursor: default; text-decoration: none; }

/* Crop's work area: every page in one scrolling list. */
.crop-list {
  position: relative;
  display: grid;
  justify-items: start;
  align-content: start;
  gap: 28px;
  padding: 24px 24px 88px;
  overscroll-behavior: contain;
}
.crop-page { display: grid; gap: 8px; width: var(--page-width, 420px); margin: 0 auto; }
.crop-page-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.crop-page-label { font-weight: 600; font-size: 0.9375rem; }
.crop-stage {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.15);
  touch-action: pan-y;
  user-select: none;
  cursor: crosshair;
}
.crop-stage canvas { display: block; width: 100%; height: 100%; }
.crop-box {
  position: absolute;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 100vmax rgb(24 18 38 / 0.45);
  cursor: move;
  outline: none;
  touch-action: none;
}
.crop-box:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.crop-box.is-whole { box-shadow: none; border-style: dashed; cursor: crosshair; touch-action: pan-y; }
.crop-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 50%;
}
.crop-handle::before { content: ""; position: absolute; inset: -10px; }
.crop-handle[data-h="nw"] { left: 0; top: 0; cursor: nwse-resize; }
.crop-handle[data-h="n"] { left: 50%; top: 0; cursor: ns-resize; }
.crop-handle[data-h="ne"] { left: 100%; top: 0; cursor: nesw-resize; }
.crop-handle[data-h="e"] { left: 100%; top: 50%; cursor: ew-resize; }
.crop-handle[data-h="se"] { left: 100%; top: 100%; cursor: nwse-resize; }
.crop-handle[data-h="s"] { left: 50%; top: 100%; cursor: ns-resize; }
.crop-handle[data-h="sw"] { left: 0; top: 100%; cursor: nesw-resize; }
.crop-handle[data-h="w"] { left: 0; top: 50%; cursor: ew-resize; }
.crop-box.is-whole .crop-handle { display: none; }

.viewer-bar {
  position: absolute;
  left: 50%;
  bottom: 16px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  color: #f4f3f8;
  background: rgb(36 34 44 / 0.94);
  border: 1px solid rgb(255 255 255 / 0.08);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
  transform: translateX(-50%);
  white-space: nowrap;
}
.viewer-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.viewer-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.viewer-btn:hover:not(:disabled) { background: rgb(255 255 255 / 0.12); }
#fit-btn[data-next="width"] .fit-page-icon,
#fit-btn[data-next="page"] .fit-width-icon { display: none; }
.viewer-btn:disabled { opacity: 0.35; cursor: default; }
.viewer-btn:focus-visible, .viewer-page input:focus-visible { outline: 2px solid #b9a7ff; outline-offset: 1px; }
.viewer-sep { width: 1px; height: 20px; margin: 0 6px; background: rgb(255 255 255 / 0.2); }
.viewer-page { display: flex; align-items: center; gap: 6px; font-size: 0.875rem; }
.viewer-page input {
  width: 2.75em;
  height: 28px;
  padding: 0 4px;
  color: inherit;
  font: inherit;
  text-align: center;
  background: rgb(255 255 255 / 0.12);
  border: 0;
  border-radius: 6px;
}
.viewer-zoom { min-width: 3.25em; font-size: 0.875rem; text-align: center; font-variant-numeric: tabular-nums; }

.page-card {
  width: 100%;
  padding: 14px 12px 10px;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.page-card .thumb { height: 160px; }
.page-card .page-no { font-size: 0.875rem; font-weight: 600; color: var(--muted); }
.page-card.is-selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface));
}
.page-card.is-selected .page-no { color: var(--accent); }
.page-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.tick {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: transparent;
}
.tick svg { width: 14px; height: 14px; }
.page-card.is-selected .tick { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }

.bar-actions {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.cards.is-single .card-action { display: none; }

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 14px 0;
  background: var(--paper);
  box-shadow: 0 -1px 0 var(--line);
}

.remove {
  position: absolute;
  top: 8px; right: 8px;
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--surface);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.12s, transform 0.12s;
}
.remove svg { width: 16px; height: 16px; }
.remove:hover { background: var(--danger); color: #fff; }

.card:hover .remove,
.card:focus-within .remove { opacity: 1; transform: none; }

@media (hover: none) {
  .remove { opacity: 1; transform: none; }
}

.card.is-placeholder {
  background: transparent;
  border: 2px dashed var(--accent);
}
.card.is-placeholder > * { visibility: hidden; }

.card.is-floating {
  position: fixed;
  z-index: 50;
  margin: 0;
  pointer-events: none;
  cursor: grabbing;
  border-color: var(--accent);
  box-shadow: 0 14px 30px rgba(29, 24, 48, 0.22);
  rotate: 2deg;
}
.card.is-floating .remove { display: none; }

body.is-sorting, body.is-sorting * { cursor: grabbing !important; }

@media (prefers-reduced-motion: reduce) {
  .remove { transition: none; }
  .card.is-floating { rotate: none; }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 24px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font: 650 1rem var(--font);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--accent-hover); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.secondary { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.btn.secondary:hover { background: var(--accent-soft); }

.status { margin: 0; color: var(--muted); font-size: 0.9375rem; overflow-wrap: anywhere; }


.arrange.is-over .cards {
  outline: 2px dashed var(--accent);
  outline-offset: 8px;
  border-radius: var(--radius);
}

.link-btn {
  border: 0;
  padding: 4px 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.9375rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link-btn:hover:not(:disabled) { color: var(--muted); }

.notice {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
}
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice.success { background: var(--accent-soft); color: var(--ink); }
.notice[hidden] { display: none; }


.file-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  margin: 8px 0 24px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.file-summary .page { width: 44px; height: 56px; margin: 0; }
.file-summary .num { font-size: 1.125rem; }
.file-name {
  margin: 0 0 2px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.split-form { display: grid; gap: 20px; }
.split-form .actions { margin-top: 4px; }

.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  border: 0;
}

.choice {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 18px 18px 18px 50px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.choice:hover { border-color: var(--accent); }
.choice:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface));
}
.choice:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.choice input {
  position: absolute;
  left: 18px;
  top: 20px;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}
.choice-title { font-weight: 650; }
.choice-text { color: var(--muted); font-size: 0.9375rem; }

.select-options {
  display: grid;
  gap: 14px;
  max-width: 460px;
}
.select-options[hidden] { display: none; }

.field { display: grid; gap: 6px; }
.field label { font-weight: 600; }
.field input {
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: 1rem var(--font);
}
.field input:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field-help { margin: 0; color: var(--muted); font-size: 0.875rem; }
.field-error { margin: 0; color: var(--danger); font-size: 0.9375rem; }
.field-error[hidden] { display: none; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(3px);
}
.loader[hidden] { display: none; }

.loader-box {
  width: min(360px, 100%);
  padding: 32px 28px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px rgba(29, 24, 48, 0.16);
  text-align: center;
}

.loader-pages {
  position: relative;
  width: 64px;
  height: 72px;
  margin: 0 auto 20px;
}

.loader-pages span {
  position: absolute;
  inset: 0 12px 0 0;
  background: var(--accent-soft);
  border: 2px solid var(--accent);
  border-radius: 4px;
  animation: stack 1.6s ease-in-out infinite;
}
.loader-pages span:nth-child(1) { animation-delay: 0s; }
.loader-pages span:nth-child(2) { animation-delay: -0.53s; }
.loader-pages span:nth-child(3) { animation-delay: -1.06s; }

@keyframes stack {
  0%   { transform: translate(-14px, 8px); opacity: 0; }
  20%  { opacity: 1; }
  50%  { transform: translate(6px, 0); opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translate(6px, -14px) scale(0.9); opacity: 0; }
}

.loader-title { margin: 0 0 14px; font-size: 1.125rem; font-weight: 700; }
.loader-detail { margin: 10px 0 14px; color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }

.bar {
  height: 8px;
  overflow: hidden;
  background: var(--accent-soft);
  border-radius: 999px;
}

.bar-fill {
  width: 0;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.2s ease-out;
}

.bar.is-busy .bar-fill {
  width: 35%;
  animation: slide 1.1s ease-in-out infinite;
}

@keyframes slide {
  from { transform: translateX(-100%); }
  to   { transform: translateX(290%); }
}

@media (prefers-reduced-motion: reduce) {
  .loader-pages span { animation: none; }
  .loader-pages span:nth-child(1) { transform: translate(-8px, 6px); }
  .loader-pages span:nth-child(3) { transform: translate(8px, -6px); }
  .bar.is-busy .bar-fill { animation: none; width: 100%; opacity: 0.6; }
}

@media (max-width: 560px) {
  .site-header .wrap { padding: 0 16px; }
  main { padding: 32px 0 48px; }
  .site-nav { gap: 14px; }
  .actions .btn { width: 100%; }
  .choices { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(auto-fit, 150px); gap: 12px; }
  .page-card .thumb { height: 140px; }
  .crop-list { padding: 16px 12px 128px; gap: 20px; }
  .page-scroll { padding: 0 12px 128px; }
  .viewer-bar { bottom: 12px; padding: 4px; }
  .viewer-sep { margin: 0 2px; }
  .viewer-btn { width: 30px; height: 30px; }
  .crop-handle::before { inset: -14px; }
  .sticky-actions { padding: 10px 0; gap: 6px; }
  .sticky-actions .status { width: 100%; margin: 0; text-align: center; font-size: 0.875rem; }
  .file-summary { grid-template-columns: auto minmax(0, 1fr); }
  .file-summary .link-btn { grid-column: 1 / -1; justify-self: start; }
  .file-summary .btn { grid-column: 1 / -1; width: 100%; }
}

@media (max-width: 360px) {
  .cards { grid-template-columns: repeat(auto-fit, 130px); }
}

/* ---------- Workspace: the work area on the left, options on the right ----------
   Used by the tool pages once a file is open. The page itself doesn't scroll;
   only the work area does. Below 1024 px the panel becomes a drawer that the
   gear button opens (ui.js uses the same width). */
body:has(.workspace:not([hidden])) { height: 100vh; height: 100dvh; overflow: hidden; }
body:has(.workspace:not([hidden])) main { display: flex; min-height: 0; padding: 0; }
body:has(.workspace:not([hidden])) main > .wrap { display: flex; max-width: none; padding: 0; }
body:has(.workspace:not([hidden])) .site-footer { display: none; }

.workspace { flex: 1; display: flex; min-width: 0; min-height: 0; }
.ws { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 360px; min-width: 0; min-height: 0; }
.ws-main { position: relative; display: flex; min-width: 0; min-height: 0; background: var(--canvas); }
.ws-scroll { flex: 1; min-width: 0; overflow: auto; }
.ws-scroll:focus-visible { outline-offset: -3px; }

/* Always show the scrollbar, also on macOS, where it hides until you scroll. */
.ws-scroll::-webkit-scrollbar { width: 14px; height: 14px; }
.ws-panel-body::-webkit-scrollbar { width: 10px; }
.ws-scroll::-webkit-scrollbar-track,
.ws-scroll::-webkit-scrollbar-corner,
.ws-panel-body::-webkit-scrollbar-track { background: transparent; }
.ws-scroll::-webkit-scrollbar-thumb,
.ws-panel-body::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  background-clip: padding-box;
  border: 4px solid transparent;
  border-radius: 8px;
}
.ws-panel-body::-webkit-scrollbar-thumb { border-width: 3px; }
.ws-scroll::-webkit-scrollbar-thumb:hover,
.ws-panel-body::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }
@supports not selector(::-webkit-scrollbar) {
  .ws-scroll, .ws-panel-body { scrollbar-color: var(--scroll-thumb) transparent; }
}

.ws-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-left: 1px solid var(--line);
}
.ws-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
}
.ws-panel-head h1 { margin: 0; font-size: 1.25rem; letter-spacing: -0.02em; max-width: none; }
.ws-panel-body { flex: 1; display: grid; align-content: start; gap: 18px; padding: 20px; overflow-y: auto; }
.ws-panel-foot { display: grid; gap: 8px; padding: 16px 20px; border-top: 1px solid var(--line); }
.ws-panel-foot .btn { width: 100%; }
.ws-panel-foot .status { margin: 0; font-size: 0.875rem; text-align: center; }
.ws-panel .file-summary { grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; margin: 0; padding: 12px 14px; }
.ws-panel .file-summary .link-btn { grid-column: 2; justify-self: start; }
.ws-panel .choices { grid-template-columns: minmax(0, 1fr); gap: 8px; }
.ws-panel .choice { padding: 12px 14px 12px 44px; }
.ws-panel .choice input { left: 14px; top: 15px; }
.ws-panel .privacy { margin: 0; }
.ws-label { margin: 0 0 8px; padding: 0; font-weight: 650; font-size: 0.9375rem; }
.ws-help {
  margin: 0;
  padding: 10px 12px;
  color: var(--ink);
  font-size: 0.875rem;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
}
.ws-reset { justify-self: start; }

.ws-gear, .ws-close, .ws-fab, .ws-backdrop { display: none; }
.ws-gear svg, .ws-close svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Split's work area: the page thumbnails, with a header row that stays put. */
.page-scroll { padding: 0 24px 96px; }
.page-scroll-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 16px 0 12px;
  background: var(--canvas);
}
.page-scroll-head .status { margin: 0; }
.page-scroll-head .page-picker-tools { margin-left: auto; }
.page-scroll .page-grid { margin-top: 4px; }

/* In the workspace a message floats at the top of the work area. Clicks go
   through it, so it never blocks the buttons at the bottom. */
body:has(.workspace:not([hidden])) .notice {
  position: fixed;
  top: 76px;
  left: calc((100vw - 360px) / 2);
  z-index: 30;
  width: min(92vw, 460px);
  margin: 0;
  transform: translateX(-50%);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.2);
  pointer-events: none;
}

@media (max-width: 1023px) {
  .ws { grid-template-columns: minmax(0, 1fr); }
  .ws-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    width: min(380px, 88vw);
    visibility: hidden;
    transform: translateX(100%);
    transition: transform 0.2s ease, visibility 0s 0.2s;
    box-shadow: -8px 0 24px rgb(0 0 0 / 0.2);
  }
  .is-panel-open .ws-panel { visibility: visible; transform: none; transition: transform 0.2s ease, visibility 0s; }
  .ws-backdrop { position: fixed; inset: 0; z-index: 19; background: rgb(20 16 30 / 0.45); }
  .is-panel-open .ws-backdrop { display: block; }
  .ws-close {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--muted);
    background: none;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
  }
  .ws-close:hover { color: var(--ink); background: var(--accent-soft); }
  .ws-gear {
    position: absolute;
    top: 12px;
    right: 24px;
    z-index: 3;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    padding: 0;
    color: var(--accent);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 50%;
    box-shadow: 0 4px 14px rgb(0 0 0 / 0.18);
    cursor: pointer;
  }
  .ws-fab {
    position: absolute;
    right: 24px;
    bottom: 72px;
    z-index: 3;
    display: inline-flex;
    box-shadow: 0 6px 16px rgb(0 0 0 / 0.25);
  }
  .ws-fab:disabled { box-shadow: none; }
  .page-scroll-head { padding-right: 64px; }
  .page-scroll .page-grid { justify-content: center; }
  body:has(.workspace:not([hidden])) .notice { top: 132px; left: 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .ws-panel { transition: none; }
}

