/* KIKiie BUNNY UX redesign: hero, main navigation, quick start, companion hub, wish preview, float summary,
   Explore and My Memories. Palette: midnight purple, lavender, pastel pink, warm cream, soft gold, mint. */
:root { --f-mid: #211b53; --f-lav: #b9a2ff; --f-pink: #ff83a9; --f-cream: #fff8ef; --f-gold: #f2c14e; --f-mint: #dff5ea; }

/* activity buttons now live in Explore / My Memories (the hero shows a single main CTA) */
.top-btns #festBtn, .top-btns #historyBtn { display: none; }

/* ---------- hero ---------- */
.hero {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; padding: 16px 16px 28px;
  background: linear-gradient(180deg, rgba(20, 15, 60, 0) 0%, rgba(20, 15, 60, .15) 22%, rgba(30, 22, 78, .9) 40%, #2a1f5c 52%, #2a1f5c 100%);
  transition: opacity .35s ease;
}
.hero.leaving { opacity: 0; pointer-events: none; }
body.hero-open { overflow: hidden; }
body.hero-open .brand { opacity: 0; }
body.hero-open .sheet { visibility: hidden; }
.hero-inner { width: min(560px, 100%); text-align: center; color: #fff; }
.hero-mascot { width: 104px; height: 104px; margin: 0 auto -4px; animation: heroBob 3.2s ease-in-out infinite; }
.hero-mascot svg { width: 100%; height: 100%; }
@keyframes heroBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.hero-brand { margin: 0; font: 700 .85rem "Mali", sans-serif; color: #ffd6e8; letter-spacing: .04em; }
.hero-title { margin: 2px 0 6px; font: 700 clamp(2.4rem, 9vw, 3.6rem)/1.1 "Mali", sans-serif; text-shadow: 0 6px 26px rgba(255, 150, 200, .5); }
.hero-sub { margin: 0 auto 18px; max-width: 460px; font-size: 1rem; line-height: 1.65; color: #f3e9ff; }
.hero-cta { width: min(360px, 100%); font-size: 1.12rem !important; padding: 14px 20px !important; box-shadow: 0 12px 30px rgba(255, 131, 169, .45); }
.hero-resume { display: block; margin: 10px auto 0; color: #ffe1ef; font-weight: 700; }
.hero-sec { display: block; margin: 12px auto 0; background: rgba(255, 255, 255, .14); color: #fff; border: 1.5px solid rgba(255, 255, 255, .45); border-radius: 999px; padding: 9px 18px; font: 600 .92rem "Mali", sans-serif; cursor: pointer; }
.hero-sec:hover { background: rgba(255, 255, 255, .22); }
.hero-eco { margin: 16px 0 2px; font-size: .82rem; color: #bfeed7; }
.hero-concept { margin: 0; font: 600 .74rem "Mali", sans-serif; color: #d9c8ff; letter-spacing: .06em; }
@media (prefers-reduced-motion: reduce) { .hero-mascot { animation: none; } .hero { transition: none; } }

/* ---------- main navigation ---------- */
.main-nav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: #fff; border: 1.5px solid #f0e2f0; border-radius: 22px; padding: 5px; margin: 0 auto 14px; max-width: 560px; box-shadow: 0 6px 18px rgba(60, 30, 90, .08); }
.main-nav button { border: 0; background: transparent; border-radius: 16px; padding: 7px 4px; cursor: pointer; font: 700 .82rem "Mali", sans-serif; color: #8d7a9a; display: flex; flex-direction: column; align-items: center; gap: 1px; line-height: 1.2; }
.main-nav button span { font-size: 1.15rem; }
.main-nav button[aria-pressed="true"] { background: linear-gradient(135deg, #ffe3ee, #efe6ff); color: #51417e; }
body.nav-explore #builder, body.nav-explore #afterCard, body.nav-explore #sharedCard,
body.nav-memories #builder, body.nav-memories #afterCard, body.nav-memories #sharedCard { display: none !important; }
/* phones: thumb-reach bottom bar */
@media (max-width: 759px) {
  .main-nav { position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 15; margin: 0; max-width: none; box-shadow: 0 10px 30px rgba(33, 27, 83, .25); }
  body { padding-bottom: 78px; }
  .studio-bar { bottom: calc(80px + env(safe-area-inset-bottom)) !important; }
  .toast { bottom: calc(92px + env(safe-area-inset-bottom)) !important; }
  body.hero-open .main-nav { display: none; }
}

/* ---------- shared step header ---------- */
.step-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.step-head h2 { margin: 0; }
.step-sub { margin: 4px 0 0; color: #8d7a90; font-size: .9rem; line-height: 1.5; }
.skip-link { color: #9a86a8; font-weight: 600; }
.nav-row:has(.skip-link) { align-items: center; }

/* ---------- step 1: quick start + progressive editor ---------- */
.kt-quick { margin: 4px 0 10px; }
.kt-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.kt-tpl { border: 1.5px solid #f0dcea; background: #fff; border-radius: 18px; padding: 4px 4px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px; transition: transform .15s, border-color .15s, box-shadow .15s; }
.kt-tpl svg { width: 100%; height: auto; aspect-ratio: 200 / 150; }
.kt-tpl b { font: 700 .78rem "Mali", sans-serif; color: #51417e; }
.kt-tpl small { font-size: .68rem; color: #a593b0; }
.kt-tpl:hover { transform: translateY(-2px); }
.kt-tpl[aria-checked="true"] { border-color: var(--f-pink); box-shadow: 0 0 0 4px rgba(255, 131, 169, .18); background: #fff6fa; }
.kt-simple-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.kt-simple-actions .btn.primary { min-width: 180px; }
.kt-edit-head { display: none; justify-content: space-between; margin: 0 0 8px; }

/* simple mode (default): templates + preview, tools hidden */
.step.studio:not(.editing) .studio-side,
.step.studio:not(.editing) .studio-bar,
.step.studio:not(.editing) .studio-mini,
.step.studio:not(.editing) .studio-tip,
.step.studio:not(.editing) .kstyles,
.step.studio:not(.editing) #editBar { display: none !important; }
.step.studio:not(.editing) .studio-main { display: block; }
.step.studio:not(.editing) .studio-preview { max-width: 520px; margin: 0 auto; position: static; }
/* edit mode: the existing studio, advanced tools behind "ปรับแต่งเพิ่มเติม" */
.step.studio.editing .kt-quick, .step.studio.editing .kt-simple-actions { display: none; }
.step.studio.editing .kt-edit-head { display: flex; }
/* two modes only: Quick Create and the full Advanced Editor (style switch, save, arrange all inside) */
#ktAdv { display: none; }

@container sheet (min-width: 760px) {
  /* desktop: big preview + template panel side by side */
  .step.studio:not(.editing):not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px 20px; align-items: start; }
  .step.studio:not(.editing) > .studio-top, .step.studio:not(.editing) > .kt-simple-actions { grid-column: 1 / -1; }
  .step.studio:not(.editing) > .studio-main { grid-column: 1; grid-row: 2; }
  .step.studio:not(.editing) > .kt-quick { grid-column: 2; grid-row: 2; margin: 0; }
  .kt-templates { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .kt-simple-actions { justify-content: flex-end; }
}

/* ---------- step 2: companion hub ---------- */
.comp-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; padding: 10px 12px; border-radius: 18px; background: linear-gradient(135deg, #fff4f9, #f3ecff); border: 1.5px dashed #ecd4ea; }
.cs-label { font: 700 .8rem "Mali", sans-serif; color: #8a4f9e; margin-right: 4px; }
.cs-chip { display: inline-flex; align-items: center; gap: 4px; background: #fff; border-radius: 999px; padding: 3px 4px 3px 12px; font: 600 .82rem "Mali", sans-serif; color: #51417e; box-shadow: 0 2px 6px rgba(60, 30, 90, .08); }
.cs-chip button { border: 0; background: #f6eef8; color: #8d7a9a; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; font-size: .9rem; line-height: 1; }
.cs-empty { color: #8d7a90; font-size: .86rem; }
.comp-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.comp-card {
  position: relative; text-align: left; border: 1.5px solid #f0dcea; background: #fff; border-radius: 22px; padding: 14px 14px 12px; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; min-height: 112px; transition: transform .15s, box-shadow .15s, border-color .15s;
}
.comp-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(60, 30, 90, .1); }
.cc-ico { font-size: 1.7rem; }
.comp-card b { font: 700 1rem "Mali", sans-serif; color: #3d2b4f; }
.comp-card small { color: #8d7a90; font-size: .8rem; line-height: 1.4; }
.cc-state { position: absolute; top: 10px; right: 10px; font-style: normal; font: 700 .7rem "Mali", sans-serif; color: #9a86a8; background: #f6eef8; border-radius: 999px; padding: 2px 9px; }
.comp-card.on { border-color: var(--f-pink); background: #fff6fa; }
.comp-card.on .cc-state { background: var(--f-pink); color: #fff; }
.comp-card[aria-expanded="true"] { box-shadow: 0 0 0 4px rgba(185, 162, 255, .3); border-color: var(--f-lav); }
.comp-panel { border: 1.5px solid #efe2f3; border-radius: 22px; padding: 14px; margin: 0 0 12px; background: #fffcfa; animation: cardIn .35s ease; }
.comp-q { margin: 0 0 8px; font: 700 1rem "Mali", sans-serif; color: #8a4f9e; }
.comp-panel-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.fan-count { font-style: normal; font: 700 .72rem "Mali", sans-serif; color: #fff; background: #b48cf0; border-radius: 999px; padding: 1px 8px; margin-left: 4px; }
@container sheet (min-width: 760px) {
  .comp-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------- step 3: wish preview ---------- */
.wish-preview { display: flex; gap: 12px; align-items: center; margin: 6px 0 12px; padding: 10px 12px; border-radius: 18px; background: linear-gradient(135deg, #241c5e, #4d3f86); color: #fff; }
.wp-art { width: 96px; flex: 0 0 96px; }
.wp-art svg { width: 100%; height: auto; display: block; }
.wp-text small { display: block; font-size: .7rem; color: #d9c8ff; }
.wp-text b { display: block; font: 700 .82rem "Mali", sans-serif; color: #ffd6e8; margin: 1px 0 3px; }
.wp-text p { margin: 0; font: 700 1rem/1.45 "Mali", sans-serif; }
.wp-text p.empty { color: #bfb2e6; font-weight: 500; font-size: .86rem; }

/* ---------- step 4: summary ---------- */
.float-sum { display: grid; gap: 12px; margin-bottom: 12px; }
.fs-art { display: flex; align-items: flex-end; justify-content: center; gap: 0; padding: 14px; border-radius: 22px; background: radial-gradient(ellipse at 50% 85%, #4d3f86 0, #2a1f5c 60%, #1d1747 100%); min-height: 170px; }
.fs-doll { width: 92px; margin-right: -18px; position: relative; z-index: 1; }
.fs-doll:empty { display: none; }
.fs-doll svg { width: 100%; height: auto; display: block; }
.fs-kt { width: 210px; }
.fs-kt svg { width: 100%; height: auto; display: block; }
.fs-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.fs-list li { display: grid; grid-template-columns: 116px 1fr auto; gap: 8px; align-items: center; padding: 9px 12px; border-radius: 16px; background: #fff; border: 1px solid #f0e4f2; }
.fs-list span { font: 700 .82rem "Mali", sans-serif; color: #8a4f9e; }
.fs-list b { font-weight: 600; font-size: .9rem; color: #3d2b4f; line-height: 1.45; }
.fs-list b.muted { color: #a593b0; font-weight: 500; }
@container sheet (min-width: 720px) {
  .float-sum { grid-template-columns: 300px 1fr; align-items: center; }
}
@container sheet (max-width: 480px) {
  .fs-list li { grid-template-columns: 1fr auto; }
  .fs-list li b { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------- float: skip ---------- */
.skip-float { position: absolute; right: 14px; bottom: 14px; z-index: 8; border: 0; border-radius: 999px; padding: 7px 14px; background: rgba(255, 255, 255, .88); color: #51417e; font: 700 .8rem "Mali", sans-serif; cursor: pointer; box-shadow: 0 6px 16px rgba(0, 0, 0, .25); }

/* ---------- memory page ---------- */
.res-bless { margin: -2px 0 10px; text-align: center; font: 600 .86rem "Mali", sans-serif; color: #b0709a; }
#sizeTabs [hidden] { display: none; }

/* ---------- Explore + My Memories ---------- */
.view-head h2 { margin: 0; }
.view-head p { margin: 4px 0 12px; color: #8d7a90; font-size: .9rem; }
.ex-grid { display: grid; gap: 10px; }
.ex-card { border: 1.5px solid #f0e2f0; border-radius: 22px; padding: 14px; background: #fff; display: flex; flex-direction: column; gap: 4px; }
.ex-card h3 { margin: 0; font: 700 1.05rem "Mali", sans-serif; color: #3d2b4f; }
.ex-card p { margin: 0 0 6px; color: #6b5a76; font-size: .86rem; line-height: 1.55; }
.ex-card .btn { align-self: flex-start; margin-top: auto; }
.ex-ico { font-size: 1.8rem; }
.ex-meta { font: 700 .8rem "Mali", sans-serif; color: #8a4f9e !important; }
.ex-river { background: linear-gradient(160deg, #2a1f5c, #4d3f86); border: 0; }
.ex-river h3, .ex-river p { color: #fff; }
.ex-river .ex-meta { color: #ffd6e8 !important; }
@container sheet (min-width: 720px) { .ex-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.mm-empty { text-align: center; padding: 10px 0 6px; }
.mm-empty svg { width: 110px; height: 110px; }
.mm-empty p { color: #6b5a76; }
.mm-sec { border-top: 1.5px dashed #f0dcea; padding: 12px 0 4px; }
.mm-sec h3 { margin: 0 0 8px; font: 700 1rem "Mali", sans-serif; color: #51417e; }
.mm-list { display: grid; gap: 8px; }
.mm-item { display: flex; gap: 10px; align-items: center; background: #fff; border: 1px solid #f0e4f2; border-radius: 16px; padding: 6px 10px; }
.mm-kt { width: 72px; flex: 0 0 72px; }
.mm-kt svg { width: 100%; height: auto; display: block; }
.mm-wish { margin: 0; font: 700 .92rem/1.4 "Mali", sans-serif; color: #3d2b4f; }
.mm-item small { color: #9a86a8; font-size: .74rem; }
.mm-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.mm-petrow { display: flex; gap: 12px; align-items: flex-start; }
.mm-petart { width: 96px; flex: 0 0 96px; }
.mm-petart svg { width: 100%; height: auto; }
.mm-mini { margin: 6px 0 0; padding-left: 18px; color: #6b5a76; font-size: .84rem; line-height: 1.6; }
@container sheet (min-width: 720px) { .mm-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* phones: templates in one swipeable row so the preview stays close */
@container sheet (max-width: 759px) {
  .kt-templates { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 8px; padding: 2px 2px 8px; margin: 0 -2px; -webkit-overflow-scrolling: touch; }
  .kt-tpl { flex: 0 0 128px; scroll-snap-align: start; }
}
.main-nav .nav-lg { font-style: normal; margin-left: 3px; }
@media (max-width: 759px) { .main-nav .nav-lg { display: none; } }

/* phones: the skip link gets its own row so Back / Next stay roomy */
@container sheet (max-width: 520px) {
  .nav-row:has(.skip-link) { flex-wrap: wrap; }
  .nav-row .skip-link { order: 3; flex-basis: 100%; text-align: center; padding: 4px 0 0; }
}

/* tablet/desktop: the menu floats at the top centre of the pinned river, always in reach */
@media (min-width: 760px) {
  .main-nav {
    position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 7; margin: 0; max-width: none; width: auto;
    display: flex; gap: 4px; padding: 4px; background: rgba(255, 255, 255, .94); border: 0; box-shadow: 0 8px 24px rgba(15, 10, 50, .3);
  }
  .main-nav button { flex-direction: row; gap: 6px; padding: 7px 14px; font-size: .86rem; }
  .main-nav button span { font-size: 1rem; }
  body.hero-open .main-nav { display: none; }
}


/* ---------- final polish ---------- */
/* companion: the card already chose Fan or My Own, so the in-panel switch is hidden (one tool set at a time) */
#compDoll > .modes { display: none; }
#compDoll > .doll-actions { grid-column: 1 / -1; }
/* pet: fortune + memory cards come after floating (result page, Explore, My Memories) */
#petCreator .pet-more { display: none; }
.pet-basic-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.pet-basic-actions .btn { min-height: 44px; }
.pet-adv { margin-top: 6px; padding-top: 4px; border-top: 1.5px dashed #f0dcea; animation: cardIn .3s ease; }
/* hero */
.hero-skip { position: absolute; top: calc(12px + env(safe-area-inset-top)); left: 12px; z-index: 2; border: 0; border-radius: 999px; padding: 8px 14px; min-height: 40px; background: rgba(255, 255, 255, .9); color: #51417e; font: 700 .82rem "Mali", sans-serif; cursor: pointer; }
.hero-resume { margin: 10px auto 0; max-width: 360px; font-size: .8rem; line-height: 1.5; color: #ffe1ef; }
/* back / skip row under a step */
.step-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.step.studio.editing .step-foot { display: none; }
/* touch targets */
.comp-card, .kt-tpl, .main-nav button, .hero-sec { min-height: 44px; }

/* KIKiie BUNNY CARES: shown in Explore only, so it never takes space from making the krathong */
body.nav-create #caresCard, body.nav-memories #caresCard { display: none; }
body.nav-explore #caresCard { margin-top: 0; }
.foot-cares { display: block; margin: 0 auto 6px; font-size: .78rem; color: #3f8a66; }
body.nav-explore .foot-cares { display: none; }
