/* ---------------------------------------------------------------------------
   OpenShare — the whole stylesheet.
   No framework and no build step: one file, a small set of tokens, and a handful
   of primitives (.btn, .card, .field, .table, .badge) that every page reuses.
   --------------------------------------------------------------------------- */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-sunken: #f0f2f5;
    --border: #dfe3e8;
    --border-strong: #c6ccd4;

    --text: #1c2126;
    --text-muted: #5d6773;
    --text-faint: #8d97a3;

    --accent: #2f6fd0;
    --accent-hover: #2559ab;
    --accent-soft: #eaf1fc;

    --ok: #1f7a4d;
    --ok-soft: #e6f4ec;
    --warn: #8a6100;
    --warn-soft: #fdf3dc;
    --danger: #b3261e;
    --danger-soft: #fbeae9;

    --radius: 10px;
    --radius-sm: 6px;
    --gap: 1rem;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-lift: 0 4px 12px rgba(16, 24, 40, .09);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14171a;
        --surface: #1c2024;
        --surface-sunken: #23282d;
        --border: #2e343a;
        --border-strong: #3d454d;

        --text: #e6e9ec;
        --text-muted: #a3adb8;
        --text-faint: #7b8590;

        --accent: #6ea3ec;
        --accent-hover: #8ab6f2;
        --accent-soft: #1d2836;

        --ok: #6cc79a;
        --ok-soft: #17281f;
        --warn: #e0b45c;
        --warn-soft: #2a2314;
        --danger: #ef8b84;
        --danger-soft: #2c1917;

        --shadow: 0 1px 2px rgba(0, 0, 0, .3);
        --shadow-lift: 0 4px 14px rgba(0, 0, 0, .4);
    }
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.wrap { width: min(1120px, 100% - 2.5rem); margin-inline: auto; }

/* ---------------------------------------------------------------- header */

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    min-height: 56px;
    flex-wrap: wrap;
}

.brand {
    font-weight: 650;
    font-size: 1.05rem;
    letter-spacing: -.01em;
    color: var(--text);
    text-decoration: none;
}

.nav { display: flex; gap: .25rem; flex-wrap: wrap; margin-right: auto; }

.nav a {
    color: var(--text-muted);
    text-decoration: none;
    padding: .35rem .6rem;
    border-radius: var(--radius-sm);
    font-size: .9rem;
}

.nav a:hover { background: var(--surface-sunken); color: var(--text); }

.nav-badge-host { display: inline-flex; align-items: center; gap: .4rem; }

.header-account { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.header-account a { color: var(--text-muted); text-decoration: none; }
.header-account a:hover { color: var(--text); }

.site-footer {
    margin-top: auto;
    padding: 1.5rem 0;
    color: var(--text-faint);
    font-size: .85rem;
    border-top: 1px solid var(--border);
}

.main { flex: 1; padding: 2rem 0 3rem; }

/* ---------------------------------------------------------------- type */

h1 { font-size: 1.6rem; letter-spacing: -.02em; margin: 0 0 .35rem; font-weight: 650; }
h2 { font-size: 1.15rem; letter-spacing: -.01em; margin: 0 0 .75rem; font-weight: 620; }
h3 { font-size: 1rem; margin: 0 0 .5rem; font-weight: 600; }

.lede { color: var(--text-muted); margin: 0 0 1.75rem; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); font-size: .85rem; }
.mono { font-family: var(--mono); font-size: .85em; }

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.page-head h1 { margin-bottom: .15rem; }

/* ---------------------------------------------------------------- cards */

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

.card-body { padding: 1.1rem 1.25rem; }

.section { margin-bottom: 2rem; }
.section > h2 { display: flex; align-items: center; gap: .6rem; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.product-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}

.product-card:hover {
    box-shadow: var(--shadow-lift);
    border-color: var(--border-strong);
    transform: translateY(-2px);
}

.product-card .thumb {
    aspect-ratio: 16 / 9;
    background: var(--surface-sunken);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
}

.product-card .thumb img { width: 100%; height: 100%; object-fit: cover; }

.thumb-placeholder {
    font-size: 1.75rem;
    font-weight: 650;
    color: var(--text-faint);
    letter-spacing: .04em;
}

.product-card .card-body { display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.product-card h3 { margin: 0; }
.product-card p { margin: 0; color: var(--text-muted); font-size: .9rem; flex: 1; }

.card-meta {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
    padding-top: .35rem;
    border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------------- badges */

.badge {
    display: inline-block;
    padding: .1rem .45rem;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 600;
    line-height: 1.5;
    background: var(--surface-sunken);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

.nav-badge-host .badge { background: var(--accent); color: #fff; border-color: transparent; }

/* ---------------------------------------------------------------- buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .45rem .9rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: .9rem;
    font-weight: 550;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}

.btn-secondary:hover { background: var(--surface-sunken); border-color: var(--border-strong); }

.btn-quiet {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
}

.btn-quiet:hover { background: var(--surface-sunken); color: var(--text); border-color: transparent; }

.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-small { padding: .25rem .6rem; font-size: .82rem; }

.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.inline { display: inline; }

/* ---------------------------------------------------------------- forms */

.field { margin-bottom: 1rem; }

.field label {
    display: block;
    font-size: .85rem;
    font-weight: 560;
    margin-bottom: .3rem;
    color: var(--text);
}

.field .hint { display: block; font-weight: 400; color: var(--text-faint); font-size: .8rem; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=file], select, textarea {
    width: 100%;
    padding: .5rem .65rem;
    font: inherit;
    font-size: .92rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: var(--accent);
}

textarea { min-height: 7rem; resize: vertical; font-family: var(--mono); font-size: .86rem; }

.field-error { color: var(--danger); font-size: .82rem; margin-top: .25rem; }
input.invalid, textarea.invalid { border-color: var(--danger); }

.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row > * { flex: 1 1 12rem; }

.checkline { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.checkline input { width: auto; }
.checkline label { margin: 0; font-weight: 400; }

.checkbox-list {
    max-height: 15rem;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .6rem .75rem;
    background: var(--surface-sunken);
}

.checkbox-list .checkline { margin-bottom: .35rem; }

/* ---------------------------------------------------------------- tables */

.table-scroll { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

th, td {
    text-align: left;
    padding: .6rem .75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

th {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-faint);
    font-weight: 600;
    white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-sunken); }

td.right, th.right { text-align: right; }
td.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- flashes */

.flash {
    padding: .7rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: .9rem;
    border: 1px solid transparent;
}

.flash-ok { background: var(--ok-soft); color: var(--ok); border-color: currentColor; }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: currentColor; }

.notice {
    padding: .8rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--warn-soft);
    color: var(--warn);
    font-size: .88rem;
    margin-bottom: 1.25rem;
}

.empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-faint);
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
}

/* ---------------------------------------------------------------- narrow pages */

.narrow { width: min(26rem, 100%); margin: 3rem auto; }
.narrow .card-body { padding: 1.5rem; }
.narrow h1 { font-size: 1.3rem; }
.centred { text-align: center; }

/* ---------------------------------------------------------------- product page */

.product-hero { display: flex; gap: 2rem; flex-wrap: wrap; align-items: flex-start; }
.product-hero .col-main { flex: 3 1 24rem; min-width: 0; }
.product-hero .col-side { flex: 1 1 15rem; }

.download-list { display: flex; flex-direction: column; gap: .5rem; }

.download-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .6rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-sunken);
}

.download-row .meta { font-size: .8rem; color: var(--text-faint); }

.shots { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .5rem; }

.shots figure { margin: 0; flex: 0 0 auto; width: 18rem; }

.shots img {
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    display: block;
}

.shots figcaption { font-size: .8rem; color: var(--text-faint); margin-top: .3rem; }

/* Rendered markdown */
.prose { font-size: .95rem; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose h1, .prose h2, .prose h3 { margin-top: 1.5rem; }
.prose code {
    font-family: var(--mono);
    font-size: .86em;
    background: var(--surface-sunken);
    padding: .1rem .3rem;
    border-radius: 4px;
}
.prose pre {
    background: var(--surface-sunken);
    padding: .8rem 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    border: 1px solid var(--border);
}
.prose pre code { background: none; padding: 0; }
.prose a { color: var(--accent); }
.prose blockquote {
    margin: 1rem 0;
    padding-left: 1rem;
    border-left: 3px solid var(--border-strong);
    color: var(--text-muted);
}

/* ---------------------------------------------------------------- misc */

.key-reveal {
    background: var(--warn-soft);
    border: 1px solid currentColor;
    color: var(--warn);
    border-radius: var(--radius-sm);
    padding: .9rem 1rem;
    margin-bottom: 1.25rem;
}

.key-reveal code {
    display: block;
    margin-top: .4rem;
    font-family: var(--mono);
    font-size: .9rem;
    word-break: break-all;
    color: var(--text);
    background: var(--surface);
    padding: .5rem .65rem;
    border-radius: 4px;
}

details.panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    margin-bottom: .75rem;
}

details.panel > summary {
    cursor: pointer;
    padding: .6rem .9rem;
    font-weight: 550;
    font-size: .9rem;
    list-style-position: inside;
}

details.panel[open] > summary { border-bottom: 1px solid var(--border); }
details.panel .panel-body { padding: .9rem; }

.stack > * + * { margin-top: 1.25rem; }
.divider { height: 1px; background: var(--border); margin: 1.5rem 0; border: 0; }

.pager { display: flex; gap: .5rem; align-items: center; justify-content: center; margin-top: 1.5rem; }
