:root {
  --ink: #1d2230;
  --ink-2: #4a5164;
  --cream: #f6f1e7;
  --paper: #fffdf8;
  --line: #e6dfd0;
  --orange: #ff6b35;
  --orange-d: #e8551f;
  --teal: #13a08a;
  --yellow: #ffc93c;
  --radius: 16px;
  --shadow: 0 1px 0 rgba(29,34,48,.04), 0 10px 30px -12px rgba(29,34,48,.18);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.55 "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--cream);
  min-height: 100vh;
  display: flex; flex-direction: column;
}
main { flex: 1; width: 100%; }
h1, h2, h3 { font-family: "Bricolage Grotesque", system-ui, sans-serif; line-height: 1.1; margin: 0 0 .5em; letter-spacing: -0.01em; }
a { color: var(--orange-d); }
img { max-width: 100%; }
.muted { color: var(--ink-2); }
.tiny { font-size: .85rem; }
.center { text-align: center; }

/* ---------- top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: "Bricolage Grotesque", system-ui, sans-serif; font-weight: 800; font-size: 1.2rem; }
.brand img { width: 36px; height: 36px; }
.topbar nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.topbar nav a { color: var(--ink); text-decoration: none; font-weight: 500; }
.topbar nav a:hover { color: var(--orange-d); }
.topbar nav a.muted { color: var(--ink-2); }
.who { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: .95rem; }
.who img { width: 28px; height: 28px; border-radius: 50%; }

.flash { max-width: 900px; margin: 0 auto 10px; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px; border: 2px solid var(--ink);
  background: var(--ink); color: #fff; font: 600 1rem "DM Sans", sans-serif;
  text-decoration: none; cursor: pointer; transition: transform .12s, background .12s, box-shadow .12s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px -6px rgba(29,34,48,.5); color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-big { padding: 15px 28px; font-size: 1.08rem; }
.btn-small { padding: 7px 16px; font-size: .95rem; color: #fff !important; }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { color: var(--ink); background: #fff; }
.btn-accent { background: var(--orange); border-color: var(--orange); }
.btn-accent:hover { background: var(--orange-d); border-color: var(--orange-d); }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(18px, 3vw, 32px); }
.narrow { max-width: 560px; margin: 30px auto; }
.wide { max-width: 1120px; margin: 10px auto 40px; padding: 0 clamp(16px, 4vw, 40px); }

/* ---------- hero */
.hero { position: relative; text-align: center; padding: clamp(30px, 6vw, 70px) 20px 50px; overflow: hidden; }
.hero-pattern {
  position: absolute; inset: 0; z-index: -1; opacity: .5;
  background:
    radial-gradient(circle at 15% 25%, rgba(255,201,60,.55) 0 90px, transparent 91px),
    radial-gradient(circle at 85% 70%, rgba(19,160,138,.30) 0 120px, transparent 121px),
    radial-gradient(circle at 75% 15%, rgba(255,107,53,.25) 0 60px, transparent 61px);
}
.hero-logo { width: clamp(110px, 16vw, 170px); height: auto; filter: drop-shadow(0 12px 20px rgba(29,34,48,.18)); animation: float 5s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px) rotate(-3deg); } }
.hero-title { font-size: clamp(2.6rem, 7.5vw, 5.6rem); font-weight: 800; margin: 18px auto 14px; max-width: 14ch; }
.hero-title a {
  color: var(--ink); text-decoration: none; cursor: pointer;
  background: linear-gradient(transparent 64%, var(--yellow) 64% 90%, transparent 90%);
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  transition: color .15s;
}
.hero-title a:hover { color: var(--orange-d); }
.hero-title a:focus-visible { outline: 3px solid var(--orange); outline-offset: 4px; }
.hero-sub { font-size: 1.2rem; color: var(--ink-2); max-width: 36ch; margin: 0 auto 28px; }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; max-width: 1000px; margin: 0 auto 60px; padding: 0 20px; }
.step { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.step span { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--orange); color: #fff; font-weight: 700; margin-bottom: 10px; }
.step p { margin: 0; color: var(--ink-2); }

/* ---------- login */
.login-dialog { border: none; border-radius: 20px; padding: 32px; width: min(440px, 92vw); box-shadow: 0 30px 80px rgba(0,0,0,.3); text-align: center; background: var(--paper); }
.login-dialog::backdrop { background: rgba(29,34,48,.55); backdrop-filter: blur(3px); }
.login-dialog .close { position: absolute; top: 10px; right: 14px; border: 0; background: none; font-size: 28px; cursor: pointer; color: var(--ink-2); }
.login-logo { width: 80px; }
.social { display: grid; gap: 10px; margin: 22px 0 14px; }
.social-btn { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 13px 18px; border-radius: 12px; font-weight: 600; text-decoration: none; transition: transform .1s, filter .1s; }
.social-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.social-google { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; }
.social-facebook { background: #1877f2; color: #fff; }
.social-x { background: #000; color: #fff; }

/* ---------- create */
.create { display: grid; grid-template-columns: minmax(300px, 400px) 1fr; gap: 24px; max-width: 1240px; margin: 10px auto 40px; padding: 0 clamp(16px, 4vw, 40px); align-items: start; }
@media (max-width: 860px) { .create { grid-template-columns: 1fr; } .create-right { order: -1; } }
.create h1 { font-size: 1.8rem; }
.label { display: block; font-weight: 700; margin: 20px 0 8px; }
.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 26px 16px; border: 2px dashed #cfc5b0; border-radius: 14px; background: #fff; cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--orange); background: #fff7f2; }
.drop-icon { font-size: 26px; color: var(--orange); }
.pieces-row { display: flex; align-items: center; gap: 14px; }
.pieces-row input { flex: 1; accent-color: var(--orange); height: 28px; }
.pieces-row output { min-width: 92px; font-weight: 700; font-size: 1.1rem; text-align: right; }
.actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.progress { height: 8px; background: var(--line); border-radius: 99px; margin-top: 16px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--teal); transition: width .2s; }
.status { min-height: 1.4em; margin: 10px 0 0; }
.status.error { color: #c0392b; font-weight: 600; }
.result { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.result h2 { font-size: 1.4rem; margin: 0; }
.result .btn { width: 100%; }
.print-form { margin: 0; }
.preview { position: relative; display: grid; place-items: center; min-height: 380px; padding: 16px; background: #fff repeating-conic-gradient(#f3efe6 0 25%, #fff 0 50%) 0 0 / 22px 22px; }
.preview canvas { display: block; max-width: 100%; border-radius: 4px; box-shadow: 0 14px 40px -12px rgba(0,0,0,.35); }
.preview-empty { position: absolute; color: var(--ink-2); font-weight: 500; background: rgba(255,255,255,.85); padding: 10px 16px; border-radius: 10px; }
.preview-empty[hidden] { display: none; }
.preview canvas:not([style]) { visibility: hidden; }

/* ---------- my puzzles / admin */
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.admin-head h1 { margin: 0; }
.stats { display: flex; gap: 16px; color: var(--ink-2); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.pz { padding: 14px; display: flex; flex-direction: column; }
.pz-img { aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: var(--cream); margin-bottom: 12px; }
.pz-img img { width: 100%; height: 100%; object-fit: cover; }
.pz h3 { margin: 0; font-size: 1.15rem; }
.pz p { margin: 4px 0; }
.pz-actions { display: grid; gap: 8px; margin-top: auto; padding-top: 12px; }
.pz-actions form { margin: 0; }
.pz-actions .btn { width: 100%; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; background: var(--line); color: var(--ink); vertical-align: middle; }
.badge-paid { background: var(--yellow); }
.badge-shipped { background: var(--teal); color: #fff; }
.badge-pending { background: #eee; color: #777; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 8px 14px; border-radius: 99px; text-decoration: none; color: var(--ink); background: var(--paper); border: 1px solid var(--line); }
.tabs a.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs em { font-style: normal; opacity: .7; margin-left: 4px; }
.order { display: grid; grid-template-columns: 120px 1fr 240px; gap: 18px; margin-bottom: 14px; padding: 16px; align-items: start; }
@media (max-width: 760px) { .order { grid-template-columns: 1fr; } }
.order .thumb { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; }
.order h3 { font-size: 1.15rem; }
.order p { margin: 3px 0; }
.addr { font: inherit; background: var(--cream); padding: 10px 12px; border-radius: 8px; margin: 8px 0 0; white-space: pre-wrap; }
.order-actions { display: grid; gap: 8px; }
.order-actions form { display: grid; gap: 8px; margin: 0; }
.order-actions input { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); font: inherit; }
.big-check { width: 70px; height: 70px; border-radius: 50%; background: var(--teal); color: #fff; font-size: 38px; display: grid; place-items: center; margin: 0 auto 16px; }
.prose h2 { font-size: 1.25rem; margin-top: 1.4em; }

.footer { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; padding: 26px; color: var(--ink-2); font-size: .9rem; }
.footer a { color: var(--ink-2); }
