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

:root {
    --primary-color: #007AFF;
    --background: #ffffff;
    --text: #1a1a1a;
    --border: #cccccc;
    --hover: #f0f0f0;
    --accent: #007AFF;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.6;
}

/* View management */
.view {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

.view.active {
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    padding: 20px;
    border-bottom: 3px solid var(--border);
    flex-shrink: 0;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 5px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.2rem;
    color: #666;
}

/* Player header */
.player-header {
    padding: 15px 20px 20px;
    flex-shrink: 0;
    border-bottom: 2px solid var(--border);
}

.back-button {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 14px 24px;
    font-size: 1.1rem;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 15px;
    font-weight: 600;
    transition: opacity 0.2s;
}

.back-button:active {
    opacity: 0.7;
}

.player-header h2 {
    font-size: 2rem;
    margin: 0;
    font-weight: 600;
}

/* Audio List */
.audio-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 15px;
    flex: 1;
    overflow-y: auto;
}

.audio-item {
    padding: 22px;
    background-color: var(--background);
    border: 1px solid #e5e5ea;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    font-family: inherit;
    font-size: 1rem;
}

.audio-item:active {
    background-color: #f2f2f7;
    transform: scale(0.98);
}

.audio-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.audio-meta {
    font-size: 1rem;
    color: #666;
}

.last-played {
    font-weight: 600;
    color: var(--accent);
}

/* Player */
.player-container {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 40px 20px;
    text-align: center;
}

.loading-indicator.hidden {
    display: none;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid var(--border);
    border-top: 5px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-indicator p {
    font-size: 1.3rem;
    margin: 0;
    color: var(--text);
}

.audio-player {
    width: 100%;
    max-width: 500px;
    height: 100px;
    border-radius: 8px;
}

audio {
    accent-color: var(--accent);
}

/* Error message */
.error {
    font-size: 1.3rem;
    color: #d32f2f;
    padding: 20px;
    background-color: #ffebee;
    border-radius: 8px;
    margin: 20px;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #1a1a1a;
        --text: #ffffff;
        --border: #333333;
        --hover: #2a2a2a;
    }

    .error {
        background-color: #3d1f1f;
        color: #ff9999;
    }
}
