:root {
  color-scheme: dark;
  --bg: #090a0f;
  --panel: #11131d;
  --panel-strong: #171a27;
  --text: #f4f7fb;
  --muted: #9aa4b7;
  --line: #272c3d;
  --cyan: #00f0ff;
  --pink: #ff3df2;
  --lime: #b7ff35;
  --danger: #ff5c7a;
  --shadow: 0 24px 80px rgb(0 0 0 / 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgb(0 240 255 / 0.08), transparent 32rem),
    radial-gradient(circle at 80% 0%, rgb(255 61 242 / 0.13), transparent 24rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}

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

img,
video {
  display: block;
  max-width: 100%;
}

button,
.button,
.small-button,
.icon-button {
  border: 0;
  background: linear-gradient(135deg, var(--cyan), var(--pink));
  color: #050509;
  cursor: pointer;
  font-weight: 900;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  min-height: 44px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #090b13;
  color: var(--text);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  font: inherit;
}

input:focus,
textarea:focus {
  outline: 2px solid rgb(0 240 255 / 0.5);
  border-color: var(--cyan);
}

label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  margin-top: 1rem;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  background: rgb(9 10 15 / 0.86);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand,
.site-header nav {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 96px;
  height: 88px;
  background: #10131f;
  border: 1px solid var(--cyan);
  box-shadow: 0 0 24px rgb(0 240 255 / 0.24);
  border-radius: 8px;
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
}

.site-header nav a,
.ghost-button {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  min-height: 40px;
}

.inline-form {
  display: inline;
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 3rem);
}

.vault-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
  gap: 2rem;
  align-items: end;
  padding: clamp(1rem, 5vw, 4rem) 0 2rem;
}

.eyebrow {
  color: var(--lime);
  font-size: 0.8rem;
  font-weight: 950;
  margin: 0 0 0.5rem;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 1;
  margin-bottom: 0.7rem;
}

.hero-copy {
  max-width: 720px;
  color: var(--muted);
  font-size: clamp(1.05rem, 1.6vw, 1.3rem);
  font-weight: 800;
  text-transform: lowercase;
}

.search-panel,
.panel {
  background: linear-gradient(180deg, rgb(255 255 255 / 0.055), rgb(255 255 255 / 0.025));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
}

.search-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  padding: 0.8rem;
}

.tag-strip,
.tags,
.button-row,
.row-actions,
.panel-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.tag-strip {
  margin-bottom: 1.4rem;
}

.tag-pill,
.page-size-pill,
.tags a,
.media-badge,
.count {
  border: 1px solid var(--line);
  background: rgb(255 255 255 / 0.04);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.45rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 800;
}

.tag-pill.active,
.page-size-pill.active,
.tags a:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.gallery-controls,
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.gallery-controls {
  color: var(--muted);
}

.gallery-controls strong {
  color: var(--text);
}

.gallery-controls > div,
.page-size-control,
.media-filter-control {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.pagination {
  justify-content: center;
  margin: 1.5rem 0 0;
  color: var(--muted);
}

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

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.meme-card {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 42px rgb(0 0 0 / 0.22);
}

.meme-card:hover {
  border-color: rgb(0 240 255 / 0.7);
  transform: translateY(-2px);
  transition: transform 160ms ease, border-color 160ms ease;
}

.media-frame,
.admin-thumb {
  display: block;
  background: #05060a;
}

.media-frame {
  aspect-ratio: 1 / 1;
  padding: 0.4rem;
}

.media-frame.reel-preview {
  aspect-ratio: 9 / 16;
  width: min(100%, 360px);
  margin: 0 auto;
}

.media-frame img,
.media-frame video,
.detail-media img,
.detail-media video,
.admin-thumb img,
.admin-thumb video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.admin-thumb img,
.admin-thumb video {
  object-fit: cover;
}

.card-body {
  padding: 1rem;
}

.card-title-row,
.admin-grid,
.edit-layout,
.detail-layout {
  display: grid;
  gap: 1.5rem;
}

.card-title-row {
  grid-template-columns: 1fr auto;
  align-items: start;
}

.card-body h2,
.admin-row h2 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.card-body p,
.muted,
.hint,
.admin-row p,
.detail-meta p {
  color: var(--muted);
}

.card-footer,
.card-body time,
.admin-row time {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.9rem;
}

.card-footer time {
  margin-top: 0;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 3rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}

.compact {
  padding: 2rem;
}

.detail-layout,
.edit-layout {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  align-items: start;
}

.detail-media {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #05060a;
  min-height: 320px;
}

.detail-media.video-reel {
  aspect-ratio: 9 / 16;
  width: min(100%, 430px);
  min-height: 0;
  justify-self: center;
  box-shadow: 0 24px 80px rgb(255 61 242 / 0.12);
}

.detail-media img,
.detail-media video {
  max-height: 78vh;
  object-fit: contain;
}

.detail-media.video-reel video {
  max-height: none;
  object-fit: contain;
}

.detail-meta,
.auth-panel,
.upload-panel,
.edit-panel,
.table-panel {
  padding: clamp(1rem, 3vw, 1.5rem);
}

.detail-meta dl {
  display: grid;
  gap: 0.8rem;
  margin: 1.5rem 0;
}

.detail-meta dl div {
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
}

dt {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

dd {
  margin: 0.15rem 0 0;
}

.share-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
}

.share-row a {
  overflow-wrap: anywhere;
  color: var(--cyan);
}

.icon-button {
  min-height: 36px;
  padding: 0.45rem 0.75rem;
}

.auth-shell {
  min-height: 70vh;
  display: grid;
  place-items: center;
}

.auth-panel {
  width: min(440px, 100%);
}

.alert {
  border: 1px solid var(--danger);
  color: #ffd3dc;
  background: rgb(255 92 122 / 0.12);
  padding: 0.8rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.admin-grid {
  grid-template-columns: minmax(300px, 420px) 1fr;
  align-items: start;
}

.upload-panel,
.edit-panel {
  display: grid;
}

.upload-stack {
  display: grid;
  gap: 1rem;
}

.optional-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  margin-left: 0.35rem;
}

.admin-grid h1,
.edit-panel h1 {
  font-size: clamp(1.35rem, 2vw, 1.8rem);
  line-height: 1.08;
  margin-bottom: 1rem;
}

.admin-grid .eyebrow,
.edit-panel .eyebrow {
  font-size: 0.72rem;
}

.panel-heading {
  justify-content: space-between;
  margin-bottom: 1rem;
}

.admin-list {
  display: grid;
  gap: 0.75rem;
}

.admin-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem;
  background: rgb(255 255 255 / 0.03);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-thumb {
  width: 84px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
}

.small-button,
.danger-button {
  min-height: 38px;
  padding: 0.55rem 0.75rem;
}

.danger-button {
  background: var(--danger);
  color: #160308;
}

.neutral-button {
  background: #111827;
  border: 1px solid var(--line);
  color: var(--text);
}

.copy-toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 30;
  transform: translateY(0.75rem);
  opacity: 0;
  pointer-events: none;
  border: 1px solid rgb(0 240 255 / 0.45);
  background: rgb(9 11 19 / 0.94);
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.38);
  color: var(--text);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  font-weight: 850;
  transition: opacity 160ms ease, transform 160ms ease;
}

.copy-toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 860px) {
  .site-header,
  .vault-hero,
  .admin-grid,
  .detail-layout,
  .edit-layout,
  .admin-row {
    grid-template-columns: 1fr;
  }

  .site-header {
    display: grid;
  }

  .brand-mark {
    width: 78px;
    height: 72px;
  }

  .site-header nav {
    overflow-x: auto;
    padding-bottom: 0.2rem;
  }

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

  .gallery-controls,
  .pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-row {
    align-items: start;
  }

  .row-actions {
    width: 100%;
  }

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

  .card-footer {
    align-items: stretch;
    flex-direction: column;
  }
}
