:root {
    --ink:      #1b1b2b;
    --muted:    #5a5a72;
    --accent:   #00007f;
    --accent-2: #2d2da6;
    --line:     #e4e4ee;
    --code-bg:  #f6f7f9;
    --panel:    #ffffff;
    --ok:       #0a7d2c;
    --err:      #b00020;
    --warn:     #9a6700;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    color: var(--ink);
    background: #fafafe;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 17px;
    line-height: 1.62;
}

.wrap {
    max-width: 820px;
    margin: 0 auto;
    padding: 48px 24px 72px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- header ---- */
.brand { text-align: center; }
.brand img { width: 96px; height: 96px; }

h1 {
    text-align: center;
    font-size: 2.6rem;
    letter-spacing: -0.02em;
    margin: 18px 0 4px;
}

.tagline {
    text-align: center;
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--muted);
    margin: 0 0 22px;
}

.links {
    text-align: center;
    margin-bottom: 36px;
}
.links a {
    display: inline-block;
    margin: 4px 5px;
    padding: 6px 15px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.95rem;
    color: var(--ink);
    background: #fff;
}
.links a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ---- body copy ---- */
.lead { font-size: 1.1rem; }

h2 {
    font-size: 1.5rem;
    letter-spacing: -0.01em;
    margin: 52px 0 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
}

h3 { margin: 0 0 14px; font-size: 1.05rem; }

p { margin: 14px 0; }

.note { color: var(--muted); font-size: 0.95rem; }

.diagram {
    display: block;
    max-width: 100%;
    margin: 28px auto;
}

/* ---- code ---- */
pre.code {
    background: var(--code-bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 18px 20px;
    overflow-x: auto;
    font-size: 0.9rem;
    line-height: 1.55;
}
pre.code, code.inline {
    font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
code.inline {
    background: var(--code-bg);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 1px 5px;
    font-size: 0.86em;
    white-space: nowrap;
}

/* ---- lists ---- */
ul.steps, ul.model { list-style: none; padding: 0; }
ul.steps li {
    position: relative;
    padding-left: 26px;
    margin: 12px 0;
}
ul.steps li::before {
    content: "\203A";
    position: absolute;
    left: 8px;
    color: var(--accent);
    font-weight: 700;
}
ul.model li {
    position: relative;
    padding-left: 30px;
    margin: 14px 0;
}
ul.model li .mk {
    position: absolute;
    left: 0;
    top: 0;
    font-weight: 700;
}
.mk.ok { color: var(--ok); }
.mk.warn { color: var(--warn); }

ul.prose { padding-left: 20px; }
ul.prose li { margin: 10px 0; }

/* ---- comparison ---- */
.compare { overflow-x: auto; margin: 20px 0 16px; }
table.cmp {
    border-collapse: collapse;
    width: 100%;
    min-width: 660px;
    font-size: 0.88rem;
    line-height: 1.4;
}
table.cmp th, table.cmp td {
    border: 1px solid var(--line);
    padding: 9px 11px;
    text-align: left;
    vertical-align: top;
}
table.cmp thead th {
    background: var(--code-bg);
    font-weight: 600;
    font-size: 0.8rem;
}
table.cmp tbody th[scope="row"] { font-weight: 700; white-space: nowrap; }
table.cmp tr.me { background: rgba(0, 0, 127, 0.045); }
table.cmp td.hl { background: rgba(10, 125, 44, 0.10); }
table.cmp .y { color: var(--ok); font-weight: 700; }
table.cmp .n { color: var(--err); font-weight: 700; }
table.cmp .p { color: var(--warn); font-weight: 600; }

/* ---- live demo ---- */
.demo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-top: 18px;
}
.card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 20px;
    background: var(--panel);
    box-shadow: 0 1px 2px rgba(20, 20, 50, 0.04);
}
.card h3 { margin-bottom: 6px; }
.card .hint {
    margin: 0 0 16px;
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--muted);
}
.card label {
    display: block;
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: var(--muted);
}
.card label input {
    display: block;
    width: 100%;
    margin-top: 5px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 7px;
    font-size: 0.95rem;
    font-family: inherit;
}
.card label input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 0, 127, 0.1);
}
.card button {
    width: 100%;
    margin-top: auto;          /* anchor to card bottom so Store/Fetch buttons align despite the extra field */
    padding: 10px 12px;
    border: 0;
    border-radius: 7px;
    background: var(--accent);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}
.card button:hover { background: var(--accent-2); }

.status {
    /* Fixed height (two lines) so a message never resizes the box and shifts
       the bottom-anchored button. Centered, scrolls if a message runs longer. */
    margin-top: 12px;
    height: 2.8em;
    line-height: 1.4;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
    overflow: auto;
    word-break: break-word;
}
.status_ok { color: var(--ok); }
.status_error { color: var(--err); }

/* ---- footer ---- */
footer {
    margin-top: 64px;
    padding-top: 26px;
    border-top: 1px solid var(--line);
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
}
footer a { color: var(--muted); }
footer .motto { margin: 12px 0 6px; }

/* ---- responsive ---- */
@media (max-width: 620px) {
    body { font-size: 16px; }
    .wrap { padding: 32px 18px 56px; }
    h1 { font-size: 2.1rem; }
    .demo { grid-template-columns: 1fr; }
}
