:root {
  /* Kami Core Palette: Warm Parchment & Ink Blue */
  --parchment: #f5f4ed;
  --ivory: #faf9f5;
  --warm-sand: #e8e6dc;
  
  --brand: #1B365D; /* Ink Blue */
  --brand-light: #3a537d;
  
  --near-black: #141413;
  --olive: #504e49;
  --stone: #6b6a64;
  --border-soft: #e5e3d8;
  
  /* Modern Serif Stack */
  --serif: Charter, Georgia, "TsangerJinKai02", "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC", Palatino, serif;
  --mono: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, Monaco, monospace;

  /* Legacy Variable Mapping (to maintain compatibility with existing HTML classes) */
  --bg: var(--parchment);
  --bg-card: var(--ivory);
  --bg-nav: rgba(245, 244, 237, 0.95);
  --bg-code: var(--warm-sand);
  --text: var(--near-black);
  --text-s: var(--olive);
  --text-m: var(--stone);
  --accent: var(--brand);
  --accent-l: #eef2f8;
  --accent-h: var(--brand-light);
  --border: var(--border-soft);
  --shadow: 0 1px 2px rgba(27, 54, 93, 0.05);
  --radius: 4px; /* More rigid, paper-like edges */
  
  --warn-bg: #fff9db;
  --warn: #f59f00;
  --warn-t: #e67700;
  --tip-bg: #f8f0fc;
  --tip: #ae3ec9;
  --now: #b91c1c;
}

[data-theme="dark"] {
  --parchment: #1a1a1a;
  --ivory: #242424;
  --warm-sand: #2a2a2a;
  --brand: #8ba4c9;
  --brand-light: #acc2e3;
  --near-black: #e4e4e4;
  --olive: #b0b0af;
  --stone: #8c8c8c;
  --border-soft: #333;
  --bg-nav: rgba(26, 26, 26, 0.95);
  --accent-l: #1e293b;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 60px;
}

a { color: var(--accent); text-decoration: underline; text-decoration-color: rgba(27, 54, 93, 0.2); transition: 0.2s; }
a:hover { color: var(--accent-h); text-decoration-color: var(--accent-h); }

/* Nav - Refined Kami Style */
nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: var(--bg-nav);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0 40px;
  height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px;
}

.nav-brand { font-weight: 700; font-size: 16px; letter-spacing: -0.5px; }
.nav-brand a { color: var(--text); text-decoration: none; }

.nav-links { display: flex; gap: 8px; }
.nav-links a {
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-s);
  text-decoration: none;
}
.nav-links a:hover { background: var(--warm-sand); color: var(--accent); }
.nav-links a.active { background: var(--brand); color: #fff; font-weight: 600; }

.theme-btn {
  background: none; border: 1px solid var(--border);
  border-radius: 4px; padding: 4px 12px;
  cursor: pointer; font-size: 14px; color: var(--text);
}

/* Layout - The Paper Page */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 100px 40px 60px;
  background: transparent;
}

/* Hero - High Editorial Impact */
.hero { text-align: left; padding: 40px 0 60px; border-bottom: 1px solid var(--border); margin-bottom: 40px; }
.hero-badge {
  display: inline-block;
  background: var(--now); color: #fff;
  padding: 2px 10px; border-radius: 2px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 20px;
}
.hero-badge.blue { background: var(--brand); }
.hero h1 {
  font-size: 48px; font-weight: 800; line-height: 1.1; margin-bottom: 16px;
  letter-spacing: -1.5px; color: var(--brand);
}
.hero p { font-size: 18px; color: var(--text-s); line-height: 1.5; max-width: 680px; }

/* Section */
.section { margin-bottom: 60px; }
.section-title {
  font-size: 28px; font-weight: 700; margin-bottom: 24px;
  display: flex; align-items: center; gap: 12px;
  color: var(--brand);
}
.sn {
  font-family: var(--mono);
  font-size: 14px; color: var(--stone);
  opacity: 0.6;
}
.sn::after { content: "."; }

/* Card - Minimal Paper Style */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}
.card h3 { font-size: 20px; font-weight: 700; margin-bottom: 12px; color: var(--brand); }
.card h4 { font-size: 17px; font-weight: 700; margin: 20px 0 10px; }
.card p { margin-bottom: 12px; }

/* Callout - Editorial Note */
.callout {
  border-left: 2px solid var(--brand);
  background: var(--ivory);
  padding: 16px 24px;
  margin: 24px 0;
  font-style: italic;
  font-size: 15px;
}

/* Prompt Box - Mono Style */
.prompt-box {
  background: #fff;
  border: 1px solid var(--border);
  padding: 24px;
  margin: 20px 0;
  font-family: var(--serif);
  position: relative;
}
[data-theme="dark"] .prompt-box { background: #111; }
.prompt-box .q { color: var(--brand); font-weight: 600; font-size: 16px; }
.prompt-box .copy-btn {
  position: absolute; top: 12px; right: 12px;
  background: var(--bg); border: 1px solid var(--border);
  padding: 2px 8px; font-size: 11px; font-family: var(--mono);
}

/* Table - Formal Document Style */
.table-wrap { margin: 24px 0; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
th { background: var(--warm-sand); text-align: left; padding: 12px 16px; font-weight: 700; color: var(--brand); border-bottom: 2px solid var(--border); }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }

/* Tag */
.tag { padding: 2px 8px; border-radius: 2px; font-size: 12px; font-weight: 700; text-transform: uppercase; }
.tag-red { background: #fee2e2; color: #b91c1c; }
.tag-blue { background: #e0f2fe; color: #0369a1; }
.tag-gray { background: #f3f4f6; color: #4b5563; }

/* Steps */
.steps { list-style: none; counter-reset: steps; }
.steps li { counter-increment: steps; padding-left: 40px; position: relative; margin-bottom: 16px; }
.steps li::before {
  content: counter(steps);
  position: absolute; left: 0; top: 0;
  font-family: var(--mono); font-weight: 700; color: var(--brand);
  width: 24px; height: 24px; border: 1px solid var(--brand);
  display: flex; align-items: center; justify-content: center; font-size: 12px;
}

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 768px) { .grid-2 { grid-template-columns: 1fr; } }

/* Entry Cards (Homepage) */
.entry {
  display: block; background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 40px; color: var(--text-s); transition: 0.3s;
  text-decoration: none;
}
.entry:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(27, 54, 93, 0.1);
  border-color: var(--brand);
}
.entry .entry-icon { font-size: 32px; margin-bottom: 16px; display: block; filter: grayscale(1); }
.entry:hover .entry-icon { filter: none; }
.entry .entry-title { font-size: 22px; font-weight: 700; color: var(--brand); margin-bottom: 12px; }
.entry .entry-desc { font-size: 15px; line-height: 1.6; }

footer { text-align: left; padding: 60px 40px; border-top: 1px solid var(--border); color: var(--stone); font-size: 13px; font-family: var(--mono); }

@media print {
  body { background: white; font-size: 12pt; }
  .container { max-width: 100%; padding: 0; }
  nav { display: none; }
  .card { border: 1px solid #eee; box-shadow: none; break-inside: avoid; }
}
