:root {
  color-scheme: dark;
  --bg: #07090c;
  --surface: #11161c;
  --surface-2: #171d24;
  --surface-3: #202832;
  --text: #f2f5f7;
  --muted: #99a4ad;
  --line: #29323d;
  --accent: #ff4500;
  --accent-2: #ff6a2f;
  --blue: #72a7ff;
  --danger: #ff9a7d;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

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

body {
  background:
    radial-gradient(circle at top left, rgba(255, 69, 0, 0.16), transparent 260px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.app-shell {
  margin: 0 auto;
  max-width: 620px;
  min-height: 100vh;
}

.topbar {
  align-items: center;
  backdrop-filter: blur(18px);
  background: rgba(7, 9, 12, 0.88);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: auto auto minmax(0, 1fr);
  min-height: 62px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-mark {
  align-items: center;
  background: var(--accent);
  border-radius: 999px;
  color: #fff;
  display: flex;
  font-size: 15px;
  font-weight: 900;
  height: 34px;
  justify-content: center;
  line-height: 1;
  width: 34px;
}

.top-title {
  min-width: 0;
}

.top-title h1,
.top-title p {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-title h1 {
  font-size: 17px;
  line-height: 1.25;
}

.top-title p {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.top-title p.error {
  color: var(--danger);
}

.icon-button {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  display: flex;
  font-size: 30px;
  font-weight: 500;
  height: 38px;
  justify-content: center;
  line-height: 1;
  padding: 0 0 3px;
  width: 38px;
}

.content {
  padding: 12px 10px 28px;
}

.view.is-hidden,
.is-hidden {
  display: none;
}

.feed-view {
  display: grid;
  gap: 10px;
}

.controls-card,
.post-card,
#detail,
.metric {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012)), var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.controls-card {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.search-form {
  display: grid;
  gap: 7px;
}

.search-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.input-row {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.input-row input {
  background: #0c1015;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  min-height: 42px;
  min-width: 0;
  padding: 0 14px;
  width: 100%;
}

.input-row input:focus {
  border-color: var(--accent-2);
  outline: 3px solid rgba(255, 69, 0, 0.18);
}

.input-row button,
.load-more-button,
.quiet-button {
  background: var(--accent);
  border: 0;
  border-radius: 999px;
  color: #fff;
  font-weight: 850;
  min-height: 42px;
  padding: 0 16px;
}

.quiet-button {
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--text);
}

.sort-group {
  background: #0c1015;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(4, 1fr);
  padding: 4px;
}

.sort-button {
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  min-height: 34px;
  padding: 0 4px;
}

.sort-button.active {
  background: var(--surface-3);
  color: var(--text);
}

.top-time-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: auto minmax(0, 1fr);
}

.top-time-row label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.top-time-row select {
  appearance: none;
  background: #0c1015;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  min-height: 38px;
  padding: 0 14px;
}

.favorite-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.favorite-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.favorite-list:empty {
  display: none;
}

.favorite-chip,
.sub-pill {
  background: rgba(255, 69, 0, 0.13);
  border: 1px solid rgba(255, 69, 0, 0.28);
  border-radius: 999px;
  color: #ffb79c;
  font-size: 13px;
  font-weight: 780;
  min-height: 32px;
  padding: 0 10px;
}

.user-search {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.posts {
  display: grid;
  gap: 10px;
}

.post-card {
  overflow: clip;
}

.post-card.is-read {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.018), rgba(255, 255, 255, 0.006)), #0b0f14;
  border-color: #1d252e;
  opacity: 0.68;
}

.post-card.is-read .post-title,
.post-card.is-read .post-text {
  color: #8e99a3;
}

.post-card:active {
  transform: scale(0.992);
}

.post-open {
  align-items: start;
  background: transparent;
  border: 0;
  color: inherit;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 92px;
  min-height: 120px;
  padding: 13px;
  text-align: left;
  width: 100%;
}

.post-main {
  min-width: 0;
}

.post-meta,
.post-actions,
.comment-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 8px;
  line-height: 1.35;
}

.sub-link,
.user-link {
  background: transparent;
  border: 0;
  color: #a9c7ff;
  font: inherit;
  font-weight: 800;
  margin: 0;
  padding: 0;
}

.user-link {
  color: var(--muted);
}

.post-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 760;
  line-height: 1.34;
  margin: 6px 0 8px;
  overflow-wrap: anywhere;
}

.post-text {
  color: #c8d0d7;
  display: -webkit-box;
  font-size: 13px;
  line-height: 1.45;
  margin: 0 0 10px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.post-actions {
  font-weight: 780;
}

.score {
  color: var(--accent-2);
}

.post-thumb {
  aspect-ratio: 1 / 1;
  background: #0c1015;
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 92px;
  object-fit: cover;
  width: 92px;
}

.post-thumb.is-hidden {
  display: none;
}

.post-open:has(.post-thumb.is-hidden) {
  grid-template-columns: 1fr;
}

.load-more-button {
  margin-top: 6px;
  width: 100%;
}

.load-more-button[disabled] {
  cursor: not-allowed;
  opacity: 0.5;
}

#detail {
  min-height: calc(100vh - 94px);
  overflow: clip;
}

.detail-empty {
  align-items: center;
  display: flex;
  justify-content: center;
}

.empty-state {
  color: var(--muted);
  margin: 0 auto;
  max-width: 290px;
  padding: 38px 20px;
  text-align: center;
}

.empty-state h2 {
  color: var(--text);
  font-size: 20px;
  margin: 0 0 8px;
}

.empty-state p {
  margin: 0;
}

.thread,
.user-panel {
  padding: 14px;
}

.thread-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.thread-title {
  color: var(--text);
  font-size: 21px;
  line-height: 1.28;
  margin: 8px 0 12px;
  overflow-wrap: anywhere;
}

.thread-body,
.comment-body,
.user-panel p {
  color: #d3d9df;
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.thread-body a,
.comment-body a {
  color: var(--blue);
  text-decoration: none;
  word-break: break-word;
}

.rich-body {
  white-space: normal;
}

.rich-body h1,
.rich-body h2,
.rich-body h3,
.rich-body h4 {
  color: var(--text);
  font-size: 16px;
  line-height: 1.3;
  margin: 16px 0 8px;
}

.rich-body h3:first-child {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  padding: 12px;
}

.rich-body p {
  margin: 8px 0;
}

.rich-body ul,
.rich-body ol {
  margin: 8px 0 12px;
  padding-left: 20px;
}

.rich-body li {
  margin: 5px 0;
}

.rich-body table {
  border-collapse: collapse;
  display: block;
  margin: 12px 0;
  max-width: 100%;
  overflow-x: auto;
  white-space: nowrap;
}

.rich-body th,
.rich-body td {
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  padding: 8px 10px;
  vertical-align: top;
}

.rich-body th {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 850;
  position: sticky;
  top: 0;
}

.rich-body tr:last-child td {
  border-bottom: 0;
}

.rich-body strong {
  color: var(--text);
}

.rich-body sup {
  color: var(--muted);
  font-size: 10px;
}

.game-summary-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  margin: 12px 0;
  padding: 14px;
}

.game-kicker,
.game-date {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  margin: 0;
  text-transform: uppercase;
}

.game-matchup {
  display: grid;
  gap: 8px;
  font-size: 18px;
  font-weight: 850;
  line-height: 1.2;
}

.game-matchup strong {
  color: var(--accent-2);
  font-size: 12px;
}

.game-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 760;
  gap: 10px;
}

.media-preview {
  background: #0c1015;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  margin-top: 14px;
  max-height: 520px;
  max-width: 100%;
  object-fit: contain;
  width: 100%;
}

.thread-media {
  display: grid;
  gap: 10px;
}

.media-loading {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.inline-image-preview {
  background: #0c1015;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  margin-top: 10px;
  max-height: 480px;
  max-width: 100%;
  object-fit: contain;
}

.giphy-preview {
  max-height: 360px;
}

.thread-actions {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 780;
  gap: 12px;
  margin-top: 14px;
}

.thread-link {
  color: var(--blue);
  text-decoration: none;
}

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

.comment {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 2px 0 0;
}

.comment-body {
  margin-top: 6px;
}

.comment-children {
  border-left: 2px solid var(--line);
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding-left: 10px;
}

.comment-children .comment {
  background: transparent;
}

.user-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
}

.metric {
  box-shadow: none;
  padding: 14px;
}

.metric strong {
  display: block;
  font-size: 22px;
}

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

.sub-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

@media (min-width: 720px) {
  body {
    padding: 20px 0;
  }

  .app-shell {
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
    min-height: calc(100vh - 40px);
    overflow: clip;
  }

  .topbar {
    border-radius: 18px 18px 0 0;
  }
}

@media (max-width: 380px) {
  .content {
    padding-left: 8px;
    padding-right: 8px;
  }

  .post-open {
    grid-template-columns: minmax(0, 1fr) 78px;
  }

  .post-thumb {
    height: 78px;
    width: 78px;
  }

  .sort-button {
    font-size: 12px;
  }
}
