:root {
    --background: #ffffff;
    --surface: #f6f7f8;
    --surface-strong: #ebeef1;
    --text: #14161a;
    --muted: #69717d;
    --border: #dce1e7;
    --border-strong: #c6cdd6;
    --accent: #e1192d;
    --accent-dark: #b80f20;
    --cyan: #13bfd0;
    --shadow: 0 18px 48px rgba(20, 22, 26, 0.12);
    --radius: 8px;
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
}

button,
input,
select {
    font: inherit;
}

button,
select {
    cursor: pointer;
}

img {
    display: block;
    max-width: 100%;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(120deg, rgba(225, 25, 45, 0.08), transparent 42%),
        linear-gradient(300deg, rgba(19, 191, 208, 0.12), transparent 38%),
        #ffffff;
}

.auth-panel {
    width: min(100%, 430px);
    display: grid;
    gap: 22px;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow);
}

.auth-brand {
    align-items: center;
}

.auth-panel h1 {
    margin: 4px 0 0;
    font-size: clamp(2rem, 7vw, 3rem);
    line-height: 0.95;
    letter-spacing: 0;
}

.auth-copy {
    margin: 10px 0 0;
    color: var(--muted);
    line-height: 1.45;
}

.auth-error {
    margin: 0;
    padding: 10px 12px;
    border: 1px solid rgba(225, 25, 45, 0.28);
    border-left: 3px solid var(--accent);
    border-radius: 7px;
    background: rgba(225, 25, 45, 0.07);
    color: var(--accent-dark);
    font-size: 0.9rem;
    font-weight: 700;
}

.auth-form {
    display: grid;
    gap: 14px;
}

.auth-form label:not(.remember-control) {
    display: grid;
    gap: 7px;
    color: var(--text);
    font-size: 0.86rem;
    font-weight: 760;
}

.auth-form input[type="password"] {
    height: 42px;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 0 12px;
    color: var(--text);
    background: #ffffff;
    outline: 0;
}

.auth-form input[type="password"]:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(19, 191, 208, 0.16);
}

.remember-control {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 650;
}

.remember-control input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.auth-form .text-button {
    width: 100%;
}

.topbar {
    min-height: 72px;
    display: grid;
    grid-template-columns: minmax(230px, 310px) 1fr auto;
    align-items: center;
    gap: 18px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: var(--text);
    text-decoration: none;
    font-weight: 760;
    line-height: 1.1;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: var(--text);
    color: #ffffff;
    box-shadow: inset 4px 0 0 var(--accent);
    font-size: 0.78rem;
    letter-spacing: 0;
}

.topbar-title {
    min-width: 0;
}

.topbar-title h1,
.gallery-header h2,
.empty-state h2 {
    margin: 0;
    letter-spacing: 0;
}

.topbar-title h1 {
    font-size: clamp(1.35rem, 2vw, 2rem);
    line-height: 1;
}

.topbar-title p,
.topbar-note,
.album-summary,
.breadcrumb,
.lightbox-bottom,
.lightbox-top p {
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.35;
}

.topbar-note {
    border: 1px solid var(--border);
    border-left: 3px solid var(--cyan);
    padding: 8px 10px;
    border-radius: var(--radius);
    white-space: nowrap;
}

.workspace {
    height: calc(100vh - 72px);
    min-height: 560px;
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr);
}

.sidebar {
    border-right: 1px solid var(--border);
    background: #fbfcfd;
    min-height: 0;
    overflow: auto;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 16px 12px;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 0.86rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar-header span {
    min-width: 32px;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-strong);
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 740;
}

.folder-search-control {
    height: 36px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 10px 10px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #ffffff;
}

.folder-search-control input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 0.86rem;
}

.folder-tree {
    padding: 0 10px 18px;
}

.folder-group {
    display: grid;
    gap: 3px;
}

.folder-children {
    margin-left: 16px;
    padding-left: 10px;
    border-left: 1px solid var(--border);
}

.folder-button {
    width: 100%;
    min-height: 36px;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 7px;
    padding: 7px 8px;
    background: transparent;
    color: var(--text);
    text-align: left;
}

.folder-button:hover {
    background: var(--surface);
}

.folder-button.is-active {
    background: #191b20;
    color: #ffffff;
}

.folder-button.is-active .folder-count {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
}

.folder-icon {
    color: var(--accent);
    font-size: 0.96rem;
}

.folder-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
    font-weight: 670;
}

.folder-count {
    min-width: 28px;
    padding: 3px 7px;
    border-radius: 999px;
    background: var(--surface-strong);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 740;
    text-align: center;
}

.gallery-pane {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    padding: 14px;
    background:
        linear-gradient(90deg, rgba(225, 25, 45, 0.05), transparent 18%),
        var(--background);
}

.gallery-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    padding: 2px 2px 12px;
}

.gallery-header h2 {
    font-size: clamp(1.28rem, 1.8vw, 1.78rem);
    line-height: 1.1;
}

.breadcrumb {
    margin-bottom: 4px;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 8px 24px rgba(20, 22, 26, 0.05);
    position: sticky;
    top: 0;
    z-index: 10;
}

.search-control {
    flex: 1 1 260px;
    min-width: 180px;
    height: 38px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #ffffff;
}

.control-icon {
    color: var(--muted);
    font-size: 1.05rem;
}

.search-control input {
    width: 100%;
    border: 0;
    outline: 0;
    color: var(--text);
    background: transparent;
    font-size: 0.92rem;
}

.select-control select {
    height: 38px;
    min-width: 138px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #ffffff;
    color: var(--text);
    padding: 0 34px 0 11px;
    font-size: 0.88rem;
    font-weight: 650;
}

.segmented-control {
    height: 38px;
    display: inline-flex;
    align-items: center;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #ffffff;
}

.icon-button,
.text-button,
.glass-button,
.lightbox-nav {
    border: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.icon-button {
    width: 38px;
    height: 32px;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font-size: 1rem;
}

.icon-button:hover,
.icon-button.is-active {
    background: var(--text);
    color: #ffffff;
}

.text-button {
    height: 38px;
    gap: 8px;
    padding: 0 12px;
    border-radius: 7px;
    background: var(--accent);
    color: #ffffff;
    font-size: 0.88rem;
    font-weight: 780;
}

.text-button:hover {
    background: var(--accent-dark);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
    gap: 8px;
    align-items: start;
    padding-top: 10px;
}

.gallery-grid.is-list {
    grid-template-columns: 1fr;
}

.photo-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    box-shadow: 0 1px 0 rgba(20, 22, 26, 0.04);
    isolation: isolate;
}

.photo-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
}

.photo-button {
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
}

.photo-thumb-wrap {
    aspect-ratio: var(--ratio, 4 / 3);
    background:
        linear-gradient(135deg, rgba(19, 191, 208, 0.18), rgba(225, 25, 45, 0.12)),
        var(--surface-strong);
    overflow: hidden;
}

.photo-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 180ms ease;
}

.photo-card:hover .photo-thumb {
    transform: scale(1.025);
}

.photo-meta {
    display: grid;
    gap: 4px;
    padding: 8px;
}

.photo-title {
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.86rem;
    font-weight: 740;
}

.photo-details {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: var(--muted);
    font-size: 0.73rem;
    line-height: 1.25;
}

.gallery-grid.is-list .photo-button {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    align-items: center;
}

.gallery-grid.is-list .photo-thumb-wrap {
    aspect-ratio: 4 / 3;
}

.gallery-grid.is-list .photo-meta {
    padding: 10px 12px;
}

.empty-state {
    max-width: 560px;
    margin: 80px auto 0;
    padding: 32px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.86);
    text-align: center;
}

.empty-state h2 {
    font-size: 1.35rem;
}

.empty-state p {
    margin: 10px 0 0;
    color: var(--muted);
    line-height: 1.55;
}

.lightbox {
    position: fixed;
    inset: 72px 0 0 292px;
    z-index: 40;
    background: #090a0c;
    color: #ffffff;
    overflow: hidden;
}

.lightbox-stage {
    position: absolute;
    inset: clamp(28px, 5vw, 72px);
    display: grid;
    place-items: center;
}

.lightbox-stage img {
    width: auto;
    height: auto;
    max-width: min(100%, 1080px);
    max-height: min(100%, 720px);
    object-fit: contain;
    transform: scale(var(--zoom, 1));
    transition: transform 140ms ease;
}

.lightbox-top,
.lightbox-bottom {
    position: absolute;
    left: 10px;
    right: 10px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    pointer-events: none;
}

.lightbox-top {
    top: 10px;
}

.lightbox-bottom {
    bottom: 10px;
    color: rgba(255, 255, 255, 0.78);
}

.lightbox-top h2 {
    margin: 0;
    max-width: min(620px, 52vw);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #ffffff;
    font-size: 1rem;
}

.lightbox-top p {
    color: rgba(255, 255, 255, 0.72);
}

.lightbox-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    pointer-events: auto;
}

.glass-button {
    min-width: 38px;
    height: 38px;
    padding: 0 11px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    backdrop-filter: blur(14px);
    font-size: 1.05rem;
    font-weight: 760;
}

.glass-button:hover,
.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.24);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    z-index: 3;
    width: 48px;
    height: 72px;
    transform: translateY(-50%);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    backdrop-filter: blur(14px);
    font-size: 3rem;
    line-height: 1;
}

.lightbox-nav.previous {
    left: 10px;
}

.lightbox-nav.next {
    right: 10px;
}

body.is-lightbox-open {
    overflow: hidden;
}

@media (max-width: 900px) {
    .topbar {
        grid-template-columns: 1fr;
        align-items: start;
        gap: 8px;
        min-height: 130px;
    }

    .topbar-note {
        width: fit-content;
    }

    .workspace {
        height: auto;
        min-height: calc(100vh - 130px);
        grid-template-columns: 1fr;
    }

    .sidebar {
        max-height: 240px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .gallery-pane {
        min-height: calc(100vh - 370px);
    }

    .toolbar {
        flex-wrap: wrap;
    }

    .search-control {
        flex-basis: 100%;
    }

    .lightbox {
        inset: 130px 0 0 0;
    }
}

@media (max-width: 560px) {
    .topbar {
        padding: 12px;
    }

    .gallery-pane {
        padding: 8px;
    }

    .gallery-header {
        align-items: start;
        flex-direction: column;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
        gap: 6px;
    }

    .select-control,
    .select-control select,
    .text-button {
        flex: 1 1 auto;
    }

    .lightbox-stage {
        inset: 18px;
    }

    .lightbox-top h2 {
        max-width: 48vw;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
