:root {
  color-scheme: dark;
  --bg: #120d09;
  --panel: rgba(36, 24, 18, 0.9);
  --panel-strong: rgba(54, 37, 28, 0.96);
  --line: rgba(255, 224, 190, 0.15);
  --text: #f8efe6;
  --muted: #d1b9a4;
  --accent: #ff8f3f;
  --accent-strong: #ffd5a8;
  --danger: #ffb38d;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(255, 143, 63, 0.16), transparent 30%),
    linear-gradient(180deg, #21150f 0%, #120d09 100%);
  color: var(--text);
  font-family: Arial, sans-serif;
}

body {
  min-height: 100vh;
}

button,
input,
textarea {
  font: inherit;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.gate,
.app {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

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

.intro-screen {
  width: min(1200px, 100%);
}

.intro-video-shell {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  border-radius: 28px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: #000;
}

.intro-video {
  width: 100%;
  height: 100vh;
  object-fit: cover;
  display: block;
}

.intro-video-mobile {
  display: none;
}

.intro-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 14px;
  padding: 28px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.05) 0%, rgba(9, 6, 4, 0.78) 100%);
}

.intro-form {
  margin-top: 6px;
}

.gate-card,
.auth-card,
.upload-panel,
.viewer-card,
.detail-panel,
.admin-panel,
.admin-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.gate-card {
  width: min(460px, 100%);
  padding: 32px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--accent-strong);
  font-size: 0.78rem;
}

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(2.4rem, 5vw, 4.5rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.1rem;
}

.gate-copy {
  color: var(--muted);
  line-height: 1.6;
}

.login-form,
.upload-form,
#comment-form {
  display: grid;
  gap: 12px;
}

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

input[type="password"],
input[type="text"],
input[type="file"],
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(15, 10, 8, 0.85);
  color: var(--text);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  padding: 13px 18px;
  background: linear-gradient(135deg, #ff8f3f 0%, #ff6c37 100%);
  color: #1a110c;
  font-weight: 700;
}

button:hover {
  filter: brightness(1.05);
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.auth-topbar {
  padding-top: 24px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.flash {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
}

.flash-success {
  background: rgba(88, 173, 113, 0.14);
}

.flash-error {
  background: rgba(210, 92, 64, 0.18);
}

.upload-panel {
  padding: 20px;
  margin-bottom: 20px;
}

.upload-label {
  font-weight: 700;
  color: var(--text);
}

.upload-hint,
.welcome-copy {
  margin: 8px 0 0;
  color: var(--muted);
}

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

.auth-card {
  padding: 24px;
}

.view-switcher {
  display: inline-flex;
  gap: 10px;
  margin-bottom: 18px;
  padding: 8px;
  background: rgba(36, 24, 18, 0.75);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.view-tab {
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  padding: 10px 16px;
}

.view-tab.is-active {
  background: linear-gradient(135deg, #ff8f3f 0%, #ff6c37 100%);
  color: #1a110c;
}

.gallery {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.9fr);
  gap: 20px;
}

.is-hidden {
  display: none !important;
}

.viewer-card,
.detail-panel {
  padding: 20px;
}

.viewer-stage {
  position: relative;
  min-height: 62vh;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0)),
    #0d0907;
  touch-action: pan-y;
}

#viewer-image,
.empty-state {
  width: 100%;
  height: 100%;
  min-height: 62vh;
}

#viewer-image {
  display: block;
  object-fit: contain;
  background: #0d0907;
  transition: transform 0.18s ease, opacity 0.18s ease;
  will-change: transform, opacity;
  user-select: none;
  -webkit-user-drag: none;
}

#viewer-image.is-animating {
  transition: transform 0.24s ease, opacity 0.24s ease;
}

.empty-state {
  display: none;
  place-items: center;
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

.nav-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 54px;
  height: 54px;
  padding: 0;
  border-radius: 50%;
  background: rgba(17, 12, 9, 0.7);
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 2rem;
  z-index: 2;
}

.nav-left {
  left: 14px;
}

.nav-right {
  right: 14px;
}

.nav-button:disabled {
  opacity: 0.35;
  cursor: default;
}

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

.meta-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.meta-value {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
}

.meta-value-small {
  font-size: 1rem;
  line-height: 1.4;
}

.detail-panel {
  display: grid;
  gap: 18px;
  align-content: start;
}

.rating-panel,
.comment-panel,
.comment-list-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel-strong);
}

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

.vote-button {
  padding: 14px 10px;
}

.vote-button-dislike {
  background: linear-gradient(135deg, #ff9a66 0%, #ff5c3f 100%);
}

.vote-button-like {
  background: linear-gradient(135deg, #ffcf72 0%, #ff9437 100%);
}

.comment-headline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#comment-count {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 143, 63, 0.14);
  color: var(--accent-strong);
  font-weight: 700;
}

.comment-list {
  display: grid;
  gap: 12px;
  max-height: 380px;
  overflow: auto;
}

.comment-item {
  border-radius: 18px;
  padding: 14px;
  background: rgba(18, 12, 9, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.comment-meta,
.comment-empty,
.comment-text {
  margin: 0;
}

.comment-meta {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.comment-text {
  line-height: 1.5;
}

.comment-empty {
  color: var(--muted);
}

.feed-list {
  display: grid;
  gap: 20px;
}

.feed-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.feed-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.feed-head p,
.feed-comments p {
  margin-bottom: 0;
}

.feed-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  justify-content: flex-end;
}

.feed-image {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 20px;
  background: #0d0907;
  border: 1px solid var(--line);
}

.feed-comments {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
}

.feed-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.feed-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.feed-modal-card {
  position: relative;
  width: min(900px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  margin: 12px auto;
  padding: 20px;
  border-radius: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.feed-modal-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  background: rgba(17, 12, 9, 0.9);
  color: var(--text);
}

.feed-modal-image {
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 22px;
  background: #0d0907;
  border: 1px solid var(--line);
}

.feed-modal-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.admin-panel {
  margin-top: 24px;
  padding: 22px;
}

.admin-head {
  margin-bottom: 18px;
}

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

.admin-card {
  padding: 20px;
}

.admin-card h3 {
  margin-top: 0;
}

.admin-card-wide {
  grid-column: 1 / -1;
}

.admin-list {
  display: grid;
  gap: 12px;
  max-height: 420px;
  overflow: auto;
}

.admin-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  padding: 14px;
  border-radius: 18px;
  background: rgba(18, 12, 9, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.admin-item strong {
  display: block;
  margin-bottom: 6px;
}

.admin-user-actions {
  display: grid;
  gap: 10px;
  min-width: 240px;
}

.admin-reset-form {
  display: grid;
  gap: 8px;
}

.admin-reset-form input[type="text"] {
  width: 100%;
}

.admin-item p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.4;
}

.danger-button {
  background: linear-gradient(135deg, #ff7b66 0%, #ff5032 100%);
  color: #2d0904;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .auth-grid,
  .gallery {
    grid-template-columns: 1fr;
  }

  .view-switcher {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .viewer-stage,
  #viewer-image,
  .empty-state {
    min-height: 50vh;
  }

  .feed-modal-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .gate,
  .app {
    width: min(100% - 20px, 1200px);
    padding-top: 14px;
  }

  .intro-video-desktop {
    display: none;
  }

  .intro-video-mobile {
    display: block;
  }

  .intro-overlay {
    padding: 20px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

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

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

  .feed-head {
    flex-direction: column;
  }

  .feed-stats {
    justify-content: flex-start;
  }

  .feed-modal-meta {
    grid-template-columns: 1fr;
  }

  .admin-item {
    flex-direction: column;
  }
}
