/* Auth Common */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-width: 100vw;
    background: var(--bg);
    position: relative;
    overflow: hidden;
    padding: 16px;
}

.auth-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(13, 197, 229, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 60%, rgba(13, 197, 229, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 100%, rgba(13, 197, 229, 0.03) 0%, transparent 40%);
    animation: authBgShift 20s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes authBgShift {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(3%, -2%) scale(1.05); }
}

.auth-page .auth-card {
    width: 100%;
    max-width: 400px;
    padding: 40px 36px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
    animation: authCardEnter 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    opacity: 0;
    transform: translateY(16px) scale(0.98);
}

@keyframes authCardEnter {
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-brand {
    text-align: center;
    margin-bottom: 32px;
}

.auth-brand svg {
    width: 44px;
    height: 44px;
    color: var(--accent);
    margin-bottom: 12px;
    filter: drop-shadow(0 0 12px rgba(13, 197, 229, 0.25));
}

.auth-brand h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.02em;
}

.auth-brand p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 8px 0 0;
}

.auth-page .auth-card .field { margin-bottom: 20px; }

.auth-page .auth-card label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 8px;
    letter-spacing: 0.02em;
    text-align: left;
    padding-left: 4px;
}

.auth-page .auth-card .input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-page .auth-card input[type="email"],
.auth-page .auth-card input[type="password"],
.auth-page .auth-card input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font-body);
    outline: none;
    transition: var(--transition);
    box-sizing: border-box;
}

.auth-page .auth-card input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-page .auth-card input::placeholder {
    color: var(--text-muted);
}

.auth-page .auth-card .pw-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    z-index: 2;
}

.auth-page .auth-card .pw-toggle:hover { color: var(--text-primary); }

.auth-page .auth-card .btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.02em;
    margin-top: 4px;
    position: relative;
    overflow: hidden;
}

.auth-page .auth-card .btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.auth-page .auth-card .btn-primary:active {
    transform: translateY(0);
    box-shadow: none;
}

.auth-page .auth-card .link {
    text-align: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.auth-page .auth-card .link a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
}

.auth-page .auth-card .link a:hover {
    color: var(--accent);
}

.auth-page .auth-card .error-msg {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--danger);
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 20px;
    line-height: 1.4;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

@media (max-width: 480px) {
    .auth-page .auth-card {
        padding: 32px 24px;
        border-radius: var(--radius);
    }
    .auth-brand svg { width: 36px; height: 36px; }
    .auth-brand h1 { font-size: 1.35rem; }
}

/* Login */
.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 50%, rgba(13, 197, 229, 0.06) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 60%, rgba(16, 185, 129, 0.04) 0%, transparent 50%);
    animation: authBgShiftLogin 20s ease-in-out infinite alternate;
}

@keyframes authBgShiftLogin {
    0% { transform: translate(0, 0); }
    100% { transform: translate(5%, -3%); }
}

/* Register */
.register-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 70% 50%, rgba(13, 197, 229, 0.06) 0%, transparent 50%),
                radial-gradient(ellipse at 30% 60%, rgba(16, 185, 129, 0.04) 0%, transparent 50%);
    animation: authBgShiftRegister 20s ease-in-out infinite alternate;
}

@keyframes authBgShiftRegister {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-5%, 3%); }
}

.register-page .auth-card .info-msg {
    background: rgba(13, 197, 229, 0.08);
    border: 1px solid rgba(13, 197, 229, 0.2);
    color: var(--accent);
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.85rem;
    margin-bottom: 20px;
    line-height: 1.4;
}

/* Profile */
.profile-container { padding: 24px; max-width: 600px; margin: 0 auto; }

.profile-section {
    margin-bottom: 32px;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.profile-section h2 {
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 0 0 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.profile-avatar-row {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
}

.profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    flex-shrink: 0;
}

.profile-avatar img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }

.profile-avatar-info h3 { font-size: 18px; font-weight: 600; color: var(--text-primary); margin: 0; }

.profile-avatar-info p { font-size: 13px; color: var(--text-secondary); margin: 4px 0 0; text-transform: capitalize; }

.field { margin-bottom: 16px; }

.field label { display: block; color: var(--text-secondary); font-size: 12px; font-weight: 500; margin-bottom: 8px; letter-spacing: 0.02em; text-transform: uppercase; }

.field input[type="text"],
.field input[type="email"],
.field input[type="password"] {
    width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text-primary); font-size: 14px; outline: none; transition: border-color 0.2s;
    box-sizing: border-box;
}

.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.field input:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    padding: 10px 24px; background: var(--accent); color: var(--bg); border: none; border-radius: 8px;
    font-size: 14px; font-weight: 600; cursor: pointer; transition: opacity 0.2s;
}

.btn-primary:hover { opacity: 0.9; }

.btn-danger {
    padding: 10px 24px; background: transparent; color: var(--text-secondary); border: 1px solid var(--border);
    border-radius: 8px; font-size: 14px; cursor: pointer; transition: all 0.2s;
}

.btn-danger:hover { border-color: var(--danger); color: var(--danger); }

.error-msg { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.25); color: var(--danger); padding: 12px 16px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; line-height: 1.4; }

.success-msg { background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.25); color: var(--success); padding: 12px 16px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; line-height: 1.4; }

.pw-divider { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

.pw-divider h3 { font-size: 14px; font-weight: 600; color: var(--text-primary); margin: 0 0 16px; }

.btn-row { display: flex; gap: 12px; margin-top: 24px; }

/* Profile Tabs */
.profile-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    padding: 0 4px;
}

.profile-tab {
    padding: 10px 18px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: -1px;
}

.profile-tab:hover {
    color: var(--text-primary);
    background: var(--accent-soft);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.profile-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.profile-tab-content {
    display: none;
}

.profile-tab-content.active {
    display: block;
}

.profile-tab-content .carousel-section {
    margin-bottom: 0;
}

.profile-tab-content .carousel-header {
    padding-left: 0;
    padding-right: 0;
}

.profile-tab-content .carousel-row {
    padding-left: 0;
    padding-right: 0;
}

/* AniList Section */
.anilist-section { margin-bottom: 32px; }

.anilist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.anilist-header .carousel-title { margin: 0; }

.view-toggle {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.view-toggle-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.view-toggle-btn:hover { color: var(--text-primary); }

.view-toggle-btn.active {
    background: var(--surface);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.anilist-body { margin-bottom: 16px; }

/* Card Grid (inside profile) */
.anime-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

.anime-grid.stagger .anime-item {
    opacity: 0;
    animation: cardFadeIn 0.4s ease forwards;
    animation-delay: calc(var(--i, 0) * 60ms);
}

/* List View */
.anime-list-view {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.anime-list-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.anime-list-item:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.anime-list-item .list-thumb {
    width: 48px;
    height: 72px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
    background: var(--elevated);
}

.anime-list-item .list-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.anime-list-item .list-info h3 {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.anime-list-item .list-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.anime-list-item .list-meta .dot {
    width: 4px;
    height: 4px;
    background: var(--text-secondary);
    border-radius: 50%;
    display: inline-block;
}

.anime-list-item .list-progress {
    width: 120px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.anime-list-item .list-progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.anime-list-item .list-progress-bar .fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.anime-list-item .list-progress-label {
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
}

/* Pagination */
.anilist-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.anilist-pagination button {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    min-width: 32px;
}

.anilist-pagination button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.anilist-pagination button.active {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

.anilist-pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: var(--border);
    color: var(--text-muted);
}

.anilist-pagination .page-ellipsis {
    color: var(--text-muted);
    font-size: 13px;
    padding: 0 4px;
}

.anilist-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-sync {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-sync:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-sync.syncing {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-sync svg {
    transition: transform 0.6s ease;
}

.btn-sync.syncing svg {
    animation: spin 1s linear infinite;
}

/* Sub Tabs */
.anilist-sub-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.anilist-sub-tab {
    padding: 6px 12px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.anilist-sub-tab:hover {
    color: var(--text-primary);
    background: var(--accent-soft);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.anilist-sub-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.sub-tab-count {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1px 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.anilist-sub-tab.active .sub-tab-count {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

/* Local availability badges */
.local-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: var(--surface);
    color: var(--text-secondary);
    font-weight: 600;
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 10px;
    z-index: 3;
    font-family: var(--font-body);
    letter-spacing: 0.02em;
    border: 1px solid var(--border);
}

.local-badge.new {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.3);
}

.local-text {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
}

.local-text.new {
    color: var(--success);
}

.anime-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.7) 60%, transparent 100%);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
    z-index: 6;
}

.anime-item:hover .anime-actions {
    opacity: 1;
    pointer-events: auto;
}

.action-btn {
    padding: 4px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.2;
}

.action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.action-btn.remove {
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.action-btn.remove:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--danger);
}

.score-badge {
    background: rgba(245, 158, 11, 0.9);
    color: var(--bg);
}

.action-btn.small {
    padding: 3px 6px;
    font-size: 9px;
}

.score-badge {
    background: rgba(245, 158, 11, 0.9);
    color: var(--bg);
}

.list-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-end;
    max-width: 200px;
}

/* AniList Callback */
body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    animation: cardFadeIn 0.5s ease forwards;
    box-shadow: var(--shadow-lg);
}

.auth-card h2 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 8px;
    letter-spacing: -0.02em;
}

.auth-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 20px;
    line-height: 1.6;
}

.auth-card h2.success { color: var(--accent); }
.auth-card h2.error { color: var(--danger); }

.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 20px;
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 24px;
    color: var(--text-muted);
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.auth-logo svg {
    width: 20px;
    height: 20px;
    color: var(--accent);
}

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

@keyframes cardFadeIn {
    0% {
        opacity: 0;
        transform: translateY(16px) scale(0.97);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
