:root {
    color-scheme: light dark;
    --bg: #f7f4ee;
    --surface: #ffffff;
    --surface-soft: #f0ebe2;
    --text: #1f1f1f;
    --muted: #4f4a44;
    --border: #ddd4c8;
    --accent: #6f461f;
    --accent-strong: #4f2f14;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
    --font-main: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --content-width: 820px;
    --listing-width: 980px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121212;
        --surface: #1a1a1a;
        --surface-soft: #202020;
        --text: #e8e8e8;
        --muted: #c2c2c2;
        --border: #303030;
        --accent: #f0c98e;
        --accent-strong: #ffe2b8;
        --shadow: none;
    }
}

html[data-theme="light"] {
    color-scheme: light;
    --bg: #f7f4ee;
    --surface: #ffffff;
    --surface-soft: #f0ebe2;
    --text: #1f1f1f;
    --muted: #4f4a44;
    --border: #ddd4c8;
    --accent: #6f461f;
    --accent-strong: #4f2f14;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #121212;
    --surface: #1a1a1a;
    --surface-soft: #202020;
    --text: #e8e8e8;
    --muted: #c2c2c2;
    --border: #303030;
    --accent: #f0c98e;
    --accent-strong: #ffe2b8;
    --shadow: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-main);
    font-size: 18px;
    line-height: 1.65;
    text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration-thickness: 0.08em; text-underline-offset: 0.18em; }
a:hover, a:focus { color: var(--accent-strong); }
img { max-width: 100%; height: auto; display: block; }

.skip-link {
    position: absolute;
    left: -999px;
    top: 0;
    padding: .75rem 1rem;
    background: var(--surface);
    color: var(--text);
    z-index: 10;
}
.skip-link:focus { left: .5rem; top: .5rem; }

.site-top { border-bottom: 1px solid var(--border); background: var(--bg); }
.top-nav { max-width: 1180px; margin: 0 auto; padding: .75rem 1rem; }
.nav-groups { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.reader-nav, .owner-nav { display: flex; flex-wrap: wrap; align-items: center; gap: .9rem; }
.reader-nav a, .owner-nav a { color: var(--text); text-decoration: none; font-size: .94rem; font-weight: 700; }
.reader-nav a:hover, .owner-nav a:hover { color: var(--accent); }
.menu-toggle {
    display: none;
    width: 100%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 700;
    padding: .55rem .75rem;
    border-radius: .5rem;
}

.site-main { min-height: 70vh; }
.content-shell { width: min(calc(100% - 2rem), var(--content-width)); margin: 0 auto; padding: 2rem 0; }
.listing-shell { width: min(calc(100% - 2rem), var(--listing-width)); }
.page-title, .article-title { margin: 0 0 1.25rem; line-height: 1.12; letter-spacing: -0.02em; }
.page-title { font-size: clamp(2rem, 4vw, 3.1rem); }
.article-title { font-size: clamp(2.15rem, 5vw, 4rem); }

.article-list { display: grid; gap: 1.25rem; }
.article-card {
    padding: 1rem;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: .9rem;
    box-shadow: var(--shadow);
}
.reading-feed-item { display: block; }
.feed-article-header { margin-bottom: 1rem; }

.card-category { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .25rem; }
.card-category a {
    color: var(--accent-strong);
    font-size: .8rem;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
    text-decoration: none;
}
.card-title { margin: 0; font-size: clamp(1.35rem, 3vw, 2rem); line-height: 1.18; }
.card-title a { color: var(--text); text-decoration: none; }
.card-title a:hover { color: var(--accent); }
.card-meta, .article-meta {
    margin-top: .35rem;
    color: var(--muted);
    font-size: .9rem;
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
}
.article-meta { font-size: .95rem; }
.article-meta a { color: var(--accent-strong); }

.article-header { margin-bottom: 1.5rem; }
.article-content { font-size: clamp(1.06rem, 2vw, 1.18rem); line-height: 1.75; }
.article-content p { margin: 0 0 1.25rem; }
.article-content h2, .article-content h3 { line-height: 1.2; margin: 2rem 0 .75rem; }
.article-content blockquote { border-left: 4px solid var(--accent); margin: 1.5rem 0; padding-left: 1rem; color: var(--muted); }
.article-content img, .article-content video, .article-content iframe, .article-content embed, .article-content object {
    border-radius: .9rem;
}
.article-content figure { margin: 1.5rem 0; }
.article-content video { display: block; width: 100%; max-width: 100%; background: #000; }
.article-content iframe, .article-content embed, .article-content object { max-width: 100%; }
.wp-block-embed__wrapper, .wp-video, .wp-video-shortcode { max-width: 100%; }

.share-row { margin-top: .75rem; }
.kumachan-share-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

.kumachan-share {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: .35rem 0 1rem;
    border: 1px solid var(--border);
    background: var(--surface-soft);
    color: var(--text);
    border-radius: 999px;
    padding: .4rem .75rem;
    font: inherit;
    font-size: .86rem;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
}
.kumachan-share:hover, .kumachan-share:focus { border-color: var(--accent); color: var(--accent-strong); }

.post-navigation { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.post-navigation div:last-child { text-align: right; }
.pagination { margin: 2rem 0 0; }
.nav-links { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.nav-links a, .nav-links span { padding: .4rem .7rem; border: 1px solid var(--border); border-radius: .45rem; text-decoration: none; background: var(--surface); }
.nav-links .current { color: var(--muted); }

.search-form { display: flex; gap: .5rem; margin: 1rem 0 2rem; }
.search-form input { flex: 1; min-width: 0; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: .5rem; padding: .65rem .75rem; font: inherit; }
.search-form button { border: 1px solid var(--border); background: var(--surface-soft); color: var(--text); border-radius: .5rem; padding: .65rem .85rem; font: inherit; font-weight: 700; }

.category-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; }
.category-tile { display: flex; justify-content: space-between; gap: .75rem; padding: .9rem 1rem; border: 1px solid var(--border); border-radius: .7rem; text-decoration: none; color: var(--text); background: var(--surface); }
.category-tile strong { color: var(--accent-strong); }
.archive-year { border: 1px solid var(--border); border-radius: .7rem; background: var(--surface); margin-bottom: .75rem; padding: .65rem .9rem; }
.archive-year summary { cursor: pointer; font-weight: 800; }
.archive-year ul { columns: 2; margin: .75rem 0 0; padding-left: 1.2rem; }
.archive-year li { break-inside: avoid; margin-bottom: .25rem; }

.site-footer { border-top: 1px solid var(--border); width: min(calc(100% - 2rem), 1180px); margin: 2rem auto 0; padding: 1.25rem 0 2rem; color: var(--muted); font-size: .92rem; }
.site-footer p { margin: .2rem 0; }
.site-footer a { color: var(--accent-strong); }
.display-tools { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1rem; }
.display-tools label { display: flex; align-items: center; gap: .4rem; }
.display-tools select { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: .4rem; padding: .35rem .45rem; }

.lightbox-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .92); z-index: 9999; padding: 1rem; }
.lightbox-overlay img { max-width: 96vw; max-height: 88vh; object-fit: contain; border-radius: .5rem; }
.lightbox-overlay button { border: 1px solid rgba(255,255,255,.35); background: rgba(0,0,0,.5); color: #fff; font: inherit; border-radius: .5rem; padding: .45rem .7rem; cursor: pointer; }
.lightbox-close { position: fixed; top: 1rem; right: 1rem; }
.lightbox-prev, .lightbox-next { position: fixed; top: 50%; transform: translateY(-50%); font-size: 1.6rem; min-width: 2.5rem; }
.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }

.back-to-top {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
    color: var(--text);
    box-shadow: var(--shadow);
    font: inherit;
    font-weight: 900;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(.5rem);
    transition: opacity .16s ease, transform .16s ease;
    z-index: 999;
}
.back-to-top.is-visible { opacity: 1; pointer-events: auto; transform: translateY(0); }

.screen-reader-text { border: 0; clip: rect(1px, 1px, 1px, 1px); clip-path: inset(50%); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; word-wrap: normal !important; }

@media (max-width: 700px) {
    body { font-size: 17px; }
    .menu-toggle { display: block; }
    .nav-groups { display: none; padding-top: .75rem; align-items: stretch; }
    .nav-groups.is-open { display: block; }
    .reader-nav, .owner-nav { display: grid; gap: .2rem; }
    .reader-nav a, .owner-nav a { padding: .55rem 0; border-bottom: 1px solid var(--border); }
    .owner-nav { margin-top: .5rem; }
    .post-navigation { grid-template-columns: 1fr; }
    .post-navigation div:last-child { text-align: left; }
    .archive-year ul { columns: 1; }
    .search-form { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
