:root {
  --p-default-bg: #2a2a2a;
  --p-default-fg: #e0e0e0;
}

.p {
  --c-bg: var(--p-default-bg);
  --c-fg: var(--p-default-fg);
}
.p-0 { --c-bg: #D2C4B1; --c-fg: #0a0a0a; }
.p-1 { --c-bg: #A1C08C; --c-fg: #0a0a0a; }
.p-2 { --c-bg: #BDB285; --c-fg: #0a0a0a; }
.p-3 { --c-bg: #BBC0D0; --c-fg: #0a0a0a; }
.p-4 {
  --c-bg: linear-gradient(180deg,
    #BD7575 0%,  #B9906C 20%, #A09B78 40%,
    #619E61 60%, #6C7BB9 80%, #84619E 100%);
  --c-fg: #ffffff;
}

.page-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 100%;
  max-width: min(96vw, 1200px);
}

.media-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  width: 100%;
}

.comments-col {
  display: none;
  width: 100%;
  max-width: min(88vw, 480px);
}

.page-grid.has-comments .comments-col {
  display: block;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s ease-out, transform 0.35s ease-out;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  padding-top: 20px;
}

.page-grid.has-comments .comments-col.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (min-width: 880px) {
  .page-grid.has-comments {
    display: grid;
    grid-template-columns: minmax(50%, 1fr) minmax(240px, 360px);
    align-items: start;
    justify-items: stretch;
  }
  .page-grid.has-comments .comments-col {
    max-width: none;
    border-top: none;
    padding-top: 0;
  }
}

.replies-header {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
}

.comment.is-post {
  max-width: 85%;
  margin: 0 auto 14px 0;
}

#comments-list .comment {
  max-width: 85%;
}

#comments-list.replies-left .comment {
  align-self: flex-start;
}

#comments-list.replies-right .comment {
  align-self: flex-end;
}

#comments-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comment {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  background: var(--c-bg);
  color: var(--c-fg);
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}

.comment.p-4 {
  background: var(--c-bg);
}

.c-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.c-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  background: #000000;
}

.c-avatar-default {
  display: inline-block;
}

.c-name {
  font-weight: 600;
  font-size: 13px;
}

.c-text {
  white-space: pre-wrap;
}

.comment-more {
  display: block;
  margin-top: 12px;
  font-size: 13px;
  color: #ff69b4;
  text-decoration: underline;
  text-align: center;
  cursor: pointer;
}

.reply-on-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s ease-out, transform 0.35s ease-out;
}

.reply-on-app.visible {
  opacity: 1;
  transform: translateY(0);
}

.reply-on-app-label {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.02em;
}

@media (prefers-reduced-motion: reduce) {
  .page-grid.has-comments .comments-col,
  .reply-on-app {
    transition: none;
    opacity: 1;
    transform: none;
  }
}

.restyle-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 1100; padding: 20px;
  opacity: 0; transition: opacity 0.2s ease;
}
.restyle-modal-backdrop.is-open { opacity: 1; }
.restyle-modal-sheet {
  background: rgba(22, 22, 22, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  max-width: 440px; width: 100%;
  padding: 24px;
  color: #ffffff;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}
.restyle-modal-message {
  margin: 0 0 18px;
  font-size: 15px; line-height: 1.4;
  color: rgba(255, 255, 255, 0.9);
  white-space: pre-wrap; word-break: break-word;
}
.restyle-modal-ok {
  width: 100%;
  background: linear-gradient(135deg, #ff1a75 0%, #ff6b9d 50%, #e040fb 100%);
  color: #ffffff; border: none;
  padding: 12px; border-radius: 999px;
  font-family: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer;
}
.restyle-modal-ok:hover { filter: brightness(1.1); }
