:root {
  color-scheme: dark;
  --bg: #08090c;
  --panel: #111319;
  --panel-soft: #181b22;
  --text: #f7f8fb;
  --muted: #969da9;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #d9ff57;
  --accent-text: #111500;
  --danger: #ff7d82;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; margin: 0; background: var(--bg); }

body { overflow-x: hidden; }

button, input, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.17em;
}

.login-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(30px + var(--safe-top)) 22px calc(30px + var(--safe-bottom));
  background:
    radial-gradient(circle at 10% 0%, rgba(217, 255, 87, 0.13), transparent 36%),
    radial-gradient(circle at 100% 100%, rgba(85, 110, 255, 0.12), transparent 38%),
    var(--bg);
}

.login-card { width: min(100%, 390px); }

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 19px);
  gap: 3px;
  width: max-content;
  margin-bottom: 28px;
  transform: rotate(-5deg);
}

.brand-mark span { width: 19px; height: 19px; border-radius: 4px; background: var(--text); }
.brand-mark span:nth-child(2), .brand-mark span:nth-child(3) { background: var(--accent); }

.login-card h1, .gallery-header h1 { margin: 0; letter-spacing: -0.045em; }
.login-card h1 { font-size: clamp(40px, 12vw, 58px); line-height: 0.95; }
.login-copy { margin: 18px 0 34px; max-width: 310px; color: var(--muted); line-height: 1.65; }

.login-card label { display: block; margin-bottom: 9px; color: #c7ccd5; font-size: 13px; font-weight: 650; }
.password-row { position: relative; }
.password-row input {
  width: 100%;
  height: 56px;
  padding: 0 70px 0 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
}
.password-row input:focus { border-color: rgba(217, 255, 87, 0.75); box-shadow: 0 0 0 3px rgba(217, 255, 87, 0.1); }
.text-button {
  position: absolute;
  top: 0;
  right: 4px;
  height: 56px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}
.primary-button {
  width: 100%;
  height: 56px;
  margin-top: 12px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 800;
}
.primary-button:disabled { opacity: 0.55; }
.form-error { min-height: 22px; margin: 10px 2px 0; color: var(--danger); font-size: 13px; }
.privacy-note { margin: 30px 0 0; color: #666d78; font-size: 12px; line-height: 1.6; }

.gallery-view { min-height: 100dvh; padding-bottom: calc(28px + var(--safe-bottom)); }
.gallery-header {
  position: sticky;
  z-index: 10;
  top: 0;
  padding: calc(14px + var(--safe-top)) 14px 10px;
  background: linear-gradient(to bottom, rgba(8, 9, 12, 0.98) 78%, rgba(8, 9, 12, 0));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.gallery-header h1 { font-size: 30px; line-height: 1; }
.header-actions { display: flex; gap: 8px; }
.icon-button, .viewer-button {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(24, 27, 34, 0.82);
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}
.search-row { margin-top: 15px; }
.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 44px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 13px;
  background: rgba(24, 27, 34, 0.92);
  color: var(--muted);
}
.search-box input { flex: 1; border: 0; outline: none; background: transparent; color: var(--text); font-size: 15px; }
.search-box input::placeholder { color: #757c87; }
.filter-row { display: flex; gap: 7px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip, .root-filter {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: #aeb4bf;
  font-size: 13px;
}
.filter-chip.is-active { border-color: var(--text); background: var(--text); color: #0b0c0f; font-weight: 750; }
.root-filter { max-width: 150px; appearance: none; padding-right: 15px; }
.gallery-meta { display: flex; justify-content: space-between; margin-top: 10px; color: #626974; font-size: 10px; letter-spacing: 0.03em; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  padding: 3px 2px 0;
}
.media-card {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 1px;
  background: var(--panel-soft);
  text-align: left;
}
.media-card img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity 180ms ease; }
.media-card img.is-loaded { opacity: 1; }
.media-card::after { content: ""; position: absolute; inset: auto 0 0; height: 38%; background: linear-gradient(transparent, rgba(0, 0, 0, 0.48)); pointer-events: none; }
.card-badge { position: absolute; z-index: 2; right: 7px; bottom: 6px; color: white; font-size: 10px; font-weight: 750; text-shadow: 0 1px 5px #000; }
.video-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    linear-gradient(145deg, rgba(217, 255, 87, 0.14), transparent 45%),
    repeating-linear-gradient(135deg, #181b22 0, #181b22 8px, #14171d 8px, #14171d 16px);
}
.video-placeholder span { display: grid; place-items: center; width: 44px; height: 44px; padding-left: 3px; border-radius: 50%; background: rgba(255,255,255,0.92); color: #08090c; font-size: 18px; }
.load-more { display: block; min-width: 150px; height: 44px; margin: 20px auto 0; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); }
.empty-state { padding: 80px 30px; text-align: center; color: var(--muted); }
.empty-state > div { font-size: 38px; color: var(--accent); }
.empty-state h2 { margin: 15px 0 7px; color: var(--text); }
.empty-state p { margin: 0; font-size: 13px; line-height: 1.6; }

.viewer {
  position: fixed;
  z-index: 100;
  inset: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #000;
  overscroll-behavior: none;
}
.viewer-stage { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; touch-action: none; }
.viewer-stage img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; transform-origin: center; will-change: transform; user-select: none; -webkit-user-select: none; }
.viewer-stage video { width: 100%; max-height: 100%; background: #000; touch-action: auto; }
.viewer-toolbar {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: opacity 180ms ease, transform 180ms ease;
}
.viewer-toolbar-top { top: 0; padding: calc(10px + var(--safe-top)) 12px 22px; background: linear-gradient(rgba(0,0,0,0.76), transparent); }
.viewer-toolbar-bottom { bottom: 0; justify-content: space-between; padding: 24px 12px calc(10px + var(--safe-bottom)); background: linear-gradient(transparent, rgba(0,0,0,0.8)); }
.viewer.is-clean .viewer-toolbar { opacity: 0; pointer-events: none; }
.viewer.is-clean .viewer-toolbar-top { transform: translateY(-15px); }
.viewer.is-clean .viewer-toolbar-bottom { transform: translateY(15px); }
.viewer-button { border-color: rgba(255,255,255,0.16); background: rgba(12,12,14,0.54); backdrop-filter: blur(12px); font-size: 25px; }
.viewer-title-wrap { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.viewer-title-wrap strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.viewer-title-wrap span { margin-top: 2px; color: rgba(255,255,255,0.58); font-size: 10px; }
.quality-control { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.quality-control > span { color: rgba(255,255,255,0.6); font-size: 10px; }
.quality-button { min-height: 36px; padding: 0 14px; border: 1px solid rgba(255,255,255,0.22); border-radius: 999px; background: rgba(12,12,14,0.58); font-size: 12px; font-weight: 700; backdrop-filter: blur(12px); }
.spinner { width: 30px; height: 30px; border: 2px solid rgba(255,255,255,0.18); border-top-color: var(--accent); border-radius: 50%; animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.unsupported-video { width: min(86vw, 400px); text-align: center; color: var(--muted); }
.unsupported-video > span { display: grid; place-items: center; width: 68px; height: 68px; margin: 0 auto 20px; padding-left: 5px; border-radius: 50%; background: var(--panel-soft); color: var(--accent); font-size: 28px; }
.unsupported-video h2 { color: var(--text); font-size: 19px; }
.unsupported-video p { font-size: 13px; line-height: 1.65; }
.info-panel { position: absolute; z-index: 8; left: 12px; right: 12px; bottom: calc(12px + var(--safe-bottom)); padding: 22px; border: 1px solid var(--line); border-radius: 22px; background: rgba(20,22,27,0.96); backdrop-filter: blur(22px); }
.info-panel h2 { margin: 0 0 16px; font-size: 18px; }
.info-panel dl { margin: 0; }
.info-panel dl div { display: grid; grid-template-columns: 76px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.info-panel dt { color: var(--muted); font-size: 12px; }
.info-panel dd { min-width: 0; margin: 0; overflow-wrap: anywhere; font-size: 13px; }
.info-close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border: 0; background: transparent; font-size: 24px; }
.toast { position: fixed; z-index: 200; left: 50%; bottom: calc(22px + var(--safe-bottom)); max-width: calc(100vw - 36px); transform: translateX(-50%); padding: 11px 16px; border: 1px solid var(--line); border-radius: 999px; background: rgba(30,32,38,0.96); box-shadow: 0 12px 40px rgba(0,0,0,0.35); font-size: 12px; white-space: nowrap; }

@media (min-width: 700px) {
  .gallery-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; padding: 4px 14px; }
  .gallery-header { padding-left: 22px; padding-right: 22px; }
  .gallery-header h1 { font-size: 36px; }
}

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