* { box-sizing: border-box; }
:root {
  --sidebar-width: 240px;
  --text: #1a1a1a;
  --text-muted: #888888;
  --bg: #ffffff;
  --border: #e5e5e5;
  --radius: 6px;
}
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(180deg, #f7f7f9 0%, #ebedf1 60%, #e1e3e8 100%);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.6);
  mix-blend-mode: lighten;
  pointer-events: none;
  z-index: -2;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: 0;
}

.sidebar-toggle {
  position: fixed;
  top: 0.9rem;
  left: 0.9rem;
  width: 26px;
  height: 26px;
  background: transparent;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 400;
  color: var(--text-muted);
  z-index: 120;
  transition: left 0.2s ease, color 0.15s ease, opacity 0.15s ease;
}
.sidebar-toggle.scroll-hide {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-10px);
}
.sidebar-toggle.scroll-hide { opacity: 0; pointer-events: none; }
.sidebar-toggle:hover { color: var(--text); opacity: 1; }
body.sidebar-hidden .sidebar-toggle { left: 0.9rem; }
body:not(.sidebar-hidden) .sidebar-toggle { left: calc(var(--sidebar-width) + 0.9rem); }

.settings-fab {
  position: fixed;
  left: 0.9rem;
  bottom: 0.9rem;
  width: 26px;
  height: 26px;
  background: transparent;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 400;
  color: var(--text-muted);
  z-index: 120;
}
.settings-fab.has-updates::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  background: #e53935;
  border-radius: 50%;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}
  transition: color 0.15s ease, opacity 0.15s ease;
}
.settings-fab:hover { color: var(--text); opacity: 1; }

.zoom-controls {
  position: fixed !important;
  right: 0.9rem !important;
  bottom: 0.9rem !important;
  display: flex !important;
  flex-direction: column;
  gap: 0.3rem;
  z-index: 120;
}
.zoom-controls button {
  width: 26px;
  height: 26px;
  background: transparent;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 400;
  color: var(--text-muted);
  transition: color 0.15s ease, opacity 0.15s ease;
}
.zoom-controls button:hover { color: var(--text); opacity: 1; }

.settings-modal {
  position: fixed;
  left: 0.9rem;
  bottom: 2.9rem;
  min-width: 170px;
  max-width: 200px;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  z-index: 130;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 0.1s ease, transform 0.1s ease;
}
.settings-modal.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.settings-modal-title {
  font-size: 0.72rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}
.settings-modal-note {
  font-size: 0.66rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}
.settings-theme-options {
  display: grid;
  gap: 0.1rem;
}
.settings-theme-btn {
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--text);
  font-size: 0.68rem;
  text-align: left;
  padding: 0.18rem 0.28rem 0.18rem 0.85rem;
  cursor: pointer;
  outline: none;
  box-shadow: none;
  appearance: none;
  position: relative;
  padding-left: 1rem;
}
.settings-theme-btn:hover {
  border: 0;
  background: transparent;
  color: var(--text);
  outline: none;
  box-shadow: none;
}
.settings-theme-btn:focus,
.settings-theme-btn:focus-visible,
.settings-theme-btn:active {
  outline: none;
  box-shadow: none;
  border: 0;
}
.settings-theme-btn.active {
  background: transparent;
  font-weight: 500;
}
.settings-theme-btn.active::before {
  content: "";
  position: absolute;
  left: 0.3rem;
  top: 50%;
  width: 0.2rem;
  height: 0.2rem;
  border-radius: 50%;
  background: currentColor;
  transform: translateY(-50%);
  opacity: 0.45;
}
.settings-release {
  margin-top: 0.28rem;
  padding-top: 0.28rem;
  border-top: 1px solid var(--border);
}
.settings-release-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.64rem;
  color: var(--text-muted);
  line-height: 1.3;
}
.settings-release-row + .settings-release-row {
  margin-top: 0.1rem;
}
.settings-release-row strong {
  color: var(--text);
  font-weight: 500;
}

.sidebar {
  width: var(--sidebar-width);
  background: rgba(255, 255, 255, 0.9);
  border-right: 1px solid var(--border);
  padding: 3.5rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 110;
  transition: transform 0.2s ease;
}
body.sidebar-hidden .sidebar { transform: translateX(-100%); }

.sidebar-logo { font-size: 1rem; font-weight: 600; margin-bottom: 0.15rem; }
.sidebar-title { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 0.5rem; margin-top: 1.25rem; }
.sidebar-nav { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.sidebar-nav li { margin-bottom: 0.1rem; }
.sidebar-nav a { color: var(--text-muted); text-decoration: none; font-size: 0.8rem; display: block; padding: 0.35rem 0.5rem; border-radius: 4px; transition: 0.15s; }
.sidebar-nav a:hover { color: var(--text); background: #fafafa; }

.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 3rem 2rem;
  transition: margin 0.2s ease;
  max-width: 560px;
  z-index: 100;
  position: relative;
}
body.sidebar-hidden .main { margin: 0 auto; }
.main.centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: 0 auto;
  max-width: 100%;
}

.loader { width: 20px; height: 20px; border: 1.5px solid var(--border); border-top-color: var(--text); border-radius: 50%; animation: spin 0.6s linear infinite; margin-bottom: 1.25rem; }
@keyframes spin { to { transform: rotate(360deg); } }
.loaded .loader { opacity: 0; pointer-events: none; }
img { margin-bottom: 1.25rem; max-width: 100%; height: auto; border-radius: var(--radius); }

h1 {
  font-size: 2rem;
  font-weight: 600;
  margin: 0 0 0.3rem;
  letter-spacing: -0.02em;
  color: #777;
}
h1.page-title { font-size: 1.5rem; font-weight: 600; margin-bottom: 0.3rem; }
a {
  color: inherit;
  text-decoration: none;
  display: inline-block;
  transform: translateY(0) scale(1);
  transition: color 0.15s ease, transform 0.12s ease, opacity 0.12s ease;
}
a:hover { color: #444; }
a:active {
  transform: translateY(1px) scale(0.98);
  opacity: 0.9;
}

.sidebar-nav a,
.home-links a,
.breadcrumb a {
  opacity: 0;
  animation: link-in 0.28s ease forwards;
}

.sidebar-nav li:nth-child(1) a { animation-delay: 0.03s; }
.sidebar-nav li:nth-child(2) a { animation-delay: 0.06s; }
.sidebar-nav li:nth-child(3) a { animation-delay: 0.09s; }
.sidebar-nav li:nth-child(4) a { animation-delay: 0.12s; }
.sidebar-nav li:nth-child(5) a { animation-delay: 0.15s; }
.home-links a:nth-child(1),
.breadcrumb a:nth-child(1) { animation-delay: 0.05s; }
.home-links a:nth-child(2),
.breadcrumb a:nth-child(2) { animation-delay: 0.09s; }
.home-links a:nth-child(3),
.breadcrumb a:nth-child(3) { animation-delay: 0.13s; }

@keyframes link-in {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.995);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.home-links {
  display: flex;
  gap: 0.65rem;
  margin-top: 0.35rem;
  font-size: 0.85rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
.home-links a { color: var(--text-muted); }
.home-links a:hover { color: var(--text); }
.home-links span { color: var(--border); }
.breadcrumb { display: flex; align-items: center; gap: 0.35rem; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 1.25rem; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb span { color: var(--border); }

.page-header { margin-bottom: 1.5rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.page-header .category { display: inline-block; font-size: 0.6rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: #444; margin-bottom: 0.4rem; }
.page-header .date { color: var(--text-muted); font-size: 0.8rem; }

.content {
  font-size: 0.9rem;
  line-height: 1.6;
  width: 100%;
  max-width: 560px;
  display: grid;
  gap: 0.75rem;
}
.content p { margin: 0 0 1rem; }
.content ul, .content ol { margin: 0 0 1rem; padding-left: 1rem; }
.content li { margin-bottom: 0.25rem; }
.content code { background: #fafafa; padding: 0.1rem 0.3rem; border-radius: 3px; font-family: "SF Mono", Monaco, monospace; font-size: 0.85em; }
.content pre { background: #fafafa; padding: 0.75rem; border-radius: 4px; overflow-x: auto; margin: 0.5rem 0; }
.content pre code { background: transparent; padding: 0; }

.section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0;
  min-height: 120px;
}
.section h3 { margin: 0 0 0.35rem; font-size: 0.9rem; font-weight: 600; }
.section p { margin: 0; color: var(--text-muted); font-size: 0.85rem; }
.section ul { margin: 0.35rem 0 0; padding-left: 0.85rem; }
.section li { color: var(--text-muted); font-size: 0.8rem; }

.shortcuts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.4rem; margin-top: 0.6rem; }
.shortcut { display: flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.5rem; background: #fafafa; border-radius: 4px; font-size: 0.75rem; }
.shortcut kbd { background: var(--bg); border: 1px solid var(--border); border-radius: 3px; padding: 0.1rem 0.3rem; font-family: "SF Mono", Monaco, monospace; font-size: 0.65rem; min-width: 36px; text-align: center; }

@media (max-width: 768px) {
  .sidebar {
    display: flex !important;
    transform: translateX(-100%);
    z-index: 200;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  }
  body:not(.sidebar-hidden) .sidebar { transform: translateX(0); }
  .sidebar-toggle {
    display: flex !important;
    left: 0.6rem !important;
    top: 0.6rem !important;
  }
  body:not(.sidebar-hidden) .sidebar-toggle {
    left: calc(var(--sidebar-width) + 0.6rem) !important;
  }
  .settings-fab {
    left: 0.6rem !important;
    bottom: 0.6rem !important;
  }
  .settings-modal {
    left: 0.6rem !important;
    bottom: 2.55rem !important;
  }
  .main { margin: 0 auto !important; padding: 3.5rem 0.85rem 1.25rem; }
  h1 { font-size: 1.5rem; }
  h1.page-title { font-size: 1.25rem; }
  .content {
    max-width: 100%;
    gap: 0.55rem;
    font-size: 0.86rem;
  }
  .section {
    padding: 0.75rem;
    min-height: 96px;
  }
  .section h3 { font-size: 0.82rem; margin-bottom: 0.25rem; }
  .section p { font-size: 0.8rem; }
  .section ul, .section ol { margin-bottom: 0.65rem; }
  .section li { font-size: 0.76rem; }
  .shortcuts-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  a { transition: color 0.15s ease; }
  .sidebar-nav a,
  .home-links a,
  .breadcrumb a {
    opacity: 1;
    animation: none;
  }
  a:active {
    transform: none;
    opacity: 1;
  }
}

[data-theme="neutral"] {
  --text-muted: #555759;
  --text: #555759;
  --border: #d0d0d0;
  --bg: #e8e8e8;
}
[data-theme="neutral"] body {
  background: linear-gradient(180deg, #d8d8d8 0%, #c8c8c8 60%, #b8b8b8 100%) !important;
}
[data-theme="neutral"] .sidebar {
  background: rgba(230, 230, 230, 0.95) !important;
}
[data-theme="neutral"] .section {
  border-color: #d0d0d0 !important;
  background: rgba(240, 240, 240, 0.9) !important;
}
[data-theme="neutral"] h1,
[data-theme="neutral"] h1.page-title {
  color: #555759 !important;
}
[data-theme="neutral"] a:hover {
  color: #555759 !important;
}
[data-theme="neutral"] .sidebar-nav a:hover {
  background: #d8d8d8 !important;
}
[data-theme="neutral"] .shortcut {
  background: #d8d8d8 !important;
}
[data-theme="neutral"] .shortcut kbd {
  background: #e8e8e8 !important;
  border-color: #b0b0b0 !important;
}
[data-theme="neutral"] .content pre {
  background: #d8d8d8 !important;
}
[data-theme="neutral"] .content code {
  background: #d8d8d8 !important;
}
