:root {
  color-scheme: light;
  --bg: #edf1f0;
  --surface: #ffffff;
  --surface-muted: #f5f7f6;
  --surface-strong: #e8eeec;
  --text: #13231f;
  --text-soft: #66746f;
  --text-faint: #8b9793;
  --border: #d9e1df;
  --border-strong: #c6d1ce;
  --primary: #0d7567;
  --primary-hover: #095f54;
  --primary-soft: #dff2ee;
  --danger: #be3838;
  --danger-soft: #fff0f0;
  --ring: #17a68f;
  --shadow-sm: 0 1px 2px rgb(16 36 31 / 6%);
  --shadow-md: 0 12px 32px rgb(16 36 31 / 10%);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --topbar-height: 72px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(circle at 52% 8%, rgb(255 255 255 / 75%) 0, transparent 30rem),
    var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button,
label[for],
summary,
input[type="range"],
input[type="color"],
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
label[for]:focus-visible {
  outline: 3px solid rgb(23 166 143 / 32%);
  outline-offset: 2px;
}

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

svg {
  display: block;
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  transform: translateY(-140%);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: #fff;
  background: var(--primary);
  transition: transform 180ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: rgb(255 255 255 / 92%);
  backdrop-filter: blur(14px);
}

.brand-lockup,
.brand-line,
.header-actions,
.panel-heading,
.rail-heading,
.workspace-toolbar,
.download-bar,
.logo-upload-row,
.separator-row {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, #139987, #075e54);
  box-shadow: 0 8px 20px rgb(13 117 103 / 25%);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
}

.brand-lockup h1,
.panel-heading h2,
.rail-heading h2,
.workspace-toolbar h2 {
  margin: 0;
  line-height: 1.2;
}

.brand-lockup h1 {
  font-size: 17px;
  letter-spacing: -0.02em;
}

.brand-lockup p {
  margin: 2px 0 0;
  color: var(--text-soft);
  font-size: 12px;
}

.brand-line {
  gap: 8px;
}

.local-badge,
.scope-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid #b7dfd7;
  border-radius: 999px;
  color: #0b665a;
  background: #e9f7f4;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.header-actions {
  gap: 8px;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.button:active:not(:disabled) {
  filter: brightness(0.96);
}

.button-quiet,
.button-secondary {
  border-color: var(--border);
  color: #2c3d38;
  background: var(--surface);
}

.button-quiet {
  min-height: 44px;
  padding: 8px 11px;
  font-size: 12px;
}

.button-quiet:hover:not(:disabled),
.button-secondary:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-muted);
}

.button-primary {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 7px 18px rgb(13 117 103 / 20%);
}

.button-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.button-count {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  color: var(--primary);
  background: #fff;
  font-size: 11px;
}

.app-shell {
  display: grid;
  min-height: calc(100dvh - var(--topbar-height));
  grid-template-columns: 326px minmax(420px, 1fr) 258px;
  align-items: stretch;
}

.control-panel,
.image-rail {
  min-width: 0;
  background: rgb(255 255 255 / 96%);
}

.control-panel {
  display: flex;
  max-height: calc(100dvh - var(--topbar-height));
  flex-direction: column;
  border-right: 1px solid var(--border);
}

.image-rail {
  max-height: calc(100dvh - var(--topbar-height));
  overflow: auto;
  border-left: 1px solid var(--border);
}

.panel-heading,
.rail-heading,
.workspace-toolbar {
  justify-content: space-between;
  gap: 12px;
}

.panel-heading {
  padding: 18px 16px 12px;
}

.panel-heading h2,
.rail-heading h2,
.workspace-toolbar h2 {
  margin-top: 2px;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.eyebrow {
  display: block;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.scope-card {
  margin: 0 12px 10px;
  padding: 10px;
  border: 1px solid #c9e5df;
  border-radius: var(--radius-md);
  background: #f0faf8;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 12px 12px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #edf2f0;
}

.mode-tab {
  min-height: 44px;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  color: var(--text-soft);
  background: transparent;
  font-size: 11px;
  font-weight: 800;
  transition: color 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.mode-tab:hover {
  color: var(--text);
}

.mode-tab.is-active {
  color: var(--primary);
  background: #fff;
  box-shadow: 0 1px 4px rgb(25 50 43 / 12%);
}

.quick-panel {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 18px;
  overscroll-behavior: contain;
}

.template-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.template-option {
  display: grid;
  min-width: 0;
  min-height: 64px;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--text);
  background: #fff;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
  transition: border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.template-option:hover {
  border-color: #91c9bf;
  background: #f7fbfa;
}

.template-option:focus-visible {
  outline: 3px solid rgb(18 137 119 / 24%);
  outline-offset: 2px;
}

.template-option.is-active {
  border-color: var(--primary);
  background: #effaf7;
  box-shadow: 0 0 0 1px rgb(13 117 103 / 12%), 0 4px 12px rgb(20 78 68 / 8%);
}

.template-option strong,
.template-option small {
  display: block;
}

.template-option strong {
  font-size: 11px;
}

.template-option small {
  margin-top: 3px;
  color: var(--text-faint);
  font-size: 8px;
  line-height: 1.3;
}

.template-preview {
  position: relative;
  display: block;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border: 1px solid #d6dfdc;
  border-radius: 8px;
  background:
    linear-gradient(150deg, transparent 0 29%, rgb(109 126 121 / 18%) 30% 33%, transparent 34%),
    linear-gradient(160deg, #dbe7e3, #9cafa9);
}

.template-preview-classic::before {
  position: absolute;
  top: 17px;
  right: 0;
  left: 0;
  height: 9px;
  background: rgb(200 196 203 / 82%);
  content: "";
}

.template-preview-classic::after {
  position: absolute;
  top: 17px;
  left: 3px;
  color: rgb(255 255 255 / 92%);
  content: "••••••";
  font-size: 6px;
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 9px;
}

.template-preview-contact::before {
  position: absolute;
  right: 0;
  bottom: 3px;
  left: 0;
  height: 13px;
  background: linear-gradient(90deg, #35c5d4, #62d8df);
  content: "";
}

.template-preview-contact::after {
  position: absolute;
  top: 7px;
  left: 5px;
  width: 10px;
  height: 8px;
  border: 2px solid rgb(255 255 255 / 48%);
  border-radius: 3px;
  box-shadow: inset 0 0 0 2px rgb(41 166 176 / 24%);
  content: "";
}

.template-preview-contact i {
  position: absolute;
  bottom: 3px;
  left: 0;
  width: 15px;
  height: 13px;
  background: #fff;
  clip-path: polygon(0 0, 72% 0, 100% 100%, 0 100%);
}

.template-preview-contact b,
.template-preview-contact b::after {
  position: absolute;
  right: 3px;
  bottom: 12px;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: #1e2b2d;
}

.template-preview-contact b::after {
  right: 0;
  bottom: -5px;
  width: 14px;
  height: 1px;
  content: "";
}

.quick-ready-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 22px;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid #bfe1da;
  border-radius: 12px;
  color: #174c43;
  background: #effaf7;
}

.quick-color-swatch {
  width: 34px;
  height: 34px;
  border: 1px solid #aaa6ad;
  border-radius: 9px;
  background: #c8c4cb;
  box-shadow: inset 0 0 0 3px rgb(255 255 255 / 48%);
}

.quick-ready-card[data-template="contact"] .quick-color-swatch {
  border-color: #a7dfe4;
  background: linear-gradient(135deg, #fff 0 34%, #35c5d4 35% 67%, #62d8df 68%);
}

.quick-ready-card strong,
.quick-ready-card span {
  display: block;
}

.quick-ready-card strong {
  font-size: 11px;
}

.quick-ready-card span {
  margin-top: 2px;
  color: #58746d;
  font-size: 9px;
}

.quick-ready-card > svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

.quick-form {
  display: grid;
  gap: 14px;
  padding-top: 16px;
}

.auto-brightness-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 8px 10px;
  padding: 12px;
  border: 1px solid #eadba9;
  border-radius: 12px;
  background: linear-gradient(145deg, #fffaf0, #fffdf8);
}

.auto-brightness-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  color: #9a6712;
  background: #fff1c7;
}

.auto-brightness-icon svg,
.auto-brightness-wide svg {
  width: 20px;
  height: 20px;
}

.auto-brightness-card strong,
.auto-brightness-card span {
  display: block;
}

.auto-brightness-card strong {
  color: #5f4619;
  font-size: 11px;
}

.auto-brightness-card div > span {
  margin-top: 2px;
  color: #7e704f;
  font-size: 9px;
  line-height: 1.4;
}

.auto-brightness-card .auto-brightness-button {
  grid-column: 1 / -1;
  width: 100%;
}

.auto-brightness-card .reset-auto-brightness-button {
  grid-column: 1 / -1;
  justify-self: center;
}

.quick-brightness-range,
.brightness-scope-hint {
  grid-column: 1 / -1;
}

.quick-brightness-range {
  padding-top: 10px;
  border-top: 1px solid #eadba9;
}

.brightness-scope-hint {
  margin-top: -5px;
  color: #7e704f;
  font-size: 9px;
  line-height: 1.4;
}

.auto-brightness-wide {
  width: 100%;
}

.quick-position-field {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-muted);
}

.drag-helper {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: -7px 2px 0;
  color: var(--text-soft);
  font-size: 10px;
  line-height: 1.45;
}

.drag-helper svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--primary);
}

.quick-logo-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-muted);
}

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

.quick-logo-copy > strong,
.quick-logo-copy > span {
  display: block;
}

.quick-logo-copy > strong {
  font-size: 11px;
}

.quick-logo-copy > span {
  margin-top: 2px;
  color: var(--text-soft);
  font-size: 9px;
}

.quick-logo-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.quick-logo-actions .text-button {
  min-height: 44px;
}

.watermark-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid #a9ddd8;
  border-radius: 12px;
  background: linear-gradient(145deg, #f1fbfa, #f8fcfb);
}

.watermark-card-advanced {
  margin-top: 4px;
}

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

.watermark-heading strong,
.watermark-heading span {
  display: block;
}

.watermark-heading strong {
  color: #174c43;
  font-size: 11px;
}

.watermark-heading span {
  margin-top: 3px;
  color: var(--text-soft);
  font-size: 9px;
  line-height: 1.4;
}

.watermark-heading .switch {
  min-width: 50px;
  min-height: 44px;
  align-items: center;
  justify-content: flex-end;
  cursor: pointer;
}

.watermark-position-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.quick-reset-button {
  width: 100%;
  margin-top: 2px;
  font-size: 11px;
}

.advanced-panel {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.switch-row,
.check-row {
  display: flex;
  align-items: center;
}

.switch-row {
  min-height: 44px;
  justify-content: space-between;
  gap: 12px;
}

.switch-row strong {
  display: block;
  font-size: 12px;
}

.switch-row small {
  display: block;
  margin-top: 2px;
  color: var(--text-soft);
  font-size: 10px;
  line-height: 1.35;
}

.switch {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch-track {
  position: relative;
  width: 40px;
  height: 24px;
  border: 1px solid #c0cbc7;
  border-radius: 999px;
  background: #dce2e0;
  transition: background-color 180ms ease, border-color 180ms ease;
}

.switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgb(0 0 0 / 18%);
  content: "";
  transition: transform 180ms ease;
}

.switch input:checked + .switch-track {
  border-color: var(--primary);
  background: var(--primary);
}

.switch input:checked + .switch-track::after {
  transform: translateX(16px);
}

.switch input:focus-visible + .switch-track {
  outline: 3px solid rgb(23 166 143 / 28%);
  outline-offset: 2px;
}

.text-button {
  min-height: 44px;
  padding: 4px 0;
  border: 0;
  color: var(--primary);
  background: transparent;
  font-size: 11px;
  font-weight: 750;
}

.text-button:hover:not(:disabled) {
  text-decoration: underline;
}

.scope-card > .text-button {
  margin-top: 6px;
}

.danger-text {
  color: var(--danger);
}

.control-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.control-section {
  border-top: 1px solid var(--border);
}

.control-section:last-child {
  border-bottom: 1px solid var(--border);
}

.control-section summary {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 12px;
  font-weight: 800;
  list-style: none;
  user-select: none;
}

.control-section summary::-webkit-details-marker {
  display: none;
}

.control-section summary svg {
  width: 16px;
  height: 16px;
  transition: transform 180ms ease;
}

.control-section[open] summary svg {
  transform: rotate(180deg);
}

.control-section summary:hover {
  background: var(--surface-muted);
}

.section-body {
  display: grid;
  gap: 13px;
  padding: 2px 16px 18px;
}

.field,
.range-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field > span,
.range-label {
  color: #51605c;
  font-size: 10px;
  font-weight: 750;
}

.field input[type="text"],
.field input[type="tel"],
.field input[type="number"],
.field select {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface);
}

.field input[type="color"] {
  width: 100%;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.field input:disabled,
.field select:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  background: #f0f2f1;
}

.two-col,
.phone-grid,
.dimension-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.phone-grid {
  grid-template-columns: minmax(86px, 0.7fr) minmax(0, 1.3fr);
}

.compact-row {
  align-items: end;
}

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

.range-label output {
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  height: 24px;
  margin: 0;
  accent-color: var(--primary);
}

.mini-range {
  align-self: end;
  padding-bottom: 2px;
}

.check-row {
  min-height: 44px;
  gap: 9px;
  color: #354640;
  font-size: 11px;
  font-weight: 650;
}

.check-row input {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--primary);
}

.separator-row {
  justify-content: space-between;
  gap: 12px;
}

.separator-row .check-row {
  flex: 1;
}

.field-tiny {
  width: 64px;
}

.helper {
  margin: -3px 0 0;
  color: var(--text-faint);
  font-size: 10px;
  line-height: 1.45;
}

.logo-upload-row {
  gap: 10px;
}

.logo-preview {
  display: grid;
  width: 62px;
  height: 54px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-faint);
  background:
    linear-gradient(45deg, #edf1f0 25%, transparent 25%),
    linear-gradient(-45deg, #edf1f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf1f0 75%),
    linear-gradient(-45deg, transparent 75%, #edf1f0 75%),
    #fff;
  background-position: 0 0, 0 5px, 5px -5px, -5px 0;
  background-size: 10px 10px;
}

.logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.upload-logo-button {
  min-height: 44px;
  padding: 7px 10px;
  font-size: 10px;
}

.logo-upload-row .text-button {
  display: block;
}

.workspace {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  padding: 16px 18px 18px;
}

.workspace-toolbar {
  min-height: 39px;
  margin-bottom: 10px;
}

.workspace-toolbar h2 {
  max-width: 55vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zoom-note {
  color: var(--text-soft);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.dropzone {
  display: flex;
  min-height: 86px;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 14px 18px;
  border: 1.5px dashed #aebcb8;
  border-radius: var(--radius-md);
  color: var(--text-soft);
  background: rgb(255 255 255 / 64%);
  text-align: left;
  transition: border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.dropzone:hover,
.dropzone.is-dragging {
  border-color: var(--primary);
  background: #f2faf8;
  box-shadow: inset 0 0 0 1px rgb(13 117 103 / 8%);
}

.drop-illustration {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  color: var(--primary);
  background: var(--primary-soft);
}

.dropzone strong,
.dropzone span,
.dropzone small {
  display: block;
}

.dropzone strong {
  color: #31443e;
  font-size: 13px;
}

.dropzone span {
  font-size: 11px;
}

.dropzone label {
  color: var(--primary);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.dropzone small {
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 9px;
}

.canvas-stage,
.empty-preview {
  position: relative;
  min-height: 320px;
  flex: 1;
  margin-top: 14px;
  border: 1px solid #d4ddda;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(45deg, #dfe5e3 25%, transparent 25%),
    linear-gradient(-45deg, #dfe5e3 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dfe5e3 75%),
    linear-gradient(-45deg, transparent 75%, #dfe5e3 75%),
    #e9edec;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 48%);
}

.canvas-stage {
  display: block;
  overflow: hidden;
  padding: 0;
}

.canvas-stage[hidden] {
  display: none;
}

.canvas-viewport {
  position: absolute;
  inset: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: #95a6a1 transparent;
  scrollbar-width: thin;
}

.canvas-viewport:focus-visible {
  outline: 3px solid rgb(23 166 143 / 32%);
  outline-offset: -4px;
}

.canvas-viewport.is-zoomed {
  cursor: grab;
  touch-action: none;
}

.canvas-viewport.is-panning {
  cursor: grabbing;
  user-select: none;
}

.canvas-scroll-content {
  display: grid;
  width: max-content;
  min-width: 100%;
  height: max-content;
  min-height: 100%;
  place-items: center;
  padding: 28px;
}

#previewCanvas {
  display: block;
  max-width: none;
  max-height: none;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 18px 42px rgb(26 39 35 / 24%);
  touch-action: none;
  user-select: none;
}

#previewCanvas.can-pan {
  cursor: grab;
}

#previewCanvas.can-drag-ribbon,
#previewCanvas.is-dragging-ribbon,
#previewCanvas.can-drag-watermark,
#previewCanvas.is-dragging-watermark {
  cursor: move;
}

#previewCanvas.is-dragging-ribbon,
#previewCanvas.is-dragging-watermark {
  box-shadow: 0 18px 42px rgb(26 39 35 / 24%), 0 0 0 3px rgb(13 117 103 / 32%);
}

.drag-hint {
  position: absolute;
  top: 10px;
  left: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 9px;
  border: 1px solid rgb(255 255 255 / 52%);
  border-radius: 7px;
  color: #28443d;
  background: rgb(255 255 255 / 76%);
  box-shadow: 0 4px 12px rgb(20 40 35 / 12%);
  font-size: 9px;
  font-weight: 800;
  pointer-events: none;
  backdrop-filter: blur(8px);
  z-index: 10;
}

.drag-hint svg {
  width: 15px;
  height: 15px;
  color: var(--primary);
}

.zoom-stack {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 20;
  display: grid;
  justify-items: end;
  gap: 6px;
  pointer-events: none;
}

.zoom-controls {
  display: grid;
  grid-template-columns: 44px 64px 44px;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 62%);
  border-radius: 10px;
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 6px 18px rgb(20 40 35 / 16%);
  pointer-events: auto;
  backdrop-filter: blur(10px);
}

.zoom-button,
.zoom-value {
  min-width: 0;
  height: 44px;
  padding: 0;
  border: 0;
  color: #2e4841;
  background: transparent;
  font-weight: 800;
  transition: color 160ms ease, background-color 160ms ease;
}

.zoom-button {
  display: grid;
  place-items: center;
}

.zoom-button:hover:not(:disabled),
.zoom-value:hover:not(:disabled) {
  color: var(--primary);
  background: #e9f6f2;
}

.zoom-button:disabled,
.zoom-value:disabled {
  opacity: 0.38;
}

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

.zoom-value {
  border-right: 1px solid var(--border);
  border-left: 1px solid var(--border);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.zoom-shortcuts {
  display: grid;
  gap: 1px;
  padding: 5px 8px;
  border-radius: 7px;
  color: #4f625d;
  background: rgb(255 255 255 / 80%);
  box-shadow: 0 3px 10px rgb(20 40 35 / 10%);
  font-size: 8px;
  font-weight: 700;
  line-height: 1.35;
  text-align: right;
  backdrop-filter: blur(8px);
}

.canvas-corner {
  position: absolute;
  right: 10px;
  bottom: 9px;
  padding: 3px 7px;
  border-radius: 5px;
  color: rgb(40 55 50 / 72%);
  background: rgb(255 255 255 / 64%);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.14em;
  backdrop-filter: blur(8px);
  z-index: 10;
}

.empty-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 30px;
  color: var(--text-soft);
  text-align: center;
}

.empty-preview-icon {
  display: grid;
  width: 56px;
  height: 56px;
  margin-bottom: 12px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  color: #7d8a86;
  background: rgb(255 255 255 / 72%);
}

.empty-preview-icon svg {
  width: 26px;
  height: 26px;
}

.empty-preview strong {
  color: #43544f;
  font-size: 13px;
}

.empty-preview span {
  margin-top: 4px;
  font-size: 11px;
}

.download-bar {
  justify-content: flex-end;
  gap: 10px;
  padding-top: 14px;
}

.rail-heading {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 18px 12px 12px;
  border-bottom: 1px solid var(--border);
  background: rgb(255 255 255 / 95%);
  backdrop-filter: blur(8px);
}

.rail-heading h2 span {
  color: var(--primary);
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: #50605b;
  background: var(--surface);
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

.icon-button:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-muted);
}

.danger-icon:hover:not(:disabled) {
  border-color: #efc2c2;
  color: var(--danger);
  background: var(--danger-soft);
}

.image-list {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.image-card {
  position: relative;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 44px;
  min-height: 66px;
  align-items: center;
  gap: 9px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 11px;
  color: inherit;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.image-card:hover {
  border-color: #aebcb8;
  background: #fbfcfc;
}

.image-card.is-selected {
  border-color: var(--primary);
  background: #f4fbf9;
  box-shadow: 0 0 0 2px rgb(13 117 103 / 10%);
}

.image-card-main {
  position: absolute;
  inset: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
}

.thumb-wrap {
  position: relative;
  z-index: 1;
  display: grid;
  width: 76px;
  height: 51px;
  place-items: center;
  overflow: hidden;
  border-radius: 7px;
  background: #dfe5e3;
  pointer-events: none;
}

.thumb-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-card-copy {
  position: relative;
  z-index: 1;
  min-width: 0;
  pointer-events: none;
}

.image-card-copy strong,
.image-card-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-card-copy strong {
  color: #33443f;
  font-size: 10px;
}

.image-card-copy small {
  color: var(--text-faint);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.custom-tag {
  display: inline-block;
  margin-top: 3px;
  padding: 1px 5px;
  border-radius: 4px;
  color: #09685c;
  background: #dcf2ed;
  font-size: 8px;
  font-weight: 800;
}

.auto-brightness-tag {
  margin-left: 4px;
  color: #8a5d12;
  background: #fff0bd;
}

.delete-image {
  position: relative;
  z-index: 1;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: #75817d;
  background: transparent;
}

.delete-image:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.delete-image svg {
  width: 16px;
  height: 16px;
}

.rail-empty {
  display: grid;
  min-height: 190px;
  place-content: center;
  padding: 20px;
  color: var(--text-soft);
  text-align: center;
}

.rail-empty small {
  margin-top: 3px;
  color: var(--text-faint);
  font-size: 10px;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(10 25 21 / 50%);
  backdrop-filter: blur(4px);
}

.busy-overlay[hidden] {
  display: none;
}

.busy-card {
  display: grid;
  width: min(360px, 100%);
  place-items: center;
  padding: 28px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 30px 80px rgb(0 0 0 / 30%);
  text-align: center;
}

.preset-dialog {
  width: min(560px, calc(100vw - 28px));
  max-height: min(760px, calc(100dvh - 28px));
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 18px;
  color: var(--text);
  background: #fff;
  box-shadow: 0 30px 90px rgb(0 0 0 / 34%);
}

.preset-dialog::backdrop {
  background: rgb(10 25 21 / 54%);
  backdrop-filter: blur(5px);
}

.preset-dialog-header,
.saved-presets-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.preset-dialog-header {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: rgb(255 255 255 / 96%);
  backdrop-filter: blur(10px);
}

.preset-dialog-header h2,
.saved-presets-heading h3 {
  margin: 2px 0 0;
}

.preset-dialog-header h2 {
  font-size: 17px;
}

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

.preset-save-panel {
  display: grid;
  gap: 12px;
  margin: 18px 20px;
  padding: 16px;
  border: 1px solid #bfe1da;
  border-radius: 14px;
  background: #f3fbf9;
}

.preset-save-panel small {
  color: var(--text-soft);
  font-size: 10px;
  line-height: 1.45;
}

.saved-presets-section {
  padding: 0 20px 22px;
}

.saved-presets-heading {
  margin-bottom: 10px;
}

.saved-presets-heading h3 {
  font-size: 13px;
}

.saved-presets-heading span {
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
}

.preset-list {
  display: grid;
  gap: 8px;
}

.preset-list-empty {
  padding: 22px 16px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  color: var(--text-soft);
  background: var(--surface-muted);
  text-align: center;
  font-size: 11px;
  line-height: 1.5;
}

.preset-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.preset-list-copy {
  min-width: 0;
}

.preset-list-copy strong,
.preset-list-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset-list-copy strong {
  font-size: 11px;
}

.preset-list-copy span {
  margin-top: 3px;
  color: var(--text-faint);
  font-size: 9px;
}

.preset-list-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preset-list-actions .button {
  min-height: 44px;
  padding-inline: 12px;
  font-size: 10px;
}

.preset-delete-button {
  color: var(--danger);
}

.busy-card strong {
  margin-top: 13px;
  font-size: 16px;
}

.busy-card > span {
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 11px;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #dcece8;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.progress-track {
  width: 100%;
  height: 6px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4eae8;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 180ms ease;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 120;
  max-width: min(430px, calc(100vw - 32px));
  transform: translate(-50%, 18px);
  padding: 11px 16px;
  border: 1px solid rgb(255 255 255 / 22%);
  border-radius: 10px;
  color: #fff;
  background: #18352e;
  box-shadow: var(--shadow-md);
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (min-width: 1121px) {
  html,
  body {
    height: 100%;
  }

  body {
    overflow: hidden;
  }

  .app-shell {
    height: calc(100dvh - var(--topbar-height));
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
    overflow: hidden;
  }

  .control-panel,
  .workspace,
  .image-rail {
    height: 100%;
    min-height: 0;
  }

  .control-panel,
  .workspace {
    overflow: hidden;
  }

  .control-panel,
  .image-rail {
    max-height: none;
  }
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 310px minmax(380px, 1fr);
  }

  .image-rail {
    grid-column: 1 / -1;
    max-height: none;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .image-list {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

  .rail-heading {
    position: static;
  }

  .rail-empty {
    min-height: 110px;
  }
}

@media (max-width: 760px) {
  :root {
    --topbar-height: auto;
  }

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }

  .header-actions {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .header-actions .button {
    flex: 1 0 auto;
  }

  .app-shell {
    display: flex;
    min-height: auto;
    flex-direction: column;
  }

  .control-panel,
  .image-rail {
    max-height: none;
  }

  .control-panel {
    border-right: 0;
  }

  .control-scroll {
    overflow: visible;
  }

  .advanced-panel,
  .quick-panel {
    min-height: auto;
    overflow: visible;
  }

  .workspace {
    order: -1;
    padding: 14px 12px;
  }

  .workspace-toolbar h2 {
    max-width: 64vw;
  }

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

  .canvas-stage,
  .empty-preview {
    min-height: 280px;
  }

  .canvas-scroll-content {
    padding: 18px;
  }

  .download-bar {
    position: sticky;
    bottom: 0;
    z-index: 10;
    margin: 0 -12px -14px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: rgb(255 255 255 / 95%);
    backdrop-filter: blur(10px);
  }

  .download-bar .button {
    flex: 1;
    padding-inline: 10px;
    font-size: 11px;
  }

  .scope-card {
    margin-inline: 12px;
  }

  .image-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .brand-lockup p,
  .local-badge {
    display: none;
  }

  .dropzone {
    text-align: center;
    flex-direction: column;
  }

  .canvas-stage {
    padding: 0;
  }

  .zoom-shortcuts {
    display: none;
  }

  .zoom-controls {
    grid-template-columns: 44px 56px 44px;
  }

  .two-col,
  .dimension-grid,
  .watermark-position-grid {
    grid-template-columns: 1fr;
  }

  .compact-row {
    align-items: stretch;
  }

  .preset-save-panel {
    margin-inline: 12px;
  }

  .preset-dialog-header,
  .saved-presets-section {
    padding-inline: 12px;
  }

  .preset-list-item {
    grid-template-columns: 1fr;
  }

  .preset-list-actions .button {
    flex: 1;
  }
}

@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;
  }
}
