:root {
  --bg: #090d12;
  --surface: #121820;
  --surface-2: #19222c;
  --surface-raised: #202b36;
  --ink: #edf5f2;
  --muted: #98aaa6;
  --line: #2c3a43;
  --accent: #39c6a3;
  --accent-strong: #27a98b;
  --placeholder-accent: #116b5c;
  --placeholder-accent-soft: #173d36;
  --placeholder-accent-strong: #83e8cf;
  --warn: #f3c86b;
  --warn-bg: #332812;
  --danger: #ff8d8d;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.34);
  --radius: 8px;
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% -20%, rgba(57, 198, 163, 0.12), transparent 42%),
    linear-gradient(180deg, #0d1319, var(--bg)),
    var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.46;
  cursor: not-allowed;
}

.app-shell {
  width: min(1600px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

.topbar,
.actionbar,
.workspace {
  width: 100%;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.7rem, 2.3vw, 2.4rem);
  line-height: 1.05;
}

h2 {
  font-size: 1rem;
  line-height: 1.2;
}

.stats {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.stats span {
  border: 1px solid var(--line);
  background: rgba(18, 24, 32, 0.88);
  border-radius: var(--radius);
  min-height: 34px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.stats strong {
  color: var(--ink);
}

.stats .quality-pill.warning {
  border-color: #806426;
  background: var(--warn-bg);
  color: var(--warn);
}

.actionbar {
  display: grid;
  grid-template-columns: repeat(5, auto);
  justify-content: end;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.project-file-button {
  min-height: 42px;
}

.upload-builder {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(18, 24, 32, 0.94);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.upload-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.upload-tab {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.upload-tab + .upload-tab {
  border-left: 1px solid var(--line);
}

.upload-tab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: inset 0 -3px 0 var(--accent);
}

.upload-panel {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) auto;
  gap: 12px;
  padding: 12px;
}

.upload-panel[hidden] {
  display: none;
}

.upload-secondary-actions {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.upload-secondary-actions button {
  white-space: nowrap;
}

.dropzone {
  min-height: 74px;
  border: 1.5px dashed #52636a;
  border-radius: var(--radius);
  background: rgba(9, 13, 18, 0.38);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  cursor: pointer;
  outline: none;
}

.dropzone.dragging,
.dropzone:focus-visible {
  border-color: var(--accent);
  background: rgba(57, 198, 163, 0.1);
}

.dropzone input {
  display: none;
}

.drop-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  line-height: 1;
  flex: 0 0 auto;
}

.dropzone p,
.preview-heading p,
.print-note,
.panel-heading span,
.status-line,
.meta,
.quality-note {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.toggle {
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
  white-space: nowrap;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.segmented-control {
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  display: inline-grid;
  grid-template-columns: auto auto;
  gap: 2px;
  padding: 3px;
  margin: 0;
}

.segmented-control legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.segmented-control label {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  min-height: 36px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.layout-settings {
  display: grid;
  grid-template-columns: minmax(180px, .75fr) minmax(330px, 1.5fr) minmax(280px, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.setting-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
  padding: 12px;
  display: grid;
  gap: 9px;
  align-content: start;
}

.setting-title {
  font-size: .82rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--muted);
}

.setting-help,
.setting-error {
  color: var(--muted);
  font-size: .8rem;
  margin: 0;
}

.setting-error:not(:empty) {
  color: var(--warn);
}

.fit-warning {
  display: block;
  margin: -4px 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 176, 32, .55);
  border-radius: var(--radius);
  background: rgba(255, 176, 32, .1);
  color: var(--warn);
  font-size: .84rem;
}

.fit-warning[hidden] {
  display: none;
}

#fitWarningList {
  display: grid;
  gap: 4px;
  margin-top: 6px;
  color: var(--text);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.setting-row select,
.range-number input[type="number"],
.border-grid input {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  min-height: 34px;
}

.range-number {
  display: grid;
  grid-template-columns: 72px minmax(90px, 1fr) 76px 24px;
  align-items: center;
  gap: 8px;
  font-size: .85rem;
}

.range-number input[type="range"] {
  min-width: 0;
  accent-color: var(--accent);
}

.range-number input[type="number"],
.border-grid input {
  width: 100%;
  padding: 4px 7px;
}

.unit-label,
.border-grid em {
  color: var(--muted);
  font-size: .78rem;
  font-style: normal;
}

.compact {
  min-height: 36px;
}

.compact-toggle {
  min-height: 34px;
  padding: 0 9px;
  font-size: .83rem;
}

.border-controls,
.border-grid {
  display: grid;
  gap: 7px;
}

.border-controls[hidden],
[role="tabpanel"][hidden] {
  display: none;
}

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

.border-grid label {
  display: grid;
  grid-template-columns: 48px 1fr 18px;
  align-items: center;
  gap: 5px;
  font-size: .78rem;
}

.preview-tabs {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 12px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.preview-tabs button {
  min-height: 34px;
  padding: 6px 11px;
}

.preview-tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.item-size-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
}

.item-size-control legend {
  grid-column: 1 / -1;
}

.merge-rows label[hidden],
.merge-presets button[hidden] {
  display: none;
}

.segmented-control input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segmented-control span {
  pointer-events: none;
}

.segmented-control label:has(input:checked) {
  background: var(--accent);
  color: #fff;
}

.primary-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 800;
  min-width: 140px;
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-strong);
  color: #fff;
}

.import-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(18, 24, 32, 0.96);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 14px;
}

.import-panel[hidden] {
  display: none;
}

.download-link {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.download-link:hover {
  border-color: var(--accent);
  background: rgba(57, 198, 163, 0.1);
}

.import-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1.2fr) minmax(260px, 0.8fr);
  gap: 12px;
}

.textarea-field,
.sample-data {
  display: grid;
  gap: 7px;
}

.textarea-field span,
.sample-heading span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.textarea-field textarea {
  width: 100%;
  min-height: 190px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px;
  color: var(--ink);
  background: var(--surface);
  font: 0.9rem/1.45 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.textarea-field textarea:focus {
  outline: 2px solid rgba(57, 198, 163, 0.3);
  border-color: var(--accent);
}

.sample-data {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 10px;
  min-width: 0;
}

.sample-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sample-heading button {
  min-height: 32px;
  padding: 0 10px;
}

.sample-data pre {
  margin: 0;
  overflow: auto;
  white-space: pre;
  color: var(--ink);
  font: 0.78rem/1.45 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.import-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.file-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  background: var(--surface);
  cursor: pointer;
}

.file-button input {
  display: none;
}

.color-field {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 0 13px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
}

.color-field input[type="color"] {
  width: 34px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.color-field input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-field input[type="color"]::-webkit-color-swatch {
  border: 1px solid var(--line);
  border-radius: 5px;
}

.import-status {
  color: var(--muted);
  font-size: 0.9rem;
}

.import-status.error {
  color: var(--danger);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(236px, 300px) minmax(420px, 1fr) minmax(250px, 320px);
  gap: 14px;
  align-items: start;
}

.side-panel,
.crop-panel,
.preview-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(18, 24, 32, 0.94);
  box-shadow: var(--shadow);
}

.side-panel,
.crop-panel {
  padding: 14px;
  min-height: 420px;
}

.crop-panel .panel-heading {
  min-width: 0;
}

#selectedName {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

.preview-panel {
  padding: 14px;
  min-height: 640px;
}

.panel-heading,
.preview-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.preview-heading {
  align-items: center;
}

.print-note {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 8px 10px;
  color: var(--ink);
  white-space: nowrap;
}

.icon-button {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  font-size: 1.3rem;
}

.image-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 246px);
  overflow: auto;
  padding-right: 3px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.image-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  cursor: grab;
  text-align: left;
  outline: none;
}

.image-item.selected,
.image-item:focus-visible {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.image-item.drag-over {
  border-color: var(--accent);
  background: rgba(57, 198, 163, 0.1);
}

.image-item.dragging {
  opacity: 0.72;
}

.thumb {
  width: 46px;
  height: 64px;
  border-radius: 5px;
  background: var(--surface-raised);
  object-fit: cover;
  border: 1px solid var(--line);
}

.placeholder-thumb {
  width: 46px;
  height: 64px;
  border-radius: 5px;
  background: linear-gradient(180deg, var(--surface-raised), var(--placeholder-accent-soft));
  border: 1px solid var(--placeholder-accent);
  color: var(--placeholder-accent-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.image-title {
  min-width: 0;
}

.image-title strong,
.image-title span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-title strong {
  font-size: 0.9rem;
}

.meta {
  font-size: 0.78rem;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 104px;
}

.row-actions button {
  width: 30px;
  min-height: 30px;
  height: 30px;
  padding: 0;
}

.print-toggle {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 800;
  cursor: pointer;
}

.print-toggle input {
  margin: 0;
  accent-color: var(--accent);
}

.quality-note {
  color: var(--warn);
  margin-top: 3px;
}

.pages {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  align-items: start;
}

.sheet-wrap {
  display: grid;
  gap: 8px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.page-actions {
  display: flex;
  gap: 4px;
}

.page-actions button {
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
}

.sheet-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.sheet {
  width: 100%;
  aspect-ratio: 8.5 / 11;
  background: #fff;
  border: 1px solid #cfd8d3;
  box-shadow: 0 12px 30px rgba(26, 35, 33, 0.12);
  position: relative;
  overflow: hidden;
}

.sheet-grid {
  position: absolute;
  left: calc(0.5 / 8.5 * 100%);
  top: calc(0.25 / 11 * 100%);
  width: calc(7.5 / 8.5 * 100%);
  height: calc(10.5 / 11 * 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

.binder-sheet {
  aspect-ratio: var(--binder-aspect, 7.5 / 10.5);
}

.binder-sheet .sheet-grid {
  inset: 0;
  width: 100%;
  height: 100%;
  column-gap: var(--binder-gap-x, 0%);
  row-gap: var(--binder-gap-y, 0%);
  grid-template-columns: repeat(3, var(--binder-item-width, 33.333%));
  grid-template-rows: repeat(3, var(--binder-item-height, 33.333%));
}

.print-sheet canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.printable-border {
  position: absolute;
  border: 1px dashed rgba(181, 65, 47, .72);
  pointer-events: none;
  z-index: 2;
}

.preview-card {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  gap: 0;
  border: 1px solid rgba(18, 33, 30, 0.18);
  border-radius: 0;
  background:
    linear-gradient(45deg, #f0f2f0 25%, transparent 25%),
    linear-gradient(-45deg, #f0f2f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f0f2f0 75%),
    linear-gradient(-45deg, transparent 75%, #f0f2f0 75%);
  background-size: 16px 16px;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  overflow: hidden;
}

.preview-card:hover:not(:disabled) {
  border-color: rgba(18, 33, 30, 0.18);
  transform: none;
}

.preview-card[draggable="true"] {
  cursor: grab;
}

.preview-card.dragging {
  opacity: 0.72;
}

.preview-card.drag-over {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
  z-index: 3;
}

.preview-card canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.preview-card.wide-card {
  aspect-ratio: 5 / 3.5;
}

.mosaic-card {
  position: relative;
}

.mosaic-guides {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.mosaic-piece-guide {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  border: 1px solid rgba(18, 33, 30, 0.28);
  background: transparent;
}

.mosaic-print-toggle {
  min-height: 24px;
  margin: 4px;
  padding: 3px 6px;
  border: 1px solid rgba(18, 33, 30, .35);
  border-radius: 999px;
  background: rgba(255, 255, 255, .86);
  color: #0b493f;
  font-size: clamp(.55rem, 1.3vw, .76rem);
  font-weight: 900;
  overflow: hidden;
}

.mosaic-print-toggle:hover,
.mosaic-print-toggle:focus-visible {
  background: rgba(17, 107, 92, .16);
  color: #0b493f;
  transform: none;
}

.mosaic-piece-guide.print-excluded {
  background: rgba(30, 38, 36, .68);
}

.mosaic-piece-guide.print-excluded .mosaic-print-toggle {
  background: rgba(24, 33, 31, .88);
  color: #fff;
}

.preview-card.print-excluded canvas {
  opacity: .28;
  filter: grayscale(.7);
}

.print-excluded-badge {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(24, 33, 31, .82);
  color: #fff;
  font-size: clamp(.55rem, 1.4vw, .8rem);
  font-weight: 900;
  white-space: nowrap;
  pointer-events: none;
}

.sheet.hide-guides .mosaic-piece-guide:not(.print-excluded) {
  border-color: transparent;
}

.preview-card.empty canvas {
  display: none;
}

.preview-card.selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 2;
}

.sheet.hide-guides .preview-card {
  border-color: transparent;
}

.sheet.hide-guides .preview-card:hover:not(:disabled) {
  border-color: transparent;
}

.selected-preview {
  width: min(210px, 100%);
  aspect-ratio: 2.5 / 3.5;
  margin: 0 auto 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
  overflow: hidden;
}

.selected-preview.wide {
  width: 100%;
  aspect-ratio: 5 / 3.5;
}

.item-fit-control {
  width: 100%;
  margin-bottom: 14px;
}

.item-fit-control:has(input:disabled) {
  opacity: 0.55;
}

.selected-preview canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.control-stack {
  display: grid;
  gap: 14px;
}

.mosaic-merge-controls {
  display: grid;
  gap: 9px;
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.mosaic-merge-controls[hidden] {
  display: none;
}

.merge-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.merge-presets button {
  min-height: 32px;
  padding: 5px;
  font-size: .74rem;
}

.merge-rows {
  display: grid;
  gap: 6px;
}

.merge-rows label {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: .78rem;
}

.merge-rows select {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-raised);
  color: var(--text);
}

.control-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.lock-toggle {
  display: inline-flex !important;
  grid-template-columns: none;
  align-items: center;
  gap: 6px !important;
  color: var(--ink) !important;
  font-weight: 700;
  cursor: pointer;
}

.lock-toggle input {
  accent-color: var(--accent);
}

.control-stack label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
}

.control-stack input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.crop-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

#removeButton {
  color: var(--danger);
}

.status-line {
  margin-top: 12px;
}

@media (max-width: 1120px) {
  .layout-settings {
    grid-template-columns: 1fr 1fr;
  }

  .print-settings {
    grid-column: 1 / -1;
  }
  .workspace {
    grid-template-columns: minmax(220px, 300px) minmax(360px, 1fr);
  }

  .crop-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(180px, 240px) 1fr auto;
    gap: 14px;
    align-items: center;
    min-height: auto;
  }

  .crop-panel .panel-heading {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  .selected-preview {
    margin: 0;
  }

  .crop-actions {
    grid-template-columns: 1fr;
    margin-top: 0;
  }

  .status-line {
    grid-column: 1 / -1;
    margin-top: 0;
  }
}

@media (max-width: 760px) {
  .layout-settings {
    grid-template-columns: 1fr;
  }

  .print-settings {
    grid-column: auto;
  }

  .range-number {
    grid-template-columns: 68px minmax(70px, 1fr) 70px 22px;
  }
  .app-shell {
    width: min(100vw - 20px, 680px);
    padding-top: 14px;
  }

  .topbar,
  .preview-heading {
    align-items: start;
    flex-direction: column;
  }

  .stats {
    justify-content: flex-start;
  }

  .actionbar,
  .upload-panel,
  .import-grid,
  .workspace,
  .crop-panel {
    grid-template-columns: 1fr;
  }

  .toggle,
  .segmented-control,
  #sampleButton,
  #importToggleButton,
  .primary-button {
    width: 100%;
  }

  .upload-tabs {
    grid-template-columns: 1fr;
  }

  .upload-tab + .upload-tab {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .upload-secondary-actions {
    display: grid;
  }

  .download-link,
  .file-button,
  #importPlaceholdersButton {
    width: 100%;
  }

  .segmented-control {
    grid-template-columns: 1fr 1fr;
  }

  .side-panel,
  .preview-panel,
  .crop-panel {
    min-height: auto;
  }

  .image-list {
    max-height: 360px;
  }

  .pages {
    grid-template-columns: 1fr;
  }

  .print-note {
    white-space: normal;
  }
}
