@charset "UTF-8";

/* ═══════════════════════════════════════════════
 * 1. THEME — CSS Variables (light / dark)
 * ═══════════════════════════════════════════════ */
:root {
    --bg: #eff1f5;
    --card: #e6e9ef;
    --border: #ccd0da;
    --text: #4c4f69;
    --secondary: #5c5f77;
    --tertiary: #6c6f85;
    --primary: #1e66f5;
    --primary-light: #d6e4fb;
    --hover: #ccd0da;
    --welcome: linear-gradient(135deg, #e6e9ef, #eff1f5);
    --series-card: linear-gradient(135deg, #e6e9ef, #e8edf5);
    --code-bg: #eff1f5;
    --code-header: #d8dae0;
    --code-border: #d0d1d6;
    --code-text: #4c4f69;
    /* Admin theme — light */
    --admin-bg: #f8fafc;
    --admin-sidebar: #ffffff;
    --admin-topbar: #ffffff;
    --admin-card-bg: #ffffff;
    --admin-border: #e2e8f0;
    --admin-text: #1e293b;
    --admin-text-secondary: #64748b;
    --admin-text-muted: #94a3b8;
    --admin-hover: #f1f5f9;
    --admin-active-bg: #eff6ff;
    --admin-active-text: #2563eb;
    --admin-divider: #e2e8f0;
}
[data-theme="dark"] {
    --bg: #1e1e2e;
    --card: #181825;
    --border: #313244;
    --text: #cdd6f4;
    --secondary: #bac2de;
    --tertiary: #a6adc8;
    --primary: #89b4fa;
    --primary-light: #2a4a7a;
    --hover: #313244;
    --welcome: linear-gradient(135deg, #181825, #1e1e2e);
    --series-card: linear-gradient(135deg, #181825, #1e1e2e);
    --code-bg: #11111b;
    --code-header: #1e1e30;
    --code-border: #313244;
    --code-text: #cdd6f4;
    /* Admin theme — dark */
    --admin-bg: #0f172a;
    --admin-sidebar: #1e293b;
    --admin-topbar: #1e293b;
    --admin-card-bg: #1e293b;
    --admin-border: #334155;
    --admin-text: #f1f5f9;
    --admin-text-secondary: #94a3b8;
    --admin-text-muted: #64748b;
    --admin-hover: #334155;
    --admin-active-bg: #1e3a5f;
    --admin-active-text: #60a5fa;
    --admin-divider: #334155;
}

/* ═══════════════════════════════════════════════
 * 2. BASE — Body, Links, Typography
 * ═══════════════════════════════════════════════ */
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, "Noto Sans", "PingFang SC",
        "Microsoft YaHei", sans-serif;
    font-size: 15px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}
a {
    color: inherit;
    text-decoration: none;
    transition: opacity 0.15s;
}
a:hover {
    opacity: 0.8;
}

/* ═══════════════════════════════════════════════
 * 3. LAYOUT HELPERS
 * ═══════════════════════════════════════════════ */

/* Three-column grid — homepage & list pages: sidebar | center | sidebar */
.app-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
@media (min-width: 1024px) {
    .app-grid {
        grid-template-columns: 1fr 3fr 1fr;
    }
}

/* Reading layout — article page: TOC (left) + content (right, wider) */
.app-grid-reading {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
@media (min-width: 1024px) {
    .app-grid-reading {
        grid-template-columns: 1fr 4fr;
    }
}
.app-grid-center {
    min-width: 0; /* prevent grid overflow */
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.section {
    margin: 1.5rem 0;
}
.section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════
 * 4. COMPONENTS
 * ═══════════════════════════════════════════════ */

/* 4a. Sidebar */
.sidebar-link {
    transition: all 0.15s;
    border-radius: 6px;
}
.sidebar-link:hover {
    background: var(--hover);
    color: var(--text) !important;
}
.toc-link:hover {
    color: var(--primary) !important;
    opacity: 1;
}
.list-group-item {
    transition: opacity 0.15s;
}
.list-group-item:hover {
    opacity: 0.85;
}

/* 4b. Cards */

/* Sidebar card — elevated design without border */
.sidebar-card-wrap {
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.theme-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.welcome-card {
    background: var(--welcome);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 2.5rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.series-card {
    background: var(--series-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem 1.375rem;
    transition: all 0.2s;
}
.series-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.article-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.875rem 1.125rem;
    transition: all 0.2s;
    text-decoration: none;
    display: block;
}
.article-card:hover {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}
.sidebar-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
}

/* 4c. Badge & Link */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 500;
    background: var(--primary-light);
    color: var(--primary);
}
.link {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s;
}
.link:hover {
    color: var(--primary);
    text-decoration: underline;
    opacity: 0.85;
}

/* 4d. Text Utilities */
.text-hero {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.6;
}
.text-title {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text);
    line-height: 1.6;
}
.text-body {
    font-size: 0.8125rem;
    color: var(--text);
    line-height: 1.7;
}
.text-caption {
    font-size: 0.75rem;
    color: var(--tertiary);
    line-height: 1.5;
}
.text-mini {
    font-size: 0.6875rem;
    color: var(--tertiary);
    line-height: 1.4;
}

/* 4e. Lists */
.list-numbered {
    counter-reset: item;
    list-style: none;
    padding: 0;
}
.list-numbered > li {
    counter-increment: item;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    line-height: 1.75;
    margin-bottom: 0.25rem;
}
.list-numbered > li::before {
    content: counter(item);
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}
.list-dot {
    list-style: none;
    padding: 0;
}
.list-dot > li {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    line-height: 1.75;
    margin-bottom: 0.25rem;
}
.list-dot > li::before {
    content: "·";
    color: var(--tertiary);
    font-weight: 700;
    font-size: 1.2em;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════
 * 5. PROSE — Article / Markdown Content
 * ═══════════════════════════════════════════════ */
.prose-content {
    font-size: 16px;
    line-height: 1.85;
}
.prose-content h2,
.prose-content h3,
.prose-content h4 {
    scroll-margin-top: 5rem;
}
.prose-content h2 {
    font-size: 1.35rem;
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 0.65rem;
    color: var(--text);
    letter-spacing: -0.01em;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
}
.prose-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 1.75rem;
    margin-bottom: 0.4rem;
    color: var(--text);
}
.prose-content h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.3rem;
    color: var(--text);
}
.prose-content p {
    margin-bottom: 1.1rem;
}
.prose-content ul,
.prose-content ol {
    margin-bottom: 1.1rem;
    padding-left: 1.5rem;
}
.prose-content li {
    margin-bottom: 0.2rem;
}
.prose-content a {
    color: var(--primary);
    text-decoration: none;
}
.prose-content a:hover {
    text-decoration: underline;
}
.prose-content blockquote {
    border-left: 3px solid var(--primary);
    padding: 0.5rem 1rem 0.5rem 1.25rem;
    margin: 1.25rem 0;
    color: var(--secondary);
    background: var(--hover);
    border-radius: 0 0.5rem 0.5rem 0;
    font-size: 0.95em;
}
.prose-content code {
    background: var(--hover);
    padding: 0.125rem 0.4rem;
    border-radius: 0.3rem;
    font-size: 0.85em;
    font-family:
        "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
}
.prose-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85em;
    margin: 1.25rem 0;
    border-radius: 0.5rem;
    overflow: hidden;
}
.prose-content th,
.prose-content td {
    border: 1px solid var(--border);
    padding: 0.55rem 0.75rem;
    text-align: left;
}
.prose-content th {
    background: var(--hover);
    font-weight: 600;
}
.prose-content img {
    max-width: 100%;
    border-radius: 0.6rem;
    margin: 1.5rem 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.prose-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2.5rem 0;
}

/* ═══════════════════════════════════════════════
 * 6. CODE BLOCKS — Mac-style toolbar + fold + copy
 * ═══════════════════════════════════════════════ */
.code-block-wrap {
    margin: 1.5rem 0;
    border-radius: 0.6rem;
    overflow: hidden;
    border: 1px solid var(--code-border);
}
.code-block-wrap pre {
    margin: 0;
    padding: 1rem 1.25rem;
    background: var(--code-bg);
    color: var(--code-text);
    overflow-x: auto;
    font-size: 0.85em;
    line-height: 1.6;
    font-family:
        "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
}
.code-block-wrap pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
}
.code-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--code-header);
    border-bottom: 1px solid var(--code-border);
}
.code-dots {
    display: flex;
    align-items: center;
    gap: 14px;
}
.code-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    cursor: pointer;
    transition:
        filter 0.2s,
        transform 0.2s;
}
.code-dot:hover {
    filter: brightness(1.4);
    transform: scale(1.25);
}
.code-dot.red {
    background: #ff5f56;
}
.code-dot.green {
    background: #27c93f;
}
.code-copy-btn {
    margin-left: auto;
    padding: 2px 8px;
    font-size: 11px;
    color: var(--tertiary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.5;
    transition:
        color 0.15s,
        border-color 0.15s;
}
.code-copy-btn:hover {
    color: var(--text);
    border-color: var(--code-border);
}
.code-block-wrap.folded pre {
    display: none;
}

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

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px rgba(30, 102, 245, 0.15);
}

.shrink-0 {
  flex-shrink: 0;
}

.opacity-50 {
  opacity: 0.5;
}

.opacity-25 {
  opacity: 0.25;
}

.opacity-10 {
  opacity: 0.1;
}

.opacity-20 {
  opacity: 0.2;
}

.min-w-0 {
  min-width: 0;
}

.pointer-events-none {
  pointer-events: none;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════
 * 7. FOOTER
 * ═══════════════════════════════════════════════ */
.footer {
    border-top: 1px solid var(--border);
    background: var(--card);
    margin-top: 3rem;
}
.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    color: var(--tertiary);
    font-size: 0.75rem;
}
.footer-link {
    color: var(--tertiary);
    text-decoration: none;
    transition: color 0.15s;
}
.footer-link:hover {
    color: var(--primary);
    opacity: 1;
}
