:root {
  --reader-bg: #f6f8fb;
  --reader-panel: #ffffff;
  --reader-text: #172033;
  --reader-muted: #64748b;
  --reader-line: #d9e1ec;
  --reader-soft: #eef3f8;
  --reader-accent: #0f766e;
  --reader-accent-dark: #115e59;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--reader-bg);
  color: var(--reader-text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.reader-shell {
  width: min(1320px, 100%);
  margin: 0 auto;
}

.reader-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--reader-line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.reader-topbar .reader-shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 22px;
}

.reader-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.reader-brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 42px;
  background: var(--reader-accent);
  color: #fff;
  font-size: 18px;
}

.reader-brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
}

.reader-brand p {
  margin: 2px 0 0;
  color: var(--reader-muted);
  font-size: 12px;
  font-weight: 600;
}

.reader-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.reader-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 8px;
  font-weight: 700;
}

.reader-layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 22px;
  padding: 22px;
}

.reader-sidebar {
  position: sticky;
  top: 86px;
  align-self: start;
  max-height: calc(100vh - 108px);
  overflow: auto;
  border: 1px solid var(--reader-line);
  border-radius: 8px;
  background: var(--reader-panel);
  padding: 14px;
}

.reader-search {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid var(--reader-line);
  border-radius: 8px;
  color: var(--reader-muted);
  background: #fff;
}

.reader-search:focus-within {
  border-color: var(--reader-accent);
  color: var(--reader-accent);
}

.reader-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--reader-text);
  font-size: 14px;
}

.reader-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0 16px;
}

.reader-stats div {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: var(--reader-soft);
}

.reader-stats strong,
.reader-stats span {
  display: block;
}

.reader-stats strong {
  font-size: 20px;
  line-height: 1.1;
}

.reader-stats span {
  margin-top: 2px;
  color: var(--reader-muted);
  font-size: 11px;
  font-weight: 700;
}

.toc-title {
  margin-bottom: 8px;
  color: var(--reader-muted);
  font-size: 12px;
  font-weight: 800;
}

.toc-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toc-list a {
  display: block;
  padding: 7px 8px;
  border-radius: 7px;
  color: var(--reader-text);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.toc-list a:hover {
  background: var(--reader-soft);
  color: var(--reader-accent-dark);
}

.reader-content {
  min-width: 0;
}

.reader-state,
.markdown-body,
.raw-body {
  min-height: 520px;
  border: 1px solid var(--reader-line);
  border-radius: 8px;
  background: var(--reader-panel);
}

.reader-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--reader-muted);
  font-weight: 700;
}

.markdown-body {
  padding: 34px;
}

.markdown-body h1 {
  margin: 0 0 14px;
  font-size: 32px;
  font-weight: 850;
}

.markdown-body h2 {
  margin: 34px 0 16px;
  padding-top: 8px;
  border-top: 1px solid var(--reader-line);
  color: var(--reader-accent-dark);
  font-size: 22px;
  font-weight: 850;
}

.markdown-body blockquote {
  margin: 0 0 22px;
  padding: 13px 15px;
  border-left: 4px solid var(--reader-accent);
  border-radius: 0 8px 8px 0;
  background: #ecfdf5;
  color: #134e4a;
  font-weight: 700;
}

.markdown-body ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.markdown-body li {
  margin: 0 0 12px;
  padding: 14px 15px;
  border: 1px solid var(--reader-line);
  border-radius: 8px;
  background: #fff;
  line-height: 1.7;
}

.markdown-body li strong {
  color: #0f172a;
}

.markdown-body a {
  color: var(--reader-accent-dark);
  font-weight: 700;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.markdown-body a:hover {
  text-decoration: underline;
}

.markdown-meta {
  display: block;
  margin-top: 6px;
  color: var(--reader-muted);
  font-size: 13px;
  font-weight: 700;
}

.markdown-paragraph {
  margin: 0 0 12px;
  line-height: 1.8;
}

.reader-highlight {
  padding: 0 2px;
  border-radius: 4px;
  background: #fde68a;
  color: #713f12;
}

.raw-body {
  margin: 0;
  padding: 24px;
  color: #e5edf7;
  background: #111827;
  font-family: Consolas, Monaco, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow: auto;
}

@media (max-width: 920px) {
  .reader-topbar .reader-shell {
    align-items: flex-start;
    flex-direction: column;
  }

  .reader-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .reader-layout {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .reader-sidebar {
    position: static;
    max-height: none;
  }

  .markdown-body {
    padding: 22px;
  }
}

@media (max-width: 560px) {
  .reader-topbar .reader-shell {
    padding: 12px 14px;
  }

  .reader-brand h1 {
    font-size: 16px;
  }

  .reader-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .reader-stats {
    grid-template-columns: 1fr;
  }

  .markdown-body {
    padding: 16px;
  }

  .markdown-body h1 {
    font-size: 25px;
  }

  .markdown-body h2 {
    font-size: 19px;
  }
}
