:root {
    --bg: #fafaf9;
    --surface: #ffffff;
    --subtle: #f5f5f4;
    --text: #1c1917;
    --muted: #78716c;
    --border: #e7e5e4;
    --border-strong: #d6d3d1;
    --accent: #1d4ed8;
    --danger: #b91c1c;
    --success: #15803d;
    --warn: #a16207;
    --radius: 4px;
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121212;
        --surface: #1a1a1a;
        --subtle: #232323;
        --text: #e7e5e4;
        --muted: #a8a29e;
        --border: #2a2a2a;
        --border-strong: #3a3a3a;
        --accent: #8ab4f8;
        --danger: #f87171;
        --success: #4ade80;
        --warn: #facc15;
        color-scheme: dark;
    }
}

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

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

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

main { flex: 1; }

.wrap {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding-inline: 20px;
}

main.wrap { padding-block: 40px 72px; }

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

h1, h2, h3 { margin: 0 0 .5em; line-height: 1.25; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
img { max-width: 100%; }
[hidden] { display: none !important; }

code, pre, kbd, .mono { font-family: var(--mono); }
.mono { font-size: .93em; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }
strong { font-weight: 600; }

kbd {
    font-size: .8em;
    padding: 0 5px;
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    background: var(--surface);
}

/* Header */

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 56px;
}

.logo {
    font-family: var(--mono);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    white-space: nowrap;
}
.logo:hover { text-decoration: none; }
.logo span { color: var(--muted); font-weight: 400; }
.logo small {
    margin-left: 8px;
    padding: 1px 6px;
    font-size: .7rem;
    font-weight: 400;
    color: var(--muted);
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    vertical-align: 2px;
}

.nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 2px;
}
.nav form { margin: 0; }
.nav > a:not(.btn),
.nav button {
    padding: 6px 10px;
    color: var(--muted);
    background: none;
    border: 0;
    border-radius: var(--radius);
    font: inherit;
    font-size: .92rem;
    cursor: pointer;
}
.nav > a:not(.btn):hover,
.nav button:hover { color: var(--text); background: var(--subtle); text-decoration: none; }
.nav > a.active { color: var(--text); }
.nav .btn { margin-left: 6px; }
.count {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    font-size: .75rem;
    line-height: 18px;
    text-align: center;
    color: var(--bg);
    background: var(--text);
    border-radius: 9px;
}

/* Footer */

.site-footer {
    border-top: 1px solid var(--border);
    padding-block: 22px;
    color: var(--muted);
    font-size: .85rem;
}
.footer-inner { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 20px; flex-wrap: wrap; }
.footer-name { font-family: var(--mono); }
.footer-note { flex: 1; }
.footer-note a, .footer-links a { color: var(--muted); text-decoration: underline; }
.footer-note a:hover, .footer-links a:hover { color: var(--text); }
@media (max-width: 560px) { .footer-note { flex: 1 0 100%; order: 3; } }

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 16px;
    font: inherit;
    font-size: .92rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    cursor: pointer;
}
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn-primary { color: var(--bg); background: var(--text); border-color: var(--text); }
.btn-primary:hover { border-color: var(--text); opacity: .86; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-small { height: 30px; padding: 0 11px; font-size: .84rem; }
.btn-block { width: 100%; }

.btn-link {
    padding: 0;
    font: inherit;
    color: var(--accent);
    background: none;
    border: 0;
    cursor: pointer;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--danger); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Forms */

.field { margin-bottom: 18px; }

label { display: block; margin-bottom: 6px; font-size: .88rem; font-weight: 500; }

input[type="text"],
input[type="password"],
input[type="search"],
input[type="number"] {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
}
input:focus-visible,
.btn:focus-visible,
.btn-link:focus-visible,
.nav button:focus-visible,
.dropzone:focus-within {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
input.input-mono { font-family: var(--mono); font-size: .93rem; }

.check { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 400; font-size: .93rem; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--text); }

.hint { margin: 6px 0 0; font-size: .82rem; color: var(--muted); }
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.form-foot { margin-top: 16px; }

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

.narrow { max-width: 400px; margin: 0 auto; }
.narrow-wide { max-width: 560px; }
.narrow > h1 { margin-bottom: 8px; }
.narrow > .card,
.narrow > .creds { margin-block: 20px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; }

/* Messages */

.flash,
.notice {
    margin-bottom: 20px;
    padding: 11px 14px;
    font-size: .92rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--muted);
    border-radius: var(--radius);
}
.flash-error { border-left-color: var(--danger); }
.flash-success { border-left-color: var(--success); }
.notice { border-left-color: var(--warn); margin-block: 24px; }

.badge {
    display: inline-block;
    padding: 0 7px;
    font-family: var(--mono);
    font-size: .75rem;
    line-height: 20px;
    color: var(--muted);
    border: 1px solid var(--border-strong);
    border-radius: 3px;
}
.badge-pending { color: var(--warn); border-color: currentColor; }
.badge-active { color: var(--success); border-color: currentColor; }
.badge-suspended,
.badge-rejected { color: var(--danger); border-color: currentColor; }

/* Home */

.hero { max-width: 660px; padding-block: 40px 44px; }
.hero h1 { margin-bottom: 18px; font-size: 2.6rem; line-height: 1.1; letter-spacing: -.03em; }
.lead { max-width: 560px; font-size: 1.08rem; color: var(--muted); }
.hero .actions { margin-top: 28px; }

.sample {
    margin: 0 0 72px;
    padding: 18px 22px;
    overflow-x: auto;
    font-size: .9rem;
    line-height: 1.85;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.sample .prompt { color: var(--muted); user-select: none; }

.steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
    margin-bottom: 72px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}
.steps .num { display: block; margin-bottom: 10px; font-family: var(--mono); font-size: .82rem; color: var(--muted); }
.steps h3 { margin-bottom: 6px; }
.steps p { margin: 0; font-size: .93rem; color: var(--muted); }

.specs {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 40px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}
.spec-list { display: grid; grid-template-columns: max-content 1fr; gap: 12px 36px; margin: 0; font-size: .95rem; }
.spec-list dt { color: var(--muted); }
.spec-list dd { margin: 0; }

.prose { max-width: 640px; }
.prose h2 { margin-top: 32px; }

/* Page heads & sections */

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; }

.section { margin-bottom: 44px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.section-title { margin-top: 28px; }

.search { display: flex; gap: 8px; }
.search input { width: 180px; }

/* Upload */

.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    margin: 0;
    padding: 32px 20px;
    text-align: center;
    font-weight: 400;
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    cursor: pointer;
}
.dropzone:hover,
.dropzone.is-over { background: var(--subtle); border-color: var(--text); }
.js .dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dropzone input { margin-bottom: 12px; }
.dz-title { font-size: 1.05rem; font-weight: 600; }
.dz-sub { margin-top: 4px; font-size: .9rem; color: var(--muted); }
.upload-submit { margin-top: 16px; }
.js .js-hide { display: none; }

.upload-list { display: grid; gap: 10px; margin: 24px 0 0; padding: 0; list-style: none; }
.upload-item {
    display: grid;
    grid-template-columns: 60px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.upload-item img { display: block; width: 60px; height: 60px; object-fit: cover; background: var(--subtle); border-radius: 3px; }
.ui-head { display: flex; justify-content: space-between; gap: 12px; }
.ui-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; font-weight: 500; }
.ui-state { flex-shrink: 0; font-size: .82rem; color: var(--muted); }
.ui-error { font-size: .85rem; color: var(--danger); }
.upload-item.is-error { border-color: var(--danger); }
.progress { height: 3px; margin-top: 10px; overflow: hidden; background: var(--border); border-radius: 2px; }
.progress span { display: block; width: 0; height: 100%; background: var(--text); transition: width .15s linear; }

.copy-row { display: flex; gap: 6px; }
.copy-row input { height: 30px; min-width: 0; font-family: var(--mono); font-size: .82rem; }
.upload-item .copy-row { margin-top: 8px; }

/* Grids */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px 12px; }
.grid-item { min-width: 0; }
.tile {
    display: block;
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.tile:hover { border-color: var(--muted); }
.tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tile-caption,
.tile-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    padding-top: 6px;
    font-size: .8rem;
    color: var(--muted);
}
.tile-caption { font-family: var(--mono); }
.tile-caption a { color: var(--text); }
.tile-meta { padding-top: 0; }
.tile-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meta form { margin: 0; }

.empty {
    padding: 44px 24px;
    text-align: center;
    color: var(--muted);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
}
.empty p { margin-bottom: 16px; }
p.empty { padding: 24px; margin: 0; }

.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 28px; font-size: .9rem; }

/* Image page */

.image-page { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 32px; align-items: start; }
.image-view {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    margin: 0;
    padding: 16px;
    background: var(--subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.image-view a { display: block; }
.image-view img { display: block; width: auto; height: auto; max-height: 78vh; }
.image-title { margin-bottom: 6px; font-size: 1.05rem; word-break: break-all; }
.original-name { word-break: break-all; }

.meta { display: grid; grid-template-columns: max-content 1fr; gap: 7px 24px; margin: 16px 0 24px; font-size: .9rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.card.meta { margin: 0; padding: 18px 22px; }
.narrow .card.meta { margin-block: 20px 24px; }

.share .field { margin-bottom: 12px; }
.share label { margin-bottom: 4px; font-size: .78rem; font-weight: 500; color: var(--muted); }
.image-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.image-actions form { margin: 0; }

/* Credentials */

.creds { padding: 0; }
.cred-row {
    display: grid;
    grid-template-columns: 100px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.cred-row:last-child { border-bottom: 0; }
.cred-label { font-size: .85rem; color: var(--muted); }
.cred-value { font-size: 1.05rem; word-break: break-all; }
span.cred-value { font-size: .92rem; }

/* Admin */

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin-bottom: 44px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.stat { padding: 18px 20px; border-right: 1px solid var(--border); }
.stat:last-child { border-right: 0; }
.stat-label { font-size: .8rem; color: var(--muted); }
.stat-value { margin-top: 2px; font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: 2px; margin-bottom: 16px; overflow-x: auto; border-bottom: 1px solid var(--border); }
.tabs a {
    margin-bottom: -1px;
    padding: 8px 12px;
    font-size: .92rem;
    color: var(--muted);
    white-space: nowrap;
    border-bottom: 2px solid transparent;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--text); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 10px 14px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border); }
th { font-size: .78rem; font-weight: 500; color: var(--muted); background: var(--bg); }
tbody tr:last-child td { border-bottom: 0; }
td.actions, th.actions { text-align: right; }
.inline-actions { display: inline-flex; gap: 6px; }
.inline-actions form { margin: 0; }

.checklist { margin: 0 0 8px; padding: 6px 22px; list-style: none; font-size: .9rem; }
.checklist li { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: 0; }
.checklist .ok { color: var(--success); font-family: var(--mono); }
.checklist .fail { color: var(--danger); font-family: var(--mono); }

.back-link { display: inline-block; margin-bottom: 12px; font-size: .87rem; }
.head-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.stack > section { margin-bottom: 32px; }
.stack > section:last-child { margin-bottom: 0; }
.section-top { margin-top: 44px; }
.radio-list { display: grid; gap: 10px; margin-bottom: 18px; }
.input-suffix { display: flex; align-items: center; gap: 10px; }
.input-suffix input { width: 110px; }
.reset-box p { margin-bottom: 10px; }
.reset-box .copy-row { max-width: 420px; }
.notice p:last-child { margin-bottom: 0; }
td .badge { margin-left: 6px; }

.error-page { max-width: 520px; padding-block: 48px; }
.error-code { margin-bottom: 6px; color: var(--muted); }

/* Small screens */

@media (max-width: 860px) {
    .image-page { grid-template-columns: 1fr; }
    .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    main.wrap { padding-block: 28px 56px; }
    .hero { padding-block: 16px 32px; }
    .hero h1 { font-size: 2rem; }
    .steps { grid-template-columns: 1fr; gap: 24px; margin-bottom: 48px; }
    .specs { grid-template-columns: 1fr; gap: 16px; }
    .spec-list { grid-template-columns: 1fr; gap: 2px; }
    .spec-list dd { margin-bottom: 12px; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .stat:nth-child(2) { border-right: 0; }
    .stat:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
    .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .search { width: 100%; }
    .search input { flex: 1; width: auto; }
}

@media (max-width: 480px) {
    .header-inner { flex-wrap: wrap; padding-block: 8px; }
    .cred-row { grid-template-columns: minmax(0, 1fr) auto; }
    .cred-label { grid-column: 1 / -1; }
}
