:root {
  --bg: #0b0f14;
  --bg-soft: #11161d;
  --text: #e6edf3;
  --muted: #9aa7b4;
  --accent: #4cc2ff;
  --accent-deep: #2f8fd8;
  --accent-soft: rgba(76, 194, 255, 0.16);
  --on-accent: #0b1016;
  --border: #1f2733;
  --nav-bg: rgba(11, 15, 20, 0.85);
  --radius: 12px;
}

[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-soft: #ffffff;
  --text: #0f172a;
  --muted: #55606e;
  --border: #e2e8f0;
  --nav-bg: rgba(246, 248, 250, 0.85);
}

[data-accent="blue"] {
  --accent: #4cc2ff;
  --accent-deep: #2f8fd8;
  --accent-soft: rgba(76, 194, 255, 0.16);
}

[data-accent="green"] {
  --accent: #3ddc97;
  --accent-deep: #22a06b;
  --accent-soft: rgba(61, 220, 151, 0.16);
}

[data-accent="purple"] {
  --accent: #a78bfa;
  --accent-deep: #7c5cd6;
  --accent-soft: rgba(167, 139, 250, 0.16);
}

[data-accent="orange"] {
  --accent: #fb923c;
  --accent-deep: #e0761e;
  --accent-soft: rgba(251, 146, 60, 0.16);
}

[data-accent="pink"] {
  --accent: #f472b6;
  --accent-deep: #d64a95;
  --accent-soft: rgba(244, 114, 182, 0.16);
}

[data-theme="light"] [data-accent="blue"] { --accent-soft: rgba(76, 194, 255, 0.22); }
[data-theme="light"] [data-accent="green"] { --accent-soft: rgba(61, 220, 151, 0.22); }
[data-theme="light"] [data-accent="purple"] { --accent-soft: rgba(167, 139, 250, 0.22); }
[data-theme="light"] [data-accent="orange"] { --accent-soft: rgba(251, 146, 60, 0.22); }
[data-theme="light"] [data-accent="pink"] { --accent-soft: rgba(244, 114, 182, 0.22); }

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
}

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

/* Nav */
.nav {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 32px;
  background: var(--nav-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

@media (max-width: 640px) {
  .nav {
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 10px;
  }
  .search-wrap {
    order: 3;
    max-width: none;
    width: 100%;
  }
  .links {
    order: 4;
    width: 100%;
    justify-content: flex-start;
  }
  .hero {
    padding: 72px 20px 48px;
  }
  .section,
  .page-hero,
  .article-grid {
    padding-left: 20px;
    padding-right: 20px;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.brand-name {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.3px;
}

.links {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.nav-link {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--muted);
  transition: color 0.2s, background 0.2s;
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-soft);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-soft);
}

/* Search */
.search-wrap {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.search-input {
  width: 100%;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--accent);
}

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

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  z-index: 20;
}

.search-result {
  display: block;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  transition: background 0.15s;
}

.search-result:last-child {
  border-bottom: none;
}

.search-result:hover {
  background: var(--accent-soft);
}

.search-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
}

.search-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

.search-empty {
  padding: 12px 14px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Contact form */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 20px 0;
}

.contact-form label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 8px;
}

.contact-form input,
.contact-form textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.contact-form input:focus,
.contact-form textarea:focus {
  border-color: var(--accent);
}

.contact-form input::placeholder,
.contact-form textarea::placeholder {
  color: var(--muted);
}

.contact-form .btn {
  align-self: flex-start;
  margin-top: 14px;
  border: none;
  cursor: pointer;
}

.contact-form .btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.form-status {
  font-size: 0.9rem;
  margin-top: 8px;
}

.contact-direct {
  margin-top: 4px;
  font-size: 0.9rem;
}

/* Tags page */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
}

.tag-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.tag-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tag-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.tag-count {
  font-size: 0.75rem;
  color: var(--muted);
}

.tag-results {
  grid-column: 1 / -1;
}

.tag-results-heading {
  font-size: 1.2rem;
  margin: 24px 0 8px;
}

/* Latest list */
.latest-list {
  display: flex;
  flex-direction: column;
  margin-top: 8px;
}

.latest-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  transition: color 0.15s;
}

.latest-item:last-child {
  border-bottom: none;
}

.latest-item:hover {
  color: var(--accent);
}

.latest-title {
  font-weight: 600;
}

.latest-meta {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Theme controls */
.controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.icon-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.palette-wrap {
  position: relative;
}

.palette {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: flex;
  gap: 8px;
  padding: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 10;
}

.palette[hidden] {
  display: none;
}

.dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--c);
  cursor: pointer;
  transition: transform 0.15s;
}

.dot:hover {
  transform: scale(1.15);
}

.dot.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg-soft);
}

/* Hero */
.hero {
  max-width: 760px;
  margin: 0 auto;
  padding: 110px 32px 64px;
  text-align: center;
}

.hero h1 {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  line-height: 1.15;
  letter-spacing: -0.5px;
}

.accent {
  color: var(--accent);
}

.tagline {
  margin: 20px auto 32px;
  max-width: 520px;
  color: var(--muted);
  font-size: 1.1rem;
}

.hero-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  transition: transform 0.15s, opacity 0.15s;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-ghost {
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--accent);
}

/* Sections */
.section {
  max-width: 760px;
  margin: 0 auto;
  padding: 64px 32px;
}

.section h2 {
  font-size: 1.8rem;
  margin-bottom: 16px;
}

.section p {
  color: var(--muted);
}

/* Category grid (home hub) */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.cat-card {
  display: block;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  color: var(--text);
  transition: transform 0.15s, border-color 0.2s;
}

.cat-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.cat-card .cat-icon {
  font-size: 1.6rem;
  color: var(--accent);
}

.cat-card h3 {
  margin: 12px 0 8px;
}

.cat-card p {
  font-size: 0.95rem;
  color: var(--muted);
}

.cat-card .cat-count {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--accent);
}

/* Category / article pages */
.page-hero {
  max-width: 760px;
  margin: 0 auto;
  padding: 72px 32px 32px;
}

.breadcrumb {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.page-hero h1 {
  font-size: clamp(2rem, 5vw, 2.8rem);
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}

.page-hero p {
  color: var(--muted);
  max-width: 560px;
}

/* Article cards */
.article-grid {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 32px 64px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.article {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.article h3 {
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1.35;
}

.article h3 a {
  color: var(--text);
}

.article h3 a:hover {
  color: var(--accent);
}

.article p {
  color: var(--muted);
  font-size: 0.95rem;
  flex: 1;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

a.tag {
  cursor: pointer;
  text-decoration: none;
}

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

.article .date {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Related articles */
.related-section {
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.related-heading {
  font-size: 1.2rem;
  margin-bottom: 16px;
}

.related-list {
  display: flex;
  flex-direction: column;
}

.related-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  transition: color 0.15s;
}

.related-item:last-child {
  border-bottom: none;
}

.related-item:hover {
  color: var(--accent);
}

.related-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.related-meta {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Article nav */

/* Article page */
.article-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 64px 32px;
}

.article-page .title {
  font-size: clamp(1.8rem, 4.5vw, 2.4rem);
  letter-spacing: -0.5px;
  line-height: 1.25;
  margin-bottom: 12px;
}

.article-page .meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.article-page .meta .tag {
  font-size: 0.75rem;
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: help;
}

.article-body {
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--text);
}

.article-body h2 {
  font-size: 1.4rem;
  margin: 40px 0 12px;
  letter-spacing: -0.3px;
}

.article-body h3 {
  font-size: 1.15rem;
  margin: 28px 0 10px;
}

.article-body p {
  margin: 14px 0;
}

.article-body strong {
  color: var(--text);
}

.article-body ul,
.article-body ol {
  margin: 14px 0;
  padding-left: 24px;
}

.article-body li {
  margin: 8px 0;
}

.article-body pre {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 0.9rem;
  margin: 18px 0;
}

.code-block {
  position: relative;
  margin: 18px 0;
}

.code-block pre {
  margin: 0;
}

.code-block:hover .copy-btn {
  opacity: 1;
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 12px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s;
}

.copy-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.copy-btn.copied {
  color: var(--accent);
  border-color: var(--accent);
  opacity: 1;
}

@media (max-width: 640px) {
  .copy-btn {
    opacity: 1;
  }
}

.article-body code {
  font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: 0.9em;
}

.article-body p code,
.article-body li code {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
}

.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 18px;
  margin: 18px 0;
  color: var(--muted);
  font-style: italic;
}

.article-nav {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.9rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.card h3 {
  margin-bottom: 8px;
  color: var(--text);
}

.card p {
  font-size: 0.95rem;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 24px 32px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 12px;
}

.footer-links a {
  color: var(--muted);
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-links a svg {
  vertical-align: -2px;
  margin-right: 4px;
}

.footer-note {
  font-size: 0.8rem;
  margin-bottom: 8px;
}
