:root {
  color-scheme: light;
  --bg: #8fcaf7;
  --fg: #10243f;
  --muted: #5a6f91;
  --card: #ffffff;
  --surface: #f3f8ff;
  --accent: #1f8cff;
  --accent-2: #1474dc;
  --line: rgba(16, 36, 63, 0.14);
  --line-soft: rgba(16, 36, 63, 0.09);
}

html,
body {
  height: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  font-family: "Manrope", "Segoe UI", sans-serif;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 20% 22%, rgba(255, 255, 255, 0.22) 0 2px, transparent 2px),
    radial-gradient(circle at 78% 60%, rgba(38, 131, 216, 0.2) 0 1.5px, transparent 2.5px),
    repeating-linear-gradient(31deg, rgba(255, 255, 255, 0.14) 0 2px, transparent 2px 26px),
    repeating-linear-gradient(-33deg, rgba(43, 137, 219, 0.12) 0 2px, transparent 2px 30px);
  background-size: 130px 130px, 150px 150px, 220px 220px, 240px 240px;
  color: var(--fg);
  overflow: hidden;
}

body.modal-open {
  overflow: hidden;
}

.app {
  width: min(760px, 100vw);
  height: 100dvh;
  max-height: 100dvh;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.92), rgba(243, 248, 255, 0.94));
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 18px 40px rgba(16, 36, 63, 0.14);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 12px;
  border: 1px solid rgba(52, 118, 188, 0.22);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 3px 8px rgba(16, 36, 63, 0.05);
}

h1 {
  margin: 0;
  letter-spacing: -0.02em;
  font-size: clamp(20px, 7vw, 34px);
  line-height: 1.1;
}

#btn-close {
  min-width: 98px;
  border-radius: 12px;
  font-weight: 600;
  padding: 8px 12px;
}

button {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

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

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.ghost {
  background: rgba(255, 255, 255, 0.9);
  color: var(--fg);
  border-color: rgba(52, 118, 188, 0.28);
}

button.ghost:hover {
  background: #fff;
}

.hidden {
  display: none;
}

.thread-wrap {
  margin-top: 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
  padding-bottom: 10px;
  scroll-padding-bottom: 10px;
}

#load-more {
  width: 100%;
}

.comments {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.comment {
  border: 1px solid rgba(52, 118, 188, 0.24);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  padding: 10px 12px;
  box-shadow: 0 4px 10px rgba(16, 36, 63, 0.04);
}

.comment.reply {
  margin-left: 16px;
  border-left: 4px solid rgba(31, 140, 255, 0.58);
}

.comment.focus-pulse {
  animation: comment-focus 1.4s ease;
}

@keyframes comment-focus {
  0% {
    box-shadow: inset 0 0 0 0 rgba(31, 140, 255, 0);
  }
  30% {
    box-shadow: inset 0 0 0 2px rgba(31, 140, 255, 0.54);
  }
  100% {
    box-shadow: inset 0 0 0 0 rgba(31, 140, 255, 0);
  }
}

.comment.deleted {
  opacity: 0.82;
}

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

.comment.deleted .text {
  color: var(--muted);
  font-style: italic;
}

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

.author {
  font-weight: 700;
}

.time {
  color: var(--muted);
  font-size: 12px;
}

.text {
  margin-top: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.reply-context {
  width: 100%;
  margin-bottom: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px dashed rgba(52, 118, 188, 0.35);
  background: #eaf4ff;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-context:hover {
  background: #e0eeff;
}

.comment-actions {
  margin-top: 8px;
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 2px;
}

.action-btn {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 999px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.action-icon {
  line-height: 1;
  font-size: 13px;
}

.action-icon-danger {
  color: #bf6363;
}

.action-count {
  min-width: 10px;
  text-align: center;
}

.action-btn--like.active {
  background: #dff0ff;
  color: #0f6bc9;
  border: 1px solid #a6cdf5;
}

.action-btn--dislike.active {
  background: #edf5ff;
  color: #255591;
  border: 1px solid #c5daf8;
}

.action-btn--delete {
  border-color: var(--line);
}

.deleted-meta {
  color: var(--muted);
  font-size: 13px;
}

.composer-wrap {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid rgba(52, 118, 188, 0.2);
  background: linear-gradient(to bottom, rgba(243, 248, 255, 0.4), var(--surface) 35%);
}

.replying {
  margin-bottom: 6px;
  padding: 6px 8px;
  border-left: 3px solid #4b9ef5;
  background: #eef6ff;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}

textarea {
  width: 100%;
  min-height: 44px;
  max-height: 108px;
  resize: none;
  border: 1px solid rgba(52, 118, 188, 0.28);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  line-height: 1.35;
  color: var(--fg);
  background: #fff;
  overflow-y: hidden;
}

textarea:focus {
  outline: none;
  border-color: #6caef2;
  box-shadow: 0 0 0 2px rgba(75, 158, 245, 0.2);
}

.composer-actions {
  margin-top: 6px;
  display: grid;
  gap: 6px;
}

#send-comment {
  width: 100%;
  border-radius: 12px;
  min-height: 44px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 22, 36, 0.46);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(560px, 100%);
  background: #f9fcff;
  border: 1px solid rgba(52, 118, 188, 0.22);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.2);
}

.modal-title {
  margin: 0;
  font-size: 20px;
}

.modal-message {
  margin: 8px 0 0;
  color: var(--muted);
}

.modal-input {
  width: 100%;
  min-height: 108px;
  margin-top: 10px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  color: var(--fg);
}

.modal-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.modal-actions button {
  flex: 1;
}

.modal-submit-danger {
  background: #b83232;
}

.modal-submit-danger:hover {
  background: #9d2a2a;
}

@media (max-width: 640px) {
  .app {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    padding: 10px;
    box-shadow: none;
    border-left: 0;
    border-right: 0;
  }

  .topbar {
    padding: 5px 7px;
    border-radius: 11px;
  }

  h1 {
    font-size: clamp(18px, 7.2vw, 28px);
  }

  #btn-close {
    min-width: 90px;
    padding: 7px 10px;
  }

  .thread-wrap {
    margin-top: 8px;
  }

  .comment.reply {
    margin-left: 8px;
  }

  .modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card {
    width: 100%;
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding: 14px;
  }
}
