:root {
    --blue-50: #f3fbff;
    --blue-100: #e4f6ff;
    --blue-200: #beeaff;
    --blue-500: #30a7df;
    --blue-700: #1274a8;
    --ink: #153243;
    --muted: #668092;
    --gold: #d9ad45;
    --green: #16885e;
    --red: #c94b55;
    --line: #d8edf7;
    --shadow: 0 20px 45px rgba(29, 115, 157, .13);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif; color: var(--ink); background: linear-gradient(180deg, var(--blue-50), #fff); min-height: 100vh; }
a { color: inherit; }
button, input, textarea, select { font: inherit; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: .78rem .9rem; background: #fff; color: var(--ink); }
textarea { resize: vertical; }
label { display: grid; gap: .35rem; font-weight: 700; color: #25485d; }
small, .field-hint { color: var(--muted); font-weight: 700; font-size: .78rem; }
h1, h2, h3, p { margin-top: 0; }
.select2-container { width: 100% !important; }
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple { min-height: 48px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 48px; padding-left: .9rem; color: var(--ink); }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 48px; right: .5rem; }
.select2-container--default .select2-selection--multiple { padding: .25rem .35rem; }
.select2-container--default .select2-selection--multiple .select2-selection__choice { border: 0; border-radius: 999px; background: var(--blue-100); color: var(--blue-700); font-weight: 800; padding: .24rem .45rem; }
select[data-select-widget="chapters"] + .select2-container--default .select2-selection--multiple .select2-selection__choice { position: relative; min-width: 48px; padding: .38rem 1.65rem .38rem .72rem; text-align: center; }
select[data-select-widget="chapters"] + .select2-container--default .select2-selection--multiple .select2-selection__choice__remove { position: absolute; top: .18rem; right: .22rem; left: auto; width: 18px; height: 18px; border: 0; border-radius: 50%; display: grid; place-items: center; padding: 0; background: rgba(18, 116, 168, .14); color: var(--blue-700); font-size: 14px; line-height: 1; }
select[data-select-widget="chapters"] + .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover,
select[data-select-widget="chapters"] + .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:focus { background: var(--blue-500); color: #fff; }
.select2-dropdown { border-color: var(--line); border-radius: 10px; overflow: hidden; }
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable { background: var(--blue-500); }

.site-header { max-width: 1120px; margin: 0 auto; padding: 1.2rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .8rem; text-decoration: none; }
.brand-mark { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; color: white; font-weight: 900; background: linear-gradient(135deg, #59c7f5, #168bc4); box-shadow: var(--shadow); }
.brand-logo { width: 48px; height: 48px; object-fit: contain; flex: 0 0 48px; filter: drop-shadow(0 8px 14px rgba(18, 116, 168, .12)); }
.brand small { display: block; color: var(--muted); font-size: .78rem; font-weight: 600; }
.link-pill, .btn { border: 0; border-radius: 999px; padding: .72rem 1.05rem; background: #fff; color: var(--blue-700); text-decoration: none; font-weight: 800; cursor: pointer; box-shadow: 0 8px 18px rgba(18, 116, 168, .08); display: inline-flex; align-items: center; justify-content: center; gap: .45rem; }
.btn-primary { background: linear-gradient(135deg, #34b5ea, #168bc4); color: #fff; }
.btn-light { background: rgba(255,255,255,.78); }
.btn-danger { background: var(--red); color: #fff; }
.btn-small { padding: .48rem .7rem; font-size: .85rem; }
.site-main { max-width: 1120px; margin: 0 auto; padding: 0 1.2rem 3rem; }

.hero { min-height: 260px; display: flex; align-items: center; border-radius: 28px; padding: 2.2rem; background: linear-gradient(135deg, rgba(230, 247, 255, .92), rgba(255,255,255,.96)), url("data:image/svg+xml,%3Csvg width='120' height='120' viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 75c24-42 55-42 80 0' fill='none' stroke='%2395daf7' stroke-width='8' stroke-linecap='round'/%3E%3Ccircle cx='60' cy='44' r='18' fill='%23d9ad45' fill-opacity='.35'/%3E%3C/svg%3E"); background-size: auto, 220px; background-position: center, right 30px center; background-repeat: no-repeat; box-shadow: var(--shadow); margin-bottom: 1.4rem; }
.hero h1, .quiz-intro h1 { font-size: clamp(2.1rem, 7vw, 4.6rem); line-height: .98; margin-bottom: .8rem; color: #11364a; letter-spacing: 0; }
.hero p, .quiz-intro p { max-width: 620px; color: var(--muted); font-size: 1.08rem; }
.eyebrow, .tile-meta { color: var(--blue-700); font-weight: 900; letter-spacing: 0; text-transform: uppercase; font-size: .78rem; }

.quiz-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.quiz-list-shell { display: grid; gap: 1rem; }
.quiz-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .75rem; align-items: end; }
.quiz-list-summary { color: var(--muted); font-weight: 850; }
.quiz-list-actions { display: flex; justify-content: center; }
.quiz-list-empty[hidden], [hidden] { display: none !important; }
.mode-filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .85rem; }
.mode-filter-tile { border: 2px solid var(--line); border-radius: 16px; padding: 1rem; background: #fff; text-decoration: none; display: grid; gap: .3rem; color: var(--ink); transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease; }
.mode-filter-tile:hover, .mode-filter-tile.active { transform: translateY(-2px); border-color: var(--blue-500); box-shadow: 0 18px 34px rgba(18, 116, 168, .14); }
.mode-filter-tile.active { background: linear-gradient(135deg, #eef9ff, #fff); }
.mode-filter-tile strong { color: #11364a; }
.mode-filter-tile span { color: var(--muted); font-weight: 800; font-size: .88rem; }
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; }
.book-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.quiz-tile, .catalog-tile, .chapter-tile, .empty-card, .play-card, .panel, .table-card, .login-card { background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.quiz-tile { padding: 1.3rem; display: grid; gap: .8rem; }
.quiz-tile h2, .quiz-tile h3 { margin-bottom: 0; }
.quiz-tile p { color: var(--muted); }
.catalog-block { padding: 1.1rem; border: 1px solid var(--line); border-radius: 22px; background: rgba(255,255,255,.72); box-shadow: 0 14px 32px rgba(29, 115, 157, .08); margin-bottom: 1.2rem; }
.catalog-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; padding-bottom: .85rem; border-bottom: 1px solid var(--line); }
.catalog-head h2 { margin-bottom: 0; color: #11364a; font-size: 1.55rem; }
.catalog-head span { flex: 0 0 auto; border-radius: 999px; padding: .42rem .7rem; background: var(--blue-100); color: var(--blue-700); font-weight: 900; font-size: .86rem; }
.catalog-section { display: grid; gap: .15rem; }
.catalog-tile { position: relative; overflow: hidden; aspect-ratio: 1 / .78; padding: 1.05rem; display: grid; gap: .85rem; align-content: space-between; text-decoration: none; border-width: 2px; transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease; }
.book-grid .catalog-tile { min-height: 280px; }
.catalog-tile::after { content: ""; position: absolute; inset: auto -18px -24px auto; width: 116px; height: 116px; border-radius: 28px; transform: rotate(12deg); background: rgba(48, 167, 223, .12); }
.book-tile { background: linear-gradient(135deg, #ffffff, #eef9ff); }
.theme-tile { background: linear-gradient(135deg, #ffffff, #fff8e7); border-color: #f0d894; }
.theme-tile::after { background: rgba(217, 173, 69, .18); }
.catalog-tile:hover, .chapter-tile:hover { transform: translateY(-3px); border-color: var(--blue-500); box-shadow: 0 24px 50px rgba(18, 116, 168, .18); }
.catalog-tile h2, .catalog-tile h3 { margin-bottom: 0; color: #11364a; font-size: 1.45rem; line-height: 1.08; }
.catalog-icon { position: relative; z-index: 1; width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; color: #fff; font-size: 1.55rem; font-weight: 950; background: linear-gradient(135deg, #34b5ea, #168bc4); box-shadow: 0 14px 24px rgba(18, 116, 168, .16); }
.theme-tile .catalog-icon { background: linear-gradient(135deg, #e4bc55, #c7931d); box-shadow: 0 14px 24px rgba(151, 105, 19, .16); }
.catalog-stats { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
.catalog-stats span { border-radius: 10px; padding: .45rem .5rem; background: rgba(255,255,255,.76); color: var(--blue-700); font-weight: 850; font-size: .8rem; text-align: center; border: 1px solid rgba(216, 237, 247, .8); }
.chapter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: .75rem; }
.chapter-tile { aspect-ratio: 1 / .86; padding: .85rem; display: grid; align-content: center; justify-items: center; gap: .25rem; text-align: center; text-decoration: none; color: var(--blue-700); border-width: 2px; background: linear-gradient(135deg, #fff, #eef9ff); transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease; }
.chapter-tile strong { font-size: 2.45rem; line-height: 1; color: #11364a; }
.chapter-tile span, .chapter-tile small { color: var(--muted); font-weight: 850; font-size: .82rem; }
.tag-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.tag-row span, .status, .mode-badge { border-radius: 999px; padding: .35rem .65rem; background: var(--blue-100); color: var(--blue-700); font-weight: 800; font-size: .82rem; }
.mode-badge { display: inline-flex; background: #fff8e7; color: #8a6811; border: 1px solid #f0d894; }
.status.draft { background: #fff5d8; color: #8a6811; }
.status.published { background: #dff8ee; color: #116b4b; }
.status.unpublished { background: #eceff3; color: #52606d; }
.empty-card { padding: 1.4rem; color: var(--muted); }

.quiz-shell { display: grid; gap: 1.1rem; }
.quiz-intro { padding: 1.3rem 0; }
.back-link { color: var(--blue-700); font-weight: 800; text-decoration: none; }
.mode-tabs { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }
.mode-tab { border: 1px solid var(--line); border-radius: 999px; background: #fff; padding: .65rem .95rem; color: var(--blue-700); font-weight: 850; cursor: pointer; }
.mode-tab.active { background: var(--blue-500); color: #fff; border-color: var(--blue-500); }
.play-card { padding: 1.4rem; }
.progress-scale { height: 12px; background: var(--blue-100); border-radius: 999px; overflow: hidden; margin-bottom: 1rem; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--blue-500), var(--gold)); transition: width .2s; }
.quiz-topline { display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-weight: 800; margin-bottom: 1rem; }
.timer-pill { margin-left: auto; border-radius: 999px; padding: .25rem .6rem; background: #e1f8ef; color: var(--green); white-space: nowrap; }
.timer-pill.is-warning { background: #ffe6e8; color: var(--red); }
.timer-pill.practice { background: var(--blue-100); color: var(--blue-700); }
.captain-tools { display: flex; gap: .55rem; flex-wrap: wrap; margin-bottom: .9rem; padding: .75rem; border: 1px solid #f0d894; border-radius: 14px; background: #fff8e7; }
.captain-prize { display: inline-flex; width: fit-content; margin-bottom: 1rem; border-radius: 999px; padding: .35rem .65rem; background: #fff8e7; color: #8a6811; border: 1px solid #f0d894; font-weight: 900; }
.captain-hint { margin-bottom: 1rem; padding: .85rem 1rem; border-radius: 14px; background: #eef9ff; border: 1px solid var(--line); color: #25485d; font-weight: 800; }
.question-text { font-size: clamp(1.25rem, 4vw, 2rem); line-height: 1.25; border-left: 5px solid var(--gold); padding-left: 1rem; margin-bottom: .55rem; }
.verse-ref { color: var(--blue-700); font-weight: 800; margin-bottom: 1rem; }
.options-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .8rem; }
.option-btn { border: 2px solid var(--line); border-radius: 16px; background: #fff; padding: .9rem; text-align: left; cursor: pointer; display: flex; align-items: center; gap: .7rem; min-height: 64px; }
.option-letter { width: 34px; height: 34px; border-radius: 50%; background: var(--blue-100); color: var(--blue-700); font-weight: 900; flex: 0 0 auto; display: grid; place-items: center; }
.option-btn.option-hidden { display: none; }
.option-btn.selected { background: var(--blue-50); border-color: var(--blue-500); }
.option-btn.correct { background: #e1f8ef; border-color: var(--green); }
.option-btn.wrong { background: #ffe6e8; border-color: var(--red); }
.option-btn:disabled { cursor: default; }
.explanation { margin-top: 1rem; padding: 1rem; border-radius: 14px; background: #fff8e7; color: #725511; }
.explanation.timeout { background: #ffe6e8; color: #8a1f2a; }
.nav-area { display: flex; justify-content: space-between; gap: .8rem; margin-top: 1rem; flex-wrap: wrap; }
.result-box { text-align: center; padding: 2rem 1rem; background: var(--blue-50); border-radius: 18px; }
.result-score { font-size: 3rem; color: var(--blue-700); font-weight: 950; }
.recommendation-box { margin: 1.2rem auto; max-width: 760px; text-align: left; }
.recommendation-box h2 { font-size: 1.15rem; margin-bottom: .65rem; }
.recommendation-list { display: grid; gap: .55rem; }
.recommendation-list a { padding: .75rem .85rem; border: 1px solid var(--line); border-radius: 14px; background: #fff; text-decoration: none; display: grid; gap: .2rem; }
.recommendation-list span { color: var(--muted); font-weight: 800; font-size: .84rem; }
.review-summary { margin: 1.2rem auto; max-width: 820px; display: grid; gap: .7rem; text-align: left; }
.review-item { border: 1px solid var(--line); border-radius: 14px; padding: .85rem; background: #fff; display: grid; gap: .4rem; }
.review-item.correct { border-color: rgba(22, 136, 94, .35); background: #f1fbf6; }
.review-item.wrong { border-color: rgba(201, 75, 85, .35); background: #fff6f7; }
.review-item-head { display: flex; justify-content: space-between; gap: .75rem; color: var(--blue-700); font-weight: 900; }
.review-item p, .review-item small { margin: 0; }
.review-item small { color: var(--muted); font-weight: 800; }

.admin-body { background: #f6fbff; }
.admin-frame { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.admin-sidebar { padding: 1rem; background: linear-gradient(180deg, #dff4ff, #fff); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 1.2rem; }
.admin-nav { display: grid; gap: .5rem; }
.admin-nav a { padding: .75rem .85rem; border-radius: 12px; text-decoration: none; color: #26546e; font-weight: 850; }
.admin-nav a:hover, .admin-nav a.active { background: #fff; color: var(--blue-700); box-shadow: 0 8px 18px rgba(18, 116, 168, .08); }
.admin-nav a.active { border: 1px solid var(--line); }
.admin-main { padding: 1.4rem; min-width: 0; }
.page-head, .section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.panel, .table-card, .login-card { padding: 1.2rem; margin-bottom: 1rem; }
.login-card { max-width: 430px; margin: 8vh auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.form-stack, .question-form { display: grid; gap: .85rem; }
.wide { grid-column: 1 / -1; }
.admin-table { width: 100%; border-collapse: collapse; min-width: 880px; }
.admin-table th, .admin-table td { text-align: left; padding: .85rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table tbody tr.status-row-published { background: #edf9f3; }
.admin-table tbody tr.status-row-draft { background: #f5f7f9; }
.admin-table tbody tr.status-row-unpublished { background: #fff7e1; }
.admin-table tbody tr.status-row-published:hover { background: #e3f6ec; }
.admin-table tbody tr.status-row-draft:hover { background: #eef2f5; }
.admin-table tbody tr.status-row-unpublished:hover { background: #fff1c7; }
.table-card { overflow-x: auto; }
.actions { display: flex; gap: .45rem; flex-wrap: wrap; }
.alert, .notice { padding: .85rem 1rem; border-radius: 12px; margin-bottom: .8rem; font-weight: 800; }
.alert { background: #ffe6e8; color: #8a1f2a; }
.notice { background: #dff8ee; color: #116b4b; }
.options-admin { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
.answer-option { display: grid; grid-template-columns: auto auto auto minmax(0, 1fr); align-items: center; gap: .6rem; padding: .65rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.answer-option input[type="radio"], .online-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--green); }
.check-mark { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-100); color: transparent; font-weight: 950; }
.answer-option.is-correct { background: #e1f8ef; border-color: var(--green); }
.answer-option.is-correct .check-mark, .online-row:has(input:checked) .check-mark { background: var(--green); color: #fff; }
.import-format { padding: .85rem; border-radius: 12px; background: var(--blue-50); border: 1px solid var(--line); color: #25485d; }
.metadata-box { padding: 1rem; border-radius: 14px; border: 1px solid var(--line); background: var(--blue-50); margin-top: 1rem; }
.metadata-box h2 { font-size: 1.1rem; margin-bottom: .35rem; }
.question-list { display: grid; gap: .75rem; margin-top: 1rem; }
.question-admin-card { border: 1px solid var(--line); background: #fbfdff; border-radius: 14px; padding: .9rem; }
.question-admin-card summary { cursor: pointer; }
.question-admin-card span, .preview-item small { color: var(--muted); display: block; margin-top: .25rem; }
.compact { margin-top: .8rem; }
.preview-list { display: grid; gap: .45rem; margin: 1rem 0; }
.preview-item { padding: .75rem; border-radius: 12px; background: var(--blue-50); }
.admin-online-grid .quiz-tile { min-height: 250px; }
.bulk-import-check { display: inline-flex; grid-template-columns: none; align-items: center; gap: .45rem; font-size: .88rem; font-weight: 850; color: var(--blue-700); }
.bulk-import-check input { width: 18px; height: 18px; accent-color: var(--blue-500); }

.modal { position: fixed; inset: 0; background: rgba(16, 50, 70, .38); display: none; align-items: center; justify-content: center; padding: 1rem; z-index: 20; }
.modal.open { display: flex; }
.modal-dialog { width: min(820px, 100%); max-height: 90vh; overflow: auto; background: #fff; border-radius: 20px; padding: 1.2rem; position: relative; box-shadow: 0 30px 80px rgba(0,0,0,.22); display: grid; gap: .8rem; }
.modal-close { position: absolute; right: .8rem; top: .7rem; border: 0; background: var(--blue-100); color: var(--blue-700); border-radius: 50%; width: 34px; height: 34px; font-size: 1.35rem; cursor: pointer; }
.confirm-dialog { width: min(460px, 100%); }
.confirm-dialog h2 { margin-bottom: 0; color: #11364a; }
.confirm-dialog p { color: var(--muted); }
.confirm-actions { display: flex; justify-content: flex-end; gap: .65rem; flex-wrap: wrap; }
.modal-question-list { display: grid; gap: .55rem; }
.modal-question { border: 1px solid var(--line); border-radius: 12px; padding: .7rem; display: flex; gap: .65rem; align-items: flex-start; }
.online-row { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: start; gap: .65rem; cursor: pointer; }
.online-row .check-mark { display: grid; color: transparent; margin-top: 0; }
.online-row:has(input:checked) { background: #e1f8ef; border-color: var(--green); }

@media (max-width: 760px) {
    .site-header { align-items: flex-start; }
    .hero { padding: 1.4rem; min-height: 220px; background-position: center, right -40px bottom -20px; }
    .admin-frame { grid-template-columns: 1fr; }
    .admin-sidebar { position: static; border-right: 0; border-bottom: 1px solid var(--line); }
    .quiz-search { grid-template-columns: 1fr; }
    .form-grid, .options-admin { grid-template-columns: 1fr; }
    .play-card { padding: 1rem; }
    .quiz-topline { display: grid; }
}
