/* App pages (homepage, "Tôi", staff dashboards). Load tokens.css first.
   Layout follows the prototype: top navigation on desktop, bottom tab bar on phones. */
* { box-sizing: border-box; }

body.app {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
}
body.app a { color: inherit; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; margin: 0; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
p { margin: 0; }
.ja { font-family: var(--font-ja); }
.note { color: var(--muted); font-size: 13px; }
.grow { flex: 1; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stack { display: grid; gap: 12px; }

/* "Bỏ qua, đến nội dung chính": shown only while it has the keyboard focus (site-header.js addSkipLink) */
a.skip-link {
    position: fixed;
    z-index: 100;
    top: 8px;
    left: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--ink);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    transform: translateY(-160%);
}
body.app a.skip-link { color: #fff; }
a.skip-link:focus { transform: none; outline: none; box-shadow: var(--focus); }
main:focus { outline: none; }

/* ---------------- top bar ---------------- */
.site-top {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 10px 24px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}
.logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 20px;
    color: var(--ink);
    text-decoration: none;
    white-space: nowrap;
}
.logo svg { width: 30px; height: 30px; }
.site-nav { display: flex; gap: 4px; align-items: center; }
.site-nav a, .tabbar a, .tabbar button, .nav-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border: 0;
    border-radius: 10px;
    background: none;
    color: var(--muted);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.site-nav a:hover, .nav-more-btn:hover { color: var(--ink); background: var(--surface-2); }
.site-nav a[aria-current="page"], .nav-more-btn.on { color: var(--brand-text); background: var(--brand-soft); }
.site-account { display: flex; gap: 8px; align-items: center; flex: none; }
/* "Thêm": the links that do not fit in the bar (site-header.js fitNav) */
.nav-more { position: relative; }
.nav-more-btn .caret { font-size: 18px; margin-left: -4px; }
.nav-more-btn[aria-expanded="true"] .caret { transform: rotate(180deg); }
.nav-more-btn:focus-visible, .nav-more-menu a:focus-visible { outline: none; box-shadow: var(--focus); }
.nav-more-menu {
    position: absolute;
    z-index: 30;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    display: grid;
    gap: 2px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(47, 62, 110, .18);
}
.nav-more-menu a { display: flex; gap: 10px; padding: 10px 12px; color: var(--ink); }
.nav-more-menu a .ic { color: var(--brand); }

/* bell with the unread count */
.bell { position: relative; }
.bell-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--crit);
    color: #fff;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* result of a photo/video scan, popped up on any page (site-header.js) */
.site-notices {
    position: fixed;
    z-index: 60;
    top: 68px;
    right: 16px;
    width: min(380px, calc(100vw - 32px));
    display: grid;
    gap: 8px;
    pointer-events: none;
}
.site-notice {
    pointer-events: auto;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 10px 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--ok);
    background: var(--surface);
    box-shadow: 0 12px 32px rgba(47, 62, 110, .22);
    font-size: 14px;
    animation: notice-in .2s ease-out;
}
.site-notice > .ic { color: var(--ok); }
.site-notice.crit { border-left-color: var(--crit); }
.site-notice.crit > .ic { color: var(--crit); }
.site-notice-txt { flex: 1; display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.site-notice-txt .link { justify-self: start; }
.site-notice-x { border: 0; background: none; padding: 2px; color: var(--muted); cursor: pointer; border-radius: 8px; }
.site-notice-x:hover { color: var(--ink); background: var(--surface-2); }
.site-notice-x:focus-visible { outline: none; box-shadow: var(--focus); }
@keyframes notice-in { from { opacity: 0; transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .site-notice { animation: none; } }

.tabbar { display: none; }

/* "Thêm" sheet of the phone tab bar (site-header.js moreSheet) */
.more-sheet {
    width: 100%;
    max-width: 560px;
    max-height: min(86vh, 640px);
    margin: auto auto 0;
    padding: 0;
    border: 0;
    border-radius: 20px 20px 0 0;
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 -12px 36px rgba(47, 62, 110, .2);
    overflow-y: auto;
    overscroll-behavior: contain;
}
.more-sheet::backdrop { background: rgba(31, 38, 66, .45); }
.more-sheet[open] { animation: sheet-in .2s ease-out; }
@keyframes sheet-in { from { transform: translateY(24px); opacity: .4; } }
@media (prefers-reduced-motion: reduce) { .more-sheet[open] { animation: none; } }
.more-in { display: grid; gap: 14px; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); }
.more-head { display: flex; align-items: center; justify-content: space-between; }
.more-head h2 { font-size: 20px; }
.more-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.more-item, .more-me {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
}
.more-item .ic { color: var(--brand); font-size: 22px; }
.more-item span:last-child { min-width: 0; overflow-wrap: anywhere; }
.more-item:hover, .more-me:hover { background: var(--surface-2); }
.more-item[aria-current="page"], .more-me[aria-current="page"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-text); }
.more-item:focus-visible, .more-me:focus-visible { outline: none; box-shadow: var(--focus); }
.more-account { padding-top: 14px; border-top: 1px solid var(--line); }
.more-avatar {
    display: grid;
    place-items: center;
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--brand);
    color: var(--on-brand);
    font-weight: 700;
}
.more-who { flex: 1; min-width: 0; display: grid; overflow-wrap: anywhere; }
.more-guest { display: grid; gap: 10px; }
.more-guest .btn { flex: 1; }

/* ---------------- buttons, badges, cards ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .link:focus-visible, .site-nav a:focus-visible, .card:focus-visible { outline: none; box-shadow: var(--focus); }
.btn.pri { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.pri:hover { background: var(--brand-strong); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-text); }
.btn.dan { color: var(--crit); border-color: var(--crit-soft); }
.btn.dan.solid { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.link { border: 0; background: none; padding: 0; font: inherit; color: var(--brand-text); font-weight: 600; cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--ink);
    white-space: nowrap;
}
.badge .ic { font-size: 16px; vertical-align: -3px; }
.badge.br { background: var(--brand-soft); color: var(--brand-text); }
.badge.lan { background: var(--lantern-soft); color: var(--lantern-text); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.crit { background: var(--crit-soft); color: var(--crit); }
.tag { border: 1px solid currentColor; background: transparent; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    display: grid;
    gap: 10px;
    align-content: start;
}
button.card, a.card { text-align: left; font: inherit; color: inherit; cursor: pointer; text-decoration: none; }
button.card:hover, a.card:hover { border-color: var(--brand); }
.info { background: var(--ai-soft); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.alert { padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.alert.error { background: var(--crit-soft); color: var(--crit); }
.alert.success { background: var(--ok-soft); color: var(--ok); }
[hidden] { display: none !important; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; color: var(--muted); font-size: 14px; }
.tile b { display: block; color: var(--ink); font: 700 28px/1.1 var(--font-display); font-variant-numeric: tabular-nums; }

.bar2 { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar2 span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }

.field { display: grid; gap: 6px; }
.field label, .field .field-title { font-weight: 600; font-size: 14px; }

/* topics: toggle chips (Write Post / Đặt câu hỏi, "Chủ đề quan tâm" on Tôi and Home) */
.topic-picks { display: flex; flex-wrap: wrap; gap: 8px; }
.topic-pick {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.topic-pick:hover { border-color: var(--brand); }
.topic-pick:focus-visible { outline: none; box-shadow: var(--focus); }
.topic-pick[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-text); }
.topic-pick[aria-pressed="true"] .ic { font-size: 17px; }
.topic-pick[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.topic-pick[aria-disabled="true"]:hover { border-color: var(--line); }
.topic-pick.other { border-style: dashed; }
/* "Chủ đề quan tâm": a topic learnt from what the member did, not chosen yet */
.topic-pick .pick-hint { font-size: 16px; color: var(--brand); }
.interest-picker { display: grid; gap: 8px; }
.interest-picker .topic-picks[aria-busy="true"] .topic-pick { opacity: .6; cursor: progress; }
.interest-picker > .note { margin: 0; }
.interest-learnt-note .ic { font-size: 16px; color: var(--brand); vertical-align: -3px; }
.select {
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
}
.select:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.select[aria-invalid="true"] { border-color: var(--crit); }
/* "Đổi mật khẩu" on Tôi */
#pw-form { display: grid; gap: 12px; margin-top: 8px; max-width: 420px; }
#pw-form .alert[hidden] { display: none; }
/* "Lịch sử điểm" on Tôi */
.point-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.point-list li { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; align-items: baseline;
    padding: 6px 0; border-bottom: 1px solid var(--line); }
.point-list .delta { font-weight: 700; text-align: right; }
.point-list .delta.plus { color: var(--ok); }
.point-list .delta.minus { color: var(--crit); }
.point-list .what { overflow-wrap: anywhere; }
#history .pager { justify-content: center; margin-top: 8px; }

.page { max-width: 1080px; margin: 0 auto; padding: 24px 24px 48px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.narrow { max-width: 780px; }

/* ---------------- guest homepage ---------------- */
.hero {
    background:
        radial-gradient(circle at 85% 20%, rgba(194, 69, 110, .16), transparent 45%),
        var(--brand-soft);
    border-bottom: 1px solid var(--line);
}
.hero-in {
    max-width: 1080px;
    margin: 0 auto;
    padding: 48px 24px 0;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 32px;
    align-items: end;
}
.hero-txt { display: grid; gap: 14px; justify-items: start; padding-bottom: 40px; }
.hero h1 { font-size: clamp(30px, 4vw, 46px); font-weight: 800; text-wrap: balance; }
.hero p { max-width: 520px; font-size: 16px; }
.heromap {
    border-radius: 18px 18px 0 0;
    border: 1px solid var(--line);
    border-bottom: 0;
    overflow: hidden;
    background: #F3EFEA;
}
.heromap svg { display: block; width: 100%; height: auto; }

.quotes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.quote {
    margin: 0;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand);
    border-radius: 0 var(--radius) var(--radius) 0;
    display: grid;
    gap: 10px;
}
.quote blockquote { margin: 0; }
.quote figcaption { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-weight: 600; font-size: 14px; }

.feat { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.feat .ic.big { font-size: 30px; color: var(--brand); }

.phrase .ja.big { font-size: 26px; font-weight: 700; line-height: 1.35; }

/* ---------------- member homepage ---------------- */
.greet { display: flex; gap: 14px; align-items: center; }
.greet svg { width: 46px; height: 46px; flex: none; }
.homegrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

/* Search boxes: "Tìm trên Senpai ơi" (Home, /search) and "Tìm trong bài dành cho bạn" (/for-you) */
.site-search {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    min-height: 52px;
    padding: 4px 4px 4px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
}
.site-search:focus-within { border-color: var(--brand); box-shadow: var(--focus); }
.site-search > .ic { flex: none; color: var(--muted); }
.site-search input {
    flex: 1;
    min-width: 0;
    height: 42px;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--ink);
    font: inherit;
    text-overflow: ellipsis;
}
.site-search .btn, .site-search .count { flex: none; }
.site-search .count { padding-right: 10px; font-variant-numeric: tabular-nums; }
.home-search { box-shadow: 0 6px 18px rgba(47, 62, 110, .07); }
.hero .home-search { justify-self: stretch; max-width: 540px; }
.promptcard { border: 1px dashed var(--brand); background: var(--brand-soft); }
.mini {
    color: inherit;
    text-decoration: none;
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 8px;
    border-radius: 10px;
}
.mini:hover { background: var(--surface-2); }
.mini > .ic { color: var(--brand); }
.mini-where .ic { font-size: 15px; vertical-align: -3px; margin-right: 2px; }
.mini .when {
    flex: none;
    width: 52px;
    text-align: center;
    border-radius: 10px;
    background: var(--lantern-soft);
    color: var(--lantern-text);
    font-weight: 700;
    font-size: 12px;
    padding: 6px 0;
    line-height: 1.2;
}
.mini .when b { display: block; font-size: 18px; }
.stars { color: var(--lantern); letter-spacing: 1px; }
.blogcard h3 { font-size: 20px; }

/* "Dành cho bạn": the personal feed leads the member Home and stands out from the white cards below it */
.spot {
    display: grid;
    gap: 14px;
    padding: 22px;
    border: 1px solid rgba(194, 69, 110, .3);
    border-radius: 20px;
    background:
        radial-gradient(circle at 100% 0, rgba(232, 163, 60, .2), transparent 42%),
        radial-gradient(circle at 0 100%, rgba(194, 69, 110, .14), transparent 50%),
        var(--brand-soft);
    box-shadow: 0 14px 36px rgba(194, 69, 110, .14);
    scroll-margin-top: 76px;                    /* below the sticky top bar */
}
.spot-head { display: flex; gap: 12px; align-items: center; }
.spot-head h2 { display: flex; gap: 8px; align-items: center; font-size: 30px; font-weight: 800; }
.spot-head h2 .ic { font-size: 32px; color: var(--brand); }
.spot-sub { margin-top: -8px; font-size: 15px; }
.spot-head .btn { flex: none; }
.spot-more { display: none; }                   /* phones: "Xem thêm" under the posts, so the title keeps one line */
.spot-basis { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spot-label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-text); }
.spot-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    padding: 4px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    font-size: 13.5px;
    font-weight: 600;
    overflow-wrap: anywhere;
}
.spot-chip .ic { font-size: 17px; color: var(--brand); }
.spot-chip.off { border: 1px dashed var(--brand); background: transparent; color: var(--muted); font-weight: 500; }
/* a topic learnt from what the member did, after the chosen ones */
.spot-chip.learnt { background: transparent; font-weight: 500; }
.spot-chip.learnt .ic { color: var(--muted); }
.spot .promptcard { background: var(--surface); }
/* the first post across the whole width, the others two by two (an odd last one takes the whole row) */
.spot-posts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.spot-lead, .spot-item {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    transition: border-color .15s, box-shadow .15s;
}
.spot-lead { grid-column: 1 / -1; gap: 12px; padding: 20px 22px; border-top: 4px solid var(--brand); border-radius: var(--radius); }
.spot-item { padding: 14px 16px; border-radius: 12px; }
.spot-item:nth-child(even):last-child { grid-column: 1 / -1; }
.spot-item .spot-meta { margin-top: auto; }
.spot-lead:hover, .spot-item:hover { border-color: var(--brand); box-shadow: 0 6px 18px rgba(194, 69, 110, .14); }
.spot-lead:has(.feedtitle:focus-visible), .spot-item:has(.feedtitle:focus-visible) { box-shadow: var(--focus); }
.feedtitle { color: inherit; font-weight: 700; font-size: 16px; text-decoration: none; overflow-wrap: anywhere; }
.feedtitle:hover { color: var(--brand-text); text-decoration: underline; }
.feedtitle:focus-visible { outline: none; }
/* the whole post is the link to it */
.spot .feedtitle::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.spot-lead .feedtitle { font-family: var(--font-display); font-size: 23px; line-height: 1.25; }
.spot-excerpt { max-width: 760px; color: var(--muted); overflow-wrap: anywhere; }
.spot-meta .note { overflow-wrap: anywhere; }
.spot-meta .note .ic { font-size: 15px; vertical-align: -3px; margin: 0 2px 0 4px; }
.whys { display: flex; flex-wrap: wrap; gap: 6px; }
.why {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-text);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}
.why .ic { font-size: 16px; }
.why.stage { background: var(--lantern-soft); color: var(--lantern-text); }
.why.interest { background: var(--ai-soft); color: var(--ink); }
.spot-empty { padding: 16px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface); }
/* "Cẩm nang cho giai đoạn …" under the posts: guides of the member's stage, side by side while each keeps 220 px */
.spot-guides { display: grid; gap: 10px; }
.spot-guides-head { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
/* the title keeps 240 px: on a phone "Xem tất cả" goes under it instead of squeezing it onto three lines */
.spot-guides-head h3 { display: flex; flex: 1 1 240px; gap: 6px; align-items: center; min-width: 0; font-size: 19px; overflow-wrap: anywhere; }
.spot-guides-head h3 .ic { color: var(--brand); }
.spot-guide-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px; }
.spot-guide {
    position: relative;                         /* the title's link covers the whole card (.spot .feedtitle::after) */
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--lantern);
    border-radius: 12px;
    transition: border-color .15s, box-shadow .15s;
}
.spot-guide:hover { border-color: var(--brand); border-left-color: var(--lantern); box-shadow: 0 6px 18px rgba(194, 69, 110, .14); }
.spot-guide:has(.feedtitle:focus-visible) { box-shadow: var(--focus); }
.homegrid .card:has(.feedtitle:focus-visible) { box-shadow: var(--focus); }   /* "Việc tiếp theo": the guide's title */
.spot-guide .spot-excerpt { font-size: 14px; }
.spot-guide-foot { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: auto; }
.spot-guide-progress { display: flex; flex: 1 1 120px; gap: 8px; align-items: center; min-width: 0; }
.spot-guide-progress .bar2 { flex: 1; min-width: 48px; }

/* ---------------- "Tôi" ---------------- */
#points, #area, #interests, #guides { scroll-margin-top: 76px; }   /* /profile#points, #area…: below the sticky top bar */
/* "Cẩm nang của tôi": one row per stage (title, bar, done/total), then the guides started and finished */
.guide-stages, .guide-list { list-style: none; margin: 0; padding: 0; display: grid; font-size: 14px; }
.guide-stages li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(72px, 160px) 4.5em;
    gap: 6px 12px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}
.guide-stages .what, .guide-list .what { min-width: 0; overflow-wrap: anywhere; }
.guide-stages .what .badge { margin-left: 4px; }
.guide-stages .count { text-align: right; font-variant-numeric: tabular-nums; }
.guide-list li { display: grid; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.guide-list .bar2 { max-width: 260px; }
.guide-list .done-ic { color: var(--ok); font-size: 18px; vertical-align: -4px; margin-right: 4px; }
.guide-sub { margin: 6px 0 0; font-size: 15px; }
@media (max-width: 520px) {
    /* the bar goes under the title and the count */
    .guide-stages li { grid-template-columns: minmax(0, 1fr) auto; }
    .guide-stages li .bar2 { grid-column: 1 / -1; order: 3; }
}
.ranks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
/* scoped to the cards on Tôi: "badge rank" is the rank next to a name on posts and reviews */
.ranks .rank { border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 14px; }
.ranks .rank.got { border-color: var(--brand); background: var(--brand-soft); }
.ranks .rank ul { margin: 8px 0 0; padding-left: 18px; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.warncard { border-color: var(--crit); background: var(--crit-soft); }

/* ---------------- staff dashboards ---------------- */
.desk { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - 61px); }
/* a long role name ("Người quản lý học thuật") is cut with "…" rather than pushing the buttons off the screen */
.staff-top .badge { display: block; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; line-height: 1.6; }
.desk-side { border-right: 1px solid var(--line); background: var(--surface); padding: 18px 12px; display: grid; gap: 4px; align-content: start; }
.desk-side .side-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 6px 10px; }
.desk-side a { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 500; }
.desk-side a:hover { background: var(--surface-2); }
.desk-side a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-text); font-weight: 600; }
/* minmax(0, 1fr) here and on .page: a wide table scrolls inside its own wrapper instead of widening the page */
.desk-main { padding: 24px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-content: start; }
.module .ic.big { font-size: 28px; color: var(--brand); }

/* ---------------- responsive ---------------- */
/* staff accounts: the link to their own pages keeps only its icon (and title) until the header has room */
@media (max-width: 1500px) {
    .site-account .desk-link .who { display: none; }
}
@media (max-width: 1320px) and (min-width: 861px) {
    .site-top { gap: 12px; padding: 10px 16px; }
    .site-nav { gap: 0; }
    .site-nav > a, .nav-more-btn { padding: 8px 7px; gap: 4px; font-size: 14px; }
    .site-account .who { display: none; }
}
@media (max-width: 1100px) and (min-width: 861px) {
    .site-nav > a .ic, .nav-more-btn .ic:not(.caret) { display: none; }
}
@media (max-width: 960px) and (min-width: 861px) {
    .logo .logo-name { display: none; }
}
@media (max-width: 860px) {
    .site-top { gap: 10px; padding: 10px 16px; }
    .site-nav, .site-account .who { display: none; }
    /* "Tôi" is in the "Thêm" sheet: room for "Tin nhắn", the bell and "Đăng xuất" */
    .site-account .me-link { display: none; }
    .site-notices { top: 62px; left: 16px; right: 16px; width: auto; }
    .tabbar {
        display: flex;
        position: fixed;
        z-index: 20;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--surface);
        border-top: 1px solid var(--line);
        padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    }
    /* 5 tabs of equal width (4 features + "Thêm"), labels big enough to read and tap at 320 px */
    .tabbar a, .tabbar button {
        flex: 1 1 0;
        flex-direction: column;
        justify-content: center;
        gap: 2px;
        min-width: 0;
        min-height: 52px;
        padding: 4px 2px;
        font-size: 12px;
        line-height: 1.2;
    }
    .tabbar .ic { font-size: 24px; }
    .tabbar a[aria-current="page"], .tabbar button.on { color: var(--brand-text); }
    .tabbar a[aria-current="page"] .ic, .tabbar button.on .ic { font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 24; }
    .tabbar a:focus-visible, .tabbar button:focus-visible { outline: none; box-shadow: inset var(--focus); }
    body.app.has-tabbar { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
    .page { padding: 18px 16px 32px; }
    .hero-in { grid-template-columns: 1fr; padding: 28px 16px 0; gap: 18px; }
    .hero-txt { padding-bottom: 0; }
    .homegrid, .two, .ranks, .spot-posts { grid-template-columns: 1fr; }
    .spot { padding: 16px; border-radius: 16px; }
    .spot-head .btn { display: none; }
    .spot-head .btn.spot-find { display: inline-flex; }
    .spot .spot-more { display: inline-flex; justify-self: center; }
    .spot-head h2 { gap: 6px; font-size: 24px; }
    .spot-head h2 .ic { font-size: 24px; }
    .spot-sub { font-size: 14px; }
    .spot-lead { padding: 16px; }
    .spot-lead .feedtitle { font-size: 20px; }
    /* minmax(0, 1fr): a wide form or table scrolls inside its own box instead of widening the whole page */
    .desk { grid-template-columns: minmax(0, 1fr); min-height: 0; }
    /* the side menu becomes one row of chips that scrolls sideways (staff-desk.js shows the current one) */
    .desk-side {
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding: 8px 12px;
        grid-auto-flow: column;
        grid-auto-columns: max-content;
        overflow-x: auto;
        scrollbar-width: none;
        overscroll-behavior-x: contain;
    }
    .desk-side::-webkit-scrollbar { display: none; }
    .desk-side a { white-space: nowrap; padding: 8px 12px; }
    .desk-side .side-title { display: none; }
    .desk-main { padding: 18px 16px; }
}
@media (max-width: 480px) {
    /* staff top bar on a phone: the flower alone, so the role badge and the three buttons fit */
    .staff-top .logo-txt { display: none; }
    .staff-top .site-account .btn.sm { padding: 0 9px; }
/* the logo's name leaves room for "Tin nhắn", the bell and "Đăng xuất" on the smallest phones */
@media (max-width: 360px) {
    .logo .logo-name { display: none; }
}
/* "Xin tag định danh" (UC-U09) */
.tag-form { display: grid; gap: 14px; }
.tag-form .alert[hidden] { display: none; }
.tag-options { display: grid; gap: 8px; }
.tag-option { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line);
    border-radius: 12px; cursor: pointer; }
.tag-option:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.tag-option.owned { opacity: .6; cursor: default; }
.tag-option input { margin-top: 4px; accent-color: var(--brand); }
.tag-form .check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.tag-form .check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }
.tag-preview { max-width: 260px; max-height: 200px; border-radius: 10px; border: 1px solid var(--line); object-fit: contain; }

/* Living-area picker (components/area-picker.js) */
.area-picker { display: grid; gap: 10px; }
.area-tools { flex-wrap: wrap; }
.area-tools input { min-width: 200px; }
.area-results { display: grid; gap: 4px; max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: var(--surface); }
.area-results button { text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; font: inherit; color: var(--ink); }
.area-results button:hover, .area-results button:focus-visible { background: var(--brand-soft); }
.area-mapbox { display: grid; gap: 8px; }
.area-mapbox .row { flex-wrap: wrap; }
.area-map { height: 300px; border-radius: 10px; border: 1px solid var(--line); }
.area-credit { font-size: 12px; margin: 0; }
