/* ============================================
   nHentai Downloader - Premium Dark Theme
   ============================================ */

:root {
    --bg-primary: #fff0f6;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #fff5f9;
    --bg-input: #fff7fb;
    --border: #ffd6e8;
    --border-hover: #ffb8d6;
    --text-primary: #5c3d4d;
    --text-secondary: #8f6478;
    --text-muted: #b087a0;
    --accent: #ff9ec4;
    --accent-strong: #ff7fb0;
    --accent-glow: rgba(255, 158, 196, 0.35);
    --accent2: #ffb3d1;
    --success: #7ed6a5;
    --warning: #ffcf8b;
    --danger: #ff8b9e;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-lg: 22px;
    --shadow: 0 6px 24px rgba(255, 158, 196, 0.18);
    --shadow-glow: 0 0 40px rgba(255, 158, 196, 0.25);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html { scroll-behavior: smooth; }

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

.main {
    flex: 1 0 auto;
}

/* Soft decorative background (hearts/sparkles instead of stars) */
.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(circle at 12% 18%, rgba(255, 182, 213, 0.25), transparent 12%),
        radial-gradient(circle at 82% 12%, rgba(255, 158, 196, 0.20), transparent 14%),
        radial-gradient(circle at 68% 72%, rgba(255, 200, 224, 0.22), transparent 16%),
        radial-gradient(circle at 22% 82%, rgba(255, 182, 213, 0.20), transparent 14%),
        radial-gradient(circle at 92% 55%, rgba(255, 210, 230, 0.18), transparent 12%);
    animation: twinkle 6s ease-in-out infinite alternate;
}

@keyframes twinkle {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* Container */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    position: relative;
    z-index: 1;
}

/* ============================================
   HEADER
   ============================================ */
.header {
    padding: 30px 0 20px;
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.logo-icon {
    font-size: 48px;
    filter: drop-shadow(0 0 20px var(--accent-glow));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.logo-text h1 {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.logo-text .accent {
    color: var(--accent-strong);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 2px;
    font-weight: 400;
}

/* ============================================
   SEARCH SECTION
   ============================================ */
.search-section {
    margin: 20px 0;
}

.search-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px 4px 4px 16px;
    transition: all 0.3s;
}

.search-input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-icon {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-input-wrapper input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font);
    padding: 12px 0;
}

.search-input-wrapper input::placeholder {
    color: var(--text-muted);
}

.btn {
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-strong);
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    background: #ff6ba4;
    box-shadow: 0 6px 24px var(--accent-glow);
}

.btn-accent {
    background: var(--accent-strong);
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-accent:hover {
    transform: translateY(-2px);
    background: #ff6ba4;
    box-shadow: 0 6px 24px var(--accent-glow);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(126, 214, 165, 0.35);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

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

/* Search Hints */
.search-hints {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
}

.chip {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 5px 14px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
}

.chip:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ============================================
   QUICK DOWNLOAD
   ============================================ */
.quick-section {
    margin: 16px 0;
}

.quick-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: var(--shadow);
}

.quick-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
}

.quick-input-row {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: 250px;
}

.quick-input-row input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

/* Kill number-spinner arrows */
.quick-input-row input::-webkit-outer-spin-button,
.quick-input-row input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.quick-input-row input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.quick-hint {
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
    flex-basis: 100%;
}
.quick-hint strong { color: var(--text-secondary); font-weight: 500; }
.quick-hint b { color: var(--accent-strong); font-weight: 700; }

.quick-input-row input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ============================================
   RESULTS
   ============================================ */
.results-section {
    margin: 24px 0;
}

.results-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.results-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.result-count {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 4px 12px;
    background: var(--bg-card);
    border-radius: 20px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    align-items: stretch;
}

.gallery-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.gallery-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 8px 32px rgba(255, 158, 196, 0.28);
}

.gallery-card .thumb {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    display: block;
    background: var(--bg-input);
}

.gallery-card .card-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.gallery-card .card-title {
    font-size: 0.85rem;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    margin-bottom: 8px;
    min-height: 2.2em;
}

.gallery-card .card-meta {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.gallery-card .card-pages {
    display: flex;
    align-items: center;
    gap: 4px;
}

.gallery-card .card-fav {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Language badge */
.gallery-card .lang-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 127, 176, 0.85);
    backdrop-filter: blur(4px);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-primary);
}

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

.page-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.page-btn.active {
    background: var(--accent-strong);
    border-color: transparent;
    color: #fff;
}

/* ============================================
   DETAIL SECTION
   ============================================ */
.detail-section {
    margin: 24px 0;
}

.btn-back {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    margin-bottom: 16px;
}

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

.detail-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow);
}

.detail-layout {
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.detail-cover {
    flex: 0 0 260px;
    position: sticky;
    top: 20px;
}

.detail-cover img {
    width: 100%;
    max-height: 440px;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(255, 158, 196, 0.3);
}

.detail-info {
    flex: 1;
    min-width: 280px;
    display: flex;
    flex-direction: column;
}

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

.preview-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.preview-strip {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
}

.preview-thumb {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    transition: transform 0.2s, border-color 0.2s;
}

.preview-thumb:hover {
    transform: scale(1.05);
    border-color: var(--accent);
}

.preview-more {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 3/4;
    border-radius: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 0.9rem;
}

.detail-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1.3;
}

.detail-title-jp {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 16px;
}

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0;
}

.tag {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.tag.artist { background: rgba(255, 127, 176, 0.14); border-color: rgba(255, 127, 176, 0.35); color: #d65a90; }
.tag.parody { background: rgba(255, 158, 196, 0.16); border-color: rgba(255, 158, 196, 0.4); color: #e070a8; }
.tag.character { background: rgba(120, 190, 230, 0.15); border-color: rgba(120, 190, 230, 0.35); color: #5aa0cc; }
.tag.tag { background: rgba(126, 214, 165, 0.14); border-color: rgba(126, 214, 165, 0.3); color: #4faf82; }
.tag.category { background: rgba(255, 200, 130, 0.18); border-color: rgba(255, 200, 130, 0.4); color: #d99a4a; }
.tag.language { background: rgba(200, 150, 220, 0.15); border-color: rgba(200, 150, 220, 0.35); color: #a06bc0; }

.detail-stats {
    display: flex;
    gap: 20px;
    margin: 16px 0;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.stat-item svg {
    opacity: 0.6;
}

.detail-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.detail-loading, .detail-error {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.detail-error {
    color: var(--danger);
}

/* ============================================
   DOWNLOAD PANEL
   ============================================ */
.download-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 360px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 40px rgba(255, 158, 196, 0.4);
    z-index: 100;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(120%);
    opacity: 0;
}

.download-panel.active {
    transform: translateY(0);
    opacity: 1;
}

.dp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.dp-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.dp-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.dp-close:hover {
    color: var(--text-primary);
}

.dp-body {
    padding: 18px;
}

.dp-info {
    margin-bottom: 12px;
}

.dp-name {
    font-weight: 600;
    font-size: 0.9rem;
    display: block;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.dp-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.dp-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    overflow: hidden;
}

.dp-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-strong);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.dp-percent {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-strong);
    min-width: 40px;
    text-align: right;
}

.dp-status {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 12px;
}

.dp-actions {
    display: flex;
    gap: 8px;
}

.dp-actions .btn {
    flex: 1;
    justify-content: center;
    font-size: 0.85rem;
    padding: 8px 16px;
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    text-align: center;
    padding: 40px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .logo {
        flex-direction: column;
        gap: 8px;
    }
    .logo-text h1 {
        font-size: 1.6rem;
    }
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }
    .detail-layout {
        flex-direction: column;
    }
    .detail-cover {
        flex: 0 0 auto;
        max-width: 200px;
        margin: 0 auto;
        position: static;
    }
    .detail-cover img {
        max-height: 320px;
    }
    .download-panel {
        left: 16px;
        right: 16px;
        width: auto;
        bottom: 16px;
    }
    .quick-box {
        flex-direction: column;
        align-items: stretch;
    }
    .quick-input-row {
        min-width: auto;
        flex-direction: column;
        gap: 10px;
    }
    .quick-input-row input {
        max-width: none;
        width: 100%;
    }
    .quick-input-row .btn {
        width: 100%;
        justify-content: center;
        padding: 14px 24px;
    }
    .search-input-wrapper {
        flex-wrap: wrap;
        padding: 8px;
    }
    .search-input-wrapper input {
        flex: 1 1 100%;
        padding: 8px 4px;
    }
    .search-input-wrapper .btn {
        flex: 1;
        justify-content: center;
    }
    .search-hints {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .header {
        padding: 20px 0 10px;
    }
    .detail-content {
        padding: 16px;
    }
    .detail-title {
        font-size: 1.2rem;
    }
}