:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1c2230;
  --muted: #6b7280;
  --accent: #2f6fed;
  --border: #e6e8ec;
}

* { box-sizing: border-box; }

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 600; color: var(--ink); text-decoration: none; }
.who { color: var(--muted); font-size: 13px; }
.who a, .brand:hover { color: var(--accent); }

main { max-width: 920px; margin: 0 auto; padding: 24px 20px 60px; }

h1 { font-size: 22px; margin: 8px 0 4px; }
h2 { font-size: 15px; margin: 0 0 12px; color: var(--muted); font-weight: 600; }

.subtitle { color: var(--muted); margin: 0 0 20px; }
.back { color: var(--accent); text-decoration: none; font-size: 13px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 20px;
}

.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.export-btn {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
.export-btn:hover { border-color: var(--accent); color: var(--accent); }

.chat-list { list-style: none; padding: 0; margin: 16px 0 0; }
.chat-list li { margin-bottom: 10px; }
.chat-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
}
.chat-list a:hover { border-color: var(--accent); }
.chat-title { font-weight: 500; }
.chat-count { color: var(--muted); font-size: 13px; }

.empty { color: var(--muted); }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: end;
  margin: 0 0 20px;
}
.controls form { display: flex; gap: 10px; align-items: end; margin: 0; }
.controls label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }

/* Force every interactive control to the same box so the select, the two date
   inputs, and the button align on one baseline regardless of native sizing. */
.controls select,
.controls input[type="date"],
.controls button {
  box-sizing: border-box;
  height: 38px;
  font-size: 14px;
  line-height: normal;
  border-radius: 8px;
  margin: 0;
}
.controls select,
.controls input[type="date"] {
  padding: 0 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
}
.controls button {
  padding: 0 18px;
  border: 0;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.controls button:hover { filter: brightness(0.95); }
.range-custom { border-left: 1px solid var(--border); padding-left: 16px; }

.heatmap-wrap { overflow-x: auto; }
table.heatmap { border-collapse: collapse; }
table.heatmap th, table.heatmap td { text-align: center; }
table.heatmap th.hh { font-weight: 400; font-size: 10px; color: var(--muted); width: 22px; padding: 0 0 4px; }
table.heatmap th.dow { font-weight: 500; font-size: 11px; color: var(--muted); padding-right: 8px; text-align: right; }
table.heatmap td.hcell {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 3px;
}
.heat-legend { color: var(--muted); font-size: 12px; margin-top: 12px; }

.reply-cols { display: flex; flex-wrap: wrap; gap: 32px; }
.reply-col { flex: 1; min-width: 220px; }
.reply-col h3 { font-size: 13px; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.replylist { list-style: none; padding: 0; margin: 0; counter-reset: r; }
.replylist li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.replylist li::before { counter-increment: r; content: counter(r) "."; color: var(--muted); width: 22px; flex: 0 0 22px; }
.replylist a { text-decoration: none; color: var(--ink); flex: 1; }
.replylist a:hover { color: var(--accent); }
.replylist .rc { color: var(--muted); font-variant-numeric: tabular-nums; }

.tagcloud { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; line-height: 1.7; }
.tag { white-space: nowrap; }
.tag:hover { color: var(--accent) !important; }
.muted { color: var(--muted); }

.login { max-width: 420px; margin: 60px auto; text-align: center; }
.login p { color: var(--muted); }
.login-widget { margin: 24px 0; }
.error { color: #c0392b; }
