/* shell.css — แถบบน · แถบเมนูล่าง (มือถือ) / แท็บใต้หัว (จอใหญ่) · กรอบเนื้อหา · หัวหน้า */

.shell { min-height: 100dvh; }

/* แถบบนขาวทึบ + เส้นล่างบาง แบบหัวของหน้า /apply */
.topbar {
    position: sticky; top: 0; z-index: 20;
    background: var(--surface);
    border-bottom: 1px solid rgb(11 26 19 / 8%);
    padding-top: env(safe-area-inset-top);
}
.topbar__inner {
    max-width: 1040px; margin: 0 auto; padding: 10px 16px;
    display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; min-width: 0; margin-right: auto; }
.brand__text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.brand__name { font-weight: 700; color: var(--ink); font-size: .95rem; white-space: nowrap; }
.brand__sub { font-size: .74rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__logout { margin: 0; }

/* แถบเมนู: มือถือ = แถบล่างลอย (วัสดุโปร่ง) · จอใหญ่ = แท็บใต้หัว */
.tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: saturate(170%) blur(18px);
    -webkit-backdrop-filter: saturate(170%) blur(18px);
    border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
    padding: 6px 4px env(safe-area-inset-bottom);
}
.tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: calc(var(--tabbar-h) - 12px); color: var(--ink-2); text-decoration: none;
    font-size: .76rem; font-weight: 500;
}
.tab__icon {
    display: grid; place-items: center; width: 56px; height: 30px; border-radius: 999px;
    transition: background-color .18s ease, transform .1s ease-out, color .18s ease;
}
.tab:hover { color: var(--ink); }
.tab:active .tab__icon { transform: scale(.9); }
.tab.active { color: var(--brand); font-weight: 600; }
.tab.active .tab__icon { background: var(--brand-soft); }
/* 6–7 แถบบนจอแคบ (6 พ.ย. 69 เพิ่ม "ชำระเงิน" · 8 พ.ย. 69 เพิ่ม "LINE" เมื่อเปิดด่าน LINE): จำนวนช่องตามจำนวนแถบ ·
   ลดความกว้างพื้นหลังไอคอนไม่ให้ล้นช่อง · ป้ายห้ามตัดบรรทัด */
.tab > span:last-child { white-space: nowrap; }
@media (max-width: 420px) {
    .tab__icon { width: 40px; }
    .tab { font-size: .7rem; }
}
@media (max-width: 350px) {
    .tab__icon { width: 34px; }
    .tab { font-size: .64rem; }
}

/* ── มือถือ: 4 แท็บ + "อื่นๆ" (30 พ.ย. 69) ── เมนูในแผ่นซ่อนบนแถบ · ปุ่ม "อื่นๆ" เป็น <button> จึงล้างหน้าตาปุ่มเดิม */
.tab--in-more { display: none; }
/* ไม่ใช้ font: shorthand — จะทับ font-size ของ .tab ใน @media 420/350px (ป้าย "อื่นๆ" จะใหญ่กว่าเพื่อน) */
.tab--more { border: 0; background: none; font-family: inherit; line-height: inherit; cursor: pointer; padding: 0; }
.tab--more.active, .tab--more[aria-expanded="true"] { color: var(--brand); font-weight: 600; }
.tab--more.active .tab__icon, .tab--more[aria-expanded="true"] .tab__icon { background: var(--brand-soft); }
.tab:focus-visible { outline: none; }
.tab:focus-visible .tab__icon { box-shadow: var(--focus); }

/* แผ่น "อื่นๆ" — bottom sheet ขาว มุมบนโค้ง --r-lg แบบการ์ดของพอร์ทัล · ลอยเหนือแถบล่าง */
.more-sheet {
    position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: 560px; margin-inline: auto;
    max-height: calc(100vh - 72px); max-height: calc(100dvh - 72px); overflow: auto;
    border: 0; border-radius: var(--r-lg) var(--r-lg) 0 0;
    background: var(--surface); color: var(--ink);
    box-shadow: 0 -18px 48px -16px rgb(11 26 19 / 28%);
    /* popover อยู่ top layer ทับแถบล่างทั้งแถบ — เว้นแค่ขอบล่างของเครื่อง */
    padding: 8px 16px calc(18px + env(safe-area-inset-bottom));
    z-index: 30;
}
/* ซ่อนเป็นค่าเริ่มต้นด้วย selector ธรรมดา · แสดงแยกกฎละตัว — ห้ามรวม :popover-open กับคลาสในกฎเดียว:
   เบราว์เซอร์ที่ไม่รู้จัก :popover-open (iOS < 17) ทิ้งทั้งกฎ แผ่นจะโผล่ค้างทุกหน้า (รีวิว 30 พ.ย. 69) */
.more-sheet { display: none; }
.more-sheet.is-open { display: block; }
.more-sheet:popover-open { display: block; }
.more-sheet::backdrop { background: rgb(11 26 19 / 38%); }
/* fallback ไม่มี Popover API (more-menu.js): ม่านจากเงาของแผ่นเอง · อยู่ใต้แถบล่าง (z 20) ให้ "อื่นๆ" กดปิดได้ */
.more-sheet.is-open {
    box-shadow: 0 0 0 100vmax rgb(11 26 19 / 38%); z-index: 15;
    padding-bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom));
}
@media (prefers-reduced-motion: no-preference) {
    .more-sheet.is-open { animation: more-up .22s cubic-bezier(.2, .8, .2, 1); }
    .more-sheet:popover-open { animation: more-up .22s cubic-bezier(.2, .8, .2, 1); }
}
@keyframes more-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.more-sheet__grab { width: 40px; height: 4px; border-radius: 999px; background: var(--line); margin: 2px auto 6px; }
.more-sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.more-sheet__title { font-size: 1.1rem; color: var(--heading); margin: 0; }
.more-sheet__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.more-item {
    display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 12px;
    border: 1px solid var(--line-soft); border-radius: var(--r); background: var(--surface);
    color: var(--ink); text-decoration: none;
    transition: background-color .15s ease, border-color .15s ease;
}
.more-item:hover { background: var(--surface-2); }
.more-item:active { background: var(--brand-soft); }
.more-item:focus-visible { outline: none; box-shadow: var(--focus); }
.more-item.is-current { border-color: var(--brand-line); background: var(--brand-soft); }
.more-item__icon {
    display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 999px;
    background: var(--brand-soft); color: var(--brand);
}
.more-item__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; margin-right: auto; }
.more-item__label { font-weight: 600; }
.more-item__hint { font-size: .82rem; color: var(--ink-2); }
.more-item__go { color: var(--ink-2); flex: none; }

.content {
    max-width: 1040px; margin: 0 auto;
    padding: 18px 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom));
    outline: none;
}

@media (min-width: 900px) {
    .tabs {
        position: static; display: flex; gap: 4px; justify-content: flex-start;
        max-width: 1040px; margin: 0 auto; padding: 12px 12px 0; border-top: 0;
        background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none;
    }
    .tab { flex-direction: row; gap: 6px; min-height: 44px; padding: 0 12px 0 4px; border-radius: 999px; font-size: .95rem; }
    .tab__icon { width: 34px; height: 34px; background: transparent !important; }
    /* จอใหญ่: ทุกเมนูเป็นแท็บ · ไม่มี "อื่นๆ" และแผ่น */
    .tab--in-more { display: flex; }
    /* 8 แท็บ (มี "เชื่อมต่อ") อาจเกินความกว้างช่วง 900–1050px → ขึ้นบรรทัดใหม่แทนล้นจอ */
    .tabs { flex-wrap: wrap; }
}
@media (min-width: 900px) and (max-width: 1099px) {
    .tabs { gap: 2px; padding-inline: 8px; }
    .tab { font-size: .86rem; padding: 0 10px 0 2px; gap: 4px; }
    .tab__icon { width: 28px; }
    .tab--more, .more-sheet { display: none !important; }
    .tab:hover { background: var(--surface-2); }
    .tab.active { background: var(--brand-soft); }
    .content { padding: 22px 24px 56px; }
}

@media (prefers-reduced-transparency: reduce) {
    .tabs { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@supports not (backdrop-filter: blur(1px)) {
    .tabs { background: var(--surface); }
}

/* ── หัวหน้า ─────────────────────────────────────────────── */
.page-head { margin: 6px 0 22px; display: grid; gap: 6px; }
.page-head h1 { font-size: 1.9rem; color: var(--heading); }
.page-head__lead { color: var(--ink-2); }
.page-head .muted { color: var(--ink-2); }
.back {
    display: inline-flex; align-items: center; gap: 4px; min-height: 44px; width: fit-content;
    text-decoration: none; font-size: .95rem; font-weight: 500;
}

/* แผงเนื้อหาทั่วไป */
.panel {
    background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-lg);
    padding: 22px 20px; box-shadow: var(--shadow-sm);
}
.panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.panel__title { margin-bottom: 10px; }
/* "สำหรับผู้สมัครภาคเรียน 1/2570" ใต้หัวแผง (26 พ.ย. 69) */
.panel__for { margin: -6px 0 10px; color: var(--ink-2); font-size: .85rem; }
.panel__more { font-size: .92rem; font-weight: 500; min-height: 44px; display: inline-flex; align-items: center; text-decoration: none; }
