/* TL;TR Web App — Dark Theme (v3 — Visual Refresh) */

:root {
    --bg: #0a0a0a;
    --bg-card: #141414;
    --bg-input: #1a1a1a;
    --bg-elevated: #1c1c1c;
    --border: #262626;
    --border-hover: #404040;
    --text: #f5f5f5;
    --text-secondary: #a3a3a3;
    --text-muted: #737373;
    --accent: #1d9bf0;
    --accent-hover: #1a8cd8;
    --accent-glow: rgba(29, 155, 240, 0.15);
    --success: #00ba7c;
    --error: #f4212e;
    --warning: #ffd400;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s ease;
}
a:hover {
    text-decoration: underline;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   NAVBAR — Frosted glass, sticky
   ============================================ */
.navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
}
.nav-content {
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 20px;
}
.nav-brand:hover {
    text-decoration: none;
}
.brand-icon {
    font-size: 22px;
}
.brand-text {
    color: var(--accent);
}
.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}
.nav-link {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: color 0.15s ease;
}
.nav-link:hover {
    color: var(--text);
    text-decoration: none;
}
.nav-user {
    display: flex;
    align-items: center;
    gap: 8px;
}
.nav-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border);
}
.nav-username {
    color: var(--text-secondary);
    font-size: 14px;
}
.nav-logout {
    color: var(--text-muted);
    font-size: 13px;
}

/* ============================================
   CONTAINER
   ============================================ */
.container {
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 0 24px;
    flex: 1;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
}
.btn:active {
    transform: translateY(0);
}
.btn-login {
    background: var(--text);
    color: var(--bg);
}
.btn-login:hover {
    background: #e0e0e0;
    box-shadow: var(--shadow-md);
}
.btn-convert {
    background: var(--accent);
    color: #fff;
}
.btn-convert:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 16px rgba(29, 155, 240, 0.3);
}
.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-outline:hover {
    border-color: var(--border-hover);
    color: var(--text);
    background: var(--bg-elevated);
}
.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}
.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}
.btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

.x-icon {
    flex-shrink: 0;
}

/* ============================================
   HERO
   ============================================ */
.hero {
    text-align: center;
    padding: 80px 0 40px;
    animation: fadeIn 0.4s ease;
}
.hero-title {
    font-size: clamp(32px, 6vw, 52px);
    font-weight: 800;
    margin-bottom: 16px;
    letter-spacing: -0.03em;
    line-height: 1.1;
}
.hero-subtitle {
    font-size: 17px;
    color: var(--text-secondary);
    max-width: 500px;
    margin: 0 auto 12px;
    line-height: 1.6;
}
.hero-tagline {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 40px;
}

/* ============================================
   CONVERT FORM
   ============================================ */
.convert-form {
    max-width: 600px;
    margin: 0 auto;
}
.input-row {
    margin-bottom: 16px;
}
.url-input {
    width: 100%;
    padding: 14px 18px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: all 0.2s ease;
}
.url-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.url-input:disabled {
    opacity: 0.4;
}
.url-input::placeholder {
    color: var(--text-muted);
}
.options-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.format-toggle {
    display: flex;
    gap: 8px;
}
.format-option {
    cursor: pointer;
    display: flex;
    align-items: center;
}
.format-option input {
    display: none;
}
.format-label {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-muted);
    transition: all 0.15s ease;
}
.format-option input:checked + .format-label {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}
.format-option input:disabled + .format-label {
    opacity: 0.4;
    cursor: not-allowed;
}
.usage-note {
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-muted);
}
.btn-hero {
    padding: 12px 28px;
    font-size: 15px;
}

/* ============================================
   ALERT
   ============================================ */
.alert {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-top: 16px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}
.alert-error {
    background: rgba(244, 33, 46, 0.08);
    color: var(--error);
    border: 1px solid rgba(244, 33, 46, 0.2);
}

/* ============================================
   FEATURES
   ============================================ */
.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    padding: 60px 0;
    border-top: 1px solid var(--border);
    margin-top: 60px;
}
.feature {
    text-align: center;
    padding: 32px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.2s ease;
}
.feature:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.feature-icon {
    font-size: 32px;
    margin-bottom: 16px;
}
.feature h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}
.feature p {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.5;
}

/* ============================================
   DASHBOARD
   ============================================ */
.dashboard {
    padding: 40px 0;
    animation: fadeIn 0.3s ease;
}
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
}
.dashboard-header h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.usage-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 14px;
}
.usage-count {
    color: var(--accent);
    font-weight: 700;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 80px 0;
}
.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}
.empty-state h2 {
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-weight: 700;
    letter-spacing: -0.01em;
}
.empty-state p {
    color: var(--text-muted);
    font-size: 15px;
}
.link {
    color: var(--accent);
}

/* ============================================
   DASHBOARD LIST
   ============================================ */
.dash-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.dash-row {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    transition: all 0.2s ease;
}
.dash-row:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}
.dash-row-left {
    flex: 1;
    min-width: 0;
}
.dash-row-link {
    text-decoration: none;
    color: inherit;
    display: block;
}
.dash-row-link:hover {
    text-decoration: none;
}
.dash-row-link:hover .dash-row-title {
    color: var(--accent);
}
.dash-row-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
    letter-spacing: -0.01em;
    transition: color 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dash-row-author {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 6px;
}
.dash-row-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 12px;
    flex-wrap: wrap;
}
.dash-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.badge-bot {
    background: rgba(29, 155, 240, 0.15);
    color: var(--accent);
}
.badge-web {
    background: rgba(0, 186, 124, 0.12);
    color: var(--success);
}
.dash-status-failed {
    color: var(--error);
    font-weight: 600;
}
.dash-status-processing {
    color: var(--warning);
    font-weight: 600;
}
.dash-row-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ============================================
   JOB PAGE — Processing State
   ============================================ */
.job-page {
    padding: 0;
}
.job-card {
    max-width: 560px;
    width: 100%;
    text-align: center;
    margin: 60px auto;
    animation: fadeIn 0.4s ease;
}
.job-header {
    margin-bottom: 32px;
}
.job-header h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}
.job-author {
    color: var(--text-muted);
    font-size: 15px;
}
.job-status {
    margin-bottom: 32px;
}
.status-icon {
    font-size: 48px;
    margin-bottom: 12px;
}
.status-text {
    font-size: 15px;
    color: var(--text-muted);
}
.job-meta {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
}
.job-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}
.job-actions .btn {
    min-width: 200px;
}

/* ============================================
   STICKY AUDIO PLAYER BAR
   ============================================ */
.player-bar {
    position: sticky;
    top: 56px;
    z-index: 40;
    background: rgba(20, 20, 20, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
}
.player-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
}
.player-inner audio {
    flex: 1;
    height: 40px;
    min-width: 0;
    border-radius: var(--radius-sm);
}
.player-inner audio::-webkit-media-controls-panel {
    background: var(--bg-input);
}
.player-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ============================================
   ARTICLE CONTAINER
   ============================================ */
.article-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 40px 24px 60px;
    animation: fadeIn 0.4s ease;
}
.article-header {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}
.article-title {
    font-size: clamp(24px, 4vw, 32px);
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 8px;
    letter-spacing: -0.03em;
}
.article-author {
    color: var(--text-muted);
    font-size: 15px;
    margin-bottom: 12px;
}
.article-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.meta-item {
    color: var(--text-muted);
    font-size: 13px;
}
.meta-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.meta-link:hover {
    text-decoration: underline;
}

/* Article text body */
.article-text {
    font-size: 17px;
    line-height: 1.7;
    color: var(--text-secondary);
}
.article-text p {
    margin-bottom: 20px;
}
.article-link {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: rgba(29, 155, 240, 0.3);
    text-underline-offset: 3px;
    word-break: break-all;
    transition: text-decoration-color 0.15s ease;
}
.article-link:hover {
    text-decoration-color: var(--accent);
}
.article-loading {
    color: var(--text-muted);
    text-align: center;
    padding: 40px 0;
}
.text-muted {
    color: var(--text-muted);
}

/* Article footer */
.article-footer {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ============================================
   SPINNER
   ============================================ */
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    border-top: 1px solid var(--border);
    padding: 32px 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}
.footer-link {
    color: var(--accent);
    font-weight: 500;
}

/* ============================================
   LIBRARY PAGE
   ============================================ */
.library {
    padding: 40px 0;
    animation: fadeIn 0.3s ease;
}
.library-header {
    text-align: center;
    margin-bottom: 36px;
}
.library-header h1 {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -0.03em;
}
.library-subtitle {
    color: var(--text-muted);
    font-size: 15px;
}
.library-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    gap: 16px;
}
.library-search {
    display: flex;
    gap: 8px;
    flex: 1;
    max-width: 400px;
}
.library-search-input {
    flex: 1;
    padding: 10px 16px;
    font-size: 14px;
    transition: all 0.2s ease;
}
.library-search-input:focus {
    flex: 1.2;
}
.library-sort {
    display: flex;
    gap: 4px;
}
.sort-option {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    border: 1px solid var(--border);
    text-decoration: none;
    transition: all 0.15s ease;
}
.sort-option:hover {
    text-decoration: none;
    border-color: var(--border-hover);
    color: var(--text-secondary);
}
.sort-option.active {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-glow);
}

/* Library Grid */
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}
.library-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: all 0.25s ease;
}
.library-card:hover {
    border-color: var(--border-hover);
    text-decoration: none;
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}
.library-card-cover {
    aspect-ratio: 16 / 9;
    background: var(--bg-input);
    overflow: hidden;
    position: relative;
}
.library-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.library-card:hover .library-card-cover img {
    transform: scale(1.03);
}
.library-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    opacity: 0.3;
    background: linear-gradient(135deg, var(--bg-input), var(--bg-card));
}
.library-card-info {
    padding: 14px 16px;
}
.library-card-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}
.library-card-author {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 6px;
}
.library-card-meta {
    color: var(--text-muted);
    font-size: 12px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}
.pagination-info {
    color: var(--text-muted);
    font-size: 13px;
}

/* ============================================
   RESPONSIVE — Tablet
   ============================================ */
@media (max-width: 768px) {
    .features {
        grid-template-columns: repeat(2, 1fr);
    }
    .library-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .library-search {
        max-width: 100%;
    }
    .library-sort {
        justify-content: center;
    }
    .dashboard-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
}

/* ============================================
   RESPONSIVE — Mobile
   ============================================ */
@media (max-width: 480px) {
    .hero {
        padding: 48px 0 32px;
    }
    .hero-subtitle {
        font-size: 15px;
    }
    .features {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .feature {
        padding: 24px 16px;
    }
    .options-row {
        flex-direction: column;
        align-items: stretch;
    }
    .format-toggle {
        justify-content: center;
    }
    .dash-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .dash-row-actions {
        width: 100%;
    }
    .dash-row-title {
        white-space: normal;
    }
    .player-inner {
        flex-direction: column;
        gap: 10px;
    }
    .player-inner audio {
        width: 100%;
    }
    .article-text {
        font-size: 16px;
    }
    .article-footer {
        flex-direction: column;
    }
    .library-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }
    .library-card-info {
        padding: 10px 12px;
    }
    .library-card-title {
        font-size: 13px;
    }
    .nav-right {
        gap: 10px;
    }
    .nav-username {
        display: none;
    }
}
