:root {
  --bg: #FFFBF5;
  --card: #FFFFFF;
  --ink: #2B2440;
  --muted: #6E6880;
  --line: #EFE6DA;
  --coral: #FF6B5B;
  --sun: #FFC93C;
  --teal: #19B9A8;
  --sky: #4EA8FF;
  --grape: #8B5CF6;
  --pink: #FF7AB6;
  --lime: #7BCB45;
  --r: 18px;
  --shadow: 0 2px 0 rgba(43,36,64,.06), 0 10px 30px -12px rgba(43,36,64,.18);
  --head: "Fredoka", "Nunito", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: inherit; }
h1, h2, h3 { font-family: var(--head); font-weight: 600; line-height: 1.15; margin: 0 0 .4em; }
[hidden] { display: none !important; }

/* ---------- buttons, pills ---------- */
.btn {
  --c: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  border: 2px solid var(--ink); border-radius: 999px; background: var(--c); color: #fff;
  font: 700 15px/1 "Nunito", sans-serif; padding: .7em 1.2em; cursor: pointer; text-decoration: none;
  box-shadow: 0 3px 0 var(--ink); transition: transform .12s, box-shadow .12s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 0 var(--ink); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.btn-sun { --c: var(--sun); color: var(--ink); }
.btn-coral { --c: var(--coral); }
.btn-teal { --c: var(--teal); }
.btn-ghost { --c: #fff; color: var(--ink); }
.btn-ghost.on { --c: var(--ink); color: #fff; }
.btn-sm { font-size: 13px; padding: .5em .9em; }
.btn-lg { font-size: 17px; padding: .85em 1.6em; }
.pill { display: inline-block; font-size: 12px; font-weight: 800; padding: .25em .7em; border-radius: 999px; background: #F3EEE7; color: var(--ink); white-space: nowrap; }
.pill-grape { background: #EDE6FF; color: #5B35C9; }
.pill-teal { background: #DDF6F2; color: #0E7E72; }
.pill-coral { background: #FFE6E2; color: #C8392A; }
.pill-sun { background: #FFF2CC; color: #8A6300; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 20px;
  padding: 12px clamp(16px, 4vw, 40px); background: rgba(255,251,245,.92); backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 600 24px var(--head); }
.brand b { color: var(--coral); font-weight: 700; }
.topbar nav { display: flex; align-items: center; gap: 18px; margin-left: auto; font-weight: 700; }
.topbar nav > a:not(.btn) { text-decoration: none; padding: 4px 2px; border-bottom: 3px solid transparent; }
.topbar nav > a.active:not(.btn) { border-color: var(--sun); }
.owner-bar { display: flex; align-items: center; gap: 12px; }
.switch { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; cursor: pointer; }
.switch input { accent-color: var(--grape); width: 18px; height: 18px; }

main { max-width: 1320px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px) 60px; }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden; margin: 24px 0 18px; padding: clamp(28px, 5vw, 56px);
  border-radius: 28px; border: 2px solid var(--ink); box-shadow: 0 5px 0 var(--ink);
  background:
    radial-gradient(circle at 12% 20%, #FFE3A3 0 18%, transparent 19%),
    radial-gradient(circle at 92% 85%, #CDEBFF 0 22%, transparent 23%),
    linear-gradient(120deg, #FFF0DA 0%, #FFE1EC 55%, #E5F4FF 100%);
}
.confetti {
  position: absolute; inset: 0; pointer-events: none; opacity: .9;
  background-image:
    radial-gradient(circle, var(--coral) 0 5px, transparent 6px),
    radial-gradient(circle, var(--teal) 0 4px, transparent 5px),
    radial-gradient(circle, var(--grape) 0 4px, transparent 5px),
    radial-gradient(circle, var(--sun) 0 6px, transparent 7px),
    radial-gradient(circle, var(--sky) 0 3px, transparent 4px),
    radial-gradient(circle, var(--pink) 0 5px, transparent 6px);
  background-size: 310px 210px, 260px 240px, 380px 190px, 230px 270px, 170px 150px, 420px 260px;
  background-position: 40px 30px, 150px 120px, 260px 60px, 90px 170px, 10px 90px, 330px 10px;
  mask-image: linear-gradient(90deg, transparent 0 46%, #000 70%);
}
.hero h1 { position: relative; font-size: clamp(30px, 4.6vw, 52px); max-width: 15ch; }
.hero .lead { position: relative; max-width: 52ch; }
.lead { font-size: 18px; color: var(--muted); margin: 0 0 1.2em; }
.search {
  position: relative; display: flex; align-items: center; max-width: 680px;
  background: #fff; border: 2px solid var(--ink); border-radius: 999px; box-shadow: 0 4px 0 var(--ink);
  padding: 0 10px 0 20px;
}
.search svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; flex: none; }
.search input { flex: 1; border: 0; outline: 0; font: 600 19px "Nunito", sans-serif; padding: 16px 12px; background: transparent; min-width: 0; }
.search input::-webkit-search-cancel-button { display: none; }
.search .clear { border: 0; background: #F3EEE7; width: 34px; height: 34px; border-radius: 50%; font-size: 22px; cursor: pointer; }
.stats { position: relative; display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 20px; font-weight: 700; color: var(--muted); }
.stats b { font: 600 22px var(--head); color: var(--ink); margin-right: 4px; }

/* ---------- chips & toolbar ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px 10px; scrollbar-width: thin; }
.chip {
  --c: #fff; flex: none; display: inline-flex; align-items: center; gap: 6px;
  border: 2px solid var(--ink); border-radius: 999px; background: #fff; padding: 7px 14px;
  font: 700 14px "Nunito", sans-serif; cursor: pointer; color: var(--ink);
}
.chip i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); border: 1.5px solid var(--ink); }
.chip small { color: var(--muted); font-weight: 700; }
.chip.on { background: var(--c); box-shadow: 0 3px 0 var(--ink); }
.chip.on small { color: var(--ink); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 8px 0 18px; }
.seg { display: inline-flex; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; font: 700 14px "Nunito", sans-serif; padding: 8px 14px; cursor: pointer; color: var(--ink); }
.seg button + button { border-left: 2px solid var(--line); }
.seg button.on { background: var(--sun); }
select, input, textarea {
  font: 600 15px "Nunito", sans-serif; color: var(--ink); background: #fff;
  border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px;
}
select:focus, input:focus, textarea:focus { outline: 0; border-color: var(--sky); }
.toolbar select { border-color: var(--ink); border-radius: 999px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; cursor: pointer; }
.check input { accent-color: var(--teal); width: 17px; height: 17px; }
.count { margin-left: auto; color: var(--muted); font-weight: 700; }
body.visitor .owner-only { display: none !important; }

/* ---------- cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.card { background: var(--card); border: 2px solid var(--ink); border-radius: var(--r); box-shadow: 0 4px 0 var(--ink); }
.mcard { position: relative; display: flex; flex-direction: column; overflow: hidden; text-decoration: none; transition: transform .15s, box-shadow .15s; }
.mcard:hover { transform: translateY(-3px); box-shadow: 0 7px 0 var(--ink); }
.thumb { position: relative; aspect-ratio: 4/3; background: var(--tint, #FFF0DA); border-bottom: 2px solid var(--ink); display: grid; place-items: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb canvas { width: 100%; height: 100%; }
.ph { display: grid; place-items: center; gap: 6px; text-align: center; }
.ph svg { width: 64px; height: 64px; }
.ph span { font: 700 13px var(--head); letter-spacing: .06em; color: var(--ink); opacity: .7; }
.mcard .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.mcard h3 { font-size: 17px; margin: 0; overflow-wrap: anywhere; }
.mcard .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.mcard .sub { font-size: 13px; color: var(--muted); font-weight: 700; }
.tick {
  position: absolute; top: 10px; left: 10px; z-index: 2; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--ink); background: #fff; display: grid; place-items: center; font-weight: 800;
}
.selecting .mcard .tick { display: grid; }
.mcard .tick { display: none; }
.mcard.sel { outline: 4px solid var(--teal); outline-offset: 2px; }
.mcard.sel .tick { background: var(--teal); color: #fff; }
.more { text-align: center; padding: 26px 0; }
.empty { text-align: center; padding: 50px 20px; }
.empty h2 { font-size: 28px; }

/* ---------- bulk bar & toast ---------- */
.bulkbar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 30;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px;
  background: #fff; border: 2px solid var(--ink); border-radius: 20px; box-shadow: 0 5px 0 var(--ink);
  max-width: calc(100vw - 24px);
}
.toast {
  position: fixed; left: 50%; top: 80px; transform: translateX(-50%); z-index: 40;
  background: var(--ink); color: #fff; font-weight: 700; padding: 10px 18px; border-radius: 999px;
}

/* ---------- model page ---------- */
.back { display: inline-block; margin: 22px 0 14px; font-weight: 800; text-decoration: none; }
.model { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 24px; align-items: start; }
.viewer-wrap { display: flex; flex-direction: column; gap: 10px; }
.viewer {
  position: relative; aspect-ratio: 4/3; border: 2px solid var(--ink); border-radius: 24px; overflow: hidden;
  box-shadow: 0 5px 0 var(--ink);
  background: radial-gradient(circle at 50% 35%, #FFFFFF 0%, #FFF3E2 60%, #FFE4D6 100%);
}
.viewer canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.viewer-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; font-weight: 700; color: var(--muted); }
.viewer-msg .btn { margin-top: 10px; }
.viewer-tools { display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: var(--muted); }
.info { padding: 22px; }
.info h1 { font-size: 30px; overflow-wrap: anywhere; }
.info .badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 16px; font-size: 15px; }
.facts dt { color: var(--muted); font-weight: 700; }
.facts dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.info .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.edit { border-top: 2px dashed var(--line); padding-top: 16px; display: grid; gap: 10px; }
.edit h3 { font-size: 18px; margin: 0; }
.edit label { display: grid; gap: 4px; font-size: 13px; font-weight: 800; color: var(--muted); }
.edit .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.files-h { margin-top: 34px; font-size: 24px; }
.files { display: grid; gap: 8px; }
.frow { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: #fff; border: 2px solid var(--line); border-radius: 14px; }
.frow.on { border-color: var(--coral); }
.frow .fname { flex: 1; font-weight: 700; overflow-wrap: anywhere; }
.frow .fsize { color: var(--muted); font-weight: 700; font-size: 14px; white-space: nowrap; }
.ext { font: 700 11px var(--head); letter-spacing: .05em; padding: .3em .6em; border-radius: 8px; background: #F3EEE7; text-transform: uppercase; }

/* ---------- request page ---------- */
.request { display: grid; grid-template-columns: 1fr 1.2fr; gap: 40px; align-items: start; padding-top: 34px; }
.request h1 { font-size: clamp(30px, 4vw, 44px); }
.ticks { list-style: none; padding: 0; display: grid; gap: 10px; font-weight: 700; }
.ticks li { display: flex; gap: 10px; }
.ticks li::before { content: ""; flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--ink); background: var(--lime) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='m5 10 3.5 3.5L15 7' fill='none' stroke='%232B2440' stroke-width='2.6' stroke-linecap='round'/%3E%3C/svg%3E") center/16px no-repeat; }
.form { padding: 26px; display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-weight: 800; font-size: 14px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form .row.three { grid-template-columns: 1fr 1.4fr 1.2fr; }
.form-note { margin: 0; font-weight: 700; color: var(--teal); }

/* ---------- footer ---------- */
.foot { display: flex; flex-wrap: wrap; gap: 10px 30px; align-items: center; justify-content: space-between; padding: 26px clamp(16px, 4vw, 40px); border-top: 2px solid var(--line); font-weight: 700; }
.foot > div:first-child { display: flex; align-items: center; gap: 8px; font-family: var(--head); font-size: 18px; }
.foot .small { width: 100%; color: var(--muted); font-size: 13px; }

@media (max-width: 900px) {
  .model, .request { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 10px; }
  .topbar nav { gap: 12px; }
  .count { margin-left: 0; width: 100%; }
}
@media (max-width: 560px) {
  .brand span { font-size: 20px; }
  .topbar nav > a:not(.btn) { display: none; }
  .form .row, .form .row.three, .edit .row2 { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .mcard h3 { font-size: 15px; }
}
