:root {
  color-scheme: dark;
  font-family: "DM Sans", "Segoe UI", system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --page: #0d121b;
  --panel: #151d29;
  --panel-raised: #1b2533;
  --line: #2a3646;
  --muted: #94a2b5;
  --text: #edf3fa;
  --blue: #4d9dff;
  --blue-hover: #69adff;
  --danger: #ff8585;
}

* { box-sizing: border-box; }
.mobile-studio-nav { display: none; }
.mobile-add-photos { display: none; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background: var(--page);
  font-size: 13px;
}

h1, h2, h3, .brand { font-family: "Manrope", "Segoe UI", sans-serif; }

button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: #111823;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .04em;
}

.brand-mark {
  display: grid;
  width: 56px;
  height: 38px;
  flex: 0 0 56px;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.brand-mark-image .shared-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.back-link {
  color: #b8c6d8;
  text-decoration: none;
  font-size: 12px;
}
.back-link:hover { color: #fff; }
.header-actions { display: flex; align-items: center; gap: 14px; }
.menu-toggle {
  display: grid;
  width: 34px;
  height: 34px;
  align-content: center;
  justify-items: center;
  gap: 4px;
  padding: 0;
  border: 1px solid #344255;
  border-radius: 7px;
  background: #1a2432;
  cursor: pointer;
}
.menu-toggle:hover, .menu-toggle[aria-expanded="true"] { border-color: var(--blue); background: #1a2a45; }
.menu-toggle span { width: 15px; height: 2px; border-radius: 2px; background: #dce6f2; }
.menu-toggle:focus-visible, .menu-install:focus-visible, .menu-link:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.menu-backdrop[hidden], .app-menu[hidden] { display: none; }
.menu-backdrop {
  position: fixed;
  z-index: 9000;
  inset: 58px 0 0;
  background: rgb(3 7 12 / 28%);
}
.app-menu {
  position: fixed;
  z-index: 9001;
  top: 66px;
  right: 12px;
  width: min(286px, calc(100vw - 24px));
  padding: 8px;
  border: 1px solid #34445b;
  border-radius: 10px;
  background: #151d29;
  box-shadow: 0 16px 42px rgb(0 0 0 / 42%);
  transform-origin: top right;
  animation: menu-slide-in 150ms ease-out;
}
@keyframes menu-slide-in {
  from { opacity: 0; transform: translateY(-7px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.menu-install {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border: 1px solid #2a3a4f;
  border-radius: 7px;
  background: #1a2432;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.menu-install:hover:not(:disabled) { border-color: #4777b1; background: #202f43; }
.menu-install:disabled { border-color: #2a3646; background: #19222e; color: #c2ccda; opacity: 1; cursor: default; }
.menu-install > span:last-child { display: grid; min-width: 0; gap: 3px; }
.menu-install strong { display: block; font-size: 12px; font-weight: 650; line-height: 1.3; }
.menu-install small { display: block; color: var(--muted); font-size: 10px; line-height: 1.4; overflow-wrap: anywhere; }
.menu-install-icon {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border: 1px solid #3774bb;
  border-radius: 8px;
  background: #19385b;
  color: #b7d8ff;
  font-size: 21px;
}
.menu-status { margin: 3px 10px 6px; color: #ffb2a6; font-size: 10px; line-height: 1.45; }
.menu-status:empty { display: none; }
.menu-link { display: block; padding: 9px 10px; border-top: 1px solid #2a3646; color: #c8d3e1; font-size: 11px; text-decoration: none; }
.menu-link:hover { color: #fff; background: #1a2432; }

.workspace {
  display: grid;
  grid-template-columns: minmax(390px, 1.02fr) minmax(440px, 1fr);
  gap: 14px;
  width: 100%;
  height: calc(100vh - 58px);
  min-height: 0;
  margin: 0 auto;
  padding: 14px 18px 18px;
}

.left-column {
  display: grid;
  grid-template-rows: minmax(165px, .4fr) minmax(250px, 1.6fr) auto;
  gap: 12px;
  min-height: 0;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgb(0 0 0 / 12%);
}

.photo-panel, .crop-panel, .settings-panel, .preview-panel { padding: 13px; }
.photo-panel, .crop-panel, .settings-panel { min-height: 0; }
.photo-panel, .crop-panel { display: flex; flex-direction: column; }

.panel-heading {
  display: flex;
  min-height: 24px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-heading h1, .panel-heading h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
}

.panel-heading > span, .heading-actions, .page-navigation { color: var(--muted); font-size: 11px; }
.crop-panel-heading-actions, .crop-modal-header-actions { display: flex; min-width: 0; align-items: center; gap: 8px; }
.icon-button.crop-tools-toggle { display: none; align-content: center; justify-items: center; gap: 3px; }
.crop-tools-toggle span { width: 14px; height: 2px; border-radius: 2px; background: currentColor; }
.crop-tools-menu { display: contents; }
.crop-panel-heading-actions > span { overflow: hidden; max-width: 48%; text-overflow: ellipsis; white-space: nowrap; }
.heading-actions { display: flex; align-items: center; gap: 10px; }
.text-button {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #202b3a;
  cursor: pointer;
}
.text-button:hover:not(:disabled) { border-color: #4a6079; background: #27364a; }
.text-button.danger { color: var(--danger); }
.text-button:disabled { opacity: .45; cursor: not-allowed; }

.upload-button {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px dashed #48617d;
  border-radius: 7px;
  background: #192638;
  color: #dcecff;
  cursor: pointer;
  font-weight: 600;
}
.upload-button:hover { border-color: var(--blue); background: #1c2d43; }
.upload-button small { color: var(--muted); font-size: 10px; font-weight: 400; }

.photo-list {
  display: flex;
  flex: 1;
  gap: 8px;
  min-height: 52px;
  margin-top: 9px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-color: #43546a transparent;
}
.photo-list:empty { display: none; }

.photo-item {
  position: relative;
  display: flex;
  flex: 0 0 142px;
  align-items: center;
  gap: 7px;
  min-width: 0;
  height: 52px;
  padding: 5px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: #111925;
  cursor: pointer;
  text-align: left;
}
.photo-item.selected { border-color: var(--blue); background: #172941; }
.photo-item > img { width: 38px; height: 42px; flex: 0 0 38px; border-radius: 4px; object-fit: cover; }
.photo-item-details { display: grid; flex: 1; gap: 4px; min-width: 0; }
.photo-item-name { overflow: hidden; color: #cad6e4; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.photo-item-details label { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 9px; }
.photo-item-details input { width: 42px; height: 20px; padding: 0 4px; border: 1px solid #344255; border-radius: 4px; background: #101721; color: var(--text); font-size: 10px; }
.photo-remove {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 19px;
  height: 19px;
  padding: 0;
  border: 1px solid #29394d;
  border-radius: 5px;
  background: #111925eF;
  color: #fff;
  cursor: pointer;
}
.photo-remove:hover { background: #753c46; }
.status { min-height: 0; margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.status:empty { display: none; }

.crop-panel { position: relative; }
.crop-panel .panel-heading { margin-bottom: 9px; }
.crop-panel .panel-heading > span {
  overflow: hidden;
  max-width: 48%;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crop-frame {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 130px;
  overflow: hidden;
  border: 1px solid #304158;
  border-radius: 9px;
  background-color: #0c121b;
  background-image: linear-gradient(45deg, #151e2b 25%, transparent 25%), linear-gradient(-45deg, #151e2b 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #151e2b 75%), linear-gradient(-45deg, transparent 75%, #151e2b 75%);
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
  background-size: 14px 14px;
  box-shadow: inset 0 0 22px rgb(0 0 0 / 18%);
}
.crop-frame img { display: block; max-width: 100%; }
.crop-empty {
  display: grid;
  flex: 1;
  min-height: 90px;
  place-items: center;
  align-content: center;
  gap: 7px;
  padding: 16px;
  border: 1px dashed #3a4d65;
  border-radius: 9px;
  color: #a8b7ca;
  background: radial-gradient(ellipse at center, #172334 0%, #111925 72%);
  text-align: center;
}
.crop-empty[hidden] { display: none; }
.crop-empty-icon { display: grid; width: 34px; height: 34px; place-items: center; margin-bottom: 1px; border: 1px solid #344b67; border-radius: 10px; background: #19283b; color: #8bb8ff; }
.crop-empty-icon svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.crop-empty strong { color: #dce7f5; font-size: 11px; font-weight: 650; }
.crop-empty > span:last-child { color: #8292a8; font-size: 10px; line-height: 1.45; }
.crop-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin-top: 9px;
  padding: 5px 7px;
  border: 1px solid #263547;
  border-radius: 8px;
  background: #111925;
}
.control-label, .crop-tools output { color: #c8d3e1; font-size: 10px; font-weight: 600; }
.crop-tools input[type="range"] { flex: 1; min-width: 50px; accent-color: var(--blue); cursor: pointer; }
.crop-tools output { width: 40px; padding: 4px 5px; border: 1px solid #2a3a4e; border-radius: 5px; background: #172232; color: #bcd3f4; font-variant-numeric: tabular-nums; text-align: center; }
.icon-button {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #202b3a;
  color: #dce6f2;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.icon-button:hover:not(:disabled) { border-color: #4b6d95; background: #2a3a4e; }
.icon-button:disabled { opacity: .4; cursor: not-allowed; }
.apply-crop { min-width: 112px; min-height: 35px; align-self: flex-end; margin-top: 8px; }

.primary-button, .secondary-button {
  min-height: 36px;
  padding: 0 15px;
  border: 1px solid #438de0;
  border-radius: 7px;
  background: #2879d0;
  color: #fff;
  cursor: pointer;
  font-weight: 650;
}
.primary-button:hover:not(:disabled) { background: #388ce7; }
.secondary-button {
  border-color: #34475e;
  background: #202b3a;
  color: #e6edf6;
}
.secondary-button:hover:not(:disabled) { background: #2a3a4e; }
.primary-button:disabled, .secondary-button:disabled { opacity: .45; cursor: not-allowed; }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px 10px;
}
.field { display: flex; min-width: 0; flex-direction: column; gap: 4px; color: #aebcce; font-size: 10px; }
.border-width-field[hidden] { display: none; }
.field input, .field select {
  width: 100%;
  height: 31px;
  min-width: 0;
  padding: 0 8px;
  border: 1px solid #344255;
  border-radius: 6px;
  background: #101721;
  color: var(--text);
  font-size: 11px;
}
.field select { padding-right: 21px; }
.unit-input { position: relative; display: block; }
.unit-input input { padding-right: 29px; }
.unit-input em {
  position: absolute;
  top: 8px;
  right: 8px;
  color: #7e8da0;
  font-size: 10px;
  font-style: normal;
}
.custom-paper { display: contents; }
.custom-paper[hidden] { display: none; }
.check-field {
  display: flex;
  align-items: center;
  align-self: end;
  gap: 7px;
  min-height: 31px;
  color: #d0d9e5;
  font-size: 11px;
  white-space: nowrap;
}
.check-field input { width: 14px; height: 14px; margin: 0; accent-color: var(--blue); }
.validation { min-height: 13px; margin: 7px 0 0; color: #ff9e9e; font-size: 10px; }
.status.is-error { color: #ff9e9e; }

.preview-panel { display: flex; flex-direction: column; min-height: 0; }
.page-navigation { display: flex; align-items: center; gap: 8px; }
.page-navigation .icon-button { width: 25px; height: 25px; flex-basis: 25px; }
.preview-stage {
  display: grid;
  flex: 1;
  min-height: 240px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #263243;
  border-radius: 8px;
  background: #0c1119;
}
.empty-preview { padding: 20px; color: #718197; text-align: center; }
.paper-preview {
  position: relative;
  flex: none;
  overflow: hidden;
  background: white;
  box-shadow: 0 10px 32px rgb(0 0 0 / 35%);
}
.placement-tools { display: flex; align-items: center; gap: 10px; padding: 0 1px 8px; color: #aebcce; font-size: 10px; }
.alignment-buttons { display: flex; flex-wrap: wrap; gap: 5px; }
.alignment-button { min-height: 27px; padding: 0 9px; border: 1px solid #344255; border-radius: 6px; background: #192434; color: #d5dfec; cursor: pointer; font-size: 10px; }
.alignment-button:hover:not(:disabled) { border-color: #4b6d95; background: #24364d; }
.alignment-button:disabled { opacity: .45; cursor: not-allowed; }
.preview-photo { position: absolute; overflow: hidden; background: #fff; cursor: grab; touch-action: none; user-select: none; }
.preview-photo:active { cursor: grabbing; }
.preview-photo:focus-visible { z-index: 2; outline: 2px solid #2879d0; outline-offset: 1px; }
.preview-photo.selected { z-index: 1; box-shadow: 0 0 0 2px #4d9dff; }
.preview-photo.bordered { box-shadow: inset 0 0 0 var(--preview-border-width, 1px) #454545; }
.preview-photo.selected.bordered { box-shadow: 0 0 0 2px #4d9dff, inset 0 0 0 var(--preview-border-width, 1px) #454545; }
.preview-photo img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.stats {
  display: flex;
  justify-content: center;
  gap: clamp(28px, 7vw, 90px);
  padding: 13px 0 12px;
}
.stats div { display: flex; align-items: baseline; gap: 7px; }
.stats strong { color: #f3f7fc; font-size: 16px; font-weight: 700; }
.stats span { color: var(--muted); font-size: 11px; }
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.actions button { min-width: 0; padding-right: 8px; padding-left: 8px; }
.export-hint { margin: 9px 0 0; color: #77869a; font-size: 10px; text-align: right; }

.crop-modal[hidden] { display: none; }
.crop-modal {
  position: fixed;
  z-index: 10000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(3 7 12 / 82%);
  backdrop-filter: blur(3px);
}
.crop-modal-dialog {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  width: min(1280px, 100%);
  height: min(900px, 100%);
  min-width: 0;
  min-height: 0;
  padding: 16px;
  border: 1px solid #34445b;
  border-radius: 12px;
  background: #141c28;
  box-shadow: 0 24px 80px rgb(0 0 0 / 55%);
}
.crop-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
}
.crop-modal-header h2 { margin: 0; color: var(--text); font-size: 16px; font-weight: 650; }
.crop-modal-header span { display: block; max-width: min(70vw, 900px); margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.crop-modal-close { width: 34px; height: 34px; flex-basis: 34px; font-size: 22px; }
.crop-modal-stage {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  border: 1px solid #34445b;
  border-radius: 8px;
  background-color: #090d13;
  background-image: radial-gradient(#253143 .7px, transparent .7px);
  background-size: 12px 12px;
}
.crop-modal-frame { position: relative; width: 100%; height: 100%; min-width: 0; min-height: 0; overflow: hidden; }
.crop-modal-frame img { display: block; max-width: 100%; }
.crop-modal-stage .cropper-container { background-color: transparent; }
.crop-modal-stage .cropper-view-box { outline: 2px solid #79aeff; outline-offset: -1px; }
.crop-modal-stage .cropper-line { background-color: #79aeff; }
.crop-modal-stage .cropper-point { width: 12px; height: 12px; border: 1px solid #08111e; border-radius: 3px; background-color: #dcecff; opacity: 1; }
.crop-modal-stage .cropper-point.point-ne { right: -6px; top: -6px; }
.crop-modal-stage .cropper-point.point-nw { left: -6px; top: -6px; }
.crop-modal-stage .cropper-point.point-se { right: -6px; bottom: -6px; }
.crop-modal-stage .cropper-point.point-sw { left: -6px; bottom: -6px; }
.crop-modal-tools { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 2px 2px; }
.crop-modal-tools-row { display: flex; width: 100%; align-items: center; gap: 10px; }
.crop-modal-tools input[type="range"] { flex: 1; min-width: 60px; accent-color: var(--blue); cursor: pointer; }
.crop-modal-tools output { width: 44px; color: #c8d3e1; font-size: 12px; text-align: right; }
.crop-modal-status { min-height: 14px; margin: 0; color: var(--muted); font-size: 11px; }
.crop-modal-status.is-error { color: #ff9e9e; }
.crop-modal-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 8px; border-top: 1px solid #263243; }
body.crop-modal-open { overflow: hidden; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding-right: 12px; padding-left: 12px; }
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .left-column { grid-template-rows: minmax(160px, auto) minmax(240px, 1fr) auto; }
}

@media (max-width: 720px) {
  .topbar { height: 54px; padding: 0 12px; }
  .workspace { display: flex; height: auto; min-height: 0; flex-direction: column; padding: 10px; }
  .left-column { display: flex; flex-direction: column; }
  .photo-panel { min-height: 130px; }
  .photo-list { min-height: 58px; }
  .crop-panel { min-height: 300px; }
  .icon-button.crop-tools-toggle { display: inline-grid; width: 34px; height: 34px; flex: 0 0 34px; }
  .crop-panel-heading-actions { gap: 6px; }
  .crop-tools-menu:not(.is-open) { display: none; }
  .crop-tools-menu.is-open { display: block; }
  .crop-tools { min-height: 44px; flex-wrap: wrap; gap: 8px; }
  .crop-tools .control-label { flex: 1 0 100%; }
  .crop-tools input[type="range"] { min-width: 70px; }
  .settings-panel { min-height: 204px; }
  .preview-panel { min-height: 600px; }
  .preview-stage { min-height: 430px; }
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .back-link { font-size: 11px; }
  .header-actions { gap: 9px; }
  .menu-backdrop { inset-block-start: 54px; }
  .app-menu { top: 61px; }
}

@media (max-width: 480px) {
  .header-actions .back-link { display: none; }
}

@media (max-width: 600px) {
  .crop-modal { padding: 0; }
  .crop-modal-dialog { width: 100%; height: 100%; height: 100dvh; max-height: 100dvh; padding: max(10px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom)); border-radius: 0; }
  .crop-modal-header { padding-bottom: 8px; }
  .icon-button.crop-tools-toggle { display: inline-grid; width: 36px; height: 36px; flex: 0 0 36px; }
  .crop-modal-tools:not(.is-open) { display: none; }
  .crop-modal-tools.is-open { display: flex; min-height: 48px; padding-top: 8px; }
  .crop-modal-tools-row { gap: 6px; }
  .crop-modal-tools .icon-button { width: 34px; height: 34px; flex-basis: 34px; }
  .crop-modal-tools .text-button { min-height: 34px; padding: 0 9px; }
  .crop-modal-stage { min-height: 0; border-radius: 6px; }
  .crop-modal-actions { padding-top: 8px; }
}

@media (max-width: 720px) {
  .workspace {
    display: flex;
    height: auto;
    min-height: 0;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
  }
  .preview-panel {
    order: -1;
    width: 100%;
    min-height: 0;
    padding: 10px;
  }
  .left-column {
    order: 1;
    width: 100%;
  }
  .preview-stage {
    height: clamp(330px, 47svh, 450px);
    min-height: 0;
    flex: 0 0 auto;
    padding: 10px;
  }
  .paper-preview {
    max-width: 100%;
    max-height: 100%;
  }
  .stats { padding: 10px 0 8px; }
  .actions { margin-top: 2px; }
  .export-hint { margin-bottom: 2px; }
}

@media (max-width: 480px) {
  .workspace { gap: 9px; padding: 8px; }
  .preview-panel { padding: 9px; }
  .preview-stage {
    height: clamp(320px, 46svh, 410px);
    padding: 8px;
  }
  .stats { gap: 18px; }
}

@media (min-width: 721px) and (max-height: 680px) {
  .workspace { height: calc(100vh - 58px); padding: 8px 12px; gap: 8px; }
  .left-column { grid-template-rows: minmax(125px, .4fr) minmax(125px, 1.2fr) auto; gap: 8px; }
  .settings-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .photo-panel, .crop-panel, .settings-panel, .preview-panel { padding: 9px; }
  .panel-heading { min-height: 20px; margin-bottom: 6px; }
  .crop-frame, .crop-empty { min-height: 80px; }
  .crop-tools { min-height: 30px; margin-top: 5px; }
  .settings-grid { gap: 5px 8px; }
  .field input, .field select { height: 27px; }
  .check-field { min-height: 27px; }
  .validation { margin-top: 4px; }
  .preview-stage { min-height: 0; }
  .stats { padding: 8px 0; }
  .export-hint { margin-top: 5px; }
}

@media (max-width: 720px), (max-height: 600px) and (max-width: 900px) {
  body {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    overscroll-behavior: none;
  }
  .topbar { position: relative; z-index: 2; height: 54px; padding: 0 10px; }
  .brand { min-width: 0; gap: 7px; font-size: 11px; }
  .brand-mark { width: 42px; height: 32px; flex-basis: 42px; }
  .brand small { font-size: 9px; }
  .header-actions { gap: 0; }
  .header-actions .back-link { display: none; }
  .menu-toggle { width: 36px; height: 36px; }
  .workspace {
    position: fixed;
    inset: 54px 0 calc(58px + env(safe-area-inset-bottom));
    display: block;
    width: auto;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 8px;
    overflow: hidden;
  }
  .left-column { display: contents; }
  .photo-panel, .crop-panel, .settings-panel, .preview-panel {
    position: absolute;
    inset: 8px;
    display: none;
    width: auto;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 10px;
    overflow: hidden;
    border-radius: 10px;
  }
  body[data-mobile-view="photo"] .photo-panel,
  body[data-mobile-view="crop"] .crop-panel,
  body[data-mobile-view="settings"] .settings-panel,
  body[data-mobile-view="preview"] .preview-panel { display: flex; }
  body[data-mobile-view="settings"] .preview-panel { display: flex; }
  body[data-mobile-view="settings"] .settings-panel {
    z-index: 2;
    inset: auto 8px 8px;
    height: min(54%, 520px);
    border-color: #3b4d65;
    background: rgb(21 29 41 / 48%);
    backdrop-filter: blur(1px);
    box-shadow: 0 -10px 36px rgb(0 0 0 / 45%);
  }
  .preview-panel > .panel-heading { align-items: center; gap: 8px; }
  .placement-tools { flex-wrap: wrap; gap: 5px 8px; padding-bottom: 6px; }
  .alignment-buttons { gap: 4px; }
  .alignment-button { min-height: 29px; padding: 0 8px; }
  .mobile-add-photos {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    place-items: center;
    padding: 0;
    border: 1px solid #34445b;
    border-radius: 50%;
    background: #1a2a45;
    color: #c7dcff;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
  }
  .mobile-add-photos:hover { border-color: #6398e6; background: #223b60; }
  .photo-panel, .crop-panel, .settings-panel, .preview-panel { flex-direction: column; }
  .panel-heading { flex: 0 0 auto; min-height: 22px; margin-bottom: 7px; }
  .photo-panel .upload-button { min-height: 52px; flex: 0 0 auto; }
  .photo-list { min-height: 0; flex: 1 1 auto; }
  .crop-frame, .crop-empty { min-height: 0; }
  .crop-panel-heading-actions { min-width: 0; gap: 6px; }
  .crop-panel-heading-actions > span { max-width: 38vw; }
  .crop-tools { flex-wrap: wrap; gap: 7px; }
  .crop-tools-menu:not(.is-open) { display: none; }
  .crop-tools-menu.is-open { display: block; }
  .settings-grid {
    min-height: 0;
    flex: 1 1 auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    gap: 8px;
    overflow: auto;
    overscroll-behavior: contain;
  }
  .field input, .field select { min-height: 36px; }
  .check-field { min-height: 34px; }
  .validation { flex: 0 0 auto; margin-top: 5px; }
  .preview-stage { min-height: 0; flex: 1 1 auto; padding: 7px; }
  .paper-preview { max-width: 100%; max-height: 100%; }
  .stats { flex: 0 0 auto; gap: 18px; padding: 8px 0; }
  .actions { flex: 0 0 auto; }
  .export-hint { flex: 0 0 auto; margin-top: 6px; }
  .mobile-studio-nav {
    position: fixed;
    z-index: 5;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    height: calc(58px + env(safe-area-inset-bottom));
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
    gap: 4px;
    padding: 5px 8px env(safe-area-inset-bottom);
    border-top: 1px solid #263142;
    background: #111823;
  }
  .mobile-studio-nav button {
    min-width: 0;
    min-height: 42px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #93a1b6;
    font-size: 10px;
    font-weight: 600;
  }
  .mobile-studio-nav button[aria-pressed="true"] { background: #1a2a45; color: #a9c5ff; }
  .menu-backdrop { inset-block-start: 54px; }
  .app-menu { top: 61px; }
}
