:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6b6b70;
  --border: #e2e2e0;
  --accent: #6d1a36;
  --accent-soft: #f4e8ec;
  --danger: #b42318;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Header */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; padding: 0.9rem 1.5rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.site-header h1 { margin: 0; font-size: 1.25rem; }
.header-controls { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.admin-link { color: var(--accent); font-weight: 600; text-decoration: none; }
.who { color: var(--muted); font-size: 0.9rem; }

main { padding: 1.25rem 1.5rem; max-width: 1400px; margin: 0 auto; }

/* Controls */
select, input, textarea, button { font: inherit; }
select, input, textarea {
  padding: 0.5rem 0.6rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); width: 100%;
}
.header-controls select { width: auto; min-width: 14rem; }
textarea { resize: vertical; }
button {
  padding: 0.5rem 0.95rem; border: 1px solid var(--accent); border-radius: 8px;
  background: var(--accent); color: #fff; cursor: pointer; font-weight: 600;
}
button:disabled { opacity: 0.6; cursor: progress; }
button.secondary { background: var(--surface); color: var(--accent); }
button.danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
button.small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }

label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.75rem; }
label > input, label > textarea, label > select { margin-top: 0.25rem; }

/* Viewer */
.description { color: var(--muted); margin: 0 0 0.5rem; }
.status { min-height: 1.25rem; margin: 0 0 0.75rem; color: var(--muted); font-size: 0.9rem; }
.status.error, .msg.error { color: var(--danger); }

.layout { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.layout:has(.detail:not([hidden])) { grid-template-columns: 1fr 340px; }
@media (max-width: 900px) {
  .layout:has(.detail:not([hidden])) { grid-template-columns: 1fr; }
}

.timeline {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}

.detail {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.2rem; align-self: start;
}
.detail h2 { margin: 0 2rem 0.35rem 0; font-size: 1.15rem; }
.detail .meta { color: var(--muted); margin: 0 0 0.5rem; font-size: 0.9rem; }
.detail .tag {
  display: inline-block; margin: 0 0 0.75rem; padding: 0.15rem 0.55rem;
  background: var(--accent-soft); color: var(--accent); border-radius: 999px; font-size: 0.8rem;
}
.detail img { width: 100%; border-radius: 8px; margin-bottom: 0.75rem; }
.detail .body { line-height: 1.5; white-space: pre-wrap; }
.detail a { color: var(--accent); font-weight: 600; }
.detail .close {
  position: absolute; top: 0.6rem; right: 0.6rem; background: none; border: none;
  color: var(--muted); font-size: 1.4rem; line-height: 1; padding: 0.2rem 0.45rem;
}

/* vis-timeline theming (scoped under .timeline so it wins over the library's injected CSS) */
.timeline .vis-timeline { border: none; font-family: inherit; }
.timeline .vis-item {
  border-color: var(--accent); background-color: var(--accent-soft); color: var(--text);
  border-radius: 6px; font-size: 0.85rem; cursor: pointer;
}
.timeline .vis-item.vis-selected { background-color: var(--accent); color: #fff; border-color: var(--accent); }
.timeline .vis-item.vis-dot,
.timeline .vis-item.vis-line { border-color: var(--accent); background-color: var(--accent); }
/* Short ranges (e.g. a 6-day mission on a multi-year view) still show their label. */
.timeline .vis-item.vis-range { border-width: 2px; }
.timeline .vis-item.vis-range .vis-item-overflow { overflow: visible; }
.timeline .vis-item.vis-range.vis-selected .vis-item-content { color: var(--accent); }
.timeline .vis-labelset .vis-label { color: var(--text); font-weight: 600; font-size: 0.85rem; }

/* Admin */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; margin-bottom: 1rem;
}
.card h2 { margin: 0 0 0.9rem; font-size: 1.05rem; }
.card.narrow { max-width: 420px; margin: 2rem auto; }
.admin-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 1rem; }
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.actions { display: flex; gap: 0.5rem; }
.hint { color: var(--muted); font-size: 0.8rem; margin: 0 0 0.75rem; }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; margin: 0.25rem 0 0.75rem; }
.msg { min-height: 1.25rem; font-size: 0.9rem; }
.count { color: var(--muted); font-weight: 400; }

.table-wrap { overflow-x: auto; }
.events-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.events-table th, .events-table td {
  text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border);
}
.events-table th { color: var(--muted); font-weight: 600; }
.events-table .row-actions { white-space: nowrap; text-align: right; }
.events-table .row-actions button + button { margin-left: 0.35rem; }
.events-table .empty { color: var(--muted); text-align: center; padding: 1.5rem; }
