/**
 * Public Learning Portal Stylesheet (TOR 4.5.3 (2))
 * ระบบห้องเรียนความรู้สำหรับประชาชนและครอบครัว
 * Smong Care Production System
 */

:root {
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.12);
    --card-bg: rgba(30, 41, 59, 0.7);
    --bg-primary: rgba(15, 23, 42, 0.6);
}

html[data-theme="light"],
[data-theme="light"] {
    --text-primary: #0f172a;
    --text-muted: #475569;
    --border-color: rgba(15, 23, 42, 0.12);
    --card-bg: rgba(255, 255, 255, 0.9);
    --bg-primary: #f8fafc;
}

/* ============================================================
   Elderly Senior Accessibility Mode (TOR 4.6.2 & มาตรฐานบริการผู้สูงอายุ)
   กำหนดขนาดพื้นฐานและขนาดปรับระดับตัวอักษรสำหรับผู้รับบริการผู้สูงอายุ
   ============================================================ */
html.public-elderly-ui {
    font-size: 112.5%; /* 18px base root สำหรับผู้สูงอายุ */
}
html.public-elderly-ui[data-font-scale="normal"] { font-size: 112.5%; } /* 18px */
html.public-elderly-ui[data-font-scale="lg"]     { font-size: 125%; }   /* 20px (ตาม TOR 4.6.2 ขั้นต่ำ 20px) */
html.public-elderly-ui[data-font-scale="xl"]     { font-size: 137.5%; } /* 22px */
html.public-elderly-ui[data-font-scale="xxl"]    { font-size: 150%; }   /* 24px */

body.public-elderly-ui {
    padding: 0 !important;
    margin: 0 !important;
    font-size: 1.12rem;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Citizen Hero & Header
   ============================================================ */
.public-hero {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12) 0%, rgba(59, 130, 246, 0.08) 100%);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

.public-hero-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.public-profile-card {
    display: flex;
    align-items: center;
    gap: 14px;
}

.public-avatar {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: 3px solid #10b981;
    object-fit: cover;
    background: #e2e8f0;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.public-avatar-placeholder {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: 3px solid #10b981;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.public-user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.public-user-name {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.public-badge-line {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(6, 199, 85, 0.15);
    color: #059669;
    border: 1px solid rgba(6, 199, 85, 0.35);
    font-size: 0.92rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 14px;
}

[data-theme="dark"] .public-badge-line {
    background: rgba(6, 199, 85, 0.25);
    color: #34d399;
    border-color: rgba(6, 199, 85, 0.5);
}

.public-realname-chip {
    font-size: 1.05rem;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 600;
}

.public-realname-chip:hover {
    color: #10b981;
}

/* Controls */
.public-top-controls {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.font-scale-group {
    display: inline-flex;
    align-items: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 2px 4px;
    gap: 2px;
    height: 42px;
    box-sizing: border-box;
}

.font-scale-group .font-scale-btn,
.font-scale-btn {
    border: none !important;
    background: transparent !important;
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 10px;
    font-weight: 800;
    cursor: pointer;
    font-size: 1.05rem;
    line-height: 1;
    width: auto;
    height: auto;
    transition: all 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

[data-theme="light"] .font-scale-group .font-scale-btn,
[data-theme="light"] .font-scale-btn {
    background: transparent !important;
    border: none !important;
}

.font-scale-group .font-scale-btn:hover,
.font-scale-btn:hover {
    background: rgba(16, 185, 129, 0.15) !important;
    color: #10b981;
}

.font-scale-group .font-scale-btn:active,
.font-scale-btn:active {
    transform: scale(0.92);
}

.font-scale-value {
    font-size: 0.92rem;
    color: var(--text-muted);
    font-weight: 700;
    min-width: 34px;
    text-align: center;
    user-select: none;
}

.public-theme-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.public-theme-btn:hover {
    border-color: #10b981;
    color: #10b981;
    background: rgba(16, 185, 129, 0.12);
}

.public-theme-btn:active {
    transform: scale(0.92);
}

/* ============================================================
   Progress Summary Banner
   ============================================================ */
.curriculum-progress-box {
    background: var(--bg-primary);
    border: 1.5px solid var(--border-color);
    border-radius: 20px;
    padding: 20px 22px;
    margin-top: 18px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-weight: 800;
    font-size: 1.15rem;
}

.progress-bar-container {
    height: 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-color);
}

[data-theme="light"] .progress-bar-container {
    background: #e2e8f0;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
    transition: width 0.4s ease;
}

/* Grand Certificate Banner */
.grand-cert-banner {
    display: none;
    background: linear-gradient(135deg, rgba(217, 119, 6, 0.18) 0%, rgba(245, 158, 11, 0.1) 100%);
    border: 2px solid #f59e0b;
    border-radius: 22px;
    padding: 28px 24px;
    margin-bottom: 24px;
    text-align: center;
    box-shadow: 0 8px 28px rgba(245, 158, 11, 0.2);
}

.grand-cert-banner.active {
    display: block;
    animation: goldGlow 2.5s infinite alternate;
}

@keyframes goldGlow {
    0% { box-shadow: 0 4px 20px rgba(245, 158, 11, 0.2); }
    100% { box-shadow: 0 8px 36px rgba(245, 158, 11, 0.45); }
}

.grand-cert-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #d97706, #b45309);
    color: #fff !important;
    font-weight: 800;
    font-size: 1.25rem;
    padding: 16px 32px;
    border-radius: 25px;
    border: none;
    cursor: pointer;
    margin-top: 16px;
    text-decoration: none;
    box-shadow: 0 6px 20px rgba(180, 83, 9, 0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.grand-cert-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 26px rgba(180, 83, 9, 0.5);
}

/* ============================================================
   10 Module Cards Grid
   ============================================================ */
.module-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.module-card {
    background: var(--card-bg);
    border: 1.5px solid var(--border-color);
    border-radius: 20px;
    padding: 22px 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.module-card:hover:not(.is-locked) {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    border-color: #10b981;
}

.module-card.is-locked {
    cursor: not-allowed;
    background: var(--bg-primary);
    opacity: 0.72;
    filter: grayscale(0.85);
    border-style: dashed;
}

.module-card.is-completed {
    border-color: rgba(16, 185, 129, 0.4);
    background: linear-gradient(180deg, var(--card-bg) 0%, rgba(16, 185, 129, 0.03) 100%);
}

.module-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.module-no-badge {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.module-status-badge {
    font-size: 0.92rem;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 14px;
}

.status-compulsory {
    background: rgba(59, 130, 246, 0.12);
    color: #2563eb;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.status-completed {
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.status-unlocked {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.status-locked {
    background: rgba(100, 116, 139, 0.15);
    color: #64748b;
    border: 1px solid rgba(100, 116, 139, 0.3);
}

.module-content-main {
    display: flex;
    gap: 16px;
    margin-bottom: 18px;
    align-items: flex-start;
}

.module-icon-wrap {
    font-size: 2.3rem;
    width: 62px;
    height: 62px;
    border-radius: 18px;
    background: rgba(16, 185, 129, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.module-card.is-locked .module-icon-wrap {
    background: rgba(100, 116, 139, 0.1);
}

.module-info {
    flex: 1;
}

.module-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.module-summary {
    font-size: 1.12rem;
    color: var(--text-muted);
    line-height: 1.65;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

.module-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}

.clip-count-pill {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 600;
}

.cert-chip-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
    font-weight: 800;
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.35);
    padding: 6px 14px;
    border-radius: 16px;
    text-decoration: none;
    transition: all 0.15s ease;
}

.cert-chip-btn:hover {
    background: #d97706;
    color: #fff;
}

/* Module Card Action Button (Mobile-First Touch Button) */
.module-card-footer {
    margin-top: 16px;
}

.module-card-btn {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 60px;
    padding: 14px 22px;
    border-radius: 18px;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    box-sizing: border-box;
    text-decoration: none;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.module-card-btn:active {
    transform: scale(0.98);
}

.module-card-btn.is-btn-locked {
    cursor: not-allowed;
    opacity: 0.65;
    background: rgba(100, 116, 139, 0.1) !important;
    border: 1px solid rgba(100, 116, 139, 0.25) !important;
    color: var(--text-muted) !important;
}

.article-actions-bottom {
    display: flex;
    gap: 14px;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* ============================================================
   Lesson View Split Layout (Desktop & Mobile)
   ============================================================ */
.lesson-view-container {
    max-width: 1680px;
    margin: 0 auto;
    padding: 16px;
}

.lesson-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.lesson-split-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

@media (min-width: 1024px) {
    .lesson-split-grid {
        grid-template-columns: minmax(0, 1.35fr) minmax(360px, 1fr);
        align-items: start;
    }
}

.video-player-card {
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    aspect-ratio: 16 / 9;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.video-player-card iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.btn-manual-video-done {
    border-radius: 20px;
    font-size: 0.86rem;
    font-weight: 700;
    padding: 6px 16px;
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.35);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-manual-video-done:hover {
    background: rgba(16, 185, 129, 0.22);
    transform: translateY(-1px);
}

html[data-theme="light"] .btn-manual-video-done,
[data-theme="light"] .btn-manual-video-done {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #10b981;
}

html[data-theme="light"] .btn-manual-video-done:hover,
[data-theme="light"] .btn-manual-video-done:hover {
    background: #d1fae5;
}

/* Playlist Episodes */
.playlist-section {
    margin-top: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 14px;
}

.playlist-header {
    font-size: 0.92rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.playlist-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.playlist-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 0.88rem;
    transition: all 0.15s ease;
}

.playlist-item.active {
    background: rgba(16, 185, 129, 0.12);
    border-color: #10b981;
    font-weight: 700;
    color: #10b981;
}

/* Details & Quiz Card */
.lesson-details-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.quiz-trigger-card {
    background: var(--bg-primary);
    border: 1.5px dashed var(--border-color);
    border-radius: 14px;
    padding: 18px;
    text-align: center;
    transition: all 0.2s ease;
}

.quiz-trigger-card.is-ready {
    border-style: solid;
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.btn-quiz-launch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff !important;
    font-weight: 700;
    font-size: 1rem;
    padding: 12px 24px;
    border-radius: 25px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn-quiz-launch:hover:not(.is-locked) {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.45);
    color: #fff !important;
}

/* Locked Quiz Button State (High Contrast in both Dark and Light themes) */
.btn-quiz-launch.is-locked {
    background: rgba(100, 116, 139, 0.18) !important;
    color: #cbd5e1 !important;
    border: 1.5px dashed rgba(148, 163, 184, 0.45) !important;
    box-shadow: none !important;
    cursor: pointer;
}

.btn-quiz-launch.is-locked:hover {
    background: rgba(100, 116, 139, 0.3) !important;
    color: #f1f5f9 !important;
    border-color: rgba(148, 163, 184, 0.65) !important;
    transform: translateY(-1px);
}

/* Light Theme Visibility Enhancements */
html[data-theme="light"] .quiz-trigger-card,
[data-theme="light"] .quiz-trigger-card {
    background: #f8fafc;
    border: 1.5px dashed #cbd5e1;
}

html[data-theme="light"] .quiz-trigger-card.is-ready,
[data-theme="light"] .quiz-trigger-card.is-ready {
    background: #ecfdf5;
    border: 1.5px solid #10b981;
}

html[data-theme="light"] .btn-quiz-launch.is-locked,
[data-theme="light"] .btn-quiz-launch.is-locked {
    background: #f1f5f9 !important;
    color: #1e293b !important;
    border: 1.5px dashed #94a3b8 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
}

html[data-theme="light"] .btn-quiz-launch.is-locked:hover,
[data-theme="light"] .btn-quiz-launch.is-locked:hover {
    background: #e2e8f0 !important;
    color: #0f172a !important;
    border-color: #64748b !important;
}

html[data-theme="light"] .btn-quiz-launch:not(.is-locked),
[data-theme="light"] .btn-quiz-launch:not(.is-locked) {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-pulse-highlight {
    animation: btnPulse 2s infinite;
}

@keyframes btnPulse {
    0% { transform: scale(1); box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35); }
    50% { transform: scale(1.03); box-shadow: 0 6px 22px rgba(16, 185, 129, 0.6); }
    100% { transform: scale(1); box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35); }
}

/* Article Reader Section */
.article-full-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    line-height: 1.9;
    font-size: 1rem;
    color: var(--text-primary);
}

.article-full-card h3 {
    margin-top: 0;
    font-size: 1.3rem;
    color: #10b981;
}

/* ============================================================
   Interactive Quiz Modal
   ============================================================ */
#modal-quiz {
    z-index: 20000 !important;
}

body.quiz-modal-open {
    overflow: hidden !important;
}

body.quiz-modal-open .public-bottom-nav {
    display: none !important;
}

.quiz-modal-container {
    max-width: 680px;
    width: 90%;
    background: var(--card-bg);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    padding: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

html[data-theme="light"] .quiz-modal-container,
[data-theme="light"] .quiz-modal-container {
    background: #ffffff;
    border-color: #cbd5e1;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

.quiz-option-label {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    color: var(--text-primary);
}

html[data-theme="light"] .quiz-option-label,
[data-theme="light"] .quiz-option-label {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #0f172a;
}

.quiz-option-label:hover {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

html[data-theme="light"] .quiz-option-label:hover,
[data-theme="light"] .quiz-option-label:hover {
    background: #f0fdf4;
    border-color: #10b981;
}

.quiz-option-label.is-correct {
    background: rgba(16, 185, 129, 0.15) !important;
    border-color: #10b981 !important;
    font-weight: 600;
}

html[data-theme="light"] .quiz-option-label.is-correct,
[data-theme="light"] .quiz-option-label.is-correct {
    background: #ecfdf5 !important;
    border-color: #10b981 !important;
    color: #065f46 !important;
}

.quiz-option-label.is-wrong {
    background: rgba(239, 68, 68, 0.15) !important;
    border-color: #ef4444 !important;
}

html[data-theme="light"] .quiz-option-label.is-wrong,
[data-theme="light"] .quiz-option-label.is-wrong {
    background: #fef2f2 !important;
    border-color: #ef4444 !important;
    color: #991b1b !important;
}

.explanation-box {
    background: rgba(59, 130, 246, 0.08);
    border-left: 4px solid #3b82f6;
    border-radius: 4px;
    padding: 10px 14px;
    font-size: 0.88rem;
    margin-top: 8px;
    line-height: 1.6;
    color: var(--text-primary);
}

html[data-theme="light"] .explanation-box,
[data-theme="light"] .explanation-box {
    background: #eff6ff;
    border-left-color: #3b82f6;
    color: #1e3a8a;
}

.quiz-question-item {
    transition: all 0.25s ease;
}

.quiz-question-item.unanswered-highlight {
    outline: 2px solid #ef4444;
    outline-offset: 4px;
    background: rgba(239, 68, 68, 0.08);
    border-radius: 14px;
    padding: 12px 14px;
    animation: quizShakeMissing 0.4s ease-in-out;
}

@keyframes quizShakeMissing {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

/* ============================================================
   Public Portal / Landing Page Styles (Smong Care Citizen Hub)
   ============================================================ */

.portal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.portal-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 22px;
    padding: 24px 22px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.portal-card[data-open-modal] {
    cursor: pointer;
}

.portal-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
    border-color: rgba(16, 185, 129, 0.45);
}

.portal-card:active {
    transform: scale(0.985);
}

/* Card Colored Top Borders for High Affordance */
.portal-card.card-accent-amber {
    border-top: 4px solid #f59e0b;
}

.portal-card.card-accent-purple {
    border-top: 4px solid #8b5cf6;
}

.portal-card.card-accent-blue {
    border-top: 4px solid #0284c7;
}

.portal-card.card-accent-emerald {
    border-top: 4px solid #10b981;
}

.portal-card.highlight {
    grid-column: 1 / -1;
    border: 2px solid rgba(16, 185, 129, 0.55);
    border-top: 4px solid #10b981;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12) 0%, rgba(6, 182, 212, 0.06) 50%, var(--card-bg) 100%);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.12);
    padding: 28px 26px;
    cursor: default;
}

[data-theme="light"] .portal-card.highlight {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(6, 182, 212, 0.04) 50%, #ffffff 100%);
}

.portal-card.highlight:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(16, 185, 129, 0.18);
}

.portal-hero-highlights {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 18px 0;
}

.hero-highlight-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    white-space: nowrap;
}

.portal-card-full {
    grid-column: 1 / -1;
}

.portal-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.portal-card-icon {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    flex-shrink: 0;
    transition: transform 0.2s ease;
    font-size: 2rem;
}

.portal-card:hover .portal-card-icon {
    transform: scale(1.05);
}

.portal-icon-emerald {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.25);
}

.portal-icon-blue {
    background: rgba(2, 132, 199, 0.12);
    color: #0284c7;
    border-color: rgba(2, 132, 199, 0.25);
}

.portal-icon-amber {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
    border-color: rgba(245, 158, 11, 0.25);
}

.portal-icon-purple {
    background: rgba(139, 92, 246, 0.12);
    color: #8b5cf6;
    border-color: rgba(139, 92, 246, 0.25);
}

.portal-icon-rose {
    background: rgba(244, 63, 94, 0.12);
    color: #e11d48;
    border-color: rgba(244, 63, 94, 0.25);
}

[data-theme="dark"] .portal-icon-emerald {
    background: rgba(16, 185, 129, 0.18);
    color: #34d399;
}

[data-theme="dark"] .portal-icon-blue {
    background: rgba(2, 132, 199, 0.18);
    color: #38bdf8;
}

[data-theme="dark"] .portal-icon-amber {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
}

[data-theme="dark"] .portal-icon-purple {
    background: rgba(139, 92, 246, 0.18);
    color: #a78bfa;
}

[data-theme="dark"] .portal-icon-rose {
    background: rgba(244, 63, 94, 0.18);
    color: #fb7185;
}

.portal-card-badge {
    font-size: 0.95rem;
    font-weight: 700;
    padding: 7px 16px;
    border-radius: 20px;
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    white-space: nowrap;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.portal-card-badge.badge-blue {
    background: rgba(2, 132, 199, 0.12);
    color: #0284c7;
    border-color: rgba(2, 132, 199, 0.25);
}

.portal-card-badge.badge-amber {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
    border-color: rgba(245, 158, 11, 0.25);
}

.portal-card-badge.badge-purple {
    background: rgba(139, 92, 246, 0.12);
    color: #8b5cf6;
    border-color: rgba(139, 92, 246, 0.25);
}

.portal-card-badge.badge-rose {
    background: rgba(244, 63, 94, 0.12);
    color: #e11d48;
    border-color: rgba(244, 63, 94, 0.25);
}

.portal-card-title {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 10px 0;
    line-height: 1.35;
    letter-spacing: -0.2px;
}

.portal-card-title.portal-card-title-lg {
    font-size: 1.85rem;
}

.portal-card-desc {
    font-size: 1.18rem;
    color: var(--text-muted);
    line-height: 1.75;
    margin: 0 0 20px 0;
    flex-grow: 1;
}

.portal-card-desc.portal-card-desc-lg {
    font-size: 1.25rem;
}

.portal-card-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
}

.portal-card-action {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 64px;
    padding: 16px 24px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 1.25rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    box-sizing: border-box;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.portal-card-action:active {
    transform: scale(0.98);
}

.portal-btn-primary {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
}

.portal-btn-primary:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #fff;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
    transform: translateY(-2px);
}

.portal-btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1.5px solid var(--border-color);
}

.portal-btn-secondary:hover {
    background: rgba(16, 185, 129, 0.08);
    border-color: #10b981;
    color: #10b981;
    transform: translateY(-2px);
}

.portal-btn-lg {
    min-height: 68px;
    font-size: 1.3rem;
}

/* Welfare Items & Accordion */
.welfare-card-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 22px 20px;
    margin-bottom: 16px;
    transition: border-color 0.2s ease;
}

.welfare-card-item:hover {
    border-color: #10b981;
}

.welfare-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.welfare-item-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.4;
}

.welfare-item-amount {
    display: inline-block;
    padding: 6px 14px;
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border-radius: 20px;
    font-size: 1.15rem;
    font-weight: 800;
    margin-bottom: 10px;
}

.welfare-item-list {
    margin: 10px 0 14px 20px;
    padding: 0;
    color: var(--text-muted);
    font-size: 1.12rem;
    line-height: 1.75;
}

.welfare-meta-box {
    background: var(--card-bg);
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    padding: 14px 18px;
    font-size: 1.08rem;
    color: var(--text-muted);
    line-height: 1.7;
    margin-top: 10px;
}

/* Screening Test Styles */
.screening-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 26px;
    margin-top: 24px;
}

.screening-item-label {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px;
    border-radius: 14px;
    background: var(--bg-primary);
    border: 1.5px solid var(--border-color);
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 1.18rem;
    color: var(--text-primary);
    line-height: 1.6;
    transition: all 0.15s ease;
}

.screening-item-label:hover {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.04);
}

.screening-item-label input[type="checkbox"],
.screening-item-label input[type="radio"] {
    width: 26px;
    height: 26px;
    margin-top: 3px;
    flex-shrink: 0;
    accent-color: #10b981;
}

.screening-result-panel {
    border-radius: 18px;
    padding: 24px;
    margin-top: 20px;
    display: none;
    text-align: center;
}

/* Modern Public Profile Banner */
.public-profile-banner {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 22px;
    padding: 20px 24px;
    margin-bottom: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.profile-banner-user {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
    flex: 1;
}

.profile-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.profile-user-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.public-user-welcome {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.2;
}

.profile-user-name-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.profile-name-text {
    font-size: 1.38rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.3;
}

.profile-banner-action {
    flex-shrink: 0;
}

.public-realname-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 20px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    border: 1.5px solid rgba(16, 185, 129, 0.28);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.public-realname-chip:hover {
    background: rgba(16, 185, 129, 0.18);
    border-color: #10b981;
    transform: translateY(-1px);
}

.public-realname-chip.has-name {
    color: var(--text-primary);
    background: rgba(16, 185, 129, 0.08);
}

.status-dot-pulse {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: statusPulse 2s infinite;
    margin-right: 6px;
    vertical-align: middle;
}

@keyframes statusPulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.public-section-head {
    margin: 8px 0 18px 0;
}

.public-section-title {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 6px 0;
    letter-spacing: -0.2px;
}

.public-section-subtitle {
    font-size: 1.12rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.6;
}

/* Dedicated Emergency Assistance Section */
.public-emergency-section {
    background: var(--card-bg);
    border: 1.5px solid rgba(239, 68, 68, 0.25);
    border-radius: 22px;
    padding: 22px 24px;
    margin-bottom: 28px;
    box-shadow: 0 4px 18px rgba(239, 68, 68, 0.06);
    position: relative;
    overflow: hidden;
}

.public-emergency-section::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.emergency-section-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.emergency-header-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.emergency-section-title {
    font-size: 1.38rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 3px 0;
}

.emergency-section-subtitle {
    font-size: 1.05rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
}

/* Emergency Hotline Pills - Modern Large Touch Buttons */
.hotline-pills-wrap {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-top: 14px;
}

.hotline-pill {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 64px;
    padding: 14px 20px;
    border-radius: 18px;
    text-decoration: none;
    box-sizing: border-box;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.hotline-pill:active {
    transform: scale(0.97);
}

.hotline-icon-badge {
    font-size: 1.85rem;
    line-height: 1;
    flex-shrink: 0;
}

.hotline-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.hotline-num {
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.3px;
    line-height: 1.1;
}

.hotline-label {
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.2;
    opacity: 0.92;
}

.hotline-pill-red {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border: 1.5px solid rgba(239, 68, 68, 0.35);
}

.hotline-pill-red:hover {
    background: rgba(239, 68, 68, 0.18);
    transform: translateY(-2px);
}

.hotline-pill-green {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border: 1.5px solid rgba(16, 185, 129, 0.35);
}

.hotline-pill-green:hover {
    background: rgba(16, 185, 129, 0.18);
    transform: translateY(-2px);
}

.hotline-pill-amber {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
    border: 1.5px solid rgba(245, 158, 11, 0.35);
}

.hotline-pill-amber:hover {
    background: rgba(245, 158, 11, 0.18);
    transform: translateY(-2px);
}

.hotline-pill-purple {
    background: rgba(139, 92, 246, 0.12);
    color: #8b5cf6;
    border: 1.5px solid rgba(139, 92, 246, 0.35);
}

.hotline-pill-purple:hover {
    background: rgba(139, 92, 246, 0.18);
    transform: translateY(-2px);
}

/* Modal Close & Actions Styling */
.modal-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.modal-close-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.35);
    color: #ef4444;
}

.modal-close-btn:active {
    transform: scale(0.92);
}

.modal-footer-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.modal-btn-close-bottom {
    padding: 12px 30px;
    border-radius: 18px;
    font-size: 1.15rem;
    font-weight: 700;
}

/* ============================================================
   Mobile & Tablet Responsive Optimization (TOR 4.5.3 (2))
   ============================================================ */

@media (max-width: 900px) {
    .module-cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .lesson-view-container {
        padding: 14px 12px 80px;
    }

    .public-hero {
        padding: 18px 14px;
        border-radius: 16px;
        margin-bottom: 18px;
    }

    .public-hero-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .public-profile-card {
        gap: 12px;
        width: 100%;
    }

    .public-avatar,
    .public-avatar-placeholder {
        width: 48px;
        height: 48px;
        font-size: 1.4rem;
    }

    .public-user-name {
        font-size: 1.05rem;
        flex-wrap: wrap;
        gap: 6px;
    }

    .public-top-controls {
        width: auto;
        justify-content: flex-end;
        padding-top: 0;
        border-top: none;
    }

    .public-hero-title {
        font-size: 1.25rem !important;
        line-height: 1.35 !important;
    }

    .public-hero-desc {
        font-size: 0.88rem !important;
        line-height: 1.55 !important;
    }

    .curriculum-progress-box {
        padding: 12px 14px;
        border-radius: 14px;
        margin-top: 12px;
    }

    .module-section-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 4px !important;
    }

    /* 1 Column on mobile for clean card display */
    .portal-grid {
        grid-template-columns: 1fr;
        gap: 14px;
        margin-bottom: 20px;
    }

    .portal-card {
        padding: 20px 18px;
        border-radius: 18px;
    }

    .portal-card-icon {
        width: 52px;
        height: 52px;
        font-size: 1.85rem;
    }

    .portal-card-title {
        font-size: 1.25rem;
        font-weight: 800;
        line-height: 1.35;
    }

    .portal-card-desc {
        font-size: 0.98rem;
        line-height: 1.6;
    }

    .portal-card-action {
        min-height: 52px;
        font-size: 1.05rem;
        font-weight: 700;
        border-radius: 14px;
    }

    .module-cards-grid {
        grid-template-columns: 1fr;
        gap: 14px;
        margin-bottom: 24px;
    }

    .module-card {
        padding: 16px 14px;
        border-radius: 16px;
    }

    .module-content-main {
        gap: 12px;
        margin-bottom: 12px;
    }

    .module-icon-wrap {
        width: 48px;
        height: 48px;
        font-size: 1.85rem;
        border-radius: 14px;
    }

    .module-title {
        font-size: 1.15rem;
        font-weight: 800;
        line-height: 1.35;
        margin-bottom: 5px;
    }

    .module-summary {
        font-size: 0.94rem;
        line-height: 1.55;
    }

    .module-bottom {
        padding-top: 12px;
    }

    .grand-cert-banner {
        padding: 18px 14px;
        border-radius: 14px;
        margin-bottom: 18px;
    }

    .grand-cert-banner h2 {
        font-size: 1.2rem !important;
    }

    .grand-cert-btn {
        display: flex;
        width: 100%;
        justify-content: center;
        box-sizing: border-box;
        padding: 12px 18px;
        font-size: 0.92rem;
    }

    /* Senior Elderly Accessibility Overrides on Tablet/Mobile */
    .public-elderly-ui .public-avatar,
    .public-elderly-ui .public-avatar-placeholder {
        width: 64px;
        height: 64px;
        font-size: 1.85rem;
    }

    .public-elderly-ui .public-user-name {
        font-size: 1.3rem;
    }

    .public-elderly-ui .public-hero-title {
        font-size: 1.65rem !important;
        line-height: 1.35 !important;
    }

    .public-elderly-ui .public-hero-desc {
        font-size: 1.15rem !important;
        line-height: 1.65 !important;
    }

    .public-elderly-ui .portal-card {
        padding: 24px 20px;
    }

    .public-elderly-ui .portal-card-icon {
        width: 62px;
        height: 62px;
        font-size: 2rem;
    }

    .public-elderly-ui .portal-card-title {
        font-size: 1.45rem;
    }

    .public-elderly-ui .portal-card-desc {
        font-size: 1.15rem;
        line-height: 1.7;
    }

    .public-elderly-ui .portal-card-action {
        min-height: 60px;
        font-size: 1.2rem;
        font-weight: 800;
        padding: 15px 22px;
    }

    .public-elderly-ui .module-card {
        padding: 20px 18px;
    }

    .public-elderly-ui .module-icon-wrap {
        width: 58px;
        height: 58px;
        font-size: 2.1rem;
    }

    .public-elderly-ui .module-title {
        font-size: 1.32rem;
    }

    .public-elderly-ui .module-summary {
        font-size: 1.12rem;
        line-height: 1.65;
    }

    .public-elderly-ui .grand-cert-banner h2 {
        font-size: 1.45rem !important;
    }

    .public-elderly-ui .grand-cert-btn {
        padding: 15px 24px;
        font-size: 1.18rem;
    }

    .public-resources-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .public-emergency-bar {
        flex-direction: column;
        gap: 8px !important;
    }

    /* Lesson View Page on Mobile */
    .lesson-top-bar {
        gap: 10px;
        padding-bottom: 12px;
        margin-bottom: 16px;
    }

    .lesson-top-left {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .btn-back-portal {
        padding: 10px 18px !important;
        font-size: 1.02rem !important;
    }

    .lesson-top-right {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    #btn-bypass-video {
        font-size: 0.74rem !important;
        padding: 4px 8px !important;
    }

    .lesson-split-grid {
        gap: 16px;
        margin-bottom: 16px;
    }

    .video-player-card {
        border-radius: 12px;
    }

    .lesson-details-card {
        padding: 16px 14px;
        border-radius: 14px;
        gap: 14px;
    }

    .view-mod-title {
        font-size: 1.3rem !important;
        font-weight: 800 !important;
        line-height: 1.35 !important;
    }

    .view-mod-summary {
        font-size: 0.98rem !important;
        line-height: 1.6 !important;
    }

    .quiz-trigger-card {
        padding: 18px 16px;
        border-radius: 16px;
    }

    .btn-quiz-launch {
        width: 100%;
        justify-content: center;
        box-sizing: border-box;
        font-size: 1.05rem;
        font-weight: 700;
        min-height: 52px;
        padding: 12px 18px;
        border-radius: 16px;
    }

    #btn-next-module {
        width: 100%;
        justify-content: center;
        box-sizing: border-box;
        font-size: 1.05rem;
        font-weight: 700;
        min-height: 52px;
        padding: 12px 18px;
        border-radius: 16px;
    }

    .playlist-section {
        padding: 14px;
        border-radius: 14px;
        margin-top: 14px;
    }

    .playlist-item {
        padding: 10px 12px;
        font-size: 0.92rem;
    }

    .article-full-card {
        padding: 20px 18px;
        border-radius: 16px;
        font-size: 1.02rem;
        line-height: 1.8;
    }

    .article-full-card h3 {
        font-size: 1.25rem;
        font-weight: 800;
    }

    /* Quiz Modal on Mobile */
    #modal-quiz {
        align-items: flex-start !important;
        padding: 16px 0 calc(32px + env(safe-area-inset-bottom, 0px)) !important;
        -webkit-overflow-scrolling: touch;
    }

    .quiz-modal-container {
        width: 95% !important;
        max-width: 95% !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        padding: 20px 16px 36px !important;
        border-radius: 18px !important;
        margin: 10px auto !important;
    }

    .quiz-option-label {
        padding: 12px 14px;
        font-size: 1rem;
        line-height: 1.5;
        gap: 12px;
        border-radius: 12px;
        margin-bottom: 10px;
        min-height: 50px;
        font-weight: 600;
        touch-action: manipulation;
    }

    .quiz-option-label input[type="radio"] {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
    }

    .quiz-modal-footer {
        flex-direction: column;
        width: 100%;
        margin-top: 24px !important;
        padding-top: 16px !important;
        padding-bottom: 24px !important;
    }

    .quiz-modal-footer button,
    #btn-submit-quiz {
        width: 100% !important;
        min-height: 52px !important;
        font-size: 1.05rem !important;
        font-weight: 700 !important;
        border-radius: 14px !important;
        justify-content: center !important;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        display: inline-flex !important;
        align-items: center !important;
    }

    #quiz-result-box {
        padding: 16px 12px;
    }

    #quiz-result-box .btn,
    #quiz-result-box .cert-chip-btn {
        width: 100%;
        justify-content: center;
        box-sizing: border-box;
    }

    .public-modal-card {
        width: 95% !important;
        max-width: 95% !important;
        padding: 20px 16px !important;
        border-radius: 16px !important;
    }

    .public-modal-actions {
        flex-direction: column-reverse;
        width: 100%;
        gap: 8px;
    }

    .public-modal-actions button {
        width: 100%;
        justify-content: center;
    }
}

/* Extra small mobile (<= 420px: iPhone SE, small Androids) */
@media (max-width: 420px) {
    .lesson-view-container {
        padding: 10px 8px calc(96px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .public-hero {
        padding: 14px 10px;
    }

    .public-avatar,
    .public-avatar-placeholder {
        width: 42px;
        height: 42px;
        font-size: 1.25rem;
    }

    .public-user-name {
        font-size: 0.95rem;
    }

    .public-badge-line {
        font-size: 0.68rem;
        padding: 1px 6px;
    }

    .font-scale-group {
        padding: 1px 4px;
    }

    .font-scale-btn {
        padding: 3px 6px;
        font-size: 0.78rem;
    }

    .font-scale-value {
        min-width: 24px;
        font-size: 0.72rem;
    }

    .module-card {
        padding: 14px 12px;
    }

    .module-top {
        margin-bottom: 8px;
    }

    .module-icon-wrap {
        width: 44px;
        height: 44px;
        font-size: 1.65rem;
    }

    .module-title {
        font-size: 1.08rem;
        font-weight: 800;
        line-height: 1.35;
    }

    .lesson-top-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .lesson-top-left {
        justify-content: space-between;
        width: 100%;
    }

    .lesson-top-right {
        justify-content: space-between;
        width: 100%;
    }

    .public-bottom-nav {
        height: 78px;
        height: calc(78px + env(safe-area-inset-bottom, 0px));
    }

    .public-nav-container {
        height: 78px;
        padding: 0 4px;
    }

    .public-nav-icon {
        width: 52px;
        height: 52px;
        border-radius: 16px;
    }

    .public-nav-icon svg {
        width: 32px;
        height: 32px;
    }

    .public-nav-label {
        display: none !important;
    }

    /* Senior Elderly Accessibility Overrides on Small Mobile */
    .public-elderly-ui .public-avatar,
    .public-elderly-ui .public-avatar-placeholder {
        width: 58px;
        height: 58px;
        font-size: 1.75rem;
    }

    .public-elderly-ui .public-user-name {
        font-size: 1.22rem;
    }

    .public-elderly-ui .public-badge-line {
        font-size: 0.85rem;
        padding: 2px 8px;
    }

    .public-elderly-ui .font-scale-group {
        padding: 4px 8px;
    }

    .public-elderly-ui .font-scale-btn {
        padding: 6px 12px;
        font-size: 1rem;
    }

    .public-elderly-ui .font-scale-value {
        min-width: 28px;
        font-size: 0.88rem;
    }

    .public-elderly-ui .module-card {
        padding: 18px 16px;
    }

    .public-elderly-ui .module-icon-wrap {
        width: 54px;
        height: 54px;
        font-size: 1.95rem;
    }

    .public-elderly-ui .module-title {
        font-size: 1.25rem;
        line-height: 1.35;
    }

    .public-elderly-ui .module-summary {
        font-size: 1.08rem;
    }

    .public-elderly-ui .portal-card-title {
        font-size: 1.38rem;
    }

    .public-elderly-ui .portal-card-desc {
        font-size: 1.1rem;
    }

    .public-elderly-ui .portal-card-action {
        min-height: 58px;
        font-size: 1.18rem;
    }

    .public-elderly-ui .public-bottom-nav {
        height: 78px;
        height: calc(78px + env(safe-area-inset-bottom, 0px));
    }

    .public-elderly-ui .public-nav-container {
        height: 78px;
        padding: 0 4px;
    }

    .public-elderly-ui .public-nav-icon {
        width: 52px;
        height: 52px;
        border-radius: 16px;
    }

    .public-elderly-ui .public-nav-icon svg {
        width: 32px;
        height: 32px;
    }

    .public-elderly-ui .public-nav-label {
        display: none !important;
    }
}

/* ============================================================
   Public Mobile App Bottom Navigation Bar (Hidden per user request in favor of Home Dashboard Big Buttons)
   ============================================================ */

.public-bottom-nav {
    display: none !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10001;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ============================================================
   Senior-Friendly Home Launcher Dashboard (Big Buttons UX/UI)
   ============================================================ */

.home-launcher-section {
    margin-top: 18px;
    margin-bottom: 24px;
}

.home-launcher-heading {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 14px;
    padding: 0 4px;
}

.home-launcher-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.35;
    display: flex;
    align-items: center;
    gap: 10px;
}

.home-launcher-subtitle {
    font-size: 1.05rem;
    color: var(--text-muted);
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
}

/* ============================================================
   Senior-Friendly Home Launcher Dashboard (Refined Unified Theme)
   ============================================================ */

.home-launcher-section {
    margin-top: 14px;
    margin-bottom: 24px;
}

.service-category-block {
    margin-bottom: 18px;
}

.service-category-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 0 4px;
}

.category-icon-pin {
    font-size: 1.25rem;
}

.category-title {
    font-size: 1.28rem; /* 20-21px */
    font-weight: 800;
    color: #0d47a1;
    letter-spacing: -0.2px;
}
[data-theme="dark"] .category-title {
    color: #60a5fa;
}

.home-launcher-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 380px) {
    .home-launcher-grid {
        gap: 8px;
    }
}

.home-action-btn {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 145px;
    min-width: 0;
    max-width: 100%;
    padding: 16px 14px 14px 14px;
    border-radius: 22px;
    text-decoration: none;
    color: #ffffff !important;
    cursor: pointer;
    transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    text-align: left;
    box-sizing: border-box;
    width: 100%;
    border: none;
    outline: none;
}

.home-action-btn:hover {
    transform: translateY(-2px);
}

.home-action-btn:active {
    transform: scale(0.96);
}

/* 6 Calm, Deep, High-Contrast Solid-Tone Surfaces (Zero Gradient Noise, WCAG AAA 7:1+) */
.home-action-btn.tile-blue,
.home-action-btn.btn-accent-blue {
    background: #0d47a1 !important;
    background: linear-gradient(180deg, #1565c0 0%, #0d47a1 100%) !important;
    box-shadow: 0 6px 18px rgba(13, 71, 161, 0.28);
}
.home-action-btn.tile-blue .tile-arrow-circle,
.home-action-btn.btn-accent-blue .tile-arrow-circle {
    color: #0d47a1;
}

/* สีเขียวเข้ม ทึบ ชัดเจน ไม่ใช้เฉดจ้า (Contrast 7.5:1 กับตัวหนังสือสีขาว) */
.home-action-btn.tile-green,
.home-action-btn.btn-accent-emerald {
    background: #14532d !important;
    background: linear-gradient(180deg, #166534 0%, #14532d 100%) !important;
    box-shadow: 0 6px 18px rgba(20, 83, 45, 0.3);
}
.home-action-btn.tile-green .tile-arrow-circle,
.home-action-btn.btn-accent-emerald .tile-arrow-circle {
    color: #14532d;
}

.home-action-btn.tile-purple,
.home-action-btn.btn-accent-purple {
    background: #581c87 !important;
    background: linear-gradient(180deg, #6b21a8 0%, #581c87 100%) !important;
    box-shadow: 0 6px 18px rgba(88, 28, 135, 0.3);
}
.home-action-btn.tile-purple .tile-arrow-circle,
.home-action-btn.btn-accent-purple .tile-arrow-circle {
    color: #581c87;
}

/* สีส้มเข้มทึบ Warm Burnt Amber ชัดเจน ไม่จ้าตา ไม่ใช้สีส้มสว่าง (Contrast 7.2:1 กับตัวหนังสือสีขาว) */
.home-action-btn.tile-amber,
.home-action-btn.btn-accent-amber {
    background: #7c2d12 !important;
    background: linear-gradient(180deg, #9a3412 0%, #7c2d12 100%) !important;
    box-shadow: 0 6px 18px rgba(124, 45, 18, 0.3);
}
.home-action-btn.tile-amber .tile-arrow-circle,
.home-action-btn.btn-accent-amber .tile-arrow-circle {
    color: #7c2d12;
}

.home-action-btn.tile-teal,
.home-action-btn.btn-accent-teal {
    background: #115e59 !important;
    background: linear-gradient(180deg, #0f766e 0%, #115e59 100%) !important;
    box-shadow: 0 6px 18px rgba(17, 94, 89, 0.3);
}
.home-action-btn.tile-teal .tile-arrow-circle,
.home-action-btn.btn-accent-teal .tile-arrow-circle {
    color: #115e59;
}

.home-action-btn.tile-red,
.home-action-btn.btn-accent-red {
    background: #991b1b !important;
    background: linear-gradient(180deg, #b91c1c 0%, #991b1b 100%) !important;
    box-shadow: 0 6px 18px rgba(153, 27, 27, 0.3);
}
.home-action-btn.tile-red .tile-arrow-circle,
.home-action-btn.btn-accent-red .tile-arrow-circle {
    color: #991b1b;
}

.tile-top-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 12px;
}

.tile-icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
}

.tile-icon-badge svg {
    width: 26px;
    height: 26px;
    display: block;
}

.tile-bottom-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    position: relative;
}

.home-btn-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
    padding-right: 30px;
}

.home-btn-title {
    font-size: 1.18rem;
    font-weight: 800;
    line-height: 1.22;
    color: #ffffff !important;
    margin: 0;
    letter-spacing: -0.2px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
    word-break: break-word;
    overflow-wrap: anywhere;
}

.home-btn-desc {
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.32;
    color: #ffffff !important;
    margin: 0;
    word-break: break-word;
    overflow-wrap: anywhere;
    opacity: 0.96;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.tile-arrow-circle {
    position: absolute;
    right: 8px;
    bottom: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
    transition: transform 0.18s ease;
}

.tile-arrow-circle svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.8;
    display: block;
}

.home-action-btn:hover .tile-arrow-circle {
    transform: translateX(2px) scale(1.05);
}

@media (max-width: 640px) {
    .home-btn-title {
        font-size: 1.12rem;
    }
    .home-btn-desc {
        font-size: 0.88rem;
    }
    .tile-arrow-circle {
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
        right: 8px;
        bottom: 8px;
    }
    .tile-arrow-circle svg {
        width: 15px;
        height: 15px;
    }
}

@media (max-width: 380px) {
    .home-action-btn {
        min-height: 138px;
        padding: 12px 10px 10px 10px;
        border-radius: 18px;
    }
    .tile-top-row {
        margin-bottom: 6px;
    }
    .tile-icon-badge {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
    }
    .tile-icon-badge svg {
        width: 20px;
        height: 20px;
    }
    .home-btn-content {
        gap: 3px;
        padding-right: 26px;
    }
    .home-btn-title {
        font-size: 1.05rem;
    }
    .home-btn-desc {
        font-size: 0.82rem;
    }
    .tile-arrow-circle {
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
        right: 6px;
        bottom: 6px;
    }
    .tile-arrow-circle svg {
        width: 14px;
        height: 14px;
    }
}
}

/* Senior Notice & Hotline Bar Styles */
.senior-notice-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    margin-top: 18px;
    background: #fdf2f2;
    border: 1px solid rgba(248, 113, 113, 0.35);
    border-radius: 20px;
    box-sizing: border-box;
}
[data-theme="dark"] .senior-notice-bar {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.35);
}
.senior-notice-icon-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ef4444;
    color: #ffffff;
    flex-shrink: 0;
}
.senior-notice-text {
    flex: 1;
    min-width: 0;
}
.senior-notice-title {
    font-size: 1.22rem; /* 19-20px */
    font-weight: 800;
    color: #b91c1c;
    line-height: 1.3;
}
[data-theme="dark"] .senior-notice-title {
    color: #fca5a5;
}
.senior-notice-desc {
    font-size: 1.1rem; /* 17-18px */
    color: var(--text-muted);
    line-height: 1.35;
    margin-top: 2px;
}
.senior-notice-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    border-radius: 16px;
    background: rgba(239, 68, 68, 0.14);
    color: #dc2626;
    border: none;
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
}
[data-theme="dark"] .senior-notice-action {
    background: rgba(239, 68, 68, 0.25);
    color: #fca5a5;
}

.senior-hotline-bar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 14px;
    width: 100%;
    box-sizing: border-box;
}

@media (min-width: 600px) {
    .senior-hotline-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
    }
}

.senior-hotline-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 68px;
    padding: 14px 18px;
    border-radius: 20px;
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
    text-decoration: none;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
[data-theme="dark"] .senior-hotline-btn {
    background: var(--card-bg);
}

.senior-hotline-btn:active {
    transform: scale(0.97);
}

.senior-hotline-btn.hotline-red {
    border-color: rgba(239, 68, 68, 0.35);
    background: linear-gradient(145deg, #fff5f5, #ffffff);
}
[data-theme="dark"] .senior-hotline-btn.hotline-red {
    background: rgba(239, 68, 68, 0.08);
}

.senior-hotline-btn.hotline-green {
    border-color: rgba(34, 197, 94, 0.35);
    background: linear-gradient(145deg, #f0fdf4, #ffffff);
}
[data-theme="dark"] .senior-hotline-btn.hotline-green {
    background: rgba(34, 197, 94, 0.08);
}

.hotline-btn-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    flex: 1;
}

.hotline-btn-icon {
    font-size: 2.1rem;
    flex-shrink: 0;
    line-height: 1;
}

.hotline-btn-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.hotline-btn-num {
    font-size: 1.75rem; /* 28px */
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.3px;
}

.hotline-red .hotline-btn-num {
    color: #e53935;
}

.hotline-green .hotline-btn-num {
    color: #2e7d32;
}
[data-theme="dark"] .hotline-green .hotline-btn-num {
    color: #4ade80;
}

.hotline-btn-desc {
    font-size: 1.12rem; /* 18px */
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.3;
    white-space: normal;
    word-break: break-word;
}

.hotline-btn-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: 8px;
}
.hotline-red .hotline-btn-arrow {
    color: #e53935;
}
.hotline-green .hotline-btn-arrow {
    color: #2e7d32;
}

/* Fallback badges & tags */
.home-btn-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.86rem;
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
}
.tag-emerald { background: rgba(16, 185, 129, 0.16); color: #047857; }
.tag-amber { background: rgba(245, 158, 11, 0.16); color: #b45309; }
.tag-purple { background: rgba(139, 92, 246, 0.16); color: #6d28d9; }
.tag-blue { background: rgba(2, 132, 199, 0.16); color: #0369a1; }
.tag-teal { background: rgba(13, 148, 136, 0.16); color: #0f766e; }
.tag-red { background: rgba(239, 68, 68, 0.16); color: #b91c1c; }

.home-btn-chevron {
    color: inherit;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   Back to Home Prominent Button & View Header Bar
   ============================================================ */

.btn-back-home {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 24px;
    border-radius: 22px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.14) 0%, rgba(13, 148, 136, 0.18) 100%);
    color: #047857;
    border: 2px solid rgba(16, 185, 129, 0.5);
    font-size: 1.15rem;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    min-height: 48px;
    box-sizing: border-box;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.12);
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

[data-theme="dark"] .btn-back-home {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.22) 0%, rgba(13, 148, 136, 0.26) 100%);
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.55);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.btn-back-home:hover {
    background: linear-gradient(135deg, #10b981 0%, #0d9488 100%) !important;
    color: #ffffff !important;
    border-color: #10b981 !important;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.38) !important;
    transform: translateY(-1px);
}

.btn-back-home:active {
    transform: scale(0.96);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.btn-back-home-top {
    padding: 10px 20px !important;
    font-size: 1.05rem !important;
    min-height: 44px !important;
    border-radius: 20px !important;
    flex-shrink: 0;
}

.btn-back-home-large {
    padding: 15px 32px !important;
    font-size: 1.25rem !important;
    min-height: 56px !important;
    border-radius: 24px !important;
    box-shadow: 0 6px 22px rgba(16, 185, 129, 0.2) !important;
}

.btn-back-home-full {
    width: 100% !important;
    justify-content: center !important;
}

/* Secondary Back / Learning List Button for Dual Navigation */
.btn-back-learning {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: 20px;
    background: rgba(37, 99, 235, 0.12);
    color: #1d4ed8;
    border: 2px solid rgba(37, 99, 235, 0.45);
    font-size: 1.08rem;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    min-height: 46px;
    box-sizing: border-box;
    transition: all 0.18s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

[data-theme="dark"] .btn-back-learning {
    background: rgba(37, 99, 235, 0.22);
    color: #60a5fa;
    border-color: rgba(96, 165, 250, 0.5);
}

.btn-back-learning:hover {
    background: #2563eb !important;
    color: #ffffff !important;
    border-color: #2563eb !important;
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
    transform: translateY(-1px);
}

.btn-back-learning:active {
    transform: scale(0.96);
}

/* Dual Navigation Cluster */
.lesson-nav-cluster {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Dedicated Senior Bottom Return Bar */
.public-bottom-return-bar {
    margin-top: 36px;
    margin-bottom: 28px;
    padding: 22px 20px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(13, 148, 136, 0.04) 100%);
    border: 1.5px solid rgba(16, 185, 129, 0.28);
    border-radius: 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .public-bottom-return-bar {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12) 0%, rgba(15, 23, 42, 0.6) 100%);
    border-color: rgba(16, 185, 129, 0.35);
}

.public-bottom-return-bar .return-bar-hint {
    font-size: 1.05rem;
    color: var(--text-muted);
    font-weight: 600;
    margin: 0;
    line-height: 1.5;
}

.public-bottom-return-bar .return-bar-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    width: 100%;
}

.view-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1.5px solid var(--border-color);
    flex-wrap: wrap;
    gap: 12px;
}

/* Pinned Sticky Header Bar for Modals on Scroll */
.public-modal-card .view-header-bar {
    position: sticky;
    top: -24px;
    margin: -24px -24px 18px -24px;
    padding: 16px 20px 14px 20px;
    background: #ffffff;
    z-index: 25;
    border-bottom: 2px solid var(--border-color);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .public-modal-card .view-header-bar {
    background: #1e293b;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.modal-btn-close-bottom {
    width: 100% !important;
    justify-content: center !important;
    padding: 14px 20px !important;
    font-size: 1.22rem !important;
    min-height: 52px !important;
    box-sizing: border-box !important;
}

.view-section-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.view-section-title {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
}

/* Senior-Friendly Benefit Selector Pills */
.benefit-pills-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.benefit-pills-row::-webkit-scrollbar {
    display: none;
}

.benefit-pill-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 16px;
    border: 1.5px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1.08rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
    user-select: none;
}

.benefit-pill-item.active {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #fff;
    font-weight: 800;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
}

.benefit-card-single {
    display: none;
    animation: fadeInBenefit 0.2s ease forwards;
}
.benefit-card-single.active {
    display: block;
}

@keyframes fadeInBenefit {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Senior-Friendly Healthcare Network Selector Pills */
.network-pills-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.network-pills-row::-webkit-scrollbar {
    display: none;
}

.network-pill-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 16px;
    border: 1.5px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1.08rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
    user-select: none;
}

.network-pill-item.active {
    background: #0d9488;
    border-color: #0d9488;
    color: #fff;
    font-weight: 800;
    box-shadow: 0 4px 14px rgba(13, 148, 136, 0.35);
}

.network-card-single {
    display: none;
    animation: fadeInBenefit 0.2s ease forwards;
}
.network-card-single.active {
    display: block;
}

/* Screening Segmented Nav */
.screening-tabs-row {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    background: var(--bg-primary);
    padding: 6px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

.screening-tab-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.screening-tab-btn.active {
    background: #8b5cf6;
    color: #fff;
    font-weight: 800;
    box-shadow: 0 3px 12px rgba(139, 92, 246, 0.3);
}

/* ============================================================
   Senior Hub & Spoke Modal Navigation System (TOR Senior UX)
   โหมดแสดงปุ่มตัวเลือกขนาดใหญ่ แล้วกดเข้าไปดูทีละด้าน เพื่อความสะดวกของผู้สูงอายุ
   ============================================================ */

.senior-menu-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 14px 0 20px;
}

.senior-menu-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: var(--bg-primary);
    border: 1.5px solid var(--border-color);
    border-radius: 18px;
    text-align: left;
    width: 100%;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    user-select: none;
    text-decoration: none;
    color: var(--text-primary);
    box-sizing: border-box;
}

.senior-menu-card:hover {
    transform: translateY(-2px);
    border-color: #f59e0b;
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.16);
}

.senior-menu-card:active {
    transform: scale(0.985);
}

.senior-menu-card.theme-teal:hover {
    border-color: #0d9488;
    box-shadow: 0 8px 24px rgba(13, 148, 136, 0.16);
}

.senior-menu-icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    font-size: 1.75rem;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.senior-menu-card:hover .senior-menu-icon-badge {
    transform: scale(1.08);
}

.senior-menu-content {
    flex: 1;
    min-width: 0;
}

.senior-menu-title {
    font-size: 1.22rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.35;
    margin-bottom: 4px;
}

.senior-menu-desc {
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.45;
}

.senior-menu-action {
    flex-shrink: 0;
}

.senior-menu-action-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    border-radius: 12px;
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
    font-size: 0.98rem;
    font-weight: 800;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.senior-menu-card.theme-teal .senior-menu-action-pill {
    background: rgba(13, 148, 136, 0.12);
    color: #0d9488;
}

.senior-menu-card:hover .senior-menu-action-pill {
    background: #f59e0b;
    color: #ffffff;
}

.senior-menu-card.theme-teal:hover .senior-menu-action-pill {
    background: #0d9488;
    color: #ffffff;
}

/* Back to Menu Bar inside Detail View */
.btn-senior-back-menu {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 14px;
    background: rgba(245, 158, 11, 0.12);
    border: 1.5px solid rgba(245, 158, 11, 0.35);
    color: #d97706;
    font-size: 1.08rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.btn-senior-back-menu.theme-teal {
    background: rgba(13, 148, 136, 0.12);
    border-color: rgba(13, 148, 136, 0.35);
    color: #0d9488;
}

.btn-senior-back-menu:hover {
    background: #f59e0b;
    color: #ffffff;
}

.btn-senior-back-menu.theme-teal:hover {
    background: #0d9488;
    color: #ffffff;
}

.senior-counter-badge {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 6px 14px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    white-space: nowrap;
}

.btn-senior-stepper {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 16px;
    border-radius: 16px;
    font-weight: 800;
    font-size: 1.12rem;
    border: 1.5px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-senior-stepper:hover {
    background: var(--card-bg);
    border-color: #10b981;
}

.btn-senior-back-menu-bottom {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 16px;
    font-weight: 800;
    font-size: 1.15rem;
    width: 100%;
    background: var(--bg-primary);
    border: 1.5px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
    margin-top: 10px;
}

.btn-senior-back-menu-bottom:hover {
    border-color: #f59e0b;
    color: #d97706;
}

/* Senior Screening Touch Choice Card */
.screening-touch-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1.5px solid var(--border-color);
    background: var(--bg-primary);
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.screening-touch-card:hover {
    border-color: #10b981;
}

.screening-touch-card.is-checked {
    background: rgba(16, 185, 129, 0.1);
    border-color: #10b981;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.18);
}

.screening-touch-checkbox {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    background: var(--card-bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    font-weight: 900;
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 2px;
    transition: all 0.15s ease;
}

.screening-touch-card.is-checked .screening-touch-checkbox {
    background: #10b981;
    border-color: #10b981;
    color: #ffffff;
}

.screening-touch-body {
    flex: 1;
    min-width: 0;
    font-size: 1.12rem;
    line-height: 1.55;
    color: var(--text-primary);
}

.screening-touch-body strong {
    font-size: 1.15rem;
    color: var(--text-primary);
}

/* 2Q Touch Toggle Pill Buttons */
.q2-touch-toggle-row {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.q2-touch-pill {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 14px;
    border: 1.5px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 1.15rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.q2-touch-pill.active-no {
    background: rgba(16, 185, 129, 0.12);
    border-color: #10b981;
    color: #059669;
}

.q2-touch-pill.active-yes {
    background: rgba(239, 68, 68, 0.12);
    border-color: #ef4444;
    color: #dc2626;
}

.screening-tab-section {
    display: none;
}
.screening-tab-section.active {
    display: block;
    animation: fadeInBenefit 0.2s ease forwards;
}

/* Emergency Hotline Action Buttons */
.emergency-hotline-card {
    background: var(--bg-primary);
    border: 1.5px solid var(--border-color);
    border-radius: 18px;
    padding: 18px;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-emergency-dial {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 20px;
    border-radius: 16px;
    font-size: 1.25rem;
    font-weight: 800;
    text-decoration: none;
    color: #fff;
    box-sizing: border-box;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    transition: transform 0.15s ease, filter 0.15s ease;
}
.btn-emergency-dial:active {
    transform: scale(0.97);
}

.btn-dial-red {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}
.btn-dial-green {
    background: linear-gradient(135deg, #10b981, #059669);
}
.btn-dial-amber {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}
.btn-dial-purple {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

/* ============================================================
   Senior Medical Resources Cards (.resource-touch-card)
   การ์ดคลังคู่มือและเอกสารทางการแพทย์ขนาดสัมผัสใหญ่ อ่านง่าย ไม่บีบตัวหนังสือ
   ============================================================ */
.senior-resources-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 10px;
}

.resource-touch-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 18px;
    background: var(--bg-primary);
    border: 1.5px solid var(--border-color);
    border-radius: 18px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    box-sizing: border-box;
    user-select: none;
}

.resource-touch-card:hover {
    transform: translateY(-2px);
    border-color: #f59e0b;
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.16);
}

.resource-touch-card:active {
    transform: scale(0.985);
}

.resource-touch-top {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.resource-touch-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(245, 158, 11, 0.14);
    font-size: 1.65rem;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.resource-touch-card:hover .resource-touch-icon {
    transform: scale(1.08);
}

.resource-touch-content {
    flex: 1;
    min-width: 0;
}

.resource-touch-title {
    font-size: 1.22rem;
    font-weight: 800;
    line-height: 1.45;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.resource-touch-org {
    font-size: 0.98rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.resource-touch-action {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 4px;
}

.resource-touch-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 12px;
    background: rgba(16, 185, 129, 0.12);
    border: 1.5px solid rgba(16, 185, 129, 0.35);
    color: #059669;
    font-size: 1.05rem;
    font-weight: 800;
    transition: all 0.2s ease;
}

.resource-touch-card:hover .resource-touch-pill {
    background: #10b981;
    color: #ffffff;
    border-color: #10b981;
}

/* Base Desktop Senior Modal System */
.public-senior-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(5px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 20px 0;
    box-sizing: border-box;
}

.public-senior-modal .public-modal-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    width: 92%;
    max-width: 680px;
    max-height: 88vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    position: relative;
}

/* ============================================================
   Senior Full Mobile Screen Modal Layout (TOR Senior Accessibility)
   ปรับปรุงให้พอดีกับหน้าจอมือถือทุกขนาด (360px - 640px) 
   ไม่ล้น ไม่เหลื่อม แถบหัวไม่ซ้อนทับ และกดง่ายด้วยนิ้วสัมผัส
   ============================================================ */
@media (max-width: 640px) {
    .public-senior-modal,
    body.public-elderly-body {
        padding: 0 !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
    }

    .public-senior-modal .public-modal-card,
    body.public-elderly-body > .public-modal-card {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 100% !important;
        min-height: 100vh !important;
        min-height: 100dvh !important;
        height: auto !important;
        max-height: none !important;
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        padding: 16px 14px max(64px, calc(env(safe-area-inset-bottom, 24px) + 36px)) !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Sticky Header Bar: Flush alignment with mobile card padding */
    .public-modal-card .view-header-bar {
        position: sticky !important;
        top: -16px !important;
        margin: -16px -14px 16px -14px !important;
        padding: 12px 14px !important;
        border-radius: 0 !important;
        z-index: 100 !important;
    }

    /* Resource touch cards full-width button on mobile */
    .resource-touch-card {
        padding: 14px 14px !important;
        gap: 12px !important;
        border-radius: 16px !important;
    }

    .resource-touch-top {
        gap: 12px !important;
    }

    .resource-touch-icon {
        width: 44px !important;
        height: 44px !important;
        font-size: 1.5rem !important;
        border-radius: 12px !important;
    }

    .resource-touch-title {
        font-size: 1.15rem !important;
        line-height: 1.4 !important;
        margin-bottom: 4px !important;
    }

    .resource-touch-org {
        font-size: 0.94rem !important;
        line-height: 1.45 !important;
    }

    .resource-touch-action {
        width: 100% !important;
        margin-top: 6px !important;
    }

    .resource-touch-pill {
        width: 100% !important;
        padding: 11px 16px !important;
        font-size: 1.05rem !important;
        box-sizing: border-box !important;
    }
}

@media (max-width: 480px) {
    /* Header Bar Sizing on Mobile */
    .public-modal-card .view-header-bar {
        padding: 10px 12px !important;
        gap: 6px !important;
        margin: -16px -14px 14px -14px !important;
    }

    .btn-back-home.btn-back-home-top {
        padding: 8px 10px !important;
        font-size: 0.95rem !important;
        gap: 5px !important;
        border-radius: 12px !important;
        flex-shrink: 0 !important;
    }

    .btn-back-home.btn-back-home-top svg {
        width: 18px !important;
        height: 18px !important;
    }

    .view-section-title-wrap {
        gap: 6px !important;
        min-width: 0 !important;
        flex: 1 !important;
        justify-content: center !important;
    }

    .view-section-title-wrap span {
        font-size: 1.3rem !important;
        flex-shrink: 0 !important;
    }

    .view-section-title {
        font-size: clamp(0.95rem, 3.8vw, 1.15rem) !important;
        font-weight: 800 !important;
        white-space: normal !important;
        line-height: 1.25 !important;
        text-align: center !important;
        overflow: visible !important;
        text-overflow: unset !important;
    }

    .modal-close-btn {
        width: 38px !important;
        height: 38px !important;
        flex-shrink: 0 !important;
    }

    .modal-close-btn svg {
        width: 20px !important;
        height: 20px !important;
    }

    /* Welfare detail title & meta box full width on mobile */
    .welfare-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }

    .welfare-meta-box a {
        display: flex !important;
        width: 100% !important;
        justify-content: center !important;
        box-sizing: border-box !important;
        margin-top: 6px !important;
        min-height: 46px !important;
    }

    /* Video action bar on mobile */
    .video-action-bar {
        flex-direction: column-reverse !important;
        align-items: stretch !important;
        gap: 10px !important;
    }

    .btn-manual-video-done {
        width: 100% !important;
        min-height: 48px !important;
        font-size: 1.02rem !important;
        justify-content: center !important;
    }

    /* Senior Hub Menu Cards */
    .senior-menu-container {
        gap: 10px !important;
        margin: 10px 0 16px !important;
    }

    .senior-menu-card {
        padding: 13px 12px !important;
        gap: 10px !important;
        border-radius: 16px !important;
    }

    .senior-menu-icon-badge {
        width: 42px !important;
        height: 42px !important;
        font-size: 1.45rem !important;
        border-radius: 12px !important;
        flex-shrink: 0 !important;
    }

    .senior-menu-content {
        flex: 1 !important;
        min-width: 0 !important;
    }

    .senior-menu-title {
        font-size: 1.15rem !important;
        font-weight: 800 !important;
        line-height: 1.35 !important;
        margin-bottom: 2px !important;
        word-break: normal !important;
        white-space: normal !important;
    }

    .senior-menu-desc {
        font-size: 0.94rem !important;
        line-height: 1.4 !important;
        color: var(--text-muted) !important;
        word-break: normal !important;
    }

    .senior-menu-action {
        flex-shrink: 0 !important;
        display: flex !important;
        align-items: center !important;
    }

    .senior-menu-action-pill {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 50% !important;
        font-size: 1.15rem !important;
        flex-shrink: 0 !important;
    }

    .senior-menu-action-pill .pill-text {
        display: none !important;
    }

    /* Senior Detail Navigation Bar */
    .btn-senior-back-menu {
        padding: 8px 12px !important;
        font-size: 0.95rem !important;
        gap: 6px !important;
        border-radius: 12px !important;
    }

    .btn-senior-back-menu svg {
        width: 18px !important;
        height: 18px !important;
    }

    .senior-counter-badge {
        padding: 6px 10px !important;
        font-size: 0.92rem !important;
        border-radius: 10px !important;
    }

    .btn-senior-stepper {
        padding: 11px 8px !important;
        font-size: 1.02rem !important;
        border-radius: 14px !important;
        gap: 4px !important;
    }

    .btn-senior-back-menu-bottom {
        padding: 12px 14px !important;
        font-size: 1.05rem !important;
        border-radius: 14px !important;
        margin-top: 8px !important;
    }

    /* Benefit Stepper Pills Row */
    .benefit-pills-row {
        gap: 6px !important;
        margin-bottom: 12px !important;
        padding-bottom: 4px !important;
    }

    .benefit-pill-item {
        padding: 7px 12px !important;
        font-size: 0.92rem !important;
        border-radius: 12px !important;
    }

    /* Welfare Content Cards on Mobile */
    .welfare-item-title {
        font-size: 1.22rem !important;
        line-height: 1.35 !important;
    }

    .welfare-item-amount {
        font-size: 1.22rem !important;
        padding: 8px 12px !important;
        border-radius: 12px !important;
    }

    .welfare-body p {
        font-size: 1.05rem !important;
        line-height: 1.65 !important;
    }

    .welfare-item-list li {
        font-size: 1.02rem !important;
        line-height: 1.55 !important;
        padding: 8px 10px !important;
    }

    .welfare-meta-box {
        padding: 12px 12px !important;
        font-size: 1rem !important;
        border-radius: 14px !important;
    }

    /* Screening Modal Touch Cards & Buttons */
    .screening-touch-card {
        padding: 12px 12px !important;
        gap: 10px !important;
        border-radius: 14px !important;
        margin-bottom: 8px !important;
    }

    .screening-touch-checkbox {
        width: 24px !important;
        height: 24px !important;
        font-size: 0.95rem !important;
        border-radius: 7px !important;
    }

    .screening-touch-body {
        font-size: 1.02rem !important;
        line-height: 1.45 !important;
    }

    .screening-touch-body strong {
        font-size: 1.05rem !important;
    }

    .q2-touch-toggle-row {
        gap: 8px !important;
    }

    .q2-touch-pill {
        padding: 11px 10px !important;
        font-size: 1.05rem !important;
        border-radius: 12px !important;
    }

    /* Emergency Hotline Dial Buttons */
    .emergency-hotline-card {
        padding: 14px 12px !important;
        border-radius: 16px !important;
        gap: 10px !important;
    }

    .btn-emergency-dial {
        padding: 12px 16px !important;
        font-size: 1.12rem !important;
        border-radius: 14px !important;
    }

    /* Network Dial & Map Action Buttons */
    .btn-dial-green,
    .btn-dial-amber,
    .btn-dial-purple {
        padding: 11px 14px !important;
        font-size: 1.02rem !important;
        border-radius: 14px !important;
    }

    /* Modal Bottom Actions */
    .modal-footer-actions {
        margin-top: 14px !important;
        padding-top: 12px !important;
    }

    .modal-btn-close-bottom {
        width: 100% !important;
        padding: 12px 16px !important;
        font-size: 1.05rem !important;
        border-radius: 14px !important;
        justify-content: center !important;
    }
}

/* Extra Compact Screens (<= 375px: iPhone SE, Galaxy Fold, Small Androids) */
@media (max-width: 375px) {
    .btn-back-home.btn-back-home-top {
        width: 38px !important;
        height: 38px !important;
        padding: 8px !important;
        justify-content: center !important;
        border-radius: 12px !important;
    }

    .btn-back-home.btn-back-home-top span {
        display: none !important;
    }

    .view-section-title {
        font-size: 1.05rem !important;
    }

    .senior-menu-title {
        font-size: 1.05rem !important;
    }

    .senior-menu-action-pill {
        padding: 5px 8px !important;
        font-size: 0.82rem !important;
    }

    .btn-senior-back-menu span {
        font-size: 0.88rem !important;
    }
}

/* Single-Screen Full Overlay for Senior Experience */
.senior-view-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    z-index: 99999;
    overflow-y: auto;
    padding: 16px;
    box-sizing: border-box;
    display: none;
}

.senior-view-overlay.active {
    display: block;
}

.senior-view-container {
    max-width: 680px;
    margin: 0 auto;
    background: var(--card-bg);
    border: 1.5px solid var(--border-color);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

@media (max-width: 600px) {
    .senior-view-overlay {
        padding: 8px 6px;
    }
    .senior-view-container {
        padding: 18px 14px;
        border-radius: 18px;
    }
}

.public-nav-container {
    display: flex;
    max-width: 580px;
    height: 80px;
    margin: 0 auto;
    align-items: center;
    justify-content: space-around;
    padding: 0 8px;
    box-sizing: border-box;
}

.public-nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-muted);
    flex: 1;
    height: 100%;
    min-width: 58px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.public-nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 20px;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-muted);
}

.public-nav-icon svg {
    width: 34px;
    height: 34px;
    display: block;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.public-nav-label {
    display: none !important;
}

.public-nav-item:hover .public-nav-icon,
.public-nav-item:focus .public-nav-icon {
    color: var(--text-primary);
    background: rgba(16, 185, 129, 0.08);
}

.public-nav-item:active .public-nav-icon {
    transform: scale(0.92);
}

.public-nav-item.is-active {
    color: #10b981;
}

.public-nav-item.is-active .public-nav-icon {
    background: rgba(16, 185, 129, 0.16);
    color: #10b981;
    border: 2px solid rgba(16, 185, 129, 0.45);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.25);
    transform: scale(1.06);
}

[data-theme="light"] .public-nav-item.is-active .public-nav-icon {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.2);
}

.public-nav-item.is-active::after {
    content: '';
    position: absolute;
    top: 5px;
    width: 28px;
    height: 4px;
    border-radius: 4px;
    background: #10b981;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.6);
}

/* Ensure all public pages leave room for the fixed bottom nav bar and prevent horizontal blowout */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

.lesson-view-container.public-container,
.lesson-view-container {
    max-width: 100% !important;
    overflow-x: hidden;
    box-sizing: border-box;
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)) !important;
}

/* Public Medical Resources Grid (Mobile-safe wrapping) */
.public-resources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-width: 640px) {
    .public-resources-grid {
        grid-template-columns: 1fr;
    }
}

.resource-card-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.15s ease;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.resource-card-link:hover {
    border-color: #10b981;
    transform: translateY(-1px);
}

.resource-card-title {
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.35;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Mobile-First App Card & Touch Target Enhancements */
.app-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 22px 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.app-card:active {
    transform: scale(0.985);
}

.app-btn-touch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 52px;
    padding: 12px 20px;
    border-radius: 16px;
    font-size: 1.05rem;
    font-weight: 800;
    text-decoration: none;
    border: none;
    cursor: pointer;
    box-sizing: border-box;
    transition: all 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.app-btn-touch:active {
    transform: scale(0.98);
}



/* ============================================================
   Public Mobile App Header Bar (Top App Bar: Logo + Brand + Controls)
   Modern Healthcare Theme with Senior Accessibility Toolbar
   ============================================================ */
header.public-app-header,
.public-app-header {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 12px;
    padding: 14px 18px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #0d9488 0%, #0f766e 45%, #047857 100%) !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.22) !important;
    border-radius: 22px;
    box-shadow: 0 8px 24px -4px rgba(13, 148, 136, 0.28), 0 2px 8px rgba(0, 0, 0, 0.06);
    box-sizing: border-box;
    width: 100%;
    color: #ffffff;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

[data-theme="dark"] header.public-app-header,
[data-theme="dark"] .public-app-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 55%, #064e3b 100%) !important;
    border: 1px solid rgba(16, 185, 129, 0.3) !important;
    box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(16, 185, 129, 0.15);
}

.public-header-top-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
}

.public-app-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1 1 auto;
}

.public-header-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    text-decoration: none;
    flex-shrink: 0;
    transition: background 0.15s ease, transform 0.15s ease;
}

.public-header-back-btn:active {
    transform: scale(0.92);
}

.public-app-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    min-width: 0;
    user-select: none;
}

.public-app-logo-box {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.14);
    flex-shrink: 0;
    overflow: hidden;
    border: 1.5px solid rgba(255, 255, 255, 0.85);
}

.public-app-logo {
    width: 34px;
    height: 34px;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.08));
}

.public-app-brand-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.public-app-title {
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.2;
}

.public-app-title-main {
    font-size: 1.35rem;
    font-weight: 900;
    color: #ffffff;
    letter-spacing: -0.2px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.public-app-desc {
    font-size: 0.88rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.92);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Controls ด้านบนขวา: SOS 1669 + สลับธีม */
.public-top-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ปุ่มโทรฉุกเฉินด่วน 1669 กู้ชีพ */
.header-sos-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff !important;
    text-decoration: none !important;
    padding: 0 12px;
    height: 42px;
    min-height: 42px;
    border-radius: 13px;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 3px 10px rgba(220, 38, 38, 0.35);
    font-weight: 800;
    font-size: 0.96rem;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
    user-select: none;
}

.header-sos-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(220, 38, 38, 0.45);
    color: #ffffff !important;
}

.header-sos-btn:active {
    transform: scale(0.94);
}

.header-sos-btn .sos-badge-icon {
    font-size: 1.15rem;
    line-height: 1;
}

.header-sos-btn .sos-badge-text {
    line-height: 1;
}

/* ปุ่มสลับธีม สไตล์ Frosted Glass */
.public-app-header .public-theme-btn,
.public-theme-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1.5px solid rgba(255, 255, 255, 0.38);
    color: #ffffff !important;
    cursor: pointer;
    transition: all 0.18s ease;
    flex-shrink: 0;
    box-sizing: border-box;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.public-app-header .public-theme-btn:hover {
    background: rgba(255, 255, 255, 0.32);
    transform: translateY(-1px);
}

.public-app-header .public-theme-btn:active,
.public-theme-btn:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.4);
}

/* ============================================================
   Senior Accessibility Toolbar: ปรับขนาดตัวหนังสือสำหรับผู้สูงอายุ
   ============================================================ */
.public-header-accessibility-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 16px;
    padding: 6px 8px 6px 12px;
}

[data-theme="dark"] .public-header-accessibility-bar {
    background: rgba(0, 0, 0, 0.35);
    border-color: rgba(255, 255, 255, 0.15);
}

.font-scale-bar-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.94rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.95);
    white-space: nowrap;
    user-select: none;
}

.font-scale-bar-label svg {
    opacity: 0.95;
    flex-shrink: 0;
}

.public-app-header .font-scale-group,
.font-scale-group {
    display: inline-flex !important;
    align-items: center;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 13px;
    padding: 2px;
    height: 42px;
    box-sizing: border-box;
    gap: 3px;
}

.public-app-header .font-scale-btn,
.font-scale-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: transparent !important;
    border: none !important;
    color: #ffffff !important;
    padding: 0 14px !important;
    min-width: 68px !important;
    height: 36px !important;
    min-height: 36px !important;
    border-radius: 10px;
    cursor: pointer;
    line-height: 1;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

.font-scale-btn .font-scale-symbol {
    font-weight: 900;
    font-size: 1.05rem;
    line-height: 1;
}

.font-scale-btn.font-scale-large-btn .font-scale-symbol {
    font-size: 1.18rem;
}

.font-scale-btn .font-scale-text {
    font-weight: 700;
    font-size: 0.88rem;
    line-height: 1;
}

.public-app-header .font-scale-btn:hover,
.font-scale-btn:hover {
    background: rgba(255, 255, 255, 0.22) !important;
}

.public-app-header .font-scale-btn.is-active,
.font-scale-btn.is-active {
    background: #ffffff !important;
    color: #065f46 !important;
    font-weight: 900;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    transform: scale(1.02);
}

[data-theme="dark"] .public-app-header .font-scale-btn.is-active,
[data-theme="dark"] .font-scale-btn.is-active {
    background: #ffffff !important;
    color: #064e3b !important;
}

.public-app-header .font-scale-btn:active,
.font-scale-btn:active {
    transform: scale(0.95);
}

/* ============================================================
   Unified Frosted User Profile Header Row (Clean, Single Card)
   ============================================================ */
.public-header-user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.18) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    color: #ffffff;
}

[data-theme="dark"] .public-header-user-card {
    background: rgba(15, 23, 42, 0.55) !important;
    border-color: rgba(255, 255, 255, 0.15);
}

.header-avatar-box {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-avatar-box .public-avatar {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    display: block !important;
}

.header-avatar-box .public-avatar-placeholder {
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #ffffff !important;
    font-size: 1.6rem !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    background: transparent !important;
}

.header-user-details {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.header-user-greeting-line {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    flex-wrap: nowrap;
    overflow: hidden;
}

.header-user-welcome {
    font-size: 1.05rem; /* 16-17px */
    font-weight: 600;
    color: #64748b;
    line-height: 1.25;
    flex-shrink: 0;
}
[data-theme="dark"] .header-user-welcome {
    color: #94a3b8;
}

.header-user-name-line {
    display: flex;
    align-items: center;
    min-width: 0;
}

.header-user-name {
    font-size: 1.25rem; /* 20px bold */
    font-weight: 700;
    color: #0f172a;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
[data-theme="dark"] .header-user-name {
    color: #ffffff;
}

.header-user-status-line {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #16a34a;
    margin-top: 2px;
}

.status-dot-pulse {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #16a34a;
    box-shadow: 0 0 0 2.5px rgba(22, 163, 74, 0.25);
    flex-shrink: 0;
}

.header-user-meta-chips {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    min-width: 0;
    margin-top: 2px;
}

.header-user-meta-chips .public-badge-line {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #ffffff;
    background: #06c755;
    border-radius: 12px;
    padding: 3px 8px;
    min-height: 26px;
    box-sizing: border-box;
    box-shadow: 0 1px 3px rgba(6, 199, 85, 0.25);
    line-height: 1.2;
    flex-shrink: 0;
    white-space: nowrap;
}

.badge-line-text {
    white-space: nowrap;
}

.header-user-meta-chips .public-realname-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #0284c7;
    background: rgba(2, 132, 199, 0.12);
    border: 1px solid rgba(2, 132, 199, 0.35);
    border-radius: 12px;
    padding: 3px 8px;
    min-height: 26px;
    box-sizing: border-box;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    user-select: none;
    line-height: 1.2;
    white-space: nowrap;
    flex-shrink: 0;
    white-space: nowrap;
}
[data-theme="dark"] .header-user-meta-chips .public-realname-chip {
    color: #38bdf8;
    background: rgba(2, 132, 199, 0.2);
    border-color: rgba(56, 189, 248, 0.4);
}

.header-user-meta-chips .public-realname-chip:hover {
    transform: translateY(-1px);
}

.public-app-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.public-header-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.22);
    border: 1.5px solid rgba(255, 255, 255, 0.38);
    color: #ffffff !important;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 700;
    flex-shrink: 0;
    transition: all 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

.public-header-back-btn:active {
    transform: scale(0.92);
}

.public-app-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    min-width: 0;
}

.public-app-logo-box {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ffffff;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
    flex-shrink: 0;
    overflow: hidden;
}

.public-app-logo {
    width: 22px;
    height: 22px;
    object-fit: contain;
    display: block !important;
}

.public-app-brand-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.public-app-title {
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.2;
}

.public-app-title-main {
    font-size: 1.14rem; /* ~19-20px bold */
    font-weight: 800;
    color: #ffffff !important;
    letter-spacing: -0.2px;
    white-space: nowrap;
}

.public-app-desc {
    font-size: 0.88rem; /* 14px */
    color: rgba(255, 255, 255, 0.92) !important;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

@media (max-width: 768px) {
    .public-app-desc {
        display: none !important; /* ซ่อนสโลแกนบนมือถือเพื่อป้องกันการชนกับปุ่มและชื่อแอป */
    }
}

/* Accessibility overrides for mobile screens (maintain clean space & zero overlap) */
@media (max-width: 640px) {
    .lesson-view-container {
        padding: 12px 10px !important;
    }

    header.public-app-header,
    .public-app-header {
        padding: 12px 14px;
        margin-bottom: 14px;
        border-radius: 20px;
        gap: 10px;
    }

    .public-app-header-left {
        flex: 1 1 auto;
        gap: 10px;
    }

    .public-app-brand {
        gap: 10px;
    }

    .public-header-user-card {
        padding: 8px 12px;
        border-radius: 14px;
        gap: 10px;
    }

    .header-avatar-box {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
    }

    .header-avatar-box .public-avatar-placeholder {
        font-size: 1.3rem !important;
    }

    .header-user-welcome {
        font-size: 0.92rem;
    }

    .header-user-name {
        font-size: 1.05rem;
    }

    .public-app-title-main {
        font-size: 1.25rem;
    }

    .public-app-desc {
        font-size: 0.84rem;
    }

    .public-app-logo-box {
        width: 40px;
        height: 40px;
        border-radius: 12px;
    }

    .public-app-logo {
        width: 30px;
        height: 30px;
    }

    .header-sos-btn {
        height: 40px;
        min-height: 40px;
        padding: 0 10px;
        font-size: 0.92rem;
        border-radius: 12px;
    }

    .public-app-header .public-theme-btn,
    .public-theme-btn {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        border-radius: 12px;
    }

    /* แถบตัวหนังสือเต็มความกว้างบนมือถือ */
    .public-header-accessibility-bar {
        padding: 4px;
        gap: 4px;
        border-radius: 14px;
    }

    .font-scale-bar-label {
        display: none;
    }

    .public-app-header .font-scale-group,
    .font-scale-group {
        width: 100%;
        display: flex !important;
        height: 42px;
        border-radius: 12px;
        padding: 2px;
        gap: 4px;
    }

    .public-app-header .font-scale-btn,
    .font-scale-btn {
        flex: 1;
        min-width: 0 !important;
        height: 38px !important;
        min-height: 38px !important;
        padding: 0 6px !important;
        font-size: 0.88rem;
        border-radius: 9px;
        gap: 4px;
    }

    .font-scale-btn .font-scale-symbol {
        font-size: 1.05rem;
    }

    .font-scale-btn.font-scale-large-btn .font-scale-symbol {
        font-size: 1.15rem;
    }

    .font-scale-btn .font-scale-text {
        font-size: 0.88rem;
    }

    .header-user-meta-chips {
        flex-wrap: wrap;
        gap: 6px;
    }
}

@media (max-width: 380px) {
    header.public-app-header,
    .public-app-header {
        padding: 10px 10px;
        margin-bottom: 12px;
        gap: 8px;
        border-radius: 18px;
    }

    .public-header-user-card {
        padding: 6px 8px;
        gap: 8px;
    }

    .header-avatar-box {
        width: 34px;
        height: 34px;
        min-width: 34px;
        min-height: 34px;
    }

    .header-avatar-box .public-avatar-placeholder {
        font-size: 1.15rem !important;
    }

    .header-user-welcome {
        font-size: 0.85rem;
    }

    .header-user-name {
        font-size: 0.98rem;
    }

    .public-app-title-main {
        font-size: 1.16rem;
    }

    .public-app-desc {
        font-size: 0.78rem;
    }

    .public-app-logo-box {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }

    .public-app-logo {
        width: 26px;
        height: 26px;
    }

    .header-sos-btn {
        height: 38px;
        min-height: 38px;
        padding: 0 8px;
        font-size: 0.88rem;
        border-radius: 10px;
    }

    .public-app-header .public-theme-btn,
    .public-theme-btn {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        min-height: 38px !important;
        border-radius: 10px;
    }

    .public-header-accessibility-bar {
        padding: 3px;
        gap: 2px;
        border-radius: 12px;
    }

    .public-app-header .font-scale-group,
    .font-scale-group {
        height: 40px;
        padding: 2px;
        gap: 3px;
        border-radius: 10px;
    }

    .public-app-header .font-scale-btn,
    .font-scale-btn {
        height: 36px !important;
        min-height: 36px !important;
        padding: 0 3px !important;
        gap: 2px;
    }

    .font-scale-btn .font-scale-symbol {
        font-size: 0.98rem;
    }

    .font-scale-btn.font-scale-large-btn .font-scale-symbol {
        font-size: 1.05rem;
    }

    .font-scale-btn .font-scale-text {
        font-size: 0.80rem;
    }
}

/* ============================================================
   Public Learning Portal Mobile Usability Enhancements
   (Mobile-First Senior / Caregiver UX Architecture)
   ============================================================ */

/* 1. Header User Card Contrast Fix */
.public-header-user-card .header-user-welcome {
    color: rgba(255, 255, 255, 0.9) !important;
}
.public-header-user-card .header-user-name {
    color: #ffffff !important;
}
.public-header-user-card #profile-real-name {
    color: rgba(255, 255, 255, 0.95) !important;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}

/* 2. Top Nav Bar & Breadcrumb */
.learning-top-nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 10px 0 16px 0;
}
.btn-back-home-top {
    padding: 10px 18px !important;
    font-size: 1.02rem !important;
    flex-shrink: 0;
}
.learning-top-breadcrumb {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}
.breadcrumb-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 2.5px rgba(16, 185, 129, 0.25);
}

/* 3. Hero Intro */
.learning-hero-intro {
    margin-bottom: 18px;
}
.learning-page-title {
    font-size: clamp(1.35rem, 4.5vw, 1.85rem);
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 8px 0;
    line-height: 1.35;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    overflow-wrap: anywhere;
}
.learning-page-title-sub {
    color: #10b981;
}
.learning-page-subtitle {
    color: var(--text-muted);
    font-size: clamp(0.98rem, 3.2vw, 1.15rem);
    margin: 0;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

/* 4. Curriculum Progress Box Tuning */
#prog-count-text {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}
.curriculum-progress-box .progress-bar-container {
    height: 10px;
    border-radius: 10px;
    background: rgba(100, 116, 139, 0.2);
    overflow: hidden;
    margin: 10px 0;
}
.curriculum-progress-box .progress-bar-fill {
    height: 100%;
    border-radius: 10px;
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

/* 5. Resume Learning Hero Card (Enlarged Hero) */
.resume-learning-hero {
    margin: 20px 0 28px 0;
}
.resume-hero-card {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.18) 0%, rgba(5, 150, 105, 0.08) 100%);
    border: 2px solid rgba(16, 185, 129, 0.5);
    border-radius: 22px;
    padding: 22px 22px;
    box-shadow: 0 8px 28px rgba(16, 185, 129, 0.15);
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
[data-theme="dark"] .resume-hero-card {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.22) 0%, rgba(15, 23, 42, 0.8) 100%);
    border-color: rgba(16, 185, 129, 0.55);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}
.resume-hero-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.resume-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.98rem;
    font-weight: 800;
    color: #059669;
    background: rgba(16, 185, 129, 0.18);
    padding: 6px 14px;
    border-radius: 14px;
    width: fit-content;
}
[data-theme="dark"] .resume-hero-badge {
    color: #34d399;
    background: rgba(16, 185, 129, 0.26);
}
.resume-hero-tag {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-muted);
}
.pulse-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.35);
    animation: pulse-ring 2s infinite;
}
.resume-hero-body {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}
.resume-hero-icon {
    width: 64px;
    height: 64px;
    min-width: 64px;
    border-radius: 18px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}
.resume-hero-info {
    flex: 1;
    min-width: 0;
}
.resume-hero-module-no {
    font-size: 0.92rem;
    font-weight: 800;
    color: #10b981;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 2px;
}
.resume-hero-title {
    font-size: clamp(1.35rem, 4.8vw, 1.65rem);
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 8px 0;
    line-height: 1.35;
    overflow-wrap: anywhere;
}
.resume-hero-summary {
    font-size: 1.05rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0 0 10px 0;
    overflow-wrap: anywhere;
}
.resume-hero-meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.resume-hero-meta-pill {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 10px;
}
.resume-hero-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff !important;
    font-size: 1.25rem;
    font-weight: 800;
    padding: 16px 24px;
    border-radius: 18px;
    text-decoration: none;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    min-height: 56px;
    transition: all 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.resume-hero-btn:hover {
    box-shadow: 0 8px 26px rgba(16, 185, 129, 0.5);
    transform: translateY(-2px);
}
.resume-hero-btn:active {
    transform: scale(0.98);
}

/* 6. Grand Certificate Banner Styling */
.grand-cert-banner {
    padding: 24px 20px;
    border-radius: 20px;
    text-align: center;
    margin-bottom: 24px;
}
.grand-cert-icon {
    font-size: 2.8rem;
    margin-bottom: 8px;
}
.grand-cert-title {
    font-size: clamp(1.3rem, 4vw, 1.65rem);
    font-weight: 800;
    color: #b45309;
    margin: 0 0 8px 0;
    line-height: 1.35;
}
.grand-cert-desc {
    color: var(--text-muted);
    font-size: clamp(0.95rem, 3.2vw, 1.12rem);
    margin: 0 0 16px 0;
    line-height: 1.6;
}
.grand-cert-btn {
    font-size: 1.15rem;
    font-weight: 800;
    padding: 14px 26px;
    border-radius: 18px;
    display: inline-block;
    text-decoration: none;
    min-height: 48px;
    box-sizing: border-box;
}

/* 7. Filter Chips Bar (Smooth Horizontal Scroll) */
.learning-filter-scroll-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 2px 10px 2px;
    margin-top: 10px;
    margin-bottom: 14px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.learning-filter-scroll-wrap::-webkit-scrollbar {
    display: none;
}
.learning-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 700;
    background: var(--card-bg);
    border: 1.5px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    min-height: 44px;
    transition: all 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.learning-filter-chip:hover {
    border-color: #10b981;
    color: var(--text-primary);
}
.learning-filter-chip.is-active {
    background: #10b981;
    border-color: #10b981;
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}
.learning-filter-chip .chip-count {
    font-size: 0.82rem;
    padding: 2px 7px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.08);
    color: inherit;
    font-weight: 800;
}
.learning-filter-chip.is-active .chip-count {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

/* 8. Module Card Mobile Enhancements */
.module-card {
    border-radius: 18px;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.module-card:active:not(.is-locked) {
    transform: scale(0.985);
}
.module-card.is-unlocked-active {
    border-color: #10b981;
    box-shadow: 0 4px 18px rgba(16, 185, 129, 0.12);
}
.module-card.is-locked {
    opacity: 0.78;
    background: var(--bg-primary);
    border: 1.5px dashed var(--border-color);
}
.module-card.is-locked .module-title {
    color: var(--text-muted);
}
.module-card-btn {
    min-height: 52px !important;
    font-size: 1.12rem !important;
    border-radius: 16px !important;
}

/* 9. Medical Resources Library */
.public-resources-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 22px 20px;
    margin-top: 28px;
}
.resources-section-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 18px;
}
.resources-header-icon {
    font-size: 2.2rem;
    line-height: 1;
    flex-shrink: 0;
}
.resources-section-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 6px 0;
    line-height: 1.35;
    overflow-wrap: anywhere;
}
.resources-section-subtitle {
    font-size: 1rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.6;
    overflow-wrap: anywhere;
}
.resource-card-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-primary);
    border: 1.5px solid var(--border-color);
    border-radius: 16px;
    text-decoration: none;
    color: inherit;
    transition: all 0.15s ease;
    min-height: 54px;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}
.resource-card-link:hover {
    border-color: #10b981;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.12);
}
.resource-card-link:active {
    transform: scale(0.985);
}
.resource-card-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
}
.resource-card-body {
    flex: 1;
    min-width: 0;
}
.resource-card-title {
    font-size: 1.08rem !important;
    font-weight: 700 !important;
    color: var(--text-primary) !important;
    line-height: 1.45 !important;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.resource-card-meta {
    font-size: 0.92rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 600;
}

/* 10. Floating Back-to-Top Button */
.btn-back-to-top {
    position: fixed;
    bottom: 24px;
    right: 20px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 25px;
    background: #10b981;
    color: #ffffff;
    border: none;
    font-size: 0.95rem;
    font-weight: 800;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    cursor: pointer;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}
.btn-back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.btn-back-to-top:active {
    transform: scale(0.94);
}

/* 11. Mobile Screen Overrides (<= 640px) */
@media (max-width: 640px) {
    .learning-page-title {
        font-size: 1.45rem;
    }
    .learning-page-subtitle {
        font-size: 0.98rem;
    }
    .module-cards-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    .module-card {
        padding: 16px 14px !important;
        border-radius: 16px !important;
    }
    .module-title {
        font-size: 1.18rem !important;
    }
    .module-summary {
        font-size: 0.95rem !important;
        line-height: 1.5 !important;
    }
    .module-card-btn {
        min-height: 50px !important;
        padding: 12px 18px !important;
        font-size: 1.08rem !important;
    }
    .public-resources-section {
        padding: 16px 14px;
        border-radius: 18px;
    }
    .public-resources-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .resume-hero-card {
        padding: 20px 18px;
        border-radius: 20px;
        gap: 15px;
    }
    .resume-hero-icon {
        width: 58px;
        height: 58px;
        min-width: 58px;
        font-size: 2.2rem;
        border-radius: 16px;
    }
    .resume-hero-title {
        font-size: 1.42rem !important;
    }
    .resume-hero-summary {
        font-size: 1rem;
        line-height: 1.55;
    }
    .resume-hero-btn {
        padding: 16px 22px;
        font-size: 1.25rem;
        min-height: 56px;
        border-radius: 18px;
    }
    .grand-cert-banner {
        padding: 20px 16px;
        border-radius: 18px;
    }
    .grand-cert-btn {
        padding: 12px 20px;
        font-size: 1.08rem;
        width: 100%;
        text-align: center;
    }
    .lesson-nav-cluster {
        width: 100%;
        gap: 8px;
    }
    .lesson-nav-cluster .btn-back-home,
    .lesson-nav-cluster .btn-back-learning {
        flex: 1 1 calc(50% - 8px);
        min-width: 130px;
        font-size: 0.98rem !important;
        padding: 10px 12px !important;
    }
    .public-bottom-return-bar {
        padding: 18px 14px;
        margin-top: 28px;
        border-radius: 18px;
    }
    .public-bottom-return-bar .btn-back-home {
        width: 100% !important;
        font-size: 1.15rem !important;
        padding: 14px 18px !important;
        min-height: 52px !important;
    }
    .modal-btn-close-bottom {
        min-height: 52px !important;
        font-size: 1.15rem !important;
        border-radius: 18px !important;
    }
}

/* 10 Modules List & Filter Section Hidden on Public Learning Landing Page */
.module-section-header,
.module-cards-grid {
    display: none !important;
}

/* ============================================================
   หน้าต่างเข้าสู่ระบบ LINE & ปุ่ม Bypass สำหรับทดสอบระบบ (Login Gateway)
   ============================================================ */
.learning-login-gateway {
    width: 100%;
    max-width: 620px;
    margin: 20px auto 36px auto;
    animation: fadeInGateway 0.3s ease-out;
}

@keyframes fadeInGateway {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-gateway-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 22px;
    padding: 24px 20px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(8px);
    text-align: center;
}

.login-gateway-brand {
    margin-bottom: 18px;
}

.login-gateway-icon-wrap {
    width: 62px;
    height: 62px;
    margin: 0 auto 12px auto;
    background: linear-gradient(135deg, rgba(6, 199, 85, 0.15) 0%, rgba(37, 99, 235, 0.15) 100%);
    border: 2px solid rgba(6, 199, 85, 0.3);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(6, 199, 85, 0.15);
}

.login-gateway-title {
    margin: 0 0 6px 0;
    font-size: 1.52rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.35;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.login-gateway-title-sub {
    font-size: 1.12rem;
    font-weight: 700;
    color: #10b981;
}

.login-gateway-subtitle {
    margin: 0;
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1.55;
}

.login-benefits-list {
    background: rgba(37, 99, 235, 0.05);
    border: 1px solid rgba(37, 99, 235, 0.18);
    border-radius: 16px;
    padding: 12px 16px;
    margin-bottom: 18px;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.benefit-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.98rem;
    color: var(--text-primary);
    line-height: 1.45;
}

.benefit-icon {
    font-size: 1.25rem;
    line-height: 1.2;
    flex-shrink: 0;
}

.login-actions-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

/* ปุ่ม LINE Login สีเขียวมาตรฐาน */
.btn-line-gateway {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    min-height: 58px;
    padding: 12px 18px;
    background: #06C755;
    color: #ffffff !important;
    border: none;
    border-radius: 18px;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(6, 199, 85, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
    text-decoration: none;
    box-sizing: border-box;
}

.btn-line-gateway:hover,
.btn-line-gateway:focus-visible {
    background: #05b34c;
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(6, 199, 85, 0.45);
}

.btn-line-gateway:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(6, 199, 85, 0.3);
}

.line-icon-svg {
    flex-shrink: 0;
}

.line-btn-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    line-height: 1.3;
}

.line-btn-main {
    font-size: 1.22rem;
    font-weight: 800;
    letter-spacing: 0.3px;
}

.line-btn-sub {
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.95;
}

/* ตัวคั่น "หรือ สำหรับทดสอบระบบ" */
.login-divider {
    display: flex;
    align-items: center;
    margin: 2px 0;
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 600;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.login-divider span {
    padding: 0 12px;
    white-space: nowrap;
}

/* ปุ่ม Bypass สำหรับทดสอบระบบแบบไม่ต้อง Login */
.btn-bypass-gateway {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 54px;
    padding: 10px 16px;
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-primary) !important;
    border: 2px dashed rgba(148, 163, 184, 0.38);
    border-radius: 16px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    box-sizing: border-box;
}

.btn-bypass-gateway:hover,
.btn-bypass-gateway:focus-visible {
    background: rgba(37, 99, 235, 0.1);
    border-color: rgba(37, 99, 235, 0.55);
    color: #2563eb !important;
    transform: translateY(-2px);
}

.btn-bypass-gateway:active {
    transform: translateY(0);
}

.bypass-btn-icon {
    font-size: 1.35rem;
    line-height: 1;
    flex-shrink: 0;
}

.bypass-btn-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    line-height: 1.35;
}

.bypass-btn-main {
    font-size: 1.12rem;
    font-weight: 800;
}

.bypass-btn-sub {
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.85;
}

.login-gateway-footer {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}

@media (max-width: 480px) {
    .login-gateway-card {
        padding: 18px 14px;
        border-radius: 18px;
    }
    .login-gateway-icon-wrap {
        width: 54px;
        height: 54px;
        margin-bottom: 10px;
        border-radius: 16px;
    }
    .login-gateway-title {
        font-size: 1.35rem;
    }
    .login-gateway-title-sub {
        font-size: 1.02rem;
    }
    .login-gateway-subtitle {
        font-size: 0.94rem;
    }
    .login-benefits-list {
        padding: 10px 12px;
        margin-bottom: 14px;
        gap: 6px;
    }
    .benefit-item {
        font-size: 0.92rem;
    }
    .btn-line-gateway {
        min-height: 54px;
        padding: 10px 14px;
    }
    .line-btn-main {
        font-size: 1.12rem;
    }
    .line-btn-sub {
        font-size: 0.8rem;
    }
    .btn-bypass-gateway {
        min-height: 48px;
        padding: 8px 12px;
    }
    .bypass-btn-main {
        font-size: 1.02rem;
    }
    .bypass-btn-sub {
        font-size: 0.8rem;
    }
}



