:root {
    color-scheme: light;
    --bg: #edf2f5;
    --paper: #fff;
    --soft: #f5f8fa;
    --ink: #192a39;
    --muted: #53697b;
    --line: #cdd9e2;
    --accent: #075f69;
    --accent-bg: #e1f2f1;
    --front: #205c9a;
    --front-bg: #eaf3ff;
    --back: #875015;
    --back-bg: #fff3e2;
    --sql: #6e4195;
    --sql-bg: #f3eafa;
    --redis: #9e3e42;
    --redis-bg: #ffedee;
    --shadow: 0 6px 24px #1b3a5010;
    --code: #172b3d;
    --code-ink: #e7f0fa;
}

:root[data-theme=dark] {
    color-scheme: dark;
    --bg: #101820;
    --paper: #19242e;
    --soft: #202e39;
    --ink: #e5edf4;
    --muted: #a9bdcc;
    --line: #3b4e5d;
    --accent: #7bd6d0;
    --accent-bg: #1d3e40;
    --front: #9ac8ff;
    --front-bg: #213b56;
    --back: #ffd18e;
    --back-bg: #46351f;
    --sql: #d9b7ff;
    --sql-bg: #3c2d50;
    --redis: #ffb0b2;
    --redis-bg: #492c34;
    --shadow: 0 6px 24px #0003;
    --code: #10181f;
    --code-ink: #e7f0fa;
}

@media (prefers-color-scheme:dark) {
    :root[data-theme=auto] {
        color-scheme: dark;
        --bg: #101820;
        --paper: #19242e;
        --soft: #202e39;
        --ink: #e5edf4;
        --muted: #a9bdcc;
        --line: #3b4e5d;
        --accent: #7bd6d0;
        --accent-bg: #1d3e40;
        --front: #9ac8ff;
        --front-bg: #213b56;
        --back: #ffd18e;
        --back-bg: #46351f;
        --sql: #d9b7ff;
        --sql-bg: #3c2d50;
        --redis: #ffb0b2;
        --redis-bg: #492c34;
        --shadow: 0 6px 24px #0003;
        --code: #10181f;
        --code-ink: #e7f0fa;
    }
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 85px;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.6 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}

a {
    color: var(--accent);
}

button,select {
    font: inherit;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 12px;
    cursor: pointer;
}

a:focus-visible,button:focus-visible,select:focus-visible,summary:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}

.bar {
    max-width: 1240px;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    gap: 15px;
}

.brand {
    font-weight: 850;
    letter-spacing: .09em;
}

.brand small {
    font-weight: 500;
    letter-spacing: 0;
    color: var(--muted);
    margin-left: 10px;
}

.controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.wrap {
    max-width: 1240px;
    margin: auto;
    padding: 30px 24px 64px;
}

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

h1 {
    font-size: clamp(34px,5vw,55px);
    line-height: 1.09;
    letter-spacing: -.045em;
    margin-bottom: 16px;
}

h2 {
    font-size: 26px;
    letter-spacing: -.025em;
    margin-bottom: 5px;
}

h3 {
    font-size: 18px;
    margin-bottom: 9px;
}

h4 {
    font-size: 15px;
    margin-bottom: 5px;
}

p {
    margin-bottom: 12px;
}

.muted {
    color: var(--muted);
}

.eyebrow {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .18em;
    color: var(--accent);
    font-weight: 800;
    margin-bottom: 10px;
}

.hero {
    padding: 34px 36px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.hero:before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: var(--accent);
}

.hero p {
    max-width: 860px;
    color: var(--muted);
    font-size: 17px;
}

.tags {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.tag {
    font-size: 12px;
    font-weight: 650;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px 10px;
    background: var(--soft);
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    padding: 16px 4px;
    margin-bottom: 12px;
}

nav a {
    font-size: 13px;
    text-decoration: none;
    font-weight: 650;
}

nav a:hover {
    text-decoration: underline;
}

section {
    margin-top: 32px;
}

.section-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.num {
    color: var(--accent);
    font-weight: 800;
    font-size: 13px;
    letter-spacing: .1em;
}

.panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 22px;
    box-shadow: var(--shadow);
}

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

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

.note {
    padding: 12px 15px;
    border-left: 3px solid var(--accent);
    background: var(--accent-bg);
    border-radius: 0 8px 8px 0;
    margin-top: 14px;
    font-size: 14px;
}

.mini {
    font-size: 12px;
    color: var(--muted);
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 12px 0 18px;
    font-size: 12px;
    color: var(--muted);
}

.legend span:before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    background: var(--c);
    border-radius: 3px;
    margin-right: 5px;
}

.diagram {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.node {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 13px 16px;
    background: var(--soft);
    text-align: center;
    line-height: 1.4;
}

.node b {
    display: block;
    font-size: 17px;
}

.node small {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

.front {
    background: var(--front-bg);
    border-color: var(--front);
    color: var(--front);
}

.back {
    background: var(--back-bg);
    border-color: var(--back);
    color: var(--back);
}

.sql {
    background: var(--sql-bg);
    border-color: var(--sql);
    color: var(--sql);
}

.redis {
    background: var(--redis-bg);
    border-color: var(--redis);
    color: var(--redis);
}

.arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    font-size: 11px;
    font-weight: 650;
    color: var(--muted);
    line-height: 1.2;
    padding: 4px 0;
}

.arrow:after {
    content: "↕";
    font-size: 23px;
    line-height: 1.1;
    color: var(--accent);
}

.arrow.one:after {
    content: "↓";
}

.boundary {
    border: 2px dashed var(--line);
    padding: 15px 18px 18px;
    border-radius: 14px;
    width: 100%;
    background: var(--paper);
}

.boundary-label {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--muted);
    font-weight: 800;
    margin-bottom: 12px;
}

.narrow {
    max-width: 630px;
    margin: auto;
}

.client {
    max-width: 360px;
}

.data-branch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: 100%;
    margin-top: 4px;
}

.data-branch .arrow {
    min-height: 48px;
    justify-content: center;
}

.data-branch .node {
    min-height: 98px;
}

.sidepath {
    border: 1px dashed var(--redis);
    color: var(--redis);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 12px;
    text-align: center;
    margin: 10px 0 0;
}

.gitpath {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
}

.gitpath .node {
    font-size: 13px;
}

.gitpath .arr {
    color: var(--accent);
    font-weight: 800;
}

.container-node {
    border: 1px dashed var(--line);
    border-radius: 12px;
    padding: 8px;
    background: var(--soft);
}

.container-node .label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .12em;
    font-weight: 750;
    color: var(--muted);
    margin-bottom: 6px;
    text-align: left;
}

.netlabel {
    font: 12px ui-monospace,monospace;
    color: var(--accent);
    text-align: center;
    margin: 8px 0;
}

.tile {
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--soft);
}

.tile h3 {
    font-size: 15px;
}

.tile p {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 0;
}

.tablewrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

th,td {
    padding: 11px 13px;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
}

th {
    background: var(--soft);
    font-weight: 750;
    color: var(--accent);
}

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

td:first-child {
    font-weight: 650;
}

code {
    font-family: ui-monospace,SFMono-Regular,Consolas,monospace;
    font-size: .91em;
    overflow-wrap: anywhere;
}

pre {
    margin: 0;
    background: var(--code);
    color: var(--code-ink);
    border-radius: 10px;
    padding: 16px;
    overflow: auto;
    line-height: 1.5;
    font-size: 12px;
    tab-size: 2;
}

pre code {
    font-size: inherit;
    overflow-wrap: normal;
}

.codebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.codebar button {
    font-size: 12px;
}

.steps {
    counter-reset: steps;
    display: grid;
    gap: 10px;
}

.step {
    counter-increment: steps;
    position: relative;
    padding: 11px 12px 11px 45px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--soft);
    font-size: 14px;
}

.step:before {
    content: counter(steps,decimal-leading-zero);
    position: absolute;
    left: 12px;
    top: 11px;
    color: var(--accent);
    font-weight: 800;
}

.step p {
    margin: 2px 0 0;
    font-size: 13px;
    color: var(--muted);
}

details {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 15px;
    margin-top: 10px;
    background: var(--soft);
}

summary {
    cursor: pointer;
    font-weight: 700;
}

details p,details ul {
    font-size: 14px;
    margin-top: 10px;
    margin-bottom: 5px;
}

ul {
    padding-left: 21px;
    margin: 5px 0 10px;
}

li {
    margin-bottom: 5px;
}

footer {
    margin-top: 36px;
    padding-top: 15px;
    border-top: 1px solid var(--line);
    font-size: 12px;
    color: var(--muted);
}

.checklist {
    display: grid;
    gap: 8px;
}

.checklist label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 14px;
}

.checklist input {
    margin-top: 5px;
    accent-color: var(--accent);
}

.status {
    font-size: 12px;
    color: var(--muted);
}

.source-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
}

.source-links a {
    font-size: 13px;
}

.sep {
    height: 1px;
    background: var(--line);
    margin: 18px 0;
}

.call {
    font-size: 13px;
    color: var(--muted);
}

@media (max-width:700px) {
    .wrap {
        padding: 20px 12px 40px;
    }

    .bar {
        padding: 10px 12px;
    }

    .brand small {
        display: none;
    }

    .controls button {
        display: none;
    }

    .hero {
        padding: 24px 20px;
    }

    .panel {
        padding: 14px;
    }

    .cols,.three {
        grid-template-columns: 1fr;
    }

    .boundary {
        padding: 10px;
    }

    .data-branch {
        gap: 8px;
    }

    .data-branch .node {
        padding: 10px 7px;
    }

    .node b {
        font-size: 15px;
    }

    .gitpath {
        grid-template-columns: 1fr;
    }

    .gitpath .arr {
        text-align: center;
        transform: rotate(90deg);
    }

    .section-head {
        gap: 8px;
    }

    th,td {
        padding: 9px;
    }

    h2 {
        font-size: 23px;
    }
}

@media print {
    header,nav,.controls,.codebar button {
        display: none;
    }

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

    .wrap {
        max-width: none;
        padding: 0;
    }

    .panel,.hero {
        box-shadow: none;
        break-inside: avoid;
    }

    section {
        break-inside: auto;
    }

    .node,.tile,.step {
        break-inside: avoid;
    }

    a {
        color: inherit;
    }

    * {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}

.legend-front {
    --c: var(--front);
}

.legend-back {
    --c: var(--back);
}

.legend-sql {
    --c: var(--sql);
}

.legend-redis {
    --c: var(--redis);
}

.m-0 {
    margin: 0;
}

.codebar-caption {
    margin: 3px 0 0;
}

.mt-0 {
    margin-top: 0px;
}

.mt-8 {
    margin-top: 8px;
}

.mt-10 {
    margin-top: 10px;
}

.mt-14 {
    margin-top: 14px;
}

.mt-15 {
    margin-top: 15px;
}

.mt-16 {
    margin-top: 16px;
}

.mt-17 {
    margin-top: 17px;
}

.clipboard-field {
    position: fixed;
    opacity: 0;
}
