:root {
    --bg-color: #f2F2f6;
    /* Apple-like light gray background */
    --card-bg: #ffffff;
    --text-primary: #000000;
    --text-secondary: #8E8E93;
    --accent: #007AFF;
    /* iOS Blue */
    --accent-light: rgba(0, 122, 255, 0.1);
    --border-radius: 16px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #000000;
        --card-bg: #1C1C1E;
        --text-primary: #FFFFFF;
        --text-secondary: #EBEBF599;
        --accent: #0A84FF;
        --accent-light: rgba(10, 132, 255, 0.15);
        --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.hidden {
    display: none !important;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
    /* Prevents pull-to-refresh on mobile */
}

/* Header */
.app-header {
    position: sticky;
    top: 0;
    background-color: var(--bg-color);
    padding: 20px 20px 10px;
    z-index: 100;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    background-color: rgba(var(--bg-color), 0.85);
}

.app-header h1 {
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -1px;
    margin: 0;
}

.app-content {
    padding: 0 20px 40px;
    max-width: 600px;
    margin: 0 auto;
}

/* Search Section */
.search-section {
    position: sticky;
    top: 60px;
    z-index: 99;
    padding-bottom: 20px;
    background-color: var(--bg-color);
}

.search-bar-container {
    display: flex;
    align-items: center;
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 10px 16px;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
}

.search-bar-container:focus-within {
    box-shadow: 0 0 0 2px var(--accent-light);
    transform: scale(1.01);
}

.search-icon {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    margin-right: 12px;
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 18px;
    color: var(--text-primary);
    outline: none;
    font-weight: 500;
    width: 100%;
}

.search-input::placeholder {
    color: var(--text-secondary);
    font-weight: 400;
}

.clear-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-btn svg {
    width: 18px;
    height: 18px;
}

.search-tabs {
    display: flex;
    margin-top: 15px;
    gap: 15px;
}

.tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    padding: 5px 0;
    transition: color 0.2s;
}

.tab.active {
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
}

.primary-btn {
    background: linear-gradient(135deg, #007AFF, #00C7BE);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 122, 255, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.4);
}

.secondary-pill {
    background: transparent;
    color: var(--accent);
    border: 2px solid var(--accent);
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    margin-top: 10px;
}

.secondary-pill:active {
    background: var(--accent-light);
    transform: scale(0.98);
}

/* Feedback States (Loading, Empty) */
.feedback-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
    animation: fadeIn 0.3s ease;
}

.feedback-state.hidden {
    display: none;
}

.placeholder-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
    color: var(--text-secondary);
    opacity: 0.5;
}

.feedback-state h2 {
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--accent-light);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Hymn Display */
.hymn-article {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: var(--shadow);
    margin-top: 20px;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.hymn-article.hidden {
    display: none;
}

.hymn-header {
    margin-bottom: 30px;
    text-align: center;
    border-bottom: 1px solid var(--accent-light);
    padding-bottom: 20px;
}

.hymn-number {
    color: var(--accent);
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.hymn-title {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.5px;
}

.hymn-body {
    font-size: 18px;
    line-height: 1.8;
    color: var(--text-primary);
}

/* Styling markdown elements if injected */
.hymn-body p {
    margin-bottom: 1.5em;
}

.hymn-body strong {
    color: var(--accent);
    font-size: 16px;
    display: block;
    margin-bottom: 4px;
    margin-top: 24px;
}

.hymn-body br+strong {
    margin-top: 0;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* App Views */
.app-view {
    animation: fadeIn 0.3s ease;
}

.app-view.hidden {
    display: none;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background-color: rgba(var(--bg-color), 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid var(--accent-light);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    width: 33%;
    height: 100%;
    cursor: pointer;
    transition: color 0.2s;
}

.nav-item svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
}

.nav-item.active {
    color: var(--accent);
}

.app-content {
    padding: 0 20px 90px;
    max-width: 600px;
    margin: 0 auto;
}

/* Header Rows in Views */
.view-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    margin-top: 5px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--accent-light);
}

.icon-btn.text-green {
    color: #34C759;
    background-color: rgba(52, 199, 89, 0.1);
}

.text-btn {
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
}

.back-btn {
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 17px;
    font-weight: 500;
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-left: -8px;
}

.back-btn svg {
    margin-right: 2px;
}

/* Lists and Items */
.list-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.list-item {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: transform 0.1s;
}

.list-item:active {
    transform: scale(0.98);
}

/* Hymn Index specific items — number and title side by side */
.hymn-index-item {
    background-color: var(--card-bg);
    border-radius: 0;
    padding: 12px 16px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--accent-light);
    transition: background-color 0.15s;
}

.hymn-index-item:last-child {
    border-bottom: none;
}

.hymn-index-item:active {
    background-color: var(--accent-light);
}

.hymn-index-num {
    font-weight: 700;
    color: var(--accent);
    min-width: 42px;
    font-size: 14px;
    flex-shrink: 0;
}

.hymn-index-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
}

.list-item-content {
    flex: 1;
}

.list-item-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.list-item-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.list-item-action {
    color: var(--accent);
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    animation: fadeIn 0.2s ease;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--card-bg);
    width: 100%;
    max-height: 80vh;
    border-radius: 20px 20px 0 0;
    padding: 24px 20px 40px;
    position: relative;
    z-index: 2001;
    animation: slideUp 0.3s ease;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
}

.close-btn {
    background: #E5E5EA;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 15px;
    font-weight: bold;
    color: #8E8E93;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.modal-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.w-100 {
    width: 100%;
}

.floating-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: var(--accent-light);
    color: var(--accent);
    border: none;
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 15px;
    font-weight: 600;
    margin: 20px auto 0;
    cursor: pointer;
}