/* ============================================================
   Hermes Design System · unified tokens
   Sovereign Station · dark (default) + light mode
   ============================================================ */
:root {
  --bg:          #0d1117;
  --panel:       #161b22;
  --panel-2:     #1b212b;
  --border:      #30363d;
  --border-soft: #21262d;
  --text:        #c9d1d9;
  --text-strong: #f0f6fc;
  --muted:       #8b949e;
  --accent:      #58a6ff;
  --accent-2:    #3fb950;
  --accent-3:    #bc8cff;
  --warn:        #d29922;
  --bad:         #f85149;
  --ok:          #3fb950;
  --glow:        rgba(88, 166, 255, 0.12);
  --shadow:      0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-sm:   0 2px 8px rgba(0, 0, 0, 0.16);
  --radius:      12px;
  --radius-sm:   8px;
  --radius-lg:   18px;
  --font-mono:   ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

html[data-theme="light"] {
  --bg:          #f6f8fa;
  --panel:       #ffffff;
  --panel-2:     #f3f4f6;
  --border:      #d0d7de;
  --border-soft: #e1e4e8;
  --text:        #24292f;
  --text-strong: #09090b;
  --muted:       #57606a;
  --accent:      #0969da;
  --accent-2:    #1a7f37;
  --accent-3:    #8250df;
  --warn:        #9a6700;
  --bad:         #cf222e;
  --ok:          #1a7f37;
  --glow:        rgba(9, 105, 218, 0.10);
  --shadow:      0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-sm:   0 2px 8px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background .2s, color .2s;
  -webkit-font-smoothing: antialiased;
}

/* ---- global floating switcher (app.js injects this) ---- */
.hm-bar {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 1000;
}
.hm-bar .group {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  display: flex;
  gap: 3px;
  box-shadow: var(--shadow);
}
.hm-lang, .hm-theme {
  background: transparent;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px; padding: 7px 12px;
  transition: background .2s, color .2s, transform .2s;
}
.hm-theme { width: 38px; height: 34px; padding: 0; }
.hm-theme svg, .hm-lang svg { width: 18px; height: 18px; display: block; }
.hm-lang:hover, .hm-theme:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.hm-lang.active { color: #fff; background: var(--accent); }
html[data-theme="light"] .hm-lang.active { color: #fff; }
.hm-theme:active { transform: rotate(20deg) scale(1.05); }

/* ---- shared container ---- */
.hm-wrap { width: 100%; max-width: 860px; margin: 0 auto; padding: 20px 16px 40px; }

/* ---- unified back navigation pill ---- */
.hm-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
  transition: all .18s cubic-bezier(.2,.7,.2,1);
  margin-bottom: 16px;
  cursor: pointer;
}
/* Absolute protection: strictly prohibit any duplicate arrow symbol */
.hm-back::before, .hm-back::after {
  content: none !important;
  display: none !important;
}
.hm-back:hover {
  color: var(--text-strong);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  transform: translateX(-3px);
  box-shadow: var(--shadow);
}
.hm-back svg {
  width: 14px;
  height: 14px;
  display: block;
  transition: transform .18s ease;
}
.hm-back:hover svg {
  transform: translateX(-2px);
}

/* ---- hero (root) ---- */
.hm-hero { text-align: center; margin: 18px 0 30px; }
.hm-hero .mark {
  width: 64px; height: 64px; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 18px; color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-3));
  box-shadow: var(--shadow);
}
.hm-hero .mark svg { width: 32px; height: 32px; }
.hm-hero h1 { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; color: var(--text-strong); }
.hm-hero .sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }

/* ---- group label ---- */
.hm-group { margin-bottom: 24px; }
.hm-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  margin-bottom: 12px;
}
.hm-group-head .dot { width: 7px; height: 7px; border-radius: 50%; }
.hm-group-head .dot-pub { background: var(--ok); }
.hm-group-head .dot-priv { background: var(--warn); }
.hm-group-head .line { flex: 1; height: 1px; background: var(--border-soft); }

/* ---- card grid ---- */
.hm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.hm-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform .18s cubic-bezier(.2,.7,.2,1), border-color .18s, box-shadow .18s;
  position: relative;
  overflow: hidden;
}
.hm-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.hm-card .ico {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent); flex: 0 0 auto;
}
.hm-card .ico svg { width: 20px; height: 20px; }
.hm-card .body { flex: 1; min-width: 0; }
.hm-card .t { font-weight: 700; font-size: 14px; color: var(--text-strong); }
.hm-card .d { font-size: 11.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hm-card .tag {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--border-soft); border-radius: 999px;
  padding: 3px 8px; display: inline-flex; align-items: center; gap: 4px;
}
.hm-card .tag svg { width: 10px; height: 10px; }
.hm-card .tag.priv { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.hm-card .tag.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }

/* ---- Markdown Reader Modal (OKF Doc Reader) ---- */
.md-modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center;
  z-index: 9999; padding: 16px;
}
.md-modal-backdrop.open { display: flex; }
.md-modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%; max-width: 820px; max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
  animation: mdModalIn .2s ease-out;
}
@keyframes mdModalIn { from { opacity: 0; transform: scale(.97) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.md-modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--border-soft); background: var(--panel-2);
  border-radius: 16px 16px 0 0;
}
.md-modal-title { font-size: 15px; font-weight: 700; color: var(--text-strong); display: flex; align-items: center; gap: 8px; }
.md-modal-path { font-size: 11px; font-family: var(--font-mono); color: var(--muted); margin-top: 2px; }
.md-modal-close {
  background: transparent; border: 0; color: var(--muted); cursor: pointer;
  padding: 6px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.md-modal-close:hover { color: var(--text-strong); background: var(--border-soft); }
.md-modal-close svg { width: 18px; height: 18px; }
.md-modal-body {
  padding: 22px 24px; overflow-y: auto; flex: 1;
  font-size: 13.5px; line-height: 1.7; color: var(--text);
}
.md-modal-body h1, .md-modal-body h2, .md-modal-body h3 {
  color: var(--text-strong); margin: 18px 0 8px; font-weight: 700;
}
.md-modal-body h1 { font-size: 19px; border-bottom: 1px solid var(--border-soft); padding-bottom: 6px; }
.md-modal-body h2 { font-size: 16px; }
.md-modal-body h3 { font-size: 14px; }
.md-modal-body p { margin-bottom: 12px; }
.md-modal-body ul, .md-modal-body ol { margin: 8px 0 12px 24px; }
.md-modal-body li { margin-bottom: 4px; }
.md-modal-body pre {
  background: var(--panel-2); border: 1px solid var(--border-soft);
  border-radius: 8px; padding: 12px 14px; overflow-x: auto;
  font-family: var(--font-mono); font-size: 12px; margin: 12px 0;
}
.md-modal-body code {
  font-family: var(--font-mono); font-size: 12px; background: var(--panel-2);
  padding: 2px 6px; border-radius: 4px; color: var(--accent);
}
.md-modal-body blockquote {
  border-left: 3px solid var(--accent); padding-left: 14px; margin: 12px 0;
  color: var(--muted); font-style: italic;
}

/* ---- subtle animations & helpers ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
