:root {
  color-scheme: light dark;
  --bg: #0e1116;
  --card: #171b22;
  --text: #e6e8eb;
  --muted: #8a919c;
  --accent: #4f8cff;
  --border: #262c36;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

.topbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  font-size: 1rem;
}
.brand-logo { height: 24px; width: auto; display: block; }
.brand-suffix { color: var(--muted); font-weight: 600; font-size: 0.85rem; }

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 16px;
}
.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}
.topbar nav a:hover { color: var(--text); }

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

.generate-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.generate-bar button, .btn-like {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
}
.generate-bar button:hover, .btn-like:hover { border-color: var(--accent); color: var(--accent); }

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.toolbar-overview { justify-self: start; }
.toolbar-map { justify-self: center; }
.toolbar-lang { justify-self: end; }

.toggle-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.toggle-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.toggle-btn:not(.active):hover { color: var(--text); border-color: var(--text); }

.digest-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }

.badge {
  background: var(--accent);
  color: white;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.muted { color: var(--muted); font-size: 0.9rem; }

.digest {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
}
.digest a { color: var(--accent); }

.digest-intro { margin-bottom: 8px; }
.digest-intro p { margin: 0.4em 0; }

.theme {
  border-top: 1px solid var(--border);
  padding: 4px 0;
}
.theme:first-of-type { border-top: none; }

.theme summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 10px 4px;
  list-style: revert;
}
.theme summary::marker { color: var(--accent); }
.theme summary:hover { color: var(--accent); }

.theme-body { padding: 4px 4px 12px 4px; }
.theme-body p:first-child { margin-top: 0; }
.theme-body ul { margin: 0.4em 0; padding-left: 1.3em; }
.theme-body li { margin: 0.3em 0; }

a.src {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0 5px;
  margin-left: 4px;
  vertical-align: 1px;
}
a.src:hover { color: var(--accent); border-color: var(--accent); }

a.wpn {
  display: inline-block;
  font-size: 0.75rem;
  text-decoration: none;
  margin-left: 3px;
  opacity: 0.85;
}
a.wpn:hover { opacity: 1; }

.pin {
  display: none;
  font: inherit;
  font-size: 0.8rem;
  margin-left: 4px;
  vertical-align: 1px;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  opacity: 0.85;
}
.digest.map-on .pin { display: inline-block; }
.pin:hover { opacity: 1; transform: scale(1.15); }

.mini-map {
  height: 220px;
  margin: 8px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.overview-map {
  height: 380px;
  margin: 0 0 16px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.pin-flash { animation: pin-flash-anim 1.6s ease-out; border-radius: 4px; }
@keyframes pin-flash-anim {
  0% { background: rgba(79, 140, 255, 0.35); }
  100% { background: transparent; }
}

.back-to-map-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 50;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.back-to-map-btn:hover { border-color: var(--accent); color: var(--accent); }

.digest-disclaimer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.digest-disclaimer p { margin: 0; }

.digest-list { list-style: none; padding: 0; }
.digest-list li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.digest-list a { color: var(--text); text-decoration: none; display: flex; gap: 10px; align-items: center; }
.digest-list a:hover { color: var(--accent); }

.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px;
}

.login-alt {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}
.login-alt a { color: var(--accent); text-decoration: none; }
.login-alt a:hover { text-decoration: underline; }

.legacy-login {
  width: 100%;
  max-width: 320px;
  margin-top: 4px;
}
.legacy-login summary {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  cursor: pointer;
  list-style: none;
}
.legacy-login summary::-webkit-details-marker { display: none; }
.legacy-login summary:hover { color: var(--text); }
.legacy-login .login-card { margin-top: 10px; padding: 20px; }

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 320px;
  text-align: center;
}
.login-logo { display: block; height: 40px; width: auto; margin: 0 auto 8px; }
.login-card input, .login-card textarea {
  width: 100%;
  padding: 10px 12px;
  margin: 0 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
}
.login-card input:first-of-type { margin-top: 16px; }
.login-card button {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
}
.error { color: #ff6b6b; font-size: 0.9rem; }

.back-link {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  margin-bottom: 16px;
}
.back-link:hover { color: var(--accent); }

.notice {
  background: rgba(240, 173, 78, 0.12);
  border: 1px solid rgba(240, 173, 78, 0.4);
  color: #f0ad4e;
  font-size: 0.8rem;
  border-radius: 8px;
  padding: 8px 12px;
  margin: 0 0 14px;
  text-align: center;
}

.subscribe-card { text-align: left; max-width: 380px; }
.subscribe-standalone-card { margin: 12px auto 0; }
.subscribe-card .muted { text-align: center; }
.subscribe-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px 0;
  font-size: 0.9rem;
}
.subscribe-options label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  white-space: nowrap;
}
.subscribe-options input[type="checkbox"] { flex: none; width: 16px; height: 16px; margin: 0; }
.small { font-size: 0.75rem; margin-top: 16px; }

.section-heading { font-size: 1rem; margin: 28px 0 10px; }
.user-list { list-style: none; padding: 0; margin: 0; }
.user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.small-inline { font-size: 0.8rem; margin-top: 2px; }
.user-actions { display: flex; gap: 8px; flex: none; }
.user-actions button {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}
.approve-btn { color: #4caf50; border-color: #4caf50; }
.approve-btn:hover { background: rgba(76, 175, 80, 0.12); }
.reject-btn { color: #ff6b6b; border-color: #ff6b6b; }
.reject-btn:hover { background: rgba(255, 107, 107, 0.12); }

.about-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
}
.about-card a { color: var(--accent); }
.about-card .section-heading:first-of-type { margin-top: 8px; }
.channel-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 16px; }
.channel-list a {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.9rem;
  text-decoration: none;
}
.channel-list a:hover { border-color: var(--accent); }

.glossary-list { list-style: none; padding: 0; margin: 0 0 20px; }
.glossary-entry {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  border-radius: 6px;
  scroll-margin-top: 16px;
}
.glossary-entry:last-child { border-bottom: none; }
.glossary-entry-name { font-weight: 700; }
.glossary-entry-aliases { font-size: 0.8rem; margin-top: 2px; }
.glossary-entry-desc { margin: 6px 0; font-size: 0.9rem; line-height: 1.5; }
.glossary-entry-link { font-size: 0.85rem; text-decoration: none; }
.glossary-entry-link:hover { text-decoration: underline; }
.glossary-entry:target {
  background: rgba(79, 140, 255, 0.12);
  outline: 1px solid var(--accent);
  padding-left: 10px;
  padding-right: 10px;
}
