/* Catalogs web gallery - dark, photo-first, iOS-like.
   One accent (the desktop app's blue), one easing curve, one radius system:
   cards 22/18 (double bezel), pills for buttons and chips, 14 for inputs, 6 for photo tiles. */

@font-face {
  font-family: "Geist";
  src: url("/static/fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #0b0c0f;
  --surface: #15171c;
  --surface-2: #1b1e24;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text: #eef1f6;
  --text-2: #8b93a3;
  --text-3: #6f7787;
  --accent: #4f8cff;
  --on-accent: #061226;
  --accent-soft: rgba(79, 140, 255, 0.16);
  --accent-text: #9cc0ff;
  --gold: #f4c04e;
  --on-gold: #3a2a03;
  --danger: #ff7a7a;
  --glass: rgba(30, 33, 40, 0.72);
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --r-card: 22px;
  --r-core: 18px;
  --r-input: 14px;
  --r-tile: 6px;
  --pad: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: "Geist", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; }
.icon { width: 20px; height: 20px; flex: none; }
.icon.sm { width: 16px; height: 16px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---- Glass (fixed elements only) ---- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
@media (prefers-reduced-transparency: reduce) {
  .glass { background: #1e2128; -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* ---- Buttons ---- */
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--text);
  transition: transform 0.25s var(--ease), background-color 0.25s var(--ease);
}
.pill:active, .round:active, .card:active { transform: scale(0.98); }
.pill.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.pill.primary .nest {
  width: 30px; height: 30px; margin-right: -10px; border-radius: 999px;
  background: rgba(6, 18, 38, 0.14); display: grid; place-items: center;
  transition: transform 0.35s var(--ease);
}
.pill.primary:hover .nest { transform: translateX(2px); }
.pill[disabled] { opacity: 0.45; cursor: default; }
.round {
  width: 44px; height: 44px; border-radius: 999px; display: grid; place-items: center;
  transition: transform 0.25s var(--ease);
}
.round.gold { background: var(--gold); color: var(--on-gold); border-color: var(--gold); }

/* ---- Chips ---- */
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px var(--pad) 10px;
  scrollbar-width: none; scroll-snap-type: x proximity;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; scroll-snap-align: start;
  padding: 6px 13px; border-radius: 999px; font-size: 13px; color: #cfd5df;
  border: 1px solid var(--line-strong); white-space: nowrap;
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease), transform 0.25s var(--ease);
}
.chip .n { color: var(--text-2); margin-left: 4px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 500; }
.chip[aria-pressed="true"] .n { color: rgba(6, 18, 38, 0.7); }

/* ---- Shell layout ---- */
.layout { min-height: 100dvh; }
.sidebar { display: none; }
.content { padding-bottom: calc(110px + var(--safe-b)); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + var(--safe-t)) var(--pad) 8px;
  background: rgba(11, 12, 15, 0.82);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease);
}
.topbar .small-title {
  font-weight: 600; font-size: 16px; opacity: 0; transform: translateY(6px);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; text-align: center;
}
.topbar.compact { border-bottom-color: var(--line); }
.topbar.compact .small-title { opacity: 1; transform: none; }
.topbar .spacer { width: 44px; flex: none; }

.large-title { padding: 4px var(--pad) 2px; }
.large-title h1 { margin: 0; font-size: 32px; line-height: 1.1; font-weight: 600; letter-spacing: -0.02em; }
.large-title p { margin: 4px 0 0; color: var(--text-2); font-size: 14px; }

.search {
  margin: 12px var(--pad) 10px; display: flex; align-items: center; gap: 8px;
  padding: 0 12px; height: 40px; border-radius: 12px; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--line);
}
.search input { flex: 1; background: none; border: 0; outline: none; color: var(--text); font-size: 15px; min-width: 0; }
.search input::placeholder { color: var(--text-3); }
.search:focus-within { border-color: rgba(79, 140, 255, 0.55); }

/* ---- Run sections ---- */
.section { content-visibility: auto; contain-intrinsic-size: auto 900px; }
.section-head {
  display: flex; align-items: center; gap: 10px; padding: 14px var(--pad) 10px;
}
.section-head .toggle { display: flex; align-items: center; gap: 8px; min-width: 0; }
.section-head .toggle .icon { color: var(--text-2); transition: transform 0.3s var(--ease); }
.section.collapsed .section-head .toggle .icon { transform: rotate(-90deg); }
.section-head h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.section-head .meta { color: var(--text-2); font-size: 13px; white-space: nowrap; }
.hidden-pill {
  margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: #aab2c0; white-space: nowrap;
}
.hidden-pill[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); border-color: rgba(79, 140, 255, 0.4); }
.section.collapsed .grid { display: none; }

/* ---- Album cards (double bezel) ---- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 0 var(--pad) 8px; }
.card {
  position: relative; display: block; text-align: left; width: 100%;
  padding: 4px; border-radius: var(--r-card);
  background: rgba(255, 255, 255, 0.035); border: 1px solid rgba(255, 255, 255, 0.055);
  transition: transform 0.3s var(--ease), opacity 0.6s var(--ease), translate 0.6s var(--ease);
}
.card .core {
  border-radius: var(--r-core); overflow: hidden; background: var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.card .cover { position: relative; aspect-ratio: 1 / 1; background: var(--surface-2); }
.card .cover img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.45s var(--ease); }
.card .cover img.loaded { opacity: 1; }
.card .meta { padding: 9px 11px 11px; }
.card .title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .kind { font-size: 12.5px; color: var(--text-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .kind .add { color: #7fa8ff; }
.card .badge {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 999px;
  display: grid; place-items: center;
}
.card .badge.gold { background: var(--gold); color: var(--on-gold); }
.card.is-hidden .core { opacity: 0.55; }
.card.is-hidden { border-style: dashed; border-color: var(--line-strong); }
.card .unhide { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 999px; display: grid; place-items: center; color: var(--text); }

/* Entry motion: cards fade up as they arrive (off under reduced motion). */
.reveal { opacity: 0; translate: 0 14px; }
.reveal.in { opacity: 1; translate: 0 0; }

/* ---- Skeleton ---- */
.skeleton .cover, .skeleton .line { background: linear-gradient(100deg, #15171c 30%, #1d2027 50%, #15171c 70%); background-size: 300% 100%; animation: shimmer 1.4s var(--ease) infinite; }
.skeleton .line { height: 12px; border-radius: 6px; margin: 4px 0; }
.skeleton .line.short { width: 55%; }
@keyframes shimmer { to { background-position: -100% 0; } }

/* ---- Empty and error states ---- */
.empty { padding: 60px 28px; text-align: center; color: var(--text-2); }
.empty h3 { color: var(--text); font-size: 18px; font-weight: 600; margin: 12px 0 6px; }
.empty .icon { width: 36px; height: 36px; color: var(--text-3); }

/* ---- Tab bar (phone) ---- */
.tabbar {
  position: fixed; z-index: 30; left: 50%; bottom: calc(14px + var(--safe-b)); translate: -50% 0;
  display: flex; gap: 2px; padding: 6px; border-radius: 999px;
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--text-2); padding: 6px 18px; border-radius: 999px;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}
.tab[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }

/* ---- Album page ---- */
.hero { position: relative; height: min(58vh, 460px); background: var(--surface-2); overflow: hidden; }
.hero img { width: 100%; height: 100%; object-fit: cover; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(11, 12, 15, 0) 45%, var(--bg) 98%); }
/* Pinned to the screen, not the cover photo: always there while scrolling the photos. */
.hero .back { position: fixed; z-index: 25; top: calc(12px + var(--safe-t)); left: 12px; }
.hero .heading { position: absolute; z-index: 2; left: var(--pad); right: var(--pad); bottom: 8px; }
.hero h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.2; }
.hero .sub { color: #aab2c0; font-size: 13px; margin-top: 4px; }
.actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 14px var(--pad) 16px; }
.action { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: #aab2c0; text-align: center; min-width: 0; }
.action span.label { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.action .round { border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); }
.action[aria-disabled="true"] { opacity: 0.4; pointer-events: none; }
.photos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; padding: 0 var(--pad) 24px; }
.photo { position: relative; aspect-ratio: 1 / 1; border-radius: var(--r-tile); overflow: hidden; background: var(--surface-2); }
.photo img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.4s var(--ease); }
.photo img.loaded { opacity: 1; }
.photo .main-badge {
  position: absolute; left: 6px; top: 6px; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--on-accent);
}

/* ---- Viewer ---- */
.viewer {
  position: fixed; inset: 0; z-index: 50; background: #000; touch-action: none;
  display: grid; grid-template-rows: auto 1fr auto;
  animation: fade-in 0.3s var(--ease);
}
.viewer .vtop { display: flex; align-items: center; justify-content: space-between; padding: calc(10px + var(--safe-t)) 12px 8px; }
.viewer .counter { font-size: 14px; color: #cfd5df; font-variant-numeric: tabular-nums; }
.viewer .stage { position: relative; overflow: hidden; min-height: 0; }
.viewer .stage img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  transform-origin: center; will-change: transform; user-select: none; -webkit-user-drag: none;
}
.viewer .vbar {
  justify-self: center; margin: 8px 12px calc(14px + var(--safe-b)); padding: 6px; border-radius: 999px;
  display: flex; gap: 4px;
}
.viewer .vbar button, .viewer .vbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px;
  padding: 6px 14px; border-radius: 999px; color: #cfd5df;
}
.viewer .vbar [aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
.viewer .nav-zone { position: absolute; top: 0; bottom: 0; width: 22%; z-index: 1; }
.viewer .nav-zone.prev { left: 0; }
.viewer .nav-zone.next { right: 0; }

/* ---- Sheet ---- */
.backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.5); animation: fade-in 0.3s var(--ease); }
.sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0;
  max-height: 86dvh; overflow: auto; padding: 8px 18px calc(18px + var(--safe-b));
  background: #16181d; border-radius: 26px 26px 0 0; border-top: 1px solid var(--line-strong);
  animation: sheet-up 0.45s var(--ease);
}
.sheet .grab { width: 38px; height: 5px; border-radius: 9px; background: #3a3f49; margin: 2px auto 14px; }
.sheet h2 { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.sheet .hint { color: var(--text-2); font-size: 13px; margin: 0 0 4px; }
.sheet .chips { padding: 10px 0 8px; }
.option { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 2px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); text-align: left; font-size: 15px; }
.option .auto { font-size: 12px; color: var(--text-2); }
.option .box {
  margin-left: auto; width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid #4a5160;
  display: grid; place-items: center; color: var(--on-accent);
}
.option[aria-checked="true"] .box { background: var(--accent); border-color: var(--accent); }
.option .box .icon { width: 14px; height: 14px; opacity: 0; }
.option[aria-checked="true"] .box .icon { opacity: 1; }
.sheet .buttons { display: flex; gap: 10px; margin-top: 16px; }
.sheet .buttons .pill { flex: 1; justify-content: center; }

/* ---- Sign in ---- */
.signin {
  min-height: 100dvh; display: grid; align-content: center; padding: 32px 26px calc(32px + var(--safe-b));
  background: radial-gradient(120% 60% at 50% 0%, #17233d 0%, var(--bg) 62%);
}
.signin .box { width: 100%; max-width: 380px; margin: 0 auto; }
.signin .mark { width: 62px; padding: 4px; border-radius: 20px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); }
.signin .mark div { height: 52px; border-radius: 16px; display: grid; place-items: center; color: #eaf1ff; background: linear-gradient(160deg, #4f8cff, #1f3f88); }
.signin .mark .icon { width: 28px; height: 28px; }
.signin h1 { margin: 18px 0 6px; font-size: 28px; font-weight: 600; letter-spacing: -0.02em; }
.signin p { margin: 0; color: var(--text-2); }
.field { margin-top: 22px; }
.field label { display: block; font-size: 13px; color: #aab2c0; margin-bottom: 6px; }
.field input {
  width: 100%; height: 48px; padding: 0 14px; border-radius: var(--r-input);
  background: var(--surface); border: 1px solid var(--line-strong); outline: none; font-size: 16px;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.22); }
.field .error { min-height: 20px; margin-top: 6px; font-size: 13px; color: var(--danger); }
.remember { display: flex; align-items: center; gap: 10px; margin-top: 4px; color: #aab2c0; font-size: 14px; }
.remember input { width: 20px; height: 20px; accent-color: var(--accent); }
.signin .pill.primary { width: 100%; justify-content: space-between; min-height: 50px; margin-top: 22px; font-size: 16px; padding-left: 22px; padding-right: 14px; }

/* ---- Toast ---- */
#toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(96px + var(--safe-b)); translate: -50% 12px;
  padding: 10px 16px; border-radius: 999px; background: #22252d; border: 1px solid var(--line-strong);
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 0.3s var(--ease), translate 0.3s var(--ease);
  max-width: calc(100vw - 32px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#toast.show { opacity: 1; translate: -50% 0; }
#toast.error { color: var(--danger); }

@keyframes fade-in { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } }

/* ---- Wider screens: sidebar instead of the tab bar ---- */
@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .photos { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  :root { --pad: 28px; }
  .layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); }
  .sidebar {
    display: block; position: sticky; top: 0; height: 100dvh; overflow-y: auto;
    padding: 18px 12px; border-right: 1px solid var(--line);
  }
  .sidebar .brand { display: flex; align-items: center; gap: 10px; font-weight: 600; padding: 4px 8px 16px; }
  .sidebar .brand .logo { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: linear-gradient(160deg, #4f8cff, #1f3f88); color: #eaf1ff; }
  .sidebar .brand .logo .icon { width: 16px; height: 16px; }
  .side-link {
    display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
    padding: 8px 10px; border-radius: 10px; color: #cfd5df; font-size: 14px;
    transition: background-color 0.25s var(--ease);
  }
  .side-link:hover { background: rgba(255, 255, 255, 0.04); }
  .side-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
  .side-link .n { margin-left: auto; color: var(--text-2); font-size: 12px; }
  .side-head { color: var(--text-3); font-size: 12px; margin: 18px 10px 6px; }
  .sidebar .signout { margin-top: 18px; }
  .tabbar { display: none; }
  .content { padding-bottom: 40px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
  .photos { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
  .large-title h1 { font-size: 34px; }
  .search { max-width: 420px; }
  .hero { height: 420px; }
  .hero .back { left: calc(236px + 16px); }  /* beside the sidebar */
  .actions { max-width: 520px; }
  .sheet { left: 50%; right: auto; bottom: 50%; width: 560px; translate: -50% 50%; border-radius: 26px; border: 1px solid var(--line-strong); animation: fade-in 0.3s var(--ease); }
  .sheet .grab { display: none; }
  #toast { bottom: 28px; }
}

@media (hover: hover) {
  .card:hover { transform: translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; translate: none; }
}
