/* ==========================================================================
   App chrome: top bar, sign-in, installer, errors, dashboard, admin, print
   ========================================================================== */

/* ---------- top bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 50; height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px; background: color-mix(in srgb, var(--surface) 86%, transparent); border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(1.6) blur(12px); backdrop-filter: saturate(1.6) blur(12px);
}
.appbar-left, .appbar-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.appbar-left { flex: 1; }
.appbar-right { gap: 4px; }
.appbar-search {
  flex: 1; min-width: 0; max-width: 540px; display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 8px 0 16px; margin-left: 28px;
  background: var(--surface-3); border: 1px solid transparent; border-radius: var(--radius-full); color: var(--text-3);
  transition: border-color var(--dur), box-shadow var(--dur), background var(--dur);
}
.appbar-search:hover { border-color: var(--border); }
.appbar-search:focus-within { background: var(--surface); border-color: var(--accent); box-shadow: var(--ring); }
.appbar-search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; color: var(--text); font-size: 14px; }
.appbar-search input:focus { box-shadow: none; }
.brand-tile { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--butter); border: 1.5px solid var(--line); box-shadow: 2px 2px 0 var(--line); transition: transform .35s var(--spring); }
.brand-tile .brand-logo { width: 24px; height: 24px; color: var(--brand); }
.brand:hover .brand-tile { transform: rotate(-8deg); }
.brand:hover .brand-tile .brand-logo { transform: none; }
@media (max-width: 720px) {
  .appbar { padding: 0 12px; gap: 8px; height: 60px; }
  .appbar .brand span:not(.brand-tile) { display: none; }
  .appbar-search { margin-left: 4px; height: 40px; }
  .appbar-search kbd { display: none; }
}

/* ---------- sign in: split scene + mascot ---------- */
.auth-body { background: var(--bg); overflow-x: hidden; }
.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-art {
  position: relative; overflow: hidden; isolation: isolate; color: #fff;
  background: radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--brand) 70%, #3fd6c4), var(--brand) 55%, var(--brand-deep));
  display: flex; flex-direction: column; justify-content: space-between; padding: 40px 48px;
}
.auth-art-bg { position: absolute; inset: 0; z-index: -1; pointer-events: none; background-image: radial-gradient(rgba(255, 200, 87, .32) 1px, transparent 1.3px); background-size: 24px 24px; -webkit-mask-image: linear-gradient(180deg, #000, transparent 85%); mask-image: linear-gradient(180deg, #000, transparent 85%); }
.auth-art::after { content: ''; position: absolute; width: 520px; height: 520px; right: -200px; bottom: -220px; border-radius: 50%; z-index: -1; background: radial-gradient(circle, rgba(255, 122, 89, .45), transparent 65%); animation: drift 18s ease-in-out infinite; }
@keyframes drift { 50% { transform: translate(-30px, -24px) scale(1.06); } }
.auth-logo { color: #fff; font-size: 20px; align-self: flex-start; }
.auth-scene { position: relative; align-self: center; width: min(100%, 440px); aspect-ratio: 1.15; display: grid; place-items: center; margin: 24px 0; }
.auth-scene .sticker { position: absolute; z-index: 2; animation: bob 6s ease-in-out infinite; font-size: 14px; }
.auth-scene .st1 { --tilt: -7deg; left: 0; top: 14%; }
.auth-scene .st2 { --tilt: 5deg; right: 0; top: 46%; animation-delay: -2s; }
.auth-scene .st3 { --tilt: 9deg; left: 30%; bottom: 4%; animation-delay: -4s; }
@keyframes bob { 50% { translate: 0 -10px; } }
.auth-pitch { max-width: 460px; }
.auth-pitch h2 { color: #fff; font-size: clamp(26px, 2.8vw, 36px); font-weight: 800; letter-spacing: -.03em; line-height: 1.12; }
.auth-pitch p { margin-top: 10px; color: rgba(255, 255, 255, .82); font-size: 15px; }
.squiggle { position: relative; white-space: nowrap; }
.squiggle::after { content: ''; position: absolute; left: -2%; right: -2%; bottom: -.18em; height: .32em; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 12' preserveAspectRatio='none'%3E%3Cpath d='M2 8 C 20 2, 30 11, 48 6 S 80 1, 96 7 S 112 9, 118 4' fill='none' stroke='%23ffc857' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center / 100% 100%; }
.auth-points { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; color: rgba(255, 255, 255, .92); font-weight: 500; }
.auth-points li { display: flex; align-items: center; gap: 10px; }
.auth-points .icon { width: 22px; height: 22px; padding: 3px; border-radius: 50%; background: rgba(255, 255, 255, .18); color: var(--butter); }

.auth-stage { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 88px 24px 40px; }
.auth-top { position: absolute; top: 20px; left: 24px; right: 24px; display: flex; justify-content: space-between; align-items: center; }
.auth-card { position: relative; width: 100%; max-width: 440px; padding: 36px 34px 28px; display: flex; flex-direction: column; gap: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 28px; box-shadow: var(--shadow-lg); animation: cardPop .6s var(--spring) both; }
@keyframes cardPop { from { transform: translateY(20px) scale(.98); } }
.auth-card.is-shake { animation: cardPop .6s var(--spring) both, shake .5s .5s var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.auth-heading { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.auth-heading h1 { font-size: 32px; font-weight: 800; letter-spacing: -.035em; }
.auth-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-full); background: var(--accent-soft); color: var(--accent-fg); font-size: 12px; font-weight: 700; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form .field > span:first-child { font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-2); }
.input-icon { position: relative; display: block; }
.input-icon > .icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; transition: color var(--dur); z-index: 1; }
.input-icon .input { padding-left: 44px; border-radius: 14px; }
.input-icon:focus-within > .icon { color: var(--accent-fg); }
.auth-submit { margin-top: 4px; gap: 6px; }
.auth-submit .icon { transition: transform .25s var(--spring); }
.auth-submit:hover .icon { transform: translateX(4px); }
.auth-links { display: flex; gap: 6px; justify-content: center; align-items: center; font-size: 14px; flex-wrap: wrap; padding-top: 16px; border-top: 1px solid var(--border); }
.auth-links a { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.auth-foot { display: flex; align-items: center; justify-content: center; gap: 6px; text-align: center; }

/* admin variant: calm ink scene */
.auth.is-admin .auth-art { background: radial-gradient(120% 90% at 0% 0%, #1d3236, #0f191b 60%); }
.auth.is-admin .auth-art::after { background: radial-gradient(circle, rgba(15, 155, 142, .45), transparent 65%); }
.auth.is-admin .auth-art-bg { background-image: radial-gradient(rgba(90, 216, 201, .25) 1px, transparent 1.3px); }

@media (max-width: 960px) {
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-art { padding: 18px 20px 0; min-height: 0; }
  .auth-pitch { display: none; }
  .auth-scene { width: 100%; max-width: 360px; aspect-ratio: auto; height: 190px; margin: 4px auto 0; place-items: end center; }
  .auth-scene .sticker { font-size: 12px; padding: 5px 10px; }
  .auth-scene .st1 { top: 18%; } .auth-scene .st2 { top: 38%; } .auth-scene .st3 { display: none; }
  .auth-stage { justify-content: flex-start; padding: 0 16px 32px; }
  .auth-top { position: static; width: 100%; max-width: 440px; order: -1; margin-top: -1px; padding-top: 12px; }
  .auth-top .btn-ghost:not(.btn-icon) { display: none; }
  .auth-top { justify-content: flex-end; }
  .auth-card { margin-top: -6px; padding: 28px 22px 22px; border-radius: 24px; }
  .auth-heading h1 { font-size: 26px; }
  .auth-art .auth-logo { position: relative; z-index: 3; }
}
@media (max-width: 960px) {
  /* the toggle sits in the jade band on small screens */
  .auth { position: relative; }
  .auth-stage { position: static; }
  .auth-top { position: absolute; top: 14px; right: 14px; left: auto; width: auto; padding: 0; margin: 0; z-index: 5; }
  .mascot-shadow { display: none; }
  .auth-top .btn-icon { color: #fff; }
  .auth-top .btn-icon:hover { background: rgba(255, 255, 255, .15); }
  .auth-stage { padding-top: 0; }
  .auth-card { margin-top: -18px; }
}

/* ---------- mascot "Formi": a paper clipboard with ink outlines ---------- */
.mascot { position: relative; width: 300px; height: 222px; }
.mascot-svg { width: 100%; height: 100%; overflow: visible; display: block; }
.mascot-shadow { position: absolute; left: 6%; right: 6%; bottom: -9px; height: 18px; border-radius: 12px; background: rgba(255, 255, 255, .16); border: 1.5px solid rgba(255, 255, 255, .38); box-shadow: 0 10px 24px -8px rgba(0, 0, 0, .35); }
.m-body { transform-origin: 80px 130px; transition: transform .35s var(--spring); animation: breathe 4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: translateY(2px) scaleY(.985); } }
.m-page { fill: #fffdf8; stroke: var(--ink); stroke-width: 3.5; }
.m-line { fill: #ece7dc; }
.m-clip { fill: var(--coral); stroke: var(--ink); stroke-width: 3; }
.m-clip-dot { fill: rgba(255, 255, 255, .55); }
.m-badge circle { fill: var(--butter); stroke: var(--ink); stroke-width: 2.5; }
.m-badge path { fill: var(--ink); }
.m-white { fill: #fff; stroke: var(--ink); stroke-width: 2.5; }
.m-pupil { transition: transform .12s linear; }
.m-pupil circle { fill: var(--ink); }
.m-pupil .m-shine { fill: #fff; }
.m-lid { fill: #fffdf8; transform-box: fill-box; transform-origin: top; transform: scaleY(0); animation: blink 4.5s infinite; }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(0); } 95% { transform: scaleY(1); } }
.m-cheek { fill: var(--coral); opacity: .45; }
.m-brow { fill: none; stroke: var(--ink); stroke-width: 3.5; stroke-linecap: round; opacity: 0; transition: opacity .2s, transform .3s var(--spring); transform-box: fill-box; transform-origin: center; }
.m-mouth { fill: none; stroke: var(--ink); stroke-width: 3.5; stroke-linecap: round; opacity: 0; transition: opacity .15s; }
.m-mouth.happy { fill: var(--ink); stroke-linejoin: round; }
.m-mouth.o { fill: var(--ink); stroke: none; }
.mascot[data-mood="idle"] .m-mouth.smile, .mascot[data-mood="look"] .m-mouth.smile { opacity: 1; }
.mascot[data-mood="typing"] .m-mouth.o { opacity: 1; }
.mascot[data-mood="sad"] .m-mouth.sad, .mascot[data-mood="sad"] .m-brow { opacity: 1; }
.mascot[data-mood="sad"] .m-brow.l { transform: rotate(-14deg) translateY(2px); } .mascot[data-mood="sad"] .m-brow.r { transform: rotate(14deg) translateY(2px); }
.mascot[data-mood="happy"] .m-mouth.happy { opacity: 1; }
.mascot[data-mood="happy"] .m-body { animation: hop .7s var(--spring) 2; }
@keyframes hop { 40% { transform: translateY(-12px); } }
.m-hand { transition: transform .45s var(--spring); }
.m-hand ellipse { fill: var(--butter); stroke: var(--ink); stroke-width: 3; }
.m-hand path { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; opacity: .5; }
.mascot.is-hiding .m-hand { transform: translateY(-88px); }
.mascot.is-hiding.is-peeking .m-hand.r { transform: translateY(-64px) rotate(-12deg); transform-origin: 98px 152px; }
.mascot.is-hiding .m-mouth { opacity: 0 !important; }
.mascot.is-hiding .m-mouth.o { opacity: 1 !important; }
@media (max-width: 960px) { .mascot { width: 220px; height: 163px; } }
@media (prefers-reduced-motion: reduce) { .auth-scene .sticker, .auth-art::after { animation: none !important; } }

/* ---------- installer ---------- */
.setup-body { background: var(--bg); background-image: radial-gradient(color-mix(in srgb, var(--text) 7%, transparent) 1px, transparent 1.2px); background-size: 22px 22px; }
.setup { max-width: 780px; margin: 0 auto; padding: 32px 20px 64px; display: flex; flex-direction: column; gap: 16px; }
.setup .card { border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.setup-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; padding: 12px 14px 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-full); box-shadow: var(--shadow-xs); }
.steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text-3); flex-wrap: wrap; }
.steps li { display: flex; align-items: center; gap: 8px; }
.steps li + li::before { content: ''; width: 22px; height: 2px; border-radius: 2px; background: var(--border-strong); margin-right: 2px; }
.steps li.is-done + li::before { background: var(--accent); }
.step-dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--border-strong); font-weight: 700; font-size: 12px; background: var(--surface); transition: all .3s var(--spring); }
.steps li.is-current { color: var(--text); font-weight: 600; }
.steps li.is-current .step-dot { border-color: var(--accent); color: var(--accent-fg); box-shadow: var(--ring); transform: scale(1.08); }
.steps li.is-done .step-dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.setup-success { display: flex; gap: 16px; align-items: center; }
.setup-foot { text-align: center; }
.checklist { list-style: none; padding: 0; margin: 16px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px 16px; }
.checklist li { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.checklist li.ok .icon { color: var(--success); } .checklist li.bad { color: var(--danger); }
.radio-cards { display: grid; gap: 10px; }
.radio-card { display: flex; gap: 12px; align-items: flex-start; padding: 15px 16px; border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer; background: var(--surface); transition: border-color var(--dur), background var(--dur), transform .2s var(--spring); }
.radio-card:hover { border-color: var(--border-strong); }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-softer); }
.radio-card input { margin-top: 3px; accent-color: var(--accent); }
.radio-card span { display: flex; flex-direction: column; gap: 2px; }
.schema-tables { border: 1px solid var(--border); border-radius: var(--radius-sm); }
.schema-actions { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.schema-actions summary { padding: 12px 14px; cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.schema-actions ol { margin: 0; padding: 0 16px 14px 36px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.schema-actions li span { display: block; }
code.sql { display: block; margin-top: 4px; padding: 6px 8px; white-space: pre-wrap; word-break: break-word; font-size: 11.5px; color: var(--text-2); }
.admin-access { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.admin-access-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-fg); flex: none; }
@media (max-width: 600px) { .setup-head { border-radius: var(--radius-lg); } }

/* ---------- errors ---------- */
.page-center { display: grid; place-items: center; padding: 24px; background-image: radial-gradient(color-mix(in srgb, var(--text) 7%, transparent) 1px, transparent 1.2px); background-size: 22px 22px; }
.error-page { text-align: center; max-width: 500px; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 40px 28px 32px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-md); animation: cardPop .6s var(--spring) both; }
.error-icon { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: var(--butter); border: 1.5px solid var(--line); color: var(--ink); box-shadow: var(--shadow-pop); margin-bottom: 10px; transform: rotate(-6deg); }
.error-icon .icon { width: 28px; height: 28px; }
.error-code { font-family: var(--font-display); font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-fg); }
.error-page h1 { font-size: 28px; font-weight: 800; letter-spacing: -.03em; }
.error-page .row { margin-top: 14px; }
.debug { text-align: left; white-space: pre-wrap; font-size: 12px; background: var(--surface-3); padding: 12px; border-radius: 8px; margin-top: 24px; overflow: auto; max-height: 300px; max-width: 90vw; }

/* ---------- legacy landing blocks ---------- */
.landing { padding-bottom: 80px; }
.hero { text-align: center; max-width: 760px; margin: 0 auto; padding: 88px 24px 56px; display: flex; flex-direction: column; gap: 20px; align-items: center; }
.hero h1 { font-size: clamp(32px, 5.5vw, 52px); letter-spacing: -.03em; line-height: 1.1; font-weight: 800; }
.lead { font-size: 17px; color: var(--text-2); max-width: 600px; }
.eyebrow { display: inline-flex; gap: 6px; align-items: center; padding: 4px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); color: var(--text-2); font-weight: 600; font-size: 13px; }
.eyebrow .icon { width: 15px; height: 15px; color: var(--accent-fg); }
.features { max-width: 1080px; margin: 0 auto; padding: 0 24px; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-xs); }
.feature-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-fg); margin-bottom: 14px; }
.feature h3 { font-size: 15px; margin-bottom: 4px; }

/* ---------- dashboard ---------- */
.dashboard { padding-bottom: 88px; }
.dash-hello { position: relative; overflow: hidden; isolation: isolate; }
.dash-hello::before { content: ''; position: absolute; inset: 0; z-index: -1; background-image: radial-gradient(color-mix(in srgb, var(--text) 8%, transparent) 1px, transparent 1.2px); background-size: 22px 22px; -webkit-mask-image: linear-gradient(180deg, #000 20%, transparent); mask-image: linear-gradient(180deg, #000 20%, transparent); }
.dash-hello::after { content: ''; position: absolute; z-index: -1; width: 460px; height: 460px; right: -120px; top: -260px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--brand) 22%, transparent), transparent 65%); }
.dash-hello-inner { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-top: 36px; padding-bottom: 8px; }
.dash-greet { font-size: clamp(26px, 3.4vw, 38px); font-weight: 800; letter-spacing: -.035em; line-height: 1.1; }
.dash-hello .muted { margin-top: 6px; font-size: 15px; }
.wave { display: inline-block; transform-origin: 70% 70%; animation: wave 2.4s ease-in-out 1s 2; }
@keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(16deg); } 20%, 40% { transform: rotate(-8deg); } }
.dash-stats { display: grid; grid-template-columns: repeat(3, minmax(110px, 1fr)); gap: 10px; }
.dash-stat { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px 18px 14px 16px; border-radius: 20px; font-size: 13px; background: var(--surface) !important; border: 1px solid var(--border); box-shadow: var(--shadow-xs); overflow: hidden; transition: transform .25s var(--spring), box-shadow .25s; }
.dash-stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.dash-stat::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: currentColor; }
.dash-stat b { font-family: var(--font-display); font-size: 28px; font-weight: 800; color: var(--text); letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.dash-stat span { color: var(--text-2); font-weight: 500; }
.dash-stat .icon { position: absolute; right: 12px; top: 12px; width: 30px; height: 30px; padding: 6px; border-radius: 10px; background: color-mix(in srgb, currentColor 14%, transparent); }
@media (max-width: 600px) { .dash-stats { width: 100%; grid-template-columns: repeat(3, 1fr); } .dash-stat { padding: 12px; } .dash-stat b { font-size: 22px; } .dash-stat .icon { display: none; } }

.templates-strip { padding: 22px 0 8px; }
.templates-strip h2 { font-size: 16px; }
.template-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 16px; padding-top: 14px; max-height: 204px; overflow: hidden; }
.template-row.is-gallery { max-height: none; }
.template-tile { min-width: 0; }
.template-thumb {
  --t: var(--accent);
  display: block; width: 100%; aspect-ratio: 4 / 3; padding: 0; border: 1px solid var(--border); border-radius: var(--radius);
  background: color-mix(in srgb, var(--t) 12%, var(--surface-2)); overflow: hidden; position: relative;
}
.template-thumb::after { content: ''; position: absolute; width: 70%; aspect-ratio: 1; right: -30%; bottom: -40%; border-radius: 50%; background: color-mix(in srgb, var(--t) 22%, transparent); transition: transform .4s var(--spring); }
.template-thumb:hover { border-color: color-mix(in srgb, var(--t) 55%, var(--border)); box-shadow: var(--shadow-md); }
.template-thumb:hover::after { transform: scale(1.25); }
.template-tile.blank .template-thumb { background: var(--surface); display: grid; place-items: center; border: 2px dashed var(--border-strong); }
.template-tile.blank .template-thumb::after { display: none; }
.template-tile.blank .template-thumb:hover { border-color: var(--accent); background: var(--accent-softer); }
.template-tile .plus { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; background: var(--brand); color: #fff; border: 1.5px solid var(--line); box-shadow: var(--shadow-pop); transition: transform .35s var(--spring); }
.template-tile .plus .icon { width: 26px; height: 26px; }
.template-tile.blank .template-thumb:hover .plus { transform: rotate(90deg) scale(1.06); }
.template-name { font-weight: 600; margin-top: 9px; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.template-cat { font-size: 12px; }

.mini-form { position: absolute; z-index: 1; inset: 14px 16px auto; display: flex; flex-direction: column; gap: 6px; text-align: left; background: var(--surface); border-radius: 10px; padding: 10px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); border-top: 4px solid var(--t); transition: transform .35s var(--spring); }
.template-thumb:hover .mini-form, .form-card-thumb:hover .mini-form { transform: translateY(-3px) rotate(-1.5deg); }
.mini-title { font-size: 10.5px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-display); }
.mini-line { height: 5px; border-radius: 9px; background: var(--surface-3); }
.mini-line.short { width: 60%; }
.mini-opt { height: 6px; width: 70%; border-radius: 9px; background: var(--surface-3); position: relative; margin-left: 12px; }
.mini-opt::before { content: ''; position: absolute; left: -12px; top: -1px; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid color-mix(in srgb, var(--t) 75%, var(--text-3)); }
.mini-head { display: none; }

.dash-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 30px 0 16px; }
.dash-toolbar h1 { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.form-card { --t: var(--accent); position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; overflow: hidden; box-shadow: var(--shadow-xs); }
.form-card:hover { box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--t) 35%, var(--border)); }
.form-card-thumb { display: block; position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: color-mix(in srgb, var(--t) 12%, var(--surface-2)); border-bottom: 1px solid var(--border); }
.form-card-thumb::after { content: ''; position: absolute; width: 55%; aspect-ratio: 1; right: -18%; top: -30%; border-radius: 50%; background: color-mix(in srgb, var(--t) 20%, transparent); }
.form-card-thumb .mini-form { inset: 18px 22px auto; }
.thumb-chip { position: absolute; right: 10px; bottom: 10px; z-index: 2; }
.form-card-body { display: flex; gap: 10px; align-items: flex-start; padding: 13px 6px 13px 14px; }
.form-card-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: color-mix(in srgb, var(--t) 14%, transparent); color: var(--t); flex: none; margin-top: 1px; }
.form-card-icon .icon { width: 16px; height: 16px; }
.form-card-text { flex: 1; min-width: 0; }
.form-card-title { display: block; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-display); letter-spacing: -.01em; }
.form-card-meta { display: flex; flex-direction: column; gap: 1px; font-size: 12px; margin-top: 2px; }
.form-card-meta .sep { display: none; }
.form-grid.is-list .form-card-meta { flex-direction: row; gap: 6px; }
.form-grid.is-list .form-card-meta .sep { display: inline; }
.form-grid.is-list { grid-template-columns: 1fr; gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-xs); }
.form-grid.is-list .form-card { border: 0; border-radius: 0; border-bottom: 1px solid var(--border); box-shadow: none; display: flex; transform: none !important; }
.form-grid.is-list .form-card:last-child { border-bottom: 0; }
.form-grid.is-list .form-card:hover { background: var(--surface-2); }
.form-grid.is-list .form-card-thumb { display: none; }
.form-grid.is-list .form-card-body { flex: 1; align-items: center; padding: 11px 10px 11px 16px; }
.select-wrap.sm { display: inline-block; }
@media (max-width: 600px) { .form-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: 12px; } .template-row { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; max-height: 182px; } .dash-toolbar .segmented { max-width: 100%; overflow-x: auto; } }

/* ---------- admin ---------- */
.admin { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: calc(100dvh - 64px); }
.admin-nav { padding: 18px 12px; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; position: sticky; top: 64px; height: calc(100dvh - 64px); background: var(--surface); }
.admin-nav-item { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-radius: 12px; background: none; color: var(--text-2); font-weight: 600; font-size: 14px; text-decoration: none !important; text-align: left; transition: background var(--dur), color var(--dur); }
.admin-nav-item .icon { width: 19px; height: 19px; }
.admin-nav-item:hover { background: var(--surface-3); color: var(--text); }
.admin-nav-item.is-active { background: var(--accent-soft); color: var(--accent-fg); }
.admin-nav-item.is-active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); }
.admin-nav-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.admin-main { padding: 32px 36px 88px; max-width: 1140px; width: 100%; }
.admin-main > * { animation: riseIn .45s var(--ease) both; }
.page-title { font-size: 28px; font-weight: 800; letter-spacing: -.03em; margin-bottom: 16px; display: flex; align-items: center; gap: 12px; }
.page-title .icon { width: 40px; height: 40px; padding: 9px; border-radius: 13px; color: var(--accent-fg); background: var(--accent-soft); }
.lead-sm { margin: -6px 0 22px; max-width: 760px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.stat-card { position: relative; overflow: hidden; display: flex; gap: 14px; align-items: center; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-xs); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card::after { content: ''; position: absolute; width: 120px; height: 120px; right: -50px; top: -50px; border-radius: 50%; background: var(--accent-softer); }
.stat-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-fg); flex: none; }
.stat-grid > :nth-child(4n+2) .stat-icon { background: color-mix(in srgb, var(--coral) 16%, transparent); color: #e2593a; }
.stat-grid > :nth-child(4n+3) .stat-icon { background: color-mix(in srgb, var(--butter) 28%, transparent); color: #a86f00; }
.stat-grid > :nth-child(4n+4) .stat-icon { background: color-mix(in srgb, var(--sky) 16%, transparent); color: #2f7fe0; }
:root[data-theme="dark"] .stat-grid > :nth-child(4n+2) .stat-icon { color: #ff9a80; } :root[data-theme="dark"] .stat-grid > :nth-child(4n+3) .stat-icon { color: #ffd27a; } :root[data-theme="dark"] .stat-grid > :nth-child(4n+4) .stat-icon { color: #8cc2ff; }
.stat-value { font-family: var(--font-display); font-size: 26px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-label { font-size: 13px; }
.status-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 10px; }
.status-list li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.status-list b { margin-left: auto; font-size: 13px; font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); } .dot.warn { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.sticky-save { position: sticky; bottom: 16px; display: flex; justify-content: flex-end; }
.sticky-save .btn { box-shadow: var(--shadow-lg); }
details > summary { list-style: none; display: flex; align-items: center; gap: 8px; }
details > summary::-webkit-details-marker { display: none; }
@media (max-width: 900px) {
  .admin { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; align-content: start; }
  .admin-nav-item { align-self: center; }
  .admin-nav { position: sticky; top: 60px; z-index: 20; height: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 8px; scrollbar-width: none; }
  .admin-nav::-webkit-scrollbar { display: none; }
  .admin-nav-item { flex: none; width: auto; padding: 8px 14px; border-radius: 99px; }
  .admin-nav-item.is-active::before { display: none; }
  .admin-nav-foot { margin: 0; padding: 0; border: 0; }
  .admin-main { padding: 22px 16px 88px; }
  .page-title { font-size: 24px; }
}

/* ---------- print ---------- */
.print-page { max-width: 820px; margin: 0 auto; padding: 32px 24px; }
.print-actions { display: flex; justify-content: space-between; margin-bottom: 24px; }
.print-response { break-inside: avoid; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-top: 18px; background: var(--surface); }
.print-response h2 { font-size: 16px; margin-bottom: 10px; }
.print-q { padding: 8px 0; border-top: 1px dashed var(--border); }
.print-q-title { font-weight: 600; font-size: 13px; color: var(--text-2); }
@media print {
  .no-print, .appbar, .toasts { display: none !important; }
  body { background: #fff; }
  .print-response { border-color: #ddd; }
}
@media (max-width: 600px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; }
  .stat-icon { width: 36px; height: 36px; }
  .stat-value { font-size: 22px; }
}

.tone-jade { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.tone-coral { background: color-mix(in srgb, var(--coral) 14%, transparent); color: #e2593a; }
.tone-butter { background: color-mix(in srgb, var(--butter) 26%, transparent); color: #a86f00; }
.tone-sky { background: color-mix(in srgb, var(--sky) 16%, transparent); color: #2f7fe0; }
:root[data-theme="dark"] .tone-coral { color: #ff9a80; } :root[data-theme="dark"] .tone-butter { color: #ffd27a; } :root[data-theme="dark"] .tone-jade { color: #5ad8c9; } :root[data-theme="dark"] .tone-sky { color: #8cc2ff; }

/* Cards: a gentle lift, a little personality */
.form-card, .template-thumb, .stat-card { transition: transform .28s var(--spring), box-shadow .28s, border-color .28s; }
.form-card:hover, .template-thumb:hover { transform: translateY(-4px); }

/* ---------- installer access gate ---------- */
.setup-gate { max-width: 520px; padding-top: 56px; }
.gate-card { text-align: left; border-radius: 28px !important; box-shadow: var(--shadow-lg) !important; animation: cardPop .6s var(--spring) both; }
.gate-icon { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; background: var(--butter); color: var(--ink); border: 1.5px solid var(--line); box-shadow: var(--shadow-pop); transform: rotate(-6deg); }
.gate-icon .icon { width: 28px; height: 28px; }
.gate-steps { margin: 0; padding-left: 20px; color: var(--text-2); display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.gate-input { letter-spacing: .1em; text-transform: uppercase; font-family: var(--mono); font-size: 15px; }
.gate-input::placeholder { letter-spacing: .04em; }
.setup-foot .linklike { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); }

/* ---------- error helpful links ---------- */
.error-links { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.error-links a { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-weight: 600; font-size: 13px; text-decoration: none; transition: transform .2s var(--spring), border-color .2s; }
.error-links a:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--accent-fg); }
@media (min-width: 600px) and (max-width: 960px) {
  .auth-scene { height: 250px; max-width: 460px; }
  .mascot { width: 280px; height: 207px; }
  .auth-stage { padding-bottom: 56px; }
}

/* ---------- Continue with Google ---------- */
.auth-or { display: flex; align-items: center; gap: 12px; margin: -2px 0; color: var(--text-3); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.auth-or::before, .auth-or::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.btn-google { gap: 12px; font-weight: 600; background: var(--surface); border-color: var(--border-strong); }
.btn-google:hover:not(:disabled) { background: var(--surface-2); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-google .g-logo { width: 20px; height: 20px; flex: none; transition: transform .35s var(--spring); }
.btn-google:hover .g-logo { transform: rotate(-12deg) scale(1.08); }
.btn-google.is-busy .g-logo { animation: spin 1s linear infinite; }
:root[data-theme="dark"] .btn-google { background: var(--surface-2); }
