:root {
  --bg: #fff7f9;
  --surface: #ffffff;
  --text: #2a2230;
  --muted: #7b6f84;
  --line: #f0dde4;
  --brand: #e8557a;
  --brand-ink: #ffffff;
  --brand-soft: #fde4eb;
  --ok: #2f9e6e;
  --warn: #d98a1d;
  --bad: #d64545;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(80, 30, 60, .06), 0 6px 18px rgba(80, 30, 60, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1620;
    --surface: #26202d;
    --text: #f3ecf6;
    --muted: #a99db3;
    --line: #3a3144;
    --brand: #ff7a9c;
    --brand-ink: #2a1019;
    --brand-soft: #3d2330;
    --ok: #52c492;
    --warn: #f0b04c;
    --bad: #ff7b7b;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 22px 0 10px; }
h3 { font-size: 1.02rem; font-weight: 600; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 1.15rem; }

main { max-width: 720px; margin: 0 auto; padding: 8px 16px 24px; }
.view[hidden], [hidden] { display: none !important; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 12px 0;
  box-shadow: var(--shadow);
}
.card h2:first-child { margin-top: 2px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* form */
fieldset { border: 0; padding: 0; margin: 0 0 16px; }
legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
legend .hint { font-weight: 400; color: var(--muted); font-size: .85rem; margin-left: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px; min-height: 44px;
  border: 1.5px solid var(--line); border-radius: 999px;
  background: var(--surface); font-size: .95rem;
}
.chip input:checked + span { border-color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.chip input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--brand) 50%, transparent); outline-offset: 2px; }

textarea, input[type="text"], input[type="search"], select {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: 12px; padding: 10px 12px; min-height: 44px;
}
textarea { resize: vertical; min-height: 72px; }
.field { display: block; margin: 10px 0; font-weight: 500; }
.field > :not(:first-child) { margin-top: 6px; }

button { font: inherit; cursor: pointer; }
.primary {
  width: 100%; min-height: 50px; border: 0; border-radius: 14px;
  background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: 1.02rem;
}
.ghost, .btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 8px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--text);
}
.ghost.small { min-height: 36px; padding: 4px 12px; font-size: .88rem; }
.danger { border: 1.5px solid var(--bad); color: var(--bad); background: transparent; border-radius: 12px; min-height: 40px; padding: 6px 12px; margin-top: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0 6px; }

/* result */
.summary { border-left: 6px solid var(--brand); }
.summary.sensitive { border-left-color: var(--bad); }
.summary.low { border-left-color: var(--warn); }
.summary.neutral { border-left-color: var(--brand); }
.summary.open { border-left-color: var(--ok); }
.summary h2 { margin: 0 0 6px; }
.script { background: var(--brand-soft); border-radius: 12px; padding: 10px 12px; margin: 10px 0 4px; font-style: italic; }
.dolist, .avoidlist { margin: 6px 0 0; padding-left: 20px; }
.dolist li::marker { content: "✅ "; }
.avoidlist li::marker { content: "⛔ "; }
.cols { display: grid; gap: 4px 24px; }
@media (min-width: 560px) { .cols { grid-template-columns: 1fr 1fr; } }
.cols h3 { margin-top: 10px; }

/* question cards */
.q h3 { margin: 6px 0 4px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .78rem; color: var(--muted); }
.tag { padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--text); }
.depth { letter-spacing: 1px; color: var(--brand); }
.meta { font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.meta.fresh { color: var(--ok); }
.meta.stale { color: var(--warn); }
.qactions { display: flex; gap: 8px; margin-top: 10px; }
.qactions .primary { min-height: 44px; font-size: .95rem; }
details { margin-top: 6px; }
summary { cursor: pointer; font-weight: 600; color: var(--brand); min-height: 32px; display: flex; align-items: center; }
.hint-box { padding: 4px 0 2px; }
.hint-box p { margin: 8px 0; }
.hint-box b { display: block; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.notes { margin: 8px 0 0; padding: 0; list-style: none; }
.notes li { background: var(--bg); border-radius: 10px; padding: 8px 10px; margin-top: 6px; font-size: .92rem; }
.notes time { display: block; color: var(--muted); font-size: .78rem; }
.points { margin: 6px 0; padding-left: 20px; }
.skip-reason { font-size: .82rem; color: var(--warn); margin-top: 2px; }
.q.dim { opacity: .75; }
.sect-title { display: flex; justify-content: space-between; align-items: center; }

/* filters */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 4px; }
.filters input { grid-column: 1 / -1; }

/* tabbar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  border: 0; background: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; min-height: 60px; font-size: .78rem;
}
.tabbar button span { font-size: 1.3rem; line-height: 1; }
.tabbar button.active { color: var(--brand); font-weight: 700; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 20;
  background: var(--text); color: var(--bg);
  padding: 10px 14px; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  display: flex; gap: 12px; align-items: center; max-width: calc(100vw - 32px);
}
#toast button { background: none; border: 0; color: inherit; text-decoration: underline; font-weight: 700; }

.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
.ci { display: flex; gap: 10px; align-items: center; }
.ci .emoji { font-size: 1.6rem; }

#result { scroll-margin-top: 64px; }

.tabbar button { font-size: .72rem; }
.line-text { white-space: pre-wrap; font-size: 1.02rem; margin: 8px 0 4px; }
.line-src { color: var(--muted); font-size: .82rem; }
.qactions .ghost { min-height: 44px; }
.qactions { flex-wrap: wrap; }
.qactions .primary { flex: 1 1 100px; width: auto; }
.qactions .ghost { padding: 8px 12px; }
.fav-on { color: var(--bad); border-color: var(--bad); }
.read-box { background: var(--brand-soft); border-radius: 12px; padding: 8px 12px; margin: 10px 0 4px; }
.read-box b { display: block; margin-bottom: 4px; }
.read-box ul { margin: 0; padding-left: 18px; }
.read-box .small { margin-top: 6px; }
.inline-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin: 10px 0; }
.inline-form input[type=text] { grid-column: 1 / 3; }
.inline-form select + input { grid-column: 2 / 3; }
#dateForm input[type=text] { grid-column: 1 / -1; }
#dateForm { grid-template-columns: 1fr auto; }
#profileForm { grid-template-columns: 1fr auto; }
#profileForm input { grid-column: 1 / -1; }
#profileForm select { grid-column: 1 / 2; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item button { background: none; border: 0; color: var(--muted); font-size: 1.1rem; min-width: 36px; min-height: 36px; }
.banner { border-left: 6px solid var(--warn); }
.banner h3 { margin-bottom: 4px; }
.trend { display: flex; gap: 4px; align-items: flex-end; height: 64px; }
.trend span { flex: 1; border-radius: 6px 6px 2px 2px; background: var(--brand); min-height: 6px; opacity: .85; }
.trend-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .75rem; margin-top: 4px; }
.stat-row { display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.stat b { display: block; font-size: 1.3rem; }
.quick h2 { margin: 0 0 8px; }
.kicker { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

.steps { margin: 6px 0 10px; padding-left: 22px; }
.steps li { margin: 6px 0; }
.say { background: var(--brand-soft); border-radius: 12px; padding: 8px 12px; margin: 6px 0 10px; }
.say p { margin: 4px 0 8px; font-style: italic; }
.next { border-left: 4px solid var(--ok); padding-left: 10px; }
details.sub { margin: 8px 0; border-top: 1px dashed var(--line); padding-top: 4px; }
.kit { margin: 6px 0; padding-left: 18px; }
.kit li { margin: 8px 0; }

/* ===== Giao diện v6 ===== */
:root { --grad: linear-gradient(135deg, #ff8fab 0%, #e8557a 55%, #c93c68 100%); --ring: color-mix(in srgb, var(--brand) 35%, transparent); }
body { background: radial-gradient(1200px 500px at 50% -150px, color-mix(in srgb, var(--brand) 14%, transparent), transparent), var(--bg); }
.top { background: color-mix(in srgb, var(--surface) 80%, transparent); }
.top h1 { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 800; letter-spacing: .2px; }
.top-actions { display: flex; gap: 8px; }
.card { border-radius: 20px; }
.primary { background: var(--grad); box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 35%, transparent); }
.primary.small { min-height: 38px; font-size: .92rem; width: auto; padding: 4px 16px; }
.tabbar { backdrop-filter: blur(10px); background: color-mix(in srgb, var(--surface) 92%, transparent); }
.tabbar button { font-size: .66rem; padding: 8px 2px; }
.tabbar button span { font-size: 1.25rem; transition: transform .15s; }
.tabbar button.active span { transform: translateY(-2px) scale(1.12); }
.tabbar button.active::after { content: ""; width: 18px; height: 3px; border-radius: 3px; background: var(--grad); margin-top: 2px; }
.chip span { transition: border-color .15s, background .15s; }

.hero { background: var(--grad); color: #fff; border-radius: 22px; padding: 18px 18px 16px; margin: 12px 0; box-shadow: 0 10px 24px color-mix(in srgb, var(--brand) 30%, transparent); }
.hero h2 { margin: 0 0 6px; font-size: 1.25rem; }
.hero p { margin: 0; opacity: .96; }

.principles { display: grid; gap: 10px; }
.pr { display: flex; gap: 10px; align-items: flex-start; }
.pr p { margin: 2px 0 0; }
.pr-ico { font-size: 1.5rem; line-height: 1.2; }

.progress { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 10px 0 6px; }
.progress span { display: block; height: 100%; background: var(--grad); border-radius: 999px; transition: width .3s; }

.timeline { position: relative; margin: 14px 0; }
.stage { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; margin: 10px 0; box-shadow: var(--shadow); overflow: hidden; }
.stage.current { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.stage-head { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; cursor: pointer; min-height: 56px; }
.stage-head:focus-visible { outline: 3px solid var(--ring); outline-offset: -3px; }
.stage-num { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.stage.current .stage-num, .stage.done .stage-num { background: var(--grad); color: #fff; }
.stage-title { flex: 1; display: flex; flex-direction: column; }
.chev { color: var(--muted); }
.stage-body { padding: 0 14px 14px; }
.stage-body h4 { margin: 14px 0 6px; font-size: .9rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.goal { background: var(--brand-soft); border-radius: 12px; padding: 8px 12px; }
.checkpoint { border-left: 4px solid var(--warn); padding-left: 10px; margin: 14px 0 10px; }

.react { border: 1px solid var(--line); border-left-width: 6px; border-radius: 14px; padding: 10px 12px; margin: 10px 0; background: var(--surface); }
.react.good { border-left-color: var(--ok); }
.react.mid { border-left-color: var(--warn); }
.react.stop { border-left-color: var(--bad); }
.react-head { display: flex; gap: 10px; align-items: flex-start; }
.react-ico { font-size: 1.2rem; }
.react p { margin: 6px 0; }
.react.compact { display: flex; gap: 10px; padding: 8px 10px; }
.avoid-line { color: var(--muted); font-size: .92rem; }

.ladder { padding-left: 20px; }
.ladder li { margin: 10px 0; }
.ladder .ex { font-style: italic; background: var(--brand-soft); border-radius: 10px; padding: 6px 10px; margin: 4px 0; }
.sig { border-radius: 12px; padding: 8px 12px; margin: 8px 0; }
.sig.good { background: color-mix(in srgb, var(--ok) 14%, transparent); }
.sig.mid { background: color-mix(in srgb, var(--warn) 14%, transparent); }
.sig.stop { background: color-mix(in srgb, var(--bad) 12%, transparent); }
.sig ul { margin: 4px 0 0; padding-left: 20px; }
.dolist.x li::marker { content: "🚫 "; }

fieldset.dim { margin: 14px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; }
.scale { display: flex; gap: 8px; margin-top: 6px; }
.dot { position: relative; flex: 1; }
.dot input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.dot span { display: grid; place-items: center; height: 44px; border-radius: 12px; border: 1.5px solid var(--line); font-weight: 600; background: var(--surface); }
.dot input:checked + span { background: var(--grad); color: #fff; border-color: transparent; }
.dot input:focus-visible + span { outline: 3px solid var(--ring); outline-offset: 2px; }
.scale-note { text-align: center; margin-top: 4px; }
.result.green { border-left: 6px solid var(--ok); }
.result.yellow { border-left: 6px solid var(--warn); }
.result.red { border-left: 6px solid var(--bad); }
.hist-head { display: flex; justify-content: space-between; align-items: center; }
.x { background: none; border: 0; color: var(--muted); font-size: 1.1rem; min-width: 36px; min-height: 36px; cursor: pointer; }

/* ===== Tour ===== */
#tour { position: fixed; inset: 0; z-index: 100; }
.tour-spot { position: fixed; border-radius: 14px; box-shadow: 0 0 0 9999px rgba(20, 10, 25, .62); border: 2px solid #fff; transition: all .25s ease; pointer-events: none; }
.tour-tip { position: fixed; background: var(--surface); color: var(--text); border-radius: 18px; padding: 16px; box-shadow: 0 16px 40px rgba(0,0,0,.35); outline: none; max-width: calc(100vw - 24px); transition: top .25s ease, left .25s ease; }
.tour-icon { font-size: 1.8rem; line-height: 1; }
.tour-title { margin: 6px 0 4px; font-size: 1.1rem; }
.tour-text { margin: 0 0 10px; color: var(--muted); }
.tour-dots { display: flex; gap: 5px; justify-content: center; margin-bottom: 12px; }
.tour-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.tour-dots span.on { background: var(--brand); width: 18px; border-radius: 4px; }
.tour-actions { display: flex; gap: 8px; align-items: center; }
.tour-actions .grow { flex: 1; }
@media (prefers-reduced-motion: reduce) { .tour-spot, .tour-tip, .progress span, .tabbar button span { transition: none; } }
.top h1 { white-space: nowrap; font-size: 1.1rem; }
.top-actions button { white-space: nowrap; }
.icon-btn { min-width: 40px; padding: 4px 10px; font-size: 1.05rem; }
