:root {
  --bg: #eef2f8;
  --card: #ffffff;
  --card-soft: #f5f7fb;
  --line: #dde5f0;
  --ink: #1f2a37;
  --muted: #718198;
  --accent: #2f80ed;
  --accent-strong: #2266be;
  --accent-soft: #e8f1ff;
  --bubble: #f7f9fc;
  --chip: #eef4ff;
  --danger: #d94a57;
  --shadow: 0 18px 42px rgba(28, 51, 84, 0.08);
  --composer-bg: rgba(248, 250, 252, 0.96);
  --composer-field-bg: #ffffff;
  --composer-field-border: #d7e0ee;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, #f9fbfe 0%, var(--bg) 100%);
}

button,
textarea {
  font: inherit;
}

.app-shell {
  width: min(720px, calc(100% - 20px));
  margin: 0 auto;
  padding: 14px 0 108px;
}

.thread-shell {
  background: var(--card);
  border: 1px solid rgba(221, 229, 240, 0.94);
  border-radius: 28px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.thread-header {
  padding: 18px 18px 16px;
  background:
    radial-gradient(circle at top right, rgba(47, 128, 237, 0.14), transparent 38%),
    linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border-bottom: 1px solid var(--line);
}

.post-published-bar {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.post-title,
.post-body,
.comment-text,
.comment-author,
.comment-time,
.post-author-name,
.author-copy strong,
.author-copy span,
.flash-note,
.empty-state strong,
.empty-state span {
  margin: 0;
}

.post-title {
  font-size: clamp(22px, 4.2vw, 32px);
  line-height: 1.12;
  letter-spacing: -0.03em;
}

.post-body {
  margin-top: 12px;
  font-size: 16px;
  line-height: 1.58;
  white-space: pre-wrap;
  color: #324255;
}

.post-author-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.post-reactions-wrap {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(221, 229, 240, 0.85);
}

.post-author-name {
  font-size: 14px;
  font-weight: 700;
  min-width: 0;
}

.author-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 38px;
  background: linear-gradient(135deg, #2f80ed, #6ea8ff);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.author-avatar-self {
  width: 40px;
  height: 40px;
  flex-basis: 40px;
}

.reaction-row,
.comment-reactions,
.comment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reaction-chip,
.action-chip {
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.reaction-chip:hover,
.action-chip:hover {
  transform: translateY(-1px);
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--accent-strong);
}

.reaction-chip span {
  color: var(--muted);
  font-size: 13px;
}

.comments-shell {
  padding: 14px 16px 18px;
}

.comments-heading {
  margin-bottom: 12px;
}

.comments-heading strong {
  font-size: 15px;
  font-weight: 700;
}

.comments-list {
  display: grid;
  gap: 14px;
}

.comment-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.comment-avatar {
  margin-top: 2px;
  width: 40px;
  height: 40px;
}

.comment-main {
  min-width: 0;
  display: grid;
  gap: 6px;
}

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

.comment-author {
  font-size: 14px;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comment-time {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.comment-text {
  font-size: 15px;
  line-height: 1.52;
  white-space: pre-wrap;
  color: #2b3645;
}

.comment-footer {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.action-chip {
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.action-chip-muted {
  color: var(--danger);
  border-color: rgba(217, 74, 87, 0.18);
}

.empty-state {
  display: grid;
  gap: 4px;
  padding: 20px 16px;
  border-radius: 18px;
  background: var(--card-soft);
  border: 1px dashed var(--line);
  text-align: center;
}

.flash-note {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(47, 128, 237, 0.1);
  color: var(--accent-strong);
  border: 1px solid rgba(47, 128, 237, 0.12);
}

.composer {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 20px));
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--composer-bg);
  backdrop-filter: blur(14px);
}

.composer::before {
  content: "";
  position: absolute;
  inset: 0;
  border-top: 1px solid rgba(205, 216, 230, 0.9);
  pointer-events: none;
}

.composer-bar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.composer-input-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 6px 6px 6px 12px;
  border-radius: 22px;
  border: 1px solid var(--composer-field-border);
  background: var(--composer-field-bg);
  box-shadow: 0 8px 22px rgba(22, 41, 71, 0.05);
}

.composer-input-wrap:focus-within {
  border-color: rgba(47, 128, 237, 0.45);
}

.composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  max-height: 180px;
  resize: none;
  padding: 9px 4px 9px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  outline: none;
  line-height: 1.45;
}

.composer-send {
  flex-shrink: 0;
  align-self: flex-end;
  min-height: 38px;
  padding: 0 14px;
  margin-bottom: 1px;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.composer-send-label {
  pointer-events: none;
}

.composer-send:disabled {
  opacity: 0.55;
  cursor: default;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 12px, 720px);
    padding-top: 8px;
    padding-bottom: 118px;
  }

  .thread-shell {
    border-radius: 22px;
  }

  .thread-header,
  .comments-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  .comment-row {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 10px;
  }

  .comment-avatar {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .composer {
    width: min(100% - 12px, 720px);
  }

  .comment-topline {
    flex-wrap: wrap;
  }

  .comment-time {
    margin-left: auto;
  }
}
