:root {
  color-scheme: dark;
  --bg: #090b0e;
  --bg-surface: #11141a;
  --bg-card: #151922;
  --bg-input: #12151e;
  --border: #222735;
  --border-focus: #3b82f6;
  --border-subtle: #1a1f2c;

  --text-main: #f3f5f8;
  --text-muted: #8d95a5;
  --text-faint: #565e6e;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #60a5fa;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --accent-line: rgba(37, 99, 235, 0.25);
  --on-accent: #ffffff;

  --accent-bubble: rgba(37, 99, 235, 0.18);
  --panel-glass: rgb(17 20 26 / 0.78);

  --moon-glow: rgba(118, 157, 216, 0.2);
  --shadow: #0006;

  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --success-text: #34d399;
  --error-text: #f87171;
  --warning-text: #fbbf24;
  --success-bg: rgba(16, 185, 129, 0.12);
  --error-bg: rgba(239, 68, 68, 0.12);
  --warning-bg: rgba(245, 158, 11, 0.12);

  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 15px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg);
  color: var(--text-main);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.moon {
  position: fixed;
  top: clamp(96px, 14vh, 150px);
  left: calc(50% + 250px);
  width: clamp(300px, 38vw, 560px);
  aspect-ratio: 1;
  border-radius: 50%;
  opacity: 0.5;
  overflow: hidden;
  background: var(--bg) url("/moon-nasa.jpg") center / 115% 115% no-repeat;
  box-shadow: 0 0 70px var(--moon-glow);
  pointer-events: none;
  z-index: 0;
}

.site-main {
  flex: 1;
  min-height: 100dvh;
  width: 100%;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
[hidden] { display: none !important; }

textarea, select, input:not([type=checkbox]) { width: 100%; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-main); padding: 10px 12px; font: inherit; resize: vertical; }
button:disabled, textarea:disabled { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 3px; }

.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: var(--on-accent);
  text-decoration: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 22px;
  font-size: 14.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.05s ease;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-quiet { border: 1px solid var(--border); border-radius: var(--radius-sm); background: transparent; color: var(--text-muted); padding: 9px 12px; font: 14px var(--font); cursor: pointer; }
.btn-quiet:hover { color: var(--text-main); border-color: var(--text-muted); }

.plain-message { white-space:pre-wrap; overflow-wrap:anywhere; font-size:14px; line-height:1.6; }
.markdown { white-space:normal; overflow-wrap:anywhere; font-size:14px; line-height:1.6; }
.markdown p { margin:6px 0; white-space:pre-wrap; }
.markdown ul,.markdown ol { padding-left:24px; margin:8px 0; }
.markdown pre { max-width:100%; white-space:pre; overflow:auto; background:var(--bg-input); padding:12px; border:1px solid var(--border); border-radius:6px; }
.markdown code { font-family:ui-monospace,monospace; font-size:.9em; }
.markdown strong { color:var(--text-main); font-size:inherit; }
.markdown a { color:var(--accent-light); text-decoration:underline; }
.markdown h3,.markdown h4,.markdown h5 { font-size:1em; margin:12px 0 6px; }

/* Error page */
.error-hero {
  padding: 24px 0;
}

.badge {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent-light);
  border: 1px solid var(--accent-line);
  font-size: 12.5px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 6px;
  margin-bottom: 20px;
  letter-spacing: 0.02em;
}

.badge-subtle {
  background: var(--bg-surface);
  color: var(--text-muted);
  border-color: var(--border);
}

.hero-title {
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--text-main);
  margin-bottom: 20px;
}

.hero-subtitle {
  font-size: 18px;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 640px;
  margin-bottom: 32px;
}

/* Stats section */
#stats-section {
  margin-top: 40px;
}

#stats-section h2 {
  font-size: 24px;
  margin-bottom: 20px;
  color: var(--text-main);
}

#stats-section h3 {
  font-size: 16px;
  margin-top: 24px;
  margin-bottom: 16px;
  color: var(--text-main);
}

.stats-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--accent-light);
  border-bottom-color: var(--accent-light);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 13px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.stats-table thead {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.stats-table th {
  padding: 12px;
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  border-right: 1px solid var(--border);
}

.stats-table th:last-child {
  border-right: none;
}

.stats-table td {
  padding: 12px;
  border-right: 1px solid var(--border);
  color: var(--text-main);
}

.stats-table td:last-child {
  border-right: none;
}

.stats-table tbody tr {
  border-bottom: 1px solid var(--border);
}

.stats-table tbody tr:hover {
  background: rgba(37, 99, 235, 0.05);
}

.stats-table tbody tr:last-child {
  border-bottom: none;
}

.charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  position: relative;
  height: 300px;
}

.chart-container canvas {
  max-width: 100%;
  max-height: 100%;
}

canvas {
  margin-bottom: 0;
  max-width: 100%;
}

@media (max-width: 600px) {
  .moon {
    top: 104px;
    left: 46%;
    width: 340px;
  }

  .site-main { padding: 8px; }

  .stats-table {
    font-size: 11px;
  }

  .stats-table th,
  .stats-table td {
    padding: 6px;
  }

  .charts-row {
    grid-template-columns: 1fr;
  }

  .chart-container {
    height: 250px;
  }
}
