:root {
    color-scheme: light;
    --text: #21313f;
    --muted: #65798a;
    --dim: #485f70;
    --soft: rgba(255, 255, 255, 0.74);
    --line: rgba(38, 77, 93, 0.14);
    --teal: #087f8c;
    --teal-hover: #0b6f7a;
    --blue: #2f80ed;
    --coral: #e76f51;
    --amber: #f2b84b;
    --shadow: 0 24px 60px rgba(18, 54, 69, 0.18);
    --backdrop-overlay: rgba(244, 251, 255, 0.24);
    --tag-bg: rgba(255, 255, 255, 0.62);
    --tag-text: #1f6470;
    --card-bg: rgba(255, 255, 255, 0.58);
    --card-hover-bg: rgba(255, 255, 255, 0.86);
    --nav-bg: #f8fafc;
    --primary-bg: #38b2ac;
    --primary-hover: #319795;
}

[data-theme="dark"] {
    color-scheme: dark;
    --text: #e1e7ed;
    --muted: #94a3b8;
    --dim: #64748b;
    --soft: rgba(15, 23, 42, 0.82);
    --line: rgba(255, 255, 255, 0.08);
    --teal: #2dd4bf;
    --teal-hover: #14b8a6;
    --blue: #60a5fa;
    --coral: #fb7185;
    --amber: #fbbf24;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
    --backdrop-overlay: rgba(15, 23, 42, 0.55);
    --tag-bg: rgba(255, 255, 255, 0.08);
    --tag-text: #2dd4bf;
    --card-bg: rgba(30, 41, 59, 0.5);
    --card-hover-bg: rgba(51, 65, 85, 0.65);
    --nav-bg: #1e293b;
    --primary-bg: #1a4d3c;
    --primary-hover: #246d55;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: Inter, "Noto Sans SC", "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        linear-gradient(135deg, rgba(9, 93, 112, 0.28), rgba(245, 184, 75, 0.12)),
        url("https://api.dujin.org/bing/1920.php") center / cover fixed no-repeat;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: color 300ms ease;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: var(--backdrop-overlay);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    pointer-events: none;
    z-index: 0;
    transition: background 300ms ease;
}

/* Noise Texture Overlay */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

a {
    color: inherit;
}

.controls-group {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 100;
    display: flex;
    gap: 10px;
}

.theme-toggle,
.language-switch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 11px;
    color: var(--text);
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(18, 54, 69, 0.10);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    font-size: 0.88rem;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    transition: all 180ms ease;
}

.theme-toggle {
    width: 40px;
    padding: 0;
    font-size: 1.1rem;
}

.theme-toggle:hover,
.language-switch:hover {
    color: white;
    background: var(--teal);
    transform: translateY(-1px);
}

.theme-toggle .ri-sun-line,
[data-theme="dark"] .theme-toggle .ri-moon-line {
    display: none;
}

[data-theme="dark"] .theme-toggle .ri-sun-line {
    display: block;
}

.page-backdrop {
    position: fixed;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.32)),
        linear-gradient(135deg, rgba(8, 127, 140, 0.15), rgba(231, 111, 81, 0.08));
    pointer-events: none;
    z-index: 0;
    transition: opacity 300ms ease;
}

[data-theme="dark"] .page-backdrop {
    opacity: 0.4;
}

.home-shell,
.page-shell,
.error-shell {
    position: relative;
    z-index: 1;
}

.home-shell {
    width: min(1120px, calc(100% - 40px));
    margin: auto;
    padding: 44px 0 24px;
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.75fr);
    gap: 18px;
    align-items: stretch;
}

.hero-panel,
.side-panel,
.identity-panel,
.content-panel,
.error-shell {
    background: var(--soft);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.hero-panel {
    min-height: 560px;
    padding: 52px;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.side-panel {
    padding: 28px;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--teal);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

.hero-panel h1 {
    max-width: 780px;
    margin-bottom: 18px;
    font-size: 3.1rem;
    line-height: 1.1;
    letter-spacing: 0;
}

#dynamic-greeting {
    color: var(--blue);
}

.hero-copy,
.lead,
.identity-copy,
.error-copy {
    color: var(--dim);
    line-height: 1.8;
}

.hero-copy {
    max-width: 660px;
    margin-bottom: 28px;
    font-size: 1.08rem;
}

.quote-box {
    max-width: 680px;
    margin-bottom: 28px;
    padding: 16px 18px;
    border-left: 4px solid var(--coral);
    background: var(--card-bg);
    border-radius: 8px;
}

.quote-text {
    margin: 0;
    color: var(--text);
    line-height: 1.7;
}

.quote-from {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.88rem;
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.quick-link,
.note-grid a,
.journey-grid article,
.button-link {
    border: 1px solid var(--line);
    border-radius: 8px;
    text-decoration: none;
    transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.quick-link {
    min-height: 96px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--card-bg);
}

.quick-link i {
    color: var(--teal);
    font-size: 1.35rem;
}

.quick-link strong,
.quick-link small {
    display: block;
}

.quick-link small {
    margin-top: 4px;
    color: var(--muted);
}

.quick-link:hover,
.note-grid a:hover,
.journey-grid article:hover,
.button-link:hover {
    transform: translateY(-3px);
    background: var(--card-hover-bg);
    border-color: var(--teal);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.2);
}

.quick-link:focus-visible,
.note-grid a:focus-visible,
.button-link:focus-visible,
.back-link:focus-visible,
.link-row a:focus-visible {
    outline: 3px solid rgba(47, 128, 237, 0.25);
    outline-offset: 3px;
}

.profile-mini {
    display: flex;
    gap: 14px;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.profile-mini img,
.avatar {
    border-radius: 50%;
    border: 4px solid var(--soft);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.15);
    background: var(--soft);
    object-fit: cover;
}

.profile-mini strong,
.profile-mini span {
    display: block;
}

.profile-mini strong {
    font-size: 1.1rem;
}

.profile-mini span {
    margin-top: 3px;
    color: var(--muted);
}

.now-block h2,
.section-block h2 {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
    color: var(--teal);
    font-size: 1.05rem;
    letter-spacing: 0;
}

.now-block ul {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
    line-height: 1.75;
}

.link-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.link-row.center {
    justify-content: center;
}

.link-row a {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    background: var(--card-bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    text-decoration: none;
    transition: all 180ms ease;
}

.link-row a:hover {
    color: white;
    background: var(--teal) !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.page-shell {
    width: min(1060px, calc(100% - 40px));
    margin: auto;
    padding: 44px 0 24px;
}

.about-shell {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.compact-shell {
    width: min(900px, calc(100% - 40px));
}

.back-link {
    grid-column: 1 / -1;
    width: fit-content;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    color: var(--text);
    background: var(--nav-bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    text-decoration: none;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 180ms ease;
}

.back-link:hover {
    transform: translateX(-4px);
    background: var(--teal);
    color: white;
    border-color: var(--teal);
}

.identity-panel,
.content-panel {
    border-radius: 18px;
}

.identity-panel {
    padding: 34px 28px;
    text-align: center;
}

.identity-panel h1 {
    margin-bottom: 8px;
    font-size: 2rem;
}

.role {
    width: fit-content;
    margin: 0 auto 18px;
    padding: 5px 12px;
    color: var(--teal);
    background: rgba(8, 127, 140, 0.10);
    border-radius: 8px;
    font-weight: 700;
}

.identity-copy {
    margin-bottom: 22px;
}

.content-panel {
    padding: 36px;
}

.content-panel.wide {
    margin-top: 16px;
}

.page-title {
    margin-bottom: 14px;
    font-size: 2.4rem;
    line-height: 1.18;
}

.lead {
    max-width: 680px;
    margin-bottom: 28px;
}

.section-block + .section-block {
    margin-top: 30px;
    padding-top: 26px;
    border-top: 1px solid var(--line);
}

.section-block p {
    color: var(--dim);
    line-height: 1.85;
}

.section-block p:last-child {
    margin-bottom: 0;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tag-list span {
    padding: 7px 12px;
    color: var(--tag-text);
    background: var(--tag-bg);
    border: 1px solid rgba(8, 127, 140, 0.18);
    border-radius: 8px;
    font-weight: 700;
}

.media-strip {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    padding: 16px;
    background: var(--card-bg);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.album-art {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    background: #dfeaf0 url("https://p1.music.126.net/htu_O310vZDAFZJLR-egvw==/109951172488087391.jpg") center / cover no-repeat;
}

.media-strip strong,
.media-strip span {
    display: block;
}

.media-strip span {
    margin-top: 4px;
    color: var(--muted);
}

.media-strip > i {
    color: var(--coral);
    font-size: 1.8rem;
}

.note-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.note-grid a {
    padding: 16px;
    background: var(--card-bg);
}

.note-grid strong,
.note-grid span {
    display: block;
}

.note-grid span {
    margin-top: 6px;
    color: var(--muted);
    line-height: 1.65;
}

.journey-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}

.journey-grid article {
    min-height: 180px;
    padding: 20px;
    background: var(--card-bg);
}

.journey-grid i {
    color: var(--coral);
    font-size: 1.7rem;
}

.journey-grid strong,
.journey-grid span {
    display: block;
}

.journey-grid strong {
    margin: 28px 0 8px;
    font-size: 1.1rem;
}

.journey-grid span {
    color: var(--muted);
    line-height: 1.7;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.action-row.left {
    justify-content: flex-start;
}

.button-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 15px;
    background: var(--card-bg);
    font-weight: 800;
}

.button-link.primary {
    color: white;
    background: var(--primary-bg);
    border-color: rgba(255, 255, 255, 0.1);
}

.button-link.primary:hover {
    background: var(--primary-hover);
}

.error-shell {
    width: min(560px, calc(100% - 40px));
    margin: auto;
    padding: 48px;
    border-radius: 18px;
    text-align: center;
}

.error-shell h1 {
    margin: 0 0 10px;
    color: var(--blue);
    font-size: 6.5rem;
    line-height: 1;
}

.error-title {
    margin-bottom: 10px;
    font-size: 1.25rem;
    font-weight: 800;
}

.error-copy {
    margin-bottom: 28px;
}

.site-footer {
    position: relative;
    z-index: 1;
    width: min(1120px, calc(100% - 40px));
    margin: 0 auto 20px;
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 0.86rem;
}

.site-footer a {
    text-decoration: none;
}

/* --- Scattered Fragments Layout --- */
.fragments-container {
    position: relative;
    width: 100%;
    min-height: 600px;
    margin-top: 40px;
    /* Optional: uncomment below for a subtle grid background */
    /* background-image: radial-gradient(var(--line) 1px, transparent 1px);
    background-size: 20px 20px; */
}

.fragment {
    position: absolute;
    width: min(280px, 90vw); /* Keeps it responsive */
    padding: 16px;
    background: var(--card-bg);
    border: 1px solid var(--line);
    border-radius: 4px; /* Less rounded, more paper-like */
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s ease, z-index 0s;
    cursor: pointer;
    /* We will use JS to set top, left, and initial rotate */
}

[data-theme="dark"] .fragment {
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
    background: rgba(30, 41, 59, 0.85); /* Slightly more solid in dark mode */
}

.fragment:hover {
    transform: scale(1.05) rotate(0deg) !important; /* Stand up straight when hovered */
    z-index: 100 !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    border-color: var(--teal);
}

[data-theme="dark"] .fragment:hover {
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

/* Fragment Types */
.fragment.type-photo {
    padding-bottom: 24px; /* Polaroid bottom heavy */
}

.fragment-img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: var(--soft);
    border-radius: 2px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
}

.fragment-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
}

.fragment-header i {
    color: var(--teal);
    font-size: 1.2rem;
}

.fragment-location {
    font-weight: 700;
    color: var(--text);
    font-size: 0.95rem;
}

.fragment-date {
    font-size: 0.75rem;
    color: var(--muted);
    font-family: monospace;
}

.fragment-text {
    font-size: 0.9rem;
    color: var(--dim);
    line-height: 1.6;
    margin: 0;
}

/* Fallback for when JS is disabled or screen is too small */
@media (max-width: 768px) {
    .fragments-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 20px;
        min-height: auto;
    }
    
    .fragment {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        transform: rotate(0) !important;
        width: 100%;
    }
}

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

@media (max-width: 1024px) {
    body {
        background-attachment: scroll;
    }

    .home-shell,
    .about-shell {
        grid-template-columns: 1fr;
    }

    .hero-panel {
        min-height: auto;
    }

    .quick-grid,
    .journey-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 620px) {
    .home-shell,
    .page-shell,
    .compact-shell,
    .error-shell,
    .site-footer {
        width: min(100% - 28px, 1120px);
    }

    .home-shell,
    .page-shell {
        padding-top: 58px;
    }

    .language-switch {
        top: 14px;
        right: 14px;
    }

    .hero-panel,
    .side-panel,
    .identity-panel,
    .content-panel,
    .error-shell {
        border-radius: 14px;
    }

    .hero-panel,
    .content-panel,
    .error-shell {
        padding: 26px 20px;
    }

    .hero-panel h1 {
        font-size: 2.25rem;
    }

    .page-title {
        font-size: 1.9rem;
    }

    .quick-grid,
    .note-grid,
    .journey-grid {
        grid-template-columns: 1fr;
    }

    .quick-link {
        min-height: 76px;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 14px;
    }

    .quick-link i {
        width: 34px;
        text-align: center;
    }

    .media-strip {
        grid-template-columns: 58px minmax(0, 1fr) auto;
        gap: 12px;
        padding: 12px;
    }

    .album-art {
        width: 58px;
        height: 58px;
    }

    /* Pagination Controls */
    .pagination {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 12px;
        margin: 40px 0 20px;
    }

    .pagination-btn {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 8px 16px;
        background: var(--card-bg);
        border: 1px solid var(--line);
        border-radius: 8px;
        color: var(--text);
        font-weight: 700;
        cursor: pointer;
        transition: all 180ms ease;
        user-select: none;
    }

    .pagination-btn:hover:not(:disabled) {
        background: var(--teal);
        color: white;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .pagination-btn:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }

    .page-info {
        font-size: 0.95rem;
        font-weight: 600;
        color: var(--dim);
    }

    .error-shell h1 {
        font-size: 5rem;
    }}
