/* Coach with Tony — giao diện tối, tông lửa (đỏ thẫm → cam → vàng ấm) */
:root {
  color-scheme: dark;
  --bg: #0e0c10;
  --bg-2: #141117;
  --bg-3: #1c1820;
  --bg-4: #25202a;
  --line: #2d2733;
  --line-2: #3a3341;
  --text: #f5f0ea;
  --muted: #b1a8b5;
  --dim: #7b7282;
  --ember: #ff6a2b;
  --ember-2: #ff8f3a;
  --gold: #ffc35a;
  --crimson: #e2343d;
  --ok: #4fd18b;
  --fire: linear-gradient(135deg, #e2343d 0%, #ff6a2b 52%, #ffc35a 100%);
  --fire-soft: linear-gradient(135deg, rgba(226, 52, 61, 0.16), rgba(255, 106, 43, 0.12) 55%, rgba(255, 195, 90, 0.1));
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --sidebar: 300px;
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --strong: #fff;
  --em: #ffd8b0;
  --quote-text: #ffe2c7;
  --bq-text: #ffe7d6;
  --err: #ff8a80;
  --err-2: #ffb4a8;
  --overlay-bg: #0b090d;
  --caption: #f2e4d6;
  --mark-text: #fff;
  --end-bg: #3a1418;
  --end-line: #5a1d23;
  --end-text: #ff9d94;
  --top-bg: rgba(14, 12, 16, 0.85);
}

/* ---------- Giao diện SÁNG (Cài đặt → Giao diện). Cùng bộ màu lửa, nền giấy ấm; chữ vàng/cam tối hơn để đủ tương phản ---------- */
:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f8f4ef;
  --bg-2: #ffffff;
  --bg-3: #f2ece5;
  --bg-4: #e9e1d8;
  --line: #e4dbd1;
  --line-2: #d6cabd;
  --text: #1f1a22;
  --muted: #5c5361;
  --dim: #82788a;
  --ember: #de5119;
  --ember-2: #cf5a1a;
  --gold: #995800;
  --crimson: #c8283a;
  --ok: #17905a;
  --fire-soft: linear-gradient(135deg, rgba(226, 52, 61, 0.08), rgba(255, 106, 43, 0.08) 55%, rgba(255, 195, 90, 0.12));
  --shadow: 0 10px 30px rgba(70, 35, 10, 0.12);
  --strong: #120e14;
  --em: #9a4a12;
  --quote-text: #5a3412;
  --bq-text: #4a2c14;
  --err: #c62828;
  --err-2: #b3261e;
  --overlay-bg: #fbf6f0;
  --caption: #2a2128;
  --mark-text: #120e14;
  --end-bg: #fde4e4;
  --end-line: #f2b8b8;
  --end-text: #b42318;
  --top-bg: rgba(248, 244, 239, 0.88);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overscroll-behavior: none; }
/* Chống zoom: không phóng chữ tự động, chạm 2 lần không zoom (touch-action), ô nhập ≥16px để iPhone không tự zoom khi gõ */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: manipulation; }
input, textarea, select { font-size: 16px; }
button, .chip, .sess, .tool-card, .vbtn, .orb { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body { font-family: var(--font); font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--gold); }
.ico { width: 22px; height: 22px; flex: none; display: block; }
.ico.sm { width: 18px; height: 18px; }
.ico.xs { width: 15px; height: 15px; }
[hidden] { display: none !important; }

/* ---------- boot ---------- */
/* --app-h = chiều cao vùng nhìn thấy thật (trừ bàn phím iPhone), đặt bởi app.js */
#app { height: 100%; height: var(--app-h, 100dvh); }
#app.booting { display: grid; place-items: center; height: 100%; }
.boot img { border-radius: 50%; animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.06); filter: drop-shadow(0 0 24px rgba(255, 106, 43, 0.45)); } }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px calc(24px + var(--safe-b)); background:
  radial-gradient(700px 420px at 50% 0%, rgba(255, 106, 43, 0.18), transparent 70%), var(--bg); overflow-y: auto; height: 100%; }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-card img { width: 112px; height: 112px; border-radius: 50%; }
.login-card h1 { font-size: 30px; line-height: 1.15; margin: 22px 0 8px; font-weight: 800; letter-spacing: -0.02em; }
.login-card p { color: var(--muted); margin: 0 0 26px; }
.login-card form { display: grid; gap: 12px; }
.input { width: 100%; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 14px 16px; outline: none; transition: border-color 0.15s; }
.input:focus { border-color: var(--ember); }
.login-card .input { text-align: center; font-size: 18px; letter-spacing: 0.08em; }
.login-err { color: var(--err); min-height: 1.4em; font-size: 14px; }
.fine { color: var(--dim); font-size: 12.5px; margin-top: 26px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 12px; font-weight: 600; background: var(--bg-4); border: 1px solid var(--line-2); transition: transform 0.08s, background 0.15s, opacity 0.15s; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.fire { background: var(--fire); border: 0; color: #1a0d05; font-weight: 700; box-shadow: 0 6px 24px rgba(255, 106, 43, 0.28); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--bg-3); color: var(--text); }
.btn.sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; min-height: 40px; }
.btn.block { width: 100%; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--muted); transition: background 0.15s, color 0.15s; }
.icon-btn:hover { background: var(--bg-3); color: var(--text); }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; height: 100%; }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding-top: var(--safe-t); }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; padding-top: var(--safe-t); }
.scrim { display: none; }

.brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 12px; }
.brand img { width: 42px; height: 42px; border-radius: 50%; }
.brand b { display: block; font-size: 16.5px; letter-spacing: -0.01em; }
.brand small { display: block; color: var(--dim); font-size: 12.5px; margin-top: -2px; }
.brand > div { flex: 1; min-width: 0; }
.side-close { display: none; margin-right: -6px; }
.side-new { margin: 6px 14px 10px; }
.nav { display: grid; gap: 2px; padding: 4px 10px 8px; }
.nav button { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; color: var(--muted); font-weight: 500; text-align: left; }
.nav button:hover { background: var(--bg-3); color: var(--text); }
.nav button.on { background: var(--bg-4); color: var(--text); }
.nav button.on .ico { color: var(--ember-2); }
.nav .badge { margin-left: auto; font-size: 12px; background: var(--fire-soft); color: var(--gold); border: 1px solid rgba(255, 143, 58, 0.3); border-radius: 99px; padding: 0 8px; }
.side-search { margin: 4px 14px 8px; position: relative; }
.side-search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--dim); }
.side-search input { padding: 10px 12px 10px 38px; font-size: 16px; }
.sessions { flex: 1; overflow-y: auto; padding: 4px 10px 16px; min-height: 0; }
.sessions h6 { margin: 14px 10px 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); font-weight: 600; }
.sess { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 10px; color: var(--muted); }
.sess:hover { background: var(--bg-3); color: var(--text); }
.sess.on { background: var(--bg-4); color: var(--text); }
.sess b { display: block; font-weight: 500; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess small { display: block; font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot { padding: 10px 18px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); color: var(--dim); font-size: 11.5px; line-height: 1.45; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); min-height: 60px; background: var(--top-bg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); position: relative; z-index: 3; }
.top .menu { display: none; }
.top-title { flex: 1; min-width: 0; padding: 0 6px; }
.top-title b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-title small { display: block; color: var(--dim); font-size: 12.5px; margin-top: -2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voice-cta { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 99px; background: var(--fire); color: #1a0d05; font-weight: 700; font-size: 14.5px; box-shadow: 0 4px 18px rgba(255, 106, 43, 0.3); }
.voice-cta .ico { width: 19px; height: 19px; }

/* ---------- chat ---------- */
.scroll { flex: 1; overflow-y: auto; min-height: 0; scroll-behavior: smooth; overscroll-behavior: contain; }
.thread { max-width: 780px; margin: 0 auto; padding: 22px 16px 28px; display: flex; flex-direction: column; gap: 18px; }
.msg { display: flex; gap: 12px; align-items: flex-start; animation: rise 0.25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.msg .av { width: 36px; height: 36px; border-radius: 50%; flex: none; margin-top: 2px; }
.msg.user { justify-content: flex-end; }
.bubble { min-width: 0; max-width: 100%; }
.msg.user .bubble { background: var(--bg-4); border: 1px solid var(--line-2); padding: 11px 15px; border-radius: 18px 18px 6px 18px; max-width: 85%; white-space: pre-wrap; word-wrap: break-word; }
.msg.coach .bubble { flex: 1; padding-top: 4px; }
.msg .via { display: inline-flex; align-items: center; gap: 4px; color: var(--dim); font-size: 11.5px; margin-top: 4px; }
.msg.user .via { justify-content: flex-end; width: 100%; }
.md p { margin: 0 0 0.75em; }
.md p:last-child, .md ul:last-child, .md ol:last-child { margin-bottom: 0; }
.md strong { color: var(--strong); font-weight: 700; }
.md em { color: var(--em); }
.md ul, .md ol { margin: 0 0 0.75em; padding-left: 1.3em; }
.md li { margin: 0.2em 0; }
.md li::marker { color: var(--ember-2); }
.md blockquote { margin: 0 0 0.75em; padding: 6px 14px; border-left: 3px solid var(--ember); background: var(--fire-soft); border-radius: 0 10px 10px 0; color: var(--bq-text); }
.md h3, .md h4 { margin: 0.6em 0 0.35em; font-size: 1.02em; color: var(--gold); }
.md code { background: var(--bg-4); padding: 1px 6px; border-radius: 6px; font-size: 0.92em; }
.md hr { border: 0; border-top: 1px solid var(--line-2); margin: 1em 0; }
.tools { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 6px; margin-left: -8px; opacity: 0.75; }
.tools button.save-inc { color: var(--ember-2); }
.tools button { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; min-height: 40px; border-radius: 8px; color: var(--dim); font-size: 12.5px; }
.tools button:hover { background: var(--bg-3); color: var(--text); }
.tools button.playing { color: var(--ember-2); }
.typing { display: inline-flex; gap: 5px; padding: 10px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ember-2); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.note { font-size: 13px; color: var(--dim); display: flex; align-items: center; gap: 8px; }
.note .ico { color: var(--ember-2); }
.err-line { color: var(--err-2); background: rgba(226, 52, 61, 0.12); border: 1px solid rgba(226, 52, 61, 0.35); padding: 10px 14px; border-radius: 12px; font-size: 14.5px; }
.hl { animation: hl 2.4s ease-out; border-radius: 14px; }
@keyframes hl { 0%, 30% { box-shadow: 0 0 0 3px rgba(255, 143, 58, 0.55); } }

/* ---------- empty / hero ---------- */
.hero { max-width: 780px; margin: 0 auto; padding: 8vh 16px 30px; }
.hero .flame { width: 76px; height: 76px; border-radius: 50%; }
.hero h1 { font-size: clamp(28px, 5vw, 40px); line-height: 1.15; letter-spacing: -0.025em; margin: 22px 0 10px; font-weight: 800; }
.hero h1 span { background: var(--fire); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lead { color: var(--muted); font-size: 17px; margin: 0 0 26px; max-width: 560px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 30px; }
.hero-actions .btn { padding: 14px 20px; }
.chips-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--dim); font-weight: 600; margin: 0 0 12px; }
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.chip { text-align: left; padding: 14px 16px; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--line); transition: border-color 0.15s, transform 0.1s, background 0.15s; }
.chip:hover { border-color: rgba(255, 143, 58, 0.45); background: var(--bg-3); }
.chip:active { transform: scale(0.98); }
.chip b { display: block; font-size: 15px; margin-bottom: 2px; }
.chip small { display: block; color: var(--dim); font-size: 13px; line-height: 1.45; }
.quote { margin-top: 30px; padding: 16px 18px; border-radius: 14px; background: var(--fire-soft); border: 1px solid rgba(255, 143, 58, 0.22); color: var(--quote-text); font-style: italic; }
.quote small { display: block; font-style: normal; color: var(--dim); margin-top: 6px; font-size: 12.5px; }

/* ---------- composer ---------- */
.composer { padding: 10px 12px calc(12px + var(--safe-b)); background: linear-gradient(to top, var(--bg) 70%, transparent); }
.composer-in { max-width: 780px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 22px; padding: 6px; transition: border-color 0.15s; }
.composer-in:focus-within { border-color: rgba(255, 143, 58, 0.55); }
.composer textarea { flex: 1; resize: none; border: 0; outline: none; background: transparent; padding: 9px 6px 9px 12px; max-height: 200px; min-height: 42px; line-height: 1.5; font-size: 16px; }
.composer .c-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); flex: none; transition: background 0.15s, color 0.15s; }
.composer .c-btn:hover { background: var(--bg-4); color: var(--text); }
.composer .c-btn.send { background: var(--fire); color: #1a0d05; }
.composer .c-btn.send:disabled { background: var(--bg-4); color: var(--dim); }
.composer .c-btn.rec { background: var(--crimson); color: #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(226, 52, 61, 0.55); } 70% { box-shadow: 0 0 0 12px rgba(226, 52, 61, 0); } 100% { box-shadow: 0 0 0 0 rgba(226, 52, 61, 0); } }
.composer-hint { max-width: 780px; margin: 6px auto 0; color: var(--dim); font-size: 12px; text-align: center; min-height: 1em; }
.composer-hint:empty { display: none; }
/* Bàn phím đang mở (iPhone): ô soạn sát bàn phím, không chừa đệm mép dưới màn hình */
html.kb .composer { padding-top: 6px; padding-bottom: 6px; }
.session-bar { max-width: 780px; margin: 0 auto 8px; display: flex; justify-content: center; }

/* ---------- pages (journey / commitments / settings / search) ---------- */
.page { max-width: 900px; margin: 0 auto; padding: 22px 16px calc(40px + var(--safe-b)); }
.page h2 { font-size: 26px; letter-spacing: -0.02em; margin: 4px 0 6px; font-weight: 800; }
.page .sub { color: var(--muted); margin: 0 0 22px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card h3 .ico { color: var(--ember-2); }
.card .big { font-size: 17px; line-height: 1.55; }
.empty-txt { color: var(--dim); font-size: 14.5px; font-style: italic; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 28px; font-weight: 800; line-height: 1.1; background: var(--fire); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat small { color: var(--dim); font-size: 12.5px; }
.list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.list li { padding-left: 18px; position: relative; font-size: 15px; }
.list li::before { content: ''; position: absolute; left: 2px; top: 0.62em; width: 7px; height: 7px; border-radius: 50%; background: var(--ember-2); }
.list.neg li::before { background: var(--dim); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { padding: 5px 12px; border-radius: 99px; background: var(--bg-4); border: 1px solid var(--line-2); font-size: 14px; }
.tag.on { background: var(--fire-soft); border-color: rgba(255, 143, 58, 0.45); color: var(--gold); font-weight: 600; }
.wheel-wrap { display: grid; grid-template-columns: 300px 1fr; gap: 18px; align-items: center; }
.wheel svg { width: 100%; height: auto; display: block; }
.areas { display: grid; gap: 10px; }
.area { font-size: 14.5px; }
.area b { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.area b span { color: var(--gold); }
.area p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.bar { height: 5px; background: var(--bg-4); border-radius: 99px; margin-top: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--fire); border-radius: 99px; }
.timeline { display: grid; gap: 12px; }
.tl { display: grid; grid-template-columns: 92px 1fr; gap: 12px; font-size: 14.5px; }
.tl time { color: var(--dim); font-size: 12.5px; padding-top: 2px; }
.tl .kind { display: inline-block; font-size: 11.5px; font-weight: 600; color: var(--gold); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px; }
.tl a { color: var(--dim); font-size: 12.5px; text-decoration: none; }
.tl a:hover { color: var(--gold); }
textarea.input { resize: vertical; min-height: 120px; line-height: 1.55; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.commit { display: flex; gap: 12px; align-items: flex-start; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.commit:last-child { border-bottom: 0; }
.check { width: 40px; height: 40px; display: grid; place-items: center; flex: none; margin: -7px -7px -7px -7px; color: transparent; }
.check i { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line-2); display: grid; place-items: center; transition: all 0.15s; color: inherit; }
.check:hover i { border-color: var(--ember-2); }
.commit.done .check { color: #06210f; }
.commit.done .check i { background: var(--ok); border-color: var(--ok); }
.commit.done .c-text { color: var(--dim); text-decoration: line-through; }
.c-body { flex: 1; min-width: 0; }
.c-text { font-size: 15.5px; }
.c-meta { color: var(--dim); font-size: 12.5px; margin-top: 2px; }
.c-meta .due-late { color: var(--err); }
.seg { display: inline-flex; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { padding: 8px 14px; border-radius: 9px; color: var(--muted); font-weight: 500; font-size: 14.5px; min-height: 40px; }
.seg button.on { background: var(--bg-4); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset; }
.field { display: grid; gap: 8px; margin-bottom: 18px; }
.field > label { font-weight: 600; font-size: 14.5px; }
.field > small { color: var(--dim); font-size: 13px; margin-top: -4px; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
input[type='range'] { width: 100%; accent-color: var(--ember); }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--bg-4); border: 1px solid var(--line-2); border-radius: 99px; transition: 0.2s; }
.switch span::after { content: ''; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%; background: var(--muted); transition: 0.2s; }
.switch input:checked + span { background: var(--ember); border-color: var(--ember); }
.switch input:checked + span::after { transform: translateX(20px); background: #fff; }
table.usage { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.usage td, table.usage th { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.usage th { color: var(--dim); font-weight: 500; }
table.usage td.n { text-align: right; font-variant-numeric: tabular-nums; }
.result { display: block; width: 100%; text-align: left; padding: 14px 16px; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--line); margin-bottom: 10px; }
.result:hover { border-color: rgba(255, 143, 58, 0.4); }
.result small { color: var(--dim); font-size: 12.5px; display: block; margin-bottom: 4px; }
.result mark { background: rgba(255, 195, 90, 0.3); color: var(--mark-text); border-radius: 3px; padding: 0 2px; }

/* ---------- công cụ của Tony ---------- */
.tool-group { margin: 26px 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--gold); font-weight: 700; }
.tool-group:first-of-type { margin-top: 6px; }
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.tool-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; transition: border-color 0.15s; }
.tool-card:hover { border-color: rgba(255, 143, 58, 0.4); }
.tc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.tc-head b { font-size: 15.5px; }
.tc-head span { color: var(--dim); font-size: 12px; white-space: nowrap; }
.tool-card p { margin: 0 0 4px; color: var(--muted); font-size: 13.5px; line-height: 1.5; flex: 1; }
.tool-card .row { gap: 8px; }

/* ---------- thông báo đẩy ---------- */
.push-hint { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; margin: -12px 0 26px; border-radius: 14px; background: var(--fire-soft); border: 1px solid rgba(255, 143, 58, 0.3); }
.push-hint .ico { color: var(--gold); }
.ph-text { flex: 1; min-width: 0; }
.ph-text b { display: block; font-size: 15px; }
.ph-text small { display: block; color: var(--muted); font-size: 13px; line-height: 1.45; }
.ios-guide { display: flex; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--bg-3); border: 1px solid var(--line-2); font-size: 14.5px; line-height: 1.5; margin-bottom: 14px; }
.ios-guide .ico { color: var(--gold); margin-top: 2px; }
.push-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dim); flex: none; }
.push-dot.on { background: var(--ok); box-shadow: 0 0 10px rgba(79, 209, 139, 0.6); }
.slots { display: grid; gap: 8px; }
.slot-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.slot-name { flex: 1; min-width: 0; }
.slot-name b { display: block; font-size: 15px; }
.slot-name small { color: var(--dim); font-size: 12.5px; }
.input.time { width: 116px; padding: 9px 10px; text-align: center; }
.push-log { display: grid; gap: 10px; margin-top: 10px; font-size: 14px; }
.push-log small { display: block; color: var(--dim); font-size: 12px; }

/* ---------- summary card (tổng kết phiên) ---------- */
.summary-card { border: 1px solid rgba(255, 143, 58, 0.35); background: linear-gradient(180deg, rgba(255, 106, 43, 0.09), rgba(20, 17, 23, 0.6)); border-radius: 18px; padding: 18px; }
.summary-card h4 { margin: 0 0 8px; display: flex; align-items: center; gap: 8px; color: var(--gold); font-size: 15px; }
.summary-card p { margin: 0 0 10px; }
.summary-card .ins { display: grid; gap: 6px; margin-top: 8px; }
.summary-card .ins div { font-size: 14.5px; }
.summary-card .ins span { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ember-2); margin-right: 6px; }

/* ---------- menu popover ---------- */
.pop { position: absolute; right: 12px; top: 56px; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; z-index: 30; min-width: 220px; }
.pop button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px; color: var(--text); font-size: 14.5px; text-align: left; }
.pop button:hover { background: var(--bg-4); }
.pop button.danger { color: var(--err); }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translateX(-50%); background: var(--bg-4); border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); z-index: 100; font-size: 14.5px; max-width: calc(100% - 32px); animation: rise 0.2s ease-out; }

/* ---------- VOICE MODE ---------- */
.voice { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background:
  radial-gradient(900px 600px at 50% 38%, rgba(255, 106, 43, 0.14), transparent 65%), var(--overlay-bg); padding: calc(12px + var(--safe-t)) 16px calc(18px + var(--safe-b)); animation: fadein 0.25s ease-out; }
@keyframes fadein { from { opacity: 0; } }
.voice-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.voice-top .vt { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.voice-top .vt b { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voice-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; min-height: 0; }
.orb { width: min(58vw, 260px); aspect-ratio: 1; border-radius: 50%; position: relative; display: grid; place-items: center; cursor: pointer; }
.orb .core { position: absolute; inset: 14%; border-radius: 50%; background: radial-gradient(circle at 38% 32%, #ffe0a6 0%, #ffb347 18%, #ff6a2b 45%, #c8212f 78%, #4a0a12 100%); box-shadow: 0 0 60px rgba(255, 106, 43, 0.55), inset 0 -10px 40px rgba(0, 0, 0, 0.35); transition: transform 0.08s linear; }
.orb .ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(255, 143, 58, 0.35); }
.orb .ring.r2 { inset: -9%; border-color: rgba(255, 143, 58, 0.16); }
.orb img { position: relative; width: 34%; height: 34%; opacity: 0; }
.voice[data-state='listening'] .orb .core { background: radial-gradient(circle at 38% 32%, #fff3d6 0%, #ffd27a 22%, #ff8f3a 55%, #b52032 100%); }
.voice[data-state='listening'] .ring { animation: ripple 1.8s ease-out infinite; }
.voice[data-state='listening'] .ring.r2 { animation-delay: 0.6s; }
@keyframes ripple { 0% { transform: scale(0.92); opacity: 1; } 100% { transform: scale(1.25); opacity: 0; } }
.voice[data-state='thinking'] .orb .core { animation: think 1.3s ease-in-out infinite; }
@keyframes think { 50% { transform: scale(0.92); filter: brightness(1.25) saturate(1.2); } }
.voice[data-state='paused'] .orb .core { filter: grayscale(0.75) brightness(0.6); }
.voice[data-state='transcribing'] .orb .core { animation: think 0.9s ease-in-out infinite; }
.v-status { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; text-align: center; min-height: 1.4em; }
.v-hint { color: var(--dim); font-size: 14px; text-align: center; margin-top: -18px; min-height: 1.3em; }
.v-caption { max-width: 640px; width: 100%; text-align: center; color: var(--caption); font-size: 18px; line-height: 1.55; min-height: 5.2em; max-height: 34vh; overflow-y: auto; padding: 0 6px; }
.v-caption .you { color: var(--muted); font-size: 15.5px; display: block; margin-bottom: 10px; }
.v-caption .you::before { content: 'Thủy: '; color: var(--dim); }
.voice-ctrl { display: flex; justify-content: center; align-items: center; gap: 22px; }
.vbtn { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-4); border: 1px solid var(--line-2); color: var(--text); }
.vbtn.big { width: 76px; height: 76px; background: var(--fire); color: #1a0d05; border: 0; box-shadow: 0 8px 30px rgba(255, 106, 43, 0.35); }
.vbtn.end { background: var(--end-bg); border-color: var(--end-line); color: var(--end-text); }
.vbtn .ico { width: 26px; height: 26px; }
.vlabel { display: grid; justify-items: center; gap: 6px; font-size: 12px; color: var(--dim); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 320px); z-index: 40; transform: translateX(-102%); transition: transform 0.25s ease; box-shadow: var(--shadow); }
  .shell.drawer .sidebar { transform: none; }
  .sidebar { pointer-events: none; } /* đang trượt ra thì không nuốt cú chạm của nội dung bên dưới */
  .shell.drawer .sidebar { pointer-events: auto; }
  .shell.drawer .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 35; }
  .top .menu { display: grid; }
  .side-close { display: grid; }
  .voice-cta span { display: none; }
  .voice-cta { padding: 0; width: 44px; height: 44px; justify-content: center; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two { grid-template-columns: 1fr; }
  .wheel-wrap { grid-template-columns: 1fr; }
  .wheel { max-width: 300px; margin: 0 auto; }
  .hero { padding-top: 5vh; }
  .chips { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  /* Màn nhỏ: hai nút chính phải thấy ngay, không phải cuộn */
  .hero { padding: 18px 16px 28px; }
  .hero .flame { display: none; }
  .hero h1 { font-size: 26px; margin: 4px 0 8px; }
  .hero p.lead { font-size: 15px; margin-bottom: 18px; }
  .seg { display: flex; width: 100%; }
  .seg button { flex: 1; }
  .chips { grid-template-columns: 1fr; }
  .chip { padding: 12px 14px; }
  .hero-actions .btn { flex: 1; }
  .tl { grid-template-columns: 1fr; gap: 2px; }
}
/* ---------- Câu khẳng định (incantations) ---------- */
.inc-today { position: relative; overflow: hidden; border-radius: 20px; padding: 22px 20px 18px; margin-bottom: 14px; border: 1px solid rgba(255, 143, 58, 0.35);
  background: radial-gradient(520px 260px at 0% 0%, rgba(255, 106, 43, 0.22), transparent 70%), radial-gradient(420px 240px at 100% 100%, rgba(226, 52, 61, 0.18), transparent 70%), var(--bg-2); }
.inc-today-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--gold); font-weight: 700; }
.inc-today-top span:last-child { color: var(--dim); font-weight: 600; }
.inc-big { font-size: clamp(22px, 4.6vw, 30px); line-height: 1.3; font-weight: 800; letter-spacing: -0.015em; margin: 12px 0 8px; overflow-wrap: anywhere; }
.inc-en { color: var(--dim); font-size: 14px; font-style: italic; line-height: 1.5; overflow-wrap: anywhere; }
.inc-acts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.inc-acts.center { justify-content: center; }
.inc-stats { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px; font-size: 13.5px; color: var(--muted); }
.inc-stats b { color: var(--gold); }
.inc-how { margin-bottom: 14px; }
.inc-how summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 8px; min-height: 40px; list-style: none; }
.inc-how summary::-webkit-details-marker { display: none; }
.inc-how summary .ico { color: var(--ember-2); }
.inc-how ol { margin: 10px 0 2px; padding-left: 20px; display: grid; gap: 8px; color: var(--muted); font-size: 15px; }
.inc-block { margin-bottom: 6px; }
.inc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.inc-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 6px; min-width: 0; transition: border-color 0.15s; }
.inc-block .inc-card { background: var(--bg-3); }
.inc-card:hover { border-color: rgba(255, 143, 58, 0.4); }
.inc-vi { font-size: 17px; font-weight: 700; line-height: 1.45; overflow-wrap: anywhere; }
.inc-src { font-size: 12.5px; color: var(--dim); line-height: 1.45; }
.inc-kind { display: inline-block; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line-2); color: var(--muted); font-size: 11.5px; margin-right: 4px; }
.inc-kind.k-tony { border-color: rgba(255, 143, 58, 0.5); color: var(--gold); }
.inc-card .inc-acts { margin-top: auto; padding-top: 6px; }
.inc-fav .ico path { transition: fill 0.15s; }
.inc-fav.on { color: var(--ember); }
.inc-fav.on .ico path { fill: currentColor; }
.tool-group .ico { display: inline-block; vertical-align: -2px; color: var(--ember); }
.fine-print { color: var(--dim); font-size: 12.5px; margin: 22px 0 0; line-height: 1.5; }
/* Chế độ luyện toàn màn hình */
.incp { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: calc(16px + var(--safe-t)) 16px calc(20px + var(--safe-b)); overflow-y: auto;
  background-color: var(--overlay-bg); background-image: radial-gradient(700px 500px at 50% 20%, rgba(255, 106, 43, 0.25), transparent 70%); }
.incp-x { position: absolute; top: calc(10px + var(--safe-t)); right: 10px; }
.incp-in { width: 100%; max-width: 560px; text-align: center; }
.incp-k { display: block; color: var(--gold); text-transform: uppercase; letter-spacing: 0.1em; font-size: 12px; font-weight: 700; margin-bottom: 16px; }
.incp-text { font-size: clamp(26px, 6.4vw, 40px); line-height: 1.25; font-weight: 800; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.incp .inc-en { margin-top: 10px; }
.incp-count { margin: 26px auto 10px; width: 156px; height: 156px; border-radius: 50%; display: grid; place-content: center; gap: 0; background: var(--fire); color: #1a0d05;
  box-shadow: 0 0 0 10px rgba(255, 106, 43, 0.12), 0 14px 50px rgba(255, 106, 43, 0.35); transition: transform 0.12s; }
.incp-count b { font-size: 52px; line-height: 1; font-weight: 800; }
.incp-count span { font-size: 15px; font-weight: 700; opacity: 0.75; }
.incp-count small { font-size: 11.5px; font-weight: 600; opacity: 0.8; max-width: 110px; line-height: 1.3; margin-top: 4px; }
.incp.hit .incp-count { animation: incHit 0.22s ease-out; }
@keyframes incHit { 40% { transform: scale(1.08); } }
.incp-tip { color: var(--muted); font-size: 15px; max-width: 420px; margin: 10px auto 4px; }
@media (max-width: 480px) {
  .inc-grid { grid-template-columns: 1fr; }
  .inc-today { padding: 18px 16px 16px; }
  .inc-today .inc-acts .btn { flex: 1 1 auto; }
}
/* ---------- Trình dẫn Priming ---------- */
.prm { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; overflow-y: auto; padding: calc(16px + var(--safe-t)) 16px calc(20px + var(--safe-b));
  background-color: var(--overlay-bg); background-image: radial-gradient(760px 520px at 50% 18%, rgba(255, 106, 43, 0.22), transparent 70%); }
.prm-x { position: absolute; top: calc(10px + var(--safe-t)); right: 10px; }
.prm-in { width: 100%; max-width: 520px; text-align: center; display: grid; gap: 12px; }
.prm-in h2 { margin: 4px 0 0; font-size: clamp(24px, 6vw, 32px); font-weight: 800; letter-spacing: -0.02em; }
.prm-logo { width: 84px; height: 84px; border-radius: 50%; margin: 0 auto; }
.prm-sub { margin: 0; color: var(--muted); }
.prm-tip { margin: 2px 0; color: var(--dim); font-size: 14px; line-height: 1.55; }
.prm-len { margin: 6px auto 0; }
.prm-prep { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 14px; min-height: 40px; }
.prm-prep.ok { color: var(--ok); }
.prm-go { margin-top: 4px; }
.dot-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--ember); animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.prm-steps { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.prm-steps span { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 99px; background: var(--bg-3); border: 1px solid var(--line); color: var(--dim); font-size: 12.5px; }
.prm-steps b { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-4); font-size: 11.5px; }
.prm-steps span.on { color: var(--gold); border-color: rgba(255, 143, 58, 0.5); }
.prm-steps span.on b { background: var(--fire); color: #1a0d05; }
.prm-steps span.done { color: var(--muted); }
.prm-steps span.done b { background: rgba(79, 209, 139, 0.2); color: var(--ok); }
.prm-orb { --s: 1; width: min(230px, 62vw); aspect-ratio: 1; margin: 18px auto 6px; border-radius: 50%; display: grid; place-content: center; text-align: center; padding: 20px;
  background: radial-gradient(circle at 50% 40%, rgba(255, 195, 90, 0.28), rgba(226, 52, 61, 0.14) 62%, transparent 72%); border: 1px solid rgba(255, 143, 58, 0.35);
  animation: prmBreath 8s ease-in-out infinite; }
.prm-orb b { font-size: clamp(20px, 5.4vw, 26px); font-weight: 800; line-height: 1.2; }
.prm-orb small { color: var(--muted); font-size: 13px; margin-top: 4px; }
.prm-orb.beat { animation: none; transform: scale(var(--s)); background: var(--fire); border-color: transparent; color: #1a0d05; box-shadow: 0 0 60px rgba(255, 106, 43, 0.4); }
.prm-orb.beat b { font-size: 64px; }
.prm-orb.beat small { color: rgba(26, 13, 5, 0.75); }
@keyframes prmBreath { 50% { transform: scale(1.06); } }
.prm-cap { min-height: 4.8em; margin: 4px 0; color: var(--text); font-size: 16px; line-height: 1.6; }
.prm-bar { height: 5px; border-radius: 99px; background: var(--bg-4); overflow: hidden; }
.prm-bar i { display: block; height: 100%; width: 0; background: var(--fire); }
.prm-time { display: flex; justify-content: space-between; color: var(--dim); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.prm-ctrl { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin-top: 4px; }
.prm-ctrl > :first-child { justify-self: start; }
.prm-ctrl > :last-child { justify-self: end; }
.prm-play { width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center; background: var(--fire); color: #1a0d05; box-shadow: 0 10px 34px rgba(255, 106, 43, 0.35); }
.prm-play .ico { width: 28px; height: 28px; }
.prm-done { width: 76px; height: 76px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; background: var(--fire); color: #1a0d05; }
.prm-done .ico { width: 36px; height: 36px; }
.prm-lbl { text-align: left; font-weight: 600; font-size: 14.5px; margin-top: 8px; }
.prm-lbl small { display: block; font-weight: 400; color: var(--dim); }
/* ---------- Phản hồi khi chạm ---------- */
button:not(:disabled):active, .btn:not(:disabled):active, .chip:active, .sess:active { filter: brightness(1.3); }
.icon-btn:active { background: var(--bg-3); }
.dot-spin.sm { width: 12px; height: 12px; border-width: 2px; vertical-align: -1px; }
.say-loading { color: var(--gold) !important; }
.say-playing { color: var(--ember-2) !important; border-color: rgba(255, 143, 58, 0.55) !important; animation: sayPulse 1.6s ease-in-out infinite; }
@keyframes sayPulse { 50% { box-shadow: 0 0 0 4px rgba(255, 106, 43, 0.18); } }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy .ico { opacity: 0; }
.btn.busy::after { content: ''; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(127, 127, 127, 0.45); border-top-color: var(--ember); animation: spin 0.8s linear infinite; }
.btn.fire.busy::after { border-color: rgba(26, 13, 5, 0.3); border-top-color: #1a0d05; }
/* ---------- Lịch sử phiên ---------- */
.sess-all { display: flex; align-items: center; gap: 8px; width: 100%; padding: 12px; margin-top: 6px; border-radius: 10px; color: var(--gold); font-size: 14px; font-weight: 600; min-height: 44px; }
.sess-all:hover { background: var(--bg-3); }
.hist-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.hist-search { margin: 0; flex: 1 1 240px; }
.hist-n { color: var(--dim); font-weight: 600; margin-left: 4px; }
.hist-grid { display: grid; gap: 10px; }
.hist { display: block; text-decoration: none; color: inherit; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; transition: border-color 0.15s; }
.hist:hover { border-color: rgba(255, 143, 58, 0.4); }
.hist:active { filter: brightness(1.15); }
.hist-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.hist-top b { font-size: 16.5px; font-weight: 700; line-height: 1.35; min-width: 0; }
.hist-top time { flex: none; font-size: 12.5px; color: var(--dim); }
.hist-meta { margin-top: 3px; font-size: 13px; color: var(--gold); }
.hist p { margin: 8px 0 0; color: var(--muted); font-size: 14.5px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 480px) {
  .hist-tools .seg { width: 100%; }
}
/* Màn hình cảm ứng: vùng chạm tối thiểu 44px */
@media (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; }
  .composer .c-btn { width: 44px; height: 44px; }
  .tools button { padding: 9px 10px; }
  .nav button { padding: 12px; }
  .sess { padding: 11px 12px; }
  .btn.sm { padding: 10px 14px; }
}
@media (max-width: 380px) {
  .hero-actions { flex-direction: column; }
  .hero-actions .btn { width: 100%; }
  .hero h1 { font-size: 24px; }
  .hero p.lead { font-size: 14.5px; }
  .page h2 { font-size: 23px; }
  .stat b { font-size: 24px; }
  .voice-ctrl { gap: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
