: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);
    --scanline: rgba(0, 0, 0, 0.06);
    --panel: #0c0c0e;
    --panel-text: #ececef;
    --panel-muted: #8b8b92;
    --panel-accent: #e6e6ea;
    --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);
    --scanline: rgba(255, 255, 255, 0.07);
    --panel: #050507;
    --panel-text: #e9e9ec;
    --panel-muted: #7e7e87;
    --panel-accent: #e6e6ea;
}

* {
    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);
    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;
    padding: 2.5rem 1rem 1rem;
}

.container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    max-width: 1200px;
    flex: 5 1 100%;
    align-self: center;
    gap: 2rem;
}

.articles {
    max-width: 800px;
    width: 100%;
}

.section-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.section-head h2 {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 1rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    white-space: nowrap;
}
.section-head .mono-tag {
    color: var(--accent);
}
.section-head .line {
    flex: 1;
    height: 1px;
    background: var(--line);
}

/* ---------- cards ---------- */
.card {
    position: relative;
    display: flex;
    flex-direction: row;
    margin: 1.5rem 0;
    background-color: var(--surface);
    border: 1px solid var(--line);
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.card::before,
.card::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    z-index: 2;
    pointer-events: none;
}
.card::before {
    top: 0;
    left: 0;
    border-top: 2px solid var(--accent);
    border-left: 2px solid var(--accent);
}
.card::after {
    bottom: 0;
    right: 0;
    border-bottom: 2px solid var(--accent);
    border-right: 2px solid var(--accent);
}
.card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 16px 36px -16px var(--glow);
}
.card .scanline {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: linear-gradient(
        transparent 0,
        transparent calc(50% - 1px),
        var(--scanline) 50%,
        transparent calc(50% + 1px)
    );
    transform: translateY(-100%);
    transition: transform 0.55s ease;
}
.card:hover .scanline {
    transform: translateY(100%);
}

.card .thumbnail {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    max-width: 40%;
    min-width: 220px;
    overflow: hidden;
}
.card .thumbnail img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    object-position: center;
    background: var(--bg) url('../img/migu-loading.gif') center/cover no-repeat;
    transition: transform 0.35s ease;
    border: 1px solid var(--line);
}
.card:hover .thumbnail img {
    transform: scale(1.04);
}
.card .thumb-fallback {
    height: 150px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    width: 100%;
}
.card a {
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
}
.card .card-txt {
    padding: 1.25rem 1.25rem 1.25rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}
.card .card-txt h3 {
    margin: 0;
    font-size: 1.2rem;
    line-height: 1.35;
    transition: color 0.2s ease;
}
.card .card-txt a:hover h3 {
    color: var(--accent);
}
.post-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}
.post-meta .sep {
    color: var(--accent);
}
.post-meta .date {
    color: var(--accent-soft);
}
.card .card-txt .desc {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.6;
    margin: 0.2rem 0 0.5rem;
}
.read-more {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    width: fit-content;
}
.read-more .arrow {
    transition: transform 0.25s ease;
    color: var(--accent);
}
.card:hover .read-more .arrow {
    transform: translateX(5px);
}

/* ---------- aside ---------- */
aside {
    position: sticky;
    padding: 0;
    top: 96px;
    max-width: 300px;
    width: 100%;
    height: 100%;
    text-align: center;
    font-family: var(--font-body);
}
aside .profile-aside {
    position: relative;
    background-color: var(--surface);
    padding: 2rem;
    border: 1px solid var(--line);
    min-width: 300px;
}
aside .profile-aside::before,
aside .profile-aside::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    pointer-events: none;
}
aside .profile-aside::before {
    top: -1px;
    left: -1px;
    border-top: 2px solid var(--accent);
    border-left: 2px solid var(--accent);
}
aside .profile-aside::after {
    bottom: -1px;
    right: -1px;
    border-bottom: 2px solid var(--accent);
    border-right: 2px solid var(--accent);
}
.id-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1.25rem;
}
.id-label .tag {
    padding: 2px 8px;
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 3px;
}
.avatar-wrap {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 0 auto 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.avatar-wrap .ring {
    position: absolute;
    inset: -8px;
    border: 1px dashed var(--muted);
    border-radius: 50%;
    animation: spin 12s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
aside img.avatar {
    max-width: 100%;
    width: 128px;
    height: 128px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent);
    box-shadow: 0 0 0 4px var(--surface), 0 0 24px var(--glow);
}
aside h2 {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin: 0 0 1rem;
}
.profile-info {
    border-top: 1px solid var(--line);
    padding: 1rem 0;
    margin: 0;
}
.profile-info p {
    margin: 0.45rem 0;
    font-size: 0.9rem;
    color: var(--muted);
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
}
.profile-info p .k {
    color: var(--accent-soft);
}
.icon-button {
    display: flex;
    flex-direction: row;
    justify-content: space-evenly;
    padding-top: 1rem;
}
.icon-button a {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    width: 46px;
    height: 46px;
    border: 1px solid var(--line);
    border-radius: 8px;
    transition: all 0.25s ease;
}
.icon-button a:hover {
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 16px var(--glow);
    transform: translateY(-3px);
}
.term-box {
    margin-top: 1.25rem;
    text-align: left;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.9rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.7;
    color: var(--panel-muted);
}
.term-box .term-title {
    color: var(--panel-accent);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 0.65rem;
    border-bottom: 1px solid var(--panel-muted);
    padding-bottom: 0.4rem;
    margin-bottom: 0.6rem;
    display: block;
}
.term-box .prompt {
    color: var(--panel-accent);
    margin-right: 0.3rem;
}
.term-box .cmd {
    color: var(--panel-text);
    min-height: 1.2em;
}
.term-box .out {
    color: var(--panel-muted);
    margin: 0;
}
.cursor-block {
    display: inline-block;
    width: 8px;
    height: 1.05em;
    margin-left: 3px;
    vertical-align: text-bottom;
    background: var(--panel-accent);
    animation: blink 1s infinite;
}

/* glitch effect (monochrome) */
.glitch-item {
    position: relative;
    display: inline-block;
}
.glitch-item::before,
.glitch-item::after {
    content: attr(data-text);
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
}
.glitch-item.glitching::before {
    opacity: 1;
    left: 2px;
    text-shadow: 2px 0 #ffffff, -2px 0 #9aa0ab;
    clip-path: inset(10% 0 55% 0);
    animation: glitch-slice 0.4s infinite linear alternate;
}
.glitch-item.glitching::after {
    opacity: 1;
    left: -2px;
    text-shadow: -2px 0 #ffffff;
    clip-path: inset(60% 0 5% 0);
    animation: glitch-slice2 0.55s infinite linear alternate;
}
@keyframes glitch-slice {
    0% { clip-path: inset(10% 0 55% 0); transform: translateX(0); }
    50% { clip-path: inset(40% 0 20% 0); transform: translateX(-3px); }
    100% { clip-path: inset(70% 0 5% 0); transform: translateX(3px); }
}
@keyframes glitch-slice2 {
    0% { clip-path: inset(60% 0 5% 0); transform: translateX(0); }
    50% { clip-path: inset(15% 0 60% 0); transform: translateX(3px); }
    100% { clip-path: inset(40% 0 35% 0); transform: translateX(-3px); }
}

/* ---------- 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);
}

/* ---------- 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;
    }
    .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;
        flex-flow: column-reverse;
        gap: 0;
    }
    main {
        padding: 1.5rem 0.75rem 0.5rem;
    }
    .articles {
        min-width: 100%;
    }
    .card {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        margin: 0.75rem 0;
        align-items: stretch;
    }
    .card .thumbnail {
        max-width: 100%;
        min-width: 0;
        width: 100%;
        padding: 0.75rem;
    }
    .card .thumbnail img {
        height: auto;
        max-height: 200px;
        object-fit: cover;
        width: 100%;
    }
    .card .card-txt {
        padding: 0.75rem;
    }
    aside {
        height: auto;
        position: relative;
        order: -1;
        align-self: center;
        top: 0;
        max-width: 100%;
        margin: 0.5rem 0;
    }
    aside .profile-aside {
        min-width: 0;
    }
    aside .icon-button {
        justify-content: center;
        gap: 1rem;
    }
    .modal-content {
        width: 90%;
    }
    #searchForm {
        flex-direction: column;
    }
    #searchForm input[type="text"] {
        width: 100%;
    }
}

@media (min-width: 769px) and (max-width: 1200px) {
    * {
        scroll-padding-top: 0px;
    }
    .container {
        display: flex;
        flex-wrap: wrap;
        flex-direction: column;
        flex-flow: column-reverse;
        gap: 0;
        justify-content: center;
    }
    .articles {
        max-width: 80%;
        align-self: center;
    }
    aside {
        height: auto;
        position: relative;
        order: -1;
        align-self: center;
        top: 0;
        max-width: 100%;
        margin: 0.5rem 0;
    }
    aside .profile-aside {
        min-width: 0;
    }
    aside .icon-button {
        justify-content: center;
        gap: 1rem;
    }
}