:root {
  --background: #ffffff;
  --foreground: #0f172a;
  --muted: #f1f5f9;
  --muted-foreground: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --card: #ffffff;
  --accent: #0f172a;
  --accent-foreground: #f8fafc;
  --radius: 0.5rem;
  --max-width: 1100px;
  --content-width: 760px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  color: var(--foreground);
  background-color: var(--background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--muted-foreground);
}

img {
  max-width: 100%;
  display: block;
}

[hidden] {
  display: none !important;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.site-logo {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.site-logo .logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-foreground);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.site-nav a {
  transition: color 0.15s ease;
}

.site-nav a:hover {
  color: var(--foreground);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 4rem;
  padding: 2rem 0;
  font-size: 0.85rem;
  color: var(--muted-foreground);
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-footer nav {
  display: flex;
  gap: 1.25rem;
}

/* Tag */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.6;
  border-radius: 9999px;
  background: var(--muted);
  color: var(--muted-foreground);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

a.tag {
  cursor: pointer;
}

a.tag:hover {
  background: var(--accent);
  color: var(--accent-foreground);
  border-color: var(--accent);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.tag-list li {
  list-style: none;
}

/* Toolbar (TOP page article list — filter / sort) */
.toolbar-section {
  padding: 2rem 0 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.toolbar-info {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.toolbar-info .toolbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--foreground);
}

.toolbar-info .toolbar-count {
  font-size: 0.825rem;
  color: var(--muted-foreground);
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.toolbar-control {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: var(--muted-foreground);
  font-weight: 500;
}

.toolbar-control select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: var(--background);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2364748b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><polyline points='4 6 8 10 12 6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  background-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 1.85rem 0.4rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--foreground);
  font-family: inherit;
  cursor: pointer;
  min-width: 8rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.toolbar-control select:hover {
  border-color: var(--border-strong);
}

.toolbar-control select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

/* Search input in toolbar */
.toolbar-search {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.toolbar-search::before {
  content: "";
  position: absolute;
  left: 0.65rem;
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2364748b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><circle cx='7' cy='7' r='5'/><line x1='11' y1='11' x2='14' y2='14'/></svg>")
    no-repeat center / contain;
  pointer-events: none;
}

.toolbar-search input {
  appearance: none;
  -webkit-appearance: none;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.7rem 0.4rem 2rem;
  font-size: 0.85rem;
  color: var(--foreground);
  font-family: inherit;
  min-width: 14rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.toolbar-search input::placeholder {
  color: var(--muted-foreground);
}

.toolbar-search input:hover {
  border-color: var(--border-strong);
}

.toolbar-search input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

@media (max-width: 640px) {
  .toolbar {
    align-items: stretch;
  }
  .toolbar-controls {
    width: 100%;
  }
  .toolbar-search {
    width: 100%;
    flex: 1 1 100%;
  }
  .toolbar-search input {
    width: 100%;
    min-width: 0;
  }
  .toolbar-control {
    flex: 1;
  }
  .toolbar-control select {
    width: 100%;
    min-width: 0;
  }
}

/* Series cards (TOP overview + series page list) */
.series-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.series-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.1rem 1.2rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--foreground);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.series-card:hover {
  color: var(--foreground);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.04);
}

.series-card .series-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted-foreground);
}

.series-card h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.4;
}

.series-card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted-foreground);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.series-card .series-meta {
  margin-top: auto;
  padding-top: 0.6rem;
  font-size: 0.78rem;
  color: var(--muted-foreground);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

/* Card-series eyebrow (small label on TOP cards in a series) */
.card .card-series {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted-foreground);
  margin-bottom: 0.15rem;
}

.card .card-series .card-series-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--muted);
  border: 1px solid var(--border);
  font-size: 9px;
  font-weight: 700;
  color: var(--muted-foreground);
}

/* Thumbnail (dummy gradient placeholder) */
.thumb {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--muted);
  isolation: isolate;
}

.thumb::before {
  content: "";
  display: block;
  width: 100%;
  padding-top: 56.25%;
}

.thumb-pattern {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(15, 23, 42, 0.08) 1px, transparent 1px);
  background-size: 14px 14px;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: 0.6;
}

/* Card thumb (article cards on TOP / series page) */
.card .thumb-card {
  margin: -1.25rem -1.25rem 0.85rem;
  border-radius: var(--radius) var(--radius) 0 0;
}

.card .thumb-card::before {
  padding-top: 50%;
}

/* Series card thumb */
.series-card .thumb-series {
  margin: -1.1rem -1.2rem 0.6rem;
  border-radius: var(--radius) var(--radius) 0 0;
}

.series-card .thumb-series::before {
  padding-top: 42%;
}

/* Empty state */
.empty-state {
  padding: 4rem 0;
  text-align: center;
  color: var(--muted-foreground);
}

@media (max-width: 640px) {
  .site-nav {
    gap: 0.875rem;
  }
  .site-footer .container {
    flex-direction: column;
    align-items: flex-start;
  }
}
