:root {
  --font-size-base: 18px;
  --font-size-sm: 0.8889rem;
  --font-size-xs: 0.7778rem;
  --bg-color: #f7f8fa;
  --surface-1: #ffffff;
  --surface-2: #f3f4f6;
  --color-text: #111;
  --text-muted: #6b7280;
  --link-color: #2563eb;
  --link-hover: #1d4ed8;
  --link-visited: #1e40af;
  --color-hr: #e5e5e5;
  --border-color-subtle: rgba(0, 0, 0, 0.06);
  --color-hover-bg: #f6f9ff;
  --shadow-card: 0 1px 6px rgba(30, 41, 59, 0.05);
  --list-pad-x: 24px;
  --list-pad-y: 24px;
  --home-outer-margin-x: clamp(24px, calc((100vw - 1080px) / 2), 12%);
  --date-col-width: 10ch;
  --list-grid-gap: 16px;
  --navbar-height: 54px;
  --font-serif: "Palatino Linotype", "Book Antiqua", Palatino, "Times New Roman", STKaiti, SimSun, serif;
  --color-link: #2563eb;
  --color-link-hover: #1d4ed8;
  --color-border-subtle: rgba(0, 0, 0, 0.06);
  --color-border: #e2e6ea;
  --color-quote-bg: #fafafa;
  --color-quote-border: #e0e0e0;
  --color-code-bg: #f6f6f6;
  --color-code-border: #e2e2e2;
  --tag-bg: rgba(37, 99, 235, 0.05);
  --tag-color: #2563eb;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 320px;
  color: var(--color-text);
  background: var(--bg-color);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", "WenQuanYi Micro Hei", "Helvetica Neue", Arial, sans-serif;
  font-size: var(--font-size-base);
  line-height: 1.8;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  padding-top: var(--navbar-height);
}

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

a:hover,
a:focus {
  color: var(--link-hover);
}

a:visited {
  color: var(--link-visited);
}

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--navbar-height);
  min-height: var(--navbar-height);
  padding: 0 15px;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid #e7e7e7;
  box-shadow: none;
}

.brand,
.brand:visited {
  color: #777;
  font-family: var(--font-serif);
  font-size: 20px;
  height: var(--navbar-height);
  line-height: var(--navbar-height);
  padding: 0 15px;
  text-decoration: none;
  flex-shrink: 0;
}

.brand:hover,
.brand:focus,
.brand:visited:hover,
.brand:visited:focus {
  color: #333;
  text-decoration: none;
}

.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 44px;
  height: 34px;
  padding: 9px 10px;
  background-color: transparent;
  background-image: none;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  margin-left: auto;
  margin-right: 10px;
  -webkit-tap-highlight-color: transparent;
}

.menu-toggle .icon-bar {
  display: block;
  width: 22px;
  height: 2px;
  background-color: #888;
  border-radius: 1px;
  transition: all 0.2s ease;
}

.menu-toggle:hover,
.menu-toggle:focus {
  background-color: rgba(0, 0, 0, 0.05);
}

.nav-collapse {
  display: flex;
  align-items: center;
}

.nav-list {
  display: flex;
  font-size: 20px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-list li {
  display: inline-block;
}

.nav-list a {
  display: block;
  color: #777;
  height: var(--navbar-height);
  line-height: calc(var(--navbar-height) - 2px); /* height minus border */
  padding: 0 15px;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.nav-list a:hover,
.nav-list a:focus {
  color: var(--color-link-hover);
  background-color: rgba(0, 0, 0, 0.02);
  border-radius: 10px;
  text-decoration: none;
}

/* Glassmorphism active state for light mode navbar */
.nav-list li.active a {
  color: var(--color-link);
  background: rgba(255, 255, 255, 0.36);
  border: 1px solid rgba(148, 163, 184, 0.26);
  -webkit-backdrop-filter: saturate(140%) blur(6px);
  backdrop-filter: saturate(140%) blur(6px);
  box-shadow: 0 1px 6px rgba(30, 41, 59, 0.05);
  border-radius: 12px;
  text-decoration: none;
}

.brand:focus-visible,
.nav-list a:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: 2px;
}

.outer {
  margin: 48px var(--home-outer-margin-x) 64px;
}

.feed-toolbar {
  max-width: 1080px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.filter-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 8px;
  scrollbar-width: none;
}

.filter-tabs::-webkit-scrollbar {
  display: none;
}

.filter-tab {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 8px 14px;
  color: var(--color-text);
  background: var(--surface-1);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  font: inherit;
  font-size: var(--font-size-sm);
  line-height: 1;
  cursor: pointer;
  transition: all 0.25s ease;
}

.filter-tab:hover {
  color: var(--link-hover);
  background: var(--surface-2);
}

.filter-tab[aria-selected="true"] {
  color: var(--link-color);
  background: #f1f8ff;
  border-color: var(--link-color);
  box-shadow: var(--shadow-card);
}

.filter-tab:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: 2px;
}

.feed-meta {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  white-space: nowrap;
}

.list-group {
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--list-pad-y) var(--list-pad-x);
  list-style: none;
  background: var(--surface-1);
  border: 1px solid var(--border-color-subtle);
  border-radius: 12px;
  box-shadow: none;
}

.list-group-item {
  position: relative;
  display: grid;
  grid-template-columns: var(--date-col-width) 1fr auto;
  column-gap: var(--list-grid-gap);
  align-items: center;
  min-height: 58px;
  padding: 16px 20px;
  background-image: linear-gradient(to bottom, transparent calc(100% - 1px), rgba(0, 0, 0, 0.08) 0);
  background-position: 8px 0;
  background-size: calc(100% - 16px) 100%;
  background-repeat: no-repeat;
  transition: background-color 0.25s ease;
}

.list-group-item:last-child {
  background-image: none;
}

.list-group-item:hover {
  background-color: var(--color-hover-bg);
  border-radius: 10px;
}

.item-date {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  line-height: 1.6;
  white-space: nowrap;
}

.item-main {
  min-width: 0;
}

.item-title {
  display: block;
  overflow: hidden;
  color: var(--link-color);
  font-size: 1rem;
  line-height: 1.6;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-title:hover,
.item-title:focus {
  text-decoration: none;
}

.item-summary {
  color: #333;
  font-size: var(--font-size-sm);
  line-height: 1.72;
}

.item-summary p {
  margin: 0.35em 0;
}

.item-summary p:first-child {
  margin-top: 0;
}

.item-summary p:last-child {
  margin-bottom: 0;
}

.item-summary a {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.item-summary blockquote {
  background: var(--color-quote-bg);
  border-left: 4px solid var(--color-quote-border);
  padding: 0.6em 1em;
  margin: 1em 0;
  color: var(--color-text);
  font-size: 0.95rem;
  border-radius: 0 4px 4px 0;
}

.item-summary blockquote p {
  margin: 0;
}

.item-summary pre {
  font-size: 0.88em;
  line-height: 1.5;
  background: var(--color-code-bg);
  border: 1px solid var(--color-code-border);
  border-radius: 6px;
  padding: 10px 14px;
  margin: 1.2em 0;
  overflow: auto;
}

.item-summary code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.item-summary :not(pre) > code {
  font-size: 0.88em;
  background: var(--color-code-bg);
  border: 1px solid var(--color-code-border);
  border-radius: 3px;
  padding: 0.1em 0.3em;
  margin: 0 0.1em;
  word-break: break-word;
}

.item-summary table {
  display: block;
  width: 100%;
  border-collapse: collapse;
  overflow-wrap: normal;
  overflow-x: auto;
}

.item-summary table tr {
  background-color: var(--surface-1);
  border-top: 1px solid var(--color-border);
}

.item-summary table td,
.item-summary table th {
  padding: 6px 13px;
  border: 1px solid var(--color-border);
}

.item-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  line-height: 1.4;
  white-space: nowrap;
}

.source-badge {
  color: var(--text-muted);
}

.tags {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  max-width: 260px;
  overflow: hidden;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  line-height: 1.2;
  background: var(--tag-bg);
  color: var(--tag-color);
  border-radius: 999px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.2s ease;
}

.tag:hover {
  background: var(--tag-color);
  color: var(--surface-1);
}

.micro-item {
  grid-template-columns: var(--date-col-width) 1fr auto;
  align-items: start;
}

.micro-item .item-title {
  white-space: normal;
}

.micro-item .item-aside {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.micro-content {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.micro-original-link,
.micro-original-link:visited {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 4px 10px;
  color: var(--link-color);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  line-height: 1;
  text-decoration: none;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.micro-original-link:hover,
.micro-original-link:focus {
  color: var(--link-hover);
  background: var(--surface-2);
  border-color: var(--link-color);
  text-decoration: none;
}

.micro-original-link:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: 2px;
}

.empty-row,
.error-row,
.loading-row {
  grid-template-columns: 1fr;
  color: var(--text-muted);
}

.loading-row span {
  display: block;
  height: 14px;
  max-width: 320px;
  margin: 6px 0;
  background: linear-gradient(90deg, #f0f2f5, #e6e9ef, #f0f2f5);
  border-radius: 999px;
}

.loading-row span + span {
  max-width: 220px;
}

@media screen and (max-width: 860px) {
  :root {
    --font-size-base: 17px;
    --navbar-height: 44px;
    --list-pad-x: 12px;
    --list-pad-y: 8px;
  }

  .site-header {
    position: fixed;
    align-items: center;
    height: var(--navbar-height);
    min-height: var(--navbar-height);
    margin: 0;
    padding: 0 8px;
    border-radius: 0;
    border-bottom: 1px solid #e7e7e7;
  }

  .brand {
    height: var(--navbar-height);
    padding: 0 10px;
    font-size: 17px;
    line-height: var(--navbar-height);
  }

  .nav-list {
    font-size: 17px;
  }

  .nav-list a {
    height: var(--navbar-height);
    line-height: calc(var(--navbar-height) - 2px); /* height minus border */
    padding: 0 10px;
  }

  .outer {
    margin: 28px 3% 32px;
  }

  .feed-toolbar {
    display: block;
  }

  .feed-meta {
    margin-top: 4px;
  }

  .list-group-item,
  .micro-item {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 14px 12px;
  }

  .item-date {
    font-size: 13px;
  }

  .item-title {
    white-space: normal;
  }

  .item-aside {
    align-items: flex-start;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .micro-original-link {
    min-height: 44px;
    padding-inline: 12px;
  }

  .tags {
    justify-content: flex-start;
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  .menu-toggle {
    display: flex;
  }

  .nav-collapse {
    display: none;
    position: absolute;
    top: 100%;
    right: 15px; /* Aligned to drawer padding */
    z-index: 1040;
    box-sizing: border-box;
    background: var(--surface-1);
    border: 1px solid var(--color-border-subtle);
    border-radius: 12px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.1);
    margin-top: 6px;
    padding: 0 4px;
    width: fit-content;
    min-width: 76px;
    max-width: calc(100% - 30px);
  }

  .nav-collapse.open {
    display: block;
  }

  .nav-list {
    display: flex;
    flex-direction: column;
    margin: 6px 0;
    padding: 0;
    gap: 0;
    font-size: 17px;
  }

  .nav-list li {
    display: block;
    width: 100%;
  }

  .nav-list li a {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 15px;
    min-height: 40px;
    border-radius: 10px;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
    white-space: nowrap;
    height: auto;
    line-height: normal;
  }

  .nav-list li.active a {
    border-radius: 10px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #0f1115;
    --surface-1: #12161a;
    --surface-2: #0f1317;
    --color-text: #e7e7e7;
    --text-muted: #9aa4b2;
    --link-color: #8ab4f8;
    --link-hover: #a7c7ff;
    --link-visited: #b5a7ff;
    --color-hover-bg: rgba(255, 255, 255, 0.04);
    --border-color-subtle: rgba(255, 255, 255, 0.08);
    --color-link: #8ab4f8;
    --color-link-hover: #a9c6ff;
    --color-border: #2a2f37;
    --color-quote-bg: #141a20;
    --color-quote-border: #2a2f37;
    --color-code-bg: #12161a;
    --color-code-border: #2a2f37;
    --tag-bg: rgba(138, 180, 248, 0.1);
    --tag-color: #8ab4f8;
  }

  .site-header {
    background: rgba(26, 31, 38, 0.9);
    border-color: #2a2f37;
  }

  .brand,
  .brand:visited {
    color: #9aa4b2;
  }

  .brand:hover,
  .brand:focus,
  .brand:visited:hover,
  .brand:visited:focus {
    color: #fff;
  }

  .nav-list a {
    color: #9aa4b2;
  }

  .menu-toggle {
    border-color: #444;
  }

  .menu-toggle .icon-bar {
    background-color: #aaa;
  }

  .menu-toggle:hover,
  .menu-toggle:focus {
    background-color: rgba(255, 255, 255, 0.1);
  }

  .nav-list a:hover,
  .nav-list a:focus {
    background-color: rgba(255, 255, 255, 0.06);
  }

  /* Glassmorphism active state for dark mode navbar */
  .nav-list li.active a {
    color: var(--color-link);
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(148, 163, 184, 0.20);
    -webkit-backdrop-filter: saturate(140%) blur(6px);
    backdrop-filter: saturate(140%) blur(6px);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.18);
  }

  .filter-tab[aria-selected="true"] {
    background: rgba(138, 180, 248, 0.08);
    color: var(--link-color);
    border-color: var(--link-color);
  }

  .item-summary {
    color: #d1d5db;
  }

  .list-group-item {
    background-image: linear-gradient(to bottom, transparent calc(100% - 1px), rgba(255, 255, 255, 0.08) 0);
  }

  .loading-row span {
    background: linear-gradient(90deg, #181c22, #22272e, #181c22);
  }
}
