:root {
  --bg: #f6f7f8;
  --panel: #ffffff;
  --text: #1c1c1c;
  --muted: #6b6f73;
  --line: #e2e4e7;
  --link: #0b5cad;
  --accent: #e8590c;
  --up: #e8590c;
  --down: #5a75cc;
  --error-bg: #fdecea;
  --error: #a61b1b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111213;
    --panel: #1a1b1d;
    --text: #e4e6e8;
    --muted: #9a9fa5;
    --line: #2c2e31;
    --link: #7fb2ec;
    --accent: #ff7a33;
    --up: #ff7a33;
    --down: #8ea4ff;
    --error-bg: #3a1a1a;
    --error: #ff9b9b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 1.2rem 0 .5rem; }
p { margin: .4rem 0; }

/* header */
.top {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .6rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line);
}
.logo { font-weight: 800; font-size: 1.3rem; color: var(--accent); letter-spacing: -.02em; }
.top nav { display: flex; gap: .9rem; flex: 1; }
.top nav a { color: var(--text); }
.me { display: flex; gap: .8rem; align-items: center; }

main { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.columns { display: flex; gap: 1.5rem; align-items: flex-start; }
.feed { flex: 1; min-width: 0; }
.side { width: 300px; flex-shrink: 0; }
@media (max-width: 800px) {
  .columns { flex-direction: column-reverse; }
  .side { width: 100%; }
}
.narrow { max-width: 560px; margin: 0 auto; }
.narrow.wide { max-width: 760px; }

.box { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .9rem; margin-bottom: 1rem; }
.box h2 { margin-top: 0; }
.box .btn { display: block; text-align: center; margin-top: .5rem; }
.box form.inline, .box form.inline .btn { display: block; width: 100%; }

/* tabs */
.tabs { display: flex; align-items: baseline; gap: .9rem; flex-wrap: wrap; margin-bottom: .6rem; }
.tabs h1, .tabs h2 { margin: 0 .4rem 0 0; }
.tabs a { color: var(--muted); }
.tabs a.on { color: var(--accent); font-weight: 600; }
.tabs.sub { font-size: .9rem; }
.tabs .btn { margin-left: auto; }

/* posts */
.postrow, .post {
  display: flex; gap: .6rem; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: .6rem .7rem; margin-bottom: .5rem;
}
.rank { color: var(--muted); width: 1.8rem; text-align: right; padding-top: .9rem; font-size: .9rem; }
.entry { min-width: 0; flex: 1; }
.title { margin: 0; font-size: 1.05rem; font-weight: 600; overflow-wrap: anywhere; }
.post .title { font-size: 1.3rem; }
.title a { color: var(--text); }
.domain { color: var(--muted); font-size: .8rem; font-weight: 400; }
.meta { color: var(--muted); font-size: .85rem; }
.actions { font-size: .85rem; display: flex; gap: .8rem; align-items: flex-start; margin: .2rem 0; }
.actions a, .actions summary, button.link { color: var(--muted); font-weight: 600; }
.text { white-space: pre-wrap; overflow-wrap: anywhere; }
.post .text { margin: .7rem 0; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.crumb { margin: 0 0 .5rem; font-weight: 600; }
.gone { color: var(--muted); font-style: italic; }
.note { background: var(--panel); border: 1px dashed var(--line); padding: .5rem .7rem; border-radius: 6px; color: var(--muted); }
.empty { color: var(--muted); padding: 1rem 0; }
.pager { display: flex; gap: 1rem; margin: 1rem 0; }

/* votes */
.vote { display: flex; flex-direction: column; align-items: center; min-width: 2.2rem; }
.arrow {
  border: 0; background: none; cursor: pointer; padding: 0 .2rem;
  color: var(--muted); font-size: .85rem; line-height: 1.2;
}
.arrow:hover { color: var(--text); }
.score { font-weight: 700; font-size: .85rem; }
.vote.up .arrow.up, .vote.up .score { color: var(--up); }
.vote.down .arrow.down, .vote.down .score { color: var(--down); }

/* comments */
.comments { margin-top: 1rem; }
.comment { margin-top: .6rem; }
.comment.flat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; }
.chead { display: flex; align-items: center; gap: .3rem; }
.chead .vote { flex-direction: row; gap: .2rem; min-width: 0; }
.chead .meta { margin: 0; }
.comment > .text, .comment > .actions { margin-left: .5rem; }
.children { margin-left: .9rem; padding-left: .7rem; border-left: 2px solid var(--line); }
.replybox summary { cursor: pointer; list-style: none; }
.replybox summary::-webkit-details-marker { display: none; }
.replybox[open] summary { margin-bottom: .3rem; }
form.reply { display: flex; flex-direction: column; gap: .4rem; align-items: flex-start; }
form.reply.top { margin-bottom: 1rem; }
form.reply textarea { width: min(640px, 100%); }

/* subtheddit list */
.subrow {
  display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .7rem .9rem; margin-bottom: .5rem;
}
.subrow h2 { margin: 0; }
.subtitle { color: var(--muted); font-weight: 400; }
.sublist { list-style: none; padding: 0; margin: 0 0 .6rem; }
.sublist li { display: flex; justify-content: space-between; padding: .15rem 0; }

/* forms */
.form { display: flex; flex-direction: column; gap: .8rem; margin-top: 1rem; }
.form label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; }
.form .hint { margin-top: -.6rem; }
.hint { color: var(--muted); font-size: .85rem; font-weight: 400; }
label .hint { margin: 0; }
input, textarea {
  font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: .45rem .6rem; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; }
.prefixed { display: flex; align-items: center; gap: .3rem; font-weight: 400; }
.error { background: var(--error-bg); color: var(--error); padding: .5rem .7rem; border-radius: 6px; }

form.inline { display: inline; }
button { font: inherit; }
button.link { border: 0; background: none; padding: 0; cursor: pointer; font-size: inherit; }
button.link:hover { text-decoration: underline; }
.btn {
  display: inline-block; cursor: pointer; font-weight: 600; font-size: .9rem;
  padding: .4rem 1rem; border-radius: 999px;
  border: 1px solid var(--accent); background: transparent; color: var(--accent);
}
.btn:hover { text-decoration: none; filter: brightness(1.1); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.subscribed { border-color: var(--line); color: var(--muted); }
.top .me button.link { color: var(--muted); font-weight: 400; }
