:root {
    --primary: #e30611;
    --blue: #327afd;
    --blue-dark: #1a5fd4;
    --green: #13ce66;
    --green-bg: #e6f4ea;
    --green-text: #137333;
    --bg: #f4f6fb;
    --card: #ffffff;
    --text: #1c1e21;
    --text-muted: #65676b;
    --border: #e8ecf2;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --highlight: #fff3cd;
    --highlight-text: #856404;
    --header-h: auto;
    --safe-top: env(safe-area-inset-top, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    padding-top: var(--safe-top);
}

/* ── Header ── */
.view-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.view-header__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px 10px;
    max-width: 800px;
    margin: 0 auto;
}

.view-header__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.3;
    flex: 1;
    min-width: 0;
}

.view-timer {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    background: #ffebee;
    padding: 6px 10px;
    border-radius: 8px;
    white-space: nowrap;
    transition: background 0.3s, color 0.3s;
}

.view-timer--warn {
    background: #fff3e0;
    color: #e65100;
    animation: pulse 1.5s infinite;
}

.view-timer--critical {
    background: var(--primary);
    color: #fff;
    animation: pulse 0.8s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.75; }
}

/* ── Search ── */
.search-panel {
    padding: 0 16px 12px;
    max-width: 800px;
    margin: 0 auto;
}

.search-panel__row {
    position: relative;
    display: flex;
    align-items: center;
}

.search-panel__icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
}

.search-panel__input {
    width: 100%;
    padding: 14px 44px 14px 44px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    outline: none;
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
}

.search-panel__input:focus {
    border-color: var(--blue);
    background: var(--card);
    box-shadow: 0 0 0 3px rgba(50, 122, 253, 0.15);
}

.search-panel__input::placeholder { color: #999; }

.search-panel__clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    background: var(--border);
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    transition: background 0.2s;
}

.search-panel__clear.visible { display: flex; }
.search-panel__clear:hover { background: #d0d5dd; }

.search-panel__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    min-height: 22px;
}

.search-panel__count {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.search-panel__count strong {
    color: var(--blue);
    font-weight: 700;
}

.search-panel__hint {
    font-size: 12px;
    color: var(--text-muted);
    display: none;
}

.search-panel__hint.visible { display: block; }

/* ── Content ── */
.view-container {
    padding: 12px 16px 24px;
    max-width: 800px;
    margin: 0 auto;
}

.view-stats {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.view-stat {
    font-size: 12px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 20px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.view-stat--total strong { color: var(--text); }

/* ── Question cards ── */
.question-block {
    background: var(--card);
    border-radius: 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: opacity 0.2s, transform 0.2s;
}

.question-block.hidden { display: none; }

.question-block.highlight-match {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(50, 122, 253, 0.2), var(--shadow);
}

.question-block__head {
    display: flex;
    gap: 12px;
    padding: 16px 16px 0;
    align-items: flex-start;
}

.question-block__num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    background: var(--blue);
    color: #fff;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.question-block__question {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.45;
    color: var(--text);
    padding-bottom: 12px;
    flex: 1;
}

.question-block__body {
    padding: 0 16px 16px;
}

.content-img {
    max-width: 100%;
    border-radius: 10px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.question-block__answer {
    background: var(--green-bg);
    color: var(--green-text);
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.question-block__answer-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    background: var(--green);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    margin-top: 1px;
}

.question-block__answer-text { flex: 1; }

/* Search highlight */
mark.search-hit {
    background: var(--highlight);
    color: var(--highlight-text);
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 700;
}

/* ── Empty / loading ── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state__icon { font-size: 40px; margin-bottom: 12px; }
.empty-state__title { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.empty-state__text { font-size: 15px; line-height: 1.5; }

.no-results {
    display: none;
    text-align: center;
    padding: 40px 20px;
    background: var(--card);
    border-radius: 14px;
    border: 1px dashed var(--border);
    margin-top: 8px;
}

.no-results.visible { display: block; }

.no-results__icon { font-size: 36px; margin-bottom: 10px; }
.no-results__title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.no-results__text { font-size: 14px; color: var(--text-muted); line-height: 1.5; }

/* ── Video ── */
.video-wrapper {
    background: #000;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    margin-top: 8px;
}

.video-wrapper video { width: 100%; display: block; }

.video-note {
    margin-top: 14px;
    padding: 14px;
    background: var(--card);
    border-radius: 12px;
    border: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ── Copy protection ── */
.noselect {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

@media (min-width: 768px) {
    .view-header__title { font-size: 18px; }
    .question-block__question { font-size: 16px; }
    .question-block__answer { font-size: 15px; }
}