:root {
  --bg: #f6f7f8;
  --surface: #ffffff;
  --text: #1b1f23;
  --muted: #5d6772;
  --border: #d9dee3;
  --accent: #0057b8;
  --header: #0f1720;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: linear-gradient(180deg, #eef2f6 0%, var(--bg) 180px, var(--bg) 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.65;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover,
a:focus-visible {
  text-decoration: underline;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
}

.site-header {
  padding: 0.4rem 0 1.25rem;
  border-bottom: 1px solid var(--border);
}

.site-title {
  margin: 0;
  color: var(--header);
  font-size: 1.85rem;
  line-height: 1.2;
}

.site-date {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.98rem;
}

.site-nav {
  margin: 0.5rem 0 0;
  font-size: 0.92rem;
}

.title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.timeline {
  margin-top: 1rem;
}

.item {
  margin-top: 1.8rem;
  padding: 0.75rem 0.85rem 0.85rem;
  background: var(--surface);
  border-left: 3px solid var(--border);
  border-radius: 4px;
}

.item-title {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.35;
}

.timeline .item:first-child .item-title {
  font-size: 1.38rem;
  line-height: 1.22;
  letter-spacing: -0.01em;
}

.item-meta {
  margin-top: 0.15rem;
  margin-bottom: 0.65rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.item-summary {
  margin: 0;
  max-height: 6.6em;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
}

.item-toggle {
  cursor: pointer;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--accent);
  font-size: 0.9rem;
  margin-top: 0.45rem;
  text-decoration: underline;
}

.item.expanded .item-summary {
  max-height: none;
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
}

.item-background {
  display: none;
  margin: 0.55rem 0 0;
  padding: 0.65rem 0.75rem;
  background: var(--bg);
  border-radius: 4px;
  font-size: 0.92rem;
  line-height: 1.55;
}

.item.bg-expanded .item-background {
  display: block;
}

.item-bg-toggle {
  cursor: pointer;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.45rem;
  margin-left: 1ch;
  text-decoration: underline;
}

.item-image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 220px;
  object-fit: cover;
  object-position: center;
  border-radius: 4px;
  margin-bottom: 0.65rem;
}

.item-footnotes {
  margin: 0.5rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.term {
  border-bottom: 1px dotted var(--muted);
  cursor: help;
}

.term-popup {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text);
  max-width: min(260px, calc(100vw - 16px));
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
  z-index: 200;
}

.vote-controls {
  display: none;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.45rem;
}

.vote-btn {
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.vote-btn:hover {
  border-color: var(--muted);
  color: var(--text);
}

.vote-btn.active-up {
  color: #2ea043;
  opacity: 1;
}

.vote-btn.active-down {
  color: #f85149;
  opacity: 1;
}

.news-admin-corner {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  font-size: 0.75rem;
  opacity: 0.35;
  z-index: 100;
}

.news-admin-corner:hover {
  opacity: 0.8;
}

.site-footer {
  margin-top: 1.8rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

@media (min-width: 700px) {
  .page {
    padding-top: 1.5rem;
  }

  .site-title {
    font-size: 2rem;
  }

  .item {
    padding: 0.85rem 1rem 0.95rem;
  }

  .timeline .item:first-child .item-title {
    font-size: 1.58rem;
  }

  .item-image {
    height: 260px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1116;
    --surface: #121821;
    --text: #e6edf3;
    --muted: #9ca8b6;
    --border: #273141;
    --accent: #74b5ff;
    --header: #f4f8ff;
  }

  body {
    background: linear-gradient(180deg, #111825 0%, var(--bg) 180px, var(--bg) 100%);
  }
}
