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

:root {
  color-scheme: light;
  --font-ui: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --font-display: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, monospace;
  --text: #1d1d1f;
  --text-soft: #424245;
  --muted: #6e6e73;
  --faint: #6e6e73;
  --accent: #0071e3;
  --accent-strong: #0066cc;
  --line: rgba(134, 134, 139, 0.22);
  --line-strong: rgba(134, 134, 139, 0.38);
  --danger: #dc2626;
  --window-radius: 18px;
  --panel-radius: 12px;
  --card-radius: 11px;
  --control-radius: 8px;
  --ease-out: cubic-bezier(0.2, 0.75, 0.25, 1);
}

html { background: #f5f5f7; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: #f5f5f7;
  font: 14px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
select,
input { font: inherit; }

button { cursor: pointer; }

button:disabled { cursor: default; }

h1,
h2,
p { overflow-wrap: break-word; }

.od-icon {
  display: inline-block;
  inline-size: var(--od-icon-size, 1em);
  block-size: var(--od-icon-size, 1em);
  flex: none;
}

[hidden] { display: none !important; }

/* Window shell */
.app-window {
  display: flex;
  flex-direction: column;
  width: min(1280px, calc(100% - 32px));
  height: calc(100vh - 32px);
  height: calc(100dvh - 32px);
  min-height: 560px;
  margin: 16px auto;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--window-radius);
  background:
    linear-gradient(158deg, rgba(255, 255, 255, 0.78), rgba(239, 243, 246, 0.72)),
    rgba(247, 249, 250, 0.68);
  box-shadow: 0 18px 48px rgba(29, 29, 31, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(28px) saturate(118%);
  -webkit-backdrop-filter: blur(28px) saturate(118%);
  animation: window-in 0.5s var(--ease-out) backwards;
}

/* Title bar */
.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 54px;
  flex: none;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0));
}

.title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.app-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-strong);
  box-shadow: none;
}

h1 {
  margin: 0;
  overflow: hidden;
  color: #20262d;
  font: 500 16px/1.2 var(--font-display);
  letter-spacing: 0.19em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.title-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}

.runtime-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: #53606b;
  font: 500 9.5px/1 var(--font-display);
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.runtime-dot {
  width: 5px;
  height: 5px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-strong);
  box-shadow: none;
}

.reset-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.48);
  font-size: 11px;
  font-weight: 600;
  transition: background 0.16s var(--ease-out), border-color 0.16s var(--ease-out), color 0.16s var(--ease-out);
}

.reset-button:disabled { color: #697580; opacity: 0.55; }

/* Progress */
.flowbar {
  flex: none;
  padding: 8px 20px;
  border-bottom: 1px solid var(--line);
  background: transparent;
}

.steps {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.step {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 22px;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.step:not(:last-child)::after {
  width: 24px;
  height: 1px;
  margin-left: 2px;
  background: var(--line);
  content: "";
}

.step-num {
  display: grid;
  width: 19px;
  height: 19px;
  flex: none;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--faint);
  font: 600 9px/1 var(--font-display);
}

.step.is-done { color: var(--muted); }
.step.is-done .step-num {
  border-color: transparent;
  color: #ffffff;
  background: rgba(0, 113, 227, 0.78);
}
.step.is-current { color: var(--text); }
.step.is-current .step-num {
  border-color: rgba(0, 113, 227, 0.6);
  color: var(--accent);
  box-shadow: none;
}

/* Top command bar */
.command-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: none;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(70% 160% at 25% 0%, rgba(0, 113, 227, 0.08), rgba(0, 113, 227, 0) 70%),
    rgba(255, 255, 255, 0.38);
  transition: background 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}

.command-bar.is-dragging {
  background: rgba(0, 113, 227, 0.12);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.command-intake {
  display: flex;
  align-items: center;
  gap: 11px;
  flex: 1;
  min-width: 0;
  padding: 6px 8px 6px 9px;
  border: 1px dashed rgba(43, 54, 64, 0.26);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.34);
  transition: border-color 0.2s var(--ease-out), background 0.2s var(--ease-out);
}

.command-bar.is-dragging .command-intake {
  border-style: solid;
  border-color: var(--accent);
  background: rgba(0, 113, 227, 0.08);
}

.drop-illustration {
  display: grid;
  width: 36px;
  height: 36px;
  flex: none;
  place-items: center;
  border: 1px solid rgba(0, 113, 227, 0.14);
  border-radius: 9px;
  color: var(--accent);
  background: rgba(0, 113, 227, 0.07);
}

.command-copy {
  flex: 1;
  min-width: 0;
}

.drop-title {
  margin: 0;
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.25;
}

.drop-sub {
  margin: 1px 0 0;
  overflow: hidden;
  color: var(--faint);
  font-size: 10.5px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-meta {
  flex: 0 1 auto;
  max-width: 210px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-align: right;
  text-overflow: ellipsis;
}

.command-action {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  flex: 0 0 220px;
  min-width: 0;
}

.action-hint {
  color: var(--faint);
  font-size: 10px;
  line-height: 1.3;
  text-align: right;
}

.action-hint[hidden] { display: none !important; }

.browse-button {
  flex: none;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(43, 54, 64, 0.3);
  border-radius: var(--control-radius);
  color: #ffffff;
  background: #0071e3;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  transition: transform 0.16s var(--ease-out), filter 0.16s var(--ease-out), box-shadow 0.16s var(--ease-out);
}

.browse-button:active { transform: translateY(1px); }

.run-button {
  width: 100%;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(43, 54, 64, 0.35);
  border-radius: var(--control-radius);
  color: #ffffff;
  background: #0071e3;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.14);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: transform 0.16s var(--ease-out), filter 0.16s var(--ease-out), box-shadow 0.16s var(--ease-out);
}

.run-button:disabled {
  color: #64717c;
  border-color: var(--line);
  background: linear-gradient(180deg, rgba(210, 210, 215, 0.42), rgba(232, 232, 237, 0.55));
  box-shadow: none;
}

/* Status */
.status {
  flex: none;
  margin: 8px 16px 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: #343d46;
  background: rgba(255, 255, 255, 0.48);
  font-size: 11.5px;
}

.status:empty { display: none; }

/* Two-column workspace */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  flex: 1;
  min-height: 0;
  border-top: 1px solid var(--line);
}

/* Preview */
.preview-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: rgba(229, 234, 238, 0.16);
}

.preview-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex: none;
  padding: 15px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.preview-copy { min-width: 0; }

.preview-copy .rail-eyebrow { margin-bottom: 4px; }

.preview-copy h2 {
  margin: 0;
  color: #20262d;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.005em;
}

.preview-instruction {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}

.preview-empty {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 260px;
  padding: 30px;
  text-align: center;
}

.preview-empty-icon {
  display: grid;
  width: 56px;
  height: 56px;
  margin-bottom: 3px;
  place-items: center;
  border: 1px solid rgba(0, 113, 227, 0.16);
  border-radius: 14px;
  color: var(--accent);
  background: rgba(0, 113, 227, 0.07);
}

.preview-empty p {
  margin: 0;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 650;
}

.preview-empty > span:last-child {
  max-width: 300px;
  color: var(--faint);
  font-size: 11.5px;
  line-height: 1.5;
}

.preview-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 18px 18px;
}

.preview-body::-webkit-scrollbar { width: 9px; }
.preview-body::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(43, 54, 64, 0.2);
  background-clip: padding-box;
}

/* Page preview grid */
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  align-items: start;
}

.page-card {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62);
  cursor: grab;
  transition: transform 0.16s var(--ease-out), border-color 0.16s var(--ease-out), background 0.16s var(--ease-out), box-shadow 0.16s var(--ease-out);
  animation: panel-in 0.22s var(--ease-out) both;
}

.page-card:active { cursor: grabbing; }

.page-card.dragging { opacity: 0.45; }

.page-card.drag-over {
  transform: scale(1.02);
  border-color: var(--accent);
  background: rgba(248, 231, 204, 0.64);
}

.page-thumb {
  position: relative;
  display: grid;
  width: 100%;
  height: 152px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(229, 234, 238, 0.5);
}

.page-thumb canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.page-position {
  position: absolute;
  z-index: 1;
  top: 7px;
  left: 7px;
  display: grid;
  min-width: 27px;
  height: 23px;
  padding: 0 6px;
  place-items: center;
  border: 1px solid rgba(134, 134, 139, 0.38);
  border-radius: 7px;
  color: #ffffff;
  background: rgba(0, 113, 227, 0.9);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  font: 700 10px/1 var(--font-display);
  letter-spacing: 0.04em;
}

.page-info {
  overflow: hidden;
  margin-top: 7px;
  color: var(--muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-info strong {
  display: block;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-controls {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 6px;
}

.page-selection {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 10.5px;
}

.page-selection input { accent-color: var(--accent-strong); }

/* Split options */
.split-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(244, 247, 249, 0.56);
}

.split-selection { display: grid; gap: 4px; }

.split-selection strong,
.split-output legend { font-size: 11.5px; font-weight: 650; }

.split-selection span {
  color: var(--muted);
  font-size: 11.5px;
}

.split-selection button {
  margin-right: 5px;
  padding: 4px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.40);
  font-size: 11px;
  transition: background 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
}

.split-output {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 13px;
  margin: 0;
  padding: 8px 10px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.34);
}

.split-output legend {
  padding: 0 4px;
  color: var(--muted);
}

.split-output label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-soft);
  font-size: 11.5px;
  white-space: nowrap;
}

.split-output input { accent-color: var(--accent-strong); }

/* Right control rail */
.control-rail {
  min-height: 0;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: rgba(229, 234, 238, 0.22);
}

.control-rail::-webkit-scrollbar,
.file-list::-webkit-scrollbar { width: 9px; }
.control-rail::-webkit-scrollbar-thumb,
.file-list::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(43, 54, 64, 0.2);
  background-clip: padding-box;
}

.rail-section {
  padding: 13px 14px 15px;
  border-bottom: 1px solid var(--line);
}

.rail-section:last-child { border-bottom: 0; }

.rail-eyebrow {
  margin: 0 0 9px;
  color: var(--faint);
  font: 500 9px/1.2 var(--font-display);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.rail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
}

.rail-heading .rail-eyebrow { margin: 0; }

.rail-note {
  margin: 7px 0 0;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.45;
}

.rail-empty {
  margin: 2px 0 0;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--faint);
  font-size: 10.5px;
  line-height: 1.45;
  text-align: center;
}

/* Tool selector */
.tools {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.tool-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  min-height: 58px;
  padding: 9px 29px 9px 9px;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  color: var(--text);
  background: linear-gradient(166deg, rgba(255, 255, 255, 0.62), rgba(245, 245, 247, 0.76));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  text-align: left;
  transition: transform 0.16s var(--ease-out), border-color 0.16s var(--ease-out), background 0.16s var(--ease-out), box-shadow 0.16s var(--ease-out);
}

.tool-card[aria-pressed="true"] {
  border-color: rgba(0, 113, 227, 0.72);
  background: linear-gradient(166deg, rgba(0, 113, 227, 0.08), rgba(245, 245, 247, 0.82));
  box-shadow:
    0 0 0 1px rgba(0, 113, 227, 0.1),
    0 10px 24px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.tool-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: none;
  place-items: center;
  border: 1px solid rgba(0, 113, 227, 0.17);
  border-radius: 9px;
  color: var(--accent);
  background: linear-gradient(158deg, rgba(0, 113, 227, 0.04), rgba(245, 245, 247, 0.72));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  transition: background 0.16s var(--ease-out), border-color 0.16s var(--ease-out);
}

.tool-card[aria-pressed="true"] .tool-icon {
  border-color: rgba(0, 113, 227, 0.38);
  background: linear-gradient(158deg, rgba(0, 113, 227, 0.07), rgba(245, 245, 247, 0.76));
}

.tool-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.tool-copy strong {
  color: #20262d;
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: 0.005em;
}

.tool-desc {
  display: -webkit-box;
  overflow: hidden;
  color: #53606b;
  font-size: 10.5px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.tool-card[aria-pressed="true"] .tool-desc { color: #343d46; }

.tool-check {
  position: absolute;
  top: 7px;
  right: 7px;
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--accent);
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.16s var(--ease-out), transform 0.16s var(--ease-out);
}

.tool-card[aria-pressed="true"] .tool-check {
  opacity: 1;
  transform: scale(1);
}

/* Functional icon geometry */
.card-glyph,
.drop-glyph,
.add-glyph,
.reset-glyph,
.check-glyph,
.move-glyph,
.zoom-glyph,
.preview-glyph {
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.card-glyph { --od-icon-size: 20px; stroke-width: 1.45; }
.card-glyph [fill="#f8ead4"] { fill: rgba(0, 113, 227, 0.18); }
.drop-glyph { --od-icon-size: 24px; stroke-width: 1.4; }
.preview-glyph { --od-icon-size: 30px; stroke-width: 1.35; }
.add-glyph { --od-icon-size: 13px; stroke-width: 1.7; }
.reset-glyph { --od-icon-size: 14px; stroke-width: 1.5; }
.check-glyph { --od-icon-size: 10px; stroke-width: 2.2; }
.move-glyph,
.zoom-glyph { --od-icon-size: 17px; stroke-width: 1.7; }

/* DPI options */
.rail-options .rail-eyebrow { display: block; margin-bottom: 7px; }

.dpi-select {
  width: 100%;
  min-height: 38px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--control-radius);
  color: var(--text);
  background: rgba(255, 255, 255, 0.95);
  font-size: 11.5px;
}

/* Selected files */
.rail-file-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.rail-file-actions .ghost-button { flex: 1; min-height: 32px; }

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--control-radius);
  color: var(--accent);
  background: rgba(255, 255, 255, 0.40);
  font-size: 11px;
  font-weight: 600;
  transition: background 0.16s var(--ease-out), border-color 0.16s var(--ease-out), color 0.16s var(--ease-out), opacity 0.16s var(--ease-out);
}

.ghost-button:disabled { opacity: 0.5; }

.danger-ghost {
  border-color: rgba(168, 62, 50, 0.18);
  color: #9b4238;
  background: rgba(168, 62, 50, 0.08);
}

.file-list {
  display: grid;
  gap: 5px;
  max-height: 230px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.file-list li {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.file-badge {
  display: grid;
  width: 26px;
  height: 30px;
  flex: 0 0 26px;
  place-items: center;
  border: 1px solid rgba(168, 62, 50, 0.15);
  border-radius: 6px;
  color: #9b4238;
  background: rgba(168, 62, 50, 0.14);
  font: 700 8px/1 var(--font-display);
  letter-spacing: 0.04em;
}

.file-name {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 11.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-pages {
  color: var(--muted);
  font-size: 9.5px;
  white-space: nowrap;
}

.controls {
  display: flex;
  gap: 2px;
  flex: none;
}

.controls button,
.page-controls button {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #343d46;
  background: rgba(255, 255, 255, 0.48);
  font-size: 13px;
  line-height: 1;
  transition: background 0.15s var(--ease-out), border-color 0.15s var(--ease-out), color 0.15s var(--ease-out);
}

.controls button:disabled,
.page-controls button:disabled { color: #697580; opacity: 0.6; }

.controls button:last-child { color: var(--danger); }

.count-chip {
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #53606b;
  background: rgba(255, 255, 255, 0.40);
  font-size: 10px;
  font-weight: 550;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* Dialogs */
.confirm-dialog {
  width: min(92vw, 400px);
  max-width: none;
  margin: auto;
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(24px) saturate(120%);
  -webkit-backdrop-filter: blur(24px) saturate(120%);
}

.confirm-dialog::backdrop {
  background: rgba(229, 234, 238, 0.68);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.confirm-dialog[open] { animation: panel-in 0.18s var(--ease-out) both; }

.kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font: 500 9px/1 var(--font-display);
  letter-spacing: 0.14em;
}

.confirm-dialog h2 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.confirm-message {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.danger-button {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(168, 62, 50, 0.28);
  border-radius: var(--control-radius);
  color: #fff;
  background: linear-gradient(180deg, #ffc0b5, #e58d7f);
  font-size: 11.5px;
  font-weight: 700;
  transition: filter 0.16s var(--ease-out), transform 0.16s var(--ease-out);
}

.page-preview-dialog {
  width: min(94vw, 1000px);
  max-width: none;
  max-height: 92vh;
  margin: auto;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(24px) saturate(120%);
  -webkit-backdrop-filter: blur(24px) saturate(120%);
}

.page-preview-dialog::backdrop {
  background: rgba(229, 234, 238, 0.68);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.page-preview-dialog[open] { animation: panel-in 0.18s var(--ease-out) both; }

.preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.preview-head h2 {
  max-width: min(78vw, 760px);
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.preview-close {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.62);
  font-size: 22px;
  line-height: 1;
  transition: background 0.15s var(--ease-out), border-color 0.15s var(--ease-out), transform 0.18s var(--ease-out);
}

.preview-paper {
  display: grid;
  min-height: 240px;
  max-height: calc(92vh - 130px);
  place-items: center;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.56);
}

#large-preview {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 170px);
  object-fit: contain;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

#preview-status {
  margin: 22px;
  color: var(--muted);
  text-align: center;
}

/* Hover feedback for pointer devices */
@media (hover: hover) {
  .tool-card:hover {
    transform: translateX(2px);
    border-color: rgba(0, 113, 227, 0.42);
    background: linear-gradient(166deg, rgba(255, 255, 255, 0.72), rgba(245, 245, 247, 0.82));
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  }

  .tool-card:active { transform: translateX(0); }

  .reset-button:hover:not(:disabled),
  .ghost-button:hover:not(:disabled) {
    border-color: rgba(0, 113, 227, 0.48);
    background: rgba(0, 113, 227, 0.1);
  }

  .danger-ghost:hover:not(:disabled) {
    border-color: rgba(168, 62, 50, 0.3);
    background: rgba(168, 62, 50, 0.10);
  }

  .browse-button:hover {
    filter: brightness(1.04);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
  }

  .controls button:hover:not(:disabled),
  .page-controls button:hover:not(:disabled) {
    border-color: rgba(0, 113, 227, 0.48);
    color: var(--accent);
    background: rgba(0, 113, 227, 0.06);
  }

  .page-card:hover {
    transform: translateY(-2px);
    border-color: rgba(0, 113, 227, 0.32);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
  }

  .split-selection button:hover {
    border-color: rgba(0, 113, 227, 0.48);
    background: rgba(0, 113, 227, 0.1);
  }

  .run-button:hover:not(:disabled) {
    filter: brightness(1.04);
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(0, 0, 0, 0.18);
  }

  .run-button:active:not(:disabled) { transform: translateY(0); }

  .danger-button:hover { filter: brightness(1.04); transform: translateY(-1px); }

  .preview-close:hover {
    border-color: rgba(0, 113, 227, 0.45);
    background: rgba(0, 113, 227, 0.12);
    transform: rotate(90deg);
  }
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@keyframes window-in {
  from { opacity: 0; transform: translateY(8px) scale(0.997); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Tablet: stack the rail above the preview */
@media (max-width: 960px) {
  .app-window {
    height: auto;
    min-height: calc(100vh - 32px);
    min-height: calc(100dvh - 32px);
  }

  .workspace {
    display: flex;
    flex-direction: column;
    flex: none;
    border-top: 0;
  }

  .control-rail {
    order: -1;
    overflow: visible;
    border-left: 0;
    border-bottom: 1px solid var(--line);
  }

  .rail-section {
    padding: 13px 16px 15px;
  }

  .tools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .file-list { max-height: 190px; }

  .preview-panel {
    min-height: 480px;
  }

  .preview-body {
    overflow: visible;
  }

  .page-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

@media (max-width: 760px) {
  .runtime-chip { display: none; }

  .command-bar {
    flex-wrap: wrap;
    gap: 9px;
    padding: 10px 12px;
  }

  .command-intake {
    flex: 1 1 100%;
  }

  .command-meta {
    order: 3;
    flex: 1 1 100%;
    max-width: none;
    padding-left: 2px;
    text-align: left;
  }

  .command-action {
    order: 4;
    flex: 1 1 100%;
    max-width: none;
  }

  .action-hint { text-align: left; }

  .run-button { min-height: 46px; }
}

@media (max-width: 640px) {
  .app-window {
    width: calc(100% - 16px);
    min-height: calc(100vh - 16px);
    min-height: calc(100dvh - 16px);
    margin: 8px auto;
    border-radius: 14px;
  }

  .titlebar {
    min-height: 50px;
    padding: 0 14px;
  }

  h1 { font-size: 12.5px; letter-spacing: 0.14em; }
  .title-actions { gap: 8px; }

  .flowbar { padding: 8px 14px; }
  .steps { gap: 7px; }
  .step { gap: 6px; font-size: 10px; }
  .step:not(:last-child)::after { width: 14px; margin-left: 0; }
  .step-num { width: 18px; height: 18px; font-size: 9px; }

  .command-intake { padding: 6px 7px 6px 8px; }

  .drop-illustration {
    width: 38px;
    height: 38px;
  }

  .drop-glyph { --od-icon-size: 23px; }

  .browse-button { min-height: 44px; padding: 0 12px; }

  .status { margin: 8px 12px 0; }

  .rail-section { padding: 12px 14px 14px; }

  .tools { gap: 7px; }

  .tool-card {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-height: 76px;
    padding: 10px 26px 10px 10px;
    gap: 7px;
  }

  .tool-icon { width: 32px; height: 32px; border-radius: 8px; }
  .card-glyph { --od-icon-size: 18px; }
  .tool-copy strong { font-size: 12px; }
  .tool-desc { font-size: 10px; -webkit-line-clamp: 1; }

  .rail-file-actions .ghost-button { min-height: 44px; }

  .file-list li {
    flex-wrap: wrap;
    row-gap: 3px;
  }

  .file-name { flex: 1 1 130px; }
  .file-pages { margin-left: auto; }

  .controls {
    width: 100%;
    justify-content: flex-end;
    margin-top: 2px;
  }

  .controls button,
  .page-controls button { width: 44px; height: 44px; }

  .preview-panel { min-height: 420px; }

  .preview-bar {
    padding: 13px 14px 11px;
  }

  .preview-copy h2 { font-size: 16px; }

  .preview-body { padding: 12px 14px 14px; }

  .preview-empty { min-height: 300px; padding: 22px; }

  .page-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .page-thumb { height: 138px; }

  .split-options {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .split-selection button { min-height: 44px; }

  .danger-button,
  .confirm-actions .ghost-button { min-height: 44px; }
}

@media (max-width: 480px) {
  .reset-button span { display: none; }
  .reset-button { width: 34px; padding: 0; }

  .step:not(:last-child)::after { display: none; }
  .steps { justify-content: space-between; }
  .step-label { font-size: 9.5px; }

  .command-copy .drop-sub { white-space: normal; }

  .tools { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .page-grid { grid-template-columns: 1fr; }
  .page-thumb { height: 164px; }

  .command-action { flex-basis: 100%; }
}

@media (max-width: 380px) {
  h1 { font-size: 11.5px; letter-spacing: 0.12em; }
  .step-label { font-size: 9px; }
  .page-thumb { height: 146px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
