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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #27456a;
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    padding: 30px 0;
    color: white;
}

.header-logo {
    display: block;
    margin: 0 auto 18px;
    width: min(360px, 80%);
    background: white;
    border-radius: 14px;
    padding: 14px 20px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.2);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.sermon-header {
    text-align: center;
    margin-bottom: 20px;
}

.sermon-selector {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.sermon-selector label {
    font-weight: 500;
    color: #666;
}

.sermon-selector select {
    padding: 8px 12px;
    font-size: 1rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    min-width: 250px;
    cursor: pointer;
}

.sermon-selector select:focus {
    outline: none;
    border-color: #27456a;
}

.sermon-header h2 {
    border-bottom: none;
    margin-bottom: 5px;
}

.video-link {
    display: inline-block;
    margin-top: 12px;
    padding: 10px 20px;
    background: #f19226;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: background 0.3s;
}

.video-link:hover {
    background: #d9821f;
}

.outline-card {
    margin-bottom: 20px;
}

.outline-content {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    line-height: 1.8;
    min-height: 400px;
    max-height: 70vh;
    overflow-y: auto;
    font-size: 1.05rem;
}

.outline-content h1, .outline-content h2, .outline-content h3,
.section-content h1, .section-content h2, .section-content h3 {
    margin-top: 0.5em;
    margin-bottom: 0.3em;
    color: #333;
}

.outline-content h1, .section-content h1 { font-size: 1.4em; }
.outline-content h2, .section-content h2 { font-size: 1.2em; }
.outline-content h3, .section-content h3 { font-size: 1.1em; }

.outline-content ul, .outline-content ol,
.section-content ul, .section-content ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.outline-content li, .section-content li {
    margin-bottom: 0.3em;
}

.outline-content p, .section-content p {
    margin-bottom: 0.5em;
}

.outline-content strong, .section-content strong {
    font-weight: 700;
}

.sidebar-card .section:last-child {
    margin-bottom: 0;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .outline-content {
        min-height: 300px;
        max-height: 50vh;
    }
}

/* PWA: offline banner + install hint */
.offline-banner {
    background: #f19226;
    color: #fff;
    text-align: center;
    padding: 10px 16px;
    font-weight: 600;
    font-size: 0.95rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.install-hint {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: 480px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    z-index: 1001;
}

.install-hint-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.9rem;
    color: #333;
}

.install-hint-text strong {
    color: #27456a;
}

.install-hint-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.install-dismiss {
    border: none;
    background: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 4px 8px;
}

.notify-hint {
    bottom: 80px; /* sit above the install-hint when both are visible */
}

.btn-subscribed {
    background: #2e7d32 !important;
    border-color: #2e7d32 !important;
}

/* View tabs (Sermon / Bible) */
.view-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.view-tab {
    padding: 12px 40px;
    border: 2px solid rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.12);
    color: white;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1.05rem;
    transition: all 0.3s;
}

.view-tab.active {
    background: #f19226;
    border-color: #f19226;
}

.view-tab:hover {
    opacity: 0.92;
}

/* Bible tab */
.bible-card h2 {
    color: #27456a;
    margin-bottom: 15px;
}

.testament-heading {
    color: #f19226;
    margin: 18px 0 10px;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
}

.book-btn {
    padding: 10px 8px;
    border: 1px solid #e0e0e0;
    background: #f8f9fa;
    color: #27456a;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s;
    text-align: center;
}

.book-btn:hover {
    background: #27456a;
    color: white;
}

.chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
    gap: 8px;
}

.chapter-btn {
    padding: 12px 0;
    border: 1px solid #e0e0e0;
    background: #f8f9fa;
    color: #27456a;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.2s;
}

.chapter-btn:hover {
    background: #27456a;
    color: white;
}

.bible-back {
    border: none;
    background: none;
    color: #f19226;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    padding: 6px 0;
    margin-bottom: 10px;
}

.bible-back:hover {
    text-decoration: underline;
}

.reader-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.reader-pager {
    display: flex;
    gap: 8px;
}

.pager-btn {
    padding: 8px 16px;
    border: 1px solid #e0e0e0;
    background: #f8f9fa;
    color: #27456a;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.pager-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pager-btn:not(:disabled):hover {
    background: #27456a;
    color: white;
}

.bible-text {
    line-height: 1.9;
    font-size: 1.08rem;
    margin-top: 10px;
}

.bible-text p {
    margin-bottom: 0.6em;
}

.bible-text .s {
    font-weight: 700;
    color: #27456a;
    margin-top: 1em;
}

.bible-text .v {
    font-size: 0.7em;
    font-weight: 700;
    color: #f19226;
    vertical-align: super;
    margin-right: 2px;
}

.verse-highlight {
    background: #fff3d6;
    box-shadow: 0 0 0 2px #fff3d6;
    border-radius: 2px;
}

.bible-copyright {
    margin-top: 25px;
    padding-top: 12px;
    border-top: 1px solid #eee;
    color: #888;
    font-size: 0.75rem;
    line-height: 1.4;
}

.bible-unavailable {
    color: #721c24;
    background: #f8d7da;
    padding: 12px;
    border-radius: 8px;
}

.verse-link {
    color: #f19226;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-style: dotted;
    cursor: pointer;
}

.verse-link:hover {
    color: #d9821f;
}

.message.user .verse-link {
    color: #ffd9a8;
}

/* Export panel */
.export-card {
    margin-bottom: 20px;
    padding: 15px 25px;
}

.export-summary {
    cursor: pointer;
    font-weight: 600;
    color: #27456a;
    font-size: 1.05rem;
    padding: 5px 0;
}

.export-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    margin: 15px 0;
}

.export-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
}

.export-options input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #27456a;
    flex-shrink: 0;
}

.export-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.export-hint {
    margin-top: 10px;
    color: #666;
    font-size: 0.85rem;
}

.card {
    background: white;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

.card h2 {
    color: #27456a;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.sermon-info {
    margin-bottom: 20px;
}

.sermon-title {
    font-size: 1.5rem;
    color: #333;
    margin-bottom: 5px;
}

.sermon-date {
    color: #666;
    font-size: 0.9rem;
}

.section {
    margin-bottom: 25px;
}

.section h3 {
    color: #27456a;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.section-content {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    line-height: 1.6;
    max-height: 250px;
    overflow-y: auto;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 500px;
}

.mode-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.mode-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid #27456a;
    background: white;
    color: #27456a;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.mode-btn.active {
    background: #27456a;
    color: white;
}

.mode-btn:hover {
    opacity: 0.9;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 15px;
}

.message {
    margin-bottom: 15px;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    line-height: 1.5;
}

.message.user {
    background: #27456a;
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.message.assistant {
    background: white;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.chat-input {
    display: flex;
    gap: 10px;
}

.chat-input input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

.chat-input input:focus {
    border-color: #27456a;
}

.chat-input button {
    padding: 12px 24px;
    background: #f19226;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.chat-input button:hover {
    background: #d9821f;
}

.chat-input button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.no-sermon {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.no-sermon h2 {
    color: #333;
    margin-bottom: 15px;
}

.loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #666;
    padding: 10px;
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #f19226;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Admin Styles */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.admin-header a {
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    background: rgba(255,255,255,0.2);
    border-radius: 8px;
    transition: background 0.3s;
}

.admin-header a:hover {
    background: rgba(255,255,255,0.3);
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-weight: 600;
    color: #555;
}

.form-group input,
.form-group textarea {
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
}

.form-group textarea {
    min-height: 200px;
    resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #27456a;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #f19226;
    color: white;
}

.btn-primary:hover {
    background: #d9821f;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.sermon-list {
    margin-top: 30px;
}

.sermon-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 10px;
}

.sermon-item.active {
    background: #e8f5e9;
    border: 2px solid #28a745;
}

.sermon-item-info h3 {
    margin-bottom: 5px;
}

.sermon-item-info p {
    color: #666;
    font-size: 0.9rem;
}

.sermon-item-actions {
    display: flex;
    gap: 10px;
}

.sermon-item-actions button {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.alert {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.admin-key-input {
    margin-bottom: 20px;
}

.sermon-thumbnail {
    width: 100%;
    max-width: 480px;
    border-radius: 10px;
    margin-bottom: 15px;
    display: block;
}

.outline-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.outline-tab {
    flex: 1;
    padding: 12px;
    border: 2px solid #27456a;
    background: white;
    color: #27456a;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s;
}

.outline-tab.active {
    background: #27456a;
    color: white;
    border-color: #27456a;
}

.outline-tab:hover {
    opacity: 0.9;
}

/* Mobile refinements */
@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    header {
        padding: 20px 0 15px;
    }

    header h1 {
        font-size: 1.7rem;
    }

    header p {
        font-size: 0.95rem;
    }

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

    .export-card {
        padding: 12px 16px;
    }

    .sermon-selector {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .sermon-selector select {
        min-width: 0;
        width: 100%;
        font-size: 16px; /* prevents iOS zoom-on-focus */
    }

    .sermon-title {
        font-size: 1.2rem;
    }

    .outline-tabs {
        gap: 6px;
    }

    .outline-tab {
        padding: 10px 6px;
        font-size: 0.9rem;
    }

    .outline-content {
        padding: 14px;
        font-size: 1rem;
        min-height: 0;
        max-height: 60vh;
    }

    .export-options {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .export-buttons .btn {
        flex: 1;
        min-width: 140px;
    }

    .mode-selector {
        gap: 6px;
    }

    .mode-btn {
        padding: 10px 4px;
        font-size: 0.9rem;
    }

    .chat-container {
        height: 420px;
    }

    .message {
        max-width: 92%;
    }

    .chat-input input {
        font-size: 16px; /* prevents iOS zoom-on-focus */
        padding: 10px 12px;
    }

    .chat-input button {
        padding: 10px 16px;
    }

    .video-link {
        display: block;
        text-align: center;
    }

    .section-content {
        max-height: 220px;
    }

    .view-tab {
        flex: 1;
        padding: 12px 8px;
    }

    .book-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .chapter-grid {
        grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
    }

    /* Admin */
    .admin-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .sermon-item {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .sermon-item-actions {
        flex-wrap: wrap;
    }

    .sermon-item-actions button {
        flex: 1;
    }
}
