/* v2ex-inspired: light, narrow centered column, text-first, minimal chrome. */
:root {
  --bg: #f5f5f5;
  --card: #ffffff;
  --border: #e2e2e2;
  --ink: #333333;
  --muted: #999999;
  --link: #5a6a85;
  --accent: #3c3b6e;        /* Old Glory blue */
  --accent-red: #b22234;    /* Old Glory red */
  --accent-ink: #ffffff;
  --pill: #eef0f4;
  --max: 960px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--link); text-decoration: none; cursor: pointer; }
a:hover { color: var(--accent); }

.muted { color: var(--muted); }
.center { text-align: center; padding: 40px 0; }
.hidden { display: none !important; }

/* Top bar */
#topbar { background: var(--card); border-top: 3px solid var(--accent-red); border-bottom: 1px solid var(--border); }
#topbar .bar {
  max-width: var(--max); margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
#topbar .brand { display: flex; align-items: center; gap: 10px; }
.brand-seal { width: 32px; height: 36px; flex: none; }
.brand-words { display: flex; align-items: center; gap: 9px; }
.brand-name { font-family: Georgia, "Songti SC", "STSong", serif; font-size: 26px; font-weight: 700; color: var(--accent); line-height: 1; }
.brand-sub { font-size: 13px; color: var(--ink); letter-spacing: 1px; padding-left: 9px; border-left: 1px solid var(--border); }
a.brand:hover .brand-name { color: var(--accent-red); }
#topbar .auth { display: flex; align-items: center; gap: 10px; font-size: 13px; }
#topbar .me { color: var(--ink); font-weight: 600; }

/* Main column */
#app { max-width: var(--max); margin: 18px auto; padding: 0 16px; }

/* ── Two-column layout (v2ex-style) ──────────────────── */
.layout { display: flex; align-items: flex-start; gap: 20px; }
.content { flex: 1; min-width: 0; }
.sidebar { width: 240px; flex: none; display: flex; flex-direction: column; gap: 16px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; }
.side-cta { padding: 14px; }
.btn.block { display: block; width: 100%; text-align: center; }
.side-nodes { padding: 14px; }
.side-title { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.nodegrid { display: flex; flex-wrap: wrap; gap: 7px; }
.nodelink {
  display: inline-block; background: var(--pill); color: var(--link);
  font-size: 13px; padding: 4px 10px; border-radius: 4px; cursor: pointer;
}
.nodelink:hover { background: #e3e7ee; color: var(--accent); }
.nodelink.active { background: var(--accent); color: var(--accent-ink); }

/* Node tab strip above the topic list */
.tabs-strip {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; margin-bottom: 14px;
  display: flex; flex-wrap: wrap; gap: 4px;
}
.tabs-strip .tab {
  color: var(--link); font-size: 13px; padding: 5px 11px; border-radius: 5px; cursor: pointer;
}
.tabs-strip .tab:hover { background: var(--pill); }
.tabs-strip .tab.active { background: var(--accent); color: var(--accent-ink); }

/* Buttons */
.btn {
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  border-radius: 5px; padding: 6px 12px; font-size: 13px; cursor: pointer;
}
.btn:hover { opacity: .9; }
.btn.ghost { background: none; color: var(--accent); }
.link { border: 0; background: none; color: var(--link); cursor: pointer; font-size: 13px; padding: 0; }
.link:hover { color: var(--accent); }

input, textarea, select {
  width: 100%; font: inherit; color: var(--ink);
  border: 1px solid var(--border); border-radius: 5px; padding: 8px 10px; background: #fff;
}
textarea { resize: vertical; }

/* Node pill */
.node {
  display: inline-block; background: var(--pill); color: #777;
  font-size: 12px; padding: 1px 7px; border-radius: 3px;
}

/* Footer */
.site-foot {
  max-width: var(--max); margin: 24px auto; padding: 0 16px 40px;
  color: var(--muted); font-size: 12px; text-align: center;
}

/* Overlay / modal */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px;
  z-index: 50;
}
.modal {
  background: var(--card); border-radius: 8px; padding: 22px;
  width: 100%; max-width: 420px; box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.modal h2 { margin: 0 0 4px; font-size: 17px; }
.modal p.sub { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.modal .field { margin-bottom: 12px; }
.modal .field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.modal .errline { color: #c0392b; font-size: 13px; min-height: 18px; margin: 4px 0 0; }
.modal .wide-max { max-width: 560px; }

/* ── Mobile (≤640px) ─────────────────────────────────── */
@media (max-width: 800px) {
  /* Sidebar drops below the content; node tab strip scrolls horizontally. */
  .layout { flex-direction: column; }
  .sidebar { width: 100%; order: 2; }
  .tabs-strip {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs-strip::-webkit-scrollbar { display: none; }
  .tabs-strip .tab { white-space: nowrap; }
}

@media (max-width: 640px) {
  #topbar .bar { gap: 8px 10px; padding: 10px 12px; }
  #topbar .brand { font-size: 16px; }

  #app { margin: 14px auto; padding: 0 12px; }

  /* Bigger tap targets; 16px inputs stop iOS from zooming on focus. */
  input, textarea, select { font-size: 16px; padding: 10px 12px; }
  .btn { padding: 8px 14px; }

  .overlay { padding: 24px 12px; align-items: stretch; }
  .modal { max-width: 100%; }

  .listhead h1 { font-size: 17px; }
  .post.op .topic-title { font-size: 18px; }
  .site-foot { padding: 0 12px 32px; }
}
