:root {
  --pm-primary: #db2777;
  --pm-primary-dark: #f472b6;
  --pm-bg: #020617;
  --pm-surface: #1a1020;
  --pm-surface-2: #24132c;
  --pm-border: #4a2b4f;
  --pm-text: #f9eaf3;
  --pm-muted: #d0a8be;
  --pm-panel: #020617;
}

html {
  font-size: 16px;
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--pm-text);
  background: var(--pm-bg);
}

main {
  min-height: 100vh;
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 0.1rem rgba(2, 6, 23, 0.85), 0 0 0 0.25rem rgba(59, 130, 246, 0.35);
}

.form-control,
.form-select {
  background: var(--pm-surface-2);
  border-color: var(--pm-border);
  color: var(--pm-text);
}

.form-control::placeholder,
textarea.form-control::placeholder {
  color: #64748b;
}

.phone-page {
  padding: 1rem;
}

.narrow-shell {
  max-width: 680px;
  margin: 0 auto;
}

.auth-shell {
  min-height: 100vh;
  padding: 0;
}

.phone-card,
.phone-viewer-card,
.media-card {
  background: var(--pm-surface);
  border: 1px solid var(--pm-border);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.auth-card {
  width: 100%;
  min-height: 100vh;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-content {
  width: min(100%, 980px);
  padding-inline: max(2rem, 7vw);
}

.phone-title-block {
  margin-bottom: 1rem;
}

.section-back-link {
  display: inline-block;
  margin-bottom: 0.5rem;
  color: var(--pm-primary);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
}

.phone-title-block h1,
.login-title {
  font-size: clamp(3rem, 8vw, 4.75rem);
  font-weight: 700;
  margin: 0 0 0.25rem;
}

.login-subtitle {
  font-size: clamp(1.35rem, 4vw, 1.95rem);
}

.phone-title-block p,
.login-subtitle,
.login-footnote,
.muted-line,
.viewer-watermark-note,
.viewer-description,
.empty-state-card p {
  color: var(--pm-muted);
}

.app-lock {
  display: none;
}

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

.auth-content .form-control {
  min-height: 74px;
  font-size: 1.35rem;
  padding: 1rem 1.1rem;
}

.auth-content .phone-button {
  min-height: 74px;
  font-size: 1.35rem;
  font-weight: 700;
}

.capture-actions {
  display: grid;
  gap: 0.85rem;
}

.capture-card {
  padding: 0.9rem;
  border: 1px solid var(--pm-border);
  border-radius: 10px;
  background: var(--pm-surface-2);
}

.capture-help {
  margin-top: 0.45rem;
  font-size: 0.82rem;
  color: var(--pm-muted);
}

.field-label {
  font-weight: 600;
  font-size: 1.2rem;
}

.phone-button {
  min-height: 44px;
  background: var(--pm-primary);
  border-color: var(--pm-primary);
}

.gallery-topbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  background: var(--pm-primary);
  color: white;
  border-radius: 0;
  padding: 0.75rem 1rem;
  position: relative;
  z-index: 30;
}

.gallery-brand {
  font-size: 1.05rem;
  font-weight: 700;
}

.gallery-actions {
  grid-column: 2 / 4;
  display: flex;
  gap: 0.35rem;
}

.inline-capture-form {
  margin: 0;
}

.capture-icon-button {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.capture-inline-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.icon-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: white;
  text-decoration: none;
  font-size: 1.4rem;
}

.menu-popover {
  position: relative;
  z-index: 40;
}

.menu-popover[open] {
  z-index: 60;
}

.menu-popover summary {
  list-style: none;
  cursor: pointer;
}

.menu-popover summary::-webkit-details-marker {
  display: none;
}

.menu-sheet {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 170px;
  padding: 0.4rem;
  border-radius: 12px;
  background: white;
  color: var(--pm-text);
  border: 1px solid var(--pm-border);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
  z-index: 70;
  background: var(--pm-surface-2);
}

.menu-sheet a,
.menu-sheet button {
  display: block;
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 0;
  background: transparent;
  color: var(--pm-text);
  text-align: left;
  border-radius: 8px;
  text-decoration: none;
}

.menu-sheet a:hover,
.menu-sheet button:hover {
  background: rgba(59, 130, 246, 0.12);
}

.meta-chip,
.tile-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  background: rgba(59, 130, 246, 0.14);
  color: #bfdbfe;
  font-size: 0.8rem;
  font-weight: 600;
}

.gallery-grid {
  column-gap: 2px;
}

.gallery-group {
  margin-top: 0;
}

.gallery-group-header {
  padding: 0.6rem 0.9rem;
  background: #f1f5f9;
  background: #111827;
  color: var(--pm-muted);
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 0;
  text-transform: none;
}

.phone-gallery-grid {
  columns: 3;
  background: var(--pm-border);
  border-radius: 0;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.media-card {
  display: block;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  position: relative;
  border-radius: 0;
  border: 0;
  box-shadow: none;
  break-inside: avoid;
  margin-bottom: 2px;
}

.thumb-frame {
  aspect-ratio: auto;
  overflow: hidden;
  background: var(--pm-surface-2);
}

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

.viewer-stage img,
.viewer-stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.video-tile {
  height: 100%;
  display: grid;
  place-items: center;
  background: #334155;
  color: white;
  padding: 0.5rem;
  text-align: center;
}

.compact-video-tile span {
  font-size: 0.82rem;
  line-height: 1.2;
}

.tile-badge {
  position: absolute;
  top: 0.35rem;
  left: 0.35rem;
}

.media-shell {
  max-width: none;
  margin: 0;
  padding: 0;
}

.viewer-titlebar {
  background: var(--pm-primary);
  color: white;
  padding: 0.7rem 1rem;
  border-radius: 0;
}

.viewer-file-name {
  font-size: 0.92rem;
  font-weight: 700;
}

.viewer-stage {
  position: relative;
  min-height: calc(100vh - 7.2rem);
  background: black;
  overflow: hidden;
  touch-action: pan-y;
}

.viewer-stage.viewer-loading {
  opacity: 0.92;
}

.watermark-layer {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
  align-content: space-around;
  justify-items: center;
  pointer-events: none;
  padding: 1rem;
}

.watermark-layer span {
  transform: rotate(-24deg);
  color: rgba(255, 255, 255, 0.16);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-align: center;
}

.single-watermark {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%) rotate(-24deg);
  color: rgba(255, 255, 255, 0.14);
  font-size: 1rem;
  font-weight: 600;
  pointer-events: none;
}

.edge-watermark {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  font-size: 0.62rem;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.18);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
}

.edge-watermark-top {
  top: 0.75rem;
}

.edge-watermark-bottom {
  bottom: 0.75rem;
}

.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2.5rem;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  background: rgba(15, 23, 42, 0.35);
  border: 0;
  text-decoration: none;
  font-size: 2rem;
  line-height: 1;
  z-index: 4;
}

.viewer-nav-prev {
  left: 0.25rem;
  border-radius: 0.6rem;
}

.viewer-nav-next {
  right: 0.25rem;
  border-radius: 0.6rem;
}

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

.back-link {
  display: inline-block;
  margin-bottom: 0.3rem;
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
}

.viewer-meta-panel {
  background: var(--pm-panel);
  color: #e2e8f0;
  border-radius: 0;
  padding: 0.85rem 1rem 1rem;
}

.viewer-description {
  margin-top: 0.35rem;
}

.viewer-watermark-note {
  font-size: 0.8rem;
  margin-top: 0.35rem;
}

.viewer-actions-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.viewer-action-menu {
  position: relative;
}

.viewer-action-menu summary {
  list-style: none;
  cursor: pointer;
}

.viewer-action-menu summary::-webkit-details-marker {
  display: none;
}

.viewer-action-sheet {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  min-width: 220px;
  padding: 0.4rem;
  border: 1px solid var(--pm-border);
  border-radius: 12px;
  background: var(--pm-surface-2);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.28);
  z-index: 20;
}

.viewer-delete-form {
  margin: 0;
}

.viewer-action-danger {
  width: 100%;
  display: block;
  padding: 0.8rem 0.9rem;
  border: 0;
  background: transparent;
  text-align: left;
  color: #fdba74;
  border-radius: 8px;
}

.viewer-action-danger:hover {
  background: rgba(249, 115, 22, 0.12);
}

.viewer-action-danger-strong {
  color: #fca5a5;
}

.viewer-action-danger-strong:hover {
  background: rgba(239, 68, 68, 0.12);
}

.comments-panel {
  margin-top: 0;
  padding: 1rem;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  box-shadow: none;
}

.comments-header {
  margin-bottom: 0.75rem;
}

.comments-list {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.comment-item {
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--pm-border);
}

.comment-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.comment-line {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.2rem;
}

.comment-flag {
  font-size: 0.72rem;
  color: #bfdbfe;
  background: rgba(59, 130, 246, 0.14);
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
}

.comment-text {
  color: var(--pm-text);
  white-space: pre-wrap;
}

.comment-time,
.comment-empty {
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--pm-muted);
}

.comment-form {
  display: grid;
  gap: 0.75rem;
}

.comment-check-row {
  color: var(--pm-muted);
}

.terms-content {
  white-space: pre-wrap;
  font-family: inherit;
  color: var(--pm-text);
}

.check-row {
  display: flex;
  gap: 0.65rem;
  align-items: center;
}

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

.user-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1rem;
}

.user-menu-popover {
  position: relative;
}

.user-menu-button {
  list-style: none;
  width: 2.5rem;
  height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  cursor: pointer;
  color: var(--pm-muted);
}

.user-menu-button::-webkit-details-marker {
  display: none;
}

.user-menu-sheet {
  position: absolute;
  top: calc(100% + 0.25rem);
  right: 0;
  min-width: 170px;
  padding: 0.4rem;
  border: 1px solid var(--pm-border);
  border-radius: 12px;
  background: var(--pm-surface-2);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.28);
  z-index: 20;
}

.user-menu-sheet button,
.user-menu-disabled {
  width: 100%;
  display: block;
  padding: 0.7rem 0.8rem;
  border: 0;
  background: transparent;
  text-align: left;
  border-radius: 8px;
}

.user-menu-danger {
  color: #fca5a5;
}

.user-menu-danger:hover {
  background: rgba(239, 68, 68, 0.12);
}

.user-menu-disabled {
  color: var(--pm-muted);
}

.status-banner {
  margin-bottom: 0.9rem;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  background: rgba(59, 130, 246, 0.12);
  color: #bfdbfe;
}

.empty-state-card {
  padding: 1.25rem;
  margin-bottom: 0.75rem;
}

@media (max-width: 767.98px) {
  .hint-panel {
    flex-direction: column;
  }

  .viewer-stage {
    min-height: calc(100vh - 6.8rem);
  }

  .phone-page {
    padding: 0;
  }

  .phone-title-block,
  .phone-card,
  .viewer-meta-panel,
  .comments-panel,
  .status-banner,
  .empty-state-card {
    margin-left: 0;
    margin-right: 0;
  }
}

@media (min-width: 768px) {
  .auth-shell {
    display: grid;
    place-items: center;
  }

  .auth-card {
    min-height: 100vh;
  }
}
