/* ========== Design Tokens ========== */
:root {
    --bg: #fafaf8;
    --text: #1a1a1a;
    --text-secondary: #666;
    --text-muted: #999;
    --text-faint: #aaa;
    --red: #d4283c;
    --blue: #4477bb;
    --amber: #d4a028;
    --red-light: #c05050;
    --border: #e8e8e4;
    --bg-sidebar: #f5f4f0;
    --bg-code: #f0efeb;
    --bg-callout: #f5f4f0;
    --grid-color: #f0efeb;
    --sidebar-width: 50px;
    --sidebar-expanded: 180px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    font-size: 15px;
}

/* Mechanical grid background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 0;
}

::selection {
    background-color: rgba(212, 40, 60, 0.15);
    color: var(--text);
}

::-moz-selection {
    background-color: rgba(212, 40, 60, 0.15);
    color: var(--text);
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

a {
    color: var(--blue);
    text-decoration: none;
    transition: opacity 0.2s ease;
}
a:hover { opacity: 0.7; }

/* ========== Sidebar ========== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    transition: width 0.3s ease;
    overflow: hidden;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sidebar::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
}

.sidebar:hover {
    width: var(--sidebar-expanded);
}

.sidebar-nav {
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    position: relative;
    z-index: 1;
}

.sidebar-logo {
    width: 6px;
    height: 6px;
    background: var(--red);
    transform: rotate(45deg);
    margin: 10px auto 20px;
    flex-shrink: 0;
}

.sidebar-item {
    display: flex;
    align-items: center;
    padding: 14px 15px;
    color: var(--text-faint);
    text-decoration: none;
    transition: color 0.25s ease;
    white-space: nowrap;
    font-size: 0.7rem;
    letter-spacing: 2px;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.sidebar-item .sidebar-icon {
    writing-mode: vertical-rl;
    font-size: 0.65rem;
    letter-spacing: 2px;
}

.sidebar-item .sidebar-text {
    display: none;
}

.sidebar:hover .sidebar-item .sidebar-text {
    display: inline;
}

.sidebar:hover .sidebar-item .sidebar-icon {
    writing-mode: horizontal-tb;
}

.sidebar:hover .sidebar-item {
    justify-content: flex-start;
    padding: 14px 20px;
}

.sidebar-item:hover,
.sidebar-item.active {
    color: var(--text);
}

.sidebar-bottom {
    margin-top: auto;
    margin-bottom: 30px;
    width: 1px;
    height: 40px;
    background: linear-gradient(180deg, transparent, rgba(212, 40, 60, 0.4), transparent);
    position: relative;
    z-index: 1;
}

/* ========== Page Container ========== */
.page-container {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 20px 40px;
    position: relative;
    z-index: 1;
}

.main-content {
    width: 100%;
    max-width: 620px;
    position: relative;
    padding-top: 40px;
}

.page-title {
    font-family: Georgia, 'Noto Serif SC', serif;
    font-size: 1.6rem;
    letter-spacing: 8px;
    color: var(--text);
    text-align: center;
    margin-bottom: 8px;
    font-weight: normal;
}

.page-title-line {
    width: 30px;
    height: 2px;
    background: var(--red);
    margin: 0 auto 24px;
}

/* ========== Side Image ========== */
.side-image {
    display: none;
    position: fixed;
    right: 16px;
    top: 50%;
    transform: translateY(-50%) rotate(2deg);
    width: 400px;
    z-index: 1;
    pointer-events: none;
    background: #fefefe;
    padding: 14px 14px 48px;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.06),
        0 12px 24px rgba(0, 0, 0, 0.18);
}

/* Pushpin — silver metallic */
.side-image::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: radial-gradient(circle at 45% 35%, #f0f0f0, #c0c0c0 50%, #888);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    z-index: 2;
}

/* Washi tape — cream */
.side-image::after {
    content: '';
    position: absolute;
    top: 16px;
    left: -16px;
    width: 90px;
    height: 24px;
    background: rgba(245, 235, 210, 0.7);
    transform: rotate(-22deg);
    z-index: 2;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.side-image img {
    width: 100%;
    height: auto;
    display: block;
    transition: opacity 0.4s ease;
    position: relative;
    z-index: 1;
}

.user-id-line {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-bottom: 30px;
    letter-spacing: 1px;
}

/* ========== Article Cards ========== */
.article-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: 100%;
}

.article-card {
    width: 100%;
    max-width: 560px;
    background: #fff;
    border: 1px solid #d8d8d4;
    padding: 22px 26px;
    text-decoration: none;
    color: inherit;
    display: block;
    position: relative;
    text-align: center;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.article-card:hover {
    border-color: var(--red);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.article-card::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    width: 4px;
    height: 4px;
    background: var(--red);
}

.article-card:hover {
    border-color: var(--red);
}

.article-title {
    font-family: Georgia, 'Noto Serif SC', serif;
    font-size: 1.1rem;
    letter-spacing: 3px;
    color: var(--text);
    margin-bottom: 8px;
    font-weight: normal;
}

.article-card:hover .article-title {
    color: var(--red);
}

.article-meta {
    font-size: 0.75rem;
    color: var(--text-faint);
    margin-bottom: 10px;
}

.article-meta span {
    margin-right: 12px;
}

.pinned-badge {
    display: inline-block;
    font-size: 0.55rem;
    color: var(--red);
    border: 1px solid var(--red);
    padding: 1px 5px;
    letter-spacing: 1px;
    vertical-align: middle;
    margin-left: 6px;
}

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

.tag {
    font-size: 0.65rem;
    color: var(--blue);
    border: 1px solid rgba(68, 119, 187, 0.2);
    background: rgba(68, 119, 187, 0.04);
    padding: 2px 8px;
    letter-spacing: 0.5px;
}

.no-articles {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
}

/* ========== Category Filter ========== */
.filter-section {
    text-align: center;
    margin-bottom: 28px;
    padding: 20px;
    border: 1px solid var(--border);
}

.filter-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 14px;
    letter-spacing: 1px;
}

.filter-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.filter-tag {
    padding: 5px 14px;
    border: 1px solid rgba(68, 119, 187, 0.25);
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    color: var(--blue);
    font-size: 0.8rem;
    font-family: inherit;
    letter-spacing: 0.5px;
}

.filter-tag:hover {
    border-color: var(--blue);
    background: rgba(68, 119, 187, 0.04);
}

.filter-tag.active {
    background: rgba(68, 119, 187, 0.08);
    border-color: var(--blue);
    color: var(--blue);
}

/* ========== Article Page ========== */
.article-page {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 50px 20px 60px;
}

.article-page-inner {
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
}

.article-header {
    text-align: center;
    margin-bottom: 36px;
}

.article-header .article-title {
    font-size: 1.5rem;
    letter-spacing: 6px;
    margin-bottom: 10px;
}

.article-header .title-line {
    width: 40px;
    height: 1.5px;
    background: var(--red);
    margin: 0 auto 12px;
}

.article-header .article-meta {
    color: var(--text-faint);
    font-size: 0.7rem;
}

.article-header .article-meta span {
    margin: 0 6px;
}

.article-header .meta-sep {
    color: var(--border);
}

.article-header .article-tags {
    justify-content: center;
    margin-top: 14px;
}

/* ========== Article Content Elements ========== */
.article-content {
    font-size: 0.95rem;
    line-height: 2;
    color: #333;
}

.article-content h2 {
    font-family: Georgia, 'Noto Serif SC', serif;
    font-size: 1.2rem;
    color: var(--red);
    letter-spacing: 2px;
    margin: 36px 0 14px;
    font-weight: normal;
    display: flex;
    align-items: center;
    gap: 10px;
}

.article-content h2::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    background: var(--red);
    transform: rotate(45deg);
    flex-shrink: 0;
}

.article-content h3 {
    font-family: Georgia, 'Noto Serif SC', serif;
    font-size: 1rem;
    color: var(--red);
    letter-spacing: 1px;
    margin: 28px 0 10px;
    font-weight: normal;
}

.article-content h4 {
    font-family: Georgia, 'Noto Serif SC', serif;
    font-size: 0.9rem;
    color: var(--red);
    letter-spacing: 0.5px;
    margin: 24px 0 8px;
    font-weight: normal;
}

.article-content p {
    margin-bottom: 18px;
}

.article-content strong {
    color: var(--text);
}

.article-content em {
    color: var(--red);
    font-style: italic;
}

.article-content code {
    font-family: 'SF Mono', 'Consolas', 'Courier New', monospace;
    font-size: 0.82rem;
    background: var(--bg-code);
    padding: 1px 5px;
    color: var(--red);
}

.article-content a {
    color: var(--blue);
    text-decoration: none;
    border-bottom: 1px solid rgba(68, 119, 187, 0.25);
}

.article-content a:hover {
    border-bottom-color: var(--blue);
    opacity: 1;
}

.article-content blockquote {
    border-left: 2px solid var(--red);
    padding: 10px 16px;
    margin: 18px 0;
    background: var(--bg-callout);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.article-content blockquote p {
    margin-bottom: 0;
}

.article-content ul {
    list-style: none;
    padding-left: 0;
    margin: 14px 0;
}

.article-content ul li {
    padding-left: 16px;
    position: relative;
    margin-bottom: 4px;
}

.article-content ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.6em;
    width: 5px;
    height: 5px;
    background: var(--red);
    transform: rotate(45deg);
}

.article-content ol {
    padding-left: 22px;
    margin: 14px 0;
}

.article-content ol li {
    margin-bottom: 4px;
}

.article-content ol li::marker {
    color: var(--red);
    font-family: Georgia, serif;
    font-weight: bold;
}

.article-content hr {
    border: none;
    text-align: center;
    margin: 32px 0;
    overflow: visible;
}

.article-content hr::after {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    background: var(--red);
    transform: rotate(45deg);
}

.article-content pre {
    border: 1px solid var(--border);
    margin: 18px 0;
    overflow: hidden;
}

.article-content pre .code-filename {
    display: block;
    background: var(--bg-callout);
    padding: 4px 14px;
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Consolas', 'Courier New', monospace;
    border-bottom: 1px solid var(--border);
    letter-spacing: 0.5px;
}

.article-content pre code {
    display: block;
    padding: 12px 16px;
    font-family: 'SF Mono', 'Consolas', 'Courier New', monospace;
    font-size: 0.8rem;
    color: #444;
    line-height: 1.8;
    overflow-x: auto;
    background: var(--bg);
}

.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 18px 0;
    font-size: 0.85rem;
}

.article-content th {
    border-bottom: 1.5px solid var(--red);
    padding: 8px 14px;
    text-align: left;
    font-family: Georgia, serif;
    color: var(--text);
    font-size: 0.8rem;
}

.article-content td {
    border-bottom: 1px solid var(--border);
    padding: 8px 14px;
    color: #333;
}

.article-content .image-box {
    border: 1px solid var(--border);
    padding: 16px;
    margin: 24px 0;
    text-align: center;
}

.article-content .image-box img {
    max-width: 100%;
    height: auto;
}

.article-content .image-box .caption {
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.article-content .alert {
    border-left: 3px solid;
    padding: 12px 16px;
    margin: 16px 0;
    background: var(--bg-callout);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.article-content .alert p { margin: 0; }

.article-content .alert-info {
    border-color: var(--blue);
}

.article-content .alert-info::before {
    content: 'INFO';
    display: block;
    color: var(--blue);
    font-weight: bold;
    font-size: 0.8rem;
    margin-bottom: 2px;
}

.article-content .alert-warning {
    border-color: var(--amber);
}

.article-content .alert-warning::before {
    content: 'WARN';
    display: block;
    color: var(--amber);
    font-weight: bold;
    font-size: 0.8rem;
    margin-bottom: 2px;
}

.article-content .alert-success {
    border-color: var(--red);
}

.article-content .alert-success::before {
    content: 'SUCCESS';
    display: block;
    color: var(--red);
    font-weight: bold;
    font-size: 0.8rem;
    margin-bottom: 2px;
}

/* ========== Reading Progress Bar ========== */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--red), var(--red-light));
    width: 0%;
    z-index: 1001;
    transition: width 0.1s ease-out;
}

/* ========== Bottom Status Bar ========== */
.bottom-status {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    padding: 4px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.6rem;
    color: var(--text-muted);
    z-index: 1000;
    letter-spacing: 0.5px;
}

.bottom-status .status-left {
    display: flex;
    gap: 16px;
}

.bottom-status .user-id {
    color: var(--text-secondary);
}

/* ========== Footer ========== */
.footer-beian {
    text-align: center;
    padding: 30px 20px;
    margin-top: 40px;
    font-size: 0.65rem;
    color: var(--text-faint);
    border-top: 1px solid var(--border);
}

.footer-beian a {
    color: var(--text-faint);
    text-decoration: none;
    margin: 0 12px;
}

.footer-beian a:hover {
    color: var(--text-muted);
    opacity: 1;
}

.footer-beian img {
    height: 14px;
    margin-right: 4px;
    vertical-align: middle;
    opacity: 0.4;
}

/* ========== Welcome Page ========== */
.welcome-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.welcome-container::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 0;
}

.welcome-image {
    position: fixed;
    right: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.welcome-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(0.6);
}

.welcome-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.welcome-top-accent {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-bottom: 36px;
}

.welcome-top-accent .line { width: 20px; height: 1px; }
.welcome-top-accent .line.red { background: var(--red); opacity: 0.3; }
.welcome-top-accent .line.blue { background: var(--blue); opacity: 0.2; }
.welcome-top-accent .diamond {
    width: 4px;
    height: 4px;
    background: var(--red);
    transform: rotate(45deg);
    opacity: 0.4;
}

.welcome-title {
    font-family: Georgia, 'Noto Serif SC', serif;
    font-size: 2.8rem;
    letter-spacing: 16px;
    color: var(--text);
    margin-bottom: 10px;
    font-weight: normal;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    text-shadow: 0 0 40px rgba(212, 40, 60, 0.12);
    transition: letter-spacing 0.6s ease, text-shadow 0.6s ease;
}

.welcome-title:hover {
    letter-spacing: 20px;
    text-shadow: 0 0 60px rgba(212, 40, 60, 0.25);
}

.welcome-title::before,
.welcome-title::after {
    content: '';
    width: 5px;
    height: 5px;
    background: var(--red);
    transform: rotate(45deg);
    flex-shrink: 0;
    animation: diamond-pulse 3s ease-in-out infinite;
}

.welcome-title::after {
    animation-delay: 1.5s;
}

@keyframes diamond-pulse {
    0%, 100% { opacity: 0.5; transform: rotate(45deg) scale(1); }
    50% { opacity: 1; transform: rotate(45deg) scale(1.3); }
}

.welcome-title-line {
    width: 50px;
    height: 2px;
    background: var(--red);
    margin: 0 auto 14px;
}

.welcome-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 8px;
    transition: letter-spacing 0.6s ease, color 0.6s ease;
}

.welcome-subtitle:hover {
    letter-spacing: 12px;
    color: var(--red);
}

.welcome-enter {
    margin-top: 44px;
}

.welcome-enter a {
    display: inline-block;
    padding: 12px 48px;
    border: 1.5px solid var(--red);
    color: var(--red);
    font-size: 0.8rem;
    letter-spacing: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
    animation: enter-pulse 3s ease-in-out infinite;
}

@keyframes enter-pulse {
    0%, 100% { border-color: var(--red); box-shadow: 0 0 0 rgba(212, 40, 60, 0); }
    50% { border-color: #ee5060; box-shadow: 0 0 14px rgba(212, 40, 60, 0.18); }
}

.welcome-enter a:hover {
    background: var(--red);
    color: #fff;
    opacity: 1;
}

.welcome-bottom-accent {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: flex-end;
    margin-top: 48px;
}

.welcome-bottom-accent .bar {
    width: 1px;
    background: var(--red);
    opacity: 0.3;
}

.welcome-bottom-accent .bar:nth-child(1) { height: 30px; }
.welcome-bottom-accent .bar:nth-child(2) { height: 16px; background: var(--blue); opacity: 0.2; }
.welcome-bottom-accent .bar:nth-child(3) { height: 24px; opacity: 0.2; }
.welcome-bottom-accent .bar:nth-child(4) { height: 20px; background: var(--blue); opacity: 0.15; }

.welcome-corner {
    position: fixed;
    z-index: 2;
    width: 4px;
    height: 4px;
    background: var(--red);
    transform: rotate(45deg);
}

.welcome-corner.top-left { top: 24px; left: 24px; opacity: 0.5; }
.welcome-corner.bottom-right { bottom: 24px; right: 24px; opacity: 0.3; }

/* ========== Responsive: Tablet (768px) ========== */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 45px;
        --sidebar-expanded: 160px;
    }

    .page-container { padding: 30px 15px; }
    .page-title { font-size: 1.3rem; letter-spacing: 5px; }
    .article-card { padding: 18px 20px; }
    .article-title { font-size: 1rem; letter-spacing: 2px; }
    .article-meta { font-size: 0.7rem; }
    .article-content { font-size: 0.9rem; }
    .welcome-title { font-size: 2rem; letter-spacing: 10px; }
    .side-image { width: 200px; }
    .filter-section { padding: 16px; }
}

/* ========== Responsive: Phone (480px) ========== */
@media (max-width: 480px) {
    :root {
        --sidebar-width: 40px;
    }

    .page-container { padding: 20px 10px; }
    .page-title { font-size: 1.1rem; letter-spacing: 3px; }
    .article-card { padding: 14px 16px; }
    .article-title { font-size: 0.95rem; }
    .article-meta { font-size: 0.65rem; }

    .article-meta span {
        display: block;
        margin: 2px 0;
    }

    .article-content { font-size: 0.88rem; line-height: 1.8; }
    .article-content h2 { font-size: 1rem; margin: 24px 0 10px; }
    .article-content pre code { padding: 10px; font-size: 0.75rem; }
    .welcome-title { font-size: 1.6rem; letter-spacing: 8px; }
    .welcome-subtitle { letter-spacing: 4px; }
    .welcome-enter a { padding: 10px 32px; font-size: 0.7rem; letter-spacing: 4px; }
    .side-image { display: none !important; }
    .filter-section { padding: 12px; }
    .filter-tag { padding: 4px 10px; font-size: 0.7rem; }
    .sidebar-item { font-size: 0.55rem; }
    .bottom-status { font-size: 0.5rem; padding: 3px 10px; }
    .bottom-status .status-left { gap: 8px; }
}

/* ========== Large Screen (1200px+) ========== */
@media (min-width: 1200px) {
    .main-content { max-width: 700px; }
    .article-card { max-width: 620px; }
    .article-page-inner { max-width: 700px; }
}
