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

/* ===== iOS Design Tokens ===== */
:root {
    --ios-bg:        #f2f2f7;
    --ios-card:      #ffffff;
    --ios-blue:      #007aff;
    --ios-blue-dark: #0062cc;
    --ios-green:     #34c759;
    --ios-red:       #ff3b30;
    --ios-orange:    #ff9500;
    --ios-yellow:    #ffcc00;
    --ios-gray:      #8e8e93;
    --ios-gray2:     #aeaeb2;
    --ios-gray4:     #d1d1d6;
    --ios-gray5:     #e5e5ea;
    --ios-gray6:     #f2f2f7;
    --ios-label:     #1c1c1e;
    --ios-label2:    #3c3c43cc;
    --ios-radius:    12px;
    --ios-radius-lg: 16px;
    --ios-radius-sm: 8px;
    --ios-radius-pill: 50px;
    --ios-shadow:    0 2px 12px rgba(0,0,0,.07);
    --ios-shadow-md: 0 4px 20px rgba(0,0,0,.10);

    /* theme (overridden by inline style from EJS) */
    --color-primary: #007aff;
    --color-dark:    #0062cc;
    --sidebar-width: 240px;
    --topbar-height: 52px;
}

/* ===== iOS Dark Mode — Complete Theme ===== */
[data-theme="dark"] {
    /* ── iOS design tokens ── */
    --ios-bg:        #000000;
    --ios-card:      #1c1c1e;
    --ios-gray:      #8e8e93;
    --ios-gray2:     #636366;
    --ios-gray4:     #48484a;
    --ios-gray5:     #3a3a3c;
    --ios-gray6:     #2c2c2e;
    --ios-label:     #ffffff;
    --ios-label2:    rgba(235,235,245,.6);
    --ios-shadow:    0 2px 12px rgba(0,0,0,.45);
    --ios-shadow-md: 0 4px 24px rgba(0,0,0,.6);

    /* ── Bootstrap 5 core variables (cascade into ALL components) ── */
    --bs-body-bg:               #000000;
    --bs-body-color:            #ffffff;
    --bs-secondary-color:       #8e8e93;
    --bs-tertiary-color:        #636366;
    --bs-emphasis-color:        #ffffff;
    --bs-secondary-bg:          #1c1c1e;
    --bs-tertiary-bg:           #2c2c2e;
    --bs-border-color:          #3a3a3c;
    --bs-border-color-translucent: rgba(255,255,255,.1);
    --bs-link-color:            #0a84ff;
    --bs-link-hover-color:      #409cff;

    /* ── Bootstrap table ── */
    --bs-table-bg:              transparent;
    --bs-table-color:           #ffffff;
    --bs-table-border-color:    #3a3a3c;
    --bs-table-striped-bg:      rgba(44,44,46,.55);
    --bs-table-striped-color:   #ffffff;
    --bs-table-hover-bg:        rgba(58,58,60,.6);
    --bs-table-hover-color:     #ffffff;
    --bs-table-active-bg:       rgba(58,58,60,.75);

    /* ── Bootstrap form ── */
    --bs-form-control-bg:       #2c2c2e;
    --bs-form-control-color:    #ffffff;
    --bs-input-bg:              #2c2c2e;
    --bs-input-color:           #ffffff;
    --bs-input-border-color:    #48484a;
    --bs-input-focus-bg:        #3a3a3c;
    --bs-input-focus-border-color: #007aff;
    --bs-input-placeholder-color: #636366;
    --bs-input-disabled-bg:     #1c1c1e;
    --bs-form-select-bg:        #2c2c2e;
    --bs-form-select-color:     #ffffff;

    /* ── Bootstrap card ── */
    --bs-card-bg:               #1c1c1e;
    --bs-card-border-color:     #3a3a3c;
    --bs-card-cap-bg:           #2c2c2e;
    --bs-card-color:            #ffffff;

    /* ── Bootstrap modal ── */
    --bs-modal-bg:              #1c1c1e;
    --bs-modal-color:           #ffffff;
    --bs-modal-header-border-color: #3a3a3c;
    --bs-modal-footer-border-color: #3a3a3c;

    /* ── Bootstrap dropdown ── */
    --bs-dropdown-bg:           #2c2c2e;
    --bs-dropdown-border-color: #3a3a3c;
    --bs-dropdown-link-color:   #ffffff;
    --bs-dropdown-link-hover-bg:#3a3a3c;
    --bs-dropdown-link-hover-color: #ffffff;
    --bs-dropdown-link-active-bg: #007aff;
    --bs-dropdown-divider-bg:   #3a3a3c;

    /* ── Bootstrap list group ── */
    --bs-list-group-bg:         #1c1c1e;
    --bs-list-group-color:      #ffffff;
    --bs-list-group-border-color: #3a3a3c;
    --bs-list-group-action-hover-bg: #2c2c2e;

    /* ── Bootstrap nav ── */
    --bs-nav-link-color:        rgba(235,235,245,.6);
    --bs-nav-tabs-border-color: #3a3a3c;
    --bs-nav-tabs-link-active-bg: #1c1c1e;

    /* ── Bootstrap badge / pagination ── */
    --bs-pagination-bg:         #2c2c2e;
    --bs-pagination-border-color: #3a3a3c;
    --bs-pagination-color:      #007aff;
    --bs-pagination-hover-bg:   #3a3a3c;

    /* ── Bootstrap alert ── */
    --bs-alert-bg:              transparent;
}

/* ── Base ── */
html[data-theme="dark"] { background: #000; }
[data-theme="dark"] body { background-color: #000000; color: #ffffff; }

/* ── Navbar ── */
[data-theme="dark"] .navbar {
    background: rgba(18,18,18,.92) !important;
    border-bottom-color: #2c2c2e !important;
}
[data-theme="dark"] .navbar-brand { color: #ffffff !important; }
[data-theme="dark"] .nav-link { color: rgba(235,235,245,.6) !important; }
[data-theme="dark"] .nav-link:hover,
[data-theme="dark"] .nav-link.active { background: #2c2c2e !important; color: #fff !important; }
[data-theme="dark"] .navbar-toggler { border-color: #48484a; }
[data-theme="dark"] .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255,255,255,0.7%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* ── Card ── */
[data-theme="dark"] .card { background: #1c1c1e !important; border-color: #2c2c2e; }
[data-theme="dark"] .card-header { background: #2c2c2e !important; border-bottom-color: #3a3a3c; color: #ffffff; }
[data-theme="dark"] .card-body  { color: #ffffff; }

/* ── Table — full override ── */
[data-theme="dark"] .table,
[data-theme="dark"] .table > :not(caption) > * > * {
    background-color: transparent;
    color: #ffffff;
    border-color: #3a3a3c;
}
[data-theme="dark"] .table > thead { background: #2c2c2e; }
[data-theme="dark"] .table th {
    background: #2c2c2e !important;
    color: #8e8e93 !important;
    border-bottom-color: #3a3a3c !important;
}
[data-theme="dark"] .table td { border-bottom-color: #2c2c2e !important; }
[data-theme="dark"] .table-light,
[data-theme="dark"] .table-light > th,
[data-theme="dark"] .table-light > td {
    --bs-table-bg: #2c2c2e;
    --bs-table-color: #ffffff;
    background-color: #2c2c2e !important;
    color: #ffffff !important;
}
[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * { background-color: rgba(44,44,46,.55) !important; color: #fff !important; }
[data-theme="dark"] .table-hover > tbody > tr:hover > * { background-color: rgba(58,58,60,.6) !important; color: #fff !important; }
[data-theme="dark"] .table-responsive { border-color: #3a3a3c; }

/* ── Backgrounds (Bootstrap utility classes) ── */
[data-theme="dark"] .bg-white  { background-color: #1c1c1e !important; color: #ffffff; }
[data-theme="dark"] .bg-light  { background-color: #2c2c2e !important; color: #ffffff; }
[data-theme="dark"] .bg-body   { background-color: #000000 !important; }
[data-theme="dark"] .bg-dark   { background-color: #000000 !important; }

/* ── Text utilities ── */
[data-theme="dark"] .text-muted  { color: #8e8e93 !important; }
[data-theme="dark"] .text-dark   { color: #ffffff !important; }
[data-theme="dark"] .text-body   { color: #ffffff !important; }
[data-theme="dark"] .text-black  { color: #ffffff !important; }
[data-theme="dark"] .text-secondary { color: #8e8e93 !important; }

/* ── Border utilities ── */
[data-theme="dark"] .border        { border-color: #3a3a3c !important; }
[data-theme="dark"] .border-top    { border-top-color: #3a3a3c !important; }
[data-theme="dark"] .border-bottom { border-bottom-color: #3a3a3c !important; }
[data-theme="dark"] .border-start  { border-left-color: #3a3a3c !important; }
[data-theme="dark"] .border-end    { border-right-color: #3a3a3c !important; }

/* ── Forms ── */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: #2c2c2e !important;
    color: #ffffff !important;
    border-color: #48484a !important;
}
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: #3a3a3c !important;
    border-color: #007aff !important;
    color: #ffffff !important;
}
[data-theme="dark"] .form-control::placeholder { color: #636366 !important; }
[data-theme="dark"] .form-control:disabled,
[data-theme="dark"] .form-select:disabled { background-color: #1c1c1e !important; color: #636366 !important; }
[data-theme="dark"] .form-label { color: rgba(235,235,245,.6) !important; }
[data-theme="dark"] .form-check-input { background-color: #48484a; border-color: #636366; }
[data-theme="dark"] .form-check-input:checked { background-color: #007aff; border-color: #007aff; }
[data-theme="dark"] .input-group-text {
    background-color: #3a3a3c !important;
    color: #8e8e93 !important;
    border-color: #48484a !important;
}

/* ── Buttons ── */
[data-theme="dark"] .btn-light {
    background: #2c2c2e !important;
    color: #ffffff !important;
    border-color: #48484a !important;
}
[data-theme="dark"] .btn-light:hover { background: #3a3a3c !important; }
[data-theme="dark"] .btn-outline-secondary {
    background: #2c2c2e !important;
    color: #ffffff !important;
    border-color: #48484a !important;
}
[data-theme="dark"] .btn-outline-secondary:hover { background: #3a3a3c !important; }
[data-theme="dark"] .btn-outline-danger { border-color: #ff3b30; color: #ff3b30; }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* ── Modal ── */
[data-theme="dark"] .modal-content {
    background: #1c1c1e !important;
    border: 1px solid #3a3a3c;
    color: #ffffff;
}
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer { background: #2c2c2e !important; border-color: #3a3a3c !important; }
[data-theme="dark"] .modal-body { background: #1c1c1e !important; color: #ffffff; }
[data-theme="dark"] .modal-backdrop { background: rgba(0,0,0,.7); }

/* ── Dropdown ── */
[data-theme="dark"] .dropdown-menu {
    background-color: #2c2c2e !important;
    border-color: #3a3a3c !important;
}
[data-theme="dark"] .dropdown-item { color: #ffffff !important; }
[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus { background: #3a3a3c !important; color: #fff !important; }
[data-theme="dark"] .dropdown-divider { border-color: #3a3a3c !important; }

/* ── Badge ── */
[data-theme="dark"] .badge.bg-secondary { background: #48484a !important; color: #fff !important; }
[data-theme="dark"] .badge.bg-light     { background: #3a3a3c !important; color: #fff !important; }

/* ── List Group ── */
[data-theme="dark"] .list-group-item {
    background-color: #1c1c1e !important;
    border-color: #3a3a3c !important;
    color: #ffffff !important;
}
[data-theme="dark"] .list-group-item-action:hover { background: #2c2c2e !important; }

/* ── Pagination ── */
[data-theme="dark"] .page-link { background-color: #2c2c2e !important; border-color: #3a3a3c !important; color: #007aff !important; }
[data-theme="dark"] .page-link:hover { background-color: #3a3a3c !important; }
[data-theme="dark"] .page-item.active .page-link { background-color: #007aff !important; border-color: #007aff !important; color: #fff !important; }
[data-theme="dark"] .page-item.disabled .page-link { background-color: #1c1c1e !important; color: #636366 !important; }

/* ── Alerts ── */
[data-theme="dark"] .alert-primary { background: rgba(0,122,255,.15)  !important; color: #5ac8fa  !important; border: none; }
[data-theme="dark"] .alert-success { background: rgba(52,199,89,.15)  !important; color: #30d158  !important; border: none; }
[data-theme="dark"] .alert-danger  { background: rgba(255,59,48,.15)  !important; color: #ff6961  !important; border: none; }
[data-theme="dark"] .alert-warning { background: rgba(255,149,0,.15)  !important; color: #ffd60a  !important; border: none; }
[data-theme="dark"] .alert-info    { background: rgba(50,173,230,.15) !important; color: #64d2ff  !important; border: none; }
[data-theme="dark"] .alert-secondary { background: rgba(72,72,74,.3)  !important; color: #aeaeb2  !important; border: none; }

/* ── Footer ── */
[data-theme="dark"] footer { border-top-color: #2c2c2e !important; }
[data-theme="dark"] footer p { color: #8e8e93 !important; }

/* ── Accordion ── */
[data-theme="dark"] .accordion-item { background: #1c1c1e; border-color: #3a3a3c; }
[data-theme="dark"] .accordion-button {
    background: #2c2c2e !important;
    color: #ffffff !important;
}
[data-theme="dark"] .accordion-button:not(.collapsed) { background: #007aff !important; color: #fff !important; }
[data-theme="dark"] .accordion-button::after { filter: invert(1); }
[data-theme="dark"] .accordion-body { background: #1c1c1e; color: #fff; }

/* ── Tabs ── */
[data-theme="dark"] .nav-tabs { border-bottom-color: #3a3a3c; }
[data-theme="dark"] .nav-tabs .nav-link { color: #8e8e93 !important; }
[data-theme="dark"] .nav-tabs .nav-link.active { background: #1c1c1e !important; border-color: #3a3a3c #3a3a3c #1c1c1e !important; color: #fff !important; }

/* ── Callout ── */
[data-theme="dark"] .callout { background: #1c1c1e; }

/* ── Admin topbar ── */
[data-theme="dark"] .admin-topbar {
    background: rgba(18,18,18,.92) !important;
    border-bottom-color: #2c2c2e !important;
}
[data-theme="dark"] .admin-topbar .topbar-title { color: #ffffff; }

/* ── Page header admin ── */
[data-theme="dark"] .page-header-admin { border-bottom-color: #3a3a3c; }
[data-theme="dark"] .page-header-admin h3 { color: #ffffff; }

/* ── Inline style overrides for pages that hardcode colors ── */
[data-theme="dark"] [style*="background:var(--ios-gray6)"],
[data-theme="dark"] [style*="background: var(--ios-gray6)"] { color: #ffffff; }
[data-theme="dark"] [style*="color:#1c1c1e"] { color: #ffffff !important; }
[data-theme="dark"] [style*="color: #1c1c1e"] { color: #ffffff !important; }

/* ── SweetAlert2 dark (scoped on both html and body for Swal appended elements) ── */
html[data-theme="dark"] .swal2-popup,
body[data-theme="dark"] .swal2-popup {
    background: #1c1c1e !important;
    color: #ffffff !important;
    border: 1px solid #3a3a3c;
}
html[data-theme="dark"] .swal2-title,
body[data-theme="dark"] .swal2-title { color: #ffffff !important; }
html[data-theme="dark"] .swal2-html-container,
body[data-theme="dark"] .swal2-html-container { color: #ebebf5 !important; }
html[data-theme="dark"] .swal2-input,
html[data-theme="dark"] .swal2-textarea,
body[data-theme="dark"] .swal2-input,
body[data-theme="dark"] .swal2-textarea {
    background: #2c2c2e !important;
    color: #ffffff !important;
    border-color: #48484a !important;
}
html[data-theme="dark"] .swal2-input::placeholder,
html[data-theme="dark"] .swal2-textarea::placeholder,
body[data-theme="dark"] .swal2-input::placeholder,
body[data-theme="dark"] .swal2-textarea::placeholder { color: #636366 !important; }
html[data-theme="dark"] .swal2-validation-message,
body[data-theme="dark"] .swal2-validation-message { background: #2c2c2e !important; color: #ff6961 !important; }
html[data-theme="dark"] .swal2-close,
body[data-theme="dark"] .swal2-close { color: #8e8e93 !important; }
html[data-theme="dark"] .swal2-icon.swal2-warning { border-color: #ff9500 !important; color: #ff9500 !important; }
html[data-theme="dark"] .swal2-icon.swal2-error   { border-color: #ff3b30 !important; color: #ff3b30 !important; }
html[data-theme="dark"] .swal2-icon.swal2-success  { border-color: #34c759 !important; color: #34c759 !important; }

/* ── Dark mode toggle button animation ── */
#themeToggleBtn { transition: transform .3s cubic-bezier(.34,1.56,.64,1); }
#themeToggleBtn:hover { transform: rotate(20deg) scale(1.1); }

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Kanit', sans-serif;
    background-color: var(--ios-bg);
    color: var(--ios-label);
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: var(--ios-blue); }
a:hover { color: var(--ios-blue-dark); }
img { max-width: 100%; height: auto; }

/* ===== Pace ===== */
.pace { pointer-events: none; user-select: none; }
.pace-inactive { display: none; }
.pace .pace-progress {
    background: var(--color-primary);
    position: fixed; z-index: 9999;
    top: 0; right: 100%;
    width: 100%; height: 3px;
}

/* ===== Navbar ===== */
.navbar {
    background: rgba(255,255,255,.85) !important;
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--ios-gray5);
    box-shadow: none;
    padding-top: 8px;
    padding-bottom: 8px;
    will-change: transform;
    transform: translateZ(0);
}
.navbar-brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--ios-label) !important;
    letter-spacing: -.3px;
}
.navbar-brand i { color: var(--color-primary); }
.nav-link {
    font-weight: 500;
    font-size: 0.88rem;
    color: var(--ios-label2) !important;
    border-radius: var(--ios-radius-sm);
    padding: 6px 10px !important;
    transition: background .15s, color .15s;
}
.nav-link:hover, .nav-link.active {
    color: var(--ios-label) !important;
    background: var(--ios-gray6);
}
.navbar-toggler {
    border: 1px solid var(--ios-gray4);
    padding: 4px 8px;
    border-radius: var(--ios-radius-sm);
}
.navbar-toggler:focus { box-shadow: none; }
.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2828,28,30,0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
.dropdown-menu {
    border: none;
    border-radius: var(--ios-radius);
    box-shadow: var(--ios-shadow-md);
    padding: 6px;
    min-width: 160px;
}
.dropdown-item {
    border-radius: var(--ios-radius-sm);
    font-size: 0.88rem;
    padding: 8px 12px;
    color: var(--ios-label);
}
.dropdown-item:hover { background: var(--ios-gray6); }

/* ===== Page wrapper ===== */
.page-wrapper { padding: 20px 0 40px; }

/* ===== Cards ===== */
.card {
    background: var(--ios-card);
    border: none;
    border-radius: var(--ios-radius-lg);
    box-shadow: var(--ios-shadow);
    margin-bottom: 16px;
    overflow: hidden;
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--ios-gray5);
    font-weight: 600;
    font-size: 0.92rem;
    padding: 14px 16px;
    color: var(--ios-label);
}
.card-header.bg-primary {
    background: var(--color-primary) !important;
    color: #fff;
    border-bottom: none;
}
.card-header.bg-success { background: var(--ios-green) !important; color: #fff; border-bottom: none; }
.card-header.bg-danger  { background: var(--ios-red) !important;   color: #fff; border-bottom: none; }
.card-header.bg-warning { background: var(--ios-orange) !important; color: #fff; border-bottom: none; }
.card-header.bg-info    { background: #32ade6 !important; color: #fff; border-bottom: none; }
.card-header.bg-dark    { background: #1c1c1e !important; color: #fff; border-bottom: none; }
.card-body { padding: 16px; }

/* Bordered card variants */
.card.border-success { border: 1.5px solid var(--ios-green) !important; }
.card.border-warning { border: 1.5px solid var(--ios-orange) !important; }
.card.border-info    { border: 1.5px solid #32ade6 !important; }
.card.border-danger  { border: 1.5px solid var(--ios-red) !important; }

/* ===== Buttons ===== */
.btn {
    font-family: 'Kanit', sans-serif;
    font-weight: 600;
    font-size: 0.88rem;
    border-radius: var(--ios-radius-pill);
    padding: 9px 20px;
    border: none;
    transition: opacity .15s, transform .1s;
    letter-spacing: .1px;
}
.btn:active { transform: scale(.97); }

.btn-primary {
    background: var(--color-primary) !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(0,122,255,.25);
}
.btn-primary:hover { opacity: .88; }

.btn-success {
    background: var(--ios-green) !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(52,199,89,.25);
}
.btn-danger  { background: var(--ios-red) !important; color: #fff !important; }
.btn-warning { background: var(--ios-orange) !important; color: #fff !important; }
.btn-info    { background: #32ade6 !important; color: #fff !important; }
.btn-dark    { background: #1c1c1e !important; color: #fff !important; }

.btn-outline-secondary {
    background: var(--ios-gray6) !important;
    color: var(--ios-label) !important;
    border: none !important;
}
.btn-outline-secondary:hover { background: var(--ios-gray5) !important; }

.btn-sm  { padding: 6px 14px; font-size: 0.82rem; }
.btn-lg  { padding: 13px 28px; font-size: 1rem; }
.btn-link { background: none !important; color: var(--ios-blue) !important;
            box-shadow: none !important; padding: 0 !important;
            border-radius: 0 !important; }

/* ===== Alerts ===== */
.alert {
    border: none;
    border-radius: var(--ios-radius);
    font-size: 0.88rem;
    font-weight: 500;
    padding: 12px 16px;
}
.alert-primary { background: rgba(0,122,255,.1);  color: #0060c7; }
.alert-success { background: rgba(52,199,89,.12); color: #1a7a35; }
.alert-danger  { background: rgba(255,59,48,.1);  color: #c0392b; }
.alert-warning { background: rgba(255,149,0,.12); color: #b35900; }
.alert-info    { background: rgba(50,173,230,.12); color: #1a7090; }
.alert-dark    { background: #1c1c1e; color: #fff; }
.alert-link    { font-weight: 700; }

/* ===== Forms ===== */
.form-control, .form-select {
    font-family: 'Kanit', sans-serif;
    background: var(--ios-gray6);
    border: 1.5px solid transparent;
    border-radius: var(--ios-radius);
    padding: 10px 14px;
    font-size: 0.92rem;
    color: var(--ios-label);
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
    background: var(--ios-card);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0,122,255,.12);
    outline: none;
}
.form-control.is-invalid {
    border-color: var(--ios-red);
    box-shadow: 0 0 0 3px rgba(255,59,48,.12);
}
.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--ios-label2);
    margin-bottom: 6px;
}
.form-text { font-size: 0.78rem; color: var(--ios-gray); }

.input-group-text {
    background: var(--ios-gray5);
    border: 1.5px solid transparent;
    border-right: none;
    border-radius: var(--ios-radius) 0 0 var(--ios-radius);
    color: var(--ios-gray);
    font-size: 0.92rem;
}
.input-group > .form-control { border-radius: 0 var(--ios-radius) var(--ios-radius) 0; }
.input-group > .btn { border-radius: 0 var(--ios-radius-pill) var(--ios-radius-pill) 0; }
.input-group-lg .form-control { font-size: 0.95rem; padding: 12px 14px; }
.input-group-lg .input-group-text { font-size: 0.95rem; }

/* ===== Tables ===== */
.table { font-size: 0.88rem; color: var(--ios-label); }
.table th {
    font-weight: 600;
    color: var(--ios-gray);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 1.5px solid var(--ios-gray5) !important;
    padding: 10px 12px;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--ios-gray6); vertical-align: middle; }
.table-striped > tbody > tr:nth-of-type(odd) > * { background: rgba(242,242,247,.6); }
.table-sm th, .table-sm td { padding: 7px 10px; }

/* ===== Badges ===== */
.badge {
    font-family: 'Kanit', sans-serif;
    font-weight: 600;
    font-size: 0.72rem;
    border-radius: var(--ios-radius-pill);
    padding: 4px 10px;
}
.badge.bg-success { background: var(--ios-green) !important; }
.badge.bg-danger  { background: var(--ios-red) !important; }
.badge.bg-warning { background: var(--ios-orange) !important; }
.badge.bg-secondary { background: var(--ios-gray4) !important; color: var(--ios-label) !important; }

/* ===== List group ===== */
.list-group { border-radius: var(--ios-radius-lg); overflow: hidden; box-shadow: var(--ios-shadow); }
.list-group-item {
    border: none;
    border-bottom: 1px solid var(--ios-gray5);
    padding: 14px 16px;
    font-size: 0.9rem;
    color: var(--ios-label);
    background: var(--ios-card);
    transition: background .12s;
}
.list-group-item:last-child { border-bottom: none; }
.list-group-item-action:hover { background: var(--ios-gray6); color: var(--ios-label); }

/* ===== Pagination ===== */
.pagination { gap: 4px; }
.page-link {
    border: none;
    border-radius: var(--ios-radius-sm) !important;
    color: var(--color-primary);
    font-weight: 500;
    font-size: 0.88rem;
    padding: 6px 12px;
    background: var(--ios-gray6);
}
.page-item.active .page-link {
    background: var(--color-primary);
    color: #fff;
}
.page-link:hover { background: var(--ios-gray5); color: var(--color-primary); }

/* ===== Modal ===== */
.modal-content {
    border: none;
    border-radius: var(--ios-radius-lg);
    box-shadow: var(--ios-shadow-md);
    overflow: hidden;
}
.modal-header {
    border-bottom: 1px solid var(--ios-gray5);
    padding: 16px 20px;
}
.modal-title { font-weight: 700; font-size: 1rem; }
.modal-footer { border-top: 1px solid var(--ios-gray5); padding: 12px 20px; }
.modal-backdrop { background: rgba(0,0,0,.45); }

/* ===== Callout (feed) ===== */
.callout {
    padding: 14px 16px;
    margin: 10px 0;
    border: none;
    border-radius: var(--ios-radius-lg);
    background: var(--ios-card);
    box-shadow: var(--ios-shadow);
}
.callout h4 { margin-top: 0; margin-bottom: 6px; font-size: 0.9rem; }
.callout h4 a { font-weight: 600; color: var(--ios-label); }
.callout h4 .timeago { font-size: .7em; color: var(--ios-gray); }
.callout p:last-child { margin-bottom: 0; font-size: 0.88rem; }
.callout-success { border-left: 3px solid var(--ios-green); }
.callout-warning { border-left: 3px solid var(--ios-orange); }

/* ===== Reaction radio ===== */
.input-hidden { position: absolute; left: -9999px; }
.form-check-inline { display: inline-block; padding: 3px; }
input[type=radio]:checked + label > img {
    border: 2.5px solid #fff;
    box-shadow: 0 0 0 3px var(--color-primary);
    transform: scale(1.2);
    transition: transform .2s cubic-bezier(.34,1.56,.64,1);
    border-radius: 50%;
}

/* ===== Countdown ===== */
.countdown { font-family: 'Kanit', sans-serif; }
.countdown ul { list-style: none; padding: 2px; margin: 0; }
.countdown ul li { display: inline-block; }
.countdown ul li span { font-size: 22px; font-weight: 300; line-height: 40px; }
.countdown ul li.seperator { font-size: 20px; line-height: 35px; vertical-align: top; }
.countdown ul li p { font-size: 11px; margin: 0; color: var(--ios-gray); }
#premium-countdown {
    padding: 12px;
    text-align: center;
    background: var(--ios-label);
    color: #fff;
    border-radius: var(--ios-radius-lg);
    margin: 8px 0 16px;
}
#next #countdown { font-weight: 700; }

/* ===== Feed misc ===== */
.feed-img { margin-bottom: 8px; }
.list-log .fa-thumbs-up { color: var(--ios-red); }
.list-log .timeago { color: var(--ios-gray); font-size: smaller; }

/* ===== Footer ===== */
footer { font-size: 0.82rem; color: var(--ios-gray); }
footer a { color: var(--ios-gray); }
footer a:hover { color: var(--ios-label); }

/* ===== Utility ===== */
.nfont { font-weight: 300; }
.tooltip { position: fixed; }

/* ===== iOS Toast Notification ===== */
#ios-toast-container {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 320px;
    max-width: calc(100vw - 32px);
    pointer-events: none;
}
.ios-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(30,30,30,.92);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    color: #fff;
    padding: 12px 16px;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,.25);
    font-family: 'Kanit', sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
    width: 100%;
    pointer-events: all;
    animation: toast-in .3s cubic-bezier(.34,1.56,.64,1) forwards;
}
.ios-toast.hiding { animation: toast-out .25s ease forwards; }
.ios-toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.ios-toast-icon.success { color: #34c759; }
.ios-toast-icon.error   { color: #ff3b30; }
.ios-toast-icon.info    { color: #32ade6; }
.ios-toast-icon.warning { color: #ff9500; }
@keyframes toast-in {
    from { opacity: 0; transform: translateY(-16px) scale(.9); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(-10px) scale(.95); }
}

/* ===== Admin Sidebar ===== */
.admin-layout { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: #1c1c1e;
    position: fixed;
    top: 0; left: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.admin-sidebar .sidebar-brand {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    display: block;
    letter-spacing: -.3px;
}
.admin-sidebar .sidebar-brand i { color: var(--color-primary); margin-right: 8px; }
.admin-sidebar .sidebar-nav {
    flex: 1; padding: 10px 8px;
    list-style: none; margin: 0;
    overflow-y: auto;
}
.admin-sidebar .sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: #8e8e93;
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: var(--ios-radius);
    margin-bottom: 2px;
    transition: background .15s, color .15s;
}
.admin-sidebar .sidebar-nav a i { width: 20px; margin-right: 10px; font-size: 0.9rem; }
.admin-sidebar .sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.admin-sidebar .sidebar-nav a.active {
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
}
.admin-sidebar .sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.admin-sidebar .sidebar-footer a {
    color: #8e8e93;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--ios-radius-sm);
}
.admin-sidebar .sidebar-footer a:hover { color: #fff; background: rgba(255,255,255,.06); }

.admin-main { margin-left: var(--sidebar-width); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }
.admin-topbar {
    height: var(--topbar-height);
    background: rgba(255,255,255,.85);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--ios-gray5);
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1030;
}
.admin-topbar .topbar-title { font-weight: 700; font-size: 0.95rem; color: var(--ios-label); flex: 1; }
.admin-content { padding: 20px; flex: 1; }

.sidebar-toggle-btn { display: none; background: none; border: none; font-size: 1.2rem; color: var(--ios-label); margin-right: 10px; cursor: pointer; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); backdrop-filter: blur(2px); z-index: 1039; }
.sidebar-overlay.show { display: block; }

@media (max-width: 991.98px) {
    .admin-sidebar { transform: translateX(-100%); }
    .admin-sidebar.show { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .sidebar-toggle-btn { display: block; }
}

/* ===== Admin page header ===== */
.page-header-admin {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1.5px solid var(--ios-gray5);
}
.page-header-admin h3 { margin: 0; font-size: 1.2rem; font-weight: 700; color: var(--ios-label); }
.page-header-admin i { margin-right: 8px; color: var(--color-primary); }

/* ===== Mobile ===== */
@media (max-width: 575.98px) {
    .page-wrapper { padding-top: 12px; }
    .container { padding-left: 12px; padding-right: 12px; }
    .card-body { padding: 12px; }
    .alert { font-size: 0.85rem; padding: 10px 12px; }
    .alert h1.h5 { font-size: 0.9rem; }
    .btn { min-height: 40px; }
    .btn-lg { min-height: 46px; font-size: 0.95rem; }
    .navbar-brand { font-size: 0.95rem; }
    .form-check-inline label img { width: 34px; }
    .countdown ul li span { font-size: 18px; }
    .table { font-size: 0.8rem; }
    .table th, .table td { padding: 7px 8px; }
    #ios-toast-container { width: calc(100vw - 32px); }
}
@media (max-width: 767.98px) {
    .input-group > .btn { white-space: nowrap; }
    .page-header-admin { flex-wrap: wrap; gap: 8px; }
    .admin-topbar { padding: 0 12px; }
    .admin-content { padding: 14px 10px; }
    .modal-dialog { margin: 10px; }
}

/* ===== Additional Responsive ===== */

/* Prevent horizontal scroll globally */
body { overflow-x: hidden; }
h1, h2, h3, h4, h5, h6, p, li { word-break: break-word; }

/* Blog user-generated content */
.blog-content img    { max-width: 100% !important; height: auto !important; display: block; }
.blog-content table  { overflow-x: auto; display: block; max-width: 100%; }
.blog-content pre    { overflow-x: auto; white-space: pre-wrap; }
.blog-content iframe { max-width: 100% !important; }

/* Mobile (≤575px) */
@media (max-width: 575.98px) {
    /* Scale down bare H1 without a .h* size class (e.g. home hero) */
    h1 { font-size: 1.4rem; line-height: 1.35; }
    /* Lead paragraph */
    .lead { font-size: 0.95rem; }
    /* Accordion tighter on mobile */
    .accordion-button { font-size: 0.85rem; padding: 12px 14px; }
    .accordion-body   { font-size: 0.88rem; padding: 12px 14px; }
    /* Footer links wrap gracefully */
    footer .mt-2.mb-1 { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
    footer .border-end { border-right: none !important; }
    /* CTA gradient section padding compact */
    .card.text-center.p-4 { padding: 20px 14px !important; }
    /* Stats bar: smaller icon on mobile */
    .col-6 .fs-3 { font-size: 1.5rem !important; }
    /* Blog post back/forward buttons stack on very narrow */
    .d-flex.justify-content-between { flex-wrap: wrap; gap: 8px; }
}

/* Tablet portrait (576–767px) */
@media (min-width: 576px) and (max-width: 767.98px) {
    h1 { font-size: 1.75rem; line-height: 1.3; }
    .lead { font-size: 1rem; }
}

/* Tablet landscape (768–991px) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .blog-content img { max-width: 100%; }
}


