html {
    touch-action: manipulation;
}

@font-face {
    font-family: 'Kazesawa-Regular';
    src: url('https://cdn.rrrosmontis.icu/ttf-1.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://cdn.rrrosmontis.icu/background.jpg');
    background-size: cover;
    background-position: center;
    z-index: -1;
}

body {
    padding-top: 80px;
    min-height: 100vh;
}

.content-info-text a {
    color: rgba(128, 128, 128, 0.8);
    text-decoration: none;
}

.article-title-box a {
    color: white;
}

.content-box a {
    color: black;
    text-decoration: none;
}

@media (max-width: 768px) {
    body::before {
        background-image: url('https://cdn.rrrosmontis.icu/background-mobile.jpg');
    }
}

.topbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background: #ffffff;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5%;
    z-index: 1000;
    gap: 20px;
}

.brand-text {
    font-size: 1.8em;
    color: #2c3e50;
    font-weight: 600;
    letter-spacing: 1.5px;
    font-family: 'Kazesawa-Regular', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-left: auto;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.right-logo {
    height: 45px;
    width: auto;
    transition: transform 0.3s ease;
    cursor: pointer;
}

.right-logo:hover {
    animation: spin 0.5s linear;
}

.dropdown-menu {
    position: absolute;
    right: 0;
    top: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 180px;
    display: none;
    z-index: 1001;
}

.dropdown-menu.active {
    display: block;
    animation: menuSlide 0.3s ease;
}

@keyframes menuSlide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-menu a {
    display: block;
    padding: 12px 20px;
    color: #2c3e50;
    text-decoration: none;
    font-size: 1em;
    transition: background 0.2s ease;
}

.dropdown-menu a:hover {
    background: rgba(44, 62, 80, 0.05);
}

.topbar-nav {
    display: flex;
    gap: 20px;
    order: -1;
    margin-right: 0;
}

.nav-item {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 1.1em;
    color: #2c3e50;
    text-decoration: none;
    position: relative;
    transition: color 0.2s ease;
    padding: 5px 0;
}

.nav-item:hover {
    color: #3498db;
}

.nav-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: #3498db;
    transition: width 0.3s ease;
}

.nav-item:hover::after {
    width: 100%;
}

.additional-box {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border-radius: 20px;
    padding: 40px;
    margin: 0 auto 60px;
    max-width: 1100px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    text-align: left;
}

#line-number {
    font-size: 2.5em;
    margin-bottom: 0.5em;
    color: #2c3e50;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.5s ease;
}

#content-text {
    font-size: 1.8em;
    color: #666;
    min-height: 1.5em;
    letter-spacing: 1px;
    opacity: 1;
}

.typing-cursor {
    display: inline-block;
    width: 3px;
    background: #666;
    margin-left: 2px;
    animation: blink 1s infinite;
}

.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #ffffff;
    padding: 15px 0;
    text-align: center;
    font-size: 0.9em;
    color: #666;
    border-top: 1px solid #eee;
    z-index: 999;
    font-family: 'Kazesawa-Regular', -apple-system, BlinkMacSystemFont, sans-serif;
}

.title-container {
    margin: 0 auto;
    font-weight: bold;
    font-size: 13px;
}

.content-info-text {
    font-size: 14px;
    color: #cccccc;
    text-align: center;
    margin: 0 auto;
}

.article-note {
    background: rgba(128, 128, 128, 0.12);
    border-left: 3px solid #999;
    border-radius: 4px;
    padding: 12px 16px;
    margin: 16px 0 20px 0;
    text-align: left;
    font-size: 0.95em;
    color: #888;
    line-height: 1.6;
}

.article-paragraph {
    text-indent: 2em;
    margin: 0;
}

.custom-hr {
    border: none;
    height: 1px;
    background-color: #ccc;
    width: 40%;
    margin: 20px auto;
    opacity: 0.6;
}

.beian {
    text-decoration: none;
    color: #666;
    font-size: 0.88em;
}

@keyframes fall {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh);
        opacity: 0;
    }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

html {
    scroll-behavior: smooth;
}

.title-container h1 {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 0.3rem;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding: 0 12px;
    scrollbar-width: thin;
    font-size: clamp(1.2rem, 6vw, 2rem);
}

.title-container h1 img {
    height: 1.25em;
    width: auto;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    margin: 0 2px;
}

.title-container {
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: thin;
}

.additional-box .title-container {
    margin-left: 0;
    margin-right: 0;
}

@media (max-width: 480px) {
    .title-container h1 {
        gap: 0.2rem;
        padding: 0 6px;
    }
    .title-container h1 img {
        height: 1.2em;
    }
}

.additional-box h2,
.additional-box .title-container,
.additional-box .content-info-text {
    margin-left: 0;
}

.additional-box p,
.additional-box a:not(.nav-item) {
    margin-left: 2em;
}

.additional-box .content-info-text p {
    margin-left: 0;
    text-align: center;
}

.additional-box .note {
    color: #aaa;
    font-style: italic;
}

.additional-box a {
    color: #aaa;
    font-style: italic;
    text-decoration: underline;
}

.additional-box h2 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.additional-box h2:first-of-type {
    margin-top: 0.2em;
}

.additional-box p {
    margin-bottom: 0.5em;
}

.additional-box .indent-2 {
    margin-left: 4em;
}

.additional-box img {
    display: block;
    margin-left: auto;
    margin-right: auto;
    border-radius: 16px;
    transition: transform 0.2s;
}

.additional-box img:hover {
    transform: scale(1.01);
}

.spacer-end {
    margin-top: 8px;
}

/* Code / URL styling */
.additional-box code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    background: rgba(44, 62, 80, 0.06);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.92em;
    word-break: break-all;
}

.additional-box .indent-2 code {
    font-size: 0.88em;
}

/* Dark code block (CSDN style) */
.code-block {
    background: #1e1e1e;
    border-radius: 8px;
    margin: 0.8em 2em 1.2em 2em;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.code-block .code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #2a2a2a;
    padding: 8px 16px;
    border-bottom: 1px solid #333;
}
.code-block .code-lang {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 12px;
    color: #999;
    letter-spacing: 0.5px;
}
.code-block .code-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 6px;
}
.code-block pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #444 #1e1e1e;
}
.code-block pre code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.7;
    color: #d4d4d4;
    background: none;
    padding: 0;
    border-radius: 0;
    word-break: normal;
    white-space: pre;
}
.code-block .dot-red    { background: #ff5f56; }
.code-block .dot-yellow { background: #ffbd2e; }
.code-block .dot-green  { background: #27ca40; }

@media (max-width: 768px) {
    .code-block {
        margin: 0.6em 0 1em 0;
    }
    .code-block pre code {
        font-size: 11px;
    }
}

@media (min-width: 769px) {
    .fixed-image {
        width: 8%;
        max-width: 150px;
    }
    .title-container h1 {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 1rem;
    }
    .title-container h1::before,
    .title-container h1::after {
        content: '';
        flex: 1;
        max-width: 200px;
        height: 1px;
        background: #aaa;
    }

    .article-layout {
        display: flex;
        align-items: flex-start;
        justify-content: center;
        gap: 24px;
        width: 100%;
        max-width: 1380px;
        margin: 0 auto;
        padding: 0 30px;
    }
    .article-layout > .additional-box {
        flex: 1;
        margin-left: 0;
        margin-right: 0;
        min-width: 0;
    }
    .article-toc {
        position: sticky;
        top: 90px;
        width: 240px;
        flex-shrink: 0;
        align-self: flex-start;
        background: rgba(255, 255, 255, 0.85);
        backdrop-filter: blur(8px);
        border-radius: 16px;
        padding: 24px 20px 40px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
        font-size: 14px;
        line-height: 2;
        min-height: calc(100vh - 250px);
        z-index: 500;
    }
    .article-toc .toc-title {
        font-weight: 700;
        font-size: 16px;
        color: #1a1a1a;
        margin-bottom: 12px;
        padding-bottom: 8px;
        border-bottom: 1px solid #e5e5e5;
        letter-spacing: 1px;
    }
    .article-toc .toc-empty {
        color: #aaa;
        font-size: 14px;
        padding-top: 8px;
    }
    .article-toc ul {
        list-style: none;
        padding: 0;
        margin: 0;
    }
    .article-toc > ul > li {
        margin: 4px 0;
    }
    .article-toc > ul > li > a {
        font-weight: 600;
        font-size: 14px;
        color: #333;
    }
    .article-toc a {
        display: block;
        padding: 2px 0;
        color: #666;
        text-decoration: none;
        transition: color 0.2s;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .article-toc a:hover {
        color: #3370ff;
    }
    .article-toc li > ul {
        padding-left: 14px;
        margin-top: 2px;
        border-left: 1px solid #e8e8e8;
    }
    .article-toc li > ul a {
        font-size: 13px;
        color: #888;
        font-weight: 400;
        padding: 1px 0 1px 8px;
    }
    .article-toc li > ul a:hover {
        color: #3370ff;
    }

}

/* 文章入场动画 */
@keyframes tocSlideIn {
    from { opacity: 0; transform: translateX(-50px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes contentSlideIn {
    from { opacity: 0; transform: translateX(50px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes contentSlideInDown {
    from { opacity: 0; transform: translateY(40px); }
    to   { opacity: 1; transform: translateY(0); }
}
#article-content .article-toc {
    opacity: 0;
}
#article-content .article-toc.anim-enter {
    animation: tocSlideIn 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}
#article-content .additional-box {
    opacity: 0;
}
#article-content .additional-box.anim-enter {
    animation: contentSlideIn 0.5s 0.1s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@media (max-width: 768px) {
    body {
        font-size: 14px;
        padding-top: 80px;
    }

    .topbar {
        height: 55px;
        padding: 0 20px;
        justify-content: center;
    }

    .brand-text {
        font-size: 1.4em;
        text-align: center;
        width: 100%;
    }

    .logo-container,
    .right-logo,
    .dropdown-menu {
        display: none !important;
    }

    .mobile-nav-row {
        display: flex;
        position: fixed;
        top: 55px;
        left: 0;
        width: 100%;
        background: #ffffff;
        border-top: 1px solid #eee;
        border-bottom: 1px solid #eee;
        padding: 10px 0;
        justify-content: center;
        align-items: center;
        gap: 30px;
        z-index: 998;
        box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    }

    .mobile-nav-row .nav-item {
        font-size: 1em;
        color: #2c3e50;
        text-decoration: none;
        position: relative;
        padding: 5px 0;
        margin: 0;
    }

    .additional-box {
        width: 92%;
        max-width: none;
        margin: 0 auto 20px;
        padding: 20px 15px;
    }

    .title-container h1 {
        font-size: clamp(1rem, 5.5vw, 1.7rem);
        display: block;
        white-space: normal;
        overflow-x: visible;
        text-align: center;
    }

    .additional-box p {
        font-size: 1.1em;
        line-height: 1.6;
        margin: 10px 0;
    }

    .footer {
        padding: 6px 0;
    }

    .desktop-footer {
        display: none;
    }

    .mobile-footer {
        display: flex;
        flex-direction: column;
        gap: 4px;
        align-items: center;
        justify-content: center;
    }

    .copyright-large {
        font-size: 0.9em;
        color: #333;
        font-weight: 500;
        margin: 0;
    }

    .beian-small {
        font-size: 0.65em;
        color: #999;
        text-decoration: none;
    }

    .custom-hr {
        width: 70%;
        margin: 20px auto;
    }

    body {
        padding-bottom: 70px;
    }
}

.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .article-toc {
        display: none;
    }
    #article-content .additional-box.anim-enter {
        animation: contentSlideInDown 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    }
    .article-layout {
        display: block;
        padding: 0;
        max-width: none;
    }
    .mobile-only {
        display: block !important;
    }

    .mobile-nav-row.mobile-only {
        display: flex !important;
        justify-content: center !important;
    }

    .mobile-footer.mobile-only {
        display: flex !important;
    }

    .mobile-toc-bar {
        display: flex;
        position: fixed;
        bottom: 52px;
        left: 5%;
        width: 90%;
        background: rgba(255,255,255,0.68);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255,255,255,0.3);
        border-radius: 20px;
        padding: 10px 38px 10px 18px;
        align-items: flex-start;
        z-index: 997;
        box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
        font-size: 14px;
        color: #333;
        line-height: 1.5;
    }
    .mobile-toc-label {
        flex: 1;
        min-width: 0;
        white-space: normal;
        word-break: break-all;
        overflow-wrap: break-word;
    }
    #mobile-toc-current {
        display: inline-block;
        overflow: hidden;
        vertical-align: bottom;
    }
    #mobile-toc-current .toc-text {
        display: inline-block;
        white-space: nowrap;
    }
    .toc-progress {
        position: absolute;
        right: 38px;
        top: 50%;
        transform: translateY(-50%);
        overflow: hidden;
        font-size: 13px;
        color: rgba(0,0,0,0.35);
    }
    .toc-progress .toc-progress-text {
        display: inline-block;
        white-space: nowrap;
    }
    .mobile-toc-arrow {
        position: absolute;
        right: 14px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 18px;
        color: #555;
        cursor: pointer;
        line-height: 1;
        transition: transform 0.3s;
        user-select: none;
    }
    .mobile-toc-arrow.open {
        transform: translateY(-50%) rotate(180deg);
    }
    .mobile-toc-panel {
        position: fixed;
        bottom: 100px;
        left: 5%;
        width: 90%;
        max-height: 45vh;
        overflow-y: auto;
        background: rgba(255,255,255,0.72);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255,255,255,0.25);
        border-radius: 16px;
        padding: 16px 20px;
        z-index: 996;
        box-shadow: 0 -4px 16px rgba(0,0,0,0.1);
        display: none !important;
        font-size: 14px;
        line-height: 2.2;
    }
    .mobile-toc-panel.open {
        display: block !important;
    }
    .mobile-toc-panel a {
        display: block;
        color: #555;
        text-decoration: none;
        padding: 4px 0;
        border-bottom: 1px solid rgba(0,0,0,0.05);
    }
    .mobile-toc-panel a:last-child {
        border-bottom: none;
    }
    .mobile-toc-panel a.active {
        color: #3370ff;
        font-weight: 600;
    }
    body {
        padding-bottom: 120px;
    }
}

#article-loading {
    text-align: center;
    color: #999;
    padding: 60px 20px;
    font-size: 16px;
}
#article-error {
    text-align: center;
    color: #c44;
    padding: 60px 20px;
    font-size: 16px;
    display: none;
}
#article-error a {
    color: #3370ff;
    text-decoration: none;
}
