:root {
    /* Elegant dark Bible-inspired palette (gold + deep navy/cream) */
    --bg: #0f172a;
    --bg-subtle: #1e2937;
    --card-bg: #1e2937;
    --text: #f1e7d9;
    --text-muted: #94a3b8;
    --accent: #c5a46e; /* warm gold */
    --accent-light: #d4b98a;
    --primary: #b45309;
    --primary-hover: #92400e;
    --success: #c5a46e;
    --success-hover: #a37c4f;
    --history-bg: #1e2937;
    --border: #475569;
    --border-strong: #64748b;
    --input-bg: #0f172a;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
    --rsvp-overlay: rgba(15, 23, 42, 0.97);
    --rsvp-panel: #1e2937;
    --rsvp-display-bg: #0f172a;
    --rsvp-word-color: #f5f0e6;
}

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

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: linear-gradient(165deg, var(--bg) 0%, #1e2937 50%, #0f172a 100%);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.app-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem;
}

.header {
    margin-bottom: 2rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.lang-switcher {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0.25rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow);
}

.lang-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.4rem;
    height: 2.25rem;
    padding: 0 0.45rem;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: #fff; /* white text/emoji for unselected on dark switcher bg */
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.lang-btn:hover:not(.active) {
    background: rgba(197, 164, 110, 0.18);
}

.lang-btn.active {
    background: var(--accent-light);
    color: #1e2937; /* dark text on light gold active bg for contrast */
}

.lang-switcher .lang-btn:first-child.active {
    /* left side (EN) selected: rounded outer left, completely flat (no radius) on inner right — "D" shape variant */
    border-radius: 999px 0 0 999px;
}

.lang-switcher .lang-btn:last-child.active {
    /* right side (PT) selected: completely flat (no radius) on inner left, rounded on outer right — "D" shape */
    border-radius: 0 999px 999px 0;
}

.lang-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.lang-flag {
    font-size: 1.2rem;
    line-height: 1;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    height: 2.4rem;
    width: auto;
    max-width: 4rem;
    object-fit: contain;
    vertical-align: middle;
    border-radius: 4px; /* subtle rounding if the logo has edges */
}

h1 {
    font-size: 2rem;
    color: var(--accent);
    font-weight: 700;
}

.tagline {
    font-size: 0.95rem;
    color: var(--text-muted);
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

h2, h3 {
    color: var(--accent);
    margin-bottom: 1.25rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--input-bg);
    color: var(--text);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(197, 164, 110, 0.2);
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 9999px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
    background: var(--accent-light);
    border-color: var(--accent);
}

.btn-large {
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    width: 100%;
}

.btn-start {
    background: var(--success);
    color: white;
    font-size: 1.25rem;
    padding: 1.1rem 3rem;
}

.btn-start:hover {
    background: var(--success-hover);
}

.hidden {
    display: none !important;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.preview-stats {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.preview-text {
    max-height: 280px;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    background: var(--bg-subtle);
    border-radius: 10px;
    font-size: 1.05rem;
    line-height: 1.7;
    border: 1px solid var(--border);
    color: var(--text);
}

.preview-text sup {
    color: var(--accent);
    font-weight: 700;
    margin-right: 0.15rem;
}

.preview-start-btn {
    margin-top: 1.25rem;
    width: 100%;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 2rem;
}

.setting {
    margin-bottom: 1rem;
}

.setting-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.setting-value {
    font-weight: 700;
    color: var(--accent);
}

.setting-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

.chunk-buttons {
    display: flex;
    gap: 0.5rem;
}

.chunk-btn {
    flex: 1;
    padding: 0.6rem;
    background: var(--bg-subtle);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.chunk-btn:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.chunk-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.history-card {
    background: var(--history-bg);
    border-color: var(--border);
}

.streak-display {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.history-list {
    max-height: 180px;
    overflow-y: auto;
    margin-bottom: 1rem;
    padding-right: 0.5rem;
}

.history-item {
    background: var(--card-bg);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border);
}

.history-item .date {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.btn-small {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
}

.ad-container {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--card-bg);
    border-radius: 16px;
    text-align: center;
    border: 2px dashed var(--border-strong);
    box-shadow: var(--shadow);
}

.ad-placeholder {
    max-width: 728px;
    margin: 0 auto;
    color: var(--text-muted);
}

.ad-slot-inner {
    background: var(--bg-subtle);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
}

/* RSVP modal — light green reading focus */
.rsvp-modal {
    position: fixed;
    inset: 0;
    background: var(--rsvp-overlay);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.rsvp-content {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 92vh;
    box-shadow: var(--shadow-lg);
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.rsvp-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--rsvp-panel);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 1rem;
}

.rsvp-reference {
    color: var(--text);
    font-weight: 600;
}

.rsvp-stats {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.current-verse {
    background: var(--accent);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-left: 0.75rem;
}

.rsvp-display {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--rsvp-display-bg);
    position: relative;
}

.rsvp-word {
    font-family: Georgia, "EB Garamond", serif;
    font-size: 3.5rem;
    line-height: 1.3;
    text-align: center;
    max-width: 85%;
    color: var(--rsvp-word-color);
    font-weight: 500;
}

.rsvp-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    align-items: center;
    padding: 1.25rem;
    background: var(--rsvp-panel);
    border-top: 1px solid var(--border);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-subtle);
    padding: 0.25rem;
    border-radius: 9999px;
    border: 1px solid var(--border);
}

.control-value {
    min-width: 70px;
    text-align: center;
    font-weight: 700;
    color: var(--accent);
}

.btn-control,
.btn-small {
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
}

.btn-close {
    background: var(--text-muted);
    color: white;
}

.btn-close:hover {
    background: var(--accent);
}

@media (max-width: 768px) {
    .rsvp-word {
        font-size: 2.2rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .rsvp-controls {
        gap: 0.5rem;
    }

    .app-container {
        padding: 1rem;
    }

    .toast {
        right: 12px;
        bottom: 12px;
        min-width: 240px;
    }
}

/* Next chapter toast - bottom right with 5s timer */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1100;
    min-width: 280px;
    max-width: 340px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    font-size: 0.95rem;
}

.toast-body {
    padding: 0.9rem 1rem 0.75rem;
}

.toast-message {
    color: var(--text);
    font-weight: 500;
    margin-bottom: 0.4rem;
}

.toast-progress {
    height: 4px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
    margin: 0.35rem 0 0.5rem;
}

.toast-bar {
    height: 100%;
    background: var(--accent);
    width: 100%;
}

.toast-actions {
    display: flex;
    gap: 0.5rem;
}