:root {
  color-scheme: light;
  --ink: #15171c;
  --muted: #68707d;
  --soft: #f5f7fa;
  --line: #dfe4eb;
  --accent: #2167d8;
  --accent-dark: #174ea6;
  --paper: #ffffff;
  --sidebar: #f8fafc;
  --shadow: 0 18px 48px rgba(31, 43, 61, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--soft);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.project-pet {
  position: fixed;
  right: 14px;
  bottom: 8px;
  z-index: 8;
  width: clamp(92px, 8vw, 124px);
  aspect-ratio: 1;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.96);
  border-radius: 50%;
  background: #eef1f5;
  box-shadow: 0 10px 24px rgba(31, 43, 61, 0.22);
  pointer-events: none;
  animation: pet-float 3.2s ease-in-out infinite;
}

.project-pet img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 38%;
}

@keyframes pet-float {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg);
  }
  50% {
    transform: translateY(-8px) rotate(1deg);
  }
}

.app-shell {
  display: grid;
  height: 100vh;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  overflow: hidden;
}

.sidebar {
  display: flex;
  height: 100vh;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  overflow: hidden;
}

.sidebar-header,
.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.sidebar-header {
  padding: 24px 22px 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.1;
}

.icon-button,
.tool-button {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  font-size: 20px;
}

.search-box {
  display: grid;
  gap: 8px;
  padding: 0 22px 14px;
}

.search-box span,
.meta-line {
  color: var(--muted);
  font-size: 13px;
}

.search-box input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  outline: none;
  padding: 0 12px;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(33, 103, 216, 0.12);
}

.meta-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 22px;
}

.article-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 10px;
}

.article-item {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  text-align: left;
  padding: 12px;
}

.article-item:hover,
.article-item.active {
  background: #eaf1ff;
}

.article-item.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.article-item strong,
.article-item span {
  display: block;
}

.article-item strong {
  overflow: hidden;
  margin-bottom: 6px;
  font-size: 14px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.article-item span {
  color: var(--muted);
  font-size: 12px;
}

.reader-pane {
  height: 100vh;
  min-width: 0;
  overflow: auto;
  padding: 16px 22px 28px;
}

.reader-toolbar {
  position: sticky;
  top: 10px;
  z-index: 5;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 28px rgba(31, 43, 61, 0.14);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 8px 10px;
}

.reader-toolbar > div:first-child {
  min-width: 0;
  flex: 1 1 auto;
}

.reader-toolbar .eyebrow {
  margin-bottom: 2px;
  font-size: 10px;
}

.reader-toolbar h2 {
  overflow: hidden;
  margin-bottom: 0;
  font-size: 17px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.toolbar-actions::-webkit-scrollbar {
  display: none;
}

.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  padding: 0 10px;
  text-decoration: none;
  white-space: nowrap;
}

.speed-control {
  display: inline-flex;
  min-height: 34px;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding-left: 8px;
  white-space: nowrap;
}

.speed-control select {
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  outline: none;
  padding-right: 5px;
}

.tool-button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.tool-button.primary:hover {
  background: var(--accent-dark);
}

.mobile-only {
  display: none;
}

.markdown-body {
  width: min(900px, 100%);
  margin: 16px auto 80px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 18px 48px rgba(31, 43, 61, 0.08);
  padding: clamp(24px, 5vw, 58px);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  line-height: 1.25;
}

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

.markdown-body h2 {
  margin-top: 28px;
  font-size: 24px;
}

.markdown-body h3 {
  margin-top: 24px;
  font-size: 20px;
}

.markdown-body p,
.markdown-body li,
.markdown-body blockquote {
  font-size: 17px;
  line-height: 1.85;
}

.markdown-body a {
  color: var(--accent);
}

.markdown-body blockquote {
  margin: 24px 0;
  border-left: 4px solid var(--accent);
  background: #f4f8ff;
  color: #3f4652;
  padding: 14px 18px;
}

.markdown-body code {
  border-radius: 4px;
  background: #eef1f5;
  padding: 2px 5px;
}

.markdown-body pre {
  overflow: auto;
  border-radius: 8px;
  background: #111827;
  color: #f8fafc;
  padding: 18px;
}

.markdown-body img {
  max-width: 100%;
  border-radius: 8px;
}

.empty-state {
  color: var(--muted);
}

@media (max-width: 840px) {
  .app-shell {
    display: block;
    height: 100dvh;
  }

  .sidebar {
    height: 100dvh;
    min-height: 0;
    border: 0;
  }

  .sidebar-header {
    padding: 14px 16px 10px;
  }

  .search-box {
    padding: 0 16px 10px;
  }

  .meta-line {
    padding: 8px 16px;
  }

  .article-list {
    max-height: none;
  }

  .reader-pane {
    display: none;
    height: 100dvh;
    padding: 10px;
  }

  body.article-open .sidebar {
    display: none;
  }

  body.article-open .reader-pane {
    display: block;
  }

  .reader-toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px;
  }

  .reader-toolbar .eyebrow {
    display: none;
  }

  .toolbar-actions {
    display: flex;
    width: 100%;
  }

  .mobile-only {
    display: block;
  }

  .tool-button {
    width: auto;
    min-width: 0;
    flex: 0 0 auto;
    padding: 0 10px;
  }

  .reader-toolbar h2 {
    font-size: 16px;
  }

  .markdown-body {
    margin-top: 10px;
    margin-bottom: 32px;
    padding: 22px 18px;
  }

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

  .markdown-body h2 {
    margin-top: 24px;
    font-size: 22px;
  }

  .markdown-body h3 {
    margin-top: 20px;
    font-size: 19px;
  }

  .markdown-body p,
  .markdown-body li,
  .markdown-body blockquote {
    font-size: 16px;
    line-height: 1.75;
  }
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .reader-toolbar,
  .project-pet {
    display: none;
  }

  .app-shell {
    display: block;
  }

  .reader-pane,
  .markdown-body {
    margin: 0;
    border: 0;
    box-shadow: none;
    padding: 0;
    width: 100%;
  }
}

@media (max-width: 760px) {
  .project-pet {
    right: 4px;
    bottom: 2px;
    width: 76px;
    border-width: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .project-pet {
    animation: none;
  }
}
