:root {
  color-scheme: dark;
  --bg: #08090c;
  --surface: #111319;
  --surface-2: #171a21;
  --line: rgba(255, 255, 255, .1);
  --line-strong: rgba(255, 255, 255, .18);
  --text: #f4f1ea;
  --muted: #9b9ca3;
  --accent: #d6ff5f;
  --accent-dark: #171b08;
  --danger: #ff8c8c;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 .8rem; color: var(--accent); font-size: .69rem; font-weight: 800; letter-spacing: .2em; }
.brand-mark { display: grid; width: 3.25rem; height: 3.25rem; place-items: center; border-radius: 50%; background: var(--accent); color: #0b0c08; font-family: Georgia, serif; font-size: 1.7rem; font-weight: 900; }
.brand-mark.small { width: 2.65rem; height: 2.65rem; font-size: 1.35rem; }

/* Login */
.login-page { overflow-x: hidden; }
.login-shell { display: grid; min-height: 100vh; grid-template-columns: minmax(0, 1.25fr) minmax(380px, .75fr); }
.login-art { position: relative; display: flex; overflow: hidden; flex-direction: column; justify-content: center; padding: clamp(2rem, 7vw, 7rem); isolation: isolate; }
.login-art::before { position: absolute; z-index: -2; inset: 0; content: ""; background: radial-gradient(circle at 72% 30%, rgba(214, 255, 95, .18), transparent 28%), radial-gradient(circle at 28% 75%, rgba(110, 80, 255, .22), transparent 34%), linear-gradient(135deg, #171a22, #08090c 72%); }
.login-art::after { position: absolute; z-index: -1; width: 38vw; height: 38vw; min-width: 360px; min-height: 360px; right: -8vw; bottom: -12vw; border: 1px solid rgba(255, 255, 255, .12); border-radius: 50%; content: ""; box-shadow: 0 0 0 4vw rgba(255,255,255,.018), 0 0 0 8vw rgba(255,255,255,.012); }
.login-art h1 { margin: 1.6rem 0 1.2rem; max-width: 760px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(3rem, 7vw, 7rem); font-weight: 400; letter-spacing: -.06em; line-height: .96; }
.login-lead { max-width: 29rem; color: #b5b5ba; font-size: clamp(1rem, 1.5vw, 1.25rem); line-height: 1.8; }
.art-stack { position: absolute; right: 8%; top: 17%; width: 20%; aspect-ratio: 3/4; opacity: .45; transform: rotate(7deg); }
.art-stack i { position: absolute; inset: 0; border: 1px solid rgba(255,255,255,.25); border-radius: 1.2rem; background: linear-gradient(160deg, rgba(255,255,255,.1), rgba(255,255,255,.01)); box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.art-stack i:nth-child(2) { transform: translate(-22%, 10%) rotate(-7deg); }
.art-stack i:nth-child(3) { transform: translate(-42%, 21%) rotate(-13deg); }
.login-panel { display: grid; place-items: center; padding: 2rem; background: #0d0f13; border-left: 1px solid var(--line); }
.login-card { width: min(100%, 420px); }
.login-card h2 { margin: 0; font-family: Georgia, serif; font-size: clamp(2.4rem, 5vw, 4rem); font-weight: 400; letter-spacing: -.045em; }
.login-card > .muted { margin: .65rem 0 2.5rem; }
.login-form { display: grid; gap: 1.25rem; }
.login-form label { display: grid; gap: .55rem; color: #c7c7ca; font-size: .82rem; font-weight: 700; }
.login-form input { width: 100%; padding: 1rem 1.05rem; border: 1px solid var(--line-strong); border-radius: .8rem; outline: none; background: #15171d; color: var(--text); transition: border-color .2s, box-shadow .2s; }
.login-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(214,255,95,.1); }
.primary-button { display: flex; min-height: 3.35rem; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1.15rem; border: 0; border-radius: .85rem; background: var(--accent); color: #101207; font-weight: 850; text-decoration: none; cursor: pointer; transition: transform .2s, filter .2s; }
.primary-button:hover { filter: brightness(1.06); transform: translateY(-1px); }
.login-form .primary-button { margin-top: .5rem; }
.login-error { margin: 1.25rem 0; padding: .8rem 1rem; border: 1px solid rgba(255,140,140,.3); border-radius: .7rem; background: rgba(255,140,140,.08); color: #ffb1b1; font-size: .88rem; }
.login-foot { margin-top: 1.5rem; color: #666a72; font-size: .76rem; text-align: center; }

/* Gallery shell */
.site-header { position: sticky; z-index: 20; top: 0; display: grid; min-height: 4.8rem; grid-template-columns: 1fr auto 1fr; align-items: center; padding: .75rem clamp(1rem, 4vw, 3.5rem); border-bottom: 1px solid var(--line); background: rgba(8,9,12,.86); backdrop-filter: blur(18px); }
.brand { display: flex; width: max-content; align-items: center; gap: .8rem; color: var(--text); text-decoration: none; }
.brand > span:last-child { display: grid; gap: .08rem; }
.brand b { font-family: Georgia, serif; font-size: 1.2rem; }
.brand small { color: #74767d; font-size: .54rem; font-weight: 800; letter-spacing: .15em; }
.header-stats { display: flex; gap: 1.6rem; color: var(--muted); font-size: .76rem; }
.header-stats b { color: var(--text); font-size: .88rem; }
.site-header form { justify-self: end; }
.ghost-button { padding: .6rem .9rem; border: 1px solid var(--line); border-radius: .7rem; background: transparent; color: #c7c8cc; cursor: pointer; }
.ghost-button:hover { border-color: var(--line-strong); background: var(--surface); }
.hero { padding: clamp(3rem, 8vw, 7rem) clamp(1rem, 4vw, 3.5rem) clamp(2rem, 5vw, 4rem); }
.hero h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(3.2rem, 8vw, 7.7rem); font-weight: 400; letter-spacing: -.07em; line-height: .9; }
.hero > p:last-child { margin: 1.25rem 0 0; color: var(--muted); font-size: clamp(.95rem, 1.5vw, 1.15rem); }
.toolbar { position: sticky; z-index: 15; top: 4.8rem; display: flex; align-items: end; gap: .7rem; padding: 1rem clamp(1rem, 4vw, 3.5rem); border-block: 1px solid var(--line); background: rgba(8,9,12,.92); backdrop-filter: blur(18px); }
.search-box { display: flex; min-width: 230px; flex: 1; align-items: center; gap: .65rem; padding: .75rem .9rem; border: 1px solid var(--line); border-radius: .75rem; background: var(--surface); }
.search-box span { color: var(--muted); font-size: 1.35rem; line-height: .6; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.search-box input::placeholder { color: #676970; }
.segmented { display: flex; padding: .22rem; border: 1px solid var(--line); border-radius: .75rem; background: var(--surface); }
.segmented button { display: flex; align-items: center; gap: .35rem; padding: .55rem .65rem; border: 0; border-radius: .55rem; background: transparent; color: var(--muted); cursor: pointer; }
.segmented button.is-active { background: #2a2d35; color: var(--text); }
.select-wrap { display: grid; min-width: 120px; gap: .28rem; color: #777980; font-size: .62rem; font-weight: 800; letter-spacing: .08em; }
.select-wrap select, .theme-editor select { padding: .56rem 1.9rem .56rem .7rem; border: 1px solid var(--line); border-radius: .65rem; outline: 0; background: var(--surface); color: var(--text); cursor: pointer; }
.result-line { display: flex; align-items: center; justify-content: space-between; padding: 1.2rem clamp(1rem, 4vw, 3.5rem); color: var(--muted); font-size: .78rem; }
.result-line button { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.result-line button:hover { color: var(--text); }

/* Cards and views */
.gallery { padding: 0 clamp(1rem, 4vw, 3.5rem) 5rem; }
.gallery.view-grid { columns: 4 260px; column-gap: 1rem; }
.image-card { overflow: hidden; margin: 0 0 1rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); break-inside: avoid; box-shadow: 0 16px 38px rgba(0,0,0,.18); transition: transform .25s, border-color .25s; }
.image-card:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.image-card[hidden] { display: none !important; }
.image-open { position: relative; display: block; width: 100%; padding: 0; overflow: hidden; border: 0; background: #08090b; cursor: zoom-in; }
.image-open img { display: block; width: 100%; height: auto; min-height: 180px; max-height: 72vh; object-fit: contain; transition: transform .5s ease; }
.image-card:hover .image-open img { transform: scale(1.018); }
.theme-pill { position: absolute; top: .7rem; left: .7rem; padding: .35rem .55rem; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; background: rgba(8,9,12,.64); color: #eee; font-size: .66rem; backdrop-filter: blur(9px); }
.image-overlay { position: absolute; inset: auto 0 0; display: flex; align-items: center; justify-content: space-between; padding: 3rem .9rem .8rem; background: linear-gradient(transparent, rgba(0,0,0,.75)); opacity: 0; transition: opacity .25s; }
.image-card:hover .image-overlay { opacity: 1; }
.image-overlay span { font-size: .76rem; font-weight: 750; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .8rem .85rem; }
.card-copy { display: grid; min-width: 0; gap: .22rem; }
.card-copy strong { overflow: hidden; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.card-copy > span { color: #70727a; font-size: .64rem; }
.card-actions { display: flex; flex: none; gap: .15rem; }
.metric { display: flex; align-items: center; gap: .2rem; padding: .32rem .38rem; border: 0; border-radius: .45rem; background: transparent; color: #868891; font-size: .67rem; }
button.metric { cursor: pointer; }
button.metric:hover, button.metric.is-active { background: rgba(214,255,95,.1); color: var(--accent); }
button.metric[data-value="-1"].is-active { background: rgba(255,140,140,.1); color: var(--danger); }

.gallery.view-single { display: grid; width: min(100%, 1100px); gap: 2rem; margin: 0 auto; }
.gallery.view-single .image-card { margin: 0; border-radius: 1.25rem; }
.gallery.view-single .image-open img { max-height: 82vh; }
.gallery.view-single .card-meta { padding: 1rem 1.2rem; }

.stack-gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr)); gap: 1.4rem; padding: 0 clamp(1rem, 4vw, 3.5rem) 5rem; }
.stack-card { position: relative; min-height: 360px; padding: 0; overflow: visible; border: 0; background: transparent; color: var(--text); cursor: pointer; text-align: left; }
.stack-visual { position: relative; height: 300px; margin: 1.4rem 1.2rem 0 0; }
.stack-visual::before, .stack-visual::after { position: absolute; inset: 0; border: 1px solid var(--line); border-radius: 1rem; background: #171920; content: ""; }
.stack-visual::before { transform: translate(16px, -16px) rotate(2.5deg); opacity: .5; }
.stack-visual::after { transform: translate(8px, -8px) rotate(1.2deg); opacity: .75; }
.stack-visual img { position: relative; z-index: 2; width: 100%; height: 100%; border: 1px solid var(--line); border-radius: 1rem; object-fit: cover; box-shadow: 0 18px 45px rgba(0,0,0,.34); transition: transform .25s; }
.stack-card:hover img { transform: translateY(-4px); }
.stack-count { position: absolute; z-index: 3; right: .8rem; bottom: .8rem; display: grid; width: 2.5rem; height: 2.5rem; place-items: center; border-radius: 50%; background: var(--accent); color: #111407; font-weight: 900; }
.stack-copy { display: flex; align-items: end; justify-content: space-between; padding: 1rem .25rem 0; }
.stack-copy b { font-family: Georgia, serif; font-size: 1.5rem; font-weight: 400; }
.stack-copy span { color: var(--muted); font-size: .72rem; }
.empty-state { display: grid; min-height: 35vh; place-content: center; gap: .5rem; color: var(--muted); text-align: center; }
.empty-state b { color: var(--text); font-family: Georgia, serif; font-size: 1.8rem; font-weight: 400; }

/* Detail */
.detail-dialog { width: min(94vw, 1320px); max-width: none; height: min(92vh, 900px); max-height: none; padding: 0; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 1.3rem; background: #0d0f13; color: var(--text); box-shadow: 0 40px 100px rgba(0,0,0,.65); }
.detail-dialog::backdrop { background: rgba(0,0,0,.78); backdrop-filter: blur(8px); }
.dialog-shell { display: grid; height: 100%; grid-template-columns: minmax(0, 1fr) 340px; }
.dialog-close { position: absolute; z-index: 5; top: 1rem; right: 1rem; width: 2.5rem; height: 2.5rem; border: 1px solid var(--line); border-radius: 50%; background: rgba(12,13,16,.75); color: var(--text); font-size: 1.35rem; cursor: pointer; backdrop-filter: blur(10px); }
.detail-visual { display: grid; min-width: 0; place-items: center; overflow: hidden; background: #060709; }
.detail-visual img { width: 100%; height: 100%; object-fit: contain; }
.detail-panel { display: flex; flex-direction: column; padding: 4.5rem 1.5rem 1.5rem; border-left: 1px solid var(--line); }
.detail-panel h2 { margin: 0; overflow-wrap: anywhere; font-family: Georgia, serif; font-size: 1.7rem; font-weight: 400; line-height: 1.15; }
.detail-panel > .muted { margin: .7rem 0 1.6rem; font-size: .75rem; }
.detail-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; }
.detail-metrics button, .detail-metrics > div { display: grid; min-height: 5.1rem; grid-template-columns: auto auto; place-content: center; gap: .2rem .4rem; border: 1px solid var(--line); border-radius: .8rem; background: var(--surface); color: var(--text); }
.detail-metrics button { cursor: pointer; }
.detail-metrics button.is-active { border-color: rgba(214,255,95,.45); background: rgba(214,255,95,.08); color: var(--accent); }
.detail-metrics small { grid-column: 1 / -1; color: var(--muted); font-size: .62rem; }
.title-editor { display: grid; gap: .5rem; margin-top: 1.2rem; color: var(--muted); font-size: .75rem; }
.title-editor-row { display: flex; gap: .45rem; }
.title-editor input { min-width: 0; flex: 1; padding: .62rem .7rem; border: 1px solid var(--line); border-radius: .65rem; outline: 0; background: var(--surface); color: var(--text); }
.title-editor input:focus { border-color: rgba(214,255,95,.5); box-shadow: 0 0 0 3px rgba(214,255,95,.08); }
.title-editor button { padding: .55rem .75rem; border: 1px solid var(--line-strong); border-radius: .65rem; background: #252932; color: var(--text); cursor: pointer; }
.title-editor button:hover { border-color: var(--accent); color: var(--accent); }
.detail-info { display: flex; justify-content: space-between; margin-top: 1.4rem; padding: 1rem 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .75rem; }
.detail-info b { color: var(--text); }
.theme-editor { display: grid; gap: .5rem; margin: 1rem 0; color: var(--muted); font-size: .75rem; }
.detail-panel .primary-button { margin-top: auto; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 1.4rem; padding: .7rem 1rem; border: 1px solid var(--line-strong); border-radius: 999px; background: #1c1f26; color: var(--text); font-size: .78rem; opacity: 0; pointer-events: none; transform: translate(-50%, 1rem); transition: opacity .2s, transform .2s; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-art { min-height: 42vh; padding: 2.5rem 2rem; }
  .login-art h1 { font-size: clamp(3rem, 12vw, 5rem); }
  .login-panel { min-height: 58vh; border: 0; border-top: 1px solid var(--line); }
  .art-stack { display: none; }
  .toolbar { flex-wrap: wrap; }
  .search-box { flex-basis: 100%; }
  .select-wrap { flex: 1; }
  .dialog-shell { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; overflow: auto; }
  .detail-panel { padding: 1.2rem; border-top: 1px solid var(--line); border-left: 0; }
  .detail-panel .primary-button { margin-top: 1rem; }
}

@media (max-width: 640px) {
  .site-header { grid-template-columns: 1fr auto; }
  .header-stats { display: none; }
  .hero { padding-top: 3.5rem; }
  .toolbar { top: 4.8rem; align-items: stretch; }
  .segmented { order: 2; flex: 1 0 100%; }
  .segmented button { flex: 1; justify-content: center; }
  .select-wrap { min-width: calc(50% - .5rem); }
  .gallery.view-grid { columns: 2 150px; column-gap: .7rem; }
  .image-card { margin-bottom: .7rem; border-radius: .75rem; }
  .card-meta { align-items: start; flex-direction: column; }
  .image-overlay { display: none; }
  .detail-dialog { width: 100vw; height: 100dvh; border: 0; border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
