:root {
  --bg: #f3f2ee;
  --surface: #ffffff;
  --line: #e2e0d9;
  --field: #ecebe6;
  --chip: #e8e6e0;
  --chip-ink: #3d3b37;
  --ink: #17171c;
  --ink-2: #55534d;
  --ink-3: #7b7870;
  --muted: #5f5f69;
  --placeholder: #757575;
  --dark: #2b2a28;
  --disabled: #d6d6cf;
  --radio: #767676;
  --dot: #aaa79e;
  --col: 480px;
  --r-lg: 16px;
  --r-xl: 24px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.4 6.6 11.4 12.5 4.8' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", "PingFang TC", system-ui, sans-serif;
  font-size: 16px;
  line-height: 27.2px;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.app { max-width: var(--col); margin: 0 auto; min-height: 100dvh; }

/* 卡片 */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  overflow: clip;
}

/* 封面 */
.cover { padding: 12px 16px 32px; }
.cover .card { border-radius: 28px; padding: 32px; display: flex; flex-direction: column; gap: 22px; }
.cover h1 { margin: 0; font-weight: 900; font-size: 34px; line-height: 40.8px; letter-spacing: -1.02px; display: flex; flex-direction: column; gap: 5px; }
.cover h1 span:last-child { color: var(--ink-3); }
.cover p { margin: 0; color: var(--muted); }
.btn-start {
  margin-top: 12px;
  display: flex; align-items: center; justify-content: space-between;
  min-height: 60px; padding: 14px 28px;
  border: 0; border-radius: 999px;
  background: var(--dark); color: #fff;
  font-weight: 900; font-size: 18px; line-height: 30.6px;
}
.btn-start img { width: 24px; height: 24px; }

/* 固定標題 */
.step-head { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 12px 16px; }
.step-head .card { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.step-title { display: flex; align-items: center; gap: 8px; }
.step-chip {
  display: inline-flex; align-items: center; height: 26px; padding: 5px 12px;
  border-radius: 999px; background: var(--chip); color: var(--chip-ink);
  font-weight: 700; font-size: 12px; line-height: 20.4px; letter-spacing: .24px;
}
.step-title h1 { margin: 0; font-weight: 900; font-size: 20px; line-height: 29px; letter-spacing: -.52px; }
.step-head.tight .step-title h1 { line-height: 24px; }  /* 設計稿 2/5、4/5、5/5 的標題列高 26 */
.step-head p { margin: 0; }

/* 內容 */
.content { padding: 0 16px 120px; display: flex; flex-direction: column; gap: 12px; }
.q { padding: 20px; }
.q-title { margin: 0; font-weight: 900; font-size: 19px; line-height: 28.5px; }
.q-title-row { display: flex; align-items: center; gap: 8px; padding-top: 6px; flex-wrap: wrap; }
.q-note { margin: 0; }
.fieldset { margin: 0; min-width: 0; }
.options { padding: 14px 0 8px; display: flex; flex-direction: column; gap: 8px; }
.options.spaced { padding-top: 22px; }

/* 選項列 */
.opt {
  display: flex; align-items: center; gap: 12px;
  min-height: 54px; padding: 12px 16px;
  background: var(--field); border: 1px solid transparent; border-radius: var(--r-lg);
  cursor: pointer;
}
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.box {
  flex: none; width: 20px; height: 20px; display: grid; place-items: center;
  background: #fff; border: 1px solid var(--dark); border-radius: 4px;
  color: #fff; font-weight: 900; font-size: 13px; line-height: 22.1px;
}
.opt input:checked + .box { background: var(--dark); border-radius: 6px; }
.opt input:checked + .box::after, .el[aria-pressed="true"] .box::after, .mood-badge::after {
  content: ""; display: block; width: 14px; height: 14px; background: var(--check) center / contain no-repeat;
}
.mood-badge::after { width: 11px; height: 11px; }
.radio { flex: none; width: 20px; height: 20px; background: #fff; border: 1px solid var(--radio); border-radius: 10px; display: grid; place-items: center; }
.opt input:checked + .radio { border-color: var(--dark); }
.opt input:checked + .radio::after { content: ""; width: 10px; height: 10px; border-radius: 5px; background: var(--dark); }
.opt input:focus-visible + span { outline: 2px solid var(--dark); outline-offset: 2px; }

/* 選「其他」「否」時展開的輸入框 */
.other-wrap { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows .32s var(--ease), opacity .2s, margin-top .32s var(--ease); }
.other-wrap.is-open { grid-template-rows: 1fr; opacity: 1; }
.other-inner { overflow: hidden; min-height: 0; }
.other-wrap .input { margin-top: 0; }
.options .other-wrap:not(.is-open) { margin-top: -8px; }

/* 輸入框 */
.input, .textarea {
  width: 100%;
  background: var(--field); border: 1px solid transparent; border-radius: var(--r-lg);
  padding: 14px 16px; outline: none;
}
.input { height: 57.2px; line-height: normal; }
.input::placeholder, .textarea::placeholder { color: var(--placeholder); }
.input:focus, .textarea:focus { border-color: var(--dark); background: #fff; }
.field-row { display: flex; gap: 8px; padding-top: 8px; }
.textarea { display: block; height: 138.8px; min-height: 110px; resize: none; }

/* 2/5 氛圍（互動不照設計稿：隨機順序、看完四組才能選） */
.mood { padding: 16px 0; }  /* 上下與左右（hint、track 的 16px）一致 */
.mood-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; }
.mood .hint { margin: 0; flex: 1; }
.mood-count { flex: none; transition: background-color .3s, color .3s; }
.mood.unlocked .mood-count { background: var(--dark); color: #fff; }
.mood-track {
  display: flex; gap: 8px; padding: 16px 16px 0;
  overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: 0 16px;
  scrollbar-width: none; overscroll-behavior-x: contain;
}
.mood-track::-webkit-scrollbar { display: none; }
.mood-card {
  position: relative; flex: 0 0 calc(100% - 32px); scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; flex-direction: column; gap: 12px; padding: 15px;  /* 加 1px 外框共 16px，同外層區塊 */
  border: 1px solid var(--line); border-radius: 18px; background: #fff;  /* 未選時同 4/5 視覺元素卡的外框 */
  text-align: left; opacity: .45;
}
.mood-card.is-current { opacity: 1; }
.mood-card[aria-pressed="true"] { background: var(--chip); border-color: var(--dark); box-shadow: inset 0 0 0 1px var(--dark); }
.mood-card { cursor: default; }
.mood-card:not(.is-current), .mood.unlocked .mood-card { cursor: pointer; }
.mood-badge {
  position: absolute; left: 20px; top: 20px; z-index: 2; width: 20px; height: 20px; border-radius: 10px;
  background: var(--dark); border: 1.5px solid #fff; display: grid; place-items: center;
  color: #fff; font-weight: 900; font-size: 13px; line-height: 1;
  opacity: 0; transform: scale(.4); transition: opacity .2s, transform .3s var(--ease);
}
.mood-card[aria-pressed="true"] .mood-badge { opacity: 1; transform: none; }
.mood-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.mood-tile { display: block; border-radius: 12px; overflow: hidden; background: var(--field); }
.mood-tile img {
  width: 100%; height: var(--tile-h, 150px); object-fit: cover;
  transition: opacity .7s ease var(--d), filter .7s ease var(--d), transform .8s var(--ease) var(--d);
}
/* 還沒看過的組先模糊，滑到時逐張變清楚 */
.mood-card:not(.is-seen) .mood-tile img { opacity: .35; filter: blur(10px); transform: scale(1.06); }
.mood-nav { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 14px 16px 0; }
.round-btn {
  flex: none; width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: #fff;
  display: grid; place-items: center; padding: 0;
}
.round-btn img { width: 20px; height: 20px; transition: opacity .2s; }
.round-btn:disabled { cursor: default; }
.round-btn:disabled img { opacity: .3; }
.dots { display: flex; gap: 10px; align-items: center; justify-content: center; }
.dot { width: 10px; height: 10px; padding: 0; border-radius: 5px; border: 1.5px solid var(--dot); background: transparent; transition: background-color .2s, border-color .2s, transform .3s var(--ease); }
.dot.seen { background: var(--dot); }
.dot.current { border-color: var(--ink); background: var(--ink); transform: scale(1.3); }

/* 3/5 已選氛圍 */
.picked {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: 0 8px 10px rgba(40, 36, 30, .08);
  padding: 10px 20px 12px; margin-right: 4px;
  position: sticky; z-index: 4;
}
.picked-head { display: flex; align-items: center; justify-content: space-between; font-size: 14px; line-height: 23.8px; }
.link-btn { border: 0; background: none; padding: 2px 0; font-family: "PingFang TC", "Noto Sans TC", sans-serif; font-weight: 600; font-size: 12px; line-height: 20.4px; text-decoration: underline; }
.picked-strip { display: flex; gap: 4px; padding-top: 6px; height: 50px; }
.strip-tile { flex: 1 1 0; min-width: 0; height: 100%; }
.picked-strip img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }
/* 進入 3/5 時，縮圖在框內逐格出現 */
.strip-tile { animation: strip-in .6s cubic-bezier(.22, .8, .24, 1) both; animation-delay: calc(.3s + var(--k) * 40ms); }
@keyframes strip-in {
  from { opacity: 0; transform: scale(.96); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: none; }
}

/* 形容詞 */
.count-chip { padding: 2px 10px; border-radius: 999px; background: var(--field); font-weight: 500; font-size: 12px; line-height: 20.4px; }
.adj-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding-top: 12px; }
.adj {
  min-height: 44px; padding: 4px; border: 1px solid var(--line); border-radius: 14px; background: #fff;
  font-weight: 700; font-size: 16px; line-height: 22px; text-align: center; overflow-wrap: anywhere;
}
.adj[aria-pressed="true"] { background: var(--dark); border-color: var(--dark); color: #fff; }
.adj.custom { line-height: normal; }
.adj.wide { grid-column: span 2; }
.adj[aria-disabled="true"] { cursor: default; }
.btn-add {
  flex: none; min-height: 48px; padding: 10px 18px; border-radius: 14px;
  border: 1px solid var(--ink); background: #fff; font-weight: 900;
}
.btn-add:disabled { opacity: .35; cursor: default; }

/* 4/5 視覺元素 */
.el-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; padding-top: 14px; }
.el {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 10px 12px; border: 1px solid var(--line); border-radius: 18px; background: #fff;
  font-weight: 900; text-align: center;
}
.el[aria-pressed="true"] { background: var(--chip); border-color: var(--dark); box-shadow: inset 0 0 0 1px var(--dark); }
.el .box { position: absolute; left: 11px; top: 11px; border-color: var(--line); }
.el[aria-pressed="true"] .box { background: var(--dark); border-color: var(--dark); border-radius: 6px; }
.el-visual { width: 72px; height: 72px; display: grid; place-items: center; }
.el-visual img { width: 100%; height: 100%; object-fit: contain; }
.el-visual.wide { width: 79px; }
.el-visual.wide img { object-fit: cover; }
.el-visual.rose { position: relative; overflow: hidden; }
.el-visual.rose img { position: absolute; left: 16.62%; top: .18%; width: 66.76%; height: 113.8%; max-width: none; object-fit: fill; }
.swatch { width: 60px; height: 60px; border-radius: 30px; }

/* 底部按鈕列 */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(243, 242, 238, 0), var(--bg) 30%);
}
.bar-inner {
  max-width: calc(var(--col) - 32px); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 999px;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .06));
}
.btn {
  min-height: 48px; padding: 10px 22px; border-radius: 999px; font-weight: 900; text-align: center;
  border: 1px solid var(--line); background: #fff;
}
.btn-primary { background: var(--dark); border-color: var(--dark); color: #fff; width: 220px; max-width: 220px; }
.btn-primary.full { width: auto; max-width: none; flex: 1; }
.btn-primary:disabled { background: var(--disabled); border-color: var(--disabled); cursor: default; }
.bar-msg { max-width: calc(var(--col) - 32px); margin: 0 auto 8px; padding: 8px 16px; border-radius: 12px; background: #fff; border: 1px solid #d7141f; color: #b0101a; font-size: 14px; line-height: 23.8px; }

/* 感謝頁 */
.thanks { padding: 12px 16px 120px; display: flex; flex-direction: column; gap: 12px; }
.thanks-title { padding: 16px; }
.btn-restart { width: 100%; animation: fade .4s ease-out 1.3s both; }
.thanks-title h1 { margin: 0; font-weight: 900; font-size: 20px; line-height: normal; letter-spacing: -.52px; }
.result { padding: 22px; }
.result-lead { margin: 0; color: var(--muted); font-size: 14px; line-height: 23.8px; }
.result-words { display: flex; flex-wrap: wrap; column-gap: 14px; padding-top: 6px; }
.result-words span { font-weight: 900; font-size: 35.37px; line-height: 40.675px; color: var(--ink-2); }
.result-words span:first-child { color: var(--ink); }
.result-sub { margin: 16px 0 8px; padding: 6px 0; font-weight: 900; font-size: 13px; line-height: 22.1px; letter-spacing: 1.04px; color: var(--muted); }
.result-mood { display: grid; grid-template-columns: 2fr 1fr; grid-template-rows: repeat(3, 1fr); gap: 6px; aspect-ratio: 315 / 273; }
.result-mood img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; background: var(--field); min-height: 0; }
.result-mood img:first-child { grid-row: 1 / span 3; }
.result-els { display: flex; flex-wrap: wrap; gap: 8px; }
.el-chip { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 5px 14px 5px 6px; border-radius: 999px; background: var(--field); font-weight: 900; font-size: 14px; line-height: 23.8px; }
.el-chip img { width: 28px; height: 28px; object-fit: contain; }
.el-chip .swatch { width: 22px; height: 22px; margin: 3px; }

/* ---------- 瀏覽器原生表面 ---------- */
::selection { background: var(--dark); color: #fff; }
input, textarea { caret-color: var(--dark); }
:focus-visible { outline: 2px solid var(--dark); outline-offset: 2px; }
.input:focus-visible, .textarea:focus-visible { outline: none; }
.opt:has(input:focus-visible) { outline: 2px solid var(--dark); outline-offset: 2px; }
.opt input:focus-visible + span { outline: none; }

/* ---------- 微互動 ---------- */
.btn, .btn-start, .btn-add, .round-btn, .adj, .el, .opt, .mood-card, .link-btn, .input, .textarea {
  transition: transform .14s var(--ease), background-color .2s, border-color .2s, color .2s, box-shadow .2s, opacity .3s;
}
.btn:not(:disabled):active, .btn-start:active, .btn-add:not(:disabled):active, .round-btn:not(:disabled):active, .adj:not([aria-disabled="true"]):active, .el:active { transform: scale(.97); }
.opt:active { transform: scale(.99); }
.btn-start img { transition: transform .3s var(--ease); }
@media (hover: hover) {
  .btn-start:hover img { transform: translateX(4px); }
  .opt:hover { background: #e6e5df; }
  .adj:not([aria-pressed="true"]):not([aria-disabled="true"]):hover, .el:not([aria-pressed="true"]):hover { border-color: #c9c6bd; }
  .btn:not(.btn-primary):hover, .round-btn:not(:disabled):hover, .btn-add:not(:disabled):hover { background: #f7f6f3; }
  .btn-primary:not(:disabled):hover, .btn-start:hover { background: #3a3936; }
}
.opt input:checked + .box::after, .el[aria-pressed="true"] .box::after { animation: tick .22s var(--ease) both; }
.opt input:checked + .radio::after { animation: tick .22s var(--ease) both; }
.tap { animation: tap .26s var(--ease); }
.chip-in { animation: chip-in .32s var(--ease) both; }
.nudge { animation: nudge .42s ease-out; }
.bump { animation: bump .5s var(--ease); }
.mood-card.picked { animation: tap-soft .3s var(--ease); }
@keyframes tap-soft { 0% { transform: scale(.985); } 100% { transform: none; } }

.bar-msg.pop-in { animation: rise .3s var(--ease) both; }
.btn-primary.is-loading { animation: breathe 1.1s ease-in-out infinite; }

@keyframes tick { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: none; } }
@keyframes tap { 0% { transform: scale(.95); } 100% { transform: none; } }
@keyframes chip-in { from { opacity: 0; transform: scale(.82); } to { opacity: 1; transform: none; } }
@keyframes nudge {
  0%, 100% { transform: none; }
  20% { transform: translateX(-4px); background: var(--dark); color: #fff; }
  40% { transform: translateX(4px); background: var(--dark); color: #fff; }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .72; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 換頁過場 ---------- */
.step-head { view-transition-name: step-head; }
.step-body { view-transition-name: step-body; }
.bar { view-transition-name: step-bar; }
::view-transition-group(*) { animation-duration: .32s; animation-timing-function: var(--ease); }
/* 內容區塊不做位置與大小的過渡，只淡出、再淡入並微微上移，避免斜向移動 */
::view-transition-group(step-body) { animation: none; }
::view-transition-group(step-bar), ::view-transition-group(step-head) { animation: none; }
::view-transition-old(step-bar), ::view-transition-old(step-head) { animation: .12s ease-in both vt-out; }
::view-transition-new(step-bar), ::view-transition-new(step-head) { animation: .2s ease-out both fade; }
::view-transition-old(step-body) { animation: .16s ease-in both vt-out; }
::view-transition-new(step-body) { animation: .38s var(--ease) .06s both vt-in; }
.enter-fwd, .enter-back { animation: .38s var(--ease) both vt-in; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- 感謝頁揭示 ---------- */
.thanks-title { animation: drop .5s var(--ease) both; }
.result { animation: drop .5s var(--ease) .08s both; }
.result-words span { animation: word-in .7s var(--ease) both; animation-delay: calc(.3s + var(--i) * 90ms); }
.result-sub { animation: fade .4s ease-out .55s both; }
.result-mood img { animation: unveil .8s var(--ease) both; animation-delay: calc(.6s + var(--i) * 80ms); }
.el-chip { animation: drop .45s var(--ease) both; animation-delay: calc(1s + var(--i) * 60ms); }
@keyframes word-in { from { opacity: 0; transform: translateY(-14px); filter: blur(8px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes unveil { from { clip-path: inset(0 0 100% 0 round 12px); } to { clip-path: inset(0 0 0 0 round 12px); } }

/* ---------- 減少動態 ---------- */
@media (prefers-reduced-motion: reduce) {
  .enter-fwd, .enter-back, .thanks-title, .result, .result-words span, .result-mood img, .el-chip, .bar-msg.pop-in, .chip-in { animation-name: fade !important; }
  .strip-tile { animation-name: fade !important; }
  .tap, .nudge, .bump, .mood-card.picked, .btn-primary.is-loading { animation: none !important; }
  .mood-card:not(.is-seen) .mood-tile img { filter: none; transform: none; }
  * { transition-duration: .01ms !important; }
  .btn:active, .btn-start:active, .btn-add:active, .round-btn:active, .adj:active, .el:active, .opt:active { transform: none !important; }
}
