/* ============================================================
   Yuanlight Notes — global design tokens & shared components
   Theme: dark (default) / light via [data-theme="light"] on <html>
   ============================================================ */

:root {
  color-scheme: dark;

  /* palette */
  --bg: #060913;
  --bg-soft: #0b101f;
  --soft: rgba(148, 163, 205, 0.08);
  --text: #e9edf9;
  --muted: #96a0c0;
  --line: rgba(139, 152, 199, 0.16);
  --line-strong: rgba(139, 152, 199, 0.32);

  /* neon accents */
  --neon-a: #22d3ee;
  --neon-b: #a78bfa;
  --neon-c: #f472b6;
  --accent: #82a0ff;
  --accent-strong: #5f7df0;
  --grad-neon: linear-gradient(135deg, var(--neon-a), var(--neon-b) 55%, var(--neon-c));

  /* glass */
  --glass-bg: rgba(13, 18, 34, 0.62);
  --glass-bg-strong: rgba(16, 22, 42, 0.82);
  --glass-hi: rgba(255, 255, 255, 0.07);
  --blur: 14px;

  /* glow & shadow */
  --glow-accent: 0 0 0 1px rgba(130, 160, 255, 0.35), 0 8px 32px rgba(95, 125, 240, 0.28);
  --shadow-card: 0 18px 50px rgba(2, 6, 18, 0.55);
  --shadow-card-hover: 0 26px 64px rgba(2, 6, 18, 0.65), 0 0 40px rgba(95, 125, 240, 0.16);

  /* shape & spacing */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --space-1: 8px;
  --space-2: 14px;
  --space-3: 22px;
  --space-4: 32px;

  /* type */
  --font-sans: "Space Grotesk", "Noto Sans SC", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, monospace;

  /* motion */
  --ease-spring: cubic-bezier(0.22, 1.2, 0.36, 1);
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
}

[data-theme="light"] {
  color-scheme: light;

  --bg: #f2f4fb;
  --bg-soft: #ffffff;
  --soft: rgba(21, 87, 230, 0.06);
  --text: #151923;
  --muted: #5d6880;
  --line: rgba(21, 31, 48, 0.12);
  --line-strong: rgba(21, 31, 48, 0.26);

  --accent: #4f46e5;
  --accent-strong: #4338ca;

  --glass-bg: rgba(255, 255, 255, 0.66);
  --glass-bg-strong: rgba(255, 255, 255, 0.86);
  --glass-hi: rgba(255, 255, 255, 0.6);

  --glow-accent: 0 0 0 1px rgba(79, 70, 229, 0.3), 0 10px 32px rgba(79, 70, 229, 0.2);
  --shadow-card: 0 18px 50px rgba(21, 31, 48, 0.1);
  --shadow-card-hover: 0 26px 64px rgba(21, 31, 48, 0.16), 0 0 40px rgba(79, 70, 229, 0.12);
}

* {
  box-sizing: border-box;
}

::selection {
  background: rgba(167, 139, 250, 0.4);
  color: var(--text);
}

html {
  scrollbar-color: rgba(130, 160, 255, 0.45) transparent;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.65;
  transition: background-color 300ms ease, color 300ms ease;
}

/* drifting aurora blobs — transform-only animation for cheap compositing */
body::before,
body::after {
  position: fixed;
  z-index: -1;
  width: 62vmax;
  height: 62vmax;
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

body::before {
  top: -24vmax;
  left: -16vmax;
  background: radial-gradient(circle, rgba(95, 125, 240, 0.16), transparent 68%);
  animation: yl-drift-a 38s ease-in-out infinite alternate;
}

body::after {
  right: -22vmax;
  bottom: -26vmax;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.12), transparent 68%);
  animation: yl-drift-b 46s ease-in-out infinite alternate;
}

[data-theme="light"] body::before {
  background: radial-gradient(circle, rgba(79, 70, 229, 0.12), transparent 68%);
}

[data-theme="light"] body::after {
  background: radial-gradient(circle, rgba(34, 197, 94, 0.1), transparent 68%);
}

@keyframes yl-drift-a {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(9vmax, 6vmax, 0) scale(1.12); }
}

@keyframes yl-drift-b {
  from { transform: translate3d(0, 0, 0) scale(1.05); }
  to { transform: translate3d(-8vmax, -7vmax, 0) scale(0.94); }
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--neon-a);
  outline-offset: 2px;
}

/* entrance rise */
@keyframes yl-rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* theme toggle (shared across pages) */
.theme-toggle {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 30;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-card);
  color: var(--text);
  font-size: 19px;
  cursor: pointer;
  transition: transform 200ms var(--ease-spring), box-shadow 200ms ease, border-color 200ms ease;
}

.theme-toggle::before {
  content: "☀";
}

[data-theme="light"] .theme-toggle::before {
  content: "☾";
}

.theme-toggle:hover {
  border-color: var(--line-strong);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--glow-accent);
  transform: translateY(-2px) rotate(12deg);
}

.theme-toggle:active {
  transform: scale(0.92);
}

#canvas-nest {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  pointer-events: none;
}

/* ---------------- home ---------------- */

.home {
  position: relative;
  z-index: 1;
  display: grid;
  place-content: center;
  min-height: 100vh;
  width: min(720px, calc(100% - 32px));
  margin: 0 auto;
}

.home h1 {
  margin: 0 0 28px;
  background: var(--grad-neon);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 52px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  animation: yl-rise 600ms var(--ease-out) backwards;
}

.home-links {
  display: grid;
  gap: 14px;
}

.big-link,
.item,
.note {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
  box-shadow: inset 0 1px 0 var(--glass-hi);
}

.big-link {
  display: block;
  position: relative;
  overflow: hidden;
  padding: 22px 24px;
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-card);
  transition: transform 220ms var(--ease-spring), border-color 220ms ease, box-shadow 220ms ease;
  animation: yl-rise 560ms var(--ease-out) backwards;
}

/* neon edge that lights up on hover */
.big-link::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--grad-neon);
  content: "";
  opacity: 0;
  transition: opacity 220ms ease;
}

.home-links .big-link:nth-child(1) { animation-delay: 80ms; }
.home-links .big-link:nth-child(2) { animation-delay: 160ms; }
.home-links .big-link:nth-child(3) { animation-delay: 240ms; }
.home-links .big-link:nth-child(4) { animation-delay: 320ms; }

.big-link:hover {
  border-color: var(--line-strong);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-card-hover);
  transform: translateY(-4px);
}

.big-link:hover::before {
  opacity: 1;
}

.big-link:active {
  transform: translateY(-1px) scale(0.99);
}

.big-link span {
  display: block;
  font-size: 22px;
  font-weight: 700;
}

.big-link small,
.muted {
  color: var(--muted);
}

/* ---------------- control portal ---------------- */

.control-home {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 72px 0;
}

.control-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  animation: yl-rise 520ms var(--ease-out) backwards;
}

.control-kicker {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.control-back {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  transition: color 160ms ease, transform 160ms var(--ease-spring);
}

.control-back:hover {
  color: var(--accent);
  transform: translateX(-2px);
}

.control-home h1 {
  margin-bottom: 12px;
}

.control-intro {
  margin: 0 0 28px;
  color: var(--muted);
  animation: yl-rise 560ms var(--ease-out) 60ms backwards;
}

.control-access {
  overflow: hidden;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--glass-bg-strong);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-card);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
  animation: yl-rise 560ms var(--ease-out) 100ms backwards;
}

.control-access-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 24px;
}

.control-access-copy {
  min-width: 0;
}

.control-access-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.control-access h2 {
  margin: 0;
  font-size: clamp(21px, 4vw, 28px);
  line-height: 1.2;
}

.control-access-copy p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.control-access-switch {
  position: relative;
  width: 106px;
  min-width: 106px;
  height: 48px;
  padding: 0 14px 0 49px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(251, 94, 122, 0.15);
  color: #ff8ea3;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 200ms ease, border-color 200ms ease, box-shadow 200ms ease, color 200ms ease, opacity 160ms ease;
}

.control-access-switch::before {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(2, 6, 18, 0.35);
  content: "";
  transition: transform 220ms var(--ease-spring);
}

.control-access-switch[aria-checked="true"] {
  padding-right: 49px;
  padding-left: 14px;
  border-color: rgba(52, 211, 153, 0.5);
  background: rgba(52, 211, 153, 0.13);
  box-shadow: 0 0 24px rgba(52, 211, 153, 0.15);
  color: #7be6bc;
}

.control-access-switch[aria-checked="true"]::before {
  transform: translateX(58px);
}

.control-access-switch:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.control-access-switch:disabled {
  cursor: wait;
  opacity: 0.58;
}

[data-theme="light"] .control-access-switch {
  color: #c82240;
}

[data-theme="light"] .control-access-switch[aria-checked="true"] {
  color: #087955;
}

.control-access-footer {
  display: grid;
  gap: 9px;
  padding: 13px 24px 15px;
  border-top: 1px solid var(--line);
  background: var(--glass-bg);
}

.control-access-message {
  min-height: 21px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.control-access-message.is-good {
  color: #34d399;
}

.control-access-message.is-error {
  color: #fb5e7a;
}

[data-theme="light"] .control-access-message.is-good {
  color: #087955;
}

[data-theme="light"] .control-access-message.is-error {
  color: #c82240;
}

.control-access-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
}

.control-access-meta a {
  color: var(--accent);
  font-weight: 700;
}

.control-access-meta a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------------- header / shell ---------------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
}

.brand {
  background: var(--grad-neon);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 20px;
  font-weight: 700;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-weight: 700;
}

.site-nav a {
  transition: color 160ms ease, text-shadow 160ms ease;
}

.site-nav a:hover {
  color: var(--accent);
  text-shadow: 0 0 18px rgba(130, 160, 255, 0.55);
}

.site-nav a[aria-current="page"] {
  color: var(--accent);
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 44px 0 72px;
}

.page-head {
  margin-bottom: 28px;
}

.page-head h1 {
  margin: 0 0 8px;
  font-size: 36px;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.page-head p {
  margin: 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

/* ---------------- explorer bar / breadcrumb ---------------- */

.explorer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
}

.breadcrumb {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
  box-shadow: inset 0 1px 0 var(--glass-hi);
}

.breadcrumb button,
.icon-button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.breadcrumb button {
  padding: 4px 7px;
}

.breadcrumb button:hover,
.breadcrumb button[aria-current="page"],
.icon-button:hover {
  background: rgba(130, 160, 255, 0.14);
}

.breadcrumb span {
  color: var(--muted);
}

.icon-button {
  min-height: 42px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
  box-shadow: inset 0 1px 0 var(--glass-hi);
  color: var(--text);
  transition: transform 180ms var(--ease-spring), border-color 180ms ease, box-shadow 180ms ease;
}

.icon-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--glow-accent);
  color: var(--accent);
  transform: translateY(-2px);
}

.icon-button:active:not(:disabled) {
  transform: scale(0.96);
}

.icon-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.upload-input {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

#upButton {
  order: 1;
}

.breadcrumb {
  order: 2;
}

.upload-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  order: 3;
  border-color: transparent;
  background: var(--grad-neon);
  box-shadow: 0 10px 28px rgba(95, 125, 240, 0.35);
  color: #0a1020;
  font-weight: 800;
}

.upload-button span {
  pointer-events: none;
}

/* sheen sweep on hover — transform only */
.upload-button::after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  content: "";
  transform: translateX(-160%) skewX(-18deg);
  transition: transform 520ms var(--ease-out);
  pointer-events: none;
}

.upload-button:hover:not(:disabled)::after {
  transform: translateX(320%) skewX(-18deg);
}

.upload-button:hover:not(:disabled) {
  box-shadow: 0 14px 36px rgba(95, 125, 240, 0.5);
  color: #0a1020;
}

.upload-button[aria-busy="true"] {
  opacity: 0.72;
}

.upload-button.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

#refreshButton {
  order: 4;
}

/* ---------------- form controls ---------------- */

.input {
  width: min(420px, 100%);
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--glass-bg);
  box-shadow: inset 0 1px 0 var(--glass-hi);
  color: var(--text);
  font: inherit;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: var(--glow-accent);
  outline: none;
}

.select-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  color: var(--muted);
  font-weight: 700;
}

.select {
  min-height: 42px;
  padding: 7px 34px 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--glass-bg-strong);
  color: var(--text);
  font: inherit;
}

/* ---------------- generic cards / lists ---------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.list {
  display: grid;
  gap: 12px;
}

.item {
  display: block;
  padding: 18px;
  transition: transform 200ms var(--ease-spring), border-color 200ms ease, box-shadow 200ms ease;
}

a.item:hover {
  border-color: var(--line-strong);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-card-hover);
  transform: translateY(-3px);
}

.item h2,
.item h3 {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.35;
}

.item p {
  margin: 0;
  color: var(--muted);
}

.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
}

.image-card .item-body {
  padding: 14px;
}

/* ---------------- filters ---------------- */

.month-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 22px;
}

.filter-button {
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass-bg);
  box-shadow: inset 0 1px 0 var(--glass-hi);
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms var(--ease-spring), border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.filter-button:hover {
  border-color: var(--line-strong);
  color: var(--accent);
  transform: translateY(-1px);
}

.filter-button:active {
  transform: scale(0.95);
}

.filter-button[aria-pressed="true"] {
  border-color: transparent;
  background: var(--grad-neon);
  box-shadow: 0 6px 20px rgba(95, 125, 240, 0.35);
  color: #0a1020;
}

/* ---------------- gallery ---------------- */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.explorer-grid {
  align-items: stretch;
}

.gallery-card {
  display: grid;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
  box-shadow: inset 0 1px 0 var(--glass-hi);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 200ms var(--ease-spring), border-color 200ms ease, box-shadow 200ms ease;
}

article.gallery-card {
  cursor: default;
}

.gallery-card:hover {
  border-color: var(--line-strong);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-card-hover);
  transform: translateY(-4px);
}

.gallery-card:active {
  transform: translateY(-1px) scale(0.99);
}

.gallery-card img,
.media-open,
.folder-icon,
.image-thumb-fallback,
.video-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1;
}

.gallery-card img {
  object-fit: cover;
  background: var(--soft);
}

.image-thumb-fallback {
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(34, 211, 238, 0.16), rgba(167, 139, 250, 0.16)),
    var(--soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.media-open {
  overflow: hidden;
  padding: 0;
  border: 0;
  background: var(--soft);
  cursor: pointer;
}

.folder-card {
  border-style: dashed;
}

.folder-icon {
  position: relative;
  background: linear-gradient(180deg, #f7d36c, #e9aa35);
}

.folder-icon::before {
  position: absolute;
  top: 22%;
  left: 13%;
  width: 36%;
  height: 15%;
  border-radius: 6px 6px 0 0;
  background: #ffe39a;
  content: "";
}

.folder-icon::after {
  position: absolute;
  inset: 32% 10% 15%;
  border-radius: 7px;
  background: #ffc94d;
  box-shadow: 0 14px 28px rgba(96, 67, 11, 0.16);
  content: "";
}

.video-thumb {
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(34, 211, 238, 0.85), rgba(124, 58, 237, 0.8)),
    #0f172a;
  color: #fff;
}

.video-thumb-label {
  display: inline-grid;
  place-items: center;
  min-width: 72px;
  min-height: 40px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.video-thumb img {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: cover;
}

.video-play-badge {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(8, 13, 24, 0.76);
  box-shadow: 0 10px 24px rgba(8, 13, 24, 0.28), 0 0 18px rgba(34, 211, 238, 0.35);
}

.video-play-badge::before {
  width: 0;
  height: 0;
  margin-left: 3px;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 15px solid #fff;
  content: "";
}

.gallery-card-body {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 10px 12px 12px;
}

.gallery-card-body strong,
.gallery-card-body small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-card-body strong {
  font-size: 15px;
  line-height: 1.35;
}

.gallery-card-body small {
  color: var(--muted);
}

/* ---------------- reactions ---------------- */

.reaction-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 12px 12px;
}

.reaction-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  min-width: 56px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--glass-bg);
  box-shadow: inset 0 1px 0 var(--glass-hi);
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms var(--ease-spring), border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.reaction-button:hover {
  border-color: var(--line-strong);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--glow-accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.reaction-button:active {
  transform: scale(0.94);
}

.reaction-icon {
  display: inline-block;
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  fill: currentColor;
}

.gallery-loading {
  grid-column: 1 / -1;
}

/* ---------------- lightbox (always dark) ---------------- */

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

/* the theme toggle sits where the lightbox close button lands */
.is-lightbox-open .theme-toggle {
  display: none;
}

.lightbox[hidden] {
  display: none;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  align-items: center;
  gap: 14px;
  padding: 72px 24px 24px;
  background: rgba(4, 7, 16, 0.9);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  color: #fff;
}

.lightbox-frame {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  min-height: 0;
  height: 100%;
  margin: 0;
}

.lightbox-media {
  display: grid;
  place-items: center;
  min-height: 0;
}

.lightbox-media img,
.lightbox-media video {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 172px);
  margin: auto;
  border-radius: var(--r-sm);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), 0 0 60px rgba(95, 125, 240, 0.18);
  object-fit: contain;
}

.lightbox-media video {
  width: min(100%, 1180px);
  background: #000;
}

.lightbox-frame figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 16px;
  min-height: 34px;
  color: #dbe7ff;
}

.lightbox-frame a {
  color: #fff;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.lightbox-reactions {
  padding: 0;
}

.lightbox-reactions .reaction-button {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
  color: #dbe7ff;
}

.lightbox-close,
.lightbox-nav {
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  transition: transform 180ms var(--ease-spring), background 180ms ease, box-shadow 180ms ease;
}

.lightbox-close:hover,
.lightbox-nav:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 24px rgba(34, 211, 238, 0.35);
  transform: scale(1.06);
}

.lightbox-close:active,
.lightbox-nav:active:not(:disabled) {
  transform: scale(0.94);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 30px;
  line-height: 1;
}

.lightbox-nav {
  width: 52px;
  height: 72px;
  border-radius: var(--r-sm);
  font-size: 46px;
  line-height: 1;
}

.lightbox-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ---------------- notes & articles ---------------- */

.note {
  padding: 16px;
  background: var(--soft);
  color: var(--muted);
}

.article {
  max-width: 760px;
}

.article h1,
.article h2,
.article h3 {
  line-height: 1.28;
}

.article a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.article pre {
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #0b1120;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  color: #eef4ff;
}

.article code {
  font-family: var(--font-mono);
}

.article :not(pre) > code {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--soft);
}

.article img {
  max-width: 100%;
  border-radius: var(--r-sm);
}

/* ---------------- motion safety ---------------- */

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

/* ---------------- responsive ---------------- */

@media (max-width: 760px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
    padding-right: 76px;
  }

  .home h1 {
    font-size: 38px;
  }

  .big-link {
    padding: 18px 20px;
  }

  .control-access-main {
    align-items: flex-start;
    gap: 18px;
    padding: 20px;
  }

  .control-access-footer {
    padding-right: 20px;
    padding-left: 20px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .input,
  .select-label,
  .select {
    width: 100%;
  }

  .select-label {
    display: grid;
    align-items: stretch;
    gap: 6px;
  }

  .explorer-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .breadcrumb {
    width: 100%;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .theme-toggle {
    top: 14px;
    right: 14px;
    width: 40px;
    height: 40px;
  }

  .lightbox {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 8px;
    padding: 70px 10px 16px;
  }

  .lightbox-nav {
    width: 42px;
    height: 56px;
    font-size: 36px;
  }

  .lightbox-media img,
  .lightbox-media video {
    max-height: calc(100vh - 184px);
  }

  .lightbox-frame figcaption {
    align-content: center;
    font-size: 14px;
  }
}
