/* ============================================
   灵境（VR Novel）全局样式
   版本：26.5.22
   ============================================ */

/* --- CSS 变量（夜间模式默认） --- */
:root,
[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --bg-card: #16213e;
    --bg-input: #1a1a2e;
    --bg-hover: #0f3460;

    --text-primary: #eaeaea;
    --text-secondary: #a8a8b3;
    --text-muted: #6b7280;
    --text-link: #60a5fa;

    --accent: #e94560;
    --accent-hover: #ff6b81;
    --accent-secondary: #0f3460;

    --border-color: #2a2a4a;
    --border-light: #333366;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --transition: 0.2s ease;

    --reader-bg: #1a1a2e;
    --reader-text: #d4d4d4;

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
}

/* --- 日间模式 --- */
[data-theme="light"] {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e9ecef;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: #e9ecef;

    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --text-link: #2563eb;

    --accent: #e94560;
    --accent-hover: #d63850;
    --accent-secondary: #3b82f6;

    --border-color: #e5e7eb;
    --border-light: #d1d5db;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);

    --reader-bg: #f5f0e8;
    --reader-text: #333333;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color var(--transition), color var(--transition);
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--transition);
}

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

img {
    max-width: 100%;
    height: auto;
}

/* --- Layout --- */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 16px;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* --- Loading Screen --- */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    color: var(--text-secondary);
}

.loader {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

/* --- Header --- */
.site-header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    height: 60px;
}

.header-logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-logo:hover {
    color: var(--accent-hover);
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-nav a {
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: color var(--transition);
}

.header-nav a:hover,
.header-nav a.active {
    color: var(--accent);
}

.header-search {
    position: relative;
}

.header-search input {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 36px 8px 12px;
    color: var(--text-primary);
    font-size: 0.9rem;
    width: 200px;
    transition: border-color var(--transition), width var(--transition);
}

.header-search input:focus {
    outline: none;
    border-color: var(--accent);
    width: 260px;
}

.header-search button {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
}

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

.header-user .btn {
    font-size: 0.85rem;
    padding: 6px 16px;
}

.user-dropdown {
    position: relative;
    cursor: pointer;
}

.user-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.85rem;
}

.user-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    padding: 8px 0;
    display: none;
    z-index: 200;
}

.user-dropdown-menu.show {
    display: block;
}

.user-dropdown-menu a,
.user-dropdown-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 16px;
    color: var(--text-primary);
    font-size: 0.9rem;
    background: none;
    border: none;
    cursor: pointer;
    transition: background var(--transition);
}

.user-dropdown-menu a:hover,
.user-dropdown-menu button:hover {
    background: var(--bg-hover);
}

/* --- Footer --- */
.site-footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 20px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.site-footer .version {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    color: #fff;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

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

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

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

.btn-danger:hover {
    opacity: 0.9;
    color: #fff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

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

/* --- Forms --- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
}

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

textarea.form-input {
    resize: vertical;
    min-height: 120px;
}

select.form-input {
    cursor: pointer;
}

.form-error {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 4px;
}

.form-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 4px;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-body {
    padding: 16px;
}

.card-image {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    background: var(--bg-tertiary);
}

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

.novel-card .card-image {
    height: 220px;
}

.novel-card .card-body {
    padding: 12px;
}

.novel-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.novel-card-author {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.novel-card-meta {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Novel List Item (horizontal) --- */
.novel-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.novel-list-item {
    display: flex;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: all var(--transition);
}

.novel-list-item:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.novel-list-cover {
    width: 80px;
    height: 106px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.novel-list-info {
    flex: 1;
    min-width: 0;
}

.novel-list-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.novel-list-author {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.novel-list-summary {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 8px;
}

.novel-list-meta {
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.novel-list-category {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    font-size: 0.75rem;
}

/* --- Tags --- */
.tag {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.tag-primary {
    background: var(--accent);
    color: #fff;
}

.tag-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

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

.tag-warning {
    background: var(--warning);
    color: #000;
}

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    background: var(--accent);
    color: #fff;
}

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

.pagination button {
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all var(--transition);
}

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

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

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* --- Alerts --- */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid var(--info);
    color: var(--info);
}

/* --- Category Nav --- */
.category-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.category-nav a {
    padding: 6px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: all var(--transition);
}

.category-nav a:hover,
.category-nav a.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(233, 69, 96, 0.1);
}

/* --- Stats Grid --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
}

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

/* --- Table --- */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

table tr:hover td {
    background: var(--bg-hover);
}

/* --- Page Title --- */
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

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

.section-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-title a {
    font-size: 0.85rem;
    font-weight: 400;
}

/* --- Reader --- */
.reader-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 30px 20px;
}

.reader-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 12px;
}

.reader-controls-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.reader-font-btn {
    padding: 4px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
}

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

.reader-content {
    font-size: 1.05rem;
    line-height: 2;
    color: var(--text-primary);
}

.reader-content.font-sm { font-size: 0.9rem; }
.reader-content.font-md { font-size: 1.05rem; }
.reader-content.font-lg { font-size: 1.2rem; }
.reader-content.font-xl { font-size: 1.4rem; }

.reader-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* --- Comments --- */
.comment-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.comment-item {
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    overflow: hidden;
}

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

.comment-user {
    font-weight: 600;
    font-size: 0.9rem;
}

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

.comment-body {
    font-size: 0.95rem;
    line-height: 1.6;
}

.comment-replies {
    margin-left: 48px;
    margin-top: 12px;
    padding-left: 16px;
    border-left: 2px solid var(--border-color);
}

/* --- Search --- */
.search-box {
    max-width: 600px;
    margin: 0 auto 30px;
}

.search-box .form-input {
    font-size: 1.1rem;
    padding: 14px 20px;
}

/* --- Auth Pages --- */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 140px);
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 30px;
}

.auth-card h1 {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 24px;
}

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

/* --- Tabs --- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
}

.tab {
    padding: 10px 20px;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
    font-size: 0.9rem;
    font-weight: 500;
}

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

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

/* --- Breadcrumb --- */
.breadcrumb {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

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

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

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

/* --- 404 --- */
.page-404 {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    text-align: center;
}

.page-404 h1 {
    font-size: 6rem;
    color: var(--accent);
    margin-bottom: 8px;
}

.page-404 p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* --- Notification --- */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    color: #fff;
    font-size: 0.9rem;
    z-index: 9999;
    animation: slideIn 0.3s ease;
    max-width: 360px;
}

.notification-success { background: var(--success); }
.notification-error { background: var(--danger); }
.notification-info { background: var(--info); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* --- Skeleton --- */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: 12px;
}

.skeleton-image {
    width: 100%;
    aspect-ratio: 3/4;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 0.95rem;
}

/* --- Utilities --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.font-bold { font-weight: 700; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

.hidden { display: none !important; }

/* --- Responsive --- */
@media (max-width: 768px) {
    .header-inner {
        height: 52px;
    }

    .header-nav {
        gap: 12px;
    }

    .header-search input {
        width: 140px;
    }

    .header-search input:focus {
        width: 180px;
    }

    .novel-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 12px;
    }

    .novel-list-item {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .novel-list-cover {
        width: 100px;
        height: 133px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .comment-replies {
        margin-left: 20px;
    }

    .reader-container {
        padding: 20px 12px;
    }

    .main-content {
        padding: 12px 8px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .novel-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}