:root {
  --pm-orange: #ff6c37;
  --pm-orange-dark: #e05323;
  --text: #212121;
  --text-muted: #6b6b6b;
  --border: #e6e6e6;
  --border-strong: #d1d1d1;
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --bg-sidebar: #f7f7f7;
  --topbar-bg: #ffffff;
  --link: #0265d2;
  --code-bg: #f4f4f4;
  --tag-bg: #fff4ef;
  --tag-fg: #c8451c;
  --error-bg: #fdf2ef;
  --error-border: #f0c9c1;
  --error-fg: #8a2f14;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  --radius: 6px;
  --sidebar-w: 260px;
  --topbar-h: 56px;
  --content-max: 820px;
}

:root[data-theme="dark"] {
  --text: #e6e6e6;
  --text-muted: #9a9a9a;
  --border: #2a2a2a;
  --border-strong: #3a3a3a;
  --bg: #131417;
  --bg-soft: #191a1e;
  --bg-sidebar: #17181c;
  --topbar-bg: #131417;
  --link: #6fb1ff;
  --code-bg: #1f2126;
  --tag-bg: rgba(255, 108, 55, 0.16);
  --tag-fg: #ffb18f;
  --error-bg: rgba(255, 92, 60, 0.1);
  --error-border: rgba(255, 92, 60, 0.35);
  --error-fg: #ffb1a0;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Topbar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
.brand-logo {
  display: block;
  height: 22px;
  width: auto;
}
.brand-logo-dark {
  display: none;
}
:root[data-theme="dark"] .brand-logo-light {
  display: none;
}
:root[data-theme="dark"] .brand-logo-dark {
  display: block;
}

.topbar-title {
  color: var(--text-muted);
  font-size: 14px;
  border-left: 1px solid var(--border);
  padding-left: 24px;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-link {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
}
.topbar-link:hover {
  color: var(--pm-orange);
  border-color: var(--pm-orange);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.icon-btn:hover {
  color: var(--pm-orange);
  border-color: var(--pm-orange);
}
.icon-btn:focus-visible {
  outline: 2px solid var(--pm-orange);
  outline-offset: 2px;
}
.icon-btn .icon-moon {
  display: none;
}
:root[data-theme="dark"] .icon-btn .icon-sun {
  display: none;
}
:root[data-theme="dark"] .icon-btn .icon-moon {
  display: block;
}

/* --- Layout --- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  max-width: 1200px;
  margin: 0 auto;
  min-height: calc(100vh - var(--topbar-h));
}

/* --- Sidebar --- */
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-sidebar);
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}

.sidebar-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
  position: sticky;
  top: 0;
  z-index: 1;
}

#version-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#version-search:focus {
  border-color: var(--pm-orange);
  box-shadow: 0 0 0 3px rgba(255, 108, 55, 0.15);
}

.version-list {
  padding: 8px 0 24px;
}

.version-item {
  display: flex;
  flex-direction: column;
  padding: 8px 16px;
  border-left: 3px solid transparent;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.1s;
}
.version-item:hover {
  background: rgba(255, 108, 55, 0.06);
}
.version-item.active {
  background: var(--bg);
  border-left-color: var(--pm-orange);
  font-weight: 600;
}
.version-item .v-num {
  font-size: 14px;
  color: var(--text);
}
.version-item .v-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.version-item.empty .v-num {
  color: var(--text-muted);
  font-weight: 400;
}
.version-item.empty .v-tag {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- Content --- */
.content {
  padding: 40px 48px 80px;
  max-width: calc(var(--content-max) + 96px);
}

.loading,
.empty-state {
  color: var(--text-muted);
  padding: 32px 0;
  font-size: 14px;
}

.disclaimer {
  max-width: var(--content-max);
  margin: 0 0 24px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-left: 3px solid var(--pm-orange);
  border-radius: var(--radius);
}
.disclaimer a {
  color: var(--link);
  text-decoration: none;
}
.disclaimer a:hover {
  text-decoration: underline;
}

.release {
  max-width: var(--content-max);
}

.release-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 24px;
}
.release-version {
  font-size: 12px;
  font-weight: 600;
  color: var(--tag-fg);
  background: var(--tag-bg);
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-block;
  letter-spacing: 0.3px;
}
.release-title {
  font-size: 32px;
  font-weight: 700;
  margin: 12px 0 4px;
  letter-spacing: -0.3px;
}
.release-date {
  color: var(--text-muted);
  font-size: 14px;
}

/* Markdown content */
.markdown h1,
.markdown h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 32px 0 12px;
  letter-spacing: -0.2px;
}
.markdown h1:first-child,
.markdown h2:first-child {
  margin-top: 0;
}
.markdown h3 {
  font-size: 17px;
  font-weight: 700;
  margin: 24px 0 10px;
  color: var(--text);
}
.markdown h4 {
  font-size: 15px;
  font-weight: 700;
  margin: 20px 0 8px;
  color: var(--text);
}
.markdown p {
  margin: 0 0 14px;
}
.markdown ul,
.markdown ol {
  margin: 0 0 14px;
  padding-left: 22px;
}
.markdown li {
  margin-bottom: 6px;
}
.markdown a {
  color: var(--link);
  text-decoration: none;
}
.markdown a:hover {
  text-decoration: underline;
}
.markdown strong {
  font-weight: 600;
}
.markdown code {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  background: var(--code-bg);
  padding: 2px 5px;
  border-radius: 4px;
}
.markdown pre {
  background: var(--code-bg);
  padding: 12px 14px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
}
.markdown pre code {
  background: transparent;
  padding: 0;
}
.markdown blockquote {
  border-left: 3px solid var(--pm-orange);
  padding: 4px 14px;
  color: var(--text-muted);
  margin: 0 0 14px;
  background: var(--bg-soft);
}
.markdown hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}
.markdown img {
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.error {
  border: 1px solid var(--error-border);
  background: var(--error-bg);
  color: var(--error-fg);
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
}

@media (max-width: 780px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    max-height: 320px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .content {
    padding: 24px 20px 60px;
  }
  .release-title {
    font-size: 26px;
  }
  .topbar-title {
    display: none;
  }
}
