:root {
    --bg: #071019;
    --panel: rgba(14, 27, 39, .78);
    --panel-solid: #101d28;
    --panel-soft: rgba(255, 255, 255, .055);
    --text: #f4f8fb;
    --muted: #92a2b1;
    --line: rgba(255, 255, 255, .11);
    --accent: #6bc4ff;
    --accent-strong: #2ca8f7;
    --shadow: 0 30px 90px rgba(0, 0, 0, .34);
    --radius-lg: 28px;
    --radius-md: 18px;
    --radius-sm: 12px;
}

html[data-theme="paper"] {
    --bg: #eceae4;
    --panel: rgba(255, 255, 255, .76);
    --panel-solid: #f9f8f4;
    --panel-soft: rgba(24, 30, 35, .045);
    --text: #182027;
    --muted: #68727a;
    --line: rgba(20, 26, 31, .12);
    --accent: #356f91;
    --accent-strong: #225a7a;
    --shadow: 0 28px 80px rgba(38, 43, 47, .16);
}

html[data-theme="warm"] {
    --bg: #17100d;
    --panel: rgba(43, 27, 21, .8);
    --panel-solid: #2b1b15;
    --panel-soft: rgba(255, 225, 196, .07);
    --text: #fff7ef;
    --muted: #c3aa98;
    --line: rgba(255, 225, 196, .13);
    --accent: #eead75;
    --accent-strong: #dd8242;
    --shadow: 0 30px 90px rgba(0, 0, 0, .42);
}

html[data-theme="minimal"] {
    --bg: #0d0d0e;
    --panel: rgba(23, 23, 25, .86);
    --panel-solid: #18181a;
    --panel-soft: rgba(255, 255, 255, .045);
    --text: #f7f7f7;
    --muted: #929296;
    --line: rgba(255, 255, 255, .1);
    --accent: #efefef;
    --accent-strong: #ffffff;
    --shadow: 0 30px 90px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 18% -8%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 34%),
        radial-gradient(circle at 90% 18%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 30%),
        var(--bg);
    font-family: Inter, "SF Pro Display", "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
    transition: background-color .25s ease, color .25s ease;
}

button, input { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.ambient {
    position: fixed;
    border-radius: 999px;
    filter: blur(100px);
    opacity: .2;
    pointer-events: none;
    z-index: 0;
}

.ambient-one { width: 38vw; height: 38vw; left: -14vw; top: 5vh; background: var(--accent); }
.ambient-two { width: 30vw; height: 30vw; right: -10vw; top: 34vh; background: var(--accent-strong); opacity: .11; }

.app-shell {
    position: relative;
    z-index: 1;
    width: min(1480px, 100%);
    min-height: 100vh;
    margin: 0 auto;
    padding: 28px clamp(18px, 3vw, 48px) 56px;
}

.center-state {
    min-height: calc(100vh - 84px);
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 18px;
    color: var(--muted);
}

.logo-mark {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    color: var(--accent);
}
.logo-mark svg { width: 100%; height: 100%; }
.logo-mark--large { width: 78px; height: 78px; }
.logo-mark--small { width: 42px; height: 42px; flex: 0 0 auto; }

.spinner {
    width: 26px;
    height: 26px;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
.spinner--small { width: 18px; height: 18px; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-view {
    min-height: calc(100vh - 84px);
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(360px, 480px);
    align-items: center;
    gap: clamp(48px, 8vw, 130px);
    padding: clamp(24px, 7vh, 80px) clamp(0px, 4vw, 60px);
}

.login-copy { max-width: 720px; }
.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 750;
    letter-spacing: .18em;
}
.login-copy h1 {
    margin: 12px 0 22px;
    font-size: clamp(48px, 6vw, 88px);
    line-height: .98;
    letter-spacing: -.055em;
}
.login-copy > p:not(.eyebrow) {
    max-width: 650px;
    margin: 0;
    color: var(--muted);
    font-size: clamp(17px, 1.55vw, 22px);
    line-height: 1.75;
}
.security-note {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 32px;
    color: var(--muted);
    font-size: 14px;
}
.security-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #53d58a;
    box-shadow: 0 0 0 5px rgba(83, 213, 138, .12);
}

.login-card {
    padding: clamp(28px, 4vw, 46px);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(28px) saturate(140%);
}
.login-card__head { margin-bottom: 30px; }
.login-card h2 { margin: 0; font-size: 30px; letter-spacing: -.035em; }
.login-card__head > p:last-child { margin: 10px 0 0; color: var(--muted); line-height: 1.6; }

.field { display: grid; gap: 9px; margin-top: 18px; }
.field span { color: var(--muted); font-size: 13px; font-weight: 650; }
.field input {
    width: 100%;
    height: 54px;
    padding: 0 17px;
    border: 1px solid var(--line);
    border-radius: 14px;
    outline: 0;
    color: var(--text);
    background: var(--panel-soft);
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.field input:focus {
    border-color: color-mix(in srgb, var(--accent) 68%, transparent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
    background: color-mix(in srgb, var(--panel-solid) 76%, transparent);
}
.field input::placeholder { color: color-mix(in srgb, var(--muted) 72%, transparent); }

.form-error {
    margin: 16px 0 0;
    padding: 12px 14px;
    border: 1px solid rgba(255, 108, 108, .28);
    border-radius: 12px;
    color: #ffb0b0;
    background: rgba(255, 75, 75, .08);
    font-size: 13px;
    line-height: 1.5;
}

.primary-button {
    width: 100%;
    height: 56px;
    margin-top: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 0;
    border-radius: 15px;
    color: #06111a;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 16px 34px color-mix(in srgb, var(--accent) 20%, transparent);
    transition: transform .18s ease, filter .18s ease;
}
.primary-button svg { width: 20px; height: 20px; }
.primary-button:hover { transform: translateY(-1px); filter: brightness(1.05); }
.primary-button:disabled { cursor: wait; opacity: .7; transform: none; }

.portal-view { min-height: calc(100vh - 56px); }
.topbar {
    position: sticky;
    top: 18px;
    z-index: 20;
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 12px 14px 12px 16px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: color-mix(in srgb, var(--panel) 90%, transparent);
    backdrop-filter: blur(28px) saturate(140%);
    box-shadow: 0 18px 55px rgba(0, 0, 0, .16);
}
.brand-button {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    text-align: left;
}
.brand-button small { display: block; color: var(--muted); font-size: 9px; letter-spacing: .16em; }
.brand-button strong { display: block; margin-top: 3px; font-size: 17px; }
.account-area { display: flex; align-items: center; gap: 15px; }
.account-copy { display: grid; text-align: right; }
.account-copy strong { font-size: 14px; }
.account-copy span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.ghost-button, .back-button, .viewer-action {
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--text);
    background: var(--panel-soft);
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.ghost-button { height: 42px; padding: 0 16px; }
.ghost-button:hover, .back-button:hover, .viewer-action:hover { background: color-mix(in srgb, var(--accent) 10%, var(--panel-soft)); border-color: color-mix(in srgb, var(--accent) 32%, var(--line)); }

.content-view { padding: clamp(44px, 7vw, 92px) 0 0; }
.hero-row { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.hero-row h1, .gallery-title-row h1 {
    margin: 0;
    font-size: clamp(34px, 4vw, 58px);
    line-height: 1.04;
    letter-spacing: -.05em;
}
.hero-row p:last-child { margin: 14px 0 0; color: var(--muted); font-size: 16px; }

.folder-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
}
.folder-card {
    min-width: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 24px;
    color: var(--text);
    background: var(--panel);
    box-shadow: 0 18px 48px rgba(0, 0, 0, .12);
    cursor: pointer;
    text-align: left;
    transition: transform .24s ease, border-color .24s ease, box-shadow .24s ease;
}
.folder-card:hover {
    transform: translateY(-5px);
    border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
    box-shadow: 0 26px 66px rgba(0, 0, 0, .22);
}
.folder-cover { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: var(--panel-soft); }
.folder-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.folder-card:hover .folder-cover img { transform: scale(1.035); }
.folder-cover::after { content: ""; position: absolute; inset: auto 0 0; height: 45%; background: linear-gradient(transparent, rgba(0, 0, 0, .48)); }
.folder-cover__empty { width: 100%; height: 100%; display: grid; place-items: center; color: var(--accent); font-size: 44px; background: linear-gradient(135deg, var(--panel-soft), transparent); }
.folder-kind { position: absolute; left: 14px; bottom: 14px; z-index: 1; padding: 7px 10px; border: 1px solid rgba(255, 255, 255, .18); border-radius: 999px; color: white; background: rgba(8, 12, 17, .48); backdrop-filter: blur(12px); font-size: 11px; font-weight: 750; }
.folder-card__body { padding: 20px 20px 18px; }
.folder-card__body h2 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 21px; letter-spacing: -.025em; }
.folder-card__body p { height: 42px; margin: 9px 0 0; overflow: hidden; color: var(--muted); font-size: 13px; line-height: 1.6; }
.folder-card__meta { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

.empty-state { min-height: 360px; display: grid; place-content: center; justify-items: center; text-align: center; color: var(--muted); }
.empty-icon { width: 66px; height: 66px; display: grid; place-items: center; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 22px; color: var(--accent); background: var(--panel-soft); font-size: 30px; }
.empty-state h2 { margin: 0; color: var(--text); font-size: 24px; }
.empty-state p { max-width: 480px; margin: 10px 0 0; line-height: 1.7; }

.gallery-heading { margin-bottom: 24px; }
.back-button { height: 40px; display: inline-flex; align-items: center; gap: 6px; padding: 0 13px; margin-bottom: 24px; }
.back-button svg { width: 18px; height: 18px; }
.gallery-title-row { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.folder-type-badge { display: inline-flex; margin-bottom: 11px; padding: 6px 9px; border-radius: 999px; color: var(--accent); background: color-mix(in srgb, var(--accent) 11%, transparent); font-size: 11px; font-weight: 800; }
#galleryDescription { max-width: 760px; margin: 13px 0 0; color: var(--muted); line-height: 1.7; }
.gallery-stats { display: grid; min-width: 110px; text-align: right; }
.gallery-stats strong { font-size: 32px; line-height: 1; }
.gallery-stats span { margin-top: 5px; color: var(--muted); font-size: 12px; }

.toolbar {
    position: sticky;
    top: 106px;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: color-mix(in srgb, var(--panel) 92%, transparent);
    backdrop-filter: blur(24px);
}
.search-box { width: min(420px, 100%); height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel-soft); }
.search-box svg { width: 18px; height: 18px; color: var(--muted); flex: 0 0 auto; }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; }
.search-box input::placeholder { color: var(--muted); }
.download-hint { padding-right: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; }

.media-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.media-card { min-width: 0; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 17px; color: var(--text); background: var(--panel); cursor: pointer; text-align: left; transition: transform .2s ease, border-color .2s ease; }
.media-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 38%, var(--line)); }
.media-card__image { position: relative; aspect-ratio: 1 / 1; overflow: hidden; background: var(--panel-soft); }
.media-card__image img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.media-card:hover .media-card__image img { transform: scale(1.035); }
.play-mark { position: absolute; inset: 0; display: grid; place-items: center; background: linear-gradient(transparent, rgba(0, 0, 0, .15)); }
.play-mark span { width: 48px; height: 48px; display: grid; place-items: center; padding-left: 3px; border: 1px solid rgba(255, 255, 255, .28); border-radius: 50%; color: white; background: rgba(4, 8, 12, .45); backdrop-filter: blur(10px); }
.media-card__copy { padding: 13px 14px 14px; }
.media-card__copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.media-card__copy span { display: block; margin-top: 7px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.load-more { min-height: 90px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 13px; }
.load-sentinel { height: 2px; }


/* Visitor image-save guard: blocks the normal desktop context menu and the
   mobile long-press image callout without preventing card clicks from bubbling. */
.story-card__media,
.media-card__image,
.viewer-stage {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}
.story-card__media img,
.media-card__image img,
.viewer-stage img,
.viewer-stage video {
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    pointer-events: none;
}
.media-save-guard {
    position: absolute;
    z-index: 5;
    inset: 0;
    display: block;
    background: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: pan-y pinch-zoom;
}
.viewer-image-guard {
    z-index: 2;
    inset: 22px 80px 34px;
}
#viewerImage[hidden] + .viewer-image-guard { display: none; }

.viewer-dialog {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    color: white;
    background: rgba(2, 5, 8, .94);
}
.viewer-dialog::backdrop { background: rgba(0, 0, 0, .74); backdrop-filter: blur(12px); }
.viewer-shell {
    position: relative;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
}
.viewer-topbar { position: relative; z-index: 3; min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px clamp(16px, 3vw, 38px); border-bottom: 1px solid rgba(255, 255, 255, .1); background: rgba(8, 10, 13, .78); backdrop-filter: blur(18px); }
.viewer-index { margin: 0 0 4px; color: rgba(255,255,255,.55); font-size: 10px; }
.viewer-topbar h2 { max-width: 60vw; margin: 0; overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.viewer-actions { display: flex; gap: 8px; }
.viewer-action { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0 14px; color: white; text-decoration: none; background: rgba(255,255,255,.07); }
.viewer-action--icon { width: 42px; padding: 0; }
.viewer-action svg { width: 20px; height: 20px; }
.viewer-stage {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}
.viewer-stage img,
.viewer-stage video {
    position: absolute;
    inset: 22px 80px 34px;
    width: calc(100% - 160px);
    height: calc(100% - 56px);
    max-width: none;
    max-height: none;
    display: block;
    object-fit: contain;
    object-position: center;
    border-radius: 4px;
    box-shadow: 0 28px 80px rgba(0,0,0,.45);
}
.viewer-stage video {
    inset: 22px 80px 94px;
    width: calc(100% - 160px);
    height: calc(100% - 116px);
    pointer-events: none;
}
.viewer-video-guard {
    z-index: 2;
    inset: 22px 80px 94px;
    touch-action: none;
}
.video-controls {
    position: absolute;
    z-index: 5;
    left: 50%;
    bottom: 22px;
    width: min(760px, calc(100% - 190px));
    min-height: 52px;
    display: grid;
    grid-template-columns: auto minmax(100px, 1fr) auto auto auto;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 14px;
    background: rgba(6,9,13,.78);
    box-shadow: 0 12px 38px rgba(0,0,0,.38);
    backdrop-filter: blur(16px);
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.video-control-button {
    min-width: 58px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 10px;
    color: #fff;
    background: rgba(255,255,255,.08);
    cursor: pointer;
}
.video-progress { width: 100%; min-width: 0; accent-color: #fff; }
.video-time { min-width: 94px; color: rgba(255,255,255,.76); font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; }
.video-error {
    position: absolute;
    z-index: 6;
    left: 50%;
    top: 50%;
    max-width: min(560px, calc(100% - 48px));
    margin: 0;
    padding: 14px 18px;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 14px;
    color: #fff;
    background: rgba(12,15,20,.86);
    text-align: center;
    transform: translate(-50%, -50%);
}
.viewer-loading { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.viewer-nav { position: absolute; z-index: 4; top: 50%; width: 48px; height: 58px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.12); border-radius: 15px; color: white; background: rgba(255,255,255,.07); backdrop-filter: blur(10px); cursor: pointer; transform: translateY(-50%); }
.viewer-nav:disabled { opacity: .2; cursor: default; }
.viewer-nav svg { width: 25px; height: 25px; }
.viewer-nav--prev { left: 18px; }
.viewer-nav--next { right: 18px; }

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

@media (max-width: 760px) {
    .app-shell { padding: 14px 13px 36px; }
    .login-view { min-height: calc(100vh - 30px); grid-template-columns: 1fr; gap: 34px; padding: 42px 4px; }
    .login-copy h1 { font-size: 48px; }
    .login-copy > p:not(.eyebrow) { font-size: 16px; }
    .security-note { margin-top: 22px; }
    .login-card { padding: 25px 20px; border-radius: 22px; }
    .topbar { top: 10px; min-height: 64px; border-radius: 18px; }
    .account-copy { display: none; }
    .brand-button small { display: none; }
    .content-view { padding-top: 48px; }
    .hero-row h1, .gallery-title-row h1 { font-size: 36px; }
    .folder-grid { grid-template-columns: 1fr; gap: 16px; }
    .folder-card { border-radius: 20px; }
    .gallery-title-row { align-items: start; }
    .gallery-stats { min-width: 70px; }
    .toolbar { top: 87px; padding: 9px; }
    .download-hint { display: none; }
    .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .media-card { border-radius: 14px; }
    .media-card__copy { padding: 11px 10px 12px; }
    .viewer-stage { padding: 0; }
    .viewer-stage img {
        inset: 12px 8px 78px;
        width: calc(100% - 16px);
        height: calc(100% - 90px);
    }
    .viewer-stage video {
        inset: 12px 8px 146px;
        width: calc(100% - 16px);
        height: calc(100% - 158px);
    }
    .viewer-image-guard { inset: 12px 8px 78px; }
    .viewer-video-guard { inset: 12px 8px 146px; }
    .video-controls {
        bottom: 72px;
        width: calc(100% - 16px);
        min-height: 62px;
        grid-template-columns: auto minmax(70px, 1fr) auto auto;
        gap: 7px;
        padding: 8px;
    }
    .video-time { display: none; }
    .video-control-button { min-width: 48px; padding: 0 8px; }
    .viewer-nav { top: auto; bottom: 18px; width: 54px; height: 48px; transform: none; }
    .viewer-nav--prev { left: calc(50% - 64px); }
    .viewer-nav--next { right: calc(50% - 64px); }
    .viewer-topbar h2 { max-width: 46vw; }
}

@media (max-width: 390px) {
    .media-grid { grid-template-columns: 1fr 1fr; }
    .ghost-button { padding: 0 12px; }
}
