:root {
    color-scheme: light;
    --bg: #fff;
    --fg: #171717;
    --muted: #6b7280;
    --line: #d8dee4;
    --panel: #f5f7f9;
    --nav: #394b59;
    --accent: #1976a5;
    --shadow: 0 1px 5px #132b3b14
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #1c2630;
    --fg: #e6eaee;
    --muted: #aab5bf;
    --line: #46535e;
    --panel: #25323e;
    --nav: #18232c;
    --accent: #77c8ef;
    --shadow: 0 1px 6px #0004
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif
}

a {
    color: inherit;
    text-decoration: none
}

a:hover {
    color: var(--accent)
}

button,
select,
input {
    font: inherit;
    color: inherit;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: .45rem .6rem
}

button {
    cursor: pointer
}

button:hover,
.button:hover {
    background: var(--panel)
}

.nav {
    height: 56px;
    background: var(--nav);
    color: #edf3f7;
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 0 max(calc((100vw - 1440px)/2), 20px);
    position: sticky;
    top: 0;
    z-index: 5
}

.brand {
    font-size: 20px;
    font-weight: 750
}

.nav nav,
.tools {
    display: flex;
    align-items: center;
    gap: 17px
}

.tools {
    margin-left: auto
}

.nav form {
    margin: 0
}

.nav button,
.nav select {
    color: #edf3f7;
    background: transparent;
    border: 0;
    padding: 4px
}

.nav nav a:hover,
.tools a:hover {
    color: white
}

main {
    max-width: 1440px;
    margin: 0 auto;
    padding: 28px 24px;
    min-height: calc(100vh - 115px)
}

h1 {
    font-size: 25px;
    margin: 4px 0 20px
}

h2 {
    font-size: 19px;
    margin: 24px 0 12px
}

h3 {
    font-size: 16px
}

.hero {
    text-align: center;
    padding: 9vh 0 4vh
}

.hero h1 {
    font-size: 40px
}

.stats,
.quicklinks,
.pills,
.toolbar,
.filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px
}

.stats {
    justify-content: center;
    margin: 36px auto
}

.stat,
.listbox,
.site {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 18px;
    min-width: 130px;
    display: flex;
    flex-direction: column;
    gap: 5px
}

.stat strong {
    font-size: 24px
}

.button {
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 9px 14px;
    background: var(--panel)
}

.filters {
    padding: 12px;
    background: var(--panel);
    border-radius: 9px;
    margin: 12px 0
}

.filters input {
    max-width: 170px
}

.filters select {
    max-width: 170px
}

.toolbar {
    justify-content: flex-end;
    margin: 10px 0
}

.pagination {
    display: flex;
    gap: 7px;
    align-items: center;
    margin: 16px 0;
    flex-wrap: wrap
}

.pagination a,
.pagination strong,
.pagination span {
    padding: 4px 8px;
    border: 1px solid var(--line);
    border-radius: 5px
}

.pagination strong {
    background: var(--nav);
    color: white
}

.pagination>span:last-child {
    margin-left: auto;
    border: 0
}

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

.scene-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr))
}

.performer-grid.columns-6 {
    grid-template-columns: repeat(6, minmax(0, 1fr))
}

.performer-grid.columns-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr))
}

.studio-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr))
}

.card {
    border: 1px solid var(--line);
    border-radius: 9px;
    overflow: hidden;
    background: var(--bg);
    box-shadow: var(--shadow);
    min-width: 0
}

.imagebox {
    height: auto;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--panel);
    color: var(--muted);
    overflow: hidden
}

.imagebox.wide {
    aspect-ratio: 16/9
}

.imagebox img {
    width: 100%;
    height: 100%;
    object-fit: cover
}

.performer-photo {
    height: auto;
    aspect-ratio: auto;
    border: 0;
    border-radius: 0;
    background: transparent
}

.performer-photo img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain
}

.performer-grid .card {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent
}

.performer-nav-settings {
    display: flex;
    align-items: center;
    gap: 6px
}

.performer-nav-settings form {
    margin: 0
}

.performer-nav-settings select {
    font-size: 13px
}

.cardbody {
    padding: 8px 10px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 5px
}

.cardbody>a {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

.cardbody small {
    grid-column: 1/-1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted)
}

.cardbody form {
    grid-column: 2;
    grid-row: 1;
    margin: 0
}

.cardbody button {
    padding: 0 4px;
    border: 0
}

.gender {
    color: #c55;
    font-weight: bold;
    margin-right: 5px
}

.taggroup {
    margin: 26px 0
}

.pills a,
.pills span {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 13px
}

.pills a span {
    border: 0;
    padding: 0 0 0 5px;
    color: var(--muted)
}

.profile {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 24px;
    margin: 20px 0 32px
}

.performer-cover {
    position: relative;
    display: block;
    width: 240px;
    height: 300px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    overflow: hidden;
    background: transparent;
    cursor: pointer
}

.performer-cover:disabled { cursor: default }
.performer-cover .detail-image { display: block; transition: opacity .18s ease }
.performer-cover:not(:disabled):hover .detail-image { opacity: .78 }
.performer-cover:not(:disabled):hover::after { content: ""; position: absolute; inset: 0; background: rgba(0,0,0,.12); pointer-events: none }
.performer-cover .noimg { width: 100%; height: 100% }
.gallery-badge { position: absolute; right: 9px; bottom: 9px; z-index: 1; display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 6px; background: rgba(0,0,0,.76); color: #fff; font-size: 13px; line-height: 1 }
.gallery-badge svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round }
.cover-hover-hint { position: absolute; left: 8px; right: 8px; bottom: 10px; z-index: 1; color: #fff; opacity: 0; text-align: left; font-size: 12px; text-shadow: 0 1px 3px #000; transition: opacity .18s ease }
.performer-cover:hover .cover-hover-hint { opacity: 1 }
.performer-gallery { position: fixed; inset: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; overflow: hidden; border: 0; background: rgba(36,52,63,.88); color: #fff }
.performer-gallery::backdrop { background: rgba(0,0,0,.58) }
.gallery-stage { display: grid; grid-template-columns: minmax(0,1.1fr) minmax(420px,.9fr); gap: 22px; width: 100%; height: 100%; padding: 20px 70px 20px 24px; box-sizing: border-box }
.gallery-main { display: flex; position: relative; min-width: 0; min-height: 0; flex-direction: column; align-items: center; justify-content: center }
.gallery-main img { display: block; width: 100%; height: calc(100% - 40px); object-fit: contain; background: rgba(0,0,0,.12); transition: opacity .12s ease }
.gallery-main img.is-loading { opacity: .35 }
.gallery-main-count { display: block; height: 32px; padding-top: 8px; box-sizing: border-box; text-align: center; font-size: 16px }
.gallery-side { min-width: 0; min-height: 0; overflow: hidden }
.gallery-thumbnails { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); grid-auto-rows: 200px; gap: 10px; height: 100%; padding-right: 4px; overflow-y: auto; align-content: start }
.gallery-thumb { position: relative; min-width: 0; min-height: 0; padding: 0; overflow: hidden; border: 2px solid rgba(255,255,255,.55); border-radius: 8px; background: #18232b; cursor: pointer }
.gallery-thumb.is-active { border-color: #ff4c55 }
.gallery-thumb img { display: block; width: 100%; height: 100%; object-fit: cover }
.gallery-thumb span { position: absolute; right: 3px; bottom: 3px; padding: 3px 5px; border-radius: 3px; background: rgba(0,0,0,.75); color: #fff; font-size: 12px; line-height: 1.1 }
.gallery-close { position: absolute; top: 12px; right: 12px; z-index: 2; width: 42px; height: 42px; padding: 0; border: 0; background: transparent; color: #c2cbd0; font-size: 42px; font-weight: 200; line-height: 1; cursor: pointer }
@media (max-width: 900px) { .gallery-stage { grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(40vh,1fr) minmax(0,.8fr); gap: 10px; padding: 12px 44px 12px 12px } .gallery-thumbnails { grid-template-columns: repeat(auto-fill,minmax(90px,1fr)); grid-auto-rows: 120px } }

.detail-image {
    object-fit: cover;
    border-radius: 8px;
    background: var(--panel)
}

.portrait {
    width: 240px;
    height: 300px
}

.wide-detail {
    width: min(850px, 100%);
    aspect-ratio: 16/9
}

.noimg {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--panel);
    color: var(--muted);
    border-radius: 8px
}

.facts {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 6px 14px
}

.facts dt {
    color: var(--muted)
}

.facts dd {
    margin: 0
}

.sitegrid,
.listgrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px
}

.site {
    min-width: 0
}

.site p {
    margin: 0;
    color: var(--muted)
}

.auth {
    max-width: 450px;
    margin: 5vh auto;
    padding: 24px;
    background: var(--panel);
    border-radius: 10px
}

.auth input {
    max-width: 100%
}

.notice {
    padding: 10px;
    background: #1976a522;
    border-radius: 6px
}

footer {
    text-align: center;
    padding: 16px;
    color: var(--muted);
    border-top: 1px solid var(--line)
}

@media(max-width:1100px) {
    .scene-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr))
    }

    .performer-grid.columns-5,
    .performer-grid.columns-6,
    .studio-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr))
    }

    .nav {
        gap: 14px
    }

    .nav nav {
        gap: 10px
    }
}

@media(max-width:720px) {
    .nav {
        height: auto;
        min-height: 56px;
        flex-wrap: wrap;
        padding: 10px 14px
    }

    .nav nav {
        order: 3;
        width: 100%;
        overflow: auto
    }

    .tools {
        gap: 7px
    }

    .nav nav a {
        white-space: nowrap
    }

    main {
        padding: 20px 14px
    }

    .scene-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr))
    }

    .performer-grid.columns-5,
    .performer-grid.columns-6,
    .studio-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr))
    }

    .profile {
        grid-template-columns: 1fr
    }

    .portrait {
        width: 200px;
        height: 250px
    }

    .filters input,
    .filters select {
        max-width: 100%;
        flex: 1 1 130px
    }
}

@media(min-width:721px) and (max-width:900px) {

    .performer-grid.columns-5,
    .performer-grid.columns-6,
    .studio-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr))
    }
}

/* Performer index is an edge-to-edge wall of uncropped portraits. */
.performer-grid {
    gap: 0
}

.performer-grid .performer-photo {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: auto;
    overflow: visible
}

.performer-grid .performer-photo img {
    display: block;
    width: 100%;
    height: auto;
    max-width: none;
    object-fit: unset;
    vertical-align: top
}

/* Masonry-style performer wall: preserve each image's natural proportions. */
.performer-grid {
    display: block;
    columns: 6;
    column-gap: 0;
    gap: 0
}

.performer-grid .card {
    display: inline-block;
    width: 100%;
    margin: 0;
    padding: 0;
    break-inside: avoid;
    vertical-align: top
}

@media(max-width:1100px) {
    .performer-grid {
        columns: 4
    }
}

@media(max-width:720px) {
    .performer-grid {
        columns: 3
    }
}

/* Studio logos stay uncropped in a landscape frame; name and count share one line. */
.studio-photo {
    aspect-ratio: 16/9;
    background: #111820
}

.studio-photo img {
    width: 100%;
    height: 100%;
    object-fit: contain
}

.studio-cardbody {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px
}

.studio-cardbody>a {
    flex: 1;
    min-width: 0
}

.studio-cardbody .studio-count {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap
}

.studio-cardbody form {
    flex: 0 0 auto;
    margin: 0
}

/* Studio detail logos use their stored aspect ratio in a dark landscape panel. */
.studio-profile {
    grid-template-columns: minmax(0, min(42vw, 520px)) minmax(0, 1fr);
    align-items: start
}

.studio-detail-logo {
    display: block;
    width: 100%;
    height: auto;
    max-width: 520px;
    object-fit: contain;
    background: #111820;
    padding: 14px;
    border-radius: 8px
}

.studio-detail-placeholder {
    width: 100%;
    max-width: 520px;
    aspect-ratio: 16/9;
    background: #111820;
    color: #aab5bf
}

@media(max-width:720px) {
    .studio-profile {
        grid-template-columns: 1fr
    }

    .studio-detail-logo,
    .studio-detail-placeholder {
        max-width: 100%
    }
}

.page-nav-settings {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap
}

.page-nav-settings form {
    margin: 0
}

.page-nav-settings span {
    font-size: 13px
}

.scene-sort-only {
    margin: 12px 0
}

/* Main scene index is an image-only, edge-to-edge masonry wall. */
.scene-wall {
    display: block;
    columns: 3;
    column-gap: 0;
    gap: 0
}

.scene-wall .card {
    display: inline-block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    break-inside: avoid;
    vertical-align: top
}

.scene-photo {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: auto;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent
}

.scene-photo img {
    display: block;
    width: 100%;
    height: auto;
    max-width: none;
    object-fit: unset;
    vertical-align: top
}

@media(min-width:1801px) {
    .scene-wall {
        columns: 4
    }
}

@media(max-width:1100px) {
    .scene-wall {
        columns: 2
    }
}

@media(max-width:720px) {
    .scene-wall {
        columns: 1
    }
}

.scene-detail-image {
    display: block;
    width: min(1280px, 100%);
    height: auto;
    max-height: none;
    aspect-ratio: auto;
    object-fit: contain
}
