:root {
  --ink: #111114;
  --muted: #6d6d78;
  --line: #e7e7ee;
  --bg: #ffffff;
  --soft: #f4f4f8;
  --primary: #6855f6;
  --primary-soft: #efedff;
  --danger: #c4361f;
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow-x: hidden; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.4;
}
.app {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh; height: var(--app-h, 100dvh);
  width: 100%; max-width: 720px; margin: 0 auto; overflow: hidden;
  background: var(--bg);
}
/* header */
.top { padding: 12px max(18px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left)); padding-top: max(12px, env(safe-area-inset-top)); flex: none; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 34px; }
.logo { height: 36px; width: auto; max-width: 52%; object-fit: contain; display: block; }
.top-right { display: flex; flex-direction: column; align-items: flex-end; min-width: 0; }
.hint { font-size: 13px; color: var(--muted); white-space: nowrap; }
.finish-link { background: none; border: 0; font: inherit; font-size: 12px; color: var(--muted); cursor: pointer; padding: 3px 0 3px 10px; margin-top: -1px; text-decoration: underline; text-underline-offset: 2px; text-decoration-color: #c8c8d2; }
.finish-link:hover { color: var(--primary); }
.finish-link:disabled { opacity: .45; cursor: default; }
.finish-link[hidden] { display: none; }
.bar { height: 3px; border-radius: 3px; background: var(--line); margin: 10px 0 0; overflow: hidden; }
.barfill { height: 100%; width: 0; background: var(--primary); border-radius: 3px; transition: width .4s ease; }
/* chat */
.scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 18px max(18px, env(safe-area-inset-right)) 8px max(18px, env(safe-area-inset-left)); scroll-behavior: smooth; overscroll-behavior: contain; }
.chat { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; flex-direction: column; max-width: 84%; animation: pop .22s ease both; }
.msg.bot { align-self: flex-start; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.bubble {
  padding: 10px 14px; border-radius: var(--radius); font-size: 16px; word-wrap: break-word; overflow-wrap: anywhere;
  white-space: pre-wrap; text-align: left;
}
.bot .bubble { background: var(--soft); border-bottom-left-radius: 6px; }
.user .bubble {
  background: var(--primary); color: #fff; border-bottom-right-radius: 6px; border: 0; font: inherit; cursor: pointer;
}
.user .bubble:disabled { cursor: default; }
.user .bubble:not(:disabled):active { opacity: .85; }
.user .bubble.editing { outline: 2px solid var(--primary); outline-offset: 2px; background: #fff; color: var(--primary); }
.edit-tag { font-size: 11px; color: var(--muted); margin: 2px 6px 0; }
.bubble a.cta {
  display: inline-block; margin-top: 4px; padding: 10px 16px; border-radius: 999px; background: var(--ink); color: #fff;
  text-decoration: none; font-weight: 600; font-size: 15px;
}
.typing { align-self: flex-start; background: var(--soft); border-radius: var(--radius); border-bottom-left-radius: 6px; padding: 14px 16px; display: flex; gap: 5px; animation: pop .2s ease both; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #a5a5b2; animation: blink 1.1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
/* dock */
.dock { flex: none; padding: 10px max(18px, env(safe-area-inset-right)) 14px max(18px, env(safe-area-inset-left)); padding-bottom: max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); max-height: 52dvh; overflow-y: auto; }
.dock[hidden] { display: none; }
.dock-note { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.linkbtn { background: none; border: 0; color: var(--primary); font: inherit; font-size: 13px; cursor: pointer; padding: 4px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px; padding: 10px 16px;
  font: inherit; font-size: 15px; cursor: pointer; text-align: left; min-height: 44px;
  transition: border-color .12s, background .12s;
}
.chip:active { background: var(--soft); }
.chip.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.chip.wide { width: 100%; border-radius: 14px; }
.chip.ghost { border-style: dashed; color: var(--muted); }
.chip.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.chip:disabled { opacity: .4; cursor: default; }
.chip.select { appearance: none; -webkit-appearance: none; padding-right: 16px; }
.row-actions { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.row-actions .chip.primary { flex: 1; text-align: center; }
.compose { display: flex; gap: 8px; align-items: flex-end; }
.compose textarea, .compose input {
  flex: 1; min-width: 0; resize: none; border: 1.5px solid var(--line); border-radius: 22px; padding: 11px 16px; font: inherit; font-size: 16px;
  line-height: 1.35; max-height: 120px; outline: none; background: #fff; color: var(--ink);
}
.compose textarea:focus, .compose input:focus { border-color: var(--primary); }
.send {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; cursor: pointer;
  display: grid; place-items: center;
}
.send:disabled { opacity: .35; cursor: default; }
.send svg { width: 20px; height: 20px; }
.err { color: var(--danger); font-size: 13px; margin: 0 0 8px; }
.skip-row { margin-top: 8px; }
/* answer cards */
.card-wrap { list-style: none; align-self: stretch; animation: pop .22s ease both; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: 0 1px 2px rgba(17, 17, 20, .04); transition: opacity .16s ease, transform .16s ease; }
.card.leaving { opacity: 0; transform: translateY(-4px) scale(.98); pointer-events: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px 4px; min-height: 32px; }
.card-title { font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
.card-note { padding: 0 16px 6px; font-size: 12px; color: var(--muted); }
.card .linkbtn { font-size: 12px; padding: 2px 0; }
.opts { display: flex; flex-direction: column; margin-top: 4px; }
.opt {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 52px; padding: 10px 16px;
  background: #fff; border: 0; border-top: 1px solid var(--line); color: var(--ink); font: inherit; font-size: 15px; text-align: left; cursor: pointer;
  transition: background .12s;
}
.opt:active { background: var(--soft); }
.opt-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.opt-label { overflow-wrap: anywhere; }
.opt-desc { font-size: 13px; color: var(--muted); line-height: 1.3; }
.opt.primary { background: var(--primary-soft); }
.opt.primary .opt-label { font-weight: 600; }
.opt.on .opt-label { font-weight: 600; color: var(--primary); }
.mark { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.mark svg { width: 13px; height: 13px; opacity: 0; }
.card:not(.multi) .mark { visibility: hidden; }
.card:not(.multi) .opt.on .mark { visibility: visible; background: var(--primary); }
.card:not(.multi) .opt.on .mark svg { opacity: 1; }
.card.multi .mark { border: 1.5px solid #cfcfda; }
.card.multi .opt.on .mark { background: var(--primary); border-color: var(--primary); }
.card.multi .opt.on .mark svg { opacity: 1; }
.opt.own { justify-content: flex-start; color: var(--muted); }
.own-ic { display: grid; place-items: center; width: 22px; height: 22px; color: var(--muted); }
.own-ic svg { width: 16px; height: 16px; }
.opt.own-open { cursor: default; padding: 8px 10px 8px 16px; }
.opt.own-open:active { background: #fff; }
.opt.own-open input {
  flex: 1; min-width: 0; height: 40px; border: 1.5px solid var(--line); border-radius: 20px; padding: 0 14px; font: inherit; font-size: 16px;
  color: var(--ink); background: #fff; outline: none;
}
.opt.own-open input:focus { border-color: var(--primary); }
.send.sm { width: 40px; height: 40px; }
.card-err { padding: 8px 16px 0; margin: 0; }
.card-foot { padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.submit {
  width: 100%; min-height: 46px; border: 0; border-radius: 999px; background: var(--primary); color: #fff; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.submit:disabled { opacity: .35; cursor: default; }
.submit:not(:disabled):active { opacity: .85; }
@media (min-width: 760px) { .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
/* small phones */
@media (max-width: 359px) {
  .top, .scroll, .dock { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  .msg { max-width: 90%; }
  .chip { padding: 10px 14px; }
}
/* tablets and up: a bit more room, same centered column */
@media (min-width: 768px) {
  .top, .scroll, .dock { padding-left: 28px; padding-right: 28px; }
  .msg { max-width: 78%; }
  .bubble { font-size: 17px; }
  .opt { font-size: 16px; }
  .finish-link, .hint { font-size: 14px; }
}
@media (min-width: 1280px) {
  .scroll { padding-top: 28px; }
}
/* short landscape screens: less chrome so the input always fits */
@media (max-height: 520px) {
  .top { padding-top: max(6px, env(safe-area-inset-top)); }
  .logo { height: 28px; }
  .dock { max-height: 60dvh; padding-top: 6px; }
}
/* ---------- cover ---------- */
@property --ai-a { syntax: "<angle>"; initial-value: 0deg; inherits: true; }
.cover {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto; overflow-x: hidden; display: flex; background-color: #fff;
  background-image:
    radial-gradient(60% 45% at 50% 8%, rgba(150, 110, 255, .10), transparent 70%),
    radial-gradient(70% 50% at 50% 100%, rgba(150, 110, 255, .09), transparent 70%);
  transition: opacity .55s ease, transform .55s cubic-bezier(.2, .7, .2, 1), filter .55s ease;
}
.cover[hidden] { display: none; }
.cover.leaving { opacity: 0; transform: scale(1.035); filter: blur(6px); pointer-events: none; }
.cover-in {
  margin: auto; width: 100%; max-width: 460px; display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: max(28px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
  animation: coverIn .8s cubic-bezier(.2, .7, .2, 1) both;
}
.cover-logo { height: 34px; width: auto; max-width: 70%; object-fit: contain; margin-bottom: clamp(22px, 5vh, 44px); }
.cover-title { margin: 0 0 clamp(24px, 5vh, 40px); font-size: clamp(27px, 7.4vw, 40px); line-height: 1.12; letter-spacing: -.025em; font-weight: 700; text-wrap: balance; }
.ai-ring {
  position: relative; width: 100%; max-width: 380px; padding: 3px; border-radius: 29px; isolation: isolate;
  background:
    conic-gradient(from var(--ai-a), transparent 0deg, rgba(168, 85, 247, 0) 40deg, #7c3aed 90deg, #c084fc 150deg, #f0abfc 190deg, #a855f7 240deg, rgba(124, 58, 237, 0) 320deg, transparent 360deg) border-box,
    #e9e0ff;
  animation: aiSpin 5.5s linear infinite;
}
.ai-ring::before, .ai-ring::after {
  content: ""; position: absolute; inset: -2px; border-radius: inherit; z-index: -1; pointer-events: none;
  background: conic-gradient(from var(--ai-a), transparent 0deg, transparent 40deg, #8b3dff 120deg, #c084fc 175deg, #8b3dff 235deg, transparent 320deg, transparent 360deg);
}
.ai-ring::before { filter: blur(13px); opacity: .75; }
.ai-ring::after { filter: blur(36px); opacity: .45; inset: -6px; }
.ai-card {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; text-align: left;
  padding: 20px 18px 18px; border-radius: 26px; background: #fff;
}
.ai-msg { display: flex; align-items: flex-end; gap: 10px; width: 100%; }
.ai-bot { flex: none; display: block; line-height: 0; filter: drop-shadow(0 4px 10px rgba(110, 60, 240, .28)); }
.ai-bubble {
  margin: 0; padding: 12px 16px; border-radius: 18px; border-top-left-radius: 6px; background: var(--soft);
  font-size: 17px; line-height: 1.35; font-weight: 500; letter-spacing: -.005em; border-bottom-left-radius: 6px; border-top-left-radius: 18px;
}
.ai-start {
  width: 100%; min-height: 52px; margin-top: 6px; border: 0; border-radius: 999px; cursor: pointer; font: inherit; font-size: 17px; font-weight: 600; color: #fff; letter-spacing: .01em;
  background: linear-gradient(135deg, #7c5cff, #5b34ee); box-shadow: 0 8px 22px -8px rgba(98, 50, 240, .65);
  transition: transform .15s ease, box-shadow .15s ease;
}
.ai-start:hover { transform: translateY(-1px); box-shadow: 0 12px 26px -8px rgba(98, 50, 240, .7); }
.ai-start:active { transform: translateY(0) scale(.99); }
.ai-start:focus-visible { outline: 3px solid rgba(124, 92, 255, .4); outline-offset: 3px; }
.cover-note { margin: 22px 0 0; font-size: 14.5px; color: var(--muted); }
.app.enter { animation: appIn .6s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes aiSpin { to { --ai-a: 360deg; } }
@keyframes coverIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes appIn { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
@media (min-width: 768px) {
  .cover-logo { height: 40px; }
  .ai-ring { max-width: 420px; }
  .ai-card { padding: 26px 24px 24px; }
  .ai-bubble { font-size: 18px; }
  .cover-in { max-width: 600px; }
}
@media (min-width: 1600px) and (min-height: 900px) {
  .cover-in { max-width: 720px; }
  .cover-logo { height: 46px; margin-bottom: 52px; }
  .cover-title { font-size: 52px; margin-bottom: 48px; }
  .ai-ring { max-width: 500px; border-radius: 33px; }
  .ai-card { padding: 30px 28px 28px; gap: 18px; border-radius: 30px; }
  .ai-bubble { font-size: 21px; padding: 14px 20px; }
  .ai-start { min-height: 60px; font-size: 19px; }
  .cover-note { font-size: 16.5px; margin-top: 28px; }
}
@media (max-width: 359px) { .cover-in { padding-left: 16px; padding-right: 16px; } .ai-bubble { font-size: 15.5px; padding: 10px 13px; } .ai-card { padding: 18px 16px 16px; gap: 12px; } }
@media (max-height: 640px) { .cover-logo { height: 26px; margin-bottom: 16px; } .cover-title { margin-bottom: 20px; font-size: clamp(24px, 6.4vw, 32px); } .cover-note { margin-top: 16px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ---------- coming back ---------- */
.resume .cover { display: none; }
.compose input { height: 46px; border-radius: 23px; }
.bubble .back-link { display: inline-block; margin-top: 4px; padding: 2px 0; background: none; border: 0; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; text-decoration-color: #c8c8d2; }
.bubble .back-link:hover { color: var(--primary); }
.bubble .back-ask { display: block; margin-top: 4px; font-size: 13px; color: var(--muted); }
.bubble .back-ask .back-link { margin: 0 10px 0 0; }
.bubble .back-ask .back-link.yes { color: var(--primary); text-decoration-color: var(--primary); }
.phone-err { margin: 0 0 8px; }
