:root {
    --bg-color: #0f0f13;
    --card-bg: #1c1c24;
    --primary: #0a84ff;
    --text-main: #ffffff;
    --text-secondary: #8e8e93;
    --danger: #ff453a;
    --success: #30d158;
    --safe-area-top: env(safe-area-inset-top);
    --safe-area-bottom: env(safe-area-inset-bottom);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    padding-top: calc(var(--safe-area-top) + 20px);
    padding-bottom: calc(var(--safe-area-bottom) + 80px);
}

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

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

.user-badge {
    background: var(--card-bg);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* Login Form */
.login-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 80vh;
    text-align: center;
}

.login-input {
    background: var(--card-bg);
    border: 1px solid #333;
    color: white;
    padding: 15px;
    border-radius: 12px;
    width: 100%;
    font-size: 16px;
    margin-bottom: 15px;
    outline: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 12px;
    width: 100%;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

/* Dashboard */
.action-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 20px;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.url-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    padding: 12px;
    border-radius: 10px;
    color: white;
    font-size: 16px;
}

.btn-add {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}

.file-upload-label {
    display: block;
    text-align: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.stat-item {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 12px;
    text-align: center;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    display: block;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Episodes List */
.episodes-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.episode-card {
    background: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    position: relative;
}

.episode-art {
    width: 80px;
    height: 80px;
    object-fit: cover;
}

.episode-info {
    padding: 12px;
    flex: 1;
    min-width: 0;
}

.episode-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.episode-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    gap: 10px;
}

.btn-delete {
    background: none;
    border: none;
    color: var(--danger);
    padding: 0 15px;
    cursor: pointer;
    font-size: 20px;
}

/* RSS Link */
.rss-section {
    margin-top: 30px;
    text-align: center;
}

.rss-link-box {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 12px;
    word-break: break-all;
    margin: 10px 0;
    user-select: all;
}

.hidden {
    display: none !important;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(50, 50, 50, 0.9);
    backdrop-filter: blur(10px);
    padding: 12px 24px;
    border-radius: 20px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
    display: inline-block;
}

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

.episode-card.processing {
    opacity: 0.7;
}

.episode-card.error {
    border: 1px solid var(--danger);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    background: rgba(40, 40, 40, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 24px;
    width: 90%;
    max-width: 320px;
    text-align: center;
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.hidden .modal {
    transform: scale(0.9);
}

.modal h3 {
    margin-top: 0;
    margin-bottom: 12px;
}

.modal p {
    color: #ccc;
    margin-bottom: 24px;
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-danger {
    background: rgba(255, 59, 48, 0.2);
    color: #ff3b30;
    border: 1px solid rgba(255, 59, 48, 0.3);
}

.btn-danger:active {
    background: rgba(255, 59, 48, 0.4);
}

.btn-text {
    background: transparent;
    color: #aaa;
    border: none;
    font-size: 14px;
    padding: 8px 12px;
}

.btn-text:active {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}