:root {
  color-scheme: light;
  --ink: #1f2328;
  --muted: #68707a;
  --line: #d8d0c4;
  --paper: #fffdf8;
  --panel: rgba(255, 253, 248, 0.88);
  --accent: #7c1d2c;
  --accent-strong: #52111e;
  --stage: #e8dfd1;
  --shadow: 0 18px 45px rgba(55, 44, 31, 0.22);
  font-family: Arial, "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(124, 29, 44, 0.12), transparent 38%),
    linear-gradient(225deg, rgba(35, 95, 94, 0.14), transparent 34%),
    var(--stage);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

select {
  font: inherit;
}

.catalog-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.topbar,
.controlbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px max(clamp(14px, 3vw, 32px), env(safe-area-inset-right)) 12px max(clamp(14px, 3vw, 32px), env(safe-area-inset-left));
  background: var(--panel);
  border-color: rgba(94, 77, 58, 0.18);
  backdrop-filter: blur(18px);
}

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

.controlbar {
  justify-content: center;
  flex-wrap: wrap;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}

body.admin-open .controlbar {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
}

.brand-mark {
  display: block;
  flex: 0 0 76px;
  width: 76px;
  height: 42px;
  object-fit: contain;
  object-position: center;
}

.brand h1 {
  margin: 0;
  font-size: clamp(16px, 2vw, 22px);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar,
.zoom-controls,
.admin-actions,
.row-actions,
.modal-actions,
.import-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar,
.admin-actions,
.modal-actions,
.import-tools {
  flex-wrap: wrap;
}

.icon-button {
  display: inline-grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(91, 76, 57, 0.25);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, transform 160ms ease, background 160ms ease;
}

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

.icon-button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

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

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

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  max-width: 100%;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

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

.secondary-button {
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  border-color: rgba(91, 76, 57, 0.25);
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.danger-button {
  color: #9f1239;
}

.danger-toolbar-button {
  flex: 0 0 auto;
  font-weight: 700;
  background: rgba(159, 18, 57, 0.08);
  color: #9f1239;
  border-color: rgba(159, 18, 57, 0.32);
}

.danger-toolbar-button:hover {
  background: rgba(159, 18, 57, 0.12);
  border-color: #9f1239;
}

.return-catalog-button {
  font-weight: 700;
}

.book-stage {
  position: relative;
  display: grid;
  min-height: 0;
  padding: clamp(16px, 3vw, 34px);
  place-items: center;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.book {
  --page-width: min(42vw, 520px);
  --page-ratio: 0.707;
  position: relative;
  display: block;
  width: min(calc(var(--page-width) * 2), 100%);
  height: calc(var(--page-width) / var(--page-ratio));
  direction: ltr;
  filter: drop-shadow(var(--shadow));
}

.pageflip-mount {
  width: 100%;
  height: 100%;
  margin: 0 auto;
}

.catalog-hotspot-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.catalog-hotspot {
  position: absolute;
  display: grid;
  place-items: center;
  min-width: 28px;
  min-height: 24px;
  border: 1px solid rgba(124, 29, 44, 0.58);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  pointer-events: auto;
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.catalog-hotspot::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(124, 29, 44, 0.12);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.36);
}

.catalog-hotspot span {
  position: absolute;
  right: 50%;
  bottom: calc(100% + 8px);
  max-width: 220px;
  transform: translateX(50%);
  padding: 6px 9px;
  border-radius: 6px;
  background: rgba(31, 35, 40, 0.92);
  color: #fff;
  font-size: 12px;
  line-height: 1.3;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 160ms ease, transform 160ms ease;
}

.catalog-hotspot:hover,
.catalog-hotspot:focus-visible {
  background: rgba(124, 29, 44, 0.16);
  box-shadow: 0 0 0 4px rgba(124, 29, 44, 0.15);
  outline: none;
}

.catalog-hotspot:hover span,
.catalog-hotspot:focus-visible span {
  opacity: 1;
  transform: translateX(50%) translateY(-2px);
}

.stf__parent {
  margin: 0 auto;
}

.stf__parent canvas {
  border: 1px solid rgba(76, 63, 49, 0.2);
  background: var(--paper);
}

.status {
  max-width: 460px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.9);
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.page-picker {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(91, 76, 57, 0.2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
}

.page-picker input {
  width: 54px;
  height: 30px;
  border: 1px solid rgba(91, 76, 57, 0.2);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  text-align: center;
}

.zoom-controls output {
  min-width: 54px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.modal {
  width: min(92vw, 460px);
  max-height: min(92vh, 92dvh);
  padding: 0;
  border: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(17, 24, 39, 0.42);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  display: grid;
  gap: 14px;
  max-height: min(92vh, 92dvh);
  overflow: auto;
  padding: 24px;
  border: 1px solid rgba(91, 76, 57, 0.25);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.modal-panel h2,
.admin-header h2 {
  margin: 0;
  font-size: 22px;
}

.modal-panel p,
.admin-header p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.modal-panel label:not(.import-page) {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.modal-panel input:not([type="checkbox"]) {
  height: 42px;
  border: 1px solid rgba(91, 76, 57, 0.28);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.modal-close {
  position: absolute;
  top: 14px;
  left: 14px;
}

.form-message {
  min-height: 22px;
  color: #9f1239;
  font-size: 14px;
}

.admin-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 320px;
  background: #f8f5ef;
  color: var(--ink);
}

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

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px max(clamp(14px, 3vw, 32px), env(safe-area-inset-right)) 16px max(clamp(14px, 3vw, 32px), env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.94);
}

.admin-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

.admin-catalog-select {
  display: flex;
  align-items: center;
  flex: 1 1 460px;
  gap: 8px;
  min-width: min(100%, 420px);
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid rgba(91, 76, 57, 0.2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 13px;
}

.admin-catalog-select select {
  width: min(48vw, 560px);
  max-width: 100%;
  min-width: min(54vw, 360px);
  height: 32px;
  border: 1px solid rgba(91, 76, 57, 0.22);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
}

.admin-actions svg,
.primary-button svg,
.secondary-button svg {
  width: 18px;
  height: 18px;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.admin-list {
  display: grid;
  gap: 10px;
  align-content: start;
  justify-items: center;
  padding: clamp(12px, 2.5vw, 24px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-row {
  display: grid;
  grid-template-columns: 92px minmax(220px, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: min(100%, 760px);
  padding: 10px;
  border: 1px solid rgba(91, 76, 57, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.admin-preview {
  display: block;
  max-width: 96px;
  border: 1px solid rgba(76, 63, 49, 0.18);
  background: #fff;
  cursor: zoom-in;
}

.hotspot-row-button {
  color: #235f5e;
}

.admin-magnifier {
  position: fixed;
  z-index: 40;
  display: grid;
  place-items: center;
  width: 340px;
  height: 240px;
  overflow: hidden;
  border: 1px solid rgba(76, 63, 49, 0.24);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(57, 47, 35, 0.22), inset 0 0 0 5px rgba(255, 253, 248, 0.74);
  pointer-events: none;
}

.admin-magnifier[hidden] {
  display: none;
}

.admin-magnifier canvas {
  display: block;
  width: 340px;
  height: 240px;
}

.admin-row-text {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.admin-row-text strong {
  font-size: 16px;
}

.admin-row-text span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delete-modal {
  width: min(92vw, 520px);
}

.delete-panel {
  gap: 18px;
}

.delete-preview-wrap {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(91, 76, 57, 0.18);
  border-radius: 8px;
  background: #fff;
}

#deletePreviewCanvas {
  max-width: min(58vw, 180px);
  border: 1px solid rgba(76, 63, 49, 0.18);
  background: #fff;
}

.delete-preview-grid {
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  align-items: center;
  justify-items: center;
}

.delete-preview-item {
  display: grid;
  justify-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.delete-preview-item canvas {
  max-width: 92px;
  border: 1px solid rgba(76, 63, 49, 0.18);
  background: #fff;
}

.delete-preview-more {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 50%;
  background: rgba(159, 18, 57, 0.1);
  color: #9f1239;
  font-weight: 800;
}

.delete-actions {
  flex-direction: row-reverse;
  justify-content: center;
}

.danger-confirm-button {
  background: #9f1239;
  border-color: #9f1239;
}

.danger-confirm-button:hover {
  background: #7f102d;
}

.import-modal {
  width: min(94vw, 980px);
}

.create-catalog-modal {
  width: min(94vw, 620px);
}

.create-catalog-panel {
  gap: 14px;
}

.checkbox-label {
  display: flex !important;
  grid-template-columns: none;
  align-items: center;
  gap: 9px !important;
  color: var(--ink) !important;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
}

.create-catalog-actions {
  justify-content: flex-start;
}

.import-panel {
  max-height: min(88vh, 88dvh);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 48px;
}

.import-tools,
.modal-actions {
  justify-content: flex-start;
}

.import-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(146px, 100%), 1fr));
  gap: 12px;
  overflow: auto;
  padding: 2px;
}

.import-page {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(91, 76, 57, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  cursor: pointer;
}

.import-page input {
  justify-self: start;
}

.import-page canvas {
  max-width: 120px;
  border: 1px solid rgba(76, 63, 49, 0.18);
  background: #fff;
}

.import-page span {
  color: var(--muted);
  font-size: 13px;
}

.hotspot-modal {
  width: min(96vw, 1080px);
}

.hotspot-panel {
  max-height: min(90vh, 90dvh);
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.hotspot-heading {
  padding-left: 46px;
}

.hotspot-editor {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(260px, 320px);
  gap: 16px;
  min-height: 0;
}

.hotspot-canvas-wrap {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  min-width: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid rgba(91, 76, 57, 0.18);
  border-radius: 8px;
  background: #f8f5ef;
}

#hotspotCanvas {
  display: block;
  max-width: 100%;
  border: 1px solid rgba(76, 63, 49, 0.2);
  background: #fff;
  cursor: crosshair;
}

.hotspot-overlay {
  position: absolute;
  pointer-events: none;
}

.hotspot-editor-box {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  height: var(--h);
  display: grid;
  place-items: center;
  min-width: 18px;
  min-height: 18px;
  border: 2px solid rgba(124, 29, 44, 0.86);
  border-radius: 5px;
  background: rgba(124, 29, 44, 0.16);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  pointer-events: none;
}

.hotspot-editor-box.is-draft {
  border-style: dashed;
  background: rgba(35, 95, 94, 0.18);
}

.hotspot-form {
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
}

.hotspot-form select {
  height: 42px;
  border: 1px solid rgba(91, 76, 57, 0.28);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.hotspot-form-actions {
  display: grid;
  gap: 8px;
}

.hotspot-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.hotspot-empty {
  margin: 0;
  padding: 12px;
  border: 1px dashed rgba(91, 76, 57, 0.25);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.hotspot-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(91, 76, 57, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.hotspot-list-item div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.hotspot-list-item strong,
.hotspot-list-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hotspot-list-item span {
  color: var(--muted);
  font-size: 12px;
}

.hotspot-footer-actions {
  justify-content: flex-end;
}

.share-modal {
  width: min(94vw, 720px);
}

.share-panel {
  gap: 18px;
}

.share-heading {
  display: grid;
  gap: 6px;
  padding-left: 46px;
}

.share-page-picker {
  border: 1px solid rgba(91, 76, 57, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.share-page-picker summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 48px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
}

.share-page-picker summary::-webkit-details-marker {
  display: none;
}

.share-page-picker summary span {
  display: grid;
  gap: 2px;
}

.share-page-picker summary small,
.share-page-option small {
  color: var(--muted);
  font-size: 12px;
}

.share-page-picker summary svg {
  width: 18px;
  height: 18px;
  transition: transform 160ms ease;
}

.share-page-picker[open] summary svg {
  transform: rotate(180deg);
}

.share-page-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 10px;
  max-height: min(44vh, 360px);
  overflow: auto;
  padding: 0 12px 12px;
  -webkit-overflow-scrolling: touch;
}

.share-page-option {
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  gap: 7px;
  min-height: 154px;
  padding: 9px;
  border: 1px solid rgba(91, 76, 57, 0.18);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.share-page-option input {
  justify-self: start;
}

.share-page-option canvas {
  max-width: 82px;
  border: 1px solid rgba(76, 63, 49, 0.18);
  background: #fff;
}

.share-page-option span {
  color: var(--muted);
  font-size: 13px;
}

.share-page-option-full {
  grid-template-rows: auto 1fr;
  align-content: center;
  min-height: 96px;
}

.share-page-option-full span {
  align-self: center;
  display: grid;
  gap: 4px;
  color: var(--ink);
  text-align: center;
}

.share-visuals {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(210px, 0.85fr);
  align-items: stretch;
  gap: 14px;
}

.share-catalog-preview,
.qr-box {
  min-width: 0;
  border: 1px solid rgba(91, 76, 57, 0.18);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(57, 47, 35, 0.08);
}

.share-catalog-preview {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  margin: 0;
  padding: 14px;
  overflow: hidden;
}

.share-catalog-preview::before {
  content: "";
  position: absolute;
  inset: 14px 14px 42px;
  border-radius: 7px;
  background: linear-gradient(90deg, rgba(31, 35, 40, 0.12), transparent 18%, transparent 82%, rgba(31, 35, 40, 0.08));
  pointer-events: none;
}

.share-catalog-preview img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 260px;
  object-fit: contain;
  border: 1px solid rgba(76, 63, 49, 0.14);
  border-radius: 7px;
  background: #fff;
}

.share-catalog-preview figcaption,
.qr-box span {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.qr-box {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 16px;
}

#qrCanvas {
  width: min(62vw, 240px);
  height: min(62vw, 240px);
}

.share-url {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.share-url input {
  direction: ltr;
  height: 42px;
  border: 1px solid rgba(91, 76, 57, 0.25);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.share-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.social-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  text-decoration: none;
  font-weight: 800;
}

.facebook-button {
  background: #1877f2;
  font-family: Arial, sans-serif;
  font-size: 26px;
}

.linkedin-button {
  background: #0a66c2;
  font-size: 18px;
}

.mail-button {
  background: #5f6368;
}

.mail-button svg {
  width: 20px;
  height: 20px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    gap: 12px;
  }

  .book {
    --page-width: min(88vw, 520px);
  }

  .brand-mark {
    flex-basis: 68px;
    width: 68px;
    height: 38px;
  }

  .admin-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-actions {
    justify-content: flex-start;
  }

  .admin-row {
    grid-template-columns: 84px minmax(0, 1fr);
    width: 100%;
  }

  .row-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .catalog-shell {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .topbar {
    gap: 8px;
    padding: 10px max(10px, env(safe-area-inset-right)) 10px max(10px, env(safe-area-inset-left));
  }

  .brand h1 {
    font-size: 15px;
  }

  .brand p {
    display: none;
  }

  .toolbar {
    flex: 0 0 auto;
    gap: 4px;
    justify-content: flex-end;
  }

  .icon-button {
    width: 36px;
    height: 36px;
  }

  .icon-button svg {
    width: 18px;
    height: 18px;
  }

  .book-stage {
    padding: 8px;
    align-items: center;
  }

  .controlbar {
    display: grid;
    grid-template-columns: 36px 36px minmax(118px, 148px) 36px 36px;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 7px max(8px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .page-picker {
    justify-self: stretch;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    padding-inline: 8px;
  }

  .page-picker input {
    width: 42px;
    height: 28px;
  }

  .zoom-controls {
    grid-column: 1 / -1;
    justify-self: center;
    gap: 8px;
  }

  .zoom-controls output {
    min-width: 48px;
  }

  .primary-button,
  .secondary-button {
    min-height: 38px;
    padding-inline: 11px;
    font-size: 14px;
  }

  .modal {
    width: min(94vw, 420px);
  }

  .modal-panel {
    padding: 18px;
  }

  .modal-panel h2,
  .admin-header h2 {
    font-size: 19px;
  }

  .admin-header {
    gap: 12px;
    padding: 12px max(10px, env(safe-area-inset-right)) 12px max(10px, env(safe-area-inset-left));
  }

  .admin-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    width: 100%;
  }

  .admin-actions .primary-button,
  .admin-actions .secondary-button,
  .admin-catalog-select {
    width: 100%;
  }

  .admin-catalog-select {
    grid-column: 1 / -1;
    justify-content: space-between;
  }

  .admin-catalog-select select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    flex: 1 1 auto;
  }

  #deleteAllButton {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .admin-row {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 10px;
    width: 100%;
    padding: 8px;
  }

  .admin-preview {
    max-width: 72px;
  }

  .admin-row-text strong {
    font-size: 15px;
  }

  .row-actions {
    justify-content: center;
  }

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

  .import-page {
    padding: 8px;
  }

  .import-page canvas {
    max-width: 104px;
  }

  .hotspot-editor {
    grid-template-columns: 1fr;
  }

  .hotspot-heading {
    padding-left: 42px;
  }

  .hotspot-canvas-wrap {
    padding: 8px;
  }

  .share-heading {
    gap: 10px;
    padding-left: 42px;
  }

  .share-visuals {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .share-catalog-preview {
    padding: 10px;
  }

  .share-catalog-preview::before {
    inset: 10px 10px 36px;
  }

  .share-catalog-preview img {
    max-height: 160px;
  }

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

  .share-page-option {
    min-height: 138px;
    padding: 8px;
  }

  .share-page-option canvas {
    max-width: 70px;
  }

  .share-actions {
    justify-content: center;
  }

  .share-panel {
    gap: 12px;
  }

  .qr-box {
    padding: 10px;
  }

  #qrCanvas {
    width: min(52vw, 190px);
    height: min(52vw, 190px);
  }
}

@media (max-width: 390px) {
  .brand {
    gap: 8px;
  }

  .brand-mark {
    flex-basis: 60px;
    width: 60px;
    height: 34px;
  }

  .brand h1 {
    font-size: 14px;
  }

  .toolbar {
    gap: 3px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }

  .controlbar {
    grid-template-columns: 34px 34px minmax(112px, 138px) 34px 34px;
    gap: 5px;
  }

  .admin-actions {
    grid-template-columns: 1fr 1fr;
  }

  #deleteAllButton {
    grid-column: 1 / -1;
  }

  #closeAdminButton {
    grid-column: 1 / -1;
    justify-self: center;
  }
}

@media (max-height: 620px) and (orientation: landscape) {
  .topbar,
  .controlbar {
    padding-block: 7px;
  }

  .brand p {
    display: none;
  }

  .book-stage {
    padding-block: 8px;
  }

  .icon-button {
    width: 36px;
    height: 36px;
  }

  .page-picker {
    min-height: 36px;
  }
}

@media (min-width: 861px) and (max-width: 1180px) {
  .book-stage {
    padding: clamp(12px, 2vw, 22px);
  }
}
