:root {
    color-scheme: light;

    --bg: #faf6ef;
    --surface: #fffdf9;
    --surface-2: #f3ead9;
    --surface-translucent: rgba(255, 253, 249, 0.86);
    --text: #3d2f23;
    --muted: rgba(61, 47, 35, 0.75);
    --accent: #7c5c3e;
    --accent-soft: #e5d8c3;
    --line: #e7dbc9;
    --code-bg: #2f241a;
    --code-text: #f7efe3;
    --shadow: rgba(61, 47, 35, 0.05);
    --shadow-hover: rgba(61, 47, 35, 0.12);
    --focus: #7c5c3e;

    --btn-bg: #7c5c3e;
    --btn-text: #ffffff;
    --btn-2-bg: #b09a7c;
    --btn-2-text: #221a12;
    --btn-danger-bg: #a64032;
    --btn-danger-text: #ffffff;

    --badge-seed: #f4e8d0;
    --badge-sprout: #dff0d8;
    --badge-evergreen: #d8eaf6;
    --badge-compost: #e6ddd2;
    --badge-private: #ece1d2;
    --badge-unlisted: #e3e7ea;
    --badge-public: #d8f0dd;

    --chip-bg: #efe6d6;
    --pill-bg: #f3ead9;

    --alert-error-bg: #fbe7e4;
    --alert-error-text: #8c2f22;
    --alert-error-line: #f0b9b0;
    --alert-success-bg: #e9f4e4;
    --alert-success-text: #2f6323;
    --alert-success-line: #bcd8b2;
    --alert-info-bg: #e8f0f7;
    --alert-info-text: #31536b;
    --alert-info-line: #c8d9e8;

    --fs-hero: clamp(2.6rem, 6vw, 4rem);
    --fs-h1: clamp(1.9rem, 4.5vw, 2.6rem);
    --fs-h2: clamp(1.35rem, 3vw, 1.7rem);
    --fs-body: 1.0625rem;
    --fs-small: 0.9rem;
    --space-section: clamp(44px, 7vw, 72px);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --bg: #221a14;
        --surface: #2b221b;
        --surface-2: #362b22;
        --surface-translucent: rgba(43, 34, 27, 0.86);
        --text: #f0e6d8;
        --muted: rgba(240, 230, 216, 0.72);
        --accent: #d0a068;
        --accent-soft: #4a3b2e;
        --line: #4a3b2e;
        --code-bg: #1b1410;
        --code-text: #f7efe3;
        --shadow: rgba(0, 0, 0, 0.35);
        --shadow-hover: rgba(0, 0, 0, 0.55);
        --focus: #e0b98a;

        --btn-bg: #c99a63;
        --btn-text: #221a14;
        --btn-2-bg: #6b5844;
        --btn-2-text: #f0e6d8;
        --btn-danger-bg: #b0503f;
        --btn-danger-text: #ffe9e4;

        --badge-seed: rgba(246, 196, 69, 0.16);
        --badge-sprout: rgba(140, 200, 120, 0.16);
        --badge-evergreen: rgba(120, 180, 220, 0.16);
        --badge-compost: rgba(180, 160, 140, 0.16);
        --badge-private: rgba(200, 180, 150, 0.14);
        --badge-unlisted: rgba(160, 170, 180, 0.14);
        --badge-public: rgba(140, 210, 150, 0.16);

        --chip-bg: rgba(208, 160, 108, 0.16);
        --pill-bg: rgba(240, 230, 216, 0.08);

        --alert-error-bg: rgba(196, 90, 74, 0.18);
        --alert-error-text: #f2b8ad;
        --alert-error-line: rgba(196, 90, 74, 0.40);
        --alert-success-bg: rgba(120, 190, 130, 0.16);
        --alert-success-text: #bfe3b8;
        --alert-success-line: rgba(120, 190, 130, 0.35);
        --alert-info-bg: rgba(110, 160, 200, 0.16);
        --alert-info-text: #bcd6ea;
        --alert-info-line: rgba(110, 160, 200, 0.35);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #221a14;
    --surface: #2b221b;
    --surface-2: #362b22;
    --surface-translucent: rgba(43, 34, 27, 0.86);
    --text: #f0e6d8;
    --muted: rgba(240, 230, 216, 0.72);
    --accent: #d0a068;
    --accent-soft: #4a3b2e;
    --line: #4a3b2e;
    --code-bg: #1b1410;
    --code-text: #f7efe3;
    --shadow: rgba(0, 0, 0, 0.35);
    --shadow-hover: rgba(0, 0, 0, 0.55);
    --focus: #e0b98a;

    --btn-bg: #c99a63;
    --btn-text: #221a14;
    --btn-2-bg: #6b5844;
    --btn-2-text: #f0e6d8;
    --btn-danger-bg: #b0503f;
    --btn-danger-text: #ffe9e4;

    --badge-seed: rgba(246, 196, 69, 0.16);
    --badge-sprout: rgba(140, 200, 120, 0.16);
    --badge-evergreen: rgba(120, 180, 220, 0.16);
    --badge-compost: rgba(180, 160, 140, 0.16);
    --badge-private: rgba(200, 180, 150, 0.14);
    --badge-unlisted: rgba(160, 170, 180, 0.14);
    --badge-public: rgba(140, 210, 150, 0.16);

    --chip-bg: rgba(208, 160, 108, 0.16);
    --pill-bg: rgba(240, 230, 216, 0.08);

    --alert-error-bg: rgba(196, 90, 74, 0.18);
    --alert-error-text: #f2b8ad;
    --alert-error-line: rgba(196, 90, 74, 0.40);
    --alert-success-bg: rgba(120, 190, 130, 0.16);
    --alert-success-text: #bfe3b8;
    --alert-success-line: rgba(120, 190, 130, 0.35);
    --alert-info-bg: rgba(110, 160, 200, 0.16);
    --alert-info-text: #bcd6ea;
    --alert-info-line: rgba(110, 160, 200, 0.35);
}

* {
    box-sizing: border-box;
}

::selection {
    background: var(--accent);
    color: var(--btn-text);
}

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

main:focus {
    outline: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 300;
    background: var(--btn-bg);
    color: var(--btn-text);
    padding: 12px 18px;
    border-radius: 0 0 12px 0;
    text-decoration: none;
    font-weight: 700;
}

.skip-link:focus {
    left: 0;
}

body {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    font-size: var(--fs-body);
}

a {
    color: var(--accent);
}

img {
    max-width: 100%;
    height: auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 80;
    background: var(--surface-translucent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    padding: 14px 24px 12px;
}

.site-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    max-width: 1080px;
    margin: 0 auto 10px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-size: 1.32rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    text-decoration: none;
    color: var(--accent);
}

.brand-icon {
    width: 26px;
    height: 26px;
    flex: none;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.site-nav a,
.link-button {
    color: var(--text);
    text-decoration: none;
    padding: 7px 13px;
    border-radius: 999px;
    transition: background-color 0.15s ease;
}

.site-nav a:hover,
.link-button:hover {
    background: var(--pill-bg);
}

.link-button {
    background: none;
    border: 0;
    font: inherit;
    cursor: pointer;
}

.inline-form {
    display: inline;
}

.theme-menu {
    position: relative;
    display: inline-block;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    cursor: pointer;
    font-size: 1rem;
    list-style: none;
    transition: background-color 0.15s ease;
}

.theme-toggle:hover {
    background: var(--surface-2);
}

.theme-toggle::-webkit-details-marker {
    display: none;
}

.theme-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 60;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px;
    display: grid;
    gap: 6px;
    min-width: 130px;
    box-shadow: 0 12px 30px var(--shadow);
}

.theme-option {
    border: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
}

.theme-option:hover {
    background: var(--surface-2);
}

.theme-option.active {
    background: var(--pill-bg);
    font-weight: 700;
}

.site-search {
    display: flex;
    gap: 8px;
    max-width: 1080px;
    margin: 0 auto;
}

.site-search input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

.site-search button,
.button {
    border: 0;
    background: var(--btn-bg);
    color: var(--btn-text);
    padding: 10px 18px;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.15s ease, transform 0.06s ease;
}

.button:active {
    transform: scale(0.98);
}

.button-ghost {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.button-ghost:hover {
    background: var(--pill-bg);
}

.site-main {
    width: min(1080px, calc(100% - 40px));
    margin: 0 auto;
    padding: 26px 0 60px;
}

.site-footer {
    border-top: 1px solid var(--line);
    background: var(--surface);
    padding: 44px 24px 26px;
}

.footer-grid {
    max-width: 1080px;
    margin: 0 auto 28px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 30px;
}

.footer-brand {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--accent);
    margin-bottom: 8px;
}

.footer-col p {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.footer-title {
    font-weight: 700;
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.footer-col a {
    display: block;
    color: var(--muted);
    text-decoration: none;
    padding: 3px 0;
    transition: color 0.15s ease;
}

.footer-col a:hover {
    color: var(--accent);
}

.footer-base {
    max-width: 1080px;
    margin: 0 auto;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.85rem;
    text-align: center;
}

.alert {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 18px;
}

.alert-error {
    background: var(--alert-error-bg);
    color: var(--alert-error-text);
    border: 1px solid var(--alert-error-line);
}

.alert-success {
    background: var(--alert-success-bg);
    color: var(--alert-success-text);
    border: 1px solid var(--alert-success-line);
}

.alert-info {
    background: var(--alert-info-bg);
    color: var(--alert-info-text);
    border: 1px solid var(--alert-info-line);
}

.hero {
    padding: clamp(40px, 8vw, 84px) 0 10px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--pill-bg);
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: 20px;
}

.hero h1 {
    margin: 0 0 14px;
    font-size: var(--fs-hero);
    line-height: 1.05;
    letter-spacing: -0.02em;
}

.hero-tagline {
    margin: 0 0 24px;
    font-size: clamp(1.05rem, 2.2vw, 1.3rem);
    color: var(--muted);
    max-width: 56ch;
}

.hero-facts {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 26px;
}

.hero-fact {
    padding: 9px 15px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    font-size: var(--fs-small);
    color: var(--muted);
}

.hero-fact strong {
    color: var(--text);
    font-size: 1.08rem;
    margin-right: 6px;
}

.hero-cta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.hero-cta .button {
    padding: 12px 22px;
    border-radius: 12px;
}

.section {
    margin: var(--space-section) 0;
}

.section h2 {
    margin: 0 0 20px;
    font-size: var(--fs-h2);
    letter-spacing: -0.01em;
}

.page-head {
    padding: 26px 0 10px;
}

.page-head h1 {
    margin: 0 0 10px;
    font-size: var(--fs-h1);
    line-height: 1.12;
    letter-spacing: -0.015em;
}

.page-head p {
    margin: 0;
    color: var(--muted);
    font-size: 1.05rem;
    max-width: 62ch;
}

.space-map {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 18px;
}

.space-card {
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 8px 20px var(--shadow);
    transform: rotate(-0.3deg);
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.space-card:nth-child(even) {
    transform: rotate(0.4deg);
}

.space-card:hover {
    transform: rotate(0deg) translateY(-2px);
    box-shadow: 0 12px 28px var(--shadow-hover);
}

.space-card h3 {
    margin: 0 0 8px;
    font-size: 1.2rem;
}

.space-card p {
    margin: 0;
    color: var(--muted);
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.note-card {
    position: relative;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 22px 20px 20px;
    box-shadow: 0 8px 20px var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.note-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 18px;
    right: 18px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--card-accent, transparent);
}

.note-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px var(--shadow-hover);
}

.note-card-cover {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--line);
}

.note-card-title {
    text-decoration: none;
    color: inherit;
    display: block;
}

.note-card-title h3 {
    margin: 0;
    font-size: 1.18rem;
    line-height: 1.35;
    letter-spacing: -0.01em;
}

.note-card-excerpt {
    margin: 0;
    color: var(--muted);
}

.note-card-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: var(--fs-small);
    margin-top: auto;
}

.mood-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--pill-bg);
    text-decoration: none;
    color: var(--text);
    transition: background-color 0.15s ease;
}

.mood-dot-color {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    display: inline-block;
}

.note-card-space {
    color: var(--muted);
}

.note-card-date {
    color: var(--muted);
}

.note-card-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tag-chip {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--chip-bg);
    color: var(--text);
    text-decoration: none;
    font-size: 0.8rem;
    transition: background-color 0.15s ease, transform 0.12s ease;
}

.tag-chip:hover {
    background: var(--accent-soft);
    transform: translateY(-1px);
}

.note-detail {
    max-width: 820px;
    margin: 0 auto;
}

.note-cover {
    width: 100%;
    max-height: 340px;
    object-fit: cover;
    border-radius: 16px;
    border: 1px solid var(--line);
    margin: 0 0 22px;
}

.note-head h1 {
    margin: 0 0 14px;
    font-size: var(--fs-h1);
    line-height: 1.15;
    letter-spacing: -0.015em;
}

.note-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.note-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    border-radius: 999px;
    background: var(--pill-bg);
    text-decoration: none;
    color: var(--text);
    transition: background-color 0.15s ease;
}

.meta-date {
    color: var(--muted);
}

.note-content {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 30px;
    box-shadow: 0 10px 24px var(--shadow);
}

.note-content h1,
.note-content h2,
.note-content h3,
.note-content h4,
.note-content h5,
.note-content h6 {
    line-height: 1.25;
    letter-spacing: -0.01em;
    margin: 1.4em 0 0.6em;
}

.note-content h2 {
    font-size: 1.45rem;
}

.note-content h3 {
    font-size: 1.2rem;
}

.note-content p {
    margin: 0 0 1em;
}

.note-content a {
    color: var(--accent);
}

.note-content img {
    border-radius: 12px;
    border: 1px solid var(--line);
}

.note-content ul,
.note-content ol {
    margin: 0 0 1em;
    padding-left: 24px;
}

.note-content blockquote {
    margin: 0 0 1em;
    padding: 14px 18px;
    border-left: 4px solid var(--accent);
    background: var(--pill-bg);
    border-radius: 0 12px 12px 0;
}

.note-content pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 18px;
    border-radius: 14px;
    overflow-x: auto;
    margin: 0 0 1em;
}

.note-content code {
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 0.95em;
}

.note-content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.note-content p code,
.note-content li code {
    background: var(--pill-bg);
    padding: 2px 6px;
    border-radius: 6px;
}

.wikilink {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dashed var(--accent);
}

.wikilink:hover {
    border-bottom-style: solid;
}

.wikilink-muted {
    color: var(--muted);
    border-bottom: 1px dotted var(--muted);
}

.reaction-bar {
    margin-top: 26px;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px dashed var(--line);
    border-radius: 16px;
}

.reaction-title {
    font-weight: 700;
    margin-bottom: 6px;
}

.reaction-bar .muted {
    margin: 0 0 12px;
}

.reaction-form,
.reaction-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.reaction-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--line);
    background: var(--bg);
    border-radius: 999px;
    padding: 7px 13px;
    cursor: pointer;
    font: inherit;
    color: var(--text);
    transition: transform 0.12s ease, background-color 0.12s ease;
}

.reaction-btn:hover {
    background: var(--pill-bg);
    transform: translateY(-1px);
}

.reaction-pill {
    cursor: default;
}

.reaction-pill:hover {
    transform: none;
    background: var(--bg);
}

.reaction-voted,
.reaction-voted:hover {
    background: var(--pill-bg);
    border-color: var(--accent);
}

.reaction-emoji {
    font-size: 1.05rem;
    line-height: 1;
}

.reaction-count {
    font-size: 0.85rem;
    color: var(--muted);
}

.note-links {
    margin-top: 26px;
    display: grid;
    gap: 18px;
}

.note-links-title {
    font-size: 1.1rem;
    margin: 0 0 10px;
}

.note-links-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    display: inline-block;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 0.8rem;
    white-space: nowrap;
}

.badge-seed { background: var(--badge-seed); }
.badge-sprout { background: var(--badge-sprout); }
.badge-evergreen { background: var(--badge-evergreen); }
.badge-compost { background: var(--badge-compost); }
.badge-private { background: var(--badge-private); }
.badge-unlisted { background: var(--badge-unlisted); }
.badge-public { background: var(--badge-public); }

.empty-state {
    padding: 26px;
    background: var(--surface);
    border: 1px dashed var(--line);
    border-radius: 16px;
    color: var(--muted);
}

.search-form.big {
    display: flex;
    gap: 10px;
    margin: 20px 0 10px;
}

.search-form.big input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

.pagination {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 26px;
}

.page-link {
    display: inline-block;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
}

.page-link.current {
    background: var(--btn-bg);
    color: var(--btn-text);
    border-color: var(--btn-bg);
}

.page-link.disabled {
    opacity: 0.45;
}

.page-dots {
    padding: 7px 4px;
    color: var(--muted);
}

.static-page {
    max-width: 820px;
    margin: 0 auto;
}

@media (max-width: 700px) {
    .hero h1 {
        font-size: 2.3rem;
    }

    .note-head h1 {
        font-size: 1.8rem;
    }

    .note-content {
        padding: 20px;
    }

    .site-nav a,
    .link-button,
    .button,
    .tag-chip,
    .meta-pill,
    .mood-badge,
    .page-link,
    .reaction-btn {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .theme-toggle {
        width: 44px;
        height: 44px;
    }

    .site-search {
        flex-direction: column;
    }

    .site-search button {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
    }

    html {
        scroll-behavior: auto !important;
    }

    .note-card:hover,
    .space-card:hover,
    .tag-chip:hover,
    .reaction-btn:hover,
    .button:active {
        transform: none !important;
    }
}