:root {
  --paper: #0d1110;
  --ink: #f5f1e8;
  --muted: #9da79f;
  --hairline: #2f3833;
  --green: #6ac38f;
  --green-2: #153622;
  --orange: #f09a53;
  --blue-rail: #111a1f;
  --red: #ff6b5f;
  --white: #171d1a;
  --field: #0f1513;
  --field-border: #3a4840;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.48);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

a {
  color: inherit;
  text-decoration-color: rgba(35, 107, 75, 0.35);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

button,
input,
textarea {
  font: inherit;
}

.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;
}

.topbar {
  min-height: 64px;
  display: grid;
  grid-template-columns: auto auto minmax(180px, 360px) auto auto;
  align-items: center;
  gap: 24px;
  padding: 12px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--hairline);
  background: rgba(13, 17, 16, 0.94);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  background: var(--green);
  color: #07100b;
  border-radius: 7px;
  font-size: 12px;
}

.nav {
  display: flex;
  gap: 18px;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
}

.nav a {
  text-decoration: none;
}

.search input,
.stack-form input,
.stack-form textarea,
.stack-form select,
.submit-dialog input,
.submit-dialog textarea,
.submit-dialog select {
  width: 100%;
  border: 1px solid var(--field-border);
  background: var(--field);
  color: var(--ink);
  border-radius: 6px;
  padding: 11px 12px;
  outline: none;
}

.search input:focus,
.stack-form input:focus,
.stack-form textarea:focus,
.stack-form select:focus,
.submit-dialog input:focus,
.submit-dialog textarea:focus,
.submit-dialog select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(106, 195, 143, 0.18);
}

.button {
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 750;
  font-size: 14px;
}

.button-primary {
  background: var(--green);
  border-color: var(--green);
  color: #07100b;
}

.layout {
  width: min(1220px, calc(100vw - 36px));
  margin: 28px auto 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 28px;
}

.stream {
  min-width: 0;
}

.stream-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  padding: 0 0 20px;
  border-bottom: 3px solid var(--ink);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(32px, 4vw, 58px);
  line-height: 0.95;
  margin-bottom: 10px;
  letter-spacing: 0;
}

.deck {
  color: var(--muted);
  max-width: 620px;
  margin-bottom: 0;
}

.stream-meta {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.story-list {
  display: grid;
}

.story {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 14px;
  padding: 18px 0;
  border-bottom: 1px solid var(--hairline);
}

.score {
  min-height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 6px;
  font-weight: 850;
  background: var(--green-2);
}

.story h2 {
  margin: 0 0 6px;
  font-size: clamp(19px, 2vw, 28px);
  line-height: 1.1;
  letter-spacing: 0;
}

.story-title {
  text-decoration: none;
}

.story-title:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

.story-note {
  margin: 0 0 10px;
  color: #d7d1c5;
}

.story-selection {
  margin: 8px 0 10px;
  padding-left: 12px;
  border-left: 3px solid var(--orange);
  color: #c4beb2;
}

.story-meta,
.story-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.tag {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--green-2);
  color: #b8f0cd;
  text-decoration: none;
  font-size: 12px;
  font-weight: 750;
}

.comments {
  align-self: start;
  display: inline-grid;
  min-width: 74px;
  gap: 2px;
  justify-items: center;
  border-left: 4px solid var(--orange);
  background: var(--white);
  padding: 8px 10px;
  color: var(--orange);
  font-size: 12px;
  font-weight: 800;
}

.comments strong {
  color: var(--red);
  font-size: 22px;
  line-height: 1;
}

.rail {
  display: grid;
  align-content: start;
  gap: 14px;
}

.rail-section {
  background: var(--blue-rail);
  border: 1px solid #263b43;
  border-radius: 8px;
  padding: 16px;
}

.rail-section h2 {
  font-size: 15px;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stats {
  display: grid;
  gap: 10px;
  margin: 0;
}

.stats div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #263b43;
  padding-bottom: 8px;
}

.stats div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

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

.stats dd {
  margin: 0;
  font-weight: 850;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rail-note p {
  color: #c3ccc4;
  margin-bottom: 12px;
}

.rail-copy {
  color: #c3ccc4;
  margin-bottom: 12px;
}

.mini-form {
  display: grid;
  gap: 8px;
}

.mini-form input {
  width: 100%;
  border: 1px solid var(--field-border);
  background: var(--field);
  color: var(--ink);
  border-radius: 6px;
  padding: 10px;
  outline: none;
}

.quiet-link {
  font-size: 14px;
  font-weight: 750;
}

.account {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 10px;
  min-width: 88px;
  color: var(--muted);
  font-size: 13px;
}

.account strong {
  color: var(--ink);
}

.account img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--field-border);
}

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

.mini-button {
  min-height: 28px;
  border: 1px solid var(--field-border);
  border-radius: 5px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
}

.mini-button[aria-pressed="true"] {
  background: var(--green);
  color: #07100b;
  border-color: var(--green);
}

.mini-list {
  display: grid;
  gap: 10px;
}

.mini-item {
  display: grid;
  gap: 3px;
  border-bottom: 1px solid #263b43;
  padding-bottom: 10px;
}

.mini-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.mini-item a {
  font-weight: 850;
  text-decoration: none;
}

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

.compact-form {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.compact-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.compact-form input,
.compact-form textarea,
.compact-form select,
.submit-dialog select {
  width: 100%;
  border: 1px solid var(--field-border);
  background: var(--field);
  color: var(--ink);
  border-radius: 6px;
  padding: 9px 10px;
  outline: none;
}

.suggestions {
  display: grid;
  gap: 8px;
}

.suggestion-option {
  border: 1px solid var(--field-border);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  padding: 10px;
  font-size: 13px;
}

.newsletter-draft {
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--field-border);
  border-radius: 6px;
  background: var(--field);
  color: #d7d1c5;
  padding: 10px;
  font-size: 12px;
}

body.density-compact .story {
  padding: 12px 0;
}

body.density-compact .story h2 {
  font-size: clamp(18px, 1.8vw, 24px);
}

body.density-roomy .story {
  padding: 24px 0;
}

body.hide-scores .score {
  display: none;
}

body.hide-scores .story {
  grid-template-columns: minmax(0, 1fr) auto;
}

body.hide-comments .comments {
  display: none;
}

.submit-dialog {
  width: min(640px, calc(100vw - 24px));
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 0;
}

.submit-dialog::backdrop {
  background: rgba(0, 0, 0, 0.64);
}

.submit-dialog form {
  padding: 20px;
  display: grid;
  gap: 14px;
}

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

.dialog-head h2 {
  margin: 0;
  font-size: 24px;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--field-border);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
}

.submit-dialog label,
.stack-form label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  font-weight: 750;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.checkbox-row {
  display: inline-flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 650 !important;
}

.checkbox-row input {
  width: auto;
}

.form-status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
}

.single-pane {
  width: min(820px, calc(100vw - 36px));
  margin: 34px auto 64px;
}

.submit-page {
  border-top: 3px solid var(--ink);
  padding-top: 22px;
}

.stack-form {
  display: grid;
  gap: 16px;
}

@media (max-width: 920px) {
  .topbar {
    grid-template-columns: 1fr auto;
    gap: 12px;
  }

  .nav,
  .search,
  .account {
    grid-column: 1 / -1;
  }

  .nav {
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar {
    padding-inline: 14px;
  }

  .button {
    padding-inline: 10px;
  }

  .stream-head {
    display: grid;
  }

  .stream-meta {
    white-space: normal;
  }

  .story {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .comments {
    grid-column: 2;
    justify-self: start;
  }

  .score {
    min-height: 42px;
  }
}
