:root {
    --bg: #03100f;
    --bg-soft: #071a18;
    --panel: rgba(7, 27, 24, 0.88);
    --panel-solid: #0b211e;
    --line: rgba(111, 228, 197, 0.2);
    --line-strong: rgba(111, 228, 197, 0.44);
    --text: #eefbf7;
    --muted: #a7c8bf;
    --green: #6fe4c5;
    --green-deep: #28b58f;
    --cyan: #72d8f5;
    --yellow: #f0c96b;
    --orange: #f19b72;
    --danger: #ff8d91;
    --shadow: 0 22px 60px rgba(0, 0, 0, 0.36);
    --topbar-height: 62px;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--topbar-height) + 24px);
}

body {
    min-width: 320px;
    margin: 0;
    color: var(--text);
    background:
        linear-gradient(140deg, rgba(3, 16, 15, 0.94), rgba(3, 16, 15, 0.8)),
        url('/background_butterfly_main.png') center top / cover fixed no-repeat,
        var(--bg);
    font-family: "IBM Plex Sans", "Noto Sans TC", "Noto Sans JP", system-ui, sans-serif;
    line-height: 1.72;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(circle at 15% 12%, rgba(111, 228, 197, 0.12), transparent 32rem),
        radial-gradient(circle at 85% 42%, rgba(114, 216, 245, 0.08), transparent 34rem),
        linear-gradient(rgba(255, 255, 255, 0.012) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.012) 1px, transparent 1px);
    background-size: auto, auto, 40px 40px, 40px 40px;
}

a {
    color: var(--green);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
}

a:hover {
    color: #a5f7df;
}

button,
input {
    font: inherit;
}

code,
.mono {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
}

code {
    padding: 0.12rem 0.36rem;
    color: #c8fff0;
    background: rgba(111, 228, 197, 0.1);
    border: 1px solid rgba(111, 228, 197, 0.14);
    border-radius: 0.35rem;
    overflow-wrap: anywhere;
}

.skip-link {
    position: fixed;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 100;
    padding: 0.65rem 0.9rem;
    color: #00130e;
    background: var(--green);
    border-radius: 0.5rem;
    transform: translateY(-150%);
}

.skip-link:focus {
    transform: translateY(0);
}

.top-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: var(--topbar-height);
    border-bottom: 1px solid var(--line);
    background: rgba(3, 16, 15, 0.86);
    backdrop-filter: blur(18px);
}

.top-bar-inner {
    width: min(1520px, calc(100% - 32px));
    min-height: var(--topbar-height);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--text);
    font-weight: 700;
    letter-spacing: 0.02em;
    text-decoration: none;
    white-space: nowrap;
}

.brand-link img {
    width: 34px;
    height: 34px;
    object-fit: cover;
    border-radius: 9px;
    box-shadow: 0 0 22px rgba(111, 228, 197, 0.24);
}

.current-section {
    min-width: 0;
    flex: 1;
    color: var(--muted);
    font-size: 0.88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-links,
.language-switch {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.top-links a,
.language-switch a {
    padding: 0.42rem 0.66rem;
    color: var(--muted);
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.top-links a:hover,
.language-switch a:hover,
.language-switch a.is-active {
    color: var(--text);
    border-color: var(--line);
    background: rgba(111, 228, 197, 0.08);
}

.manual-shell {
    width: min(1520px, calc(100% - 32px));
    margin: 0 auto;
    padding: 30px 0 96px;
    display: grid;
    grid-template-columns: minmax(250px, 310px) minmax(0, 1fr);
    gap: 30px;
}

.sidebar-panel {
    position: sticky;
    top: calc(var(--topbar-height) + 22px);
    max-height: calc(100vh - var(--topbar-height) - 44px);
    padding: 1rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(5, 22, 19, 0.88);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.sidebar-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 0.75rem;
}

.sidebar-heading strong {
    font-size: 0.86rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.sidebar-close {
    display: none;
    width: 2.2rem;
    height: 2.2rem;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
}

.toc-search {
    width: 100%;
    padding: 0.7rem 0.78rem;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 10px;
    outline: none;
    background: rgba(255, 255, 255, 0.035);
}

.toc-search:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(111, 228, 197, 0.1);
}

.toc-empty {
    display: none;
    margin: 0.8rem 0 0;
    color: var(--muted);
    font-size: 0.86rem;
}

.toc-nav {
    margin-top: 0.75rem;
    padding-right: 0.25rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: rgba(111, 228, 197, 0.35) transparent;
}

.toc-nav ol {
    margin: 0;
    padding: 0;
    list-style: none;
}

.toc-nav li + li {
    margin-top: 0.18rem;
}

.toc-nav a {
    display: block;
    padding: 0.46rem 0.62rem;
    color: var(--muted);
    border-left: 2px solid transparent;
    border-radius: 0 8px 8px 0;
    font-size: 0.9rem;
    line-height: 1.35;
    text-decoration: none;
}

.toc-nav a:hover,
.toc-nav a.is-active {
    color: var(--text);
    border-left-color: var(--green);
    background: rgba(111, 228, 197, 0.08);
}

.manual-main {
    min-width: 0;
}

.manual-hero,
.manual-section {
    border: 1px solid var(--line);
    background: linear-gradient(145deg, rgba(8, 32, 28, 0.92), rgba(4, 20, 18, 0.9));
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.manual-hero {
    position: relative;
    padding: clamp(1.8rem, 4.6vw, 4.8rem);
    overflow: hidden;
    border-radius: 26px;
}

.manual-hero::after {
    content: "";
    position: absolute;
    right: -5rem;
    bottom: -7rem;
    width: 24rem;
    height: 24rem;
    opacity: 0.18;
    background: url('/assets/meshlink-app-icon.png') center / contain no-repeat;
    filter: drop-shadow(0 0 22px rgba(111, 228, 197, 0.5));
    pointer-events: none;
}

.hero-copy {
    position: relative;
    z-index: 1;
    max-width: 850px;
}

.eyebrow {
    margin: 0 0 0.7rem;
    color: var(--green);
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.manual-hero h1 {
    max-width: 850px;
    margin: 0;
    font-size: clamp(2rem, 5vw, 4.7rem);
    line-height: 1.04;
    letter-spacing: -0.035em;
}

.manual-hero .lead {
    max-width: 760px;
    margin: 1.15rem 0 0;
    color: #c9e3dc;
    font-size: clamp(1rem, 1.8vw, 1.18rem);
}

.hero-meta,
.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.hero-meta {
    margin-top: 1.25rem;
}

.meta-chip {
    padding: 0.4rem 0.68rem;
    color: #c6e8de;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.16);
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 0.76rem;
}

.hero-actions {
    margin-top: 1.45rem;
}

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: 0.64rem 1rem;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    color: #001c14;
    background: var(--green);
    font-weight: 700;
    text-decoration: none;
}

.button-link.secondary {
    color: var(--text);
    background: rgba(255, 255, 255, 0.035);
}

.quick-start {
    margin-top: 22px;
    padding: 1.15rem 1.25rem;
    border: 1px solid rgba(240, 201, 107, 0.38);
    border-radius: 16px;
    background: rgba(240, 201, 107, 0.07);
}

.quick-start strong {
    color: #ffe4a1;
}

.manual-section {
    margin-top: 26px;
    padding: clamp(1.35rem, 3vw, 2.55rem);
    border-radius: 22px;
}

.section-number {
    margin: 0 0 0.2rem;
    color: var(--green);
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.manual-section h2 {
    margin: 0;
    font-size: clamp(1.55rem, 3vw, 2.35rem);
    line-height: 1.18;
    letter-spacing: -0.02em;
}

.manual-section h3 {
    margin: 2rem 0 0.65rem;
    color: #d9fff4;
    font-size: clamp(1.08rem, 2vw, 1.34rem);
    line-height: 1.35;
}

.manual-section h4 {
    margin: 1.35rem 0 0.45rem;
    color: #c7f2e6;
    font-size: 1rem;
}

.manual-section p,
.manual-section li,
.manual-section dd,
.manual-section td {
    color: #c2dcd5;
}

.manual-section p {
    margin: 0.65rem 0;
}

.manual-section ul,
.manual-section ol {
    padding-left: 1.35rem;
}

.manual-section li + li {
    margin-top: 0.42rem;
}

.section-intro {
    max-width: 900px;
    color: var(--muted) !important;
    font-size: 1.02rem;
}

.concept-flow {
    margin: 1.35rem 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.65rem;
    list-style: none;
}

.concept-flow li {
    position: relative;
    min-height: 116px;
    margin: 0;
    padding: 0.95rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: rgba(111, 228, 197, 0.05);
}

.concept-flow li:not(:last-child)::after {
    content: "→";
    position: absolute;
    top: 50%;
    right: -0.63rem;
    z-index: 2;
    color: var(--green);
    font-weight: 700;
    transform: translateY(-50%);
}

.concept-flow strong {
    color: var(--text);
}

.concept-flow span {
    margin-top: 0.25rem;
    color: var(--muted);
    font-size: 0.86rem;
}

.term-grid,
.feature-grid,
.status-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}

.term-card,
.feature-card,
.status-card {
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.025);
}

.term-card dt,
.feature-card strong,
.status-card strong {
    color: var(--text);
    font-weight: 700;
}

.term-card dd {
    margin: 0.35rem 0 0;
}

.path {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    margin: 0.85rem 0;
    padding: 0.78rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: #d8f5ed;
    background: rgba(0, 0, 0, 0.14);
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 0.86rem;
}

.path .arrow {
    color: var(--green);
}

.callout {
    margin: 1.1rem 0;
    padding: 0.95rem 1.05rem;
    border-left: 3px solid var(--cyan);
    border-radius: 0 12px 12px 0;
    background: rgba(114, 216, 245, 0.07);
}

.callout strong:first-child {
    color: #bdefff;
}

.callout.warning {
    border-left-color: var(--yellow);
    background: rgba(240, 201, 107, 0.075);
}

.callout.warning strong:first-child {
    color: #ffe3a0;
}

.callout.danger {
    border-left-color: var(--danger);
    background: rgba(255, 141, 145, 0.07);
}

.callout.danger strong:first-child {
    color: #ffc2c4;
}

.step-list {
    margin: 1rem 0;
    padding: 0;
    list-style: none;
    counter-reset: steps;
}

.step-list > li {
    position: relative;
    min-height: 3.2rem;
    margin: 0;
    padding: 0.85rem 0.9rem 0.85rem 3.65rem;
    counter-increment: steps;
    border-top: 1px solid var(--line);
}

.step-list > li:last-child {
    border-bottom: 1px solid var(--line);
}

.step-list > li::before {
    content: counter(steps, decimal-leading-zero);
    position: absolute;
    top: 0.85rem;
    left: 0.65rem;
    color: var(--green);
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-weight: 600;
}

.status-table-wrap {
    margin: 1rem 0;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 13px;
}

.status-table {
    width: 100%;
    min-width: 620px;
    border-collapse: collapse;
}

.status-table th,
.status-table td {
    padding: 0.78rem 0.85rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
}

.status-table th {
    color: #dffff6;
    background: rgba(111, 228, 197, 0.07);
    font-size: 0.86rem;
}

.status-table tr:last-child td {
    border-bottom: 0;
}

.checklist {
    padding-left: 0 !important;
    list-style: none;
}

.checklist li {
    position: relative;
    padding-left: 1.75rem;
}

.checklist li::before {
    content: "✓";
    position: absolute;
    left: 0.18rem;
    color: var(--green);
    font-weight: 700;
}

.manual-footer {
    margin-top: 28px;
    padding: 1.2rem 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.8rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.manual-footer p {
    margin: 0;
}

.mobile-toc-button,
.back-to-top {
    position: fixed;
    z-index: 45;
    width: 3.2rem;
    height: 3.2rem;
    align-items: center;
    justify-content: center;
    color: #00140f;
    border: 0;
    border-radius: 999px;
    background: var(--green);
    box-shadow: 0 15px 34px rgba(0, 0, 0, 0.35);
    cursor: pointer;
}

.mobile-toc-button {
    display: none;
    right: 1rem;
    bottom: 1rem;
    font-size: 1.3rem;
}

.back-to-top {
    right: 1rem;
    bottom: 4.8rem;
    display: flex;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 160ms ease, transform 160ms ease;
}

.back-to-top.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.drawer-scrim {
    display: none;
}

@media (max-width: 1060px) {
    .top-links {
        display: none;
    }

    .manual-shell {
        grid-template-columns: 250px minmax(0, 1fr);
        gap: 18px;
    }

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

    .concept-flow li:nth-child(2)::after {
        display: none;
    }
}

@media (max-width: 780px) {
    :root {
        --topbar-height: 56px;
    }

    body {
        background-attachment: scroll;
    }

    .top-bar-inner,
    .manual-shell {
        width: min(100% - 22px, 760px);
    }

    .brand-link span {
        display: none;
    }

    .current-section {
        font-size: 0.78rem;
    }

    .language-switch a {
        padding: 0.36rem 0.48rem;
    }

    .manual-shell {
        grid-template-columns: 1fr;
        padding-top: 18px;
    }

    .manual-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 70;
        width: min(88vw, 360px);
        padding: 0.75rem;
        transform: translateX(-105%);
        transition: transform 190ms ease;
    }

    .manual-sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-panel {
        position: static;
        max-height: 100%;
        height: 100%;
        border-radius: 16px;
    }

    .sidebar-close,
    .mobile-toc-button {
        display: inline-flex;
    }

    .drawer-scrim {
        position: fixed;
        inset: 0;
        z-index: 60;
        background: rgba(0, 0, 0, 0.62);
        backdrop-filter: blur(3px);
    }

    .drawer-scrim.is-open {
        display: block;
    }

    body.toc-open {
        overflow: hidden;
    }

    .manual-hero::after {
        width: 16rem;
        height: 16rem;
        right: -6rem;
        bottom: -5rem;
        opacity: 0.11;
    }

    .term-grid,
    .feature-grid,
    .status-grid {
        grid-template-columns: 1fr;
    }

    .back-to-top {
        right: 1rem;
        bottom: 4.8rem;
    }
}

@media (max-width: 540px) {
    .manual-hero,
    .manual-section {
        border-radius: 16px;
    }

    .concept-flow {
        grid-template-columns: 1fr;
    }

    .concept-flow li:not(:last-child)::after {
        top: auto;
        right: 50%;
        bottom: -0.72rem;
        display: block;
        transform: translateX(50%) rotate(90deg);
    }

    .hero-actions .button-link {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.001ms !important;
        animation-duration: 0.001ms !important;
    }
}

@media print {
    :root {
        color-scheme: light;
    }

    body {
        color: #172522;
        background: #fff;
    }

    body::before,
    .top-bar,
    .manual-sidebar,
    .mobile-toc-button,
    .back-to-top,
    .hero-actions {
        display: none !important;
    }

    .manual-shell {
        width: 100%;
        display: block;
        padding: 0;
    }

    .manual-hero,
    .manual-section {
        margin: 0 0 1rem;
        color: #172522;
        border-color: #b9cbc6;
        background: #fff;
        box-shadow: none;
        break-inside: avoid;
    }

    .manual-hero::after {
        display: none;
    }

    .manual-section p,
    .manual-section li,
    .manual-section dd,
    .manual-section td,
    .section-intro,
    .manual-hero .lead,
    .manual-footer {
        color: #263d37 !important;
    }

    a {
        color: #075b47;
    }
}
