:root {
  color-scheme: light;
  --bg: #f6f1e8;
  --panel: #fffaf2;
  --panel-strong: #fffdf9;
  --text: #1f1a16;
  --muted: #6a6057;
  --line: #d8c8b5;
  --line-strong: #b8946c;
  --accent: #bb4d00;
  --accent-soft: #f6d8bf;
  --shadow: 0 12px 28px rgba(82, 48, 20, 0.08);
  --radius: 18px;
  --thread-step: 14px;
  --max-width: 860px;
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(187, 77, 0, 0.12), transparent 28%),
    linear-gradient(180deg, #fbf7f1, #f3ebdf 55%, #efe5d7);
}

body {
  margin: 0;
  color: var(--text);
}

a {
  color: inherit;
}

.page-shell {
  width: min(100%, var(--max-width));
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid rgba(184, 148, 108, 0.35);
  border-radius: calc(var(--radius) + 6px);
  background: rgba(255, 250, 242, 0.92);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.brand-block {
  margin-bottom: 12px;
}

.brand {
  display: inline-block;
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.tagline {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.feed-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.feed-nav a,
.story-comments,
.story-hn-link,
.empty-state a,
.error-state button,
.story-thread-link,
.thread-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 999px;
  text-decoration: none;
}

.feed-nav a {
  font-weight: 700;
  background: rgba(246, 216, 191, 0.55);
  border: 1px solid rgba(184, 148, 108, 0.35);
}

.feed-nav a.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.app {
  display: grid;
  gap: 14px;
}

.panel,
.story-card,
.story-detail,
.comment,
.empty-state,
.error-state,
.loading-state {
  border: 1px solid rgba(184, 148, 108, 0.32);
  border-radius: var(--radius);
  background: rgba(255, 253, 249, 0.92);
  box-shadow: var(--shadow);
}

.loading-state,
.empty-state,
.error-state {
  padding: 20px;
}

.loading-state {
  color: var(--muted);
}

.story-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  padding: 16px;
}

.story-rank {
  width: 36px;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--accent);
}

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

.story-link {
  display: inline-block;
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.3;
  text-decoration: none;
}

.story-link:focus-visible,
.story-comments:focus-visible,
.story-hn-link:focus-visible,
.feed-nav a:focus-visible,
.comment-toggle:focus-visible,
.error-state button:focus-visible,
.thread-link:focus-visible {
  outline: 3px solid rgba(187, 77, 0, 0.35);
  outline-offset: 2px;
}

.story-domain,
.story-meta,
.story-detail-meta,
.comment-meta,
.comment-count-label,
.route-caption {
  color: var(--muted);
  font-size: 0.92rem;
}

.story-meta {
  margin-top: 8px;
  display: grid;
  gap: 4px;
  line-height: 1.45;
}

.story-meta-line {
  color: var(--muted);
}

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

.story-comments,
.story-hn-link,
.thread-link {
  justify-content: flex-start;
  border: 1px solid rgba(184, 148, 108, 0.35);
  background: var(--panel);
  font-weight: 700;
}

.story-comments {
  background: var(--accent-soft);
}

.story-detail {
  padding: 18px;
}

.story-detail h1 {
  margin: 8px 0 10px;
  font-size: clamp(1.4rem, 5vw, 2rem);
  line-height: 1.12;
}

.story-detail-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.comment-count-label {
  margin: 0 0 2px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
}

.comment {
  overflow: hidden;
  margin-top: 12px;
}

.comment.depth-0 {
  margin-top: 16px;
}

.comment-body-wrap {
  padding: 0 14px 14px 14px;
}

.comment[data-collapsed="true"] .comment-body-wrap {
  display: none;
}

.comment-toggle {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 14px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.toggle-symbol {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(187, 77, 0, 0.1);
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 800;
}

.comment-body {
  line-height: 1.62;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.comment-body p:first-child {
  margin-top: 0;
}

.comment-body p:last-child {
  margin-bottom: 0;
}

.comment-body pre,
.comment-body code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comment-children {
  position: relative;
  margin-top: 14px;
  padding-left: var(--thread-step);
}

.comment-children::before {
  content: "";
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 5px;
  width: 2px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(184, 148, 108, 0.7), rgba(184, 148, 108, 0.15));
}

.comment.depth-1 {
  background: linear-gradient(180deg, rgba(255, 248, 238, 0.96), rgba(255, 253, 249, 0.96));
}

.comment.depth-2 {
  background: linear-gradient(180deg, rgba(255, 246, 232, 0.94), rgba(255, 251, 244, 0.96));
}

.comment.depth-3,
.comment.depth-4,
.comment.depth-5,
.comment.depth-6 {
  background: linear-gradient(180deg, rgba(254, 242, 226, 0.9), rgba(255, 250, 242, 0.96));
}

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

.empty-state,
.error-state {
  display: grid;
  gap: 10px;
}

.error-state button {
  width: fit-content;
  border: 0;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

@media (min-width: 720px) {
  .feed-nav {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .story-card {
    padding: 18px 20px;
  }

  .comment-children {
    padding-left: 18px;
  }
}
