:root {
  color-scheme: light;
  --ink: #1d211d;
  --muted: #68706a;
  --soft: #f4f1eb;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --line: #d8d7cf;
  --accent: #23614f;
  --accent-strong: #16483b;
  --warm: #8a5a34;
  --rose: #9f4c55;
  --shadow: 0 12px 28px rgba(35, 39, 33, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, #f7f2ea 0, var(--paper) 240px);
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 560px) auto;
  gap: 18px;
  align-items: center;
  padding: 12px 22px;
  border-bottom: 1px solid rgba(216, 215, 207, 0.92);
  background: rgba(251, 250, 247, 0.96);
  backdrop-filter: blur(16px);
}

.brand {
  font-weight: 800;
  text-decoration: none;
}

nav {
  display: flex;
  gap: 14px;
  justify-content: flex-end;
  font-size: 14px;
}

nav a,
.back {
  color: var(--accent);
  font-weight: 650;
  text-decoration: none;
}

main {
  width: min(1380px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 30px 0 64px;
}

section {
  margin: 0 0 34px;
}

.hero {
  display: grid;
  gap: 8px;
  padding: 18px 0 4px;
}

h1 {
  margin: 0 0 8px;
  font-size: 44px;
  line-height: 1.04;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 14px;
  font-size: 21px;
  letter-spacing: 0;
}

p {
  line-height: 1.5;
}

.muted,
.empty,
.sync-note {
  color: var(--muted);
}

.search,
.wide-search {
  display: flex;
  gap: 8px;
}

input,
button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

input {
  width: 100%;
  padding: 0 12px;
  background: white;
}

button {
  padding: 0 15px;
  border-color: var(--accent);
  color: white;
  background: var(--accent);
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.danger {
  border-color: #9d1c1c;
  background: #9d1c1c;
}

button.danger:hover {
  background: #7b1515;
}

.admin-actions,
.admin-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.admin-actions form {
  display: flex;
  gap: 10px;
}

.hidden-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hidden-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.hidden-list code {
  overflow-wrap: anywhere;
}

.duplicate-groups {
  display: grid;
  gap: 14px;
}

.duplicate-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px 18px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.duplicate-group h2 {
  margin-bottom: 4px;
}

.duplicate-list {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 20px;
}

.duplicate-list a {
  overflow-wrap: anywhere;
}

.obituary {
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--rose);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(35, 39, 33, 0.06);
}

.obituary pre {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
  line-height: 1.6;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.metric {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric strong {
  display: block;
  font-size: 30px;
  line-height: 1;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.album-card-shell {
  position: relative;
  min-width: 0;
}

.album {
  display: grid;
  min-height: 76px;
  align-content: space-between;
  gap: 10px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  text-decoration: none;
}

.album:hover {
  border-color: rgba(35, 97, 79, 0.48);
  box-shadow: 0 8px 22px rgba(35, 39, 33, 0.08);
}

.album span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 720;
}

.album small {
  color: var(--muted);
}

.album-remove {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 2;
  margin: 0;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
}

.media-card-shell {
  position: relative;
  min-width: 0;
}

.media-card {
  display: grid;
  min-width: 0;
  gap: 8px;
  color: inherit;
  text-decoration: none;
}

.media-card-remove {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 2;
  margin: 0;
}

button.icon-remove {
  display: grid;
  width: 32px;
  min-height: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.26);
  font-size: 23px;
  font-weight: 800;
  line-height: 1;
}

.thumb-frame {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border: 1px solid rgba(216, 215, 207, 0.92);
  border-radius: 8px;
  background: #e8e5dc;
  box-shadow: 0 7px 18px rgba(35, 39, 33, 0.08);
}

.media-card:hover .thumb-frame {
  border-color: rgba(35, 97, 79, 0.62);
  box-shadow: var(--shadow);
}

.thumb-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-tile {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  gap: 9px;
  color: white;
  background:
    linear-gradient(135deg, rgba(22, 72, 59, 0.94), rgba(138, 90, 52, 0.88));
  font-weight: 760;
}

.play-glyph {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}

.play-glyph::after {
  display: block;
  width: 0;
  height: 0;
  margin: 15px 0 0 20px;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-left: 18px solid var(--accent-strong);
  content: "";
}

.media-title {
  display: block;
  overflow: hidden;
  color: #3d433e;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.viewer {
  display: grid;
  min-height: 360px;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: #111;
}

.viewer img {
  display: block;
  max-width: 100%;
  max-height: 78vh;
}

.viewer .video-js {
  width: 100%;
  max-width: 1180px;
  background: #111;
}

.viewer .vjs-fluid {
  width: 100%;
}

.details {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 360px);
  gap: 26px;
}

dl {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 8px 12px;
  margin: 0;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  word-break: break-word;
}

.tags {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tags span {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
}

.gate {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.gate-panel {
  width: min(440px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.gate-panel label {
  display: grid;
  gap: 8px;
}

.gate-panel form {
  display: grid;
  gap: 12px;
}

.error {
  color: #9d1c1c;
}

@media (max-width: 900px) {
  .topbar {
    position: static;
    grid-template-columns: 1fr;
  }

  nav {
    justify-content: flex-start;
  }

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

  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

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

  .hidden-list li {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 520px) {
  main {
    width: min(100vw - 20px, 1380px);
    padding-top: 18px;
  }

  h1 {
    font-size: 34px;
  }

  .search,
  .wide-search {
    display: grid;
  }

  .album-grid,
  .media-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .media-title {
    font-size: 13px;
  }
}
