@font-face {
  font-family: Outfit;
  src: url("../fonts/Outfit.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --ink: #161616;
  --muted: #5c564e;
  --paper: #f4f0e8;
  --card: #fffdf9;
  --line: #e4dcd0;
  --black: #0c0c0c;
  --magenta: #e44993;
  --magenta-deep: #c21d72;
  --cyan: #00ccff;
  --cyan-deep: #0793c4;
  --blue: #227bc3;
  --yellow: #f5c518;
  --good: #0f7a45;
  --bad: #a3213c;
  --shadow: 0 18px 50px rgba(12, 12, 12, 0.12);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body {
  margin: 0;
  font-family: Outfit, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-size: 17px;
  line-height: 1.5;
  overflow-x: hidden;
  max-width: 100%;
}
img { max-width: 100%; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.1; letter-spacing: -0.03em; }
h1 { font-size: clamp(2.2rem, 5vw, 4.4rem); margin: 0 0 0.4em; }
h2 { font-size: 1.5rem; margin: 0 0 0.4em; }

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: #fff;
  padding: 0.5rem 0.8rem;
  z-index: 20;
}
.skip:focus { top: 0.5rem; }

.devbar {
  background: var(--yellow);
  color: #1a1a1a;
  text-align: center;
  font-size: 0.85rem;
  padding: 0.35rem 1rem;
}

.site-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1.2rem;
  background: var(--black);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand { display: flex; align-items: center; }
.brand img { height: 58px; width: auto; }
.site-nav { display: flex; gap: 0.3rem 1.1rem; margin-left: auto; flex-wrap: wrap; }
.site-nav a {
  color: #fff;
  text-decoration: none;
  font-weight: 560;
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
}
.site-nav a.is-active, .site-nav a:hover { border-bottom-color: var(--cyan); }
.nav-toggle {
  display: none;
  margin-left: auto;
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 2rem;
  align-items: center;
  background: var(--black);
  color: #fff;
  padding: clamp(1.5rem, 4vw, 4rem);
  min-height: 70vh;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  color: var(--cyan);
  margin: 0 0 0.8rem;
  font-weight: 700;
}
.lede { font-size: 1.2rem; max-width: 38rem; color: #f3f3f3; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; margin: 1.4rem 0 0.8rem; }
.hero-note { color: #cfcfcf; max-width: 36rem; }
.hero-photo img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 18px;
  object-fit: cover;
  max-height: 460px;
}
.work { width: min(1120px, calc(100% - 2rem)); margin: 2rem auto; }
.work-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.8rem;
}
.work-grid figure { margin: 0; }
.work-grid img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 14px;
  background: #111;
  display: block;
}
.work-grid figcaption { margin-top: 0.35rem; color: var(--muted); font-size: 0.92rem; }
.builder-photo { margin: 0.6rem 0 0; }
.builder-photo img {
  width: min(420px, 100%);
  height: auto;
  border-radius: 14px;
  display: block;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-decoration: none;
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.3rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-magenta { background: var(--magenta); color: #fff; }
.btn-magenta:hover { background: var(--magenta-deep); }
.btn-cyan { background: var(--cyan); color: #062029; }
.btn-cyan:hover { background: #7ae6ff; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-small { padding: 0.5rem 0.75rem; font-size: 0.92rem; border-radius: 12px; }
.btn-block { width: 100%; }
.site-header .btn { color: #fff; }

.price-band, .steps, .split, .prose, .narrow, .checkout, .admin {
  width: min(1120px, calc(100% - 2rem));
  margin: 2rem auto;
}
.price-band {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.price-band article, .summary-card, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow);
}
.figure { font-size: 1.8rem; font-weight: 760; margin: 0.2rem 0; letter-spacing: -0.03em; }
.figure span { display: block; font-size: 0.95rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.preset-prices { list-style: none; padding: 0; margin: 0.4rem 0 0.6rem; }
.preset-prices li { padding: 0.15rem 0; }

.steps ol {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.steps li {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.1rem;
  border: 1px solid var(--line);
}
.steps li span {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--ink);
  color: var(--cyan);
  font-weight: 700;
}
.split { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 1.5rem; align-items: start; }
.ticks { list-style: none; padding: 0; margin: 0; }
.ticks li {
  padding: 0.7rem 0 0.7rem 1.6rem;
  position: relative;
  border-bottom: 1px solid var(--line);
}
.ticks li::before { content: ""; position: absolute; left: 0; top: 1rem; width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--magenta); }
.text-link { font-weight: 700; }

.site-footer {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: 1.5rem;
  background: var(--black);
  color: #eee;
  padding: 2rem 1.4rem 2.5rem;
  margin-top: 3rem;
}
.site-footer a { color: var(--cyan); text-decoration: none; display: block; margin: 0.2rem 0; }
.site-footer h2 { font-size: 0.85rem; letter-spacing: 0.08em; text-transform: uppercase; color: #fff; }
.footer-brand { display: flex; gap: 0.8rem; align-items: flex-start; }
.footer-brand img { width: 72px; height: auto; }
.credit { color: #aaa; }

.prose { max-width: 760px; }
.prose details { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0.8rem 1rem; margin: 0.6rem 0; }
.prose summary { cursor: pointer; font-weight: 700; }
.narrow { max-width: 680px; }
.checkout { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 1.2rem; align-items: start; }
.stack, .stack label, .size-edit, .copies { display: grid; gap: 0.3rem; }
.stack { gap: 0.8rem; }
input, select, textarea {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  border: 1px solid #d9d0c4;
  background: #fff;
}
fieldset { border: 1px solid var(--line); border-radius: 14px; }
.radio { display: flex; gap: 0.5rem; align-items: center; margin: 0.35rem 0; }
.radio input, .check input { width: auto; }
.check { display: flex; gap: 0.5rem; align-items: center; }
.split-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.hp { position: absolute; left: -9999px; }
.hint { color: var(--muted); font-size: 0.92rem; }
.banner { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 0.8rem 1rem; }
.banner-bad { border-color: #f0b4c2; background: #fff1f4; color: var(--bad); }
.banner-good { border-color: #b7e4c7; background: #f1fff6; color: var(--good); }
.quote { margin: 0.6rem 0; }
.quote div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
.quote dt { color: var(--muted); }
.quote dd { margin: 0; font-weight: 700; text-align: right; }
.warnings { padding-left: 1.1rem; color: #8a4b08; }
.summary-card { position: sticky; top: 5.5rem; }

.builder { width: min(1280px, calc(100% - 1.2rem)); margin: 1rem auto 2rem; }
.builder-intro { display: flex; justify-content: space-between; gap: 1rem; align-items: end; }
.builder-intro h1 { font-size: clamp(1.8rem, 3vw, 2.6rem); }
.price-pill {
  background: var(--black);
  color: #fff;
  border-radius: 999px;
  padding: 0.7rem 1rem;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
}
.price-pill span { color: var(--cyan); }
.builder-alert { margin: 0.8rem 0; }
.builder-layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 280px;
  gap: 0.8rem;
  margin-top: 0.8rem;
  align-items: start;
}
.panel { box-shadow: none; }
.panel h2 { font-size: 1rem; }
.upload {
  display: grid;
  place-items: center;
  border: 1.5px dashed var(--magenta);
  border-radius: 14px;
  padding: 0.9rem;
  background: #fff5fa;
  cursor: pointer;
  text-align: center;
  font-weight: 700;
}
.upload input { display: none; }
.tool-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.45rem 0; }
.copies { grid-template-columns: auto 4.2rem; align-items: center; }
.art-list { list-style: none; padding: 0; margin: 0.6rem 0; display: grid; gap: 0.4rem; }
.art-list li { border: 1px solid var(--line); border-radius: 10px; padding: 0.45rem 0.55rem; background: #fff; cursor: pointer; }
.art-list li.is-active { border-color: var(--magenta); }
.art-list li.is-soft { background: #fff7e8; }
.art-list .name { font-weight: 700; }
.progress { height: 8px; background: #eee; border-radius: 99px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--magenta); transition: width 0.2s ease; }
.bg-progress { height: 12px; margin-top: 0.5rem; }
.bg-progress.is-indeterminate span { width: 35% !important; animation: dtfgo-indeterminate 1.1s ease-in-out infinite; }
@keyframes dtfgo-indeterminate { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }

.stage { min-width: 0; }
.sheet-scroll {
  max-height: min(74vh, 860px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
}
.sheet-grid {
  display: grid;
  grid-template-columns: 32px auto;
  grid-template-rows: 32px auto;
  width: max-content;
}
.ruler-corner { position: sticky; left: 0; top: 0; z-index: 5; background: #fff; }
#ruler-x { position: sticky; top: 0; z-index: 4; background: #fff; }
#ruler-y { position: sticky; left: 0; z-index: 4; background: #fff; }
.sheet-canvas-wrap { position: relative; background: #fff; touch-action: none; }
.sheet-canvas-wrap .canvas-container,
.sheet-canvas-wrap canvas { touch-action: none; }
.sheet-canvas-wrap .canvas-container { position: absolute !important; left: 0; top: 0; }
.zoom-controls { display: flex; gap: 0.35rem; margin-bottom: 0.4rem; align-items: center; flex-wrap: wrap; }
.history-controls { display: flex; gap: 0.35rem; }
.zoom-spacer { flex: 1 1 auto; }
.zoom-controls button.undo-btn, .zoom-controls button.redo-btn { padding: 0 0.8rem; }
.zoom-controls button:disabled { opacity: 0.45; cursor: default; }
.zoom-controls button {
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 700;
  cursor: pointer;
}
.upload-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; }
.app-dock, .sheet-backdrop { display: none; }
.sheet-caption { color: var(--muted); font-size: 0.9rem; }
.sheet-tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.sheet-tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 0.35rem 0.7rem; cursor: pointer; }
.sheet-tabs button.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 0.95rem; }
.admin-head, .filters { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.filters a { margin-right: 0.8rem; text-decoration: none; font-weight: 700; color: var(--muted); }
.filters a.is-active { color: var(--magenta); }
.status { font-weight: 700; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.05em; }
.status-paid { color: var(--good); }
.status-pending { color: #8a4b08; }
.status-cancelled, .status-failed { color: var(--bad); }
.inline { margin-top: 0.35rem; }
.contact-cell { min-width: 16rem; font-size: 0.88rem; line-height: 1.35; }
#address-fields h2, #pudo-fields h2 { font-size: 1.15rem; margin: 0.4rem 0 0; }
.pudo-results { list-style: none; padding: 0; margin: 0.4rem 0; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.pudo-results:empty { display: none; }
.pudo-results button { display: grid; gap: 0.15rem; width: 100%; text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: 0.6rem 0.75rem; cursor: pointer; }
.pudo-results button:hover, .pudo-results button:focus { background: #fff5fa; }
.pudo-chosen { background: #f3fbff; border: 1px solid #b7e4f5; border-radius: 12px; padding: 0.75rem 0.85rem; margin: 0.4rem 0; }
label .hint { font-weight: 500; }

@media (pointer: coarse) {
  .btn, .nav-toggle, .dock-btn, .sheet-tabs button, .tool-row .btn { min-height: 44px; }
  input, select, textarea { font-size: 16px; }
}

@media (max-width: 980px) {
  .hero, .price-band, .steps ol, .split, .checkout, .site-footer, .builder-layout, .work-grid {
    grid-template-columns: 1fr;
  }
  .work-grid { grid-template-columns: 1fr 1fr; }
  .work-grid img { height: 180px; }
  .nav-toggle { display: inline-flex; }
  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--black);
    padding: 0.6rem 1rem 1rem;
    flex-direction: column;
  }
  body.nav-open .site-nav { display: flex; }
  .site-header { position: sticky; }
  .builder-intro { flex-direction: column; align-items: stretch; }
  .price-pill { white-space: normal; }
  .summary { order: 3; }
  .stage { order: 1; }
  .tools { order: 2; }
  .summary-card { position: static; }
  .split-fields { grid-template-columns: 1fr; }
  .price-band, .steps, .split, .prose, .narrow, .checkout, .admin, .builder {
    width: min(1120px, calc(100% - 1rem));
  }
  .site-header { flex-wrap: wrap; }
  .checkout { margin-bottom: 1.5rem; }
  body.builder-page { padding-bottom: calc(4.6rem + env(safe-area-inset-bottom)); }
  .sheet-scroll { max-height: 58dvh; }
  .builder-intro p { margin-top: 0.3rem; }
  .app-dock {
    display: grid;
    grid-template-columns: 1fr 1fr 1.3fr;
    gap: 0.4rem;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    padding: 0.55rem 0.7rem calc(0.55rem + env(safe-area-inset-bottom));
    background: #0c0c0c;
  }
  .app-dock button {
    min-height: 46px;
    border: 0;
    border-radius: 12px;
    background: #242424;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
  }
  #dock-price { background: var(--magenta); }
  .sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 40;
  }
  .sheet-backdrop[hidden] { display: none; }
  .builder-page .tools,
  .builder-page .summary {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 42;
    max-height: min(74dvh, 640px);
    overflow: auto;
    margin: 0;
    border-radius: 18px 18px 0 0;
    transform: translateY(110%);
    transition: transform 0.2s ease;
    padding-bottom: calc(5rem + env(safe-area-inset-bottom));
  }
  .builder-page .tools.is-open,
  .builder-page .summary.is-open { transform: translateY(0); }
  .sheet-handle {
    width: 42px;
    height: 5px;
    border-radius: 99px;
    background: #d9d0c4;
    margin: 0 auto 0.6rem;
  }
  .hero { min-height: 0; padding: 1.4rem 1rem 1.8rem; }
  .hero-actions .btn { width: 100%; }
}

/* v2 extend controls & background removal */
.extend-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.45rem 0 0.55rem;
}
.extend-controls .btn-small {
  padding: 0.42rem 0.65rem;
  font-size: 0.88rem;
}
.mobile-length-bar {
  display: none;
}
.bg-panel {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--line);
}
.bg-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.bg-head h3 {
  font-size: 0.96rem;
  margin: 0;
}
.bg-status {
  margin: 0.35rem 0 0;
}
.bg-solid-box {
  margin-top: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.45rem 0.6rem;
  background: #fff;
}
.bg-solid-box summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
}
.bg-solid-box .hint {
  margin: 0.35rem 0;
  font-size: 0.84rem;
}
.bg-solid-box .check {
  margin: 0.45rem 0;
  font-size: 0.86rem;
}
.bg-color-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin: 0.35rem 0;
}
.bg-color-pick {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.86rem;
  font-weight: 600;
}
.bg-color-pick input[type="color"] {
  width: 2.3rem;
  height: 2rem;
  padding: 0.15rem;
  border-radius: 8px;
  cursor: pointer;
}
.art-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.08rem 0.45rem;
  border-radius: 999px;
  background: #e9fbf2;
  color: var(--good);
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: middle;
}

@media (max-width: 980px) {
  .mobile-length-bar {
    display: block;
    margin-top: 0.55rem;
    padding: 0.55rem 0.65rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
  }
  .mobile-length-bar[hidden] {
    display: none;
  }
  .mobile-length-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
  }
}

/* v3: Apply changes bar in the tools panel */
.tools-apply-bar {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "hint hint"
    "apply reset";
  gap: 0.4rem 0.5rem;
  margin-top: 0.85rem;
  padding: 0.65rem 0 0.15rem;
  background: var(--card);
  border-top: 1px solid var(--line);
  z-index: 3;
}
.tools-apply-bar #apply-hint {
  grid-area: hint;
  margin: 0;
}
.tools-apply-bar #apply-changes {
  grid-area: apply;
}
.tools-apply-bar #cancel-changes {
  grid-area: reset;
  min-width: 5.5rem;
}
.btn.is-pending {
  box-shadow: 0 0 0 2px var(--magenta);
}
#apply-changes:not(:disabled) {
  animation: apply-pulse 1.6s ease-in-out infinite;
}
@keyframes apply-pulse {
  0%, 100% { filter: none; }
  50% { filter: brightness(1.08); }
}

@media (max-width: 980px) {
  .tools-apply-bar {
    bottom: 0;
    padding-bottom: 0.35rem;
  }
}

.sheet-tabs[hidden] { display: none !important; }

.pudo-settings { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 1rem 1.15rem; margin: 0 0 1.25rem; }
.pudo-settings h2 { margin: 0 0 0.4rem; font-size: 1.15rem; }
.pudo-settings .pudo-key-form { max-width: 28rem; }
.pudo-book-row td { background: #f7fbff; border-top: 0; padding-top: 0; }
.pudo-panel { border: 1px solid #b7e4f5; border-radius: 14px; padding: 0.85rem 1rem 1rem; margin: 0.15rem 0 0.6rem; background: #f3fbff; }
.pudo-panel-head { display: flex; gap: 0.75rem; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.pudo-panel-head h2 { margin: 0; font-size: 1.05rem; }
.pudo-shipment { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0.6rem 1rem; margin: 0.6rem 0; }
.pudo-shipment div { margin: 0; }
.pudo-shipment dt { font-size: 0.8rem; color: #555; }
.pudo-shipment dd { margin: 0.1rem 0 0; font-weight: 600; }
.pudo-pin { font-size: 1.35rem; letter-spacing: 0.12em; font-variant-numeric: tabular-nums; }
.pudo-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; }
.pudo-quote { background: #fff; border: 1px dashed #8ec8dc; border-radius: 10px; padding: 0.6rem 0.75rem; margin: 0.5rem 0; }
.pudo-quote:empty { display: none; }
.origin-chosen { margin: 0.4rem 0; }
