:root {
  color-scheme: dark;
  --bg: #090a0c;
  --panel: #111316;
  --panel-2: #17191d;
  --ink: #f4f1e9;
  --muted: #8c8e92;
  --line: rgba(255, 255, 255, .1);
  --accent: #e3ff5a;
  --accent-ink: #111500;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
html { scrollbar-width: none; }
html::-webkit-scrollbar { display: none; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 20; height: 68px; padding: 0 clamp(18px, 4vw, 58px);
  display: flex; align-items: center; justify-content: space-between;
  background: color-mix(in srgb, var(--bg) 86%, transparent); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(140%);
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-weight: 720; letter-spacing: -.02em; }
.brand-mark, .login-mark { display: grid; grid-template-columns: repeat(2, 8px); gap: 2px; transform: rotate(7deg); }
.brand-mark i, .login-mark span { display: block; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); }
.brand-mark i:nth-child(2), .login-mark span:nth-child(2) { opacity: .55; }
.brand-mark i:nth-child(3), .login-mark span:nth-child(3) { opacity: .25; }
.header-actions, .lightbox-actions { display: flex; align-items: center; gap: 8px; }
.lightbox-actions { flex: 0 0 auto; }
.header-actions form { margin: 0; }
.icon-button, .text-button { border: 0; background: transparent; cursor: pointer; }
.icon-button { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; }
.icon-button:hover, .icon-button:focus-visible { background: var(--panel-2); }
.icon-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.text-button { padding: 10px 13px; color: var(--muted); }
.text-button:hover { color: var(--ink); }

.search-panel { position: sticky; top: 68px; z-index: 19; padding: 14px clamp(18px, 4vw, 58px); background: var(--panel); border-bottom: 1px solid var(--line); }
.search-panel label { position: absolute; width: 1px; height: 1px; overflow: hidden; }
.search-panel input { width: 100%; padding: 13px 16px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; outline: none; }
.search-panel input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(227, 255, 90, .1); }

.gallery-shell { width: min(1800px, 100%); margin: auto; padding: 34px clamp(18px, 4vw, 58px) 80px; }
.breadcrumbs { display: flex; align-items: center; gap: 8px; min-height: 34px; overflow-x: auto; scrollbar-width: none; color: #65676c; }
.breadcrumbs::-webkit-scrollbar { display: none; }
.crumb { flex: 0 0 auto; padding: 5px 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.crumb:last-child { color: var(--ink); }
.crumb:hover { color: var(--accent); }
.gallery-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 36px 0 38px; }
.gallery-heading-side { display: flex; align-items: flex-end; flex-direction: column; gap: 11px; }
.eyebrow { margin: 0 0 11px; color: var(--accent); font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .18em; }
h1 { margin: 0; font-size: clamp(38px, 7vw, 82px); line-height: .94; letter-spacing: -.055em; }
.item-count { margin: 0 0 7px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.share-folder-button { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); color: var(--ink); font-size: 12px; cursor: pointer; }
.share-folder-button:hover { border-color: rgba(227, 255, 90, .45); background: var(--panel-2); }
.share-folder-button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.folder-section { margin-bottom: 40px; }
.folder-section h2 { margin: 0 0 14px; font-size: 12px; color: var(--muted); font-weight: 550; }
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 9px; }
.folder-card { min-width: 0; padding: 15px 16px; display: flex; align-items: center; gap: 12px; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); cursor: pointer; }
.folder-card:hover, .folder-card:focus-visible { border-color: rgba(227, 255, 90, .45); background: var(--panel-2); }
.folder-icon { position: relative; width: 24px; height: 18px; border-radius: 3px; background: var(--accent); opacity: .84; }
.folder-icon::before { content: ''; position: absolute; top: -4px; left: 1px; width: 10px; height: 6px; border-radius: 3px 3px 0 0; background: inherit; }
.folder-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.folder-arrow { margin-left: auto; color: #5b5e62; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: clamp(8px, 1.15vw, 18px); }
.image-card { position: relative; min-width: 0; }
.image-open { width: 100%; min-width: 0; padding: 0; display: block; border: 0; background: transparent; color: inherit; text-align: left; cursor: zoom-in; }
.image-card-delete { position: absolute; z-index: 3; top: 3px; right: 3px; width: 28px; height: 28px; padding: 0; display: grid; place-items: center; border: 0; background: transparent; color: rgba(255, 220, 216, .72); filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .75)); cursor: pointer; }
.image-card-delete:hover, .image-card-delete:focus-visible { background: transparent; color: #ffd2ce; }
.image-card-delete:disabled { opacity: .45; cursor: wait; }
.image-card-delete svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.image-frame { position: relative; display: block; aspect-ratio: 1; overflow: hidden; border-radius: var(--radius); background: linear-gradient(110deg, #111317 25%, #191b20 45%, #111317 65%); background-size: 220% 100%; animation: shimmer 1.5s linear infinite; }
.image-frame::after { content: ''; position: absolute; inset: 0; border: 1px solid rgba(255, 255, 255, .08); border-radius: inherit; pointer-events: none; }
.image-frame img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transform: scale(1.015); transition: opacity .25s ease, transform .45s ease; }
.image-frame.loaded { animation: none; background: var(--panel); }
.image-frame.loaded img { opacity: 1; }
.image-card:hover img { transform: scale(1.045); }
.image-frame.failed::before { content: 'Preview unavailable'; position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.image-meta { padding: 10px 2px 4px; display: flex; align-items: baseline; gap: 8px; }
.image-name { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: #d2d2ce; }
.image-size { color: #5f6165; font-size: 10px; white-space: nowrap; }
@keyframes shimmer { to { background-position-x: -220%; } }
.loading-row { height: 90px; display: flex; justify-content: center; align-items: center; gap: 6px; }
.loading-row span { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: pulse .8s ease infinite alternate; }
.loading-row span:nth-child(2) { animation-delay: .15s; }
.loading-row span:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { to { opacity: .2; transform: translateY(5px); } }
.empty-state { padding: 12vh 20px; text-align: center; color: var(--muted); }
.empty-state div { font-size: 44px; transform: rotate(10deg); }
.empty-state h2 { margin: 20px 0 5px; color: var(--ink); font-size: 20px; }
.empty-state p { margin: 0; font-size: 13px; }

.lightbox { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(5, 6, 7, .98); color: var(--ink); overflow: hidden; }
.lightbox::backdrop { background: #050607; }
.lightbox-backdrop { position: absolute; inset: 0; }
.lightbox-header { position: absolute; z-index: 3; top: 0; left: 0; right: 0; padding: max(16px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 16px max(18px, env(safe-area-inset-left)); display: flex; justify-content: space-between; align-items: center; background: linear-gradient(#050607 0%, transparent 100%); }
.lightbox-header > div:first-child { min-width: 0; }
.lightbox-name { max-width: min(60vw, 700px); margin: 0 0 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.lightbox-index { margin: 0; color: var(--muted); font-size: 11px; }
.lightbox-download, .lightbox-delete { display: flex; align-items: center; gap: 7px; padding: 10px 13px; border: 0; color: var(--ink); border-radius: 22px; background: transparent; text-decoration: none; font-size: 13px; cursor: pointer; }
.lightbox-download:hover, .lightbox-delete:hover { background: var(--panel-2); }
.lightbox-delete { border: 1px solid rgba(255, 142, 134, .35); background: rgba(255, 96, 86, .14); color: #ff9a92; }
.lightbox-delete:hover { border-color: rgba(255, 142, 134, .58); background: rgba(255, 96, 86, .24); }
.lightbox-delete:disabled { opacity: .45; cursor: wait; }
.lightbox-download.saving { opacity: .45; pointer-events: none; }
.lightbox-download svg, .lightbox-delete svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.lightbox-stage { position: absolute; inset: 70px 70px 30px; margin: 0; display: grid; place-items: center; }
.lightbox-stage, .lightbox-stage img { touch-action: pan-x pan-y pinch-zoom; }
.lightbox-stage img { position: absolute; z-index: 1; inset: 0; width: auto; height: auto; max-width: 100%; max-height: 100%; margin: auto; object-fit: contain; transition: opacity .18s ease; }
.lightbox-preview { opacity: .78; }
.lightbox-preview.hidden { opacity: 0; }
.lightbox-hd-preview { z-index: 2 !important; opacity: 0; }
.lightbox-hd-preview.ready { opacity: 1; }
.lightbox-hd-preview.hidden { opacity: 0; }
.lightbox-nav { position: absolute; z-index: 2; top: 50%; width: 48px; height: 70px; margin-top: -35px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .04); color: var(--ink); cursor: pointer; font-size: 38px; font-weight: 200; }
.lightbox-nav:hover { background: rgba(255, 255, 255, .1); }
.lightbox-nav.previous { left: 12px; }
.lightbox-nav.next { right: 12px; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 28px; transform: translate(-50%, 30px); padding: 11px 15px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); color: var(--ink); font-size: 12px; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.scroll-progress { position: fixed; z-index: 18; top: 50%; right: 8px; height: min(38vh, 300px); transform: translateY(-50%); display: flex; align-items: center; pointer-events: none; }
.scroll-progress[hidden] { display: none; }
.scroll-progress-track { position: relative; display: block; width: 3px; height: 100%; border-radius: 3px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.scroll-progress-thumb { position: absolute; top: 0; left: 0; display: block; width: 100%; min-height: 28px; border-radius: inherit; background: var(--accent); will-change: transform; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

.share-dialog { width: min(92vw, 540px); max-width: none; padding: 0; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); color: var(--ink); box-shadow: 0 30px 100px rgba(0, 0, 0, .7); }
.share-dialog::backdrop { background: rgba(0, 0, 0, .72); backdrop-filter: blur(7px); }
.share-form { padding: clamp(22px, 5vw, 34px); }
.share-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.share-dialog-header h2 { margin: 0; font-size: 28px; letter-spacing: -.035em; }
.share-copy { margin: 18px 0 26px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.share-fields { display: grid; gap: 18px; }
.share-fields label { display: grid; gap: 8px; color: #c7c7c2; font-size: 12px; }
.share-fields small { margin-left: 4px; color: var(--muted); font-weight: 400; }
.share-fields input, .share-fields select, .share-url { width: 100%; height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 9px; outline: none; background: var(--bg); color: var(--ink); }
.share-fields input:focus, .share-fields select:focus, .share-url:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(227, 255, 90, .1); }
.duration-row { display: grid; grid-template-columns: 1fr 110px; gap: 8px; }
.share-create:disabled { opacity: .45; cursor: wait; }
.share-result { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.share-result > p:first-child { margin: 0 0 9px; color: var(--accent); font-size: 12px; font-weight: 650; }
.share-url-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.share-copy-button { padding: 0 16px; border: 0; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; }
.share-expiry { margin: 9px 2px 0; color: var(--muted); font-size: 11px; }
.share-manager-toggle { position: relative; }
.share-count-badge { position: absolute; top: 2px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px; display: grid; place-items: center; border: 2px solid var(--bg); border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 8px; font-weight: 800; }
.share-count-badge[hidden] { display: none; }
.share-manager-dialog { width: min(94vw, 680px); max-width: none; max-height: min(82dvh, 760px); padding: 0; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); color: var(--ink); box-shadow: 0 30px 100px rgba(0, 0, 0, .7); }
.share-manager-dialog::backdrop { background: rgba(0, 0, 0, .72); backdrop-filter: blur(7px); }
.share-manager-panel { padding: clamp(22px, 5vw, 34px); }
.share-manager-copy { margin: 18px 0 22px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.share-manager-list { display: grid; gap: 9px; }
.share-manager-item { min-width: 0; padding: 14px 15px; display: flex; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.share-manager-info { min-width: 0; flex: 1; display: grid; gap: 5px; }
.share-manager-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.share-manager-info span { color: var(--muted); font-size: 10px; }
.share-manager-actions { display: flex; align-items: center; gap: 7px; }
.share-manager-actions button { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); color: var(--ink); font-size: 11px; cursor: pointer; }
.share-manager-actions button[data-action='revoke'] { color: #ff8e86; }
.share-manager-actions button:disabled { opacity: .45; cursor: wait; }
.share-manager-empty { margin: 32px 0 8px; color: var(--muted); text-align: center; font-size: 13px; }

.public-share-page { min-height: 100dvh; background: #050607; overscroll-behavior: none; }
.public-share-message { width: min(100% - 40px, 430px); min-height: 100dvh; margin: auto; display: flex; justify-content: center; flex-direction: column; }
.public-share-message h1 { font-size: clamp(38px, 11vw, 62px); }
.public-share-message > p:not(.eyebrow) { margin: 18px 0 28px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.public-share-viewer { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.public-share-viewer > header { position: relative; z-index: 2; padding: max(18px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 16px max(20px, env(safe-area-inset-left)); display: flex; align-items: center; justify-content: flex-end; }
.public-share-refresh { display: flex; align-items: center; gap: 8px; padding: 11px 16px; border: 1px solid rgba(227, 255, 90, .28); border-radius: 22px; background: rgba(227, 255, 90, .08); color: var(--accent); cursor: pointer; }
.public-share-refresh:disabled { opacity: .4; cursor: wait; }
.public-share-refresh svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.public-share-stage { position: relative; min-height: 0; margin: 0; display: grid; place-items: center; overflow: hidden; }
.public-share-image { max-width: 100%; max-height: calc(100dvh - 96px); object-fit: contain; opacity: 0; transition: opacity .18s ease; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.public-share-image.ready { opacity: 1; }
.public-share-loading { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(5, 6, 7, .12); }
.public-share-loading[hidden] { display: none; }
.public-share-loading i { width: 36px; height: 36px; border: 3px solid rgba(255, 255, 255, .24); border-top-color: var(--accent); border-radius: 50%; filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .75)); animation: share-spin .72s linear infinite; }
@keyframes share-spin { to { transform: rotate(360deg); } }
.public-share-error { max-width: 320px; padding: 14px 18px; color: #ff9c95; text-align: center; font-size: 13px; }

.login-page { display: grid; min-height: 100dvh; place-items: center; padding: 24px; background: radial-gradient(circle at 50% -20%, #252a1c 0, var(--bg) 40%); }
.login-card { width: min(100%, 410px); padding: clamp(28px, 7vw, 46px); border: 1px solid var(--line); border-radius: 22px; background: rgba(16, 18, 21, .88); box-shadow: 0 35px 100px rgba(0, 0, 0, .42); backdrop-filter: blur(15px); }
.login-mark { grid-template-columns: repeat(2, 12px); gap: 3px; margin-bottom: 40px; }
.login-mark span { width: 12px; height: 12px; border-radius: 3px; }
.login-card h1 { font-size: clamp(34px, 9vw, 48px); }
.login-copy { margin: 18px 0 34px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.login-form label { display: block; margin: 0 0 8px; color: #b6b6b2; font-size: 12px; }
.password-row { position: relative; }
.password-row input { width: 100%; height: 50px; padding: 0 50px 0 14px; color: var(--ink); background: #090a0c; border: 1px solid var(--line); border-radius: 10px; outline: none; }
.password-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(227, 255, 90, .1); }
.password-toggle { position: absolute; top: 4px; right: 4px; }
.form-error { margin: 10px 0 -6px; color: #ff958c; font-size: 12px; }
.primary-button { width: 100%; margin-top: 18px; padding: 15px 17px; display: flex; justify-content: space-between; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 720; cursor: pointer; }
.primary-button:hover { filter: brightness(.92); }
.security-note { margin: 25px 0 0; color: #61646a; text-align: center; font-size: 10px; letter-spacing: .07em; }
.security-note span { margin-right: 4px; color: #58bd73; font-size: 8px; }

@media (max-width: 700px) {
  .topbar { height: 58px; }
  .search-panel { top: 58px; }
  .gallery-shell { padding-top: 22px; }
  .gallery-heading { align-items: flex-start; flex-direction: column; padding: 25px 0 29px; gap: 12px; }
  .gallery-heading-side { width: 100%; align-items: center; flex-direction: row; justify-content: space-between; }
  .folder-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .folder-card { padding: 13px 12px; gap: 9px; }
  .folder-arrow { display: none; }
  .image-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .image-frame { border-radius: 6px; }
  .image-card-delete { top: 2px; right: 2px; width: 26px; height: 26px; }
  .image-card-delete svg { width: 14px; }
  .image-meta { display: none; }
  .lightbox-stage { inset: 70px 0 max(20px, env(safe-area-inset-bottom)); will-change: transform, opacity; }
  .lightbox-nav { display: none; }
  .lightbox-header { gap: 8px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .lightbox-header > div:first-child { max-width: calc(100vw - 158px); }
  .lightbox-name { max-width: 100%; }
  .lightbox-actions { gap: 4px; }
  .lightbox-delete, .lightbox-download { width: 42px; height: 42px; padding: 0; justify-content: center; }
  .lightbox-delete { border: 1px solid rgba(255, 142, 134, .32); background: rgba(255, 96, 86, .15); }
  .lightbox-download span { display: none; }
  .lightbox-delete span { display: none; }
  .scroll-progress { right: 4px; height: 32vh; }
  .share-dialog { width: calc(100vw - 20px); border-radius: 17px; }
  .share-manager-dialog { width: calc(100vw - 20px); border-radius: 17px; }
  .share-manager-item { align-items: flex-start; flex-direction: column; }
  .share-manager-actions { width: 100%; }
  .share-manager-actions button { flex: 1; }
  .public-share-refresh span { display: none; }
  .public-share-refresh { width: 44px; height: 44px; padding: 0; justify-content: center; }
  .public-share-image { max-height: calc(100dvh - 88px); }
}

@media (max-width: 380px) {
  .image-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
}

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