/* ====== RESET / BASE ====== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  transition: background-color .3s ease, color .3s ease;
}
a { color: inherit; text-decoration: none; }

/* ====== THEME TOKENS ====== */
:root[data-theme="light"]{
  --bg: #f6f7fb;
  --text: #16181d;
  --muted: #6c7280;
  --card: #ffffffcc;
  --card-stroke: #e6e7ee;
  --accent: #5b7cfa;
  --accent-2: #59e0c5;
  --shadow: 0 10px 30px rgba(40, 44, 52, .08);
  --nav: #ffffffcc;
  --nav-stroke: #e9ebf3;
  --glass: blur(14px) saturate(130%);
  --focus: 0 0 0 3px rgba(91,124,250,.35);
  --footer-bg: #ffffffcc;
}
:root[data-theme="dark"]{
  --bg: #0f1322;
  --text: #e9ecf5;
  --muted: #9aa3b2;
  --card: #161a2b99;
  --card-stroke: #252b40;
  --accent: #8aa2ff;
  --accent-2: #58e6cf;
  --shadow: 0 12px 30px rgba(0,0,0,.45);
  --nav: #14192b99;
  --nav-stroke: #1f2640;
  --glass: blur(14px) saturate(140%);
  --focus: 0 0 0 3px rgba(138,162,255,.45);
  --footer-bg: #14192b99;
}

/* ====== NAVBAR ====== */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.25rem;
  background: var(--nav);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border-bottom: 1px solid var(--nav-stroke);
}
.brand {
  display: flex; align-items: center; gap: .6rem;
  font-weight: 800; letter-spacing: .4px;
  color: var(--text);
}
.brand-badge {
  width: 28px; height: 28px; border-radius: 9px;
  display: grid; place-items: center;
  background: radial-gradient(120% 120% at 0% 0%, var(--accent) 0%, var(--accent-2) 100%);
  box-shadow: 0 6px 18px rgba(91,124,250,.35);
  color: white; font-size: .9rem; font-weight: 900;
}
.nav-links {
  display: flex; gap: 1rem; align-items: center;
}
.nav-links a {
  padding: .5rem .75rem; border-radius: 10px;
  font-weight: 600; color: var(--text);
  border: 1px solid transparent;
  transition: transform .18s ease, background-color .18s ease, border-color .18s ease;
}
.nav-links a:hover {
  background: linear-gradient(180deg, transparent, transparent 60%, rgba(0,0,0,.04));
  border-color: var(--card-stroke);
  transform: translateY(-1px);
}
.theme-btn {
  appearance: none; border: 1px solid var(--card-stroke);
  border-radius: 999px; padding: .5rem .75rem; cursor: pointer;
  background: var(--card);
  backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
  display: flex; align-items: center; gap: .5rem;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.theme-btn:focus-visible { outline: none; box-shadow: var(--focus); }
.theme-btn:hover { transform: translateY(-1px); }

/* ====== HERO ====== */
.hero {
  padding: 3.5rem 1.25rem 1rem;
  text-align: center;
}
.hero h1 {
  font-size: clamp(1.8rem, 3.8vw, 3rem);
  line-height: 1.15;
  margin: 0 auto .7rem;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  font-weight: 900;
}
.hero p {
  color: var(--muted);
  max-width: 720px; margin: 0 auto;
  font-size: clamp(1rem, 1.2vw, 1.1rem);
}

/* ====== TOPIC GRID ====== */
.grid-wrap { padding: 2rem 1.25rem 3rem; display: grid; place-items: center; }
.grid {
  width: min(1100px, 100%);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.1rem;
}
.card {
  position: relative;
  border-radius: 18px;
  padding: 1.2rem 1.2rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--card-stroke);
  box-shadow: var(--shadow);
  isolation: isolate;
  overflow: hidden;
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.card::after {
  content: "";
  position: absolute; inset: -80% -40% auto auto; height: 180px; width: 180px;
  background: radial-gradient(120px 120px at 70% 30%, var(--accent) 0%, transparent 60%),
              radial-gradient(120px 120px at 30% 70%, var(--accent-2) 0%, transparent 60%);
  opacity: .18; filter: blur(8px); transform: rotate(18deg);
  pointer-events: none;
}
.card:hover { transform: translateY(-4px); border-color: color-mix(in oklab, var(--accent) 45%, var(--card-stroke)); }
.card a { display: block; height: 100%; }
.card-head {
  display: flex; align-items: center; gap: .9rem; margin-bottom: .35rem;
}
.chip {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.25rem;
  background: radial-gradient(120% 120% at 0% 0%, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff; box-shadow: 0 10px 24px rgba(0,0,0,.15);
}
.card h3 {
  margin: 0; font-size: 1.2rem; letter-spacing: .2px; font-weight: 800;
}
.card p { margin: .25rem 0 0; color: var(--muted); font-size: .98rem; }

/* ====== FOOTER ====== */
footer {
  margin-top: auto;
  background: var(--footer-bg);
  border-top: 1px solid var(--nav-stroke);
  backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
  text-align: center; padding: .9rem 1rem; font-size: .95rem;
  color: var(--muted);
}

/* ====== ACCESSIBILITY ====== */
.card:focus-within { outline: none; box-shadow: var(--focus); }
.nav-links a:focus-visible, .brand:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 10px; }

/* ===== Content Writing Page ===== */
.article-hero {
  text-align: center;
  padding: 4rem 1rem 2rem;
}

.article-hero h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.article-hero .subtitle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.back-link {
  display: inline-block;
  margin-top: 0.5rem;
  text-decoration: none;
  color: var(--accent);
  font-weight: 500;
  transition: color 0.3s;
}
.back-link:hover {
  color: var(--text-primary);
}

/* Content Container */
.content-container {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Article Card */
.content-card {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: 16px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  line-height: 1.7;
}

.content-card h2 {
  margin-bottom: 1rem;
  font-size: 1.6rem;
}

.content-card p {
  margin-bottom: 1rem;
  font-size: 1.05rem;
}

/* Lists */
.content-card ul {
  list-style: none;
  padding-left: 0;
}
.content-card li {
  padding: 0.4rem 0;
}

/* Code Blocks */
pre {
  background: var(--code-bg, #2d2d2d);
  color: #f8f8f2;
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.95rem;
}

