/* Wallpaper Studio (web) — based on the W1 look. No inline styles (CSP). */
:root {
  --bg: #f3f4f1;
  --surface: #ffffff;
  --surface-2: #f8f9f7;
  --text: #1c2321;
  --muted: #5c6662;
  --line: #dde2dd;
  --primary: #0e6b5c;
  --primary-hover: #0a574b;
  --primary-soft: #e3f1ed;
  --good: #1d7f46;
  --good-bg: #e5f4ea;
  --ok: #94630d;
  --ok-bg: #fbf0d9;
  --low: #b3261e;
  --low-bg: #fbe7e5;
  --info-bg: #e9f0f7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 2px 10px rgba(20, 30, 25, .05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { background: var(--bg); }
body { margin: 0; min-height: 100vh; font-size: 15px; line-height: 1.45; display: flex; flex-direction: column; }
a { color: var(--primary); }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 19px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
[hidden] { display: none !important; }
.offscreen { position: fixed; left: -9999px; top: 0; width: 1px; height: 1px; opacity: 0; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; }
.logo { width: 26px; height: 26px; border-radius: 6px; background: var(--primary); position: relative; flex: none; }
.logo::after { content: ""; position: absolute; left: 5px; right: 5px; bottom: 6px; height: 9px;
  background: linear-gradient(135deg, transparent 45%, #fff 46%); clip-path: polygon(0 100%, 35% 30%, 55% 65%, 75% 20%, 100% 100%); }
.top-right { display: flex; align-items: center; gap: 12px; }
.engine-badge { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); cursor: help; }
.engine-badge.fast { background: var(--good-bg); color: var(--good); border-color: #bfe3cb; }
.engine-badge.slow { background: var(--ok-bg); color: var(--ok); border-color: #efd9a8; }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang button { font: inherit; font-size: 13px; font-weight: 700; border: 0; background: var(--surface); color: var(--muted); padding: 5px 10px; cursor: pointer; }
.lang button.active { background: var(--primary); color: #fff; }
.privacy-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 8px 24px; background: var(--primary-soft); color: #0b4f44; font-size: 14px; }
.lock { width: 12px; height: 12px; border: 2px solid currentColor; border-radius: 3px; position: relative; margin-top: 4px; }
.lock::before { content: ""; position: absolute; left: 1px; top: -8px; width: 6px; height: 7px; border: 2px solid currentColor; border-bottom: 0; border-radius: 5px 5px 0 0; }

.view { width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px; flex: 1 0 auto; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #c4cbc5; background: var(--surface-2); }
.btn:focus-visible, input:focus-visible, select:focus-visible, .dropzone:focus-visible, .choice:focus-visible, svg:focus-visible, .lang button:focus-visible {
  outline: 3px solid rgba(14, 107, 92, .35); outline-offset: 2px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--low); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.big { padding: 12px 22px; font-size: 16px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

input[type=text], input[type=number], select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); }
input[type=number] { width: 100px; }
input.invalid { border-color: var(--low); background: var(--low-bg); }
label.field { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 14px; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 16px 0; }
.check { display: inline-flex; gap: 8px; align-items: flex-start; font-weight: 600; cursor: pointer; }
.check input { margin-top: 3px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.card.sub { background: var(--surface-2); box-shadow: none; }

.notice { border-radius: 8px; padding: 10px 14px; margin: 10px 0; font-size: 14px; }
.notice.info { background: var(--info-bg); }
.notice.warn { background: var(--ok-bg); color: #5c3d06; }
.notice.error { background: var(--low-bg); color: #7a1912; }
.notice.good { background: var(--good-bg); color: #0f4d2a; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.low { background: var(--low-bg); color: var(--low); }
.badge.heavy { background: #f3e8fd; color: #6b2fa3; }

/* stepper */
.stepper { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.stepper .st { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--line); color: var(--muted); font-weight: 600; font-size: 13.5px; text-decoration: none; font-family: inherit; cursor: pointer; }
.stepper .st .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: #e8ebe7; font-size: 12px; }
.stepper .st.done { color: var(--text); }
.stepper .st.done .n { background: var(--primary-soft); color: var(--primary); }
.stepper .st.current { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.stepper .st.current .n { background: var(--primary); color: #fff; }
.stepper .st:disabled { opacity: .55; cursor: default; }
.wizard-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.wizard-title h1 { margin: 0; }
.wizard-title .sku { color: var(--primary); font-weight: 700; }
.step-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.step-foot .why { color: var(--muted); font-size: 13.5px; }

/* upload */
.dropzone { border: 2px dashed #b9c2bb; border-radius: var(--radius); padding: 34px 20px; text-align: center; cursor: pointer; background: var(--surface-2); }
.dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone .drop-title { font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.upload-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.upload-preview img { max-width: 100%; max-height: 420px; border-radius: 8px; display: block; background: #e8ebe7; }

/* type choice */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin: 10px 0 20px; }
.choice { border: 2px solid var(--line); border-radius: var(--radius); padding: 18px; cursor: pointer; background: var(--surface); text-align: left; font: inherit; color: inherit; }
.choice:hover { border-color: #b9c2bb; }
.choice.selected { border-color: var(--primary); background: var(--primary-soft); }
.choice .t { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.choice .icon { height: 70px; border-radius: 8px; margin-bottom: 12px; background: #dfe6e1; }
.choice .icon.mural { background: linear-gradient(160deg, #9bc7c0 0%, #4e8f86 45%, #2e5f59 70%, #d9b68c 71%, #c49b6c 100%); }
.choice .icon.pattern { background-color: #e9efe9; background-image: radial-gradient(#0e6b5c 18%, transparent 19%), radial-gradient(#b7791f 18%, transparent 19%);
  background-size: 22px 22px; background-position: 0 0, 11px 11px; }
.radio-row { display: flex; gap: 12px; flex-wrap: wrap; }
.radio { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; cursor: pointer; background: var(--surface); flex: 1 1 260px; }
.radio input { margin-top: 3px; }
.radio.selected { border-color: var(--primary); background: var(--primary-soft); }

/* framing */
.framing { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.frame-wrap { position: relative; display: inline-block; max-width: 100%; line-height: 0; user-select: none; -webkit-user-select: none; }
.frame-img { max-width: 100%; max-height: 70vh; display: block; border-radius: 6px; }
.frame-svg { position: absolute; left: 0; top: 0; cursor: crosshair; touch-action: none; }
.frame-label { font-size: 12px; font-weight: 700; paint-order: stroke; stroke: rgba(255, 255, 255, .85); stroke-width: 3px; }
.focal-outer { fill: rgba(255, 255, 255, .35); stroke: #fff; stroke-width: 2.5; cursor: grab; }
.focal-inner { fill: #e53935; stroke: #fff; stroke-width: 1.5; pointer-events: none; }
.legend { display: flex; flex-direction: column; gap: 8px; }
.legend-row { display: grid; grid-template-columns: 14px 1fr; gap: 4px 10px; align-items: center; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; }
.legend-row .sw { width: 14px; height: 14px; border-radius: 3px; }
.legend-row .sub { grid-column: 2; color: var(--muted); font-size: 13px; }
.legend-row.warn { background: var(--ok-bg); border-color: #efd9a8; }
.legend-row .warn-text { grid-column: 2; color: var(--ok); font-weight: 700; font-size: 13px; }

/* pattern */
.pattern-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.tile3 { width: 100%; max-width: 480px; display: block; border-radius: 6px; border: 1px solid var(--line); }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compare figure { margin: 0; }
.compare figcaption { font-weight: 700; margin-bottom: 6px; }
.seam-status { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.wall-canvas { width: 100%; max-width: 620px; display: block; border-radius: 8px; background: #fafaf8; border: 1px solid var(--line); }

/* tables */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; background: var(--surface-2); }
table.tbl td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.tbl tr.disabled td { opacity: .5; }
table.tbl tr.heavy td { background: #fbf7ff; }
.etsy { display: inline-flex; gap: 6px; align-items: center; }
.etsy code { background: var(--surface-2); border: 1px solid var(--line); padding: 2px 6px; border-radius: 6px; font-size: 13px; }
.sizes-tbl td input[type=number] { width: 90px; }

/* export */
.progress { height: 14px; background: #e3e7e3; border-radius: 999px; overflow: hidden; margin: 10px 0 6px; }
.progress > div { height: 100%; background: var(--primary); width: 0; transition: width .3s ease; }
.job-line { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 14px; align-items: center; }
.files { margin-top: 12px; }
.custom-box { border: 1px dashed #b9c2bb; border-radius: var(--radius); padding: 14px; margin-top: 14px; background: var(--surface-2); }
.inline-fields { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
details.pm { margin-top: 18px; }
details.pm summary { cursor: pointer; font-weight: 700; font-size: 16px; }
details.pm ol { padding-left: 22px; }
details.pm li { margin: 6px 0; }
.kv { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }

/* footer */
.foot { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; padding: 14px 24px 22px; color: var(--muted); font-size: 13px; }

/* mobile gate */
.mobile-gate { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; place-items: center; padding: 24px; }
.gate-card { max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 28px 24px; text-align: center; }
.gate-card h1 { font-size: 22px; }
.gate-icon { width: 64px; height: 44px; margin: 0 auto 16px; border: 4px solid var(--primary); border-radius: 6px; position: relative; }
.gate-icon::after { content: ""; position: absolute; left: 50%; bottom: -14px; width: 36px; height: 6px; margin-left: -18px; background: var(--primary); border-radius: 3px; }
body.gated .topbar .top-right, body.gated main, body.gated .privacy-bar { display: none; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1c2321; color: #fff; padding: 10px 18px; border-radius: 8px;
  z-index: 60; box-shadow: 0 6px 24px rgba(0, 0, 0, .2); max-width: 90vw; }
.toast.error { background: #8f1f18; }

@media (max-width: 960px) {
  .framing, .pattern-grid, .upload-grid { grid-template-columns: 1fr; }
}

/* ---- W2: generation (step 0), Premium upscale, usage page ---- */
textarea { font: inherit; width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); resize: vertical; }
textarea:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.field.wide { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 6px; }
.chip { font: inherit; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.chip:hover { border-color: #b9c2bb; }
.chip.selected { border-color: var(--primary); background: var(--primary-soft); color: #0b4f44; }
.gen-who { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: -4px 0 12px; }
.gen-who p { margin: 0; }
.prompt-details { margin: 8px 0 12px; }
.prompt-details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.prompt-full { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 12.5px; margin: 8px 0 0; }
#gen-cost { font-weight: 700; margin: 10px 0; }
.gen-batch { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.gen-batch-head { margin-bottom: 8px; }
.prompt-line { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.variants { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.variant { border: 2px solid var(--line); border-radius: var(--radius); padding: 10px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; }
.variant.chosen { border-color: var(--primary); background: var(--primary-soft); }
.variant img { width: 100%; height: 200px; object-fit: contain; background: #e8ebe7; border-radius: 6px; display: block; }
.variant-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.variant-wait { min-height: 120px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 14px; flex-wrap: wrap; }
.spinner { width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.radio.disabled { opacity: .55; cursor: not-allowed; }
.good-text { color: var(--good); font-weight: 600; }
#upscale-box { margin-bottom: 18px; }
#upscale-box .radio-row { margin-bottom: 8px; }
.usage-total { font-weight: 700; margin: 8px 0 14px; }
.calls { font-size: 12.5px; }
@media (max-width: 640px) {
  .variants { grid-template-columns: 1fr; }
}
