:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #647080;
  --line: #d9e0e7;
  --paper: #f6f7f4;
  --panel: #ffffff;
  --accent: #c7462b;
  --accent-ink: #ffffff;
  --mint: #1c8a6a;
  --blue: #3366a8;
  --gold: #b77614;
  --shadow: 0 16px 36px rgba(26, 34, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: max-content minmax(160px, 1fr) max-content max-content;
  gap: 16px;
  align-items: center;
  min-height: 64px;
  padding: 10px clamp(14px, 3vw, 32px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 0.8rem;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
}

.search input {
  width: 100%;
  min-width: 0;
  height: 40px;
  border: 0;
  outline: 0;
}

.primary,
.ghost,
.tab,
.nav-item,
.icon-button,
.comment-form button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.account {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.account-name {
  max-width: 130px;
  overflow: hidden;
  color: var(--muted);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary {
  min-height: 40px;
  padding: 0 16px;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
}

.wide {
  width: 100%;
}

.shell {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(0, 760px) minmax(220px, 300px);
  gap: 20px;
  max-width: 1360px;
  margin: 0 auto;
  padding: 20px clamp(14px, 3vw, 32px) 40px;
}

.rail,
.side {
  display: grid;
  gap: 16px;
  align-content: start;
  position: sticky;
  top: 84px;
}

.nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
  margin-bottom: 8px;
  padding: 0 12px;
  text-decoration: none;
  text-align: left;
  font-weight: 700;
}

.coin-link {
  color: var(--blue);
}

.nav-item.active,
.tab.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.pool-panel {
  display: grid;
  gap: 8px;
}

.pool-panel strong {
  font-size: 1.35rem;
}

.pool-panel code {
  display: block;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #f9faf8;
  color: var(--muted);
  font-size: 0.76rem;
}

.compact ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.feed {
  min-width: 0;
}

.feed-tools {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.tab {
  min-height: 36px;
  padding: 0 12px;
  font-weight: 800;
}

select {
  min-height: 36px;
  max-width: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
}

.post-list {
  display: grid;
  gap: 12px;
}

.post {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.vote-box {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 4px;
}

.vote {
  width: 34px;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9faf8;
  color: var(--muted);
  font-weight: 900;
}

.vote.active.up {
  color: var(--accent);
  border-color: var(--accent);
}

.vote.active.down {
  color: var(--blue);
  border-color: var(--blue);
}

.score {
  min-width: 3ch;
  text-align: center;
}

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

.meta,
.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.meta {
  color: var(--muted);
  font-size: 0.86rem;
}

.tag,
.bounty {
  border-radius: 999px;
  padding: 3px 8px;
  background: #edf3f1;
  color: var(--mint);
  font-weight: 800;
}

.bounty {
  background: #fff4dc;
  color: var(--gold);
}

.bounty.solved {
  background: #e9f5ef;
  color: var(--mint);
}

.title {
  margin: 8px 0 6px;
  overflow-wrap: anywhere;
  font-size: clamp(1.05rem, 2vw, 1.28rem);
  line-height: 1.25;
}

.excerpt {
  margin: 0 0 12px;
  color: #3c4652;
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.ghost {
  min-height: 34px;
  padding: 0 10px;
  color: var(--muted);
  font-weight: 700;
}

.comments {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.comment {
  border-left: 3px solid var(--line);
  padding: 6px 0 6px 10px;
  color: #364351;
}

.comment strong {
  display: block;
  color: var(--ink);
  font-size: 0.86rem;
}

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

.approve-reply {
  min-height: 28px;
  border: 1px solid var(--mint);
  border-radius: 8px;
  padding: 0 10px;
  background: #e9f5ef;
  color: var(--mint);
  font-size: 0.86rem;
  font-weight: 900;
}

.comment-media {
  display: block;
  width: min(100%, 520px);
  max-height: 420px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9faf8;
  object-fit: contain;
}

.comment-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 220px) max-content;
  gap: 8px;
  margin-top: 10px;
}

.comment-form input,
.modal input,
.modal textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: 0;
}

.comment-form button {
  padding: 0 14px;
  font-weight: 800;
}

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

.stats div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

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

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

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

.tag-cloud button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: #fff;
  color: var(--blue);
  font-weight: 800;
}

.modal {
  width: min(560px, calc(100vw - 24px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 30px 80px rgba(12, 18, 25, 0.24);
}

.modal::backdrop {
  background: rgba(23, 33, 43, 0.44);
}

.modal form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

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

.modal h2 {
  margin: 0;
}

.icon-button {
  width: 36px;
  aspect-ratio: 1;
  font-size: 1.4rem;
  line-height: 1;
}

.modal label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.form-message {
  margin: 0;
  border: 1px solid #f0c8b8;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff4ef;
  color: #8a2e1c;
  font-weight: 700;
}

.payment-copy {
  border-color: var(--line);
  background: #f9faf8;
  color: var(--ink);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 12px;
}

.check {
  display: flex !important;
  grid-template-columns: none;
  flex-direction: row;
  align-items: center;
}

.check input {
  width: auto;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px;
  background: #fff;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1040px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .rail,
  .side {
    position: static;
  }

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

  .nav-item {
    margin: 0;
    text-align: center;
  }
}

@media (max-width: 680px) {
  .topbar {
    grid-template-columns: 1fr max-content;
  }

  .brand span:last-child {
    display: none;
  }

  .search {
    grid-column: 1 / -1;
    order: 3;
  }

  .account {
    grid-column: 1 / -1;
    order: 4;
    justify-content: flex-end;
  }

  .rail nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .feed-tools,
  .comment-form,
  .form-grid {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  select {
    max-width: none;
  }

  .post {
    grid-template-columns: 38px minmax(0, 1fr);
    padding: 12px;
  }

  .vote {
    width: 30px;
  }
}
