:root {
  color-scheme: light;
  --accent: #ff6600;
  --accent-soft: #fff1e8;
  --bg: #f7f7f5;
  --panel: #ffffff;
  --text: #22252a;
  --muted: #7b818b;
  --faint: #a6abb3;
  --line: #e7e7e4;
  --line-strong: #d7d7d2;
  --link: #1f2937;
  --focus: #2563eb;
  --danger: #b42318;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --accent: #ff8a3d;
  --accent-soft: #2f2118;
  --bg: #111315;
  --panel: #171a1e;
  --text: #e5e7eb;
  --muted: #9aa3af;
  --faint: #707985;
  --line: #2a2f36;
  --line-strong: #3a414a;
  --link: #f1f5f9;
  --focus: #60a5fa;
  --danger: #f87171;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  backdrop-filter: blur(12px);
}

.topbar-inner {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  max-width: 1180px;
  min-height: 54px;
  margin: 0 auto;
  padding: 0 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 750;
  letter-spacing: 0;
}

.brand-mark {
  display: inline-grid;
  width: 20px;
  height: 20px;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.brand-name {
  white-space: nowrap;
}

.feed-tabs,
.toolbar,
.segmented {
  display: flex;
  align-items: center;
}

.feed-tabs {
  justify-content: center;
  gap: 4px;
}

.toolbar {
  justify-content: flex-end;
  gap: 10px;
}

.tab {
  min-width: 64px;
  min-height: 54px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.tab.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 650;
}

.segmented {
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel);
}

.segment {
  min-height: 32px;
  padding: 0 11px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segment.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
}

.brand:focus-visible,
.tab:focus-visible,
.segment:focus-visible,
.icon-button:focus-visible,
.story-title:focus-visible,
.inline-link:focus-visible,
.back-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent);
  outline-offset: 2px;
}

.shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 34px 22px 56px;
}

.view.hidden {
  display: none;
}

.page-head,
.thread-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 620;
  line-height: 1.16;
  letter-spacing: 0;
}

h2 {
  margin: 30px 0 16px;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

.status {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status.error {
  color: var(--danger);
}

.story-table-wrap {
  overflow-x: auto;
}

.story-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.story-table th {
  padding: 0 10px 13px;
  border-bottom: 1px solid var(--line);
  color: #5f6670;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
}

.story-table td {
  padding: 7px 10px;
  vertical-align: top;
}

.story-row:hover {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}

.rank-col,
.rank-cell {
  width: 34px;
  color: var(--faint);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.points-col,
.points-cell {
  width: 70px;
  color: var(--accent);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.age-col,
.age-cell {
  width: 88px;
  color: var(--muted);
  white-space: nowrap;
}

.replies-col,
.replies-cell {
  width: 72px;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.link-cell {
  min-width: 360px;
}

.story-title {
  display: inline;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--link);
  cursor: pointer;
  font-weight: 520;
  line-height: 1.35;
  text-align: left;
  text-decoration: none;
}

.story-title:hover,
.inline-link:hover,
.back-button:hover {
  color: var(--accent);
}

.host {
  margin-left: 5px;
  color: var(--faint);
  font-size: 12px;
  white-space: nowrap;
}

.subline,
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.inline-link,
.comments-link,
.back-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  text-decoration: none;
}

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

.inline-link.primary {
  color: var(--accent);
}

.thread-head {
  margin-bottom: 18px;
}

.thread-kicker {
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 13px;
}

.back-button {
  font-weight: 650;
}

.thread-title-block {
  min-width: 0;
}

.thread-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  min-width: 170px;
  padding-top: 4px;
}

.translation {
  display: inline-block;
  line-height: 1.48;
}

.translation-original {
  display: block;
  color: var(--text);
}

.translation-original.block {
  white-space: pre-line;
}

.translation-main {
  display: block;
  margin-top: 6px;
  color: #5b6470;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
}

.story-body .translation-main,
.comment-text .translation-main {
  margin-top: 10px;
  padding-left: 12px;
  border-left: 2px solid var(--line);
  font-size: 13px;
  white-space: pre-line;
}

h1 .translation-main {
  font-size: 15px;
}

.translation-pending {
  display: block;
  margin-top: 5px;
  color: var(--faint);
  font-size: 12px;
}

.story-body {
  margin-top: 18px;
  padding: 16px 0 2px;
  border-top: 1px solid var(--line);
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-line;
}

.comments {
  margin-top: 10px;
}

.comment {
  position: relative;
  margin-top: 18px;
  padding-left: 18px;
  border-left: 2px solid var(--line);
}

.comment:hover {
  border-left-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.comment.collapsed {
  border-left-color: var(--line);
}

.comment-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.comment-collapse {
  border: 0;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1;
  padding: 0 1px 0 0;
}

.comment-collapse:hover {
  color: var(--accent);
}

.comment-text {
  margin-top: 8px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.62;
  white-space: pre-line;
}

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

.empty-state,
.loading-state {
  display: grid;
  min-height: 320px;
  place-items: center;
  color: var(--muted);
}

@media (max-width: 820px) {
  .topbar-inner {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px 16px;
  }

  .brand {
    justify-content: center;
  }

  .feed-tabs {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .tab {
    min-height: 38px;
  }

  .toolbar {
    justify-content: space-between;
  }

  .shell {
    padding: 24px 14px 44px;
  }

  h1 {
    font-size: 26px;
  }

  .story-table th.age-col,
  .story-table th.replies-col,
  .age-cell,
  .replies-cell {
    display: none;
  }

  .points-col,
  .points-cell {
    width: 54px;
  }

  .link-cell {
    min-width: 260px;
  }

  .thread-head {
    display: block;
  }

  .thread-actions {
    justify-content: flex-start;
    margin-top: 14px;
  }

  .comment-children {
    margin-left: 9px;
  }
}
