[hidden] { display: none !important; }

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-muted: #f8f8fa;
  --ink: #202126;
  --muted: #6d7078;
  --line: #e4e5e9;
  --line-strong: #d5d7dc;
  --brand: #e52f39;
  --brand-dark: #bd2029;
  --brand-soft: #fff0f1;
  --success: #16784b;
  --success-soft: #eaf7f0;
  --warning: #9b5b00;
  --warning-soft: #fff7e7;
  --danger: #b7252d;
  --danger-soft: #fff0f1;
  --shadow: 0 14px 40px rgba(24, 27, 36, 0.08);
  --radius: 18px;
  --radius-small: 11px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; }
button, select, input[type="range"], input[type="file"], input[type="color"] { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(229, 47, 57, 0.24);
  outline-offset: 2px;
}
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { min-height: 100vh; }
.topbar {
  height: 76px;
  padding: 0 clamp(18px, 3vw, 46px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.08em;
}
.brand strong { display: block; letter-spacing: 0.08em; font-size: 16px; }
.brand small { display: block; margin-top: 1px; color: var(--muted); font-size: 12px; }
.topbar-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.autosave-dot { width: 8px; height: 8px; border-radius: 50%; background: #42a876; box-shadow: 0 0 0 4px #e8f7ef; }

.steps {
  min-height: 54px;
  padding: 9px clamp(18px, 3vw, 46px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 4vw, 58px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.step { position: relative; display: flex; align-items: center; gap: 8px; color: #9a9da4; font-size: 13px; font-weight: 700; white-space: nowrap; }
.step b { width: 25px; height: 25px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; background: #fff; font-size: 11px; }
.step.active { color: var(--ink); }
.step.active b { border-color: var(--brand); background: var(--brand); color: #fff; }
.step:not(:last-child)::after { content: ""; position: absolute; left: calc(100% + 9px); width: clamp(0px, 2.2vw, 36px); height: 1px; background: var(--line-strong); }

.workspace {
  width: min(1720px, 100%);
  margin: 0 auto;
  padding: 24px clamp(14px, 2vw, 30px) 42px;
  display: grid;
  grid-template-columns: minmax(280px, 350px) minmax(500px, 1fr) minmax(300px, 370px);
  gap: 22px;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 25px rgba(31, 34, 43, 0.035);
  overflow: hidden;
}
.panel-section { padding: 22px; border-bottom: 1px solid var(--line); }
.panel-section:last-child { border-bottom: 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 17px; }
.section-heading.compact { margin-bottom: 14px; }
.section-heading h2 { margin: 2px 0 0; font-size: 17px; line-height: 1.2; letter-spacing: -0.015em; }
.eyebrow { display: block; color: var(--brand); font-size: 10px; line-height: 1.2; font-weight: 900; letter-spacing: 0.14em; text-transform: uppercase; }

.field { display: grid; gap: 7px; margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.field > span, .range-field > span { color: #4a4d54; font-size: 12px; font-weight: 750; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; align-items: start; gap: 10px; }
.field-row > .field { min-width: 0; align-self: start; margin-bottom: 13px; }
input[type="text"], input[type="email"], input[type="tel"], select, textarea,
.customer-section input:not([type="checkbox"]) {
  width: 100%;
  min-height: 43px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { min-height: 70px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #bfc1c7; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(229, 47, 57, 0.08); outline: 0; }
.color-field { grid-template-columns: 1fr; }
input[type="color"] { width: 100%; height: 43px; padding: 4px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; }

.tool-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 14px; padding: 4px; border-radius: 10px; background: #f0f1f3; }
.tool-tab { min-height: 37px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 800; }
.tool-tab.active { background: #fff; color: var(--ink); box-shadow: 0 2px 7px rgba(30, 34, 43, 0.09); }
.tool-content { display: none; }
.tool-content.active { display: block; }
.upload-zone {
  min-height: 132px;
  padding: 19px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1.5px dashed #c8cbd1;
  border-radius: 13px;
  background: var(--surface-muted);
  transition: border-color .15s, background .15s, transform .15s;
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.dragging { border-color: var(--brand); background: var(--brand-soft); transform: translateY(-1px); }
.upload-icon { width: 40px; height: 40px; display: grid; place-items: center; margin-bottom: 9px; border-radius: 12px; background: #fff; color: var(--brand); box-shadow: 0 3px 12px rgba(40, 42, 50, 0.08); }
.upload-icon svg { width: 22px; height: 22px; }
.upload-zone strong { font-size: 13px; }
.upload-zone small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.switch-line { margin-top: 15px; display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 10px; cursor: pointer; }
.switch-line input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 36px; height: 21px; position: relative; border-radius: 20px; background: #d9dbe0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .15s; }
.switch-line input:checked + .switch { background: var(--brand); }
.switch-line input:checked + .switch::after { transform: translateX(15px); }
.switch-line span:last-child { display: grid; }
.switch-line strong { font-size: 12px; }
.switch-line small { color: var(--muted); font-size: 10px; }
.background-status { margin: 9px 0 0 46px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.background-status.loading { color: var(--warning); }
.background-status.ready { color: var(--success); }
.background-status.error { color: var(--danger); }

.button { min-height: 44px; padding: 10px 17px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; border: 1px solid transparent; border-radius: 10px; text-decoration: none; font-weight: 850; font-size: 13px; transition: transform .12s, box-shadow .12s, background .12s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .58; transform: none; }
.button.primary { background: var(--brand); color: #fff; box-shadow: 0 8px 18px rgba(229, 47, 57, .2); }
.button.primary:hover { background: var(--brand-dark); }
.button.secondary { border-color: var(--line-strong); background: #fff; color: var(--ink); }
.button.secondary:hover { background: var(--surface-muted); }
.button.full { width: 100%; }
.button svg { width: 19px; height: 19px; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--muted); }
.icon-button svg { width: 18px; height: 18px; }
.icon-button.danger:hover { border-color: #f2b8bc; background: var(--danger-soft); color: var(--danger); }

.range-field { display: grid; gap: 9px; margin-bottom: 15px; }
.range-field > span { display: flex; justify-content: space-between; align-items: center; }
.range-field output { color: var(--muted); font-weight: 650; }
input[type="range"] { width: 100%; accent-color: var(--brand); }
.format-buttons { display: flex; gap: 7px; margin-top: 3px; }
.format-buttons button { width: 40px; height: 36px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; }
.format-buttons button[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }

.designer-column { min-width: 0; }
.designer-toolbar { min-height: 62px; display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 14px; padding: 0 5px; }
.designer-toolbar h1 { margin: 4px 0 0; font-size: clamp(21px, 2vw, 30px); line-height: 1.15; letter-spacing: -0.04em; }
.side-pill { padding: 7px 11px; border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; color: var(--muted); font-size: 11px; font-weight: 800; white-space: nowrap; }
.canvas-stage {
  position: relative;
  width: 100%;
  min-height: 610px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 32%, rgba(255,255,255,.98), rgba(248,249,251,.92) 42%, rgba(238,240,244,.9) 100%),
    linear-gradient(45deg, #f4f5f7 25%, transparent 25%);
  box-shadow: var(--shadow);
}
.canvas-stage::before { content: ""; position: absolute; inset: auto 10% 6% 10%; height: 8%; border-radius: 50%; background: rgba(35, 39, 49, .11); filter: blur(22px); }
#designer-canvas { width: min(100%, 680px); height: auto; max-height: 720px; position: relative; z-index: 1; touch-action: none; user-select: none; cursor: default; }
.canvas-empty { position: absolute; z-index: 2; left: 50%; top: 51%; transform: translate(-50%, -50%); display: flex; flex-direction: column; padding: 9px 13px; border: 1px solid rgba(255,255,255,.38); border-radius: 11px; background: rgba(255,255,255,.68); box-shadow: 0 5px 18px rgba(20,24,34,.07); backdrop-filter: blur(7px); text-align: center; pointer-events: none; }
.canvas-empty strong { font-size: 13px; }
.canvas-empty span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.canvas-empty[hidden] { display: none; }
.print-area-label { position: absolute; z-index: 2; bottom: 15px; left: 50%; transform: translateX(-50%); padding: 5px 9px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.86); color: var(--muted); backdrop-filter: blur(8px); font-size: 10px; font-weight: 700; }
.canvas-help { margin: 10px 4px 14px; color: var(--muted); text-align: center; font-size: 11px; }
.canvas-help span { margin-right: 5px; color: var(--brand); font-weight: 900; }

.quality-card { min-height: 83px; padding: 15px 16px; display: grid; grid-template-columns: auto 1fr auto; gap: 13px; align-items: center; border: 1px solid var(--line); border-radius: 15px; background: #fff; transition: background .2s, border-color .2s; }
.quality-icon { width: 37px; height: 37px; display: grid; place-items: center; border-radius: 50%; background: #eef0f3; color: var(--muted); font-weight: 900; }
.quality-copy strong { display: block; font-size: 13px; }
.quality-copy p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.quality-badge { padding: 5px 9px; border-radius: 30px; background: #eef0f3; color: var(--muted); font-size: 10px; font-weight: 900; text-transform: uppercase; }
.quality-card.ready { border-color: #bce4cf; background: var(--success-soft); }
.quality-card.ready .quality-icon, .quality-card.ready .quality-badge { background: #d4efdf; color: var(--success); }
.quality-card.review { border-color: #efdaa9; background: var(--warning-soft); }
.quality-card.review .quality-icon, .quality-card.review .quality-badge { background: #f8e7bd; color: var(--warning); }
.quality-card.blocked { border-color: #efc0c3; background: var(--danger-soft); }
.quality-card.blocked .quality-icon, .quality-card.blocked .quality-badge { background: #f6d9db; color: var(--danger); }

.checkout-panel { position: sticky; top: 16px; }
.summary-list { margin: 0; display: grid; gap: 9px; }
.summary-list > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.summary-list dt { color: var(--muted); font-size: 11px; }
.summary-list dd { margin: 0; text-align: right; font-size: 12px; font-weight: 800; }
.production-note { margin-top: 17px; padding: 12px; display: grid; grid-template-columns: auto 1fr; gap: 10px; border-radius: 11px; background: #f5f6f8; color: #575a62; }
.production-note svg { width: 22px; height: 22px; color: var(--brand); }
.production-note span { font-size: 10px; }
.production-note strong { display: block; margin-bottom: 2px; color: var(--ink); font-size: 11px; }
.customer-section .field { margin-bottom: 11px; }
.consent-line { display: grid; grid-template-columns: auto 1fr; gap: 9px; align-items: start; margin: 14px 0; color: #575a62; font-size: 10px; cursor: pointer; }
.consent-line input { margin: 2px 0 0; accent-color: var(--brand); }
.submit-disclaimer { margin: 9px 3px 0; color: var(--muted); text-align: center; font-size: 9.5px; }

.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: grid; gap: 10px; pointer-events: none; }
.toast { max-width: 380px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow); font-size: 12px; animation: toast-in .2s ease-out; }
.toast.error { border-color: #efb7bb; background: #fff5f5; color: var(--danger); }
.toast.success { border-color: #b6dfc8; background: #f1fbf5; color: var(--success); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.success-dialog { width: min(520px, calc(100% - 28px)); padding: 33px; border: 0; border-radius: 22px; text-align: center; color: var(--ink); box-shadow: 0 28px 90px rgba(17, 20, 29, .25); }
.success-dialog::backdrop { background: rgba(24, 27, 35, .56); backdrop-filter: blur(4px); }
.success-symbol { width: 64px; height: 64px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 50%; background: var(--success-soft); color: var(--success); font-size: 30px; font-weight: 900; }
.success-dialog h2 { margin: 6px 0 10px; font-size: 24px; letter-spacing: -.03em; }
.success-dialog p { color: #565961; }
.success-status { width: fit-content; margin: 17px auto; padding: 7px 12px; border-radius: 30px; background: var(--warning-soft); color: var(--warning); font-size: 11px; font-weight: 850; }
.success-dialog .muted { color: var(--muted); font-size: 12px; }
.dialog-actions { margin-top: 22px; display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.spinner { width: 17px; height: 17px; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.preview-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; padding: 12px; margin-bottom: 12px; background: white; border: 1px solid var(--line); border-radius: 13px; }
.preview-controls .field { margin: 0; flex: 1; min-width: 120px; }
.selected-text-toolbar { display: flex; flex: 2; gap: 12px; align-items: end; }
.selected-text-toolbar[hidden] { display: none; }
.preview-controls output { font: 11px monospace; }
.draft-actions { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; margin: 14px 0 6px; }
.draft-actions .field { flex: 1; margin: 0; min-width: 150px; }
.drafts-dialog { width: min(780px, calc(100% - 28px)); max-height: 85vh; padding: 24px; border: 0; border-radius: 18px; color: var(--ink); }
.drafts-dialog::backdrop { background: rgba(24,27,35,.56); }
.drafts-dialog > p { color: var(--muted); font-size: 13px; }
.drafts-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; }
.draft-card { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.draft-card img { width: 100%; height: 160px; object-fit: contain; background: #f7f8fa; border-radius: 8px; }
.draft-card small { color: var(--muted); }

.side-tabs { display: flex; gap: 8px; margin-bottom: 6px; }
.side-tabs .button { flex: 1; }
.side-tabs .active { color: var(--brand); background: var(--brand-soft); border-color: var(--brand); }
.side-help { color: var(--muted); font-size: 11px; margin: 0 3px 10px; }
.canvas-container { position: relative; }
.canvas-scroll-down { display: none; position: absolute; top: 0; left: 50%; transform: translate(-50%, -50%); z-index: 4; width: 44px; height: 44px; padding: 0; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; background: #fff; color: var(--brand); cursor: pointer; touch-action: pan-y; }
.canvas-scroll-down svg { width: 22px; height: 22px; }
.canvas-delete { position: absolute; bottom: 8px; left: 8px; z-index: 4; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line-strong); border-radius: 12px; color: var(--danger); background: #fffffff2; touch-action: pan-y; }
.canvas-delete svg { width: 20px; height: 20px; }
.canvas-delete:hover:not(:disabled) { background: var(--danger-soft); border-color: #f2b8bc; }
.canvas-delete:disabled { opacity: .4; cursor: default; }
.selection-section { scroll-margin-top: 16px; }
.selection-section .selected-text-toolbar { display: grid; grid-template-columns: 1fr; margin-bottom: 14px; }
.selection-section .selected-text-toolbar .field { min-width: 0; }
.selection-section .selected-text-toolbar output { font: 11px monospace; }

@media (min-width: 1100px) {
  .workspace { grid-template-columns: minmax(230px, 280px) minmax(340px, 1fr) minmax(260px, 310px); gap: 20px; }
  .designer-column { position: sticky; top: 12px; }
  .canvas-stage { min-height: 0; }
  #designer-canvas { max-height: 65vh; width: auto; max-width: 100%; }
  .checkout-panel { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; overscroll-behavior: contain; }
  .checkout-panel .selection-section { border-bottom: 1px solid var(--line); }
  #text-tool .field-row { grid-template-columns: 1fr; }
}

@media (min-width: 1100px) and (max-width: 1260px) {
  .workspace { gap: 12px; padding-inline: 12px; }
  .panel-section { padding: 16px; }
}
@media (max-width: 1099px) {
  .canvas-scroll-down { display: grid; }
  .preview-controls { margin-bottom: 26px; }
  .topbar-meta { display: none; }
  .steps { justify-content: flex-start; overflow-x: auto; }
  .step:not(:last-child)::after { display: none; }
  .workspace { grid-template-columns: 1fr; padding-top: 16px; }
  .designer-column { grid-row: 1; }
  .controls-panel { grid-row: 2; }
  .checkout-panel { grid-row: 3; grid-column: auto; display: block; }
  .checkout-panel .summary-section { border-right: 0; border-bottom: 1px solid var(--line); }
  .canvas-stage { min-height: 500px; padding-top: 24px; }
  #designer-canvas { max-height: 580px; }
}
@media (max-width: 520px) {
  .topbar { height: 66px; }
  .brand-mark { width: 37px; height: 37px; }
  .brand strong { font-size: 14px; }
  .brand small { font-size: 10px; }
  .steps { gap: 14px; }
  .step { font-size: 11px; }
  .step b { width: 22px; height: 22px; }
  .workspace { padding-inline: 9px; gap: 14px; }
  .designer-toolbar { align-items: start; }
  .designer-toolbar h1 { font-size: 22px; }
  .canvas-stage { min-height: 425px; border-radius: 16px; }
  #designer-canvas { max-height: 46svh; width: auto; max-width: 100%; }
  .canvas-stage { min-height: 0; }
  .selected-text-toolbar { flex-basis: 100%; }
  .selected-text-toolbar .field:first-child { flex: 1.5; min-width: 150px; }
  .selected-text-toolbar .field:last-child { min-width: 95px; }
  .panel-section { padding: 18px; }
  .quality-card { grid-template-columns: auto 1fr; }
  .quality-badge { grid-column: 2; justify-self: start; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .success-dialog { padding: 27px 20px; }
}
