/* ==========================================================================
   KeySnap — one stylesheet, no build step, no dependencies.
   The palette is defined once as custom properties and inverted for dark mode,
   so every rule below is written against roles rather than colours.
   ========================================================================== */

:root {
    color-scheme: light dark;

    --ink: #14141a;
    --ink-soft: #55555f;
    --ink-faint: #8a8a96;

    --surface: #ffffff;
    --surface-alt: #f7f7fa;
    --surface-sunken: #f0f0f5;
    --line: #e4e4ec;
    --line-strong: #d0d0da;

    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-soft: #eff5ff;
    --accent-ink: #ffffff;

    --accent-far: #0891b2;
    --good: #15803d;
    --warn: #b45309;

    --glow-a: rgb(37 99 235 / 0.20);
    --glow-b: rgb(8 145 178 / 0.16);

    --shadow-sm: 0 1px 2px rgb(16 16 32 / 0.05), 0 2px 8px rgb(16 16 32 / 0.05);
    --shadow-lg: 0 8px 24px rgb(16 16 32 / 0.09), 0 32px 64px rgb(16 16 32 / 0.10);

    --radius: 12px;
    --radius-lg: 18px;
    --wrap: 1120px;

    --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
    --mono: "Cascadia Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
    --ink: #ececf1;
    --ink-soft: #a6a6b3;
    --ink-faint: #74747f;

    --surface: #131318;
    --surface-alt: #1b1b21;
    --surface-sunken: #0e0e12;
    --line: #2a2a33;
    --line-strong: #3a3a46;

    --accent: #60a5fa;
    --accent-hover: #93c5fd;
    --accent-soft: #16233a;
    --accent-ink: #12121a;

    --accent-far: #22d3ee;
    --good: #4ade80;
    --warn: #fbbf24;

    --glow-a: rgb(96 165 250 / 0.20);
    --glow-b: rgb(34 211 238 / 0.15);

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 8px 24px rgb(0 0 0 / 0.45), 0 32px 64px rgb(0 0 0 / 0.35);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 17px;
    line-height: 1.62;
    color: var(--ink);
    background: var(--surface);
    -webkit-font-smoothing: antialiased;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

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

a:hover {
    text-decoration: underline;
}

code,
kbd {
    font-family: var(--mono);
    font-size: 0.88em;
}

code {
    background: var(--surface-sunken);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 0.08em 0.36em;
    white-space: nowrap;
}

kbd {
    background: var(--surface-alt);
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    border-radius: 5px;
    padding: 0.1em 0.42em;
    font-size: 0.82em;
}

/* --- Layout --------------------------------------------------------------- */

.wrap {
    width: min(var(--wrap), calc(100% - 40px));
    margin-inline: auto;
}

section {
    padding: 84px 0;
}

section.tight {
    padding: 56px 0;
}

.band {
    background: var(--surface-alt);
    border-block: 1px solid var(--line);
}

h1,
h2,
h3 {
    line-height: 1.16;
    letter-spacing: -0.021em;
    margin: 0 0 0.5em;
}

h1 {
    font-size: clamp(2.4rem, 5.2vw, 3.75rem);
    font-weight: 700;
}

h2 {
    font-size: clamp(1.7rem, 3.2vw, 2.35rem);
    font-weight: 650;
}

h3 {
    font-size: 1.09rem;
    font-weight: 640;
}

p {
    margin: 0 0 1em;
}

.lede {
    font-size: 1.16rem;
    color: var(--ink-soft);
    max-width: 62ch;
}

.eyebrow {
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 12px;
}

.centred {
    text-align: center;
}

.centred .lede {
    margin-inline: auto;
}

/* --- Navigation ----------------------------------------------------------- */

header.nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--surface);
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: saturate(1.6) blur(14px);
    border-bottom: 1px solid var(--line);
}

.nav-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 62px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 680;
    font-size: 1.06rem;
    color: var(--ink);
    letter-spacing: -0.015em;
}

.brand:hover {
    text-decoration: none;
}

.brand img {
    width: 28px;
    height: 28px;
    border-radius: 8px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.nav-links a:not(.btn) {
    color: var(--ink-soft);
    padding: 7px 11px;
    border-radius: 8px;
    font-size: 0.95rem;
}

.nav-links a:not(.btn):hover {
    color: var(--ink);
    background: var(--surface-alt);
    text-decoration: none;
}

.nav-links a[aria-current="page"] {
    color: var(--ink);
    font-weight: 600;
}

/* --- Buttons -------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 12px 22px;
    border-radius: 10px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 0.98rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}

.btn:hover {
    text-decoration: none;
    background: var(--surface-alt);
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-sm {
    padding: 8px 15px;
    font-size: 0.9rem;
    border-radius: 8px;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

/* The toggle carries both icons and lets CSS pick; a Unicode sun and moon look
   different on every machine and are missing outright from some fonts. */
.theme-toggle {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 9px;
    color: var(--ink-soft);
}

.theme-toggle svg {
    width: 17px;
    height: 17px;
    display: block;
}

.theme-toggle .sun {
    display: none;
}

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

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

/* --- Hero ----------------------------------------------------------------- */

.hero {
    padding: 76px 0 0;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: "";
    position: absolute;
    inset: -220px 0 auto;
    height: 560px;
    background:
        radial-gradient(58% 60% at 22% 0%, var(--glow-a), transparent 70%),
        radial-gradient(48% 55% at 82% 8%, var(--glow-b), transparent 70%);
    pointer-events: none;
}

.hero > .wrap {
    position: relative;
}

.hero h1 {
    max-width: 15ch;
}

.hero .lede {
    font-size: 1.24rem;
}

.hero-note {
    color: var(--ink-faint);
    font-size: 0.9rem;
    margin-top: 18px;
}

.shot {
    margin-top: 54px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    background: var(--surface-alt);
}

.shot img {
    width: 100%;
}

.shot img.dark-only {
    display: none;
}

[data-theme="dark"] .shot img.light-only {
    display: none;
}

[data-theme="dark"] .shot img.dark-only {
    display: block;
}

/* --- Cards and grids ------------------------------------------------------ */

.grid {
    display: grid;
    gap: 20px;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(264px, 1fr));
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-sm);
}

.card h3 {
    margin-bottom: 6px;
}

.card p {
    color: var(--ink-soft);
    font-size: 0.96rem;
    margin: 0;
}

.card .glyph {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    display: grid;
    place-items: center;
    font-size: 1.05rem;
    margin-bottom: 14px;
}

.stat {
    text-align: center;
}

.stat b {
    display: block;
    font-size: 2.1rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.stat span {
    color: var(--ink-soft);
    font-size: 0.92rem;
}

/* --- Feature list --------------------------------------------------------- */

.features {
    display: grid;
    gap: 14px 34px;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    list-style: none;
    padding: 0;
    margin: 0;
}

.features li {
    display: flex;
    gap: 11px;
    align-items: flex-start;
    font-size: 0.97rem;
}

.features .tick {
    color: var(--good);
    font-weight: 700;
    flex: none;
    line-height: 1.6;
}

.features b {
    display: block;
    font-weight: 620;
}

.features span {
    color: var(--ink-soft);
}

/* --- Code samples --------------------------------------------------------- */

.sample {
    background: var(--surface-sunken);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    font-family: var(--mono);
    font-size: 0.9rem;
}

.sample-head {
    padding: 9px 15px;
    border-bottom: 1px solid var(--line);
    color: var(--ink-faint);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-family: var(--font);
    font-weight: 640;
}

.sample-body {
    padding: 15px;
    overflow-x: auto;
    white-space: pre;
    line-height: 1.75;
    margin: 0;
}

.tok {
    color: var(--accent);
}

.cmt {
    color: var(--ink-faint);
}

/* --- Tables --------------------------------------------------------------- */

.table-scroll {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    min-width: 620px;
}

th,
td {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

thead th {
    background: var(--surface-alt);
    font-size: 0.78rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ink-soft);
    font-weight: 680;
    white-space: nowrap;
}

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

td.yes {
    color: var(--good);
    font-weight: 640;
}

td.no {
    color: var(--ink-faint);
}

td.part {
    color: var(--warn);
}

td code {
    white-space: nowrap;
}

/* --- Pricing -------------------------------------------------------------- */

.tiers {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(252px, 1fr));
    align-items: start;
}

.tier {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 26px 24px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.tier.featured {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent), var(--shadow-lg);
    position: relative;
}

.tier .badge {
    position: absolute;
    top: -11px;
    left: 24px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 99px;
}

.tier h3 {
    font-size: 1.2rem;
    margin-bottom: 2px;
}

.tier .who {
    color: var(--ink-soft);
    font-size: 0.9rem;
    margin-bottom: 18px;
    min-height: 2.8em;
}

.price {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 4px;
}

.price b {
    font-size: 2.4rem;
    font-weight: 700;
    letter-spacing: -0.035em;
}

.price span {
    color: var(--ink-soft);
    font-size: 0.9rem;
}

.price-note {
    color: var(--ink-faint);
    font-size: 0.83rem;
    margin-bottom: 20px;
    min-height: 2.4em;
}

.tier ul {
    list-style: none;
    padding: 0;
    margin: 0 0 22px;
    display: grid;
    gap: 9px;
    font-size: 0.93rem;
}

.tier li {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    color: var(--ink-soft);
}

.tier li::before {
    content: "✓";
    color: var(--good);
    font-weight: 700;
    flex: none;
}

.tier li.off {
    color: var(--ink-faint);
}

.tier li.off::before {
    content: "—";
    color: var(--ink-faint);
}

.tier .btn {
    width: 100%;
    margin-top: auto;
}

/* --- Details / FAQ -------------------------------------------------------- */

details {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 0 18px;
    margin-bottom: 10px;
}

details[open] {
    background: var(--surface-alt);
}

summary {
    cursor: pointer;
    font-weight: 620;
    padding: 15px 0;
    list-style: none;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

summary::-webkit-details-marker {
    display: none;
}

summary::after {
    content: "+";
    color: var(--ink-faint);
    font-size: 1.25rem;
    font-weight: 400;
    line-height: 1;
}

details[open] summary::after {
    content: "−";
}

details p {
    color: var(--ink-soft);
    font-size: 0.96rem;
    margin: 0 0 15px;
    max-width: 74ch;
}

/* --- Callout -------------------------------------------------------------- */

.callout {
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    background: var(--surface-alt);
    border-radius: var(--radius);
    padding: 18px 22px;
}

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

.callout.warn {
    border-left-color: var(--warn);
}

/* --- Docs layout ---------------------------------------------------------- */

.docs {
    display: grid;
    grid-template-columns: 228px minmax(0, 1fr);
    gap: 48px;
    align-items: start;
    padding: 44px 0 90px;
}

.toc {
    position: sticky;
    top: 82px;
    font-size: 0.93rem;
}

.toc strong {
    display: block;
    font-size: 0.74rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin-bottom: 10px;
}

.toc a {
    display: block;
    padding: 5px 10px;
    border-radius: 7px;
    color: var(--ink-soft);
}

.toc a:hover {
    background: var(--surface-alt);
    color: var(--ink);
    text-decoration: none;
}

.doc-body h2 {
    padding-top: 22px;
    margin-top: 22px;
    border-top: 1px solid var(--line);
}

.doc-body h2:first-child {
    border-top: 0;
    padding-top: 0;
    margin-top: 0;
}

.doc-body h3 {
    margin-top: 28px;
}

.doc-body ul,
.doc-body ol {
    color: var(--ink-soft);
    padding-left: 22px;
}

.doc-body li {
    margin-bottom: 7px;
}

/* --- Footer --------------------------------------------------------------- */

footer {
    border-top: 1px solid var(--line);
    background: var(--surface-alt);
    padding: 46px 0 34px;
    font-size: 0.92rem;
}

.foot-grid {
    display: grid;
    grid-template-columns: 1.6fr repeat(3, 1fr);
    gap: 32px;
}

.foot-grid h4 {
    font-size: 0.76rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin: 0 0 12px;
}

.foot-grid ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}

.foot-grid a {
    color: var(--ink-soft);
}

.foot-grid a:hover {
    color: var(--ink);
}

.foot-bottom {
    margin-top: 34px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    color: var(--ink-faint);
    font-size: 0.86rem;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
}

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 860px) {
    body {
        font-size: 16px;
    }

    section {
        padding: 60px 0;
    }

    .docs {
        grid-template-columns: 1fr;
        gap: 26px;
    }

    .toc {
        position: static;
    }

    .foot-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .nav-links a:not(.btn) {
        display: none;
    }

    .nav-links a.keep {
        display: inline-flex;
    }
}

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

    * {
        transition: none !important;
    }
}

@media print {
    header.nav,
    footer,
    .btn {
        display: none;
    }
}
