@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700;800&family=Noto+Sans+KR:wght@300;400;500;700&display=swap');

:root {
    --bg: #f4fafe;
    --bg-2: #e3f4fc;
    --surface: #ffffff;
    --surface-2: #f2f9fd;
    --nav-bg: #111827;
    --line: #e3edf6;
    --line-strong: #c9e2f2;
    --text: #12141a;
    --muted: #667085;
    --faint: #9aa2b1;
    --point: #0ea5e9;
    --point-ink: #ffffff;
    --blue: #0ea5e9;
    --amber: #d97706;
    --green: #16a34a;
    --violet: #7c3aed;
    --danger: #e5484d;
    --soft-amber: #fef3c7;
    --soft-blue: #e2f6fd;
    --soft-green: #dcfce7;
    --soft-violet: #ede9fe;
    --soft-danger: #fde2e2;
    --radius: 22px;
    --radius-sm: 14px;
    --shadow: 0 14px 34px rgba(14, 116, 144, .08);
    --shadow-lg: 0 24px 60px rgba(14, 116, 144, .16);
    --font: 'Manrope', 'Noto Sans KR', Arial, sans-serif;
    --top-h: 84px;
}

* { box-sizing: border-box; }
html, body { color-scheme: light; }
body {
    margin: 0;
    min-height: 100vh;
    padding-top: calc(var(--top-h) + 22px);
    background:
        radial-gradient(900px 420px at 90% -10%, rgba(14, 165, 233, .07), transparent 60%),
        linear-gradient(180deg, #ffffff 0%, var(--bg) 50%, var(--bg-2) 100%);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}
button, input, a { font: inherit; }
button { cursor: pointer; }
body.modal-open { overflow: hidden; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(17, 24, 39, .16); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- topbar ---------- */
.topbar {
    position: fixed;
    top: 14px; left: 14px; right: 14px;
    z-index: 30;
    height: var(--top-h);
    padding: 0 12px 0 20px;
    display: flex;
    align-items: center;
    gap: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: var(--shadow);
}
.brand, .userbar, .card-head, .cal-nav, .card-actions { display: flex; align-items: center; }
.brand { gap: 12px; min-width: 0; flex: 0 0 auto; }
.brand img { width: 40px; height: 40px; object-fit: contain; border-radius: 10px; }
.brand strong { display: block; font-size: 14.5px; font-weight: 800; letter-spacing: .1px; white-space: nowrap; color: var(--text); }
.brand span { display: block; margin-top: 1px; color: var(--blue); font-size: 11px; font-weight: 700; letter-spacing: .4px; white-space: nowrap; }

/* pill nav */
.tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0 auto;
    padding: 6px;
    background: var(--nav-bg);
    border-radius: 999px;
}
.tabs button {
    padding: 9px 18px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #9aa3b5;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background .18s, color .18s;
}
.tab-ic { font-size: 14px; line-height: 1; }
.tabs button:hover { color: #fff; }
.tabs button.active { background: var(--point); color: var(--point-ink); box-shadow: 0 4px 14px rgba(14, 165, 233, .35); }

.userbar { gap: 12px; margin-right: 48px; flex: 0 0 auto; }
.user-text { text-align: right; }
.user-text strong { display: block; font-size: 13.5px; font-weight: 800; color: var(--text); }
.user-text span { display: block; color: var(--muted); font-size: 10.5px; font-weight: 600; }
.avatar {
    width: 38px; height: 38px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--nav-bg); color: var(--point);
    font-weight: 800; font-size: 14px;
}
.site-link-btn {
    width: max-content;
    min-width: max-content;
    height: 34px;
    margin-right: 6px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    text-decoration: none;
    transition: background .18s, color .18s, border-color .18s, transform .18s;
}
.site-link-btn:hover { background: var(--point); border-color: var(--point); color: #fff; transform: translateY(-1px); }

/* ---------- shell / hero ---------- */
.shell { max-width: 1440px; margin: 0 auto; padding: 6px 20px 30px; }
.section { display: none; }
.section.active { display: block; animation: sectionFade .32s ease; }
@keyframes sectionFade {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.hero {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
    padding: 32px 36px;
    background: linear-gradient(135deg, #101828 0%, #16213b 100%);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}
.hero::before {
    content: "";
    position: absolute; inset: 0;
    background: radial-gradient(360px 220px at 88% 20%, rgba(14, 165, 233, .30), transparent 70%);
    pointer-events: none;
}
.hero-text { position: relative; z-index: 1; }
.hero-text .eyebrow { color: #7dd3fc; }
.hero-text h1 { margin: 8px 0 6px; color: #fff; font-size: 27px; font-weight: 800; letter-spacing: -.2px; }
.hero-text p { margin: 0; color: #a7b0c2; font-size: 13.5px; font-weight: 500; }
.eyebrow { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: 2px; }
.section-heading { margin-bottom: 18px; }
.section-heading .eyebrow { color: var(--point); }
.section-heading h1 { margin: 6px 0 0; font-size: 24px; font-weight: 800; color: var(--text); }

.hero-art { position: relative; z-index: 1; width: 118px; height: 118px; flex: 0 0 auto; display: none; }
@media (min-width: 640px) { .hero-art { display: block; } }

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(260px, 300px) minmax(0, 1fr) minmax(320px, 380px);
    gap: 20px;
    align-items: stretch;
}

/* ---------- cards ---------- */
.card {
    position: relative;
    height: 100%;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card::before {
    content: "";
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: var(--amber);
    opacity: .9;
}
.meal-card::before { background: var(--amber); }
.timetable-card::before { background: var(--blue); }
.calendar-card::before { background: var(--violet); }
.account-card::before { background: var(--blue); }
@media (hover: hover) {
    .card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--line-strong); }
}
.card-head {
    min-height: 62px;
    padding: 16px 20px;
    gap: 10px;
    border-bottom: 1px solid var(--line);
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 800; letter-spacing: .1px; color: var(--text); }
.card-head small { color: var(--faint); font-size: 11px; white-space: nowrap; font-weight: 700; }
.icon {
    width: 32px; height: 32px; border-radius: 11px;
    display: grid; place-items: center;
    background: var(--soft-amber); color: var(--amber);
    font-size: 14px; font-weight: 800;
}
.timetable-card .icon { background: var(--soft-blue); color: var(--blue); }
.calendar-card .icon { background: var(--soft-violet); color: var(--violet); }
.card-actions { margin-left: auto; gap: 4px; }
.card-actions button:not(.chip-btn), .expand-btn {
    width: 28px; height: 28px; font-size: 15px; font-weight: 800;
    border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text);
    transition: background .18s, color .18s, border-color .18s;
}
.card-actions button:not(.chip-btn):hover, .expand-btn:hover, .cal-nav button:hover { background: var(--nav-bg); color: #fff; border-color: var(--nav-bg); }
.expand-btn { margin-left: auto; }
.meal-date-input {
    width: 132px;
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text);
    background: var(--surface-2);
    font-size: 12px;
    font-weight: 700;
    color-scheme: light;
}
.meal-date-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
}
.meal-actions { margin-left: auto; }
.chip-btn {
    padding: 0 12px;
    height: 28px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--point);
    font-size: 11.5px;
    font-weight: 800;
    transition: background .18s, color .18s, border-color .18s;
}
.chip-btn:hover { background: var(--soft-blue); border-color: var(--point); }
.sub-label { color: var(--muted); font-size: 12px; font-weight: 700; }

/* meal */
.meal-card, .timetable-card { display: flex; flex-direction: column; }
.meal-list { flex: 1; max-height: none; overflow-y: auto; }
.meal-section { padding: 16px 20px; }
.meal-section + .meal-section { border-top: 1px solid var(--line); }
.meal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; }
.badge { padding: 4px 11px; border-radius: 999px; font-size: 10.5px; font-weight: 800; }
.badge.breakfast { background: var(--soft-amber); color: var(--amber); }
.badge.lunch { background: var(--soft-blue); color: var(--blue); }
.badge.dinner { background: var(--soft-green); color: var(--green); }
.kcal { color: var(--faint); font-size: 11px; font-weight: 700; }
.meal-text { margin: 0; color: var(--text); font-size: 13.5px; line-height: 1.8; word-break: keep-all; }
.muted, .empty-cell { color: var(--faint); }

/* timetable */
.timetable-card { min-width: 0; }


/* 미신청 선택과목 경고 배너 - 이번 주 시간표에 ELECTIVE 타입(아직 신청 안 함)이
   하나라도 있으면 app.js가 hidden을 풀어서 보여줌 */
.tt-elective-warning {
    margin: 0 20px 10px;
    padding: 8px 14px;
    background: var(--soft-amber);
    color: var(--amber);
    border: 1px solid #fde3c8;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 700;
    align-items: center;
    justify-content: space-between;
}
.tt-elective-warning:not([hidden]) {
    display: flex;
}
.table-wrap { flex: 1; padding: 8px 14px 16px; overflow: hidden; display: flex; }
.week-table-wrap { max-width: 100%; }
.tt-table { width: 100%; height: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.week-tt-table { min-width: 0; table-layout: fixed; }
.tt-table th, .tt-table td { padding: 7px 4px; text-align: center; border-bottom: 1px solid var(--line); font-size: 11px; line-height: 1.35; word-break: keep-all; color: var(--text); }
.tt-table th { background: var(--soft-blue); color: var(--blue); font-weight: 800; text-transform: uppercase; letter-spacing: .3px; font-size: 9.5px; }
.week-tt-table thead th {
    white-space: nowrap;
    word-break: keep-all;
    overflow-wrap: normal;
}
.tt-head-date,
.tt-head-day {
    display: inline-block;
    white-space: nowrap;
}
.tt-head-day { margin-left: 2px; }
.tt-table td + td, .tt-table th + th { border-left: 1px solid var(--line); }
.tt-table tr:last-child td { border-bottom: 0; }
.tt-table .period { width: 48px; background: var(--surface-2); color: var(--muted); font-weight: 800; white-space: nowrap; }
.tt-legend { display: flex; gap: 12px; padding: 0 14px 16px; font-size: 11px; color: var(--muted); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-color { width: 12px; height: 12px; border-radius: 3px; display: inline-block; border: 1px solid var(--line); }
.legend-modified { background-color: #FEF3C7; }
.legend-elective { background-color: #DCFCE7; }
.message { padding: 28px 0; color: var(--faint); text-align: center; }

/* timetable cell content (과목명 / 선생님 / 위치 다단 표시)
   dashboard.js가 td.tt-cell 안의 .tt-cell-content에 각 정보를 넣어줌.
   과목마다 표시되는 정보량이 달라(교사/위치 유무) 셀 높이가 들쭉날쭉해지는 걸 막기 위해
   최소 높이를 주고, 세 줄을 세로로 정렬한다. */
.tt-table td.tt-cell {
    padding: 6px 4px;
    vertical-align: middle;
}
.tt-cell-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
}
.tt-subject {
    font-size: 11px;
    font-weight: 700;
    color: var(--text);
    word-break: keep-all;
}
.tt-teacher {
    font-size: 9.5px;
    font-weight: 600;
    color: var(--muted);
}
.tt-location {
    font-size: 9px;
    font-weight: 600;
    color: var(--blue);
    background: var(--soft-blue);
    border-radius: 999px;
    padding: 1px 6px;
}
.tt-table td.tt-empty {
    color: var(--faint);
    font-size: 11px;
}

/* calendar */
.calendar-card { min-width: 0; transition: box-shadow .2s, transform .2s; }
.calendar-card:not(.expanded) { cursor: pointer; }
.calendar-card.expanded {
    position: fixed;
    inset: 18px 64px 46px;
    z-index: 40;
    width: auto;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--surface);
    border-color: var(--line);
    box-shadow: var(--shadow-lg);
    animation: calendarPopIn .22s cubic-bezier(.16, 1, .3, 1);
}
@keyframes calendarPopIn {
    from { opacity: 0; transform: scale(.97) translateY(6px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-backdrop {
    position: fixed; inset: 0; z-index: 39;
    background: rgba(15, 23, 42, .4);
    backdrop-filter: blur(4px);
    animation: backdropIn .18s ease;
}
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }
.calendar-card.expanded { transition: none; }
.calendar-card.expanded,
.calendar-card.expanded:hover {
    transform: none !important;
}
.cal-nav { justify-content: space-between; padding: 12px 16px; }
.cal-nav strong { color: var(--text); }
.cal-nav button {
    width: 28px; height: 28px; font-size: 17px;
    border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text);
    transition: background .18s, color .18s, border-color .18s;
}
.cal-days-wrap { position: relative; }
.cal-days, .cal-weekdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); column-gap: 4px; }
.day { min-width: 0; cursor: pointer; }

.day-popover {
    position: absolute;
    z-index: 25;
    width: 210px;
    max-width: calc(100% - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    animation: popIn .16s ease;
}
@keyframes popIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.day-popover-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.day-popover-head strong { font-size: 13px; color: var(--text); }
.day-popover-head button {
    width: 22px; height: 22px; border: 0; border-radius: 50%;
    background: transparent; color: var(--faint); font-size: 15px; line-height: 1;
    display: grid; place-items: center;
}
.day-popover-head button:hover { background: var(--soft-blue); color: var(--blue); }
.day-popover ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.day-popover li {
    position: relative;
    padding-left: 14px;
    color: var(--text);
    font-size: 12.5px;
    font-weight: 600;
    overflow-wrap: anywhere;
}
.day-popover li::before {
    content: "";
    position: absolute; left: 0; top: 6px;
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--violet);
}
.cal-weekdays { padding: 0 14px 5px; }
.cal-weekdays span { text-align: center; color: var(--faint); font-size: 10.5px; font-weight: 800; }
.sun, .day.sun .num { color: var(--danger) !important; }
.sat, .day.sat .num { color: var(--blue) !important; }
.cal-days { gap: 4px; padding: 0 14px 16px; }
.day { min-height: 60px; padding: 6px 4px; border-radius: 11px; text-align: center; transition: background .15s; }
.calendar-card.expanded .card-head { background: var(--surface-2); }
.calendar-card.expanded .cal-nav { background: var(--surface); }
.calendar-card.expanded .cal-weekdays {
    margin: 0 18px;
    padding: 14px 10px 10px;
    background: var(--surface-2);
    border-radius: 14px 14px 0 0;
    column-gap: 8px;
}
.calendar-card.expanded .cal-days {
    margin: 0 18px 18px;
    padding: 0 10px 14px;
    background: var(--surface-2);
    border-radius: 0 0 14px 14px;
    gap: 8px;
}
.calendar-card.expanded .day {
    min-height: 92px;
    padding: 10px 8px;
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
.calendar-card.expanded > .card-head,
.calendar-card.expanded > .cal-nav,
.calendar-card.expanded > .cal-weekdays,
.calendar-card.expanded > .cal-days-wrap { flex-shrink: 0; }
.calendar-card.expanded .day:hover { background: var(--soft-blue); }
.calendar-card.expanded .day.other { background: transparent; box-shadow: none; }
.calendar-card.expanded .day.today { background: var(--surface); border: 1.5px solid var(--point); box-shadow: 0 3px 10px rgba(14, 165, 233, .18); }
.day:hover { background: var(--surface-2); }
.day.today { background: var(--soft-blue); }
.num { width: 24px; height: 24px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%; font-size: 12px; font-weight: 700; color: var(--text); transition: background .15s, color .15s; }
.calendar-card.expanded .num { width: 28px; height: 28px; font-size: 13px; }
.today .num { background: var(--point); color: var(--point-ink) !important; font-weight: 800; box-shadow: 0 3px 8px rgba(14, 165, 233, .35); }
.day.today.sat .num, .day.today.sun .num { color: #ffffff !important; }
.other .num { color: var(--faint); }
.day.other { opacity: .4; }
.day.other .num, .day.other.sun .num, .day.other.sat .num { color: var(--faint) !important; }
.day.other .event { display: none; }
.events { min-width: 0; display: flex; flex-direction: column; gap: 2px; margin-top: 3px; }
.event { max-width: 100%; padding: 1px 4px; overflow: hidden; border-radius: 5px; background: var(--soft-violet); color: var(--violet); font-size: 9px; white-space: nowrap; text-overflow: ellipsis; }
.calendar-card.expanded .event { padding: 2px 5px; font-size: 10px; }
.event.holiday { background: var(--soft-danger); color: var(--danger); }

/* compact (non-expanded) view: show events as small dots instead of cramped text pills */
.calendar-card:not(.expanded) .events {
    flex-direction: row; flex-wrap: wrap;
    justify-content: center;
    gap: 3px;
    margin-top: 5px;
}
.calendar-card:not(.expanded) .event {
    width: 5px; height: 5px; min-width: 5px; max-width: 5px;
    padding: 0; border-radius: 50%;
    font-size: 0; line-height: 0; color: transparent;
    background: var(--violet);
}
.calendar-card:not(.expanded) .event.holiday { background: var(--danger); }
.calendar-card:not(.expanded) .events > .event:nth-child(n+5) { display: none; }

/* tools */
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 20px; }
.tool-card { aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--line); }
.tool-card button { width: 100%; height: 100%; padding: 26px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 18px; border: 0; background: linear-gradient(145deg, var(--surface), var(--surface-2)); color: var(--text); text-align: left; transition: transform .2s, background .2s, border-color .2s; }
.tool-card button:hover { background: linear-gradient(145deg, #f5f8ff, #eaf0ff); }
.tool-card button:focus-visible { outline: 3px solid color-mix(in srgb, var(--point) 35%, transparent); outline-offset: -3px; }
.tool-card-copy { min-width: 0; }
.tool-card-copy strong { font-size: 17px; line-height: 1.45; }
.tool-card-arrow { color: var(--point); font-size: 23px; font-weight: 800; transition: transform .2s; }
.tool-card button:hover .tool-card-arrow { transform: translate(2px, -2px); }
.empty-state { padding: 70px 20px; text-align: center; color: var(--faint); font-size: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* account */
.account-card { max-width: 720px; }
.account-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 22px; padding: 20px; }
.account-item { padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.account-item span { display: block; margin-bottom: 4px; color: var(--faint); font-size: 10.5px; font-weight: 800; letter-spacing: .5px; }
.account-item strong { font-size: 14.5px; font-weight: 700; color: var(--text); }
.danger { margin: 4px 20px 20px auto; display: block; padding: 9px 18px; border-radius: 999px; border: 1px solid var(--danger); background: var(--surface); color: var(--danger); font-weight: 700; transition: background .18s, color .18s; }
.danger:hover { background: var(--danger); color: #fff; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--point); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1120px) {
    .dashboard-grid { grid-template-columns: minmax(240px, 280px) minmax(300px, 1fr) minmax(300px, 360px); gap: 16px; }
}
/* Reduce horizontal spacing continuously from 1280px to the mobile breakpoint. */
@media (min-width: 921px) {
    .topbar {
        --header-space: clamp(0px, calc((100vw - 920px) / 36), 10px);
        gap: calc(8px + var(--header-space));
        padding-left: calc(14px + var(--header-space) * .6);
        padding-right: calc(10px + var(--header-space) * .2);
    }
    .tabs {
        gap: calc(2px + var(--header-space) * .2);
        padding-inline: calc(4px + var(--header-space) * .2);
    }
    .tabs button { padding-inline: calc(11px + var(--header-space) * .7); }
    .userbar {
        gap: calc(8px + var(--header-space) * .4);
        margin-right: calc(var(--header-space) * 4.8);
    }
    .site-link-btn {
        margin-right: calc(var(--header-space) * .6);
        padding-inline: calc(10px + var(--header-space) * .3);
    }
}
@media (max-width: 920px) {
    :root { --top-h: auto; }
    body { padding-top: 78px; padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
    .topbar {
        top: 10px; left: 10px; right: 10px;
        height: auto;
        padding: 10px 14px; border-radius: 22px;
    }
    .brand { gap: 8px; flex: 1 1 auto; min-width: 0; }
    .brand > div { min-width: 0; }
    .brand img { width: 32px; height: 32px; }
    .brand strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
    .brand span { font-size: 9px; }
    .userbar { gap: 7px; margin-right: 0; flex: 0 0 auto; }
    .user-text { display: none; }
    .avatar { width: 32px; height: 32px; font-size: 12px; }
    .site-link-btn { width: max-content; min-width: max-content; height: 30px; margin-right: 1px; padding: 0 9px; font-size: 10px; }

    @media (max-width: 390px) {
        .topbar { gap: 8px; padding-inline: 10px; }
        .brand span { display: none; }
        .site-link-btn { padding-inline: 8px; }
    }

    .tabs {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 35;
        margin: 0;
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
        background: rgba(17, 24, 39, .97);
        backdrop-filter: blur(14px);
        border: 0;
        border-top: 1px solid rgba(255, 255, 255, .06);
        border-radius: 0;
        justify-content: space-around;
        gap: 0;
    }
    .tabs button {
        flex-direction: column;
        gap: 2px;
        padding: 7px 6px;
        border-radius: 14px;
        flex: 1 1 0;
    }
    .tabs button.active { box-shadow: none; }
    .tab-ic { font-size: 18px; }
    .tab-label { font-size: 10px; }

    .shell { padding: 6px 12px 30px; }
    .hero { flex-direction: column; align-items: flex-start; padding: 22px 22px; }
    .hero-text h1 { font-size: 21px; }
    .hero-art { display: none; }
    .dashboard-grid { grid-template-columns: 1fr; gap: 14px; }
    .card { height: auto; border-radius: 18px; }
    .card-head { min-height: 56px; padding: 13px 15px; flex-wrap: nowrap; gap: 8px; }
    .card-head h2 { flex: 0 0 auto; font-size: 14.5px; white-space: nowrap; }
    .icon { width: 27px; height: 27px; }
    .meal-card .meal-date-input { flex: 0 1 112px; width: 112px; min-width: 0; margin-left: auto; padding: 6px 6px; font-size: 11px; }
    .timetable-card .card-actions { margin-left: auto; justify-content: flex-end; }
    .sub-label { display: none; }
    .meal-list { max-height: none; }
    .meal-section { padding: 14px 15px; }


    .table-wrap { padding: 6px 8px 12px; overflow: hidden; display: block; }
    .tt-table { height: auto; table-layout: fixed; border-radius: 12px; }
    .week-tt-table { min-width: 0; }
    .tt-table th, .tt-table td {
        padding: 6px 2px;
        font-size: 10px;
        line-height: 1.25;
        word-break: keep-all;
        overflow-wrap: anywhere;
    }
    .week-tt-table thead th {
        white-space: nowrap;
        word-break: keep-all;
        overflow-wrap: normal;
        font-size: 9px;
        letter-spacing: 0;
    }
    .tt-head-date,
    .tt-head-day {
        display: block;
        margin: 0;
        white-space: nowrap;
    }
    .tt-table .period { width: 38px; font-size: 10px; white-space: normal; }
    .tt-cell-content { min-height: 38px; gap: 1px; }
    .tt-subject { font-size: 10px; }
    .tt-teacher { font-size: 8.5px; }
    .tt-location { font-size: 8px; padding: 1px 5px; }
    .card-actions { gap: 4px; }
    .card-actions button:not(.chip-btn) { width: 25px; height: 25px; }
    .card-actions .chip-btn { height: 25px; padding: 0 10px; font-size: 10.5px; }
    .card-actions small { font-size: 10px; }

    .calendar-card.expanded { inset: 12px 10px calc(78px + env(safe-area-inset-bottom)); border-radius: 18px; }
    .calendar-card.expanded .cal-weekdays,
    .calendar-card.expanded .cal-days {
        margin-inline: 8px;
        padding-inline: 4px;
        column-gap: 4px;
    }
    .calendar-card.expanded .day { min-height: 68px; padding: 6px 3px; }
    .calendar-card.expanded .num { max-width: 100%; }
    .calendar-card.expanded .event { font-size: 9px; }
    .tools-grid { grid-template-columns: 1fr; gap: 14px; }
    .account-grid { grid-template-columns: 1fr; }
}

/* ---------- modal ---------- */
.modal {
    position: fixed; inset: 0; z-index: 45;
    align-items: center; justify-content: center;
    padding: 20px;
}
.modal:not([hidden]) {
    display: flex;
}
.modal-content {
    background: var(--surface);
    width: 100%; max-width: 500px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--line);
    display: flex; flex-direction: column;
    max-height: 90vh;
    animation: modalPopIn .22s cubic-bezier(.16, 1, .3, 1);
}
@keyframes modalPopIn {
    from { opacity: 0; transform: scale(.97) translateY(6px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-header h3 { margin: 0; font-size: 16px; font-weight: 800; color: var(--text); }
.close-btn {
    width: 28px; height: 28px; border: 0; border-radius: 50%;
    background: transparent; color: var(--faint); font-size: 20px; line-height: 1;
    display: grid; place-items: center; cursor: pointer; transition: background .18s, color .18s;
}
.close-btn:hover { background: var(--soft-blue); color: var(--blue); }
.modal-body {
    padding: 20px; overflow-y: auto; flex: 1;
}
.elective-item {
    margin-bottom: 16px;
    padding: 16px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
}
.elective-item h4 { margin: 0 0 10px; font-size: 14.5px; font-weight: 700; color: var(--text); }
.elective-options { display: flex; flex-direction: column; gap: 8px; }
.elective-option {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    transition: background .18s, border-color .18s, box-shadow .18s;
}
.elective-option:hover { background: var(--soft-blue); border-color: var(--line-strong); }
.elective-option.selected { border-color: var(--point); background: var(--surface-2); box-shadow: 0 4px 12px rgba(14, 165, 233, .1); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.radio-circle {
    width: 20px; height: 20px; border-radius: 50%;
    border: 2px solid var(--line-strong);
    display: flex; align-items: center; justify-content: center;
    transition: all .2s;
    flex-shrink: 0;
}
.radio-circle::after {
    content: ""; width: 10px; height: 10px; border-radius: 50%;
    background: var(--point);
    transform: scale(0);
    transition: transform .2s cubic-bezier(.16, 1, .3, 1);
}
.elective-option input[type="radio"]:checked + .radio-circle { border-color: var(--point); }
.elective-option input[type="radio"]:checked + .radio-circle::after { transform: scale(1); }
.elective-option-label { flex: 1; font-size: 13.5px; font-weight: 700; color: var(--text); }
.elective-option-nickname { color: var(--faint); font-size: 11.5px; font-weight: 600; margin-left: 6px; }
