/* GOGO記帳 原型 — shell styles (index.html + js/ui/*). PLAN §1.7 / §2.2.
   Fixed light theme on purpose: the page simulates the LINE app, not a themed site. */

:root {
  color-scheme: light;
  --ink: #2F3B26;
  --ink-soft: #5C6650;
  --muted: #7A7F70;
  --honey: #FFD66B;
  --honey-deep: #FFC23D;
  --sky: #7FCDF2;
  --sky-deep: #5FB8EE;
  --coral: #FF6F59;
  --ok: #3E9B5A;
  --danger: #D9534F;
  --cream: #FFF6E6;
  --paper: #FFFDF7;
  --line-dash: #ECE3CF;

  --chat-bg: #8DABD8;
  --bubble-me: #8DE055;
  --bubble-bot: #FFFFFF;
  --meta: rgba(24, 38, 66, .62);
  --send: #06C755;

  --font: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", sans-serif;
  --round: ui-rounded, "SF Pro Rounded", -apple-system, "PingFang TC", "Noto Sans TC", sans-serif;
  --spring: cubic-bezier(.22, 1.35, .45, 1);
  --ease-out: cubic-bezier(.2, .9, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: #111;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 214, 107, .35) 0 160px, transparent 161px),
    radial-gradient(circle at 88% 82%, rgba(127, 205, 242, .30) 0 200px, transparent 201px),
    #FBF3E2;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
button:focus-visible { outline: 3px solid #3A7BD5; outline-offset: 2px; }
.cm-input:focus, .cm-input:focus-visible { outline: none; }
[hidden] { display: none !important; }

/* ───────────────────────── stage + phone frame ───────────────────────── */

.stage {
  height: 100%;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 56px;
  padding: 24px;
}

.stage-note {
  width: 280px;
  color: var(--ink);
  display: none;
}
.stage-note .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.stage-note .brand-badge {
  width: 52px; height: 52px; border-radius: 16px; background: var(--honey);
  border: 2.5px solid var(--ink); box-shadow: 0 4px 0 var(--ink);
  display: grid; place-items: center; font-size: 28px;
}
.stage-note h1 { font-size: 24px; margin: 0; letter-spacing: .02em; }
.stage-note .tag { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.stage-note ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; counter-reset: tip; }
.stage-note li {
  counter-increment: tip; position: relative; padding: 10px 12px 10px 42px; background: #fff;
  border: 2px solid var(--ink); border-radius: 14px; box-shadow: 0 3px 0 var(--ink); font-size: 14px; line-height: 1.45;
}
.stage-note li::before {
  content: counter(tip); position: absolute; left: 10px; top: 9px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--honey); border: 2px solid var(--ink); font-size: 12px; font-weight: 800; display: grid; place-items: center;
}
.stage-note kbd {
  font-family: var(--font); font-size: 13px; background: var(--cream); border: 1.5px solid var(--ink);
  border-radius: 6px; padding: 0 5px; white-space: nowrap;
}
.stage-note .fine { margin-top: 16px; font-size: 12px; color: var(--muted); line-height: 1.5; }
@media (min-width: 900px) and (min-height: 640px) { .stage-note { display: block; } }

.phone {
  position: relative;
  width: 390px;
  height: min(844px, calc(100dvh - 48px));
  min-height: 560px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 11px solid #16181B;
  border-radius: 56px;
  overflow: hidden;
  box-shadow:
    0 0 0 2px #3B3F45,
    0 30px 60px -12px rgba(47, 59, 38, .38),
    0 18px 36px -18px rgba(0, 0, 0, .45);
  isolation: isolate;
  padding-bottom: 22px; /* home-indicator zone in the desktop frame */
}

.statusbar {
  flex: none;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px 0 36px;
  font: 600 15px/1 var(--round);
  color: #111;
  background: #fff;
  position: relative;
}
.statusbar .island {
  position: absolute; left: 50%; top: 9px; width: 118px; height: 33px; margin-left: -59px;
  background: #0B0B0C; border-radius: 20px;
}
.statusbar .sb-icons { display: flex; align-items: center; gap: 6px; }
.statusbar svg { display: block; }
.home-indicator {
  position: absolute; left: 50%; bottom: 7px; width: 134px; height: 5px; margin-left: -67px;
  border-radius: 3px; background: #111; z-index: 60; pointer-events: none;
}

/* Real phones: full-bleed, no fake frame. */
@media (max-width: 519px) {
  body { background: #fff; }
  .stage { padding: 0; display: block; min-height: 0; }
  .phone {
    width: 100%;
    height: var(--app-h, 100dvh);
    min-height: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .statusbar, .home-indicator { display: none; }
  .ch { padding-top: env(safe-area-inset-top, 0px); height: calc(52px + env(safe-area-inset-top, 0px)); }
}
/* Short desktop windows: shrink the frame instead of clipping. */
@media (min-width: 520px) and (max-height: 700px) {
  .phone { height: calc(100dvh - 24px); min-height: 0; border-radius: 44px; }
  .stage { padding: 12px; }
}

.boot {
  flex: 1; display: grid; place-items: center; background: var(--chat-bg);
  color: #fff; font-weight: 700; letter-spacing: .04em;
}
.boot span { animation: bootPulse 1.2s ease-in-out infinite; }
@keyframes bootPulse { 50% { opacity: .45; } }

/* ───────────────────────── chat shell ───────────────────────── */

.chat {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
}

.ch {
  flex: none;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 6px;
  background: #fff;
  border-bottom: 1px solid #E7E9EE;
  position: relative;
  z-index: 5;
}
.ch-btn {
  width: 42px; height: 42px; flex: none; border: 0; background: transparent; border-radius: 50%;
  display: grid; place-items: center; color: #1E2128; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background .15s, transform .15s var(--spring);
}
.ch-btn:active { background: #F0F2F5; transform: scale(.92); }
.ch-btn .ic svg { width: 24px; height: 24px; display: block; }
.ch-demo .ic svg { width: 23px; height: 23px; }
.ch-demo:active .ic { transform: rotate(60deg); }
.ch-demo .ic { display: block; transition: transform .35s var(--spring); }
.ch-title {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; border: 0; background: transparent;
  padding: 4px 6px; border-radius: 12px; cursor: pointer; text-align: left; -webkit-tap-highlight-color: transparent;
  transition: background .15s;
}
.ch-title:active { background: #F3F4F7; }
.ch-ava { flex: none; display: flex; }
.ch-text { min-width: 0; display: flex; flex-direction: column; }
.ch-name { font-size: 16.5px; font-weight: 700; color: #111; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-sub { font-size: 11px; color: #8A909C; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.ch-caret { color: #9AA0AA; flex: none; }
.ch-caret svg { width: 14px; height: 14px; display: block; }

/* avatars */
.ava {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: 19px; line-height: 1; background: #D9DEE7; overflow: hidden; user-select: none;
}
.ava.is-bot { background: var(--cream); box-shadow: inset 0 0 0 1.5px rgba(47, 59, 38, .25); }
.ava.is-bot svg { width: 92%; height: 92%; margin-top: 6%; display: block; }
.ava-sm { width: 32px; height: 32px; font-size: 17px; }
.ava-xs { width: 28px; height: 28px; font-size: 15px; }
.ava-md { width: 40px; height: 40px; font-size: 21px; }
.ava-stack { display: flex; }
.ava-stack .ava { width: 26px; height: 26px; font-size: 14px; box-shadow: 0 0 0 2px #fff; }
.ava-stack .ava + .ava { margin-left: -9px; }

/* scroller */
.chat-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 4px 10px 14px;
  container-type: inline-size;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .45) transparent;
}
.chat-list.is-switch { animation: listIn .28s var(--ease-out); }
@keyframes listIn { from { opacity: 0; transform: translateY(6px); } }

.day-sep { display: flex; justify-content: center; margin: 14px 0 6px; }
.day-sep span {
  font-size: 11.5px; color: #fff; background: rgba(54, 74, 112, .38); padding: 3px 11px;
  border-radius: 999px; letter-spacing: .02em;
}

.row { display: flex; align-items: flex-start; gap: 8px; margin-top: 4px; }
.row.is-first { margin-top: 12px; }
.row-avatar { width: 36px; flex: none; }
.row-main { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; max-width: calc(100% - 44px); }
.row-name { font-size: 12px; color: rgba(20, 32, 58, .78); margin: 0 0 3px 3px; }
.row-line { display: flex; align-items: flex-end; gap: 5px; max-width: 100%; }
.row-meta {
  flex: none; display: flex; flex-direction: column; align-items: flex-start; font-size: 10.5px;
  line-height: 1.25; color: var(--meta); padding-bottom: 1px; white-space: nowrap;
}
.row-read { color: var(--meta); }

.row.from-me { justify-content: flex-end; }
.row.from-me .row-main { align-items: flex-end; max-width: 80%; }
.row.from-me .row-line { flex-direction: row-reverse; }
.row.from-me .row-meta { align-items: flex-end; }

.row.sys { justify-content: center; margin: 10px 0; }
.msg-system {
  max-width: 82%; font-size: 12px; line-height: 1.45; color: #fff; text-align: center;
  background: rgba(54, 74, 112, .42); padding: 5px 12px; border-radius: 12px; white-space: pre-wrap;
}

.msg-text {
  position: relative;
  background: var(--bubble-bot);
  color: #111;
  font-size: 15px;
  line-height: 1.45;
  padding: 8px 12px;
  border-radius: 18px;
  max-width: min(268px, calc(100cqw - 108px));
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
}
.from-me .msg-text { background: var(--bubble-me); }
.row.is-first:not(.from-me) .msg-text { border-top-left-radius: 6px; }
.row.is-first.from-me .msg-text { border-top-right-radius: 6px; }
.row.is-first:not(.from-me) .msg-text::before,
.row.is-first.from-me .msg-text::before {
  content: ""; position: absolute; top: 0; width: 10px; height: 12px; background: inherit;
}
.row.is-first:not(.from-me) .msg-text::before { left: -6px; clip-path: polygon(0 0, 100% 0, 100% 100%); border-top-left-radius: 3px; }
.row.is-first.from-me .msg-text::before { right: -6px; clip-path: polygon(0 0, 100% 0, 0 100%); border-top-right-radius: 3px; }

.msg-image { border-radius: 16px; overflow: hidden; max-width: 210px; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.msg-image img { display: block; width: 100%; height: auto; }
.msg-image.is-missing { padding: 18px; font-size: 13px; color: var(--muted); }

/* typing … */
.typing { display: inline-flex; gap: 4px; align-items: center; padding: 12px 14px; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%; background: #A8AFBC; display: block;
  animation: dot 1.1s ease-in-out infinite;
}
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { transform: translateY(0); opacity: .55; } 30% { transform: translateY(-5px); opacity: 1; } }

/* message entrance */
.row.enter { animation: msgIn .4s var(--spring) both; transform-origin: 0 100%; }
.row.from-me.enter { transform-origin: 100% 100%; animation-name: msgInMe; }
.row.sys.enter { animation: fadeIn .3s ease both; }
@keyframes msgIn { from { opacity: 0; transform: translate(-4px, 10px) scale(.92); } }
@keyframes msgInMe { from { opacity: 0; transform: translate(6px, 8px) scale(.9); } }
@keyframes fadeIn { from { opacity: 0; } }
.row.enter .fx-body > .fx-block { animation: blockIn .42s var(--ease-out) both; }
.row.enter .fx-body > .fx-block:nth-child(1) { animation-delay: .06s; }
.row.enter .fx-body > .fx-block:nth-child(2) { animation-delay: .1s; }
.row.enter .fx-body > .fx-block:nth-child(3) { animation-delay: .14s; }
.row.enter .fx-body > .fx-block:nth-child(4) { animation-delay: .18s; }
.row.enter .fx-body > .fx-block:nth-child(5) { animation-delay: .22s; }
.row.enter .fx-body > .fx-block:nth-child(6) { animation-delay: .26s; }
.row.enter .fx-body > .fx-block:nth-child(n+7) { animation-delay: .3s; }
.row.enter .fx-foot { animation: blockIn .42s var(--ease-out) .2s both; }
.row.enter .fx-track > .fx-bubble { animation: slideIn .5s var(--spring) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes blockIn { from { opacity: 0; transform: translateY(6px); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(28px) scale(.96); } }

/* ───────────────────────── toast + quick replies + composer ───────────────────────── */

.toast-layer {
  position: absolute; left: 0; right: 0; top: 62px; z-index: 20; display: flex; flex-direction: column;
  align-items: center; gap: 6px; pointer-events: none;
}
.toast {
  max-width: 86%; background: rgba(28, 33, 42, .9); color: #fff; font-size: 13px; padding: 8px 14px;
  border-radius: 999px; opacity: 0; transform: translateY(-8px) scale(.96); transition: opacity .22s, transform .3s var(--spring);
  text-align: center;
}
.toast.is-on { opacity: 1; transform: none; }
@media (max-width: 519px) { .toast-layer { top: calc(62px + env(safe-area-inset-top, 0px)); } }

.qr-bar { flex: none; background: var(--chat-bg); padding: 2px 0 9px; }
.qr-track {
  display: flex; gap: 7px; overflow-x: auto; padding: 4px 10px 4px; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; scroll-padding: 10px;
}
.qr-track::-webkit-scrollbar { display: none; }
.qr {
  flex: none; border: 2px solid var(--ink); background: #fff; color: var(--ink); font-size: 14px; font-weight: 700;
  padding: 7px 14px; border-radius: 999px; box-shadow: 0 2.5px 0 var(--ink); cursor: pointer; white-space: nowrap;
  -webkit-tap-highlight-color: transparent; transition: transform .1s, box-shadow .1s;
}
.qr:active { transform: translateY(2.5px); box-shadow: 0 0 0 var(--ink); }
.qr-bar.is-on .qr { animation: qrIn .36s var(--spring) both; animation-delay: calc(var(--i) * 35ms); }
@keyframes qrIn { from { opacity: 0; transform: translateY(10px) scale(.9); } }

.cm {
  flex: none; display: flex; align-items: flex-end; gap: 4px; padding: 7px 8px; background: #fff;
  border-top: 1px solid #E7E9EE; position: relative; z-index: 4;
}
.cm-btn {
  width: 40px; height: 40px; flex: none; border: 0; background: transparent; border-radius: 50%;
  display: grid; place-items: center; color: #5B6270; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: color .15s, background .15s, transform .15s var(--spring);
}
.cm-btn:active { transform: scale(.88); background: #F1F3F6; }
.cm-btn .ic svg { width: 24px; height: 24px; display: block; }
.cm-menu.is-open { color: var(--ink); }
.cm-field {
  flex: 1; min-width: 0; background: #F2F3F5; border-radius: 20px; padding: 0 14px; display: flex; align-items: center;
  min-height: 40px; transition: background .2s, box-shadow .2s; cursor: text;
}
.cm-field:focus-within { background: #EEF0F3; box-shadow: inset 0 0 0 1.5px #C9CED8; }
.cm-input {
  display: block; width: 100%; border: 0; background: transparent; resize: none; outline: none;
  font: 16px/1.35 var(--font); color: #111; padding: 9px 0; max-height: 104px; height: 40px;
}
.cm-input::placeholder { color: #A1A7B2; }
.cm-send { color: #BAC0CA; }
.cm-send.is-ready { color: var(--send); }
.cm-send.is-fly .ic { animation: fly .42s var(--ease-out); }
@keyframes fly { 40% { transform: translate(6px, -6px) rotate(-12deg) scale(.85); opacity: .4; } 41% { transform: translate(-8px, 8px); opacity: 0; } 100% { transform: none; opacity: 1; } }

.cm-sender {
  flex: none; height: 40px; border: 0; background: transparent; padding: 0 2px; display: flex; align-items: center;
  position: relative; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.cm-sender-face { display: flex; transition: transform .2s var(--spring); }
.cm-sender-face .ava { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--ink); }
.cm-sender-face.is-swap { animation: swapIn .45s var(--spring); }
@keyframes swapIn { 0% { transform: rotateY(90deg) scale(.7); } 100% { transform: none; } }
.cm-sender-swap {
  position: absolute; right: -2px; bottom: 2px; width: 15px; height: 15px; border-radius: 50%; background: var(--honey);
  border: 1.5px solid var(--ink); display: grid; place-items: center; color: var(--ink);
}
.cm-sender-swap svg { width: 10px; height: 10px; display: block; }
.cm.as-friend .cm-field { background: #FFF1D6; box-shadow: inset 0 0 0 1.5px rgba(201, 130, 47, .55); }

/* ───────────────────────── rich menu ───────────────────────── */

.rm { flex: none; background: #fff; position: relative; z-index: 3; }
.rm.is-hidden { display: none; }
.rm-panel { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .34s var(--ease-out); }
.rm.is-collapsed .rm-panel { grid-template-rows: 0fr; }
.rm-clip { overflow: hidden; min-height: 0; }
.rm-stage { position: relative; width: 100%; aspect-ratio: 800 / 540; overflow: hidden; background: var(--cream); }
.rm-host { position: absolute; left: 0; top: 0; width: 800px; height: 540px; transform-origin: 0 0; }
.rm-bar {
  display: flex; width: 100%; height: 36px; align-items: center; justify-content: center; gap: 4px; border: 0;
  border-top: 1px solid #E7E9EE; background: #fff; color: #3A3F48; font-size: 13.5px; font-weight: 600; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.rm-bar:active { background: #F5F6F8; }
.rm-bar-icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .3s var(--spring); }
.rm.is-collapsed .rm-bar-icon { transform: rotate(180deg); }

/* fallback grid (only if Shadow DOM is unavailable) */
.rm-fallback { position: absolute; inset: 0; background: var(--cream); font-family: var(--round); }
.rm-fallback.th-travel { background: #EEF8FD; }
.rm-fallback button { position: absolute; border: 0; background: transparent; cursor: pointer; font-size: 30px; font-weight: 800; color: var(--ink); padding: 10px; }
.rm-fb-tab { background: var(--honey) !important; }
.th-travel .rm-fb-tab { background: var(--sky) !important; }
.rm-fb-tab.is-active { text-decoration: underline; text-underline-offset: 8px; }
.rm-fb-tab.is-mode { color: #fff !important; background: var(--coral) !important; }
.rm-fb-cell::after {
  content: ""; position: absolute; inset: 10px; border: 3px solid var(--ink); border-radius: 26px; background: #fff;
  box-shadow: 0 6px 0 var(--ink); z-index: -1;
}

/* ───────────────────────── sheets (thread switcher, sender, demo panel) ───────────────────────── */

.overlay-layer { position: absolute; inset: 0; z-index: 50; pointer-events: none; }
.overlay-layer.has-sheet { pointer-events: auto; }
.sheet-backdrop {
  position: absolute; inset: 0; background: rgba(18, 22, 30, .42); opacity: 0; transition: opacity .25s ease;
}
.sheet-backdrop.is-on { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 80%; overflow-y: auto; overscroll-behavior: contain;
  background: #fff; border-radius: 22px 22px 0 0; padding: 6px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  transform: translateY(104%); transition: transform .34s var(--ease-out); box-shadow: 0 -10px 30px rgba(0, 0, 0, .12);
}
.sheet.is-on { transform: none; }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: #D9DCE2; margin: 4px auto 10px; }
.sheet-title { font-size: 17px; font-weight: 800; color: var(--ink); padding: 0 6px; }
.sheet-sub { font-size: 12.5px; color: var(--muted); padding: 3px 6px 0; }
.sheet-list { display: flex; flex-direction: column; gap: 4px; margin: 12px 0 10px; }
.sheet-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 10px; border-radius: 14px; cursor: pointer; transition: background .15s, transform .15s var(--spring);
  -webkit-tap-highlight-color: transparent;
}
.sheet.is-on .sheet-item { animation: blockIn .34s var(--ease-out) both; animation-delay: calc(var(--i) * 30ms + 60ms); }
.sheet-item:active { transform: scale(.98); background: #F0F2F5; }
.sheet-item:disabled { opacity: .45; cursor: default; }
.sheet-item.is-selected { background: var(--cream); }
.sheet-item.is-danger .sheet-label { color: var(--danger); }
.sheet-emoji {
  width: 40px; height: 40px; border-radius: 12px; background: var(--cream); border: 1.5px solid rgba(47, 59, 38, .25);
  display: grid; place-items: center; font-size: 20px; flex: none;
}
.sheet-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sheet-label { font-size: 15px; font-weight: 700; color: #16181D; }
.sheet-item-sub { font-size: 12.5px; color: #8A909C; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.sheet-meta { font-size: 11px; color: #A0A6B0; flex: none; }
.sheet-check { color: var(--ok); font-weight: 800; font-size: 16px; flex: none; }
.sheet-cancel {
  width: 100%; border: 2px solid var(--ink); background: #fff; border-radius: 14px; padding: 11px; font-size: 15px;
  font-weight: 800; color: var(--ink); box-shadow: 0 3px 0 var(--ink); cursor: pointer; transition: transform .1s, box-shadow .1s;
}
.sheet-cancel:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }

/* ───────────────────────── Flex-like cards (cards.js) ───────────────────────── */

.fx-bubble {
  --accent: var(--honey);
  --accent-deep: var(--honey-deep);
  width: min(292px, calc(100cqw - 96px));
  max-width: 100%;
  background: #fff;
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--ink);
  overflow: hidden;
  font-size: 14px;
  line-height: 1.45;
  margin-bottom: 4px;
}
.fx-bubble.th-travel { --accent: var(--sky); --accent-deep: var(--sky-deep); }
.fx-bubble.th-ok { --accent: #A8DDB0; --accent-deep: #7CC67A; }
.fx-bubble.th-warn { --accent: #FF9C8A; --accent-deep: var(--coral); }

.fx-head { display: flex; align-items: center; gap: 9px; padding: 11px 14px; background: var(--accent); border-bottom: 2px solid var(--ink); }
.th-plain .fx-head { background: var(--cream); }
.fx-head-emoji { font-size: 22px; line-height: 1; flex: none; }
.fx-head-text { min-width: 0; }
.fx-head-title { font-size: 15.5px; font-weight: 800; letter-spacing: .01em; }
.fx-head-sub { font-size: 12px; opacity: .78; margin-top: 1px; }

.fx-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.fx-body:empty { display: none; }

.fx-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.fx-text.sz-xs { font-size: 11.5px; }
.fx-text.sz-sm { font-size: 13px; }
.fx-text.sz-md { font-size: 14.5px; }
.fx-text.sz-lg { font-size: 17px; }
.fx-text.sz-xl { font-size: 21px; }
.fx-text.is-bold { font-weight: 800; }
.al-start { text-align: left; } .al-center { text-align: center; } .al-end { text-align: right; }
.c-muted { color: var(--muted) !important; }
.c-accent { color: #D9612F !important; }
.c-ok { color: var(--ok) !important; }
.c-danger { color: var(--danger) !important; }

.fx-amount { display: flex; flex-direction: column; gap: 1px; }
.fx-amount-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.fx-amount-value {
  font: 800 30px/1.15 var(--round); letter-spacing: -.01em; font-variant-numeric: tabular-nums; color: inherit;
}
.fx-amount-sub { font-size: 13px; color: var(--muted); }

.fx-kv { display: flex; flex-direction: column; gap: 6px; }
.fx-kv-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.fx-kv-k { color: var(--muted); font-size: 13px; flex: none; }
.fx-kv-v { font-weight: 700; text-align: right; min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
button.fx-kv-row {
  border: 0; background: transparent; width: 100%; padding: 4px 6px; margin: -4px -6px; width: calc(100% + 12px);
  border-radius: 8px; cursor: pointer; align-items: center; text-align: left;
}
button.fx-kv-row .fx-kv-v { flex: 1; }
.fx-chev { color: var(--muted); flex: none; }

.fx-sep { border: 0; border-top: 1.5px dashed var(--line-dash); margin: 0; }

.fx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fx-chip {
  border: 1.5px solid var(--ink); background: #fff; color: var(--ink); font-size: 13px; font-weight: 700;
  padding: 5px 10px; border-radius: 999px; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background .15s, transform .12s var(--spring), box-shadow .12s;
}
.fx-chip.is-pressed { transform: scale(.94); }
.fx-chip.is-selected { background: var(--accent); box-shadow: 0 2px 0 var(--ink); }

.fx-progress-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 5px; }
.fx-progress-label { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.fx-progress-pct { flex: none; }
.fx-progress-pct { font-weight: 800; font-variant-numeric: tabular-nums; }
.fx-progress-track { height: 12px; border-radius: 999px; background: #F3EDDF; border: 1.5px solid var(--ink); overflow: hidden; }
.fx-progress-fill {
  height: 100%; border-radius: 999px; background: #7CC67A; transition: width 1s var(--ease-out);
  background-image: linear-gradient(90deg, rgba(255, 255, 255, .0), rgba(255, 255, 255, .35) 50%, rgba(255, 255, 255, 0));
  background-size: 200% 100%; animation: shimmer 2.4s linear infinite;
}
.lv-ok .fx-progress-fill { background-color: #7CC67A; }
.lv-warn .fx-progress-fill { background-color: var(--honey-deep); }
.lv-over .fx-progress-fill { background-color: var(--coral); }
.lv-warn .fx-progress-pct { color: #B7791F; }
.lv-over .fx-progress-pct { color: var(--danger); }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }

.fx-list { display: flex; flex-direction: column; }
.fx-li {
  display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line-dash);
  text-align: left; width: 100%;
}
.fx-li:last-child { border-bottom: 0; padding-bottom: 0; }
.fx-li:first-child { padding-top: 0; }
button.fx-li { border: 0; border-bottom: 1px dashed var(--line-dash); background: transparent; cursor: pointer; }
button.fx-li:last-child { border-bottom: 0; }
.fx-li.is-action { cursor: pointer; border-radius: 8px; transition: background .15s; }
.fx-li.is-action.is-pressed { background: #F6EEDA; }
.fx-li-icon {
  width: 32px; height: 32px; border-radius: 50%; background: var(--cream); display: grid; place-items: center;
  font-size: 16px; flex: none; border: 1.5px solid rgba(47, 59, 38, .18);
}
.fx-li-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fx-li-title { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fx-li-sub { font-size: 12px; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.fx-li-right { font-weight: 800; font-variant-numeric: tabular-nums; flex: none; font-size: 14px; }
.fx-li-main { min-width: 3.5em; }
.fx-li-end { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.fx-li-end .fx-li-right { font-size: 13.5px; }

/* 所有列共用同一組欄寬（.fx-bar 用 display:contents），軌道長度才能跨列比較 */
.fx-bars { display: grid; grid-template-columns: fit-content(8em) minmax(36px, 1fr) auto; align-items: center; gap: 7px 8px; }
.fx-bar { display: contents; }
.fx-bar-label { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fx-bar-track { height: 12px; background: #F4EFE3; border-radius: 999px; overflow: hidden; display: block; }
.fx-bar-fill { display: block; height: 100%; border-radius: 999px; transition: width .9s var(--ease-out); }
.fx-bar-val { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

.fx-donut { display: flex; align-items: center; gap: 12px; container: fxdonut / inline-size; }
.fx-donut-chart { position: relative; width: 124px; height: 124px; flex: none; }
.fx-donut-chart svg { width: 100%; height: 100%; display: block; }
.fx-donut-seg { transition: stroke-dasharray .95s var(--ease-out); }
.fx-donut-center {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 28px;
  font: 800 13px/1.2 var(--round); white-space: pre-line;
}
.fx-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.fx-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.fx-legend-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; box-shadow: inset 0 0 0 1px rgba(47, 59, 38, .25); }
.fx-legend-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fx-legend-pct { font-weight: 800; font-variant-numeric: tabular-nums; }
.fx-legend-empty { font-size: 12.5px; color: var(--muted); }
/* 390px 寬（PLAN §4 QA 寬度）圖例只剩 ~106px，「🧳 住宿旅行」會被切成「住…」⇒ 窄的時候圓餅縮小、讓位給圖例 */
@container fxdonut (max-width: 252px) {
  .fx-donut-chart { width: 102px; height: 102px; }
  .fx-donut-center { padding: 18px; font-size: 11px; }
  .fx-legend { margin-left: -2px; }
}

.fx-columns { display: flex; flex-direction: column; }
.fx-col-plot {
  display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 3px; height: 92px; align-items: end;
  margin-bottom: 16px; border-bottom: 1.5px solid var(--ink); padding: 0 1px;
}
.fx-col {
  position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; border: 0; padding: 0;
  background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent; min-width: 0;
}
.fx-col-fill {
  display: block; width: 100%; border-radius: 4px 4px 1px 1px; background: var(--accent-deep); opacity: .7;
  transition: height .75s var(--ease-out), opacity .15s, filter .15s;
}
.fx-col.is-highlight .fx-col-fill { background: var(--coral); opacity: 1; }
.fx-col.is-active .fx-col-fill { opacity: 1; filter: saturate(1.3) brightness(.92); }
.fx-col-label {
  position: absolute; bottom: -17px; left: 50%; transform: translateX(-50%); font-size: 9.5px; color: var(--muted);
  white-space: nowrap; pointer-events: none;
}
.fx-col.is-active .fx-col-label, .fx-col.is-highlight .fx-col-label { color: var(--ink); font-weight: 800; }
.fx-col-caption { font-size: 12px; color: var(--ink-soft); text-align: center; min-height: 16px; font-variant-numeric: tabular-nums; }

.fx-avatars { display: flex; flex-wrap: wrap; gap: 8px; }
.fx-av { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 46px; }
.fx-av-face {
  width: 42px; height: 42px; border-radius: 50%; background: var(--cream); border: 2px solid var(--ink);
  display: grid; place-items: center; font-size: 20px;
}
.fx-av-name { font-size: 11.5px; font-weight: 700; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.fx-note { display: flex; gap: 6px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; font-size: 12.5px; line-height: 1.45; }
.fx-note.tone-info { background: #FFF6E3; color: #6A5A2E; }
.fx-note.tone-warn { background: #FFE7E1; color: #94392A; }
.fx-note-icon { flex: none; }
.fx-note-text { min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }

.fx-image img { display: block; width: 100%; height: auto; border-radius: 10px; border: 1.5px solid var(--ink); }
.fx-image.is-missing {
  padding: 18px 10px; text-align: center; border-radius: 10px; background: #F4EFE3; color: var(--muted); font-size: 12.5px;
}

.fx-foot { display: flex; gap: 8px; padding: 0 14px 14px; }
.fx-foot.is-stack { flex-direction: column; }
/* 兩顆並排放不下時由 cards.js 量過後加上（字被擠到斷行 ⇒ 上下排），按鈕維持一般大小 */
.fx-foot.is-autostack { flex-direction: column; }
.fx-btn {
  flex: 1; min-width: 0; min-height: 42px; border: 2px solid var(--ink); border-radius: 12px; background: #fff;
  color: var(--ink); font-size: 15px; font-weight: 800; padding: 6px 10px; cursor: pointer; box-shadow: 0 3px 0 var(--ink);
  -webkit-tap-highlight-color: transparent; transition: transform .1s, box-shadow .1s, background .15s;
  display: inline-flex; align-items: center; justify-content: center; text-align: center; line-height: 1.25;
}
.fx-btn.is-pressed { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.fx-btn.st-primary { background: var(--accent); }
.fx-btn.st-danger { background: var(--coral); color: #fff; }
.fx-btn.st-link {
  border-color: transparent; box-shadow: none; background: transparent; color: #2F6FA8; min-height: 34px; font-weight: 700;
}
.fx-btn.st-link.is-pressed { transform: scale(.97); }
.fx-btn:disabled { opacity: .45; cursor: default; box-shadow: none; transform: none; }
.fx-foot:not(.is-stack) .fx-btn.st-primary { flex: 1.6; }
.fx-foot.is-stack .fx-btn.st-primary { min-height: 50px; font-size: 17px; }
.fx-btn.is-tapped .fx-btn-label { animation: tapPop .34s var(--spring); }
@keyframes tapPop { 40% { transform: scale(.9); } 100% { transform: none; } }
.fx-li-btn { flex: none; min-height: 32px; font-size: 13px; padding: 4px 10px; border-radius: 10px; box-shadow: 0 2px 0 var(--ink); }
.fx-li-btn.is-pressed { transform: translateY(2px); }

/* carousel */
.row.is-carousel .row-main { flex: 1; max-width: calc(100% - 44px); }
.row.is-carousel .row-line { flex-direction: column; align-items: stretch; width: 100%; gap: 2px; }
.row.is-carousel .row-meta { padding-left: 2px; }
.fx-carousel { margin-right: -10px; position: relative; }
.fx-track {
  display: flex; align-items: stretch; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px 10px 6px 0;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
}
.fx-track::-webkit-scrollbar { display: none; }
.fx-track > .fx-bubble {
  flex: none; width: min(256px, calc(100cqw - 118px)); scroll-snap-align: start; display: flex; flex-direction: column;
}
.fx-track > .fx-bubble .fx-body { flex: 1; }
.fx-dots { display: flex; justify-content: center; gap: 5px; padding: 2px 0 0; margin-right: 10px; }
.fx-dots span { width: 6px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .55); transition: width .25s var(--spring), background .2s; }
.fx-dots span.is-on { width: 16px; background: #fff; }

@media (hover: hover) {
  button.fx-kv-row:hover { background: #FBF6EA; }
  .fx-chip:not(.is-selected):hover { background: #FFFBEF; }
  .fx-li.is-action:hover { background: #FBF6EA; }
  .fx-btn.st-secondary:hover { background: #FFFCF4; }
  .fx-btn.st-primary:hover, .fx-btn.st-danger:hover { filter: brightness(1.04); }
  .sheet-item:not(.is-selected):hover { background: #F6F7F9; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
