:root {
  color-scheme: light;
  --ink: #082d5c;
  --muted: #617084;
  --forest: #063873;
  --forest-hover: #032b5d;
  --gold: #f1bd18;
  --cream: #f2f5f8;
  --paper: #fffdf8;
  --line: #ded9ce;
  --danger: #a33a32;
  --success: #216a4d;
  --shadow: 0 18px 50px rgba(35, 48, 43, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--cream); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 4%, rgba(241, 189, 24, 0.14), transparent 28rem),
    var(--cream);
}

button, input { font: inherit; }
button, label { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
svg { display: block; fill: currentColor; }
[hidden] { display: none !important; }

.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;
}

.site-header {
  width: min(1180px, calc(100% - clamp(24px, 5vw, 48px)));
  min-height: 78px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(23, 63, 53, 0.12);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: block;
  object-fit: contain;
  border: 1px solid rgba(8, 45, 92, 0.14);
  border-radius: 13px;
  background: var(--forest);
  box-shadow: 0 8px 18px rgba(23, 63, 53, 0.18);
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 0.94rem; letter-spacing: -0.01em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 0.73rem; }

.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border: 1px solid #cfd9d3;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.66);
  color: var(--success);
  font-size: 0.76rem;
  font-weight: 750;
}

.local-badge svg { width: 16px; height: 16px; }

.page-shell {
  width: min(1180px, calc(100% - clamp(24px, 5vw, 48px)));
  margin: 0 auto;
  padding: clamp(30px, 5vw, 48px) 0 36px;
}

.intro { max-width: 730px; margin-bottom: 30px; }
.eyebrow {
  margin: 0 0 9px;
  color: #997200 !important;
  font-size: 0.76rem !important;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.intro h1 {
  max-width: 690px;
  margin: 0;
  font-size: clamp(2rem, 4.5vw, 3.45rem);
  line-height: 1.02;
  letter-spacing: -0.055em;
}

.intro p:not(.eyebrow) {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.16rem);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 370px);
  gap: clamp(16px, 2.2vw, 24px);
  align-items: start;
}

.preview-column, .preview-card, .control-card { min-width: 0; }

.preview-card, .control-card {
  border: 1px solid rgba(46, 60, 55, 0.12);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.preview-card { padding: 18px; }

.preview-heading {
  min-height: 34px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 800;
}

.preview-heading > div, .step-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-number {
  flex: 0 0 auto;
  width: 27px;
  height: 27px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #e7eee9;
  color: var(--forest);
  font-size: 0.77rem;
  font-weight: 900;
}

.resolution-label { color: var(--muted); font-size: 0.72rem; font-weight: 650; }

.canvas-shell {
  position: relative;
  width: 100%;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 1px solid #d8d3c8;
  border-radius: 16px;
  background-color: #e9e5dc;
  background-image:
    linear-gradient(45deg, rgba(23, 63, 53, 0.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(23, 63, 53, 0.035) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(23, 63, 53, 0.035) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(23, 63, 53, 0.035) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  aspect-ratio: var(--preview-aspect, 1 / 1);
  isolation: isolate;
}

#editor-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
  user-select: none;
  cursor: default;
}

#editor-canvas.is-editable { cursor: grab; }
#editor-canvas.is-editable:active { cursor: grabbing; }
#editor-canvas.is-uploadable { cursor: pointer; }
#editor-canvas:focus-visible { box-shadow: inset 0 0 0 4px rgba(211, 154, 59, 0.68); }

.empty-state, .loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 30px;
  text-align: center;
  pointer-events: none;
}

.empty-state {
  background: rgba(247, 244, 236, 0.83);
  backdrop-filter: blur(3px);
}

.empty-state strong { font-size: 1rem; }
.empty-state #empty-copy { color: var(--muted); font-size: 0.82rem; }

.empty-action {
  margin-top: 6px;
  padding: 8px 13px;
  border-radius: 999px;
  background: var(--forest);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 850;
  box-shadow: 0 8px 18px rgba(6, 56, 115, 0.18);
}

.empty-icon {
  width: 58px;
  height: 58px;
  margin-bottom: 5px;
  display: grid;
  place-items: center;
  border: 1px solid #ced8d2;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--forest);
}
.empty-icon svg { width: 26px; height: 26px; }

.loading-overlay {
  z-index: 3;
  background: rgba(255, 253, 248, 0.91);
  color: var(--forest);
  font-size: 0.9rem;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid #d6dfda;
  border-top-color: var(--forest);
  border-radius: 50%;
  animation: spin 0.72s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.gesture-hint {
  margin: 11px 0 -2px;
  color: var(--muted);
  text-align: center;
  font-size: 0.76rem;
}

.control-card {
  position: sticky;
  top: 18px;
  padding: clamp(19px, 2.2vw, 24px);
}

.step-heading { align-items: flex-start; margin-bottom: 20px; }
.step-heading h2 { margin: 0; font-size: 1.07rem; letter-spacing: -0.02em; }
.step-heading p { margin: 4px 0 0; color: var(--muted); font-size: 0.78rem; }

.order-summary {
  margin: -4px 0 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.order-summary > span {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid #d9e2dc;
  border-radius: 12px;
  background: #f2f7f4;
}

.order-summary small, .order-summary strong { display: block; }
.order-summary small { color: var(--muted); font-size: 0.62rem; line-height: 1.25; }
.order-summary strong { margin-top: 3px; overflow: hidden; font-size: 0.79rem; text-overflow: ellipsis; white-space: nowrap; }

.template-section {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #f8fafc;
}

.template-label {
  margin-bottom: 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.77rem;
  font-weight: 850;
}

.template-label small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.template-picker {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 70px;
  gap: 8px;
  padding: 2px 2px 7px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: #b8c2ce transparent;
}

.template-option {
  position: relative;
  width: 70px;
  min-height: 78px;
  padding: 5px 5px 18px;
  overflow: hidden;
  border: 2px solid #d7dee6;
  border-radius: 11px;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #eef1f4 25%, transparent 25%),
    linear-gradient(-45deg, #eef1f4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef1f4 75%),
    linear-gradient(-45deg, transparent 75%, #eef1f4 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  color: var(--ink);
  cursor: pointer;
  scroll-snap-align: start;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.template-option img {
  width: 100%;
  height: 54px;
  display: block;
  object-fit: contain;
  pointer-events: none;
}

.template-option span {
  position: absolute;
  inset: auto 0 3px;
  font-size: 0.62rem;
  font-weight: 850;
  text-align: center;
}

.template-option[aria-pressed="true"] {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(241, 189, 24, 0.22);
}

.template-option:hover:not(:disabled) { border-color: #8396ab; }
.template-option:disabled { opacity: 0.55; cursor: wait; }

.upload-button, .download-button, .secondary-button, .icon-button {
  border: 0;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.upload-button {
  width: 100%;
  min-height: 49px;
  gap: 9px;
  border: 1px solid var(--forest);
  background: var(--forest);
  color: #fff;
  font-size: 0.9rem;
}
.upload-button svg, .download-button svg { width: 20px; height: 20px; }
.upload-button:hover { background: var(--forest-hover); }
.upload-button.is-disabled { opacity: 0.48; cursor: not-allowed; }

.file-help {
  margin: 9px 0 20px;
  color: var(--muted);
  text-align: center;
  font-size: 0.7rem;
}

.photo-controls { min-width: 0; margin: 0 0 18px; padding: 0; border: 0; }
.control-group { padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: #faf8f2; }
.control-group > label { display: block; margin-bottom: 11px; font-size: 0.77rem; font-weight: 850; }
.zoom-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) 36px; align-items: center; gap: 10px; }

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 1.22rem;
}

input[type="range"] {
  width: 100%;
  height: 22px;
  margin: 0;
  accent-color: var(--forest);
  cursor: pointer;
}

.button-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 10px; }
.secondary-button {
  min-height: 43px;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.72rem;
  line-height: 1.15;
}
.secondary-button svg { width: 17px; height: 17px; }
.secondary-button span { font-size: 1.13rem; }
.secondary-button:hover, .icon-button:hover { border-color: #aebcb5; background: #f6f8f6; }

button:focus-visible, .upload-button:focus-within {
  outline: 3px solid rgba(211, 154, 59, 0.45);
  outline-offset: 2px;
}

button:active:not(:disabled), .upload-button:active:not(.is-disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.status-message {
  min-height: 20px;
  margin: 0 0 11px;
  color: var(--muted);
  text-align: center;
  font-size: 0.74rem;
  line-height: 1.4;
}
.status-message[data-tone="error"] { color: var(--danger); }
.status-message[data-tone="success"] { color: var(--success); font-weight: 750; }
.status-message[data-tone="warning"] { color: #8a6700; }

.download-button {
  width: 100%;
  min-height: 54px;
  gap: 10px;
  background: var(--gold);
  color: #082d5c;
  box-shadow: 0 10px 24px rgba(211, 154, 59, 0.23);
  font-size: 0.94rem;
}
.download-button:hover:not(:disabled) { background: #dda64b; box-shadow: 0 12px 28px rgba(211, 154, 59, 0.3); }

.how-it-works {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.how-it-works > div {
  min-height: 74px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 18px;
  border: 1px solid rgba(46, 60, 55, 0.1);
  border-radius: 16px;
  background: rgba(255, 253, 248, 0.58);
}
.how-it-works span { color: var(--gold); font-size: 1.25rem; font-weight: 950; }
.how-it-works p { margin: 0; color: var(--muted); font-size: 0.78rem; }
.how-it-works strong { color: var(--ink); }

footer {
  padding: 20px 20px calc(22px + env(safe-area-inset-bottom));
  color: var(--muted);
  text-align: center;
  font-size: 0.72rem;
}

@media (max-width: 920px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .control-card { position: static; }
  .preview-column, .control-card { max-width: 720px; width: 100%; margin-inline: auto; }
}

@media (max-width: 600px) {
  .site-header { width: min(100% - 24px, 1180px); min-height: 68px; gap: 12px; }
  .local-badge { width: 34px; height: 34px; justify-content: center; padding: 0; }
  .local-badge svg { width: 18px; height: 18px; }
  .local-badge { font-size: 0; }
  .brand { min-width: 0; gap: 9px; }
  .brand-mark { width: 42px; height: 42px; border-radius: 11px; }
  .brand > span { min-width: 0; }
  .brand strong { overflow: hidden; font-size: 0.88rem; text-overflow: ellipsis; white-space: nowrap; }
  .brand small { font-size: 0.68rem; }
  .page-shell { width: min(100% - 16px, 1180px); padding: 25px 0 28px; }
  .intro { margin-bottom: 22px; }
  .intro { padding-inline: 4px; }
  .intro h1 { font-size: clamp(1.72rem, 8.8vw, 2.35rem); line-height: 1.04; }
  .intro p:not(.eyebrow) { margin-top: 11px; font-size: 0.94rem; line-height: 1.45; }
  .workspace { gap: 14px; }
  .preview-card { padding: 9px; border-radius: 18px; }
  .preview-heading { margin: 3px 3px 11px; }
  .resolution-label { display: none; }
  .canvas-shell { border-radius: 11px; }
  .empty-state, .loading-overlay { gap: 7px; padding: 18px; }
  .empty-icon { width: 50px; height: 50px; border-radius: 15px; }
  .empty-action { padding: 8px 12px; }
  .control-card { padding: 18px 13px; border-radius: 18px; }
  .order-summary { margin-bottom: 14px; }
  .template-section { padding: 12px; }
  .template-picker { grid-auto-columns: 68px; }
  .template-option { width: 68px; }
  .button-grid { gap: 8px; }
  .secondary-button { min-height: 48px; padding-inline: 5px; }
  .upload-button { min-height: 52px; }
  .download-button { min-height: 58px; }
  .how-it-works { grid-template-columns: 1fr; gap: 8px; }
  .how-it-works > div { min-height: 62px; }
}

@media (max-width: 380px) {
  .site-header { width: min(100% - 18px, 1180px); }
  .brand-mark { width: 39px; height: 39px; }
  .brand strong { max-width: 172px; font-size: 0.82rem; }
  .brand small { font-size: 0.64rem; }
  .page-shell { width: min(100% - 10px, 1180px); }
  .preview-heading { font-size: 0.83rem; }
  .step-number { width: 25px; height: 25px; }
  .control-card { padding-inline: 11px; }
  .secondary-button { font-size: 0.68rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: 0.01ms !important; }
}
