:root {
  color-scheme: dark;
  --bg: #090909;
  --bg-accent: #14090b;
  --panel: rgba(18, 18, 20, 0.9);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #f4efed;
  --muted: #b8a9a5;
  --accent: #d7263d;
  --accent-dark: #8f1020;
  --green: #48c78e;
  --red: #ff6b6b;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.42);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(215, 38, 61, 0.24), transparent 26%),
    radial-gradient(circle at top right, rgba(140, 16, 32, 0.28), transparent 22%),
    linear-gradient(180deg, #140607 0%, var(--bg) 100%);
}

body.modal-open .page-shell {
  filter: blur(12px);
  pointer-events: none;
  user-select: none;
}

body.modal-open {
  overflow: hidden;
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 96px 0 64px;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  margin-bottom: 0;
  padding: 14px 24px;
  border-bottom: 1px solid var(--panel-border);
  border-radius: 0;
  background: rgba(10, 10, 12, 0.94);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.brand,
.nav-button,
.hero-button {
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(215, 38, 61, 0.22), rgba(143, 16, 32, 0.36));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.brand-mark svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-wordmark {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.24rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

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

.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 11px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, border-color 140ms ease;
}

.nav-button-secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.nav-button-primary {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.nav-button[aria-current="page"] {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.18),
    0 0 24px rgba(215, 38, 61, 0.28);
}

.app-main {
  display: grid;
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
  gap: 22px;
}

.hero {
  padding: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 700;
}

.hero h1 {
  margin: 0;
  max-width: 10ch;
  font-size: clamp(2.8rem, 7vw, 5.4rem);
  line-height: 0.95;
}

.hero-copy {
  max-width: 56ch;
  margin: 16px 0 0;
  font-size: 1.05rem;
  color: var(--muted);
}

.hero-actions {
  margin-top: 22px;
}

.hero-button {
  display: inline-flex;
  align-items: center;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(18px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.gallery-panel {
  padding: 22px;
  position: relative;
}

.upload-page {
  display: block;
  width: min(100%, 640px);
  margin: 0 auto;
  padding: 24px;
}

.panel-head h2,
.comments h4,
.image-title {
  margin: 0;
}

.panel-head p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.gallery-panel .panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.gallery-panel .panel-head p {
  margin: 0;
  text-align: right;
}

.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.gallery-filter {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font: inherit;
  line-height: 1;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.gallery-filter:hover {
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--text);
  transform: translateY(-1px);
}

.gallery-filter.is-active {
  border-color: rgba(255, 154, 167, 0.3);
  background: rgba(255, 154, 167, 0.14);
  color: var(--text);
}

.app-status {
  margin: 18px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(72, 199, 142, 0.12);
  color: var(--green);
}

.app-status.error {
  background: rgba(215, 38, 61, 0.14);
  color: var(--red);
}

.upload-form {
  display: grid;
  gap: 16px;
}

.file-picker,
.field {
  display: grid;
  gap: 8px;
}

.file-picker span,
.field span {
  font-size: 0.94rem;
  color: var(--muted);
}

input[type="text"],
select,
.comment-input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
}

.duration-picker {
  position: relative;
}

.duration-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.duration-caret {
  color: var(--muted);
  font-size: 0.9rem;
  transition: transform 140ms ease;
}

.duration-picker.is-open .duration-caret {
  transform: rotate(180deg);
}

.duration-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 10px);
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(13, 13, 15, 0.98);
  box-shadow: var(--shadow);
  z-index: 12;
}

.duration-menu[hidden] {
  display: none !important;
  pointer-events: none;
}

.duration-picker:not(.is-open) .duration-menu {
  display: none;
  pointer-events: none;
}

.duration-option {
  width: 100%;
  justify-content: flex-start;
  border-radius: 12px;
  padding: 10px 12px;
  background: transparent;
  color: var(--text);
}

.duration-option.is-selected,
.duration-option:hover {
  background: rgba(255, 255, 255, 0.08);
}

input[type="file"] {
  padding: 10px 0;
  font: inherit;
}

.preview-panel {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 420px);
  margin: 0 auto;
  min-height: 0;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(32, 10, 13, 0.96), rgba(70, 12, 22, 0.78));
  cursor: pointer;
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.preview-panel:hover {
  border-color: rgba(255, 255, 255, 0.18);
}

.preview-panel.drag-over {
  border-color: rgba(255, 154, 167, 0.72);
  box-shadow: 0 0 0 1px rgba(255, 154, 167, 0.3), 0 0 28px rgba(215, 38, 61, 0.2);
}

.preview-empty {
  display: grid;
  gap: 8px;
  padding: 32px;
  text-align: center;
  color: var(--muted);
  max-width: 26ch;
}

.preview-empty strong,
.preview-empty span {
  display: block;
}

.dropzone-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  margin: 0 auto 6px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.05);
  color: #ffd5db;
}

.dropzone-icon svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.preview-empty strong {
  color: var(--text);
  font-size: 1rem;
}

.upload-preview {
  position: absolute;
  display: block;
  cursor: grab;
  user-select: none;
  touch-action: none;
  max-width: none;
}

.upload-preview.dragging {
  cursor: grabbing;
}

.adjust-controls {
  width: min(100%, 420px);
  margin: 0 auto;
  display: grid;
  gap: 10px;
}

.adjust-hint {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.meta-grid {
  display: grid;
  gap: 12px;
}

.meta-card {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(28, 15, 17, 0.94), rgba(17, 17, 19, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.meta-card strong,
.meta-card span {
  display: block;
}

.meta-card span {
  margin-top: 6px;
  color: var(--muted);
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  font: inherit;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

button:hover {
  transform: translateY(-1px);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  font-weight: 700;
  margin-top: 10px;
  min-height: 50px;
  padding: 0 20px;
  box-shadow: 0 14px 30px rgba(143, 16, 32, 0.28);
}

.publish-button {
  width: 100%;
}

.button-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.button-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.image-card {
  display: grid;
  gap: 0;
  background: rgba(17, 17, 19, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  overflow: hidden;
}

.image-open-button {
  position: relative;
  padding: 0;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
}

.image-preview {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: linear-gradient(135deg, #220a0d, #68111f);
}

.image-body {
  padding: 12px 14px 14px;
}

.image-topline {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.image-title {
  font-size: 0.9rem;
  line-height: 1.25;
  font-weight: 600;
  text-align: center;
  width: 100%;
}

.timer-badge {
  flex-shrink: 0;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  background: rgba(8, 8, 10, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff1f3;
  backdrop-filter: blur(10px);
}

.image-corner-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  max-width: calc(100% - 24px);
}

.stats-row {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

#modal-stats {
  flex-wrap: wrap;
  justify-content: center;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}

.icon-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.72rem;
  line-height: 1;
  flex-shrink: 0;
}

.icon-svg svg {
  width: 15px;
  height: 15px;
  display: block;
}

.upvote .icon-glyph {
  background: rgba(72, 199, 142, 0.16);
  color: #7ff0b2;
}

.extend-button .icon-glyph {
  background: rgba(215, 38, 61, 0.18);
  color: #ff9aa7;
}

.comment-count-button .icon-glyph {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.modal-stat .icon-glyph {
  background: rgba(255, 255, 255, 0.08);
}

.vote-button,
.extend-button,
.comment-count-button,
.comment-form button {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.upvote.active {
  background: rgba(72, 199, 142, 0.16);
  color: var(--green);
}

.downvote.active {
  background: rgba(255, 107, 107, 0.18);
  color: var(--red);
}

.extend-button.active {
  background: rgba(215, 38, 61, 0.18);
  color: #ff8a98;
}

.extend-button:disabled,
.vote-button:disabled,
.comment-form button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.extend-status {
  margin: 12px 0 0;
  min-height: 1.4em;
  color: var(--muted);
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow-y: auto;
}

.image-modal[hidden] {
  display: none;
}

.image-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
}

.image-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(680px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  height: auto;
  max-height: min(90vh, 920px);
  overflow: hidden;
  align-items: start;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  background: rgba(13, 13, 15, 0.98);
  box-shadow: 0 36px 90px rgba(0, 0, 0, 0.48);
}

.image-modal-dialog.comments-open {
  width: min(1040px, 100%);
  grid-template-columns: minmax(0, 680px) 360px;
  align-items: start;
}

.modal-main {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  height: auto;
  align-self: start;
  min-width: 0;
  overflow: hidden;
  background: transparent;
}

.image-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  background: rgba(255, 255, 255, 0.08);
}

.modal-image-wrap {
  position: relative;
  width: min(100%, 540px);
  margin: 0 auto;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: transparent;
  flex-shrink: 0;
}

.modal-delete-button {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  border: 1px solid rgba(255, 154, 167, 0.34);
  border-radius: 999px;
  padding: 9px 14px;
  background: rgba(215, 38, 61, 0.92);
  color: #fff7f8;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(143, 16, 32, 0.28);
  backdrop-filter: blur(10px);
}

.modal-delete-button:hover {
  background: rgba(235, 48, 73, 0.98);
  border-color: rgba(255, 186, 194, 0.45);
}

.modal-delete-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.modal-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
}

.modal-body {
  flex: 0 0 auto;
  padding: 16px 18px 18px;
  overflow: visible;
}

.modal-comments-panel {
  width: 360px;
  flex: 0 0 360px;
  display: none;
  flex-direction: column;
  height: min(calc(100vh - 96px), 780px);
  min-height: 0;
  overflow: hidden;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  align-self: start;
}

.image-modal-dialog.comments-open .modal-comments-panel {
  display: flex;
}

.modal-comments {
  margin-top: 0;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 0 18px 18px;
  border-top: 0;
  overflow: hidden;
}

.comments.modal-comments {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.modal-comments .comment-list {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  max-height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  margin-top: 0;
  padding-right: 4px;
}

.modal-comments .comment-list > li:first-child {
  margin-top: auto;
}

.modal-comments .comment-form {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding-top: 10px;
  background: transparent;
}

.modal-comment-toggle[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.12);
}

.comments {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

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

.comment-list li {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

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

.comment-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.empty-state {
  padding: 26px;
  border-radius: 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(255, 255, 255, 0.12);
}

@media (max-width: 860px) {
  .image-modal-dialog,
  .image-modal-dialog.comments-open {
    width: min(680px, 100%);
    height: auto;
    display: flex;
    flex-direction: column;
  }

  .modal-main {
    flex: 1 1 auto;
    width: 100%;
  }

  .modal-comments-panel {
    width: 100%;
    flex: 0 0 auto;
    height: auto;
    align-self: stretch;
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

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

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

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

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

  .page-shell {
    width: min(100% - 20px, 1180px);
  }

  .hero,
  .gallery-panel,
  .upload-page {
    padding: 18px;
  }

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

  .topbar-nav {
    width: 100%;
    justify-content: space-between;
  }
}
