.ff-page { margin: 0; min-height: 100vh; }
.ff-page #ff, .ff-page > .ff-root { min-height: 100vh; }

.ff-root {
  --ff-bg: #fff; --ff-text: #0f2f2c; --ff-accent: #0f766e; --ff-accent-text: #fff;
  --ff-font: system-ui, sans-serif; --ff-radius: 8px;
  position: relative; display: flex; flex-direction: column; box-sizing: border-box;
  height: 100%; min-height: 420px; background: var(--ff-bg); color: var(--ff-text);
  font-family: var(--ff-font); line-height: 1.45; overflow: hidden;
}
.ff-root *, .ff-root *::before { box-sizing: border-box; }

.ff-progress { height: 5px; background: color-mix(in srgb, var(--ff-text) 10%, transparent); flex: none; }
.ff-progress-fill { height: 100%; width: 0; background: var(--ff-accent); transition: width .3s ease; border-radius: 0 99px 99px 0; }

.ff-stage { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px 20px; overflow-y: auto; }
.ff-card { width: 100%; max-width: 640px; margin: auto; animation: ff-in .28s ease both; }
@keyframes ff-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .ff-card { animation: none; } .ff-progress-fill { transition: none; } }

.ff-count { font-size: 13px; font-weight: 600; letter-spacing: .02em; color: var(--ff-accent); margin-bottom: 12px; }
.ff-title { font-size: clamp(23px, 3.4vw, 32px); font-weight: 700; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 10px; text-wrap: balance; overflow-wrap: anywhere; }
.ff-req { color: var(--ff-accent); }
.ff-desc { font-size: 17px; opacity: .75; margin: 0 0 22px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ff-title + .ff-input, .ff-title + div { margin-top: 22px; }

.ff-input {
  width: 100%; font: inherit; font-size: 20px; color: inherit; background: transparent;
  border: 0; border-bottom: 2px solid color-mix(in srgb, var(--ff-text) 30%, transparent);
  padding: 10px 0; outline: none; border-radius: 0; transition: border-color .16s ease;
}
.ff-input:focus { border-bottom-color: var(--ff-accent); }
.ff-input::placeholder { color: color-mix(in srgb, var(--ff-text) 35%, transparent); }
.ff-textarea { resize: vertical; min-height: 96px; }
select.ff-input { cursor: pointer; }
select.ff-input option { color: #111; background: #fff; }

.ff-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.ff-field { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.ff-field > span { opacity: .75; }
.ff-field .ff-input { font-size: 18px; }
@media (max-width: 520px) { .ff-fields { grid-template-columns: 1fr; } }

.ff-choices { display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.ff-choice, .ff-rank-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; font: inherit; font-size: 17px;
  color: inherit; min-height: 46px; padding: 9px 12px; border-radius: var(--ff-radius); cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease;
  background: color-mix(in srgb, var(--ff-accent) 8%, transparent);
  border: 1.5px solid color-mix(in srgb, var(--ff-accent) 40%, transparent);
}
.ff-choice:hover { background: color-mix(in srgb, var(--ff-accent) 16%, transparent); }
.ff-choice.on { background: color-mix(in srgb, var(--ff-accent) 22%, transparent); border-color: var(--ff-accent); box-shadow: 0 0 0 1px var(--ff-accent); }
.ff-key {
  flex: none; min-width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; border-radius: 6px; background: var(--ff-bg);
  border: 1px solid color-mix(in srgb, var(--ff-accent) 45%, transparent);
}
.ff-choice.on .ff-key { background: var(--ff-accent); color: var(--ff-accent-text); }

.ff-rank { display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.ff-rank-row { cursor: default; }
.ff-rank-label { flex: 1; overflow-wrap: anywhere; }
.ff-mini { display: inline-flex; align-items: center; font: inherit; color: inherit; background: transparent; border: 0; cursor: pointer; padding: 2px 6px; border-radius: 4px; }
.ff-mini:hover:not(:disabled) { background: color-mix(in srgb, var(--ff-accent) 20%, transparent); }
.ff-mini:disabled { opacity: .25; cursor: default; }

.ff-stars { display: flex; gap: 6px; flex-wrap: wrap; }
.ff-star { font-size: 40px; line-height: 1; background: none; border: 0; padding: 0 2px; cursor: pointer; color: color-mix(in srgb, var(--ff-text) 20%, transparent); transition: transform .1s; }
.ff-star:hover { transform: scale(1.12); }
.ff-star.on { color: var(--ff-accent); }

.ff-nums { display: flex; gap: 6px; flex-wrap: wrap; }
.ff-num {
  flex: 1 0 44px; height: 54px; font: inherit; font-size: 17px; font-weight: 600; transition: background-color .16s ease, color .16s ease; color: inherit; cursor: pointer; border-radius: var(--ff-radius);
  background: color-mix(in srgb, var(--ff-accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--ff-accent) 45%, transparent);
}
.ff-num:hover { background: color-mix(in srgb, var(--ff-accent) 18%, transparent); }
.ff-num.on { background: var(--ff-accent); color: var(--ff-accent-text); }
.ff-scale-labels { display: flex; justify-content: space-between; font-size: 13px; opacity: .65; margin-top: 8px; }

.ff-slider-wrap { max-width: 480px; }
.ff-slider-value { display: block; font-size: 32px; font-weight: 600; margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.ff-slider { width: 100%; accent-color: var(--ff-accent); }

.ff-error { min-height: 22px; margin-top: 10px; font-size: 14px; color: #dc2626; }
.ff-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.ff-btn {
  display: inline-block; font: inherit; font-size: 17px; font-weight: 600; text-decoration: none; cursor: pointer;
  color: var(--ff-accent-text); background: var(--ff-accent); border: 0; border-radius: var(--ff-radius); padding: 12px 24px; min-height: 46px;
  transition: filter .16s ease, transform .16s ease;
}
.ff-btn:active { transform: translateY(1px); }
.ff-btn:hover { filter: brightness(1.08); }
.ff-btn:focus-visible, .ff-choice:focus-visible, .ff-num:focus-visible, .ff-star:focus-visible, .ff-back:focus-visible {
  outline: 2px solid var(--ff-accent); outline-offset: 2px;
}
.ff-hint { font-size: 12px; opacity: .55; margin-top: 6px; }
.ff-actions .ff-hint { margin: 0; }

.ff-footer { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; }
.ff-back {
  font: inherit; font-size: 16px; width: 40px; height: 36px; cursor: pointer; visibility: hidden; display: inline-flex; align-items: center; justify-content: center;
  color: var(--ff-accent-text); background: var(--ff-accent); border: 0; border-radius: var(--ff-radius);
}
.ff-brand { font-size: 12px; opacity: .5; }

.ff-matrix-wrap { overflow-x: auto; }
.ff-matrix { border-collapse: separate; border-spacing: 0 6px; font-size: 15px; min-width: 100%; }
.ff-matrix th { font-weight: 500; padding: 8px 12px; text-align: center; white-space: nowrap; }
.ff-matrix tbody th { text-align: left; white-space: normal; }
.ff-matrix td { text-align: center; padding: 8px 12px; background: color-mix(in srgb, var(--ff-accent) 8%, transparent); }
.ff-matrix tbody th { background: color-mix(in srgb, var(--ff-accent) 8%, transparent); border-radius: var(--ff-radius) 0 0 var(--ff-radius); }
.ff-matrix td:last-child { border-radius: 0 var(--ff-radius) var(--ff-radius) 0; }
.ff-matrix input { width: 18px; height: 18px; accent-color: var(--ff-accent); cursor: pointer; }

.ff-drop {
  display: block; text-align: center; padding: 28px 16px; cursor: pointer; border-radius: var(--ff-radius);
  border: 2px dashed color-mix(in srgb, var(--ff-accent) 50%, transparent);
  background: color-mix(in srgb, var(--ff-accent) 6%, transparent);
}
.ff-drop.over, .ff-drop:hover { background: color-mix(in srgb, var(--ff-accent) 14%, transparent); }
.ff-drop:focus-within { outline: 2px solid var(--ff-accent); outline-offset: 2px; }
.ff-file-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ff-files { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.ff-file { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--ff-radius); background: color-mix(in srgb, var(--ff-accent) 10%, transparent); }
.ff-file .ff-hint { margin: 0; white-space: nowrap; }
.ff-sign { display: block; width: 100%; max-width: 600px; height: auto; aspect-ratio: 3 / 1; background: #fff; border-radius: var(--ff-radius); border: 1px solid color-mix(in srgb, var(--ff-text) 30%, transparent); touch-action: none; cursor: crosshair; }
.ff-embed { display: block; width: 100%; height: min(60vh, 620px); border: 0; border-radius: var(--ff-radius); background: #fff; }

.ff-root.ff-has-bg { background-size: cover; background-position: center; }
.ff-logo { position: absolute; top: 18px; left: 18px; max-height: 40px; max-width: 160px; object-fit: contain; z-index: 1; }
.ff-media { display: block; max-width: 100%; max-height: 260px; border-radius: var(--ff-radius); margin: 0 0 20px; object-fit: cover; }
.ff-pic-label { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ff-pics { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ff-choice.ff-pic { flex-direction: column; align-items: stretch; padding: 8px; gap: 8px; }
.ff-pic img, .ff-pic-empty { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: calc(var(--ff-radius) * .6); background: color-mix(in srgb, var(--ff-accent) 14%, transparent); }
.ff-other { margin-top: 6px; font-size: 17px; }
.ff-consent { display: flex; align-items: center; gap: 8px; justify-content: center; padding: 8px 18px; font-size: 13px; color: var(--ff-text); opacity: 0.85; cursor: pointer; }
.ff-consent input { width: 16px; height: 16px; accent-color: var(--ff-accent); }

/* ---------- Chat layout ---------- */
.ff-chat .ff-stage { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 24px 16px 8px; min-height: 0; }
.ff-thread { width: 100%; max-width: 640px; margin: auto auto 0; display: flex; flex-direction: column; gap: 10px; }
.ff-row { display: flex; align-items: flex-end; gap: 8px; }
.ff-row.ff-me { justify-content: flex-end; }
.ff-bubble { max-width: min(86%, 480px); padding: 10px 14px; border-radius: calc(var(--ff-radius) + 8px); overflow-wrap: anywhere; font-size: 16px; animation: ff-in .25s ease both; }
.ff-q { background: color-mix(in srgb, var(--ff-text) 8%, var(--ff-bg)); border-bottom-left-radius: 4px; }
.ff-a { background: var(--ff-accent); color: var(--ff-accent-text); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.ff-a.ff-skip { opacity: .6; font-style: italic; }
.ff-row:not(.ff-pop) > .ff-bubble:not(.ff-typing) { animation: none; }
.ff-chat .ff-thread > .ff-row:last-child > .ff-bubble { animation: ff-in .25s ease both; }
.ff-q-title { font-weight: 700; font-size: 18px; line-height: 1.3; }
.ff-q-desc { margin-top: 4px; opacity: .75; font-size: 15px; white-space: pre-wrap; }
.ff-q .ff-media { max-height: 180px; margin: 0 0 8px; }
.ff-end .ff-btn { margin-top: 12px; }
.ff-typing { display: inline-flex; gap: 5px; padding: 14px 16px; background: color-mix(in srgb, var(--ff-text) 8%, var(--ff-bg)); border-bottom-left-radius: 4px; }
.ff-typing i { width: 7px; height: 7px; border-radius: 50%; background: color-mix(in srgb, var(--ff-text) 50%, transparent); animation: ff-dot 1s infinite ease-in-out; }
.ff-typing i:nth-child(2) { animation-delay: .15s; }
.ff-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ff-dot { 0%, 70%, 100% { transform: none; opacity: .5; } 35% { transform: translateY(-4px); opacity: 1; } }

.ff-dock { flex: none; width: 100%; max-width: 640px; margin: 0 auto; padding: 12px 16px 4px; max-height: 55%; overflow-y: auto; border-top: 1px solid color-mix(in srgb, var(--ff-text) 12%, transparent); }
.ff-dock[hidden] { display: none; }
.ff-chat .ff-dock .ff-input { border: 1.5px solid color-mix(in srgb, var(--ff-text) 25%, transparent); border-radius: var(--ff-radius); padding: 10px 14px; font-size: 17px; background: color-mix(in srgb, var(--ff-text) 4%, var(--ff-bg)); }
.ff-chat .ff-dock .ff-input:focus { border-color: var(--ff-accent); }
.ff-chat .ff-dock .ff-fields .ff-input { font-size: 16px; }
.ff-chat .ff-choices { flex-direction: row; flex-wrap: wrap; max-width: none; }
.ff-chat .ff-choice { width: auto; min-height: 40px; font-size: 16px; border-radius: 999px; padding: 6px 14px 6px 8px; }
.ff-chat .ff-choice.ff-pic { border-radius: var(--ff-radius); }
.ff-chat .ff-pics { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
.ff-chat .ff-other { flex-basis: 100%; }
.ff-chat .ff-star { font-size: 34px; }
.ff-chat .ff-num { height: 44px; }
.ff-chat .ff-actions { margin-top: 10px; }
.ff-chat .ff-error { min-height: 0; }
.ff-chat .ff-error:empty { display: none; }
.ff-chat .ff-footer { padding-top: 6px; }
.ff-chat .ff-embed { height: min(40vh, 420px); }
@media (max-width: 520px) { .ff-bubble { max-width: 92%; } .ff-dock { padding: 10px 12px 2px; max-height: 60%; } .ff-chat .ff-stage { padding: 16px 12px 6px; } }

/* ---------- Playful mood ---------- */
.ff-mascot { display: inline-flex; flex: none; width: 28px; height: 28px; }
.ff-mascot svg { width: 100%; height: 100%; }
.ff-mascot.avatar { width: 32px; height: 32px; }
.ff-mascot.mini { width: 22px; height: 22px; }
.ff-mascot.big { width: 96px; height: 96px; animation: ff-bounce 1.2s ease-out both; }
.ff-cheer, .ff-note { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--ff-accent); padding: 5px 12px 5px 8px; border-radius: 999px; background: color-mix(in srgb, #fbbf24 28%, var(--ff-bg)); animation: ff-in .3s ease both; }
.ff-cheer { margin-bottom: 14px; }
.ff-note { align-self: center; }
.ff-react { position: absolute; right: 16px; bottom: 96px; z-index: 5; display: flex; align-items: center; gap: 6px; padding: 5px 12px 5px 6px; border-radius: 999px; font-weight: 700; font-size: 14px; background: color-mix(in srgb, #fbbf24 30%, var(--ff-bg)); color: var(--ff-text); box-shadow: 0 2px 10px rgba(0,0,0,.12); pointer-events: none; animation: ff-react 1.4s ease both; }
@keyframes ff-react { 0% { opacity: 0; transform: translateY(10px) scale(.8); } 15% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
@keyframes ff-bounce { 0% { transform: scale(.4); opacity: 0; } 60% { transform: scale(1.12); opacity: 1; } 100% { transform: none; } }
.ff-celebrate { position: relative; display: flex; justify-content: center; height: 110px; margin-bottom: 8px; overflow: visible; pointer-events: none; }
.ff-chat .ff-celebrate { height: 110px; margin-top: 8px; }
.ff-conf { position: absolute; top: 0; left: var(--x); width: 8px; height: 12px; border-radius: 2px; background: var(--c); transform: rotate(var(--r)); animation: ff-fall 1.8s var(--d) ease-in both; }
@keyframes ff-fall { 0% { opacity: 0; transform: translateY(-20px) rotate(var(--r)); } 15% { opacity: 1; } 100% { opacity: 0; transform: translateY(110px) rotate(calc(var(--r) + 220deg)); } }
.ff-playful .ff-choice.on { transform: scale(1.02); }
.ff-playful .ff-progress-fill { background: linear-gradient(90deg, var(--ff-accent), #fbbf24); }
@media (prefers-reduced-motion: reduce) {
  .ff-bubble, .ff-cheer, .ff-note, .ff-mascot.big, .ff-typing i, .ff-conf, .ff-react { animation: none !important; }
  .ff-conf { opacity: 0; }
  .ff-playful .ff-choice.on { transform: none; }
}
.ff-page .ff-chat, .ff-page #ff.ff-chat { height: 100vh; height: 100dvh; min-height: 0; }

.ff-ask { flex: none; width: 100%; max-width: 640px; margin: 0 auto; padding: 6px 16px 0; }
.ff-ask[hidden] { display: none; }
.ff-ask-row { display: flex; gap: 8px; }
.ff-ask-row .ff-input { flex: 1; min-width: 0; font-size: 15px; padding: 8px 12px; }
.ff-ask-btn { flex: none; font: inherit; font-weight: 600; cursor: pointer; padding: 8px 14px; border-radius: var(--ff-radius); border: 1.5px solid var(--ff-accent); background: transparent; color: var(--ff-accent); }
.ff-ask-btn:disabled { opacity: .5; cursor: default; }
.ff-ask-note { margin-top: 4px; }
.ff-ask-a { background: color-mix(in srgb, #fbbf24 22%, var(--ff-bg)); }

/* decorative emoji stickers (theme.stickers) */
.ff-stickers { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 3; }
.ff-st { position: absolute; line-height: 1; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)); filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .12)); }
.ff-st-in { display: block; font-style: normal; will-change: transform; animation-delay: calc(var(--i, 0) * -.45s); }
.ff-st-float { animation: ff-st-float 3.6s ease-in-out infinite; }
.ff-st-bounce { animation: ff-st-bounce 1.3s cubic-bezier(.3, 0, .4, 1) infinite; }
.ff-st-wiggle { animation: ff-st-wiggle 1.6s ease-in-out infinite; }
.ff-st-spin { animation: ff-st-spin 6s linear infinite; }
.ff-st-pulse { animation: ff-st-pulse 1.8s ease-in-out infinite; }
@keyframes ff-st-float { 50% { transform: translateY(-10px) rotate(6deg); } }
@keyframes ff-st-bounce { 0%, 100% { transform: translateY(0); } 45% { transform: translateY(-18px) scale(1.05, .95); } 55% { transform: translateY(-18px); } }
@keyframes ff-st-wiggle { 0%, 100% { transform: rotate(-9deg); } 50% { transform: rotate(9deg); } }
@keyframes ff-st-spin { to { transform: rotate(360deg); } }
@keyframes ff-st-pulse { 50% { transform: scale(1.18); } }
@media (prefers-reduced-motion: reduce) { .ff-st-in { animation: none !important; } }
