/* ─── Base ────────────────────────────────────────────── */
:root {
    --bg: #fafafa;
    --surface: #fff;
    --border: #e5e5e5;
    --text: #333;
    --text-secondary: #888;
    --accent: #e85b6c;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

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

/* ─── Navbar ─────────────────────────────────────────── */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .container {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
}

.nav-search {
    display: flex;
    flex: 1;
    min-width: 180px;
    max-width: 360px;
}

.nav-search input {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius) 0 0 var(--radius);
    font-size: 0.9rem;
    outline: none;
}

.nav-search input:focus {
    border-color: var(--accent);
}

.nav-search button {
    padding: 6px 14px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 0.9rem;
    cursor: pointer;
}

.nav-links {
    display: flex;
    gap: 12px;
    font-size: 0.95rem;
}

.nav-links a {
    color: var(--text-secondary);
}

.nav-links a:hover {
    color: var(--accent);
}

/* ─── Hero (index) ───────────────────────────────────── */
.hero {
    text-align: center;
    padding: 60px 0 40px;
}

.hero h1 {
    font-size: 2rem;
    color: var(--accent);
    margin-bottom: 8px;
}

.hero p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.hero-search {
    display: flex;
    max-width: 480px;
    margin: 0 auto;
}

.hero-search input {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius) 0 0 var(--radius);
    font-size: 1rem;
    outline: none;
}

.hero-search input:focus {
    border-color: var(--accent);
}

.hero-search button {
    padding: 12px 24px;
    border: 2px solid var(--accent);
    background: var(--accent);
    color: #fff;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 1rem;
    cursor: pointer;
}

/* ─── Stats ──────────────────────────────────────────── */
.stats {
    padding: 20px 0 40px;
}

.stats h2,
.recent h2,
.section h2,
.list-header h1,
.search-page h1 {
    font-size: 1.2rem;
    margin-bottom: 16px;
    color: var(--text);
}

.stat-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 100px;
    transition: box-shadow 0.15s;
}

.stat-card:hover {
    box-shadow: var(--shadow);
    text-decoration: none;
}

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

.stat-count {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
}

/* ─── Subject Grid / Cards ───────────────────────────── */
.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 16px;
}

.subject-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: box-shadow 0.15s, transform 0.15s;
    display: block;
    color: var(--text);
}

.subject-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
    text-decoration: none;
}

.card-img {
    aspect-ratio: 3/4;
    overflow: hidden;
    background: #f0f0f0;
}

.card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-info {
    padding: 10px 12px;
}

.card-info h3 {
    font-size: 0.9rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-name-jp {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-meta {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.rating {
    color: #e09030;
    font-weight: 600;
}

/* ─── Subject Detail ─────────────────────────────────── */
.subject-detail {
    padding: 30px 0;
}

.subject-header {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.subject-cover {
    flex-shrink: 0;
    width: 220px;
    border-radius: var(--radius);
    overflow: hidden;
    background: #f0f0f0;
}

.subject-cover img {
    width: 100%;
    display: block;
}

.subject-meta {
    flex: 1;
    min-width: 280px;
}

.subject-meta h1 {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.name-jp {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-bottom: 16px;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 6px;
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    display: inline-block;
    padding: 4px 10px;
    background: #f5f5f5;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.tag small {
    color: #bbb;
}

.section {
    margin-top: 32px;
}

.summary {
    font-size: 0.9rem;
    line-height: 1.8;
    color: #555;
    white-space: pre-line;
}

/* ─── Character / Person Lists ───────────────────────── */
.character-list,
.person-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.char-card,
.person-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 90px;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: box-shadow 0.15s;
    color: var(--text);
}

.char-card:hover,
.person-card:hover {
    box-shadow: var(--shadow);
    text-decoration: none;
}

.char-img,
.person-img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    background: #f0f0f0;
    margin-bottom: 6px;
}

.char-img img,
.person-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.char-info,
.person-info {
    text-align: center;
}

.char-name,
.person-name {
    font-size: 0.8rem;
    display: block;
    line-height: 1.3;
}

.char-role,
.person-pos {
    font-size: 0.7rem;
    color: var(--text-secondary);
    display: block;
    margin-top: 2px;
}

/* ─── Detail Page (Characters / Persons) ─────────────── */
.detail-page {
    padding: 30px 0;
}

.detail-header {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.detail-cover {
    width: 160px;
    border-radius: var(--radius);
    overflow: hidden;
    background: #f0f0f0;
}

.detail-cover img {
    width: 100%;
    display: block;
}

.detail-meta h1 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.detail-meta p {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* ─── List Page ──────────────────────────────────────── */
.list-page {
    padding: 30px 0;
}

.list-header {
    margin-bottom: 20px;
}

.total {
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--text-secondary);
}

.type-nav {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.type-nav a {
    padding: 6px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.type-nav a.active,
.type-nav a:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    text-decoration: none;
}

/* ─── Pagination ─────────────────────────────────────── */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 30px;
    font-size: 0.9rem;
}

.pagination a {
    padding: 8px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.pagination a:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    text-decoration: none;
}

/* ─── Misc ───────────────────────────────────────────── */
.search-page {
    padding: 30px 0;
}

.empty,
.empty-page {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-page h1 {
    font-size: 4rem;
    color: #ccc;
}

.empty-page a {
    display: inline-block;
    margin-top: 16px;
    font-size: 0.95rem;
}

footer {
    margin-top: auto;
    padding: 20px 0;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

footer a {
    color: var(--text-secondary);
    text-decoration: underline;
}

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 640px) {
    .subject-cover {
        width: 140px;
    }
    .subject-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 10px;
    }
    .stat-card {
        padding: 12px 20px;
        min-width: 0;
    }
    .stat-count {
        font-size: 1.4rem;
    }
    .nav-links {
        font-size: 0.85rem;
    }
}
