/* Lộ Trình — vở ô li, mực xanh, dấu bút cam. Tối giản, ưu tiên hình ảnh, tối ưu cho iPhone. */
@font-face { font-family: "Fira"; src: url(../fonts/fira-Light.woff) format("woff"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Fira"; src: url(../fonts/fira-Regular.woff) format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Fira"; src: url(../fonts/fira-Medium.woff) format("woff"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Fira"; src: url(../fonts/fira-SemiBold.woff) format("woff"); font-weight: 600 700; font-display: swap; }

:root {
  --bg: #F4F7FC; --surface: #FFFFFF; --surface-2: #EDF1F9; --press: rgba(27, 56, 199, .07);
  --ink: #0F1B3D; --muted: #66728F; --line: #E1E7F2;
  --brand: #1F3FD0; --on-brand: #FFFFFF; --band: #1B38C7; --on-band: #FFFFFF; --on-band-2: rgba(255, 255, 255, .74);
  --mark: #FF7A2F;
  --good: #11994A; --warn: #B87800; --bad: #D93A45; --violet: #6E4BE0; --muted-tone: #66728F;
  --grid: rgba(31, 63, 208, .11); --area: rgba(31, 63, 208, .10);
  --sh: 0 18px 40px -18px rgba(15, 27, 61, .35);
  --ease: cubic-bezier(.22, .9, .24, 1); --spring: cubic-bezier(.34, 1.4, .5, 1);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --tabbar: 58px; --kb: 0px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A0F1F; --surface: #111A33; --surface-2: #19234A; --press: rgba(140, 160, 255, .09);
    --ink: #EAF0FF; --muted: #93A0C4; --line: #1F2B52;
    --brand: #8FA4FF; --on-brand: #0A0F1F; --band: #0E1838; --mark: #FF8A45;
    --good: #3DD68C; --warn: #F2B93B; --bad: #FF7B84; --violet: #AD97FF; --muted-tone: #93A0C4;
    --grid: rgba(143, 164, 255, .10); --area: rgba(143, 164, 255, .13);
    --sh: 0 18px 40px -18px rgba(0, 0, 0, .7); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A0F1F; --surface: #111A33; --surface-2: #19234A; --press: rgba(140, 160, 255, .09);
  --ink: #EAF0FF; --muted: #93A0C4; --line: #1F2B52;
  --brand: #8FA4FF; --on-brand: #0A0F1F; --band: #0E1838; --mark: #FF8A45;
  --good: #3DD68C; --warn: #F2B93B; --bad: #FF7B84; --violet: #AD97FF; --muted-tone: #93A0C4;
  --grid: rgba(143, 164, 255, .10); --area: rgba(143, 164, 255, .13);
  --sh: 0 18px 40px -18px rgba(0, 0, 0, .7); color-scheme: dark;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--ink); }
body { font: 400 16px/1.42 "Fira", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; overscroll-behavior: none; touch-action: manipulation; }
html.lock, html.lock body { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.i { flex: none; display: block; }
b, strong { font-weight: 600; }
:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 2px; border-radius: 8px; }
.num { font-feature-settings: "tnum", "lnum"; }

/* ===== Khung ứng dụng ===== */
#app { position: fixed; inset: 0; overflow: hidden; }
#stack { position: absolute; inset: 0; }
.screen { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; background: var(--bg); }
.screen.top { z-index: 3; }
.screen.enter-push { animation: pushIn .46s var(--ease) both; box-shadow: -14px 0 30px -12px rgba(0, 0, 0, .28); }
.screen.leave-push { animation: pushOut .46s var(--ease) both; }
.screen.enter-pop { animation: popIn .46s var(--ease) both; }
.screen.leave-pop { animation: popOut .46s var(--ease) both; box-shadow: -14px 0 30px -12px rgba(0, 0, 0, .28); }
.screen.enter-fade { animation: fadeIn .26s ease-out both; }
.screen.leave-fade { animation: fadeOut .18s ease-in both; }
@keyframes pushIn { from { transform: translateX(100%); } to { transform: none; } }
@keyframes pushOut { to { transform: translateX(-26%); opacity: .55; } }
@keyframes popIn { from { transform: translateX(-26%); opacity: .55; } to { transform: none; opacity: 1; } }
@keyframes popOut { to { transform: translateX(100%); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fadeOut { to { opacity: 0; } }

/* Thanh trên + dải xanh mực */
.bar { position: sticky; top: 0; z-index: 6; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: calc(48px + var(--safe-t)); padding: var(--safe-t) 8px 0; background: var(--band); color: var(--on-band); transition: box-shadow .25s; }
.bar.on { box-shadow: 0 10px 22px -12px rgba(4, 10, 60, .65); }
.bar .l { display: flex; align-items: center; justify-self: start; }
.bar .r { display: flex; align-items: center; justify-self: end; }
.bar .ttl { max-width: 56vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 17px; opacity: 0; transform: translateY(5px); transition: opacity .22s, transform .3s var(--ease); }
.bar.on .ttl { opacity: 1; transform: none; }
.icon-btn { min-width: 44px; height: 44px; padding: 0 10px; border-radius: 22px; display: inline-flex; align-items: center; justify-content: center; gap: 2px; border: 0; background: transparent; color: inherit; transition: background .15s, transform .15s; font-weight: 500; font-size: 16px; }
.icon-btn:active { background: rgba(255, 255, 255, .16); transform: scale(.94); }
.icon-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mark); position: absolute; margin: -14px -14px 0 0; }
.bar .brandmark { display: flex; align-items: center; gap: 9px; padding-left: 10px; font-weight: 600; font-size: 17px; letter-spacing: -.01em; }
.bar .brandmark svg { width: 26px; height: 26px; border-radius: 8px; }

.hero { background: var(--band); color: var(--on-band); padding: 0 20px 26px; border-radius: 0 0 30px 30px; position: relative; }
.hero .kick { font-size: 14px; color: var(--on-band-2); margin-bottom: 2px; }
.hero h1 { font-size: 32px; line-height: 1.12; font-weight: 600; letter-spacing: -.022em; text-wrap: balance; }
.hero .sub { margin-top: 8px; font-size: 15px; line-height: 1.45; color: var(--on-band-2); max-width: 36em; }
.hero .chip { background: rgba(255, 255, 255, .17); color: #fff; }
.body { padding: 6px 16px calc(var(--tabbar) + var(--safe-b) + 40px); }
.body > :first-child { margin-top: 18px; }

/* Đường lộ trình trong hero */
.route { width: 100%; height: auto; display: block; margin: 14px 0 4px; overflow: visible; }
.route .track { fill: none; stroke: rgba(255, 255, 255, .26); stroke-width: 5; stroke-linecap: round; }
.route .prog { fill: none; stroke: #fff; stroke-width: 5; stroke-linecap: round; }
.route .start { fill: var(--band); stroke: #fff; stroke-width: 3.5; }
.route .flag { fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.route .flagfill { fill: rgba(255, 255, 255, .92); }
.route .mk { fill: var(--mark); stroke: #fff; stroke-width: 3.5; }
.route .halo { fill: rgba(255, 122, 47, .28); }
.hline { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; font-size: 14px; color: var(--on-band-2); }
.hline span { display: inline-flex; align-items: center; gap: 6px; }
.hline b { color: #fff; font-weight: 500; font-size: 16px; }

/* ===== Thanh tab ===== */
#tabbar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(var(--tabbar) + var(--safe-b)); padding-bottom: var(--safe-b); display: grid; grid-template-columns: repeat(5, 1fr); background: color-mix(in srgb, var(--surface) 84%, transparent); -webkit-backdrop-filter: saturate(1.7) blur(20px); backdrop-filter: saturate(1.7) blur(20px); border-top: 1px solid var(--line); transition: transform .35s var(--ease); }
#tabbar.hidden { transform: translateY(160%); visibility: hidden; transition: transform .35s var(--ease), visibility 0s .35s; }
.tab { text-decoration: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 500; padding: 0; transition: color .2s; }
.tab .ic { position: relative; transition: transform .35s var(--spring); }
.tab[aria-current="page"] { color: var(--brand); }
.tab[aria-current="page"] .ic { transform: translateY(-1px) scale(1.08); }
.tab:active .ic { transform: scale(.88); }
.tab.add { color: var(--ink); }
.tab.add .fab { width: 54px; height: 54px; margin-top: -26px; border-radius: 50%; display: grid; place-items: center; background: var(--mark); color: #fff; box-shadow: 0 10px 22px -8px rgba(255, 122, 47, .7), 0 0 0 5px var(--bg); transition: transform .3s var(--spring); }
.tab.add:active .fab { transform: scale(.9) rotate(90deg); }
.badge { position: absolute; top: -5px; right: -9px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; display: grid; place-items: center; background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 600; border: 2px solid var(--surface); }

/* ===== Nhóm / dòng ===== */
.sec { margin: 28px 6px 9px; font-size: 14px; font-weight: 600; color: var(--muted); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sec button { border: 0; background: none; color: var(--brand); font-weight: 500; font-size: 14px; padding: 4px 2px; }
.group { background: var(--surface); border-radius: 20px; overflow: hidden; border: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 12px 14px; text-align: left; border: 0; background: none; position: relative; text-decoration: none; color: inherit; transition: background .15s; }
.row + .row::before { content: ""; position: absolute; top: 0; right: 0; left: 14px; height: 1px; background: var(--line); }
.group.lead .row + .row::before { left: 64px; }
button.row:active, a.row:active { background: var(--press); }
.row .lead { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--brand); flex: none; }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 500; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { font-size: 13.5px; color: var(--muted); margin-top: 1px; }
.row .s.wrap { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row .end { display: flex; align-items: center; gap: 8px; color: var(--muted); flex: none; font-size: 15px; }
.row .val { color: var(--ink); font-weight: 500; font-size: 17px; }
.row.danger, .row.danger .lead { color: var(--bad); }
.row.add .lead { background: transparent; border: 1.5px dashed var(--line); color: var(--brand); }
.row.add .t { color: var(--brand); }
.unread::after { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--mark); flex: none; }
.row.unread::after { position: absolute; right: 14px; top: 16px; }

.t-good { --tc: var(--good); } .t-warn { --tc: var(--warn); } .t-bad { --tc: var(--bad); }
.t-violet { --tc: var(--violet); } .t-brand { --tc: var(--brand); } .t-muted { --tc: var(--muted-tone); }
.chip, .glyph { --tb: color-mix(in srgb, var(--tc, var(--brand)) 14%, transparent); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px 5px 8px; border-radius: 99px; background: var(--tb); color: var(--tc); font-size: 13.5px; font-weight: 500; white-space: nowrap; }
.chip.sm { font-size: 12.5px; padding: 3px 9px 3px 6px; }
.glyph { width: var(--s, 38px); height: var(--s, 38px); border-radius: calc(var(--s, 38px) * .32); display: grid; place-items: center; background: var(--tb); color: var(--tc); flex: none; }

.bar-track { position: relative; display: block; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: visible; }
.bar-track i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--brand); transform-origin: left; }
.bar-track b { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--ink); opacity: .55; }
.fresh .bar-track i { animation: grow .9s .15s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }
.spark { color: var(--brand); flex: none; }
.spark path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark circle { fill: var(--mark); }
.spark line { stroke: var(--line); stroke-width: 2; stroke-linecap: round; }

/* ===== Nút & ô nhập ===== */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 52px; border-radius: 16px; border: 0; background: var(--brand); color: var(--on-brand); font-weight: 600; font-size: 17px; transition: transform .15s var(--spring), opacity .2s, background .2s; }
.btn:active { transform: scale(.975); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.ghost { background: var(--surface-2); color: var(--brand); }
.btn.danger { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.btn.mark { background: var(--mark); color: #fff; }
.btn.sm { height: 40px; width: auto; padding: 0 16px; border-radius: 12px; font-size: 15px; }
.linkbtn { border: 0; background: none; color: var(--brand); font-weight: 500; padding: 8px; font-size: 15px; }
.btn-row { display: flex; gap: 10px; }
.field { display: block; margin-bottom: 14px; }
.field .lab { display: block; margin: 0 3px 6px; font-size: 13.5px; color: var(--muted); font-weight: 500; }
.field .inp { display: flex; align-items: center; height: 52px; padding: 0 14px; border-radius: 14px; background: var(--surface-2); border: 1.5px solid transparent; transition: border-color .15s, background .15s; }
.field .inp:focus-within { border-color: var(--brand); background: var(--surface); }
.field input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; font-size: 17px; }
.field .suf { color: var(--muted); padding-left: 8px; font-size: 15px; }
.field .hint { display: block; margin: 6px 3px 0; font-size: 13px; color: var(--muted); }
.field.err .inp { border-color: var(--bad); }
.inp .eye { border: 0; background: none; color: var(--muted); padding: 8px; margin-right: -8px; }
.formerr { display: none; align-items: flex-start; gap: 8px; margin: 0 0 14px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); font-size: 14.5px; }
.formerr.show { display: flex; }
select.sel { width: 100%; height: 52px; padding: 0 14px; border-radius: 14px; border: 1.5px solid transparent; background: var(--surface-2); font-size: 17px; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' fill='none' stroke='%2366728F' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M1 1.5l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; }
select.sel:focus { outline: 0; border-color: var(--brand); }

.seg { display: flex; gap: 3px; padding: 3px; background: var(--surface-2); border-radius: 13px; }
.seg button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; border: 0; border-radius: 10px; background: none; color: var(--muted); font-weight: 500; font-size: 15px; transition: background .25s var(--ease), color .2s, box-shadow .25s; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(10, 20, 60, .14); }
.switch { position: relative; width: 52px; height: 32px; flex: none; border: 0; border-radius: 16px; background: var(--surface-2); transition: background .25s; box-shadow: inset 0 0 0 1px var(--line); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(10, 20, 60, .3); transition: transform .3s var(--spring); }
.switch[aria-checked="true"] { background: var(--good); box-shadow: none; }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* ===== Tấm trượt / hộp thoại / toast ===== */
#layer { position: absolute; inset: 0; z-index: 50; pointer-events: none; }
#layer > * { pointer-events: auto; }
.sheet-root, .dlg-root { position: absolute; inset: 0; }
.scrim { position: absolute; inset: 0; background: rgba(6, 12, 40, .5); opacity: 0; transition: opacity .3s; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.open > .scrim { opacity: 1; }
.sheet { position: absolute; left: 0; right: 0; bottom: var(--kb); max-height: calc(100% - var(--safe-t) - 28px - var(--kb)); display: flex; flex-direction: column; background: var(--bg); border-radius: 26px 26px 0 0; transform: translateY(104%); transition: transform .42s var(--ease); box-shadow: var(--sh); }
.sheet.tall { height: calc(100% - var(--safe-t) - 28px); }
.open > .sheet { transform: none; }
.grab { padding: 9px 0 3px; display: grid; place-items: center; touch-action: none; }
.grab i { width: 38px; height: 5px; border-radius: 3px; background: var(--line); }
.sh-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 18px 8px 20px; touch-action: none; }
.sh-head h2 { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.sh-head .x { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; }
.sh-body { padding: 6px 16px calc(var(--safe-b) + 18px); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet.actions .row.act .main { font-size: 17px; }
.dlg-root { display: grid; place-items: center; padding: 28px; opacity: 0; transition: opacity .2s; }
.dlg-root.open { opacity: 1; }
.dialog { position: relative; width: min(100%, 320px); padding: 22px 20px 14px; border-radius: 22px; background: var(--surface); text-align: center; box-shadow: var(--sh); transform: scale(.92); transition: transform .3s var(--spring); }
.dlg-root.open .dialog { transform: none; }
.dialog h3 { font-size: 18px; font-weight: 600; }
.dialog p { margin-top: 8px; color: var(--muted); font-size: 15px; }
.dialog .btns { display: flex; gap: 8px; margin-top: 18px; }
.dialog .btns button { flex: 1; height: 46px; border-radius: 13px; border: 0; background: var(--surface-2); font-weight: 500; font-size: 16px; }
.dialog .btns .primary { background: var(--brand); color: var(--on-brand); font-weight: 600; }
.dialog .btns .danger { background: var(--bad); color: #fff; font-weight: 600; }
#toast { position: absolute; left: 50%; bottom: calc(var(--tabbar) + var(--safe-b) + 18px); transform: translate(-50%, 24px) scale(.96); max-width: calc(100% - 32px); display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 16px; background: var(--ink); color: var(--bg); font-size: 15px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .25s, transform .4s var(--spring); box-shadow: var(--sh); }
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast .i { color: var(--mark); }
#toast.t-good .i { color: #3DD68C; } #toast.t-bad .i { color: #FF7B84; }
#toast button { border: 0; background: none; color: var(--mark); font-weight: 600; font-size: 15px; padding: 0 0 0 6px; }

/* ===== Biểu đồ ===== */
.chartbox { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 12px 8px 6px; touch-action: pan-y; }
.chart { display: block; width: 100%; height: auto; overflow: visible; user-select: none; -webkit-user-select: none; }
.ch-grid { stroke: var(--grid); stroke-width: 1; }
.ch-ylab, .ch-xlab { font-size: 10.5px; fill: var(--muted); font-feature-settings: "tnum"; }
.ch-line { fill: none; stroke: var(--brand); stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.ch-area { fill: var(--area); stroke: none; }
.ch-dot { fill: var(--surface); stroke: var(--brand); stroke-width: 2.2; }
.ch-last { fill: var(--mark); stroke: var(--surface); stroke-width: 2.5; }
.ch-pick { fill: none; stroke: var(--ink); stroke-width: 1.6; opacity: 0; transition: opacity .15s; }
.scrub .ch-pick { opacity: .7; }
.ch-goal { stroke: var(--good); stroke-width: 1.6; stroke-dasharray: 5 4; opacity: .85; }
.ch-goaltag rect { fill: var(--good); } .ch-goaltag text { fill: #fff; font-size: 10px; font-weight: 600; }
:root[data-theme="dark"] .ch-goaltag text { fill: #05231a; }
.ch-keep { fill: none; stroke: var(--brand); stroke-width: 2.4; stroke-dasharray: 2 6; stroke-linecap: round; }
.ch-band { fill: var(--brand); opacity: .12; }
.ch-idle { fill: none; stroke: var(--bad); stroke-width: 2; stroke-dasharray: 1 5.5; stroke-linecap: round; opacity: .9; }
.ch-now { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 4; opacity: .7; }
.fresh .ch-line.draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.1s .2s var(--ease) forwards; }
.fresh .ch-area, .fresh .ch-dots, .fresh .ch-keep, .fresh .ch-band, .fresh .ch-idle { animation: fadeIn2 .7s .7s both; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fadeIn2 { from { opacity: 0; } }
.tip { position: absolute; z-index: 2; transform: translateX(-50%); display: flex; align-items: baseline; gap: 6px; padding: 6px 10px; border-radius: 12px; background: var(--ink); color: var(--bg); white-space: nowrap; font-size: 12.5px; opacity: 0; pointer-events: none; transition: opacity .15s; }
.scrub .tip { opacity: 1; }
.tip b { font-size: 17px; font-weight: 600; } .tip em { font-style: normal; font-weight: 600; } .tip em.up { color: #3DD68C; } .tip em.dn { color: #FF7B84; } .tip span { opacity: .75; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 10px 6px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 18px; height: 0; border-top: 2.5px solid var(--brand); }
.legend i.k { border-top-style: dotted; } .legend i.n { border-top-style: dotted; border-color: var(--bad); } .legend i.g { border-color: var(--good); border-top-style: dashed; }

/* Đường cong học tập */
.curvebox { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 12px 12px 8px; }
.curve { display: block; width: 100%; height: auto; }
.cv-line { fill: none; stroke: var(--line); stroke-width: 4; stroke-linecap: round; }
.cv-lab { font-size: 10.5px; fill: var(--muted); }
.cv-dot { fill: var(--tc); stroke: var(--surface); stroke-width: 2.5; }
.curvebox p { font-size: 13.5px; color: var(--muted); padding: 2px 4px 6px; }

/* ===== Phân tích ===== */
.verdict { display: flex; gap: 14px; align-items: flex-start; padding: 16px; }
.verdict h3 { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.verdict p { margin-top: 6px; color: var(--muted); font-size: 15px; line-height: 1.5; }
.ai { padding: 16px; }
.ai .hd { display: flex; align-items: center; gap: 8px; color: var(--brand); font-weight: 600; font-size: 14.5px; }
.ai .meta { margin-left: auto; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.ai h3 { margin-top: 10px; font-size: 18px; font-weight: 600; }
.ai p { margin-top: 6px; font-size: 15.5px; line-height: 1.55; }
.ai .mood { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 14.5px; color: var(--muted); display: flex; gap: 8px; }
.ai .mood .i { color: var(--violet); margin-top: 2px; }
.ai .foot { margin-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; }
.stats > div { padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.stats > div:nth-child(odd) { border-right: 1px solid var(--line); }
.stats > div:nth-child(n+3) { border-top: 1px solid var(--line); }
.stats b { display: block; font-size: 24px; font-weight: 400; line-height: 1.1; font-feature-settings: "tnum"; }
.stats small { font-size: 12.5px; color: var(--muted); }
.stats .i { color: var(--brand); }
.strip { display: flex; gap: 6px; align-items: center; }
.strip i { width: 14px; height: 14px; border-radius: 5px; background: var(--surface-2); }
.strip i.on { background: var(--brand); }
.strip i.today { outline: 2px solid var(--mark); outline-offset: 2px; }
.rowfx { padding: 14px 16px; }
.analysis { padding: 16px; }
.analysis h3 { font-size: 19px; font-weight: 600; }
.analysis p { margin-top: 8px; font-size: 15.5px; line-height: 1.55; }
.analysis .x { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 14.5px; line-height: 1.5; color: var(--muted); }
.analysis .advice { margin-top: 12px; display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 14px; background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--ink); font-size: 15px; line-height: 1.5; }
.analysis .advice .i { color: var(--brand); margin-top: 1px; }
.scen .row .lead { color: var(--tc); background: color-mix(in srgb, var(--tc) 14%, transparent); }
.scen .vals { display: flex; gap: 14px; text-align: right; }
.scen .vals div { min-width: 44px; } .scen .vals b { display: block; font-size: 17px; font-weight: 500; color: var(--ink); font-feature-settings: "tnum"; } .scen .vals small { font-size: 11.5px; color: var(--muted); }
.delta { font-size: 13px; font-weight: 500; padding: 2px 7px; border-radius: 8px; font-feature-settings: "tnum"; }
.delta.up { color: var(--good); background: color-mix(in srgb, var(--good) 13%, transparent); }
.delta.dn { color: var(--bad); background: color-mix(in srgb, var(--bad) 13%, transparent); }
.big { font-size: 56px; font-weight: 300; letter-spacing: -.03em; line-height: 1; font-feature-settings: "tnum", "lnum"; }
.big small { font-size: 24px; font-weight: 400; opacity: .8; letter-spacing: 0; }

/* ===== Trạng thái trống ===== */
.empty { text-align: center; padding: 34px 24px 20px; }
.empty .art { width: 168px; height: auto; margin: 0 auto 12px; display: block; }
.empty h3 { font-size: 19px; font-weight: 600; }
.empty p { margin: 6px auto 18px; max-width: 28em; color: var(--muted); font-size: 15px; line-height: 1.5; }
.empty .btn { width: auto; display: inline-flex; padding: 0 24px; }
.a-paper { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; }
.a-grid path { stroke: var(--grid); stroke-width: 1.2; fill: none; }
.a-route { fill: none; stroke: var(--brand); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.a-mark { fill: var(--mark); }

/* ===== Nhập điểm ===== */
.scorebox { display: flex; align-items: baseline; justify-content: center; gap: 10px; padding: 10px 0 2px; }
.scorebox input.score { width: 7ch; min-width: 0; border: 0; background: none; outline: 0; text-align: center; font-size: 64px; font-weight: 300; color: var(--brand); letter-spacing: -.03em; font-feature-settings: "tnum", "lnum"; }
.scorebox input.score::placeholder { color: var(--line); }
.scorebox .over { display: inline-flex; align-items: baseline; gap: 6px; color: var(--muted); font-size: 22px; }
.scorebox .over input { width: 3.2ch; border: 0; border-bottom: 2px dashed var(--line); background: none; outline: 0; font-size: 22px; color: var(--ink); text-align: center; padding: 0 0 2px; }
.preview { min-height: 26px; text-align: center; color: var(--muted); font-size: 14.5px; display: flex; gap: 8px; justify-content: center; align-items: center; margin-bottom: 14px; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 14px; padding: 0 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.pill { flex: none; height: 36px; padding: 0 14px; border-radius: 18px; border: 1.5px solid var(--line); background: var(--surface); font-size: 14.5px; font-weight: 500; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; transition: all .2s; }
.pill.on { border-color: var(--brand); color: var(--brand); background: color-mix(in srgb, var(--brand) 9%, transparent); }
.more { margin: 2px 0 14px; }
.more summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 8px 2px; color: var(--brand); font-weight: 500; font-size: 15px; cursor: pointer; }
.more summary::-webkit-details-marker { display: none; }
.more[open] summary .i { transform: rotate(180deg); }
.more summary .i { transition: transform .25s; }
.more .note { font-size: 13.5px; color: var(--muted); margin: 0 2px 10px; line-height: 1.45; }

/* ===== Đăng nhập ===== */
.auth { background: var(--band); display: flex; flex-direction: column; min-height: 100%; }
.auth .top { color: #fff; padding: calc(var(--safe-t) + 28px) 24px 8px; }
.auth .logo { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.auth .logo svg { width: 44px; height: 44px; border-radius: 13px; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .25); }
.auth .tag { margin-top: 14px; font-size: 28px; line-height: 1.12; font-weight: 600; letter-spacing: -.02em; max-width: 11em; text-wrap: balance; }
.auth .panel { flex: 1; margin-top: 8px; background: var(--bg); border-radius: 30px 30px 0 0; padding: 22px 20px calc(var(--safe-b) + 28px); }
.auth .panel .seg { margin-bottom: 20px; }
.auth .alt { text-align: center; margin-top: 10px; }
.auth .note { margin-top: 14px; font-size: 13.5px; color: var(--muted); text-align: center; line-height: 1.5; }

.tipbanner { display: flex; gap: 12px; align-items: flex-start; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; }
.tipbanner .lead { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--mark) 16%, transparent); color: var(--mark); flex: none; }
.tipbanner h4 { margin: 0; font-size: 15.5px; font-weight: 600; }
.tipbanner p { margin-top: 3px; font-size: 14px; color: var(--muted); line-height: 1.45; }
.tipbanner .x { margin-left: auto; border: 0; background: none; color: var(--muted); padding: 2px; }
.steps { display: flex; flex-direction: column; gap: 12px; padding: 4px 2px 8px; }
.steps div { display: flex; gap: 12px; align-items: center; font-size: 15.5px; }
.steps .lead { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); color: var(--brand); display: grid; place-items: center; flex: none; }
.syncdot { display: inline-flex; align-items: center; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sub-note { font-size: 13px; color: var(--muted); margin: 8px 8px 0; line-height: 1.45; }
.skeleton { height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (min-width: 560px) {
  #app { max-width: 480px; margin: 0 auto; left: 0; right: 0; box-shadow: 0 0 0 1px var(--line); }
  html { background: color-mix(in srgb, var(--bg) 70%, #000 6%); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}

.pd + .pd { border-top: 1px solid var(--line); }
.pd p { margin-top: 8px; }
.row .bar-track { margin-top: 9px; }

.auth .route { max-height: 104px; margin: 6px 0 0; }

/* ---- Đánh dấu đã ôn hôm nay ---- */
.plist { display: grid; gap: 10px; }
.pcard { display: flex; align-items: center; gap: 2px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 20px; padding: 5px 12px 5px 4px; transition: border-color .3s var(--ease), background-color .3s var(--ease); }
.pcard.done { border-color: var(--good); background: color-mix(in srgb, var(--good) 7%, var(--surface)); }
.tick { width: 52px; height: 52px; flex: none; border: 0; background: none; display: grid; place-items: center; padding: 0; }
.ring { width: 30px; height: 30px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--muted) 55%, transparent); display: grid; place-items: center; transition: background-color .25s var(--ease), border-color .25s var(--ease), transform .2s var(--ease); }
.ring svg { stroke: #fff; stroke-width: 3; stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .32s var(--ease) .06s; }
.tick:active .ring { transform: scale(.9); }
.pcard.done .ring { background: var(--good); border-color: var(--good); }
.pcard.done .ring svg { stroke-dashoffset: 0; }
.tick.pop .ring { animation: ringpop .45s var(--spring); }
@keyframes ringpop { 0% { transform: scale(.8); } 55% { transform: scale(1.18); } 100% { transform: scale(1); } }
.pmain { flex: 1; min-width: 0; padding: 9px 4px; color: inherit; text-decoration: none; }
.pmain .t { font-weight: 500; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pmain .s { font-size: 13.5px; color: var(--muted); }
.pend { display: flex; align-items: center; gap: 8px; color: var(--muted); text-decoration: none; flex: none; }
.pend .val { color: var(--ink); font-weight: 500; font-size: 17px; }
.hint { margin: 10px 8px 14px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.todaypill { display: inline-flex; align-items: center; gap: 10px; margin-top: 14px; padding: 7px 14px 7px 10px; border-radius: 99px; background: rgba(255, 255, 255, .15); color: #fff; font-size: 14px; }
.todaypill .dots { display: inline-flex; gap: 4px; }
.todaypill .dots i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, .6); transition: background-color .25s, border-color .25s; }
.todaypill .dots i.on { background: #5BE59B; border-color: #5BE59B; }
/* dải 14 ngày ở trang phần con */
.rvbox { padding: 14px 12px 12px; }
.rvbox .hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 4px 10px; }
.rvbox .hd b { font-size: 15px; font-weight: 600; }
.rvbox .hd span { font-size: 13px; color: var(--muted); }
.rvgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px 0; justify-items: center; }
.rvd { display: grid; justify-items: center; gap: 3px; border: 0; background: none; padding: 0; color: var(--muted); font-size: 10.5px; }
.rvd .c { width: 34px; height: 34px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--muted) 40%, transparent); display: grid; place-items: center; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; transition: background-color .2s, border-color .2s; }
.rvd.on .c { background: var(--good); border-color: var(--good); color: #fff; }
.rvd.today .c { border-color: var(--mark); } .rvd.today.on .c { border-color: var(--good); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--mark); }
.rvd:active .c { transform: scale(.92); }

/* ---- Trò chuyện ---- */
.chat { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--bg); padding-bottom: var(--kb); }
.chat-bar { flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: calc(52px + var(--safe-t)); padding: var(--safe-t) 8px 0; background: var(--band); color: var(--on-band); }
.chat-bar .l { justify-self: start; display: flex; } .chat-bar .r { justify-self: end; display: flex; }
.chat-bar .ttl { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 17px; }
.msgs { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.m { display: flex; flex-direction: column; max-width: 86%; animation: msgin .28s var(--ease) both; }
@keyframes msgin { from { opacity: 0; transform: translateY(8px); } }
.m.u { align-self: flex-end; align-items: flex-end; }
.m .b { padding: 10px 14px; border-radius: 20px; font-size: 16px; line-height: 1.42; word-break: break-word; }
.m.u .b { background: var(--brand); color: var(--on-brand); border-bottom-right-radius: 6px; }
.m.a .b { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.m.err { align-self: center; max-width: 92%; } .m.err .b { background: color-mix(in srgb, var(--bad) 11%, var(--surface)); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); color: var(--bad); font-size: 14.5px; text-align: center; }
.acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.act { display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px 4px 8px; border-radius: 99px; font-size: 13px; background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.act.off { background: var(--surface-2); color: var(--muted); }
.typing .b { display: flex; gap: 5px; padding: 14px 16px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: dotb 1.1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dotb { 0%, 70%, 100% { opacity: .3; transform: none; } 35% { opacity: 1; transform: translateY(-3px); } }
.sugs { flex: none; display: flex; gap: 8px; overflow-x: auto; padding: 2px 14px 10px; scrollbar-width: none; }
.sugs::-webkit-scrollbar { display: none; }
.sug { flex: none; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); padding: 8px 14px; border-radius: 99px; font-size: 14.5px; transition: transform .15s, background .15s; }
.sug:active { transform: scale(.96); background: var(--press); }
.composer { flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px calc(10px + var(--safe-b)); background: var(--bg); border-top: 1px solid var(--line); }
[data-kb] .composer { padding-bottom: 10px; }
.composer textarea { flex: 1; min-width: 0; resize: none; min-height: 44px; max-height: 120px; border: 1.5px solid transparent; border-radius: 22px; background: var(--surface-2); padding: 10px 16px; font: inherit; font-size: 16px; line-height: 1.3; outline: 0; color: var(--ink); transition: border-color .15s, background .15s; }
.composer textarea:focus { border-color: var(--brand); background: var(--surface); }
.send { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; transition: opacity .2s, transform .15s var(--spring); }
.send:active { transform: scale(.92); } .send[disabled] { opacity: .35; }
