:root {
  --bg: #f7f5f0;
  --bg-soft: #efece4;
  --surface: #ffffff;
  --surface-hover: #fbfaf6;
  --border: #e4dfd4;
  --border-strong: #d4cdbd;
  --text: #1a1d29;
  --text-muted: #5a6173;
  --text-subtle: #8a8f9c;
  --primary: #0b2746;
  --primary-hover: #163a63;
  --accent: #b54729;
  --accent-soft: #fbe9e2;
  --success: #1f7a4d;
  --success-soft: #e3f4ea;
  --chatgpt: #10a37f;
  --chatgpt-hover: #0d8a6b;
  --focus: #7aa7d9;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 40px rgba(15, 23, 42, 0.15), 0 8px 16px rgba(15, 23, 42, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --font-body:
    "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  --font-mono:
    ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", "Fira Code", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111319;
    --bg-soft: #191c23;
    --surface: #1a1d25;
    --surface-hover: #212530;
    --border: #2a2f3c;
    --border-strong: #373d4d;
    --text: #ecedf0;
    --text-muted: #9ba3b4;
    --text-subtle: #6e7687;
    --primary: #7aa7d9;
    --primary-hover: #a3c4e8;
    --accent: #e78a6b;
    --accent-soft: #3a2620;
    --success: #6fc693;
    --success-soft: #1f3428;
    --chatgpt: #2ec4a0;
    --chatgpt-hover: #4fd9b6;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.5), 0 8px 16px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover {
  color: var(--primary-hover);
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-soft);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--text);
  border: 1px solid var(--border);
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(150%) blur(8px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 18px;
  padding-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.brand-tag {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.3;
}
.brand-mark {
  display: inline-block;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  position: relative;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 4px;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 100% 70%, 55% 70%, 40% 100%, 30% 70%, 0 70%);
}

.help-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.help-btn:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}

/* ---------- Hero ---------- */
.hero {
  margin: 40px 0 28px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
}
.hero-copy {
  margin: 0;
  font-size: 17px;
  color: var(--text);
  line-height: 1.55;
  max-width: 760px;
}
.hero-copy code {
  font-size: 13.5px;
}
.hero-note {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 10px;
  background: var(--accent-soft);
  border-radius: 999px;
  white-space: nowrap;
  justify-self: end;
}
.hero-note .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.search {
  position: relative;
  flex: 1 1 360px;
  min-width: 240px;
}
.search input {
  width: 100%;
  padding: 14px 16px 14px 44px;
  font: inherit;
  font-size: 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.search input::placeholder {
  color: var(--text-subtle);
}
.search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  pointer-events: none;
}

.meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  color: var(--text-muted);
}
.count strong {
  color: var(--text);
  font-weight: 600;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: inherit;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover {
  color: var(--primary-hover);
}

/* ---------- Filter groups ---------- */
.filter-groups {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 32px;
}
.filter-group {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.filter-label {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  padding-top: 10px;
  min-width: 72px;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: all 120ms ease;
  white-space: nowrap;
}
.chip:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--text-muted);
}
.chip-cat .cat-icon {
  color: var(--cat-color, var(--text-muted));
  flex-shrink: 0;
}
.chip-cat:hover {
  border-color: color-mix(in srgb, var(--cat-color, var(--border-strong)) 55%, var(--border-strong));
  background: color-mix(in srgb, var(--cat-color, var(--surface)) 6%, var(--surface));
}
.chip[aria-pressed="true"] {
  color: var(--surface);
  background: var(--primary);
  border-color: var(--primary);
}
.chip-cat[aria-pressed="true"] {
  color: var(--surface);
  background: var(--cat-color, var(--primary));
  border-color: var(--cat-color, var(--primary));
}
.chip-cat[aria-pressed="true"] .cat-icon {
  color: var(--surface);
}
.chip[aria-pressed="true"] .chip-count {
  background: rgba(255, 255, 255, 0.18);
  color: var(--surface);
}
.chip-count {
  display: inline-block;
  min-width: 20px;
  text-align: center;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  margin-bottom: 48px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 20px 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color 140ms ease, box-shadow 140ms ease;
  position: relative;
  border-top: 3px solid var(--cat-color, var(--border-strong));
}
.card:hover {
  border-color: var(--border-strong);
  border-top-color: var(--cat-color, var(--border-strong));
  box-shadow: var(--shadow-md);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.card-cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--cat-color, var(--primary));
  background: color-mix(in srgb, var(--cat-color, var(--primary)) 10%, transparent);
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-weight: 600;
  line-height: 1.4;
}
.card-cat .cat-icon {
  flex-shrink: 0;
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  margin: 2px 0 10px;
  color: var(--text);
  letter-spacing: -0.005em;
}
.card-body {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0 0 14px;
  max-height: 180px;
  overflow: hidden;
  position: relative;
  transition: max-height 220ms ease;
}
.card-body::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 48px;
  background: linear-gradient(to bottom, transparent, var(--surface));
  pointer-events: none;
  transition: opacity 200ms ease;
}
.card.is-expanded .card-body {
  max-height: 4000px;
}
.card.is-expanded .card-body::after {
  opacity: 0;
}

.card-body mark,
.card-title mark {
  background: color-mix(in srgb, var(--accent) 25%, transparent);
  color: var(--text);
  border-radius: 2px;
  padding: 0 2px;
}

.card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}
.btn-primary {
  background: var(--primary);
  color: var(--surface);
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--surface);
}
.btn-secondary {
  background: var(--chatgpt);
  color: #fff;
  border-color: var(--chatgpt);
}
.btn-secondary:hover {
  background: var(--chatgpt-hover);
  border-color: var(--chatgpt-hover);
  color: #fff;
}
.btn.is-success {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
}
.btn svg {
  flex-shrink: 0;
}
.btn-expand {
  margin-left: auto;
  color: var(--text-muted);
}

/* ---------- Empty ---------- */
.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 20px;
  background: var(--bg-soft);
  border-radius: var(--radius);
  margin: 0 0 48px;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 24px 0;
  font-size: 13px;
  color: var(--text-muted);
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  text-align: center;
}
.footer-inner p {
  margin: 0;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: var(--text);
  color: var(--surface);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
  z-index: 50;
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal[hidden] {
  display: none;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}
.modal-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 36px 28px;
  max-width: 640px;
  width: 100%;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  animation: modal-in 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.modal-close:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
  color: var(--text);
}
.modal-card h2 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.modal-lead {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 15px;
}
.steps {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 38px;
  font-size: 14.5px;
  line-height: 1.5;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--surface);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}
.example {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-mono);
  line-height: 1.55;
  color: var(--text-muted);
}
.example-before code {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 25%, var(--border));
  color: var(--accent);
}
.example-after code {
  background: color-mix(in srgb, var(--success) 15%, transparent);
  border-color: color-mix(in srgb, var(--success) 30%, var(--border));
  color: var(--success);
}
.example-arrow {
  margin: 6px 0;
  color: var(--text-subtle);
  text-align: center;
  font-size: 14px;
}
.modal-footnote {
  margin: 0;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}
.modal-footnote em {
  font-style: normal;
  color: var(--text);
  font-weight: 500;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .filter-group {
    flex-direction: column;
    gap: 8px;
  }
  .filter-label {
    padding-top: 0;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 0 16px;
  }
  .brand h1 {
    font-size: 16px;
  }
  .brand-tag {
    font-size: 12px;
  }
  .hero {
    margin: 24px 0 20px;
    grid-template-columns: 1fr;
    align-items: flex-start;
    gap: 12px;
  }
  .hero-copy {
    font-size: 15.5px;
  }
  .hero-note {
    justify-self: start;
    white-space: normal;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .help-btn {
    padding: 6px 10px;
    font-size: 12px;
  }
  .help-btn span {
    display: none;
  }
  .modal-card {
    padding: 28px 20px 20px;
  }
  .modal-card h2 {
    font-size: 19px;
  }
  .card-actions .btn-expand {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
