:root {
    --bg: #0b0e12;
    --panel: #0f141a;
    --text: #e6edf3;
    --muted: #8b949e;
    --accent: #5863ff;
    --nick: #6a71df;
    --verse: #c9d1d9;
    --link: #6a71df;
    --line: #1f252b;
    --radius: 14px;
    --highlight: rgba(88, 99, 255, 0.15);
    --bookmark: #ffd700;
}

* {
    box-sizing: border-box;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-thumb {
    border-radius: 1rem;
    background: var(--link);
}

html,
body {
    min-height: 10vh;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

.wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px;
    width: 100%;
}

header {
    text-align: center;
    width: 100%;
    max-width: 800px;
}

header h1 {
    margin: 0;
    font-size: clamp(18px, 4vw, 22px);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

header p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: clamp(12px, 2.5vw, 13px);
}

.card {
    width: 100%;
    max-width: 1000px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: calc(88vh - 120px);
    scroll-behavior: smooth;
}

.controls {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
    align-items: center;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    background: var(--panel);
    z-index: 5;
}

.bottom-nav {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--line);
    background: var(--panel);
    justify-content: center;
    flex-wrap: wrap;
}

.select-wrap {
    position: relative;
    flex: 1;
    min-width: 150px;
}

.select-wrap select {
    width: 100%;
    background: #0b1015;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px 10px 2.2em;
    font-size: 15px;
    min-height: 42px;
    appearance: none;
    cursor: pointer;
}

.select-wrap i {
    position: absolute;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 14px;
    pointer-events: none;
}

.nav-buttons {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

button {
    flex: 1;
    cursor: pointer;
    background: #0b1015;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 15px;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s;
    min-width: 60px;
}

button:hover:not(:disabled) {
    background: #161c23;
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

button i {
    font-size: 14px;
    color: var(--accent);
}

.log {
    flex: 1 1 auto;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 0;
}

.line {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.04);
    word-break: break-word;
    transition: background-color 0.2s;
    position: relative;
}

.line:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.line.highlighted {
    background-color: var(--highlight);
}

.line > div:first-child {
    display: inline-flex;
    align-items: flex-start;
    gap: 6px;
}

.prefix {
    color: var(--muted);
    white-space: nowrap;
    font-size: 0.9em;
}

.nick {
    color: var(--nick);
    margin-left: 6px;
}

.msg {
    color: var(--verse);
    line-height: 1.7;
}

.footer {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    padding: 10px;
}

.link {
    color: var(--link);
    text-decoration: none;
    font-weight: 600;
}

.copy-btn {
    cursor: pointer;
    color: var(--muted);
    font-size: 14px;
    margin-left: 8px;
    transition: color 0.2s, transform 0.2s;
    padding: 4px;
}

.copy-btn:hover {
    color: var(--accent);
}

.copy-btn.fa-check {
    color: var(--accent);
    transform: scale(1.2);
}

.bookmark-btn {
    cursor: pointer;
    color: var(--muted);
    font-size: 14px;
    margin-left: 4px;
    transition: color 0.2s;
    padding: 4px;
}

.bookmark-btn:hover,
.bookmark-btn.active {
    color: var(--bookmark);
}

.verse-actions {
    display: flex;
    gap: 1px;
    margin-left: 8px;
}

.copy-btn,
.highlight-btn {
    cursor: pointer;
    color: var(--muted);
    font-size: 14px;
    padding: 4px;
    margin-left: 0;
    transition: color 0.2s, transform 0.2s;
}

.progress-bar {
    height: 6px;
    width: 100%;
    background: var(--line);
    position: relative;
    overflow: hidden;
}

.progress-bar-inner {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s ease;
    width: 0%;
}

.quick-nav {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
    flex-wrap: wrap;
}

.quick-nav-btn {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 8px;
    background: #0b1015;
    border: 1px solid var(--line);
    color: var(--text);
    cursor: pointer;
    transition: background 0.2s;
    min-width: 60px;
}

.quick-nav-btn:hover {
    background: #161c23;
}

.chapter-title {
    text-align: center;
    padding: 12px;
    font-size: 1.1em;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 65px;
    z-index: 4;
}

.search-container {
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    display: none;
}

.search-container.active {
    display: block;
}

.search-input {
    width: 100%;
    background: #0b1015;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px 10px 2.5em;
    font-size: 15px;
}

.search-results {
    margin-top: 8px;
    font-size: 14px;
    color: var(--muted);
}

.search-match {
    background-color: var(--highlight);
    padding: 0 2px;
    border-radius: 3px;
}

@media (min-width: 768px) {
    .controls {
        flex-wrap: nowrap;
    }

    .nav-buttons {
        flex: 0 0 auto;
    }

    button {
        flex: 0 0 auto;
        min-width: 110px;
    }

    .quick-nav-btn {
        min-width: 80px;
    }
}

@media (max-width: 640px) {
    .wrap {
        padding: 10px;
    }

    .card {
        max-height: calc(100vh - 100px);
    }

    .controls {
        padding: 8px;
    }

    .select-wrap {
        flex: 1 1 100%;
    }

    .nav-buttons {
        margin-top: 8px;
        flex: 1 1 100%;
    }

    .line {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    .prefix {
        display: block;
        margin-bottom: 6px;
    }

    .nick {
        margin-left: 0;
    }

    .verse-actions {
        position: absolute;
        top: 8px;
        right: 8px;
    }

    button {
        padding: 10px;
        font-size: 14px;
    }

    .quick-nav-btn {
        padding: 8px 10px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .wrap {
        padding: 8px;
        gap: 12px;
    }

    header h1 {
        flex-direction: column;
        gap: 5px;
    }

    .controls,
    .bottom-nav {
        gap: 6px;
    }

    button {
        min-height: 38px;
        font-size: 13px;
    }

    .select-wrap select {
        min-height: 38px;
        font-size: 14px;
    }

    .line {
        padding: 10px;
    }

    .msg {
        font-size: 14px;
    }
}

@media (max-width: 360px) {
    .nav-buttons {
        flex-wrap: wrap;
    }

    button {
        flex: 1 0 calc(50% - 4px);
        min-width: auto;
    }

    .quick-nav {
        gap: 4px;
    }

    .quick-nav-btn {
        flex: 1 0 calc(33.33% - 4px);
        min-width: auto;
        padding: 6px 4px;
        font-size: 11px;
    }
    .nav-buttons {
        order: 1;
        width: 100%;
        display: flex;
    }

    #prevBtn {
        order: 1;
    }

    #nextBtn {
        order: 2;
    }

    #todayBtn {
        order: 3;
    }
}

@media (hover: none) {
    button:hover:not(:disabled) {
        background: #0b1015;
    }

    .copy-btn:hover,
    .bookmark-btn:hover {
        color: var(--muted);
    }

    button:active:not(:disabled) {
        background: #161c23;
    }

    .copy-btn:active,
    .bookmark-btn:active {
        color: var(--accent);
    }
}
