:root {
    color-scheme: dark;
    --bg: #111111;
    --surface: #181818;
    --border: #2a2a2a;
    --text: #e8e8e8;
    --muted: #666666;
    --gap: 5px;
    --font-size: 11px;
    --border-radius:3px;
}

html[data-theme="light"] {
    color-scheme: light;
    --bg: #f0f0f0;
    --surface: #e6e6e6;
    --border: #d0d0d0;
    --text: #111111;
    --muted: #888888;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
    scroll-behavior: smooth;
    scrollbar-gutter: stable;
}

body {
    position: relative;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-mono), ui-monospace, SFMono-Regular, "Courier New", monospace;
    font-size: var(--font-size);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.is-page-loading {
    overflow: hidden;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select {
    font: inherit;
    border-radius: var(--border-radius);
}
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
code { font-family: inherit; font-size: inherit; }

.site-shell {
    width: 100%;
    max-width: none;
    margin: 0;
    padding-inline: 14px;
}

.site-header,
.site-main,
.site-footer {
    position: relative;
    z-index: 1;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(17, 17, 17, 0.82);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(14px);
}

html[data-theme="light"] .site-header {
    background: rgba(240, 240, 240, 0.82);
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

.header-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 40px;
}

.brand {
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

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

.site-nav a { color: var(--muted); }
.site-nav a:hover,
.site-nav a[aria-current="page"],
.site-nav a.is-active { color: var(--text); }
.site-nav a,
.footer-links a { text-transform: uppercase; }

.theme-toggle {
    border: none;
    background: none;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
    margin-left: 0;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius);
}

.theme-toggle:hover { color: var(--text); }

.theme-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
}

.theme-icon svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.latent-strip {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.latent-strip canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.62;
}

html[data-theme="light"] .latent-strip canvas {
    opacity: 0.34;
}

.latent-strip::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(to bottom, rgba(17, 17, 17, 0.02) 0%, rgba(17, 17, 17, 0.06) 100%);
    pointer-events: none;
}

html[data-theme="light"] .latent-strip::after {
    background:
        linear-gradient(to bottom, rgba(240, 240, 240, 0.01) 0%, rgba(240, 240, 240, 0.05) 100%);
}

.page-loader {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(17, 17, 17, 0.42);
    backdrop-filter: blur(12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
}

html[data-theme="light"] .page-loader {
    background: rgba(240, 240, 240, 0.52);
}

.page-loader.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.page-loader-panel {
    width: min(90vw, 360px);
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.66);
    overflow: hidden;
    border-radius: var(--border-radius);
}

html[data-theme="light"] .page-loader-panel {
    background: rgba(255, 255, 255, 0.7);
}

.page-loader-grid {
    height: 70px;
    position: relative;
    background:
        linear-gradient(to right, rgba(255, 255, 255, 0.07) 0 1px, transparent 1px 100%),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.07) 0 1px, transparent 1px 100%);
    background-size: 6px 6px;
    opacity: 0.8;
}

html[data-theme="light"] .page-loader-grid {
    background:
        linear-gradient(to right, rgba(0, 0, 0, 0.08) 0 1px, transparent 1px 100%),
        linear-gradient(to bottom, rgba(0, 0, 0, 0.08) 0 1px, transparent 1px 100%);
    background-size: 6px 6px;
}

.page-loader-grid::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.14) 50%, transparent 100%);
    transform: translateX(-100%);
    animation: loader-scan 1.2s linear infinite;
}

html[data-theme="light"] .page-loader-grid::after {
    background:
        linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.12) 50%, transparent 100%);
}

.page-loader-label {
    padding: 10px 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

@keyframes loader-scan {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}

.site-main { padding: 0; }

.tab-row {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 10px 0;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-radius: var(--border-radius);
}

.tab-btn:hover { color: var(--text); }
.tab-btn.is-active { color: var(--text); }

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

.tab-spacer { flex: 1; }

.masonry-grid {
    column-width: 260px;
    column-gap: var(--gap);
    padding: var(--gap) 0;
}

.gallery-card {
    break-inside: avoid;
    margin: 0 0 var(--gap);
    position: relative;
    overflow: hidden;
    background: rgba(24, 24, 24, 0.82);
    border-radius: var(--border-radius);
}

html[data-theme="light"] .gallery-card {
    background: rgba(230, 230, 230, 0.84);
}

.gallery-media {
    display: block;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.18);
    border-radius: var(--border-radius);
}

html[data-theme="light"] .gallery-media {
    background: rgba(0, 0, 0, 0.06);
}

.gallery-media.is-loading {
    min-height: 180px;
}

.gallery-media::before,
.gallery-media::after {
    content: "";
    position: absolute;
    pointer-events: none;
}

.gallery-media::before {
    inset: 0;
    opacity: 0;
    transition: opacity 160ms ease;
}

.gallery-media.is-loading::before {
    opacity: 1;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.14) 50%, rgba(255, 255, 255, 0.04) 100%);
    background-size: 220% 100%;
    animation: image-lazy-pulse 1.35s linear infinite;
}

html[data-theme="light"] .gallery-media.is-loading::before {
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.05) 0%, rgba(0, 0, 0, 0.14) 50%, rgba(0, 0, 0, 0.05) 100%);
    background-size: 220% 100%;
}

.gallery-media::after {
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-top-color: rgba(255, 255, 255, 0.72);
    border-radius: 50%;
    opacity: 0;
}

html[data-theme="light"] .gallery-media::after {
    border-color: rgba(0, 0, 0, 0.2);
    border-top-color: rgba(0, 0, 0, 0.6);
}

.gallery-media.is-loading::after {
    opacity: 0.95;
    animation: image-lazy-spin 0.9s linear infinite;
}

.gallery-media img {
    width: 100%;
    height: auto;
    display: block;
    opacity: 0;
    transition: opacity 220ms ease;
}

.gallery-media img.is-loaded {
    opacity: 1;
}

@keyframes image-lazy-pulse {
    from { background-position: 0% 0; }
    to { background-position: -220% 0; }
}

@keyframes image-lazy-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.card-id {
    display: block;
    padding: 8px 8px 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #999999;
}

html[data-theme="light"] .card-id {
    color: #666666;
}

.save-button {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    padding: 0;
    background: rgba(0, 0, 0, 0.68);
    backdrop-filter: blur(6px);
    cursor: pointer;
    color: rgba(255, 255, 255, 0.82);
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 120ms ease, transform 120ms ease, color 120ms ease, background 120ms ease;
    border-radius: var(--border-radius);
}

html[data-theme="light"] .save-button {
    background: rgba(240, 240, 240, 0.88);
    color: #555555;
}

.gallery-card:hover .save-button,
.gallery-card:focus-within .save-button,
.save-button[aria-pressed="true"] {
    opacity: 1;
    transform: translateY(0);
}

.save-button svg {
    width: 16px;
    height: 16px;
    fill: transparent;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.save-button:hover,
.save-button[aria-pressed="true"] {
    color: var(--text);
}

.save-button[aria-pressed="true"] svg {
    fill: currentColor;
}

body.lightbox-open {
    overflow: hidden;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
}

.lightbox.is-open {
    opacity: 1;
    pointer-events: auto;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    border: none;
    background: rgba(0, 0, 0, 0.84);
    backdrop-filter: blur(12px);
    cursor: pointer;
}

html[data-theme="light"] .lightbox-backdrop {
    background: rgba(240, 240, 240, 0.88);
}

.lightbox-panel {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 10px;
    width: min(94vw, 1600px);
    max-height: calc(100vh - 40px);
    transform: scale(0.94);
    opacity: 0;
    border-radius: var(--border-radius);
    transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1), opacity 220ms ease;
}

.lightbox.is-open .lightbox-panel {
    transform: scale(1);
    opacity: 1;
}

.lightbox-frame {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 0;
}

.lightbox-image {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 96px);
    width: auto;
    height: auto;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(0, 0, 0, 0.72);
    color: rgba(255, 255, 255, 0.92);
    cursor: pointer;
    backdrop-filter: blur(6px);
    border-radius: var(--border-radius);
}

.lightbox-close svg {
    width: 16px;
    height: 16px;
    display: block;
    margin: 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

html[data-theme="light"] .lightbox-close {
    background: rgba(240, 240, 240, 0.88);
    color: #333333;
}

.lightbox-close:hover {
    color: var(--text);
}

.lightbox-id {
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #999999;
    padding-inline: 4px;
}

.empty-state {
    padding: 48px 0;
    color: var(--muted);
    text-align: center;
}

.info-wrap {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 48px clamp(8px, 2vw, 18px) 72px;
}

.info-wrap h1 {
    font-size: var(--font-size);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 32px;
    color: var(--text);
}

.info-card {
    margin-bottom: 28px;
}

.info-card h2 {
    font-size: var(--font-size);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text);
    margin-bottom: 6px;
}

.info-card p,
.info-card li {
    color: var(--muted);
    line-height: 1.65;
}

.info-card p + p {
    margin-top: 8px;
}

.clean-list {
    list-style: none;
    padding: 0;
}

.clean-list li + li {
    margin-top: 4px;
}

.clean-list li::before {
    content: "- ";
    color: var(--border);
}

.site-footer {
    padding: 12px 0 24px;
}

.footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.footer-row p { color: var(--muted); }

.footer-links {
    display: flex;
    gap: 16px;
}

.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--text); }

@media (max-width: 640px) {
    .site-shell { padding-inline: 14px; }
    .header-row { flex-wrap: nowrap; min-height: 46px; height: auto; padding-block: 8px; gap: 10px; }
    .brand { max-width: 56vw; overflow: hidden; text-overflow: ellipsis; }
    .site-nav { width: auto; margin-left: auto; gap: 10px; }
    .site-nav a { white-space: nowrap; }
    .theme-toggle { margin-left: 0; }
    .masonry-grid { column-width: 100%; }
    .lightbox { padding: 12px; }
    .lightbox-panel { width: calc(100vw - 24px); }
    .lightbox-image { max-height: calc(100vh - 72px); }
    .footer-row { flex-wrap: wrap; justify-content: flex-start; }
    .footer-links { flex-wrap: wrap; gap: 12px; }
}

@media (hover: none) {
    .save-button {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .save-button { transition: none; }
    .lightbox { transition: none; }
    .lightbox-panel { transition: none; }
    .page-loader { transition: none; }
    .gallery-media img { transition: none; }
    .page-loader-grid::after,
    .gallery-media.is-loading::before,
    .gallery-media.is-loading::after { animation: none; }
}
