:root {
    color-scheme: light;
    --bg: #f4f4f5;
    --surface: #ffffff;
    --ink: #111113;
    --muted: #6b6b72;
    --line: #e5e5e9;
    --grid: rgba(0, 0, 0, 0.05);
    --accent: #000000;
    --accent-soft: #3a3a40;
    --glow: rgba(0, 0, 0, 0.14);
    --panel: #0c0c0e;
    --panel-text: #ececef;
    --panel-muted: #8b8b92;
    --panel-accent: #e6e6ea;
    --code-bg: #0c0c0e;
    --code-text: #ececef;
    --code-border: #26262b;
    --code-inline-bg: #ededf0;
    --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', 'SF Mono', monospace;
    --font-head: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-body: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0d0d10;
    --surface: #16161a;
    --ink: #f0f0f2;
    --muted: #a1a1a9;
    --line: #2b2b31;
    --grid: rgba(255, 255, 255, 0.045);
    --accent: #ffffff;
    --accent-soft: #c9c9cf;
    --glow: rgba(0, 0, 0, 0.55);
    --panel: #050507;
    --panel-text: #e9e9ec;
    --panel-muted: #7e7e87;
    --panel-accent: #e6e6ea;
    --code-bg: #0a0a0c;
    --code-text: #eaeaea;
    --code-border: #2b2b31;
    --code-inline-bg: #232327;
}

* {
    box-sizing: border-box;
    scroll-padding-top: 70px;
}

body {
    font-family: var(--font-body);
    font-size: 1rem;
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    color: var(--ink);
    word-wrap: break-word;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ---------- status bar ---------- */
.statusbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--panel);
    color: var(--panel-muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    padding: 0.55rem 2rem;
    border-bottom: 1px solid var(--line);
}
.status-tag {
    color: var(--panel-accent);
}
.status-msg {
    margin-left: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
@keyframes blink {
    50% { opacity: 0.25; }
}

/* ---------- nav ---------- */
.nav-container {
    z-index: 9999;
    height: 70px;
    position: sticky;
    top: 0;
    display: flex;
    justify-content: center;
    background-color: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}
.navbar {
    flex: 1 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    color: var(--ink);
}
.nav-logo {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 700;
    padding-inline: 2rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 0;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}
.nav-logo p {
    display: inline-flex;
    align-items: center;
}
.nav-logo .bracket {
    color: var(--muted);
}
.nav-logo .cursor {
    display: inline-block;
    width: 9px;
    height: 1em;
    margin-left: 3px;
    background: var(--accent);
    animation: blink 1.1s infinite;
}
nav ul {
    display: flex;
    list-style-type: none;
    justify-content: flex-end;
    gap: 1rem 1.5rem;
    padding-inline: 2rem;
    align-items: center;
    margin: 0;
}
nav ul li a {
    text-decoration: none;
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 500;
    position: relative;
    padding: 4px 0;
}
nav ul li a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 0;
    background: var(--accent);
    transition: width 0.25s ease;
}
nav ul li a:hover {
    color: var(--accent);
}
nav ul li a:hover::after {
    width: 100%;
}
#searchBtn,
#themeToggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    background: transparent;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 6px;
    transition: all 0.25s ease;
}
#searchBtn:hover,
#themeToggle:hover {
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 14px var(--glow);
}
#searchBtn svg,
#themeToggle svg {
    fill: currentColor;
}
#themeToggle svg.icon-sun {
    fill: none;
    stroke: currentColor;
}
#themeToggle .icon-moon {
    display: block;
}
#themeToggle .icon-sun {
    display: none;
}
html[data-theme="dark"] #themeToggle .icon-moon {
    display: none;
}
html[data-theme="dark"] #themeToggle .icon-sun {
    display: block;
}

/* ---------- headings ---------- */
h1, h2, h3, h4, h5, h6 {
    color: var(--ink);
    font-family: var(--font-head);
    font-weight: 700;
}

/* ---------- layout ---------- */
main {
    display: flex;
    justify-content: center;
}

.container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: 860px;
    flex: 1 1 100%;
    align-self: center;
    gap: 0;
    padding: 2rem 1rem;
    margin: 0 auto;
}

.article-panel {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    padding: clamp(1.25rem, 4vw, 2.5rem);
    width: 100%;
}
.article-panel::before,
.article-panel::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    pointer-events: none;
}
.article-panel::before {
    top: -1px;
    left: -1px;
    border-top: 2px solid var(--accent);
    border-left: 2px solid var(--accent);
}
.article-panel::after {
    bottom: -1px;
    right: -1px;
    border-bottom: 2px solid var(--accent);
    border-right: 2px solid var(--accent);
}

/* ---------- article content ---------- */
.article-head {
    text-align: left;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: 1.75rem;
}
.crumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.crumb .c-sep {
    color: var(--accent);
}
.crumb .c-current {
    color: var(--accent-soft);
}
.article-head h1 {
    margin: 0 0 1.25rem;
    font-size: clamp(1.6rem, 5vw, 2.6rem);
    line-height: 1.2;
}
.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.76rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}
.meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.meta-chip .lbl {
    color: var(--accent);
}
.meta-chip .val {
    color: var(--ink);
}
.article-cover {
    margin-top: 1.5rem;
    text-align: center;
}
.article-cover img {
    width: 100%;
    max-height: 50vh;
    object-fit: contain;
    border: 1px solid var(--line);
}

.article-body {
    line-height: 1.75;
    font-size: 1.02rem;
    color: var(--ink);
}
.article-body p {
    margin: 1.1rem 0;
}
.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4,
.article-body h5,
.article-body h6 {
    margin: 2rem 0 0.75rem;
    line-height: 1.3;
}
.article-body h1 {
    font-size: 1.7rem;
}
.article-body h2 {
    font-size: 1.45rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}
.article-body h3 {
    font-size: 1.2rem;
}
.article-body a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid var(--line);
    transition: border-color 0.2s ease;
}
.article-body a:hover {
    border-bottom-color: var(--accent);
}
.article-body img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--line);
    box-shadow: 0 8px 24px -16px var(--glow);
}
.article-body p img,
.article-body div img {
    display: block;
    margin: 1.5rem auto;
}
.article-body ul,
.article-body ol {
    padding-left: 1.5rem;
}
.article-body li {
    margin: 0.4rem 0;
}
.article-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 1.5rem 0;
    font-size: 0.95rem;
}
.article-body th,
.article-body td {
    border: 1px solid var(--line);
    padding: 0.6rem 0.9rem;
    text-align: left;
}
.article-body th {
    background: var(--bg);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-soft);
}
.article-body tr:nth-child(even) td {
    background: var(--bg);
}

/* ---------- code blocks ---------- */
pre {
    max-width: 100%;
    background-color: var(--code-bg);
    color: var(--code-text);
    padding: 1.1rem 1.25rem;
    overflow-x: auto;
    border: 1px solid var(--code-border);
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: clamp(0.8rem, 2vw, 0.92rem);
    line-height: 1.6;
}
pre code {
    background: none;
    padding: 0;
    border: none;
    color: inherit;
}
code {
    background: var(--code-inline-bg);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 0.88em;
    padding: 0.15em 0.45em;
    border-radius: 4px;
}

blockquote {
    color: var(--muted);
    border-left: 4px solid var(--accent);
    padding: 0.9rem 1.25rem;
    margin: 1.5rem 0;
    background: var(--surface);
    border-radius: 0 6px 6px 0;
    font-style: italic;
    box-shadow: inset 0 0 20px var(--glow);
}
html[data-theme="dark"] blockquote {
    background: #1c1c22;
    box-shadow: none;
    border-left-color: var(--accent);
}
blockquote footer {
    margin-top: 10px;
    font-size: 0.9em;
    color: var(--muted);
}
hr {
    border: none;
    height: 1px;
    background: var(--line);
    margin: 2rem 0;
}

/* ---------- more articles ---------- */
.more-articles {
    margin-top: 2.5rem;
    padding-top: 1.75rem;
    border-top: 1px solid var(--line);
}
.more-articles h4 {
    margin: 0 0 1rem;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.more-articles h4 .t {
    color: var(--accent);
}
.more-articles ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.more-articles li {
    margin: 0.5rem 0;
    border-left: 2px solid var(--line);
    padding-left: 0.9rem;
    transition: border-color 0.2s ease;
}
.more-articles li:hover {
    border-left-color: var(--accent);
}
.more-articles a {
    color: var(--muted);
    text-decoration: none;
    font-weight: 400;
    font-size: 0.95rem;
    transition: color 0.2s ease;
}
.more-articles a:hover {
    color: var(--accent);
}

/* ---------- footer ---------- */
footer {
    height: auto;
    margin-top: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    padding: 1.4rem 1em;
    background-color: var(--surface);
    color: var(--muted);
    border-top: 1px solid var(--line);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.12em;
}
footer .ftag {
    color: var(--accent);
}
.icon-button {
    display: flex;
    flex-direction: row;
    gap: 1.5rem;
}
.icon-button a {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--panel-muted);
    transition: color 0.25s ease, transform 0.25s ease;
}
.icon-button a:hover {
    color: var(--panel-accent);
    transform: translateY(-3px);
}

/* ---------- modal ---------- */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
}
.modal-container {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(6px);
    background-color: color-mix(in srgb, var(--bg) 65%, transparent);
    padding: 1rem;
}
.modal-content {
    position: relative;
    background-color: var(--surface);
    width: 600px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    border: 1px solid var(--accent);
    box-shadow: 0 24px 64px -24px var(--glow);
}
.modal-content::before,
.modal-content::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    pointer-events: none;
}
.modal-content::before {
    top: -1px;
    left: -1px;
    border-top: 3px solid var(--accent);
    border-left: 3px solid var(--accent);
}
.modal-content::after {
    bottom: -1px;
    right: -1px;
    border-bottom: 3px solid var(--accent);
    border-right: 3px solid var(--accent);
}
.modal-title {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 1rem;
}
#searchForm {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    width: 100%;
    gap: 0.75rem;
}
#searchForm input[type="text"] {
    width: 80%;
    padding: 12px 14px;
    background-color: var(--bg);
    color: var(--ink);
    font-family: var(--font-mono);
    border: 1px solid var(--line);
    border-radius: 4px;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
#searchForm input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--glow);
}
#searchForm button {
    padding: 12px 20px;
    background-color: var(--accent);
    color: var(--surface);
    border: 1px solid var(--accent);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.25s;
}
#searchForm button:hover {
    background-color: var(--accent-soft);
    border-color: var(--accent-soft);
    box-shadow: 0 0 16px var(--glow);
}
#searchResults {
    max-height: 300px;
    overflow-y: auto;
    width: 100%;
}
#searchResults.visible {
    padding: 1.25rem 0.25rem;
}
#searchResults a {
    text-decoration: none;
}
.search-item {
    padding: 0.9rem 0;
    border-top: 1px dashed var(--line);
    text-align: left;
}
.search-item h3 {
    margin: 0 0 0.3rem;
    font-size: 1rem;
    font-family: var(--font-head);
}
#searchResults a:hover h3 {
    color: var(--accent);
}
.search-item .s-date {
    color: var(--accent-soft);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.search-item p {
    color: var(--muted);
    font-size: 0.88rem;
    margin: 0.3rem 0 0;
    line-height: 1.5;
}

/* ---------- responsive ---------- */
@media (max-width: 768px) {
    * {
        scroll-padding-top: 0px;
    }
    body {
        font-size: 0.95rem;
    }
    .statusbar {
        padding: 0.5rem 1rem;
    }
    .status-msg {
        display: none;
    }
    .nav-container {
        height: auto;
        position: relative;
        padding: 0.6rem 0;
    }
    .navbar {
        flex-direction: column;
        gap: 0.4rem;
    }
    .nav-logo {
        padding-inline: 1rem;
    }
    nav ul {
        padding-inline: 1rem;
        gap: 0.75rem 1rem;
    }
    .container {
        display: flex;
        flex-wrap: wrap;
        flex-direction: column;
        gap: 0;
        padding: 1rem;
        max-width: 100%;
    }
    .article-panel {
        padding: 1.25rem;
    }
    .article-body img {
        max-width: 100%;
    }
    .footer-inner {
        flex-direction: column;
        gap: 1rem;
        padding: 0;
    }
    .modal-content {
        width: 90%;
    }
    #searchForm {
        flex-direction: column;
    }
    #searchForm input[type="text"] {
        width: 100%;
    }
}

.article-body img,
.article-cover img {
    cursor: zoom-in;
}

.lightbox {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    background: color-mix(in srgb, var(--bg) 72%, transparent);
    backdrop-filter: blur(4px);
    padding: 2rem;
}
.lightbox.open {
    display: flex;
}
.lightbox-panel {
    position: relative;
    background: var(--bg);
    border: 1px solid var(--accent);
    box-shadow: 0 24px 64px -24px var(--glow);
    padding: 0.75rem;
}
.lightbox-panel::before,
.lightbox-panel::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    pointer-events: none;
}
.lightbox-panel::before {
    top: -3px;
    left: -3px;
    border-top: 3px solid var(--accent);
    border-left: 3px solid var(--accent);
}
.lightbox-panel::after {
    bottom: -3px;
    right: -3px;
    border-bottom: 3px solid var(--accent);
    border-right: 3px solid var(--accent);
}
.lightbox-panel img {
    display: block;
    max-width: 88vw;
    max-height: 78vh;
    object-fit: contain;
    background: var(--bg);
}
.lightbox-close {
    position: absolute;
    top: -0.9rem;
    right: -0.9rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--accent);
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    z-index: 1;
}
.lightbox-close:hover {
    background: var(--accent);
    color: var(--bg);
}
.lightbox-caption {
    padding-top: 0.6rem;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    color: var(--muted);
    text-transform: uppercase;
}

#oml2d-tips {
    position: fixed !important;
    top: auto !important;
    left: auto !important;
    right: var(--miku-tips-right, 15px) !important;
    bottom: var(--miku-tips-bottom, 300px) !important;
    transform: none !important;
    z-index: 9999;
    width: max-content !important;
    max-width: min(240px, calc(100vw - 32px)) !important;
    min-height: auto !important;
    font-size: 12px !important;
    line-height: 1.45 !important;
    padding: 8px 10px !important;
    border-radius: 4px !important;
}

#oml2d-tips-content {
    display: block !important;
    white-space: normal !important;
    word-break: normal !important;
    text-overflow: clip !important;
    overflow: visible !important;
    -webkit-line-clamp: unset !important;
}