/* ==========================================================================
   ตารางเรียน MWIT — style.css
   ระบบสี: ใช้ data-theme="light" | "dark" บน <html>
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Kanit:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,600;1,700&display=swap');

:root{
    --accent:        #2451C4;
    --accent-bright: #4A72E0;
    --accent-ink:    #FFFFFF;
    --gold:          #E29A2E;
    --mint:          #1E9E7C;
    --coral:         #D8492F;

    --radius-lg: 22px;
    --radius-md: 14px;
    --radius-sm: 9px;

    --font-display: 'Kanit', sans-serif;
    --font-body: 'Kanit', sans-serif;
    --font-mono: 'Kanit', sans-serif;

    --shadow-soft: 0 10px 30px -12px rgba(20,23,28,0.18);
}

/* ให้เบราว์เซอร์ animate สี --accent / --accent-bright แบบไล่เฉดจริง ๆ (ใช้กับโหมดรุ้ง) */
@property --accent{
    syntax: '<color>';
    inherits: true;
    initial-value: #2451C4;
}
@property --accent-bright{
    syntax: '<color>';
    inherits: true;
    initial-value: #4A72E0;
}

html[data-theme="light"]{
    --bg-image: url('../assets/background.webp');
    --bg: #F3F3F3;
    --surface: rgba(255,255,255,0.70);
    --surface-faint: rgba(255,255,255,0.42);
    --surface-solid: #FFFFFF;
    --surface-strong: rgba(255,255,255,0.92);
    --border: rgba(20,23,28,0.09);
    --border-strong: rgba(20,23,28,0.16);
    --ink: #14171C;
    --ink-muted: #5B6270;
    --ink-faint: #8A909B;
    --accent: #2451C4;
    --shadow-soft: 0 10px 30px -14px rgba(20,23,28,0.22);
}

html[data-theme="dark"]{
    --bg-image: url('../assets/background-dark.webp');
    --bg: #090d16;
    --surface: rgba(30,48,80,0.28);
    --surface-faint: rgba(30,48,80,0.16);
    --surface-solid: #111827;
    --surface-strong: rgba(18,28,51,0.92);
    --border: rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.15);
    --ink: #F0F1F3;
    --ink-muted: #94a3b8;
    --ink-faint: #64748b;
    --accent: #3b82f6;
    --accent-bright: #60a5fa;
    --shadow-soft: 0 25px 50px -12px rgba(0,0,0,0.5),
                   0 0 30px rgba(37,99,235,0.15),
                   inset 0 1px 0 rgba(255,255,255,0.08);
}

/* ==========================================================================
   โหมดสีรุ้งสุดๆ (Rainbow / Pride) — data-theme="rainbow"
   สี accent ทั้งแอปไล่เฉดสีธงไพรด์วนลูปอัตโนมัติ ผ่าน @property ด้านบน
   ตกแต่งเพิ่ม: ลายทางสีรุ้งพื้นหลัง, ขอบการ์ดไล่สีรอบด้าน, โลโก้ไล่สี,
   เส้นใต้ topbar ไล่สี และปุ่ม/แท็บที่ active เป็นไล่สีแทนสีทึบ
   ========================================================================== */
html[data-theme="rainbow"]{
    --bg-image: url('../assets/background.webp');
    --bg: #F6F1FC;
    --surface: rgba(255,255,255,0.72);
    --surface-faint: rgba(255,255,255,0.45);
    --surface-solid: #FFFFFF;
    --surface-strong: rgba(255,255,255,0.92);
    --border: rgba(20,23,28,0.10);
    --border-strong: rgba(20,23,28,0.18);
    --ink: #14171C;
    --ink-muted: #5B6270;
    --ink-faint: #8A909B;
    --accent-ink: #FFFFFF;
    --shadow-soft: 0 14px 34px -14px rgba(150,60,220,0.32);
    --rainbow-colors: #E40303, #FF8C00, #FFED00, #008026, #004DFF, #732982, #E40303;
    animation: rainbowCycle 8s linear infinite;
}

/* ปิดอนิเมชั่นไล่สีตอนเลือกกราฟิกต่ำ (เพื่อประสิทธิภาพ) แต่ยังคงสีสวยแบบนิ่ง */
html[data-graphics="low"][data-theme="rainbow"]{
    animation: none;
    --accent: #D6249F;
    --accent-bright: #F06FC2;
}

@keyframes rainbowCycle{
    0%    { --accent: #E40303; --accent-bright: color-mix(in srgb, #E40303 55%, white); }
    16.6% { --accent: #FF8C00; --accent-bright: color-mix(in srgb, #FF8C00 55%, white); }
    33.3% { --accent: #FFED00; --accent-bright: color-mix(in srgb, #FFED00 55%, white); }
    50%   { --accent: #008026; --accent-bright: color-mix(in srgb, #008026 55%, white); }
    66.6% { --accent: #004DFF; --accent-bright: color-mix(in srgb, #004DFF 55%, white); }
    83.3% { --accent: #732982; --accent-bright: color-mix(in srgb, #732982 55%, white); }
    100%  { --accent: #E40303; --accent-bright: color-mix(in srgb, #E40303 55%, white); }
}

/* ลายทางสีรุ้งจาง ๆ ปูพื้นหลังทั้งหน้า */
html[data-theme="rainbow"] .container{
    position: relative;
}
html[data-theme="rainbow"] .container::before{
    content: '';
    position: absolute;
    inset: -18px -16px;
    z-index: -1;
    background: repeating-linear-gradient(135deg, var(--rainbow-colors) 0 42px);
    background-size: 600% 600%;
    opacity: .16;
    border-radius: 28px;
    pointer-events: none;
    animation: rainbowStripeShift 26s linear infinite;
}
@keyframes rainbowStripeShift{
    0%{ background-position: 0% 0%; }
    100%{ background-position: 300% 300%; }
}

/* โลโก้ตัวอักษรไล่สีรุ้งแบบเคลื่อนไหว */
html[data-theme="rainbow"] .brand-text .brand-title{
    background: linear-gradient(90deg, var(--rainbow-colors));
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: rainbowTextShift 5s linear infinite;
}
@keyframes rainbowTextShift{
    0%{ background-position: 0% 50%; }
    100%{ background-position: 300% 50%; }
}

/* เส้นไล่สีรุ้งใต้ topbar ทั้งแถบ */
html[data-theme="rainbow"] .topbar{
    position: relative;
    padding-bottom: 12px;
}
html[data-theme="rainbow"] .topbar::after{
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: -2px;
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--rainbow-colors));
    background-size: 300% 100%;
    animation: rainbowTextShift 5s linear infinite;
}

/* การ์ดหลัก (hero): ขอบไล่สีรุ้งรอบด้าน แบบเคลื่อนไหว */
html[data-theme="rainbow"] .hero{
    border: 3px solid transparent;
    border-radius: var(--radius-lg);
    background-image: linear-gradient(var(--surface), var(--surface)),
                       linear-gradient(120deg, var(--rainbow-colors));
    background-origin: padding-box, border-box;
    background-clip: padding-box, border-box;
    background-repeat: no-repeat;
    background-size: 100% 100%, 400% 400%;
    animation: rainbowBorderShift 9s ease infinite;
}
@keyframes rainbowBorderShift{
    0%{ background-position: 0% 0%, 0% 50%; }
    50%{ background-position: 0% 0%, 100% 50%; }
    100%{ background-position: 0% 0%, 0% 50%; }
}

/* ปุ่ม/แท็บที่ active: ไล่สีรุ้งแทนสีทึบ */
html[data-theme="rainbow"] .day-tab.active,
html[data-theme="rainbow"] .week-pill.active,
html[data-theme="rainbow"] .segmented button.active,
html[data-theme="rainbow"] .csel-option.active,
html[data-theme="rainbow"] .csel-tab.active,
html[data-theme="rainbow"] .csel-grid-btn.active,
html[data-theme="rainbow"] .modal-toolbar button.active{
    background: linear-gradient(120deg, var(--rainbow-colors));
    background-size: 300% 300%;
    border-color: transparent;
    color: #FFFFFF;
    animation: rainbowBorderShift 6s ease infinite;
}

/* ออร่าแสงพื้นหลังไล่เฉดสีรอบจอ ให้ไหวมากขึ้น */
html[data-theme="rainbow"] body::before,
html[data-theme="rainbow"] body::after{
    opacity: .30;
    animation: rainbowAura 10s linear infinite;
}
@keyframes rainbowAura{
    0%{ filter: blur(140px) hue-rotate(0deg); }
    100%{ filter: blur(140px) hue-rotate(360deg); }
}

*{ box-sizing: border-box; }

html, body{
    margin: 0;
    padding: 0;
}

body{
    min-height: 100vh;
    background-color: var(--bg);
    background-image: var(--bg-image);
    background-size: cover;
    background-position: center top;
    background-attachment: fixed;
    color: var(--ink);
    font-family: var(--font-body);
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
    transition: background-color .25s ease, color .25s ease;
    position: relative;
}

/* ออร่าแสงสีฟ้า/ม่วงแบบธีมมืดต้นฉบับ (ซ่อนในโหมดสว่าง) */
body::before,
body::after{
    content: '';
    position: fixed;
    width: 420px;
    height: 420px;
    border-radius: 999px;
    filter: blur(140px);
    opacity: 0;
    z-index: 0;
    pointer-events: none;
    transition: opacity .3s ease;
}
body::before{ background: #2563eb; top: -120px; left: -120px; }
body::after{ background: #9333ea; right: -120px; bottom: -120px; }
html[data-theme="dark"] body::before,
html[data-theme="dark"] body::after{
    opacity: .22;
}

::selection{ background: var(--accent); color: var(--accent-ink); }

a{ color: inherit; }

button, select, input, textarea{
    font-family: inherit;
    color: inherit;
}

.container{
    max-width: 880px;
    margin: 0 auto;
    padding: 18px 16px 64px;
    position: relative;
    z-index: 1;
}

/* ---------- Top bar ---------- */
.topbar{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.brand{
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-mark{
    height: 34px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
    flex-shrink: 0;
    padding: 6px 8px;
    border-radius: 11px;
    background: var(--surface-solid);
    border: 1px solid var(--border);
}

.brand-text .brand-title{
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    line-height: 1.1;
}

.brand-text .brand-sub{
    font-size: 12px;
    color: var(--ink-muted);
    font-family: var(--font-mono);
}

.topbar-controls{
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.select-pill, .icon-btn{
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--border-strong);
    background: var(--surface-solid);
    color: var(--ink);
    border-radius: 999px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s ease, transform .1s ease;
}
.select-pill:hover, .icon-btn:hover{ border-color: var(--accent); }
.csel-trigger:hover{ border-color: var(--accent); }
.select-pill:active, .icon-btn:active{ transform: scale(0.97); }

.icon-btn{
    padding: 9px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    position: relative;
    white-space: nowrap;
}

.settings-wrap{ position: relative; display: inline-block; }

.settings-btn{
    width: 38px;
    height: 38px;
    padding: 0 !important;
}

.settings-panel{
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 50;
    min-width: 220px;
    background: var(--surface-strong);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    box-shadow: var(--shadow-soft);
}
.settings-panel[hidden]{ display: none; }

.settings-row{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
}
.settings-row + .settings-row{ border-top: 1px solid var(--border); }

.settings-label{
    font-size: 12.5px;
    color: var(--ink-muted);
    font-weight: 600;
}

.settings-link{
    display: block;
    width: 100%;
    text-align: center;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    padding: 6px 0;
}
.settings-link:hover{ text-decoration: underline; }

.segmented{
    display: flex;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
}
.segmented button{
    border: none;
    background: var(--surface-solid);
    color: var(--ink-muted);
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.segmented button:first-child{ border-radius: 999px 0 0 999px; }
.segmented button:last-child{ border-radius: 0 999px 999px 0; }
.segmented button.active{
    background: var(--accent);
    color: var(--accent-ink);
}

/* ---------- Custom select (แทน native <select>) ---------- */
.csel{
    position: relative;
    display: inline-block;
}
.csel.csel-block{
    display: block;
    width: 100%;
}

.csel-native{
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

.csel-trigger{
    display: inline-flex;
    align-items: center;
    width: auto;
    text-align: left;
    padding: 9px 30px 9px 12px;
    position: relative;
    cursor: pointer;
    background: var(--surface-solid);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-size: 13.5px;
    font-weight: 500;
    font-family: var(--font-body);
}
.csel-block .csel-trigger{
    width: 100%;
    display: flex;
}
/* ตัวที่แปะ class select-pill มาด้วย (เช่น ในหัวเว็บหน้านักเรียน) ให้คงทรงพิลไว้ */
.csel-trigger.select-pill{
    border-radius: 999px;
    padding: 9px 30px 9px 14px;
    font-weight: 600;
    font-size: 13px;
}
.csel-trigger::after{
    content: '';
    position: absolute;
    right: 13px;
    top: 50%;
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-65%) rotate(45deg);
    opacity: .55;
    pointer-events: none;
}
.csel-trigger[aria-expanded="true"]::after{
    transform: translateY(-35%) rotate(-135deg);
}

.csel-panel{
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 100%;
    max-height: 260px;
    overflow-y: auto;
    background: var(--surface-strong);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 6px;
    box-shadow: var(--shadow-soft);
    z-index: 60;
}
.csel-panel[hidden]{ display: none; }

.csel-group-label{
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--ink-faint);
    font-weight: 700;
    padding: 8px 10px 4px;
}

.csel-option{
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    color: var(--ink);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}
.csel-option:hover{ background: var(--surface-solid); }
.csel-option.active{
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 600;
}

html[data-graphics="high"] .csel-panel{
    animation: fadeScaleIn var(--dur-fast) var(--ease-smooth) both;
    transform-origin: top left;
}
html[data-graphics="high"] .csel-option{
    transition: background var(--dur-fast) ease;
}

/* ---------- Custom select: โหมด grid / grid-tabs (สวยงามขึ้นสำหรับห้องเรียน/กลุ่มอังกฤษ) ---------- */
.csel-panel-grid{
    width: max-content;
    max-width: min(320px, 88vw);
    padding: 10px;
}

.csel-tabs{
    display: flex;
    gap: 4px;
    background: color-mix(in srgb, var(--ink) 5%, transparent);
    border-radius: 999px;
    padding: 4px;
    margin-bottom: 10px;
}
.csel-tab{
    flex: 1;
    border: none;
    background: transparent;
    color: var(--ink-muted);
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}
.csel-tab.active{
    background: var(--accent);
    color: var(--accent-ink);
    box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--accent) 60%, transparent);
}

.csel-grid{
    display: grid;
    grid-template-columns: repeat(var(--csel-cols, 3), 1fr);
    gap: 7px;
}

.csel-grid-btn{
    position: relative;
    border: 1px solid var(--border-strong);
    background: var(--surface-solid);
    color: var(--ink);
    border-radius: var(--radius-sm);
    padding: 11px 6px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    text-align: center;
    line-height: 1.2;
}
.csel-grid-btn.active{
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
    box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 65%, transparent);
}
.csel-grid-btn.active::after{
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--accent-ink);
    opacity: .85;
}

html[data-graphics="high"] .csel-tab{
    transition: background var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
html[data-graphics="high"] .csel-grid-btn{
    transition: transform var(--dur-fast) var(--ease-smooth),
                box-shadow var(--dur-fast) ease,
                border-color var(--dur-fast) ease,
                background var(--dur-fast) ease;
}
html[data-graphics="high"] .csel-grid-btn:hover{
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
    box-shadow: 0 8px 18px -8px color-mix(in srgb, var(--accent) 45%, transparent);
}
html[data-graphics="high"] .csel-grid-btn:active{
    transform: translateY(0) scale(.95);
}
html[data-graphics="high"] .csel-grid-btn.active{
    animation: glowIn .5s ease forwards;
}

.notify-badge{
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--coral);
    color: #fff;
    font-size: 10px;
    font-family: var(--font-mono);
    font-weight: 600;
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
}

/* ---------- Hero "now" card ---------- */
.hero{
    background: var(--surface);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 22px 18px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 14px;
    position: relative;
}

.hero-top{
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
}

.hero-date{
    font-size: 13px;
    color: var(--ink-muted);
}

.hero-date .week-tag{
    display: inline-block;
    margin-left: 6px;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
}

.hero-clock{
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.now-label{
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--ink-faint);
    font-weight: 600;
    margin-bottom: 6px;
}

.now-subject{
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(22px, 6vw, 30px);
    line-height: 1.15;
    margin-bottom: 6px;
}
html[data-theme="dark"] .hero-clock{
    text-shadow: 0 0 20px rgba(255,255,255,0.35), 0 0 4px rgba(255,255,255,0.25);
}
html[data-theme="dark"] .now-subject{
    text-shadow: 0 0 18px rgba(59,130,246,0.25);
}

.now-meta{
    color: var(--ink-muted);
    font-size: 14px;
    margin-bottom: 14px;
}

.now-meta span{ font-family: var(--font-mono); }

.progress-track{
    height: 6px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}
.progress-fill{
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-bright));
    border-radius: 999px;
    transition: width 1s linear;
}

.hero-split{
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
}

.mini-card{
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
}
.mini-card .mini-label{
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--ink-faint);
    font-weight: 600;
    margin-bottom: 4px;
}
.mini-card .mini-subject{
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}
.mini-card .mini-detail{
    font-size: 12px;
    color: var(--ink-muted);
    font-family: var(--font-mono);
}
.mini-card.free .mini-label{ color: var(--mint); }

/* ---------- Day tabs ---------- */
.day-tabs{
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 10px 2px 16px;
    margin: -10px -2px 0;
    scrollbar-width: none;
}
.day-tabs::-webkit-scrollbar{ display: none; }

.day-tab{
    flex-shrink: 0;
    border: 1px solid var(--border);
    background: var(--surface-solid);
    color: var(--ink-muted);
    border-radius: 999px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.day-tab.active{
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}
.day-tab .dot{
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: var(--gold);
    margin-left: 6px;
    vertical-align: middle;
}

/* ---------- Week pill row ---------- */
.week-row{
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}
.week-row .week-label{
    font-size: 12px;
    color: var(--ink-faint);
}
.week-pill-group{
    display: flex;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
}
.week-pill{
    border: none;
    background: var(--surface-solid);
    color: var(--ink-muted);
    padding: 6px 14px;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.week-pill:first-child{ border-radius: 999px 0 0 999px; }
.week-pill:last-child{ border-radius: 0 999px 999px 0; }
.week-pill.active{
    background: var(--accent);
    color: var(--accent-ink);
}

/* ---------- Class list ---------- */
.class-list{
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.class-item{
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface-faint);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
}

.class-item.is-now{
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent) inset;
}
html[data-theme="dark"] .class-item.is-now{
    background: rgba(37,99,235,0.22);
    border-color: #60a5fa;
    box-shadow: 0 0 25px rgba(59,130,246,0.35), inset 0 0 12px rgba(59,130,246,0.25);
}

.class-item .time-badge{
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    text-align: center;
    flex-shrink: 0;
    min-width: 78px;
    white-space: pre-line;
    line-height: 1.3;
}

.class-item .item-body{ flex: 1; min-width: 0; }

.class-item .item-subject{
    font-weight: 600;
    font-size: 14.5px;
    margin-bottom: 2px;
    overflow-wrap: anywhere;
}

.class-item .item-detail{
    font-size: 12.5px;
    color: var(--ink-muted);
}

.empty-state{
    text-align: center;
    padding: 40px 20px;
    color: var(--ink-faint);
    font-size: 14px;
}

/* ---------- Modal ---------- */
.modal-overlay{
    position: fixed;
    inset: 0;
    background: rgba(10,11,14,0.55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
    padding: 0;
}
@media (min-width: 640px){
    .modal-overlay{ align-items: center; padding: 20px; }
}

.modal-card{
    background: var(--surface-strong);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 520px;
    max-height: 82vh;
    border-radius: 22px 22px 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
@media (min-width: 640px){
    .modal-card{ border-radius: var(--radius-lg); max-height: 78vh; }
}

.modal-head{
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}
.modal-head h2{
    font-family: var(--font-display);
    font-size: 17px;
    margin: 0;
}
.modal-head .modal-sub{
    font-size: 12px;
    color: var(--ink-muted);
    margin-top: 2px;
}
.modal-close{
    border: none;
    background: var(--surface-solid);
    border: 1px solid var(--border);
    padding: 7px 14px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.modal-toolbar{
    display: flex;
    gap: 8px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
}
.modal-toolbar button{
    border: 1px solid var(--border-strong);
    background: var(--surface-solid);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: var(--ink-muted);
}
.modal-toolbar button.active{
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.modal-body{
    padding: 14px 18px 20px;
    overflow-y: auto;
}

.notify-card{
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 10px;
    background: var(--surface-solid);
}
.notify-card.expired{ opacity: 0.55; }
.notify-card .n-top{
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
}
.notify-card .n-subject{ font-weight: 700; font-size: 14px; }
.notify-card .n-time{
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--gold);
    background: color-mix(in srgb, var(--gold) 16%, transparent);
    border-radius: 999px;
    padding: 3px 8px;
    white-space: nowrap;
    height: fit-content;
}
.notify-card .n-note{
    font-size: 13px;
    color: var(--ink-muted);
    white-space: pre-line;
}

footer.site-footer{
    text-align: center;
    color: var(--ink-faint);
    font-size: 12px;
    margin-top: 30px;
}

/* ---------- Utility ---------- */
.visually-hidden{
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
}

/* ==========================================================================
   High / Low Graphic Mode
   ตั้งค่าผ่าน data-graphics="high" | "low" บน <html>
   ค่าเริ่มต้นของเว็บคือ "high" — ให้ความรู้สึกลื่นไหล มีมิติ มีเงา/ขอบเรืองแสง
   ตอนชี้คอนเทนเนอร์ ส่วน "low" คือโหมดเรียบ ไม่มีอนิเมชั่น เหมาะกับเครื่องที่แรงน้อย
   ========================================================================== */

/* ---- High graphic: จังหวะ/ระยะเวลาของอนิเมชั่นทั้งหมด ---- */
html[data-graphics="high"]{
    --ease-smooth: cubic-bezier(.22,.85,.32,1.1);
    --dur-fast: .18s;
    --dur-med: .32s;
    --dur-slow: .55s;
}

@keyframes fadeSlideUp{
    from{ opacity: 0; transform: translateY(14px); }
    to{ opacity: 1; transform: translateY(0); }
}
@keyframes fadeScaleIn{
    from{ opacity: 0; transform: scale(.94); }
    to{ opacity: 1; transform: scale(1); }
}
@keyframes shimmerSweep{
    0%{ background-position: -120% 0; }
    100%{ background-position: 220% 0; }
}
@keyframes softPulse{
    0%, 100%{ box-shadow: 0 0 0 0 color-mix(in srgb, var(--coral) 55%, transparent); }
    50%{ box-shadow: 0 0 0 5px color-mix(in srgb, var(--coral) 0%, transparent); }
}
@keyframes glowIn{
    from{ box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent); }
    to{ box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
}

/* ---- เข้าเว็บ: การ์ดหลักและรายการต่าง ๆ ลอยขึ้นมาแบบมีจังหวะ ---- */
html[data-graphics="high"] .hero{
    animation: fadeSlideUp var(--dur-slow) var(--ease-smooth) both;
}
html[data-graphics="high"] .week-row,
html[data-graphics="high"] .day-tabs{
    animation: fadeSlideUp var(--dur-slow) var(--ease-smooth) .08s both;
}
html[data-graphics="high"] .class-item{
    animation: fadeSlideUp var(--dur-med) var(--ease-smooth) both;
}
html[data-graphics="high"] .class-list .class-item:nth-child(1){ animation-delay: .03s; }
html[data-graphics="high"] .class-list .class-item:nth-child(2){ animation-delay: .07s; }
html[data-graphics="high"] .class-list .class-item:nth-child(3){ animation-delay: .11s; }
html[data-graphics="high"] .class-list .class-item:nth-child(4){ animation-delay: .15s; }
html[data-graphics="high"] .class-list .class-item:nth-child(5){ animation-delay: .19s; }
html[data-graphics="high"] .class-list .class-item:nth-child(n+6){ animation-delay: .22s; }

html[data-graphics="high"] .notify-card{
    animation: fadeSlideUp var(--dur-med) var(--ease-smooth) both;
}
html[data-graphics="high"] .login-card{
    animation: fadeScaleIn var(--dur-slow) var(--ease-smooth) both;
}

/* ---- คอนเทนเนอร์ต่าง ๆ: ลอยขึ้น + เงาเข้ม + ขอบเรืองแสงตอนชี้ ---- */
html[data-graphics="high"] .hero,
html[data-graphics="high"] .mini-card,
html[data-graphics="high"] .class-item,
html[data-graphics="high"] .notify-card,
html[data-graphics="high"] .card,
html[data-graphics="high"] .row-card,
html[data-graphics="high"] .live-status{
    transition: transform var(--dur-med) var(--ease-smooth),
                box-shadow var(--dur-med) var(--ease-smooth),
                border-color var(--dur-med) ease;
}
html[data-graphics="high"] .mini-card:hover,
html[data-graphics="high"] .class-item:hover,
html[data-graphics="high"] .notify-card:hover,
html[data-graphics="high"] .card:hover,
html[data-graphics="high"] .row-card:hover{
    transform: translateY(-3px);
    box-shadow: var(--shadow-soft);
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

/* ---- ปุ่มและตัวเลือกต่าง ๆ: ลื่นขึ้น มีแรงกดตอนคลิก ---- */
html[data-graphics="high"] .select-pill,
html[data-graphics="high"] .icon-btn,
html[data-graphics="high"] .csel-trigger,
html[data-graphics="high"] .day-tab,
html[data-graphics="high"] .week-pill,
html[data-graphics="high"] .modal-toolbar button,
html[data-graphics="high"] .btn,
html[data-graphics="high"] .tag-btn{
    transition: transform var(--dur-fast) var(--ease-smooth),
                box-shadow var(--dur-fast) ease,
                border-color var(--dur-fast) ease,
                background var(--dur-fast) ease;
}
html[data-graphics="high"] .select-pill:hover,
html[data-graphics="high"] .icon-btn:hover,
html[data-graphics="high"] .csel-trigger:hover,
html[data-graphics="high"] .day-tab:hover,
html[data-graphics="high"] .week-pill:hover,
html[data-graphics="high"] .tag-btn:hover{
    transform: translateY(-2px);
    box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--accent) 50%, transparent);
}
html[data-graphics="high"] .btn:hover{
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--accent) 60%, transparent);
}
html[data-graphics="high"] .select-pill:active,
html[data-graphics="high"] .icon-btn:active,
html[data-graphics="high"] .day-tab:active,
html[data-graphics="high"] .btn:active,
html[data-graphics="high"] .tag-btn:active{
    transform: translateY(0) scale(.96);
}
html[data-graphics="high"] .day-tab.active,
html[data-graphics="high"] .week-pill.active{
    box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--accent) 65%, transparent);
}

/* ---- คาบเรียนปัจจุบัน: ขอบเรืองแสงเบา ๆ ตลอดเวลา ---- */
html[data-graphics="high"] .class-item.is-now{
    animation: glowIn .6s ease forwards;
}

/* ---- แถบความคืบหน้า: แสงวิ่งผ่านเบา ๆ ---- */
html[data-graphics="high"] .progress-fill{
    background-image: linear-gradient(90deg, var(--accent), var(--accent-bright)),
                       linear-gradient(110deg, transparent 20%, rgba(255,255,255,.55) 50%, transparent 80%);
    background-size: 100% 100%, 200% 100%;
    background-blend-mode: normal, overlay;
    animation: shimmerSweep 2.6s linear infinite;
    transition: width 1s linear;
}

/* ---- แจ้งเตือน: เต้นเบา ๆ ตอนมีรายการใหม่ ---- */
html[data-graphics="high"] .notify-badge{
    animation: softPulse 1.8s ease-in-out infinite;
}

/* ---- Modal: เด้งเข้าแบบนุ่มนวล ---- */
html[data-graphics="high"] .modal-overlay{
    animation: fadeSlideUp .25s ease both;
}
html[data-graphics="high"] .modal-card{
    animation: fadeScaleIn var(--dur-med) var(--ease-smooth) both;
}

/* ---- โฟกัสฟอร์ม: วงแหวนโฟกัสนุ่มนวลขึ้น ---- */
html[data-graphics="high"] input:focus,
html[data-graphics="high"] select:focus,
html[data-graphics="high"] textarea:focus{
    transition: box-shadow var(--dur-fast) ease;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* ---- Low graphic: ปิดอนิเมชั่น/เงา/เบลอทั้งหมด เพื่อประสิทธิภาพสูงสุด ---- */
html[data-graphics="low"] *{
    animation: none !important;
    transition: none !important;
}
html[data-graphics="low"] .hero,
html[data-graphics="low"] .class-item,
html[data-graphics="low"] .modal-card{
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
html[data-graphics="low"] .hero{ box-shadow: none; }

@media (prefers-reduced-motion: reduce){
    *{ transition: none !important; animation: none !important; }
}

