:root {
  color-scheme: light;
  --brand: #f16a12;
  --brand-dark: #d94f00;
  --brand-end: #ed4f00;
  --brand-rgb: 241 106 18;
  --page-start: #fffdfb;
  --page-middle: #fff7f0;
  --page-end: #fdf0e6;
  --ink: #252525;
  --muted: #73706d;
  --paper: #fffaf6;
  --surface: rgba(255, 255, 255, 0.82);
  --line: rgba(70, 44, 30, 0.12);
  --shadow: 0 24px 70px rgba(96, 52, 25, 0.12);
  font-family: Geologica, Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@font-face {
  font-family: Geologica;
  src: url("/assets/Geologica-Variable.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 92% 8%, rgb(var(--brand-rgb) / 0.15), transparent 34%),
    linear-gradient(145deg, var(--page-start) 0%, var(--page-middle) 55%, var(--page-end) 100%);
  transition: background 240ms ease;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  width: min(1500px, calc(100% - 48px));
  margin: 0 auto;
  min-height: 108px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: white;
  background: var(--brand);
  transition: background 180ms ease;
}

.brand-mark img {
  width: 27px;
  height: 27px;
  display: block;
}

.brand-heading {
  display: grid;
  gap: 3px;
}

.brand-selector {
  position: relative;
  width: max-content;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  color: var(--brand-dark);
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  font-weight: 680;
}

.brand-selector select {
  width: auto;
  min-width: 0;
  height: 38px;
  padding: 0 28px 0 0;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: 0;
  outline: 0;
  color: var(--brand-dark);
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  font-size: 15px;
  font-weight: 680;
}

.brand-selector select:focus {
  border: 0;
  box-shadow: none;
}

.select-chevron {
  position: absolute;
  top: 50%;
  right: 3px;
  width: 18px;
  height: 18px;
  pointer-events: none;
  transform: translateY(-50%);
}

.select-chevron path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.eyebrow,
.step {
  margin: 0 0 5px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.035em;
}

h1 {
  font-size: clamp(22px, 3vw, 31px);
}

h2 {
  font-size: 23px;
}

h3 {
  font-size: 15px;
}

.heading-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.service-state {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.header-state {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.header-state time {
  color: #96887e;
  font-size: 11px;
}

.service-state span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #d6b69f;
  box-shadow: 0 0 0 5px rgba(214, 182, 159, 0.2);
}

.service-state.ready span {
  background: #2aa36b;
  box-shadow: 0 0 0 5px rgba(42, 163, 107, 0.16);
}

.workspace {
  width: min(1500px, calc(100% - 48px));
  margin: 0 auto 48px;
  display: grid;
  grid-template-columns: minmax(390px, 0.78fr) minmax(580px, 1.45fr);
  gap: 22px;
  align-items: start;
}

.panel {
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 30px;
  background: var(--surface);
  backdrop-filter: blur(30px);
  box-shadow: var(--shadow);
}

.controls {
  padding: 28px;
}

.preview-panel {
  padding: 28px;
  position: sticky;
  top: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 25px;
}

.panel-heading.compact-heading {
  margin-bottom: 18px;
}

.template-chip {
  padding: 9px 12px;
  border-radius: 999px;
  color: var(--brand-dark);
  background: rgb(var(--brand-rgb) / 0.1);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

form,
label {
  display: grid;
}

form {
  gap: 17px;
}

.mode-switch,
.scale-switch {
  padding: 4px;
  display: grid;
  border-radius: 14px;
  background: #f0e7e0;
}

.mode-switch {
  grid-template-columns: 1fr 1fr;
}

.mode-switch button,
.scale-switch button {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  color: #756a62;
  background: transparent;
  cursor: pointer;
  font-weight: 620;
}

.mode-switch button.active,
.scale-switch button.active {
  color: var(--brand-dark);
  background: #fff;
  box-shadow: 0 3px 8px rgba(103, 73, 50, 0.1);
}

.flow-panel {
  display: none;
}

.flow-panel.active {
  display: grid;
  gap: 17px;
}

.fine-settings {
  display: grid;
  gap: 13px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.48);
}

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

.fine-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.fine-settings .section-heading span,
.field-help {
  color: var(--muted);
  font-size: 11px;
}

.field-help {
  margin: 0;
}

label {
  gap: 8px;
}

label > span {
  color: #514d49;
  font-size: 13px;
  font-weight: 620;
}

label > span small {
  margin-left: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 430;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input,
select {
  height: 48px;
  padding: 0 14px;
}

select {
  padding: 0 46px 0 14px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='m5.5 7.5 4.5 4.5 4.5-4.5' stroke='%23514d49' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 18px 18px;
}

textarea {
  resize: vertical;
  padding: 13px 14px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgb(var(--brand-rgb) / 0.65);
  box-shadow: 0 0 0 4px rgb(var(--brand-rgb) / 0.09);
}

input:disabled,
select:disabled,
button:disabled {
  cursor: not-allowed;
}

input:disabled,
select:disabled {
  color: #9a928c;
  background: rgba(244, 240, 236, 0.78);
}

.field-grid {
  display: grid;
  grid-template-columns: 0.7fr 1.3fr;
  gap: 12px;
}

.field-grid.compact {
  grid-template-columns: 1fr 1fr;
}

.field-grid.catalog-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid.catalog-grid > label:first-child {
  grid-column: 1 / -1;
}

.source-box {
  position: relative;
  padding: 14px;
  border: 1px solid rgb(var(--brand-rgb) / 0.12);
  border-radius: 18px;
  background: rgb(var(--brand-rgb) / 0.045);
}

.source-box.loading input {
  padding-right: 44px;
}

.device-section {
  display: grid;
  gap: 14px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.section-heading span {
  color: var(--muted);
  font-size: 11px;
}

.media-source {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.48);
}

.media-source summary {
  cursor: pointer;
  color: #514d49;
  font-size: 13px;
  font-weight: 650;
}

.media-source summary small {
  margin-left: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 430;
}

.media-source[open] summary {
  margin-bottom: 13px;
}

.media-source label {
  margin-bottom: 10px;
}

.scale-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.scale-field legend {
  margin-bottom: 8px;
  color: #514d49;
  font-size: 13px;
  font-weight: 620;
}

.scale-switch {
  grid-template-columns: repeat(3, 1fr);
}

.custom-scale {
  margin-top: 10px;
  gap: 6px;
}

.custom-scale small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.batch-options {
  padding: 13px 14px;
  border: 1px solid rgba(42, 163, 107, 0.12);
  border-radius: 15px;
  background: rgba(42, 163, 107, 0.06);
}

.batch-summary {
  padding: 14px;
  display: grid;
  gap: 3px;
  border-radius: 14px;
  color: #2c2927;
  background: #f1f8f3;
}

.batch-summary b {
  font-size: 13px;
}

.batch-summary span,
.fine-print {
  color: #756d67;
  font-size: 11px;
}

.check-row {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
}

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

.fine-print {
  margin: 0;
  line-height: 1.5;
}

.action-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.load-button {
  min-width: 104px;
  border: 0;
  border-radius: 13px;
  color: #fff;
  background: var(--brand);
  cursor: pointer;
  font-size: 12px;
  font-weight: 680;
}

.load-button:disabled {
  cursor: wait;
  opacity: 0.56;
}

.catalog-state {
  min-height: 24px;
  margin-top: 9px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.catalog-state i {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #d6b69f;
  box-shadow: 0 0 0 4px rgba(214, 182, 159, 0.18);
}

.catalog-state.neutral {
  color: #837a73;
}

.catalog-state.disabled {
  color: #8b8179;
}

.catalog-state.disabled i {
  background: #b8aea6;
  box-shadow: 0 0 0 4px rgba(184, 174, 166, 0.13);
}

.catalog-state.loading i,
.canvas-loading i {
  border: 2px solid rgb(var(--brand-rgb) / 0.18);
  border-top-color: var(--brand);
  background: transparent;
  box-shadow: none;
  animation: spin 700ms linear infinite;
}

.catalog-state.success {
  color: #24734f;
}

.catalog-state.success i {
  background: #2aa36b;
  box-shadow: 0 0 0 4px rgba(42, 163, 107, 0.13);
}

.catalog-state.error {
  color: #b6291d;
}

.catalog-state.error i {
  background: #d04838;
  box-shadow: 0 0 0 4px rgba(208, 72, 56, 0.12);
}

.catalog-issues {
  margin-top: 6px;
  color: #b6291d;
  font-size: 11px;
  line-height: 1.45;
}

.catalog-issues strong {
  font-weight: 700;
}

.upload-row {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.file-button,
.text-button,
.secondary-button,
.result-link,
.icon-button {
  border: 0;
  cursor: pointer;
  text-decoration: none;
}

.file-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  color: #3f3b37;
  background: #f2ede8;
  font-size: 13px;
  font-weight: 650;
}

.file-button {
  min-height: 38px;
  padding: 0 13px;
}

.text-button {
  padding: 5px 0;
  color: var(--brand-dark);
  background: transparent;
  font-size: 13px;
  font-weight: 650;
}

.file-name {
  flex: 1 1 170px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-button {
  height: 56px;
  margin-top: 4px;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 0;
  border-radius: 17px;
  color: white;
  background: linear-gradient(135deg, var(--brand), var(--brand-end));
  box-shadow: 0 13px 30px rgb(var(--brand-rgb) / 0.25);
  cursor: pointer;
  font-weight: 700;
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 35px rgb(var(--brand-rgb) / 0.32);
}

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

.primary-button.is-loading:disabled {
  cursor: wait;
}

.batch-box {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.batch-box summary {
  cursor: pointer;
  color: #3a3734;
  font-weight: 680;
}

.batch-box p {
  margin: 10px 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.secondary-button {
  min-height: 42px;
  width: 100%;
  margin-top: 10px;
}

.batch-progress {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.canvas-shell {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  display: grid;
  place-items: center;
  border-radius: 19px;
  background: #eee7e1;
  box-shadow: inset 0 0 0 1px rgba(76, 54, 39, 0.08);
}

.canvas-shell.dragging {
  box-shadow: inset 0 0 0 3px var(--brand);
}

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

.canvas-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 6px;
  text-align: center;
  color: #403b36;
  background: rgba(255, 250, 246, 0.26);
  backdrop-filter: blur(2px);
}

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

.canvas-loading {
  position: absolute;
  right: 14px;
  bottom: 14px;
  min-height: 38px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  color: #4a433e;
  background: rgba(255, 250, 246, 0.8);
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 24px rgba(67, 43, 27, 0.12);
  font-size: 11px;
}

.canvas-loading i {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.canvas-empty.hidden,
.hidden {
  display: none !important;
}

.status-row {
  margin-top: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.status,
.result-meta {
  font-size: 12px;
}

.status {
  color: #3e3a36;
}

.status.error {
  color: #b6291d;
}

.result-meta {
  color: var(--muted);
  white-space: nowrap;
}

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

.auth-form { display: flex; align-items: center; gap: 6px; }
.auth-form input { width: 110px; min-height: 32px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.auth-form .text-button { white-space: nowrap; }
@media (max-width: 760px) { .auth-form input { width: 84px; } }

.result-link,
.icon-button {
  padding: 9px 12px;
  border-radius: 11px;
  color: var(--brand-dark);
  background: rgb(var(--brand-rgb) / 0.1);
  font-size: 12px;
  font-weight: 680;
}

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

@media (max-width: 1050px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    position: static;
  }
}

@media (max-width: 620px) {
  .topbar,
  .workspace {
    width: min(100% - 24px, 1500px);
  }

  .topbar {
    min-height: 90px;
    align-items: flex-start;
    padding: 16px 0;
  }

  .service-state {
    display: none;
  }

  .header-state time {
    max-width: 140px;
    text-align: right;
  }

  .controls,
  .preview-panel {
    padding: 18px;
    border-radius: 22px;
  }

  .field-grid,
  .field-grid.compact,
  .field-grid.catalog-grid,
  .action-field {
    grid-template-columns: 1fr;
  }

  .load-button {
    min-height: 44px;
  }

  label > span small {
    display: block;
    margin: 3px 0 0;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}
