:root {
    --bg-color: #000000;
    --surface-color: #0a0a0a;
    --surface-border: #222222;
    --surface-hover: #161616;
    --text-primary: #ededed;
    --text-muted: #888888;
    --primary-color: #ededed;
    --primary-invert: #000000;
    --error-color: #e5484d;
    --success-color: #30a46c;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.screen.active {
    opacity: 1;
}

.view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Authentication */
#auth-screen {
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    padding: 40px 32px;
    background: var(--bg-color);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

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

.auth-logo {
    width: 48px;
    height: 48px;
    margin-bottom: 20px;
    border-radius: var(--radius-sm);
}

.auth-header h1 {
    font-size: 1.25rem;
    font-weight: 500;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Inputs & Forms */
.input-group {
    margin-bottom: 16px;
}

input[type="password"],
input[type="text"],
input[type="url"],
select {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-color);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.15s ease;
}

input:focus, select:focus {
    border-color: #555;
}

input::placeholder {
    color: #555;
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    padding-right: 36px;
}

/* Buttons */
button {
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.15s ease;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: var(--primary-invert);
}

.btn-primary:hover:not(:disabled) {
    background: #ffffff;
}

.btn-primary:disabled {
    background: #333;
    color: #666;
    cursor: not-allowed;
}

.btn-secondary {
    padding: 8px 16px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--surface-border);
}

.btn-secondary:hover {
    color: var(--text-primary);
    border-color: #444;
}

/* Status Text */
.status-text {
    margin-top: 16px;
    font-size: 0.85rem;
    text-align: center;
}

.error-text {
    color: var(--error-color);
}

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

.text-muted {
    color: var(--text-muted);
}

/* App Header & Nav */
.app-header {
    border-bottom: 1px solid var(--surface-border);
    padding: 16px 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: saturate(180%) blur(10px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    width: 28px;
    height: 28px;
    border-radius: 4px;
}

.header-brand h1 {
    font-size: 1rem;
    font-weight: 500;
}

.header-nav {
    display: flex;
    gap: 8px;
    background: var(--surface-color);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--surface-border);
}

.nav-link {
    background: transparent;
    color: var(--text-muted);
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.nav-link:hover {
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--surface-border);
    color: var(--text-primary);
}

/* Main Container */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 40px 24px;
    width: 100%;
}

/* Search Section */
.search-section {
    margin-bottom: 48px;
}

.search-bar {
    display: flex;
    gap: 12px;
    max-width: 600px;
    margin: 0 auto;
}

.search-bar input {
    margin-bottom: 0;
}

.search-bar .btn-primary {
    width: auto;
    padding: 12px 24px;
}

/* Grids */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.anime-card {
    background: var(--surface-color);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.anime-card:hover {
    border-color: #444;
    background: var(--surface-hover);
}

.anime-card img {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    display: block;
    border-bottom: 1px solid var(--surface-border);
}

.anime-info {
    padding: 12px 14px;
}

.anime-title {
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.anime-year {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Tasks View */
.tasks-header {
    margin-bottom: 32px;
}

.tasks-header h2 {
    font-size: 1.5rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.tasks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.task-card {
    background: var(--surface-color);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    gap: 16px;
    align-items: center;
}

.task-img {
    width: 60px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: var(--surface-border);
    flex-shrink: 0;
}

.task-details {
    flex: 1;
    min-width: 0;
}

.task-title {
    font-weight: 500;
    font-size: 0.95rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.task-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--surface-border);
}

.status-extracting { color: #f5a623; background: rgba(245, 166, 35, 0.1); }
.status-downloading { color: #00e5ff; background: rgba(0, 229, 255, 0.1); }
.status-finished { color: var(--success-color); background: rgba(48, 164, 108, 0.1); }

.progress-container {
    height: 6px;
    background: var(--surface-border);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-bar {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

/* Spinners */
.spinner, .spinner-small {
    border: 2px solid var(--surface-border);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner {
    width: 32px;
    height: 32px;
    border-top-color: var(--text-primary);
    margin: 0 auto;
}

.spinner-small {
    width: 16px;
    height: 16px;
    border-top-color: currentColor;
}

.loading-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 16px;
}

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

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    padding: 24px;
}

.modal-content {
    background: var(--surface-color);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 440px;
    padding: 32px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.modal-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
    line-height: 1.5;
}

.modal-subtitle strong {
    color: var(--text-primary);
    font-weight: 500;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions .btn-secondary {
    flex: 1;
}

.modal-actions .btn-primary {
    flex: 2;
}
