:root {
  --header-bar-height: 59px;
  --footer-bar-height: 59px;
  --text: #1f2937;
  --muted: #4b5563;
  --bg: #f9fafb;
  --panel: #ffffff;
  --border: #d1d5db;
  --link: #0284c7;
  --link-hover: #0369a1;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.dark {
  --text: #d1d5db;
  --muted: #9ca3af;
  --bg: #111827;
  --panel: #1f2937;
  --border: #4b5563;
  --link: #38bdf8;
  --link-hover: #7dd3fc;
  --shadow: 0 4px 6px -1px rgb(255 255 255 / 0.08), 0 2px 4px -2px rgb(255 255 255 / 0.06);
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: var(--header-bar-height);
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.5;
}

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

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

button,
input {
  font: inherit;
}

.gsc-container {
  width: 100%;
  max-width: 1536px;
  margin: 0 auto;
  padding: 0 1rem;
}

.gsc-bg {
  background: var(--bg);
}

.gsc-border {
  border-color: var(--border);
}

.gsc-hidden-on-light,
.dark .gsc-hidden-on-dark {
  display: none;
}

.dark .gsc-hidden-on-light {
  display: inline-flex;
}

#gsi-header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--header-bar-height);
  border-bottom: 1px solid var(--border);
  filter: drop-shadow(0 4px 4px rgb(0 0 0 / 0.1));
}

.site-nav {
  display: flex;
  height: var(--header-bar-height);
  align-items: center;
}

.gsc-nav ul {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-main {
  min-width: 0;
  margin-right: auto;
}

.desktop-menu {
  gap: 1rem;
}

.mobile-menu {
  display: none !important;
  gap: 1rem;
}

.nav-logo {
  margin-right: 0.2rem;
  font-weight: 600;
  white-space: nowrap;
}

.nav-logo a,
.mobile-menu a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text);
}

.logo-mark {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 4px;
  color: #fff;
  background: #0284c7;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1;
}

.gsc-nav a,
.icon-button {
  display: inline-flex;
  min-height: var(--header-bar-height);
  align-items: center;
  padding: 0;
  color: var(--text);
  font-weight: 600;
}

.gsc-nav a:hover,
.gsc-nav a.gsc-active,
.icon-button:hover {
  color: var(--link);
  text-decoration: none;
}

.nav-right {
  display: flex;
  flex: none;
  gap: 1rem;
  align-items: center;
}

.icon-button {
  width: 24px;
  min-height: 24px;
  justify-content: center;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 1.45rem;
  line-height: 1;
}

.chevron {
  font-size: 1.5rem;
  transform: translateY(-2px);
}

.popup-menu {
  position: absolute;
  top: calc(var(--header-bar-height) - 12px);
  left: 1rem;
  z-index: 20;
  min-width: 11rem;
  padding: 0.5rem 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  box-shadow: var(--shadow);
}

.popup-menu a {
  display: block;
  min-height: 0;
  padding: 0.5rem 1rem;
  color: var(--text);
  white-space: nowrap;
}

.popup-menu a:hover {
  background: #e0f2fe;
}

.dark .popup-menu a:hover {
  background: #075985;
}

.hidden {
  display: none !important;
}

#gsi-content {
  min-height: calc(100vh - var(--header-bar-height) - var(--footer-bar-height));
  padding: 1rem 0;
}

#gsi-index-content h4 {
  margin: 1.3rem 0 1rem;
  font-size: 1rem;
  font-weight: 700;
}

.home-book-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, 192px);
  gap: 30px 20px;
  justify-content: flex-start;
}

.home-book-list-item {
  display: block;
  width: 192px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel);
  cursor: pointer;
  opacity: 0.9;
}

.home-book-list-item:hover {
  box-shadow: var(--shadow);
  opacity: 1;
}

.home-book-list-image {
  display: block;
  color: var(--text);
}

.home-book-list-image:hover {
  color: var(--text);
  text-decoration: none;
}

.cover {
  display: grid;
  height: 126px;
  place-items: center;
  border-bottom: 1px solid var(--border);
  color: #fff;
  font-size: 1.65rem;
  font-weight: 800;
}

.cover span {
  padding: 0.35rem 0.75rem;
  border: 2px solid rgb(255 255 255 / 0.72);
  border-radius: 4px;
  background: rgb(0 0 0 / 0.12);
}

.cover-blue { background: linear-gradient(135deg, #0f766e, #0284c7); }
.cover-green { background: linear-gradient(135deg, #15803d, #65a30d); }
.cover-yellow { background: linear-gradient(135deg, #ca8a04, #ea580c); }
.cover-red { background: linear-gradient(135deg, #be123c, #dc2626); }
.cover-indigo { background: linear-gradient(135deg, #4338ca, #2563eb); }
.cover-cyan { background: linear-gradient(135deg, #0891b2, #14b8a6); }
.cover-purple { background: linear-gradient(135deg, #7e22ce, #db2777); }
.cover-slate { background: linear-gradient(135deg, #334155, #64748b); }
.cover-orange { background: linear-gradient(135deg, #c2410c, #f59e0b); }

.home-book-list-title {
  padding: 12px 4px 4px;
  font-weight: 700;
  text-align: center;
}

.home-book-list-desc {
  min-height: 76px;
  padding: 4px 8px 10px;
  color: var(--muted);
  font-size: 0.94rem;
}

.home-blog-list-item {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 1rem;
  margin: 16px 0;
}

.home-blog-list-item span,
.article-date {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
}

#gsi-footer {
  height: var(--footer-bar-height);
  overflow: hidden;
  border-top: 1px solid var(--border);
}

.footer-inner {
  padding: 1rem 0;
  text-align: center;
}

.article-page {
  max-width: 860px;
  margin: 0 auto;
}

.article-page h1 {
  margin: 0.75rem 0 1rem;
  font-size: 2rem;
  line-height: 1.2;
}

.article-page h2 {
  margin: 2rem 0 0.6rem;
  font-size: 1.4rem;
}

.article-page p {
  margin: 1rem 0;
}

.article-page ul {
  margin: 1rem 0;
  padding-left: 1.4rem;
}

.article-page li {
  margin: 0.45rem 0;
}

.article-page blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.2rem;
  border-left: 4px solid var(--link);
  background: rgb(2 132 199 / 0.08);
}

.article-page blockquote p {
  margin: 0;
  font-weight: 600;
}

.gsc-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgb(156 163 175 / 0.5);
  backdrop-filter: blur(4px);
}

.search-dialog {
  position: fixed;
  inset: 4rem 3rem;
  display: flex;
  max-width: 1536px;
  margin: 0 auto;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  box-shadow: var(--shadow);
}

.search-box {
  flex: none;
  padding: 2rem;
  border-bottom: 1px solid var(--border);
}

.search-box input {
  display: block;
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  background: var(--panel);
}

.search-results {
  flex: auto;
  overflow-y: auto;
  padding: 1rem 2rem 2rem;
}

.search-results div {
  margin: 1rem 0;
}

.search-results p {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

@media (max-width: 980px) {
  .desktop-menu {
    gap: 0.75rem;
  }

  .nav-logo {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 768px) {
  .desktop-menu {
    display: none !important;
  }

  .mobile-menu {
    display: flex !important;
  }

  .mobile-link {
    font-weight: 600;
  }

  .home-book-list {
    grid-template-columns: 1fr;
    gap: 30px 12px;
  }

  .home-book-list-item {
    width: 100%;
  }

  .home-blog-list-item {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .search-dialog {
    inset: 2rem 1.5rem;
  }
}

@media (max-width: 480px) {
  .home-book-list-item {
    width: 100%;
  }

  .home-book-list {
    grid-template-columns: 1fr;
  }

  .cover {
    height: 116px;
  }
}
