/* ===== CSS Custom Properties ===== */
:root,
[data-theme="dark"] {
  --bg: #0a0a1a;
  --card-bg: #1a1a2e;
  --text: #e0e0e0;
  --heading: #ffffff;
  --link: #ffd700;
  --badge-bg: rgba(255, 215, 0, 0.15);
  --badge-text: #ffd700;
  --badge-border: #ffd700;
  --border: rgba(255, 215, 0, 0.15);
  --nav-bg: #0a0a1a;
  --nav-border: rgba(255, 215, 0, 0.2);
  --toggle-bg: #2a2a4e;
  --toggle-thumb: #ffd700;
  --meta-text: #999999;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text: #333333;
  --heading: #111111;
  --link: #1a1a6e;
  --badge-bg: #1a1a2e;
  --badge-text: #ffd700;
  --badge-border: #1a1a2e;
  --border: #e0e0e0;
  --nav-bg: #1a1a2e;
  --nav-border: transparent;
  --toggle-bg: #cccccc;
  --toggle-thumb: #ffd700;
  --meta-text: #777777;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition: background 0.2s, color 0.2s;
}

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

a:hover { text-decoration: underline; }

/* ===== Navigation Bar ===== */
.blog-nav {
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.blog-nav-title {
  font-family: Arial, sans-serif;
  font-weight: bold;
  font-size: 20px;
  color: #ffd700;
  text-decoration: none;
}

.blog-nav-title:hover {
  text-decoration: none;
  opacity: 0.85;
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  background: var(--toggle-bg);
  border: none;
  border-radius: 24px;
  width: 68px;
  height: 32px;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  padding: 4px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--toggle-thumb);
  position: absolute;
  transition: left 0.2s;
}

[data-theme="dark"] .toggle-thumb { left: 4px; }
[data-theme="light"] .toggle-thumb { left: 40px; }

.toggle-icon {
  font-size: 14px;
  position: absolute;
  line-height: 1;
  pointer-events: none;
}

.toggle-moon { right: 8px; }
.toggle-sun  { left: 8px; color: #ffd700; line-height: 0; }

/* ===== Page Wrapper ===== */
.page-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ===== Blog Index Hero ===== */
.blog-hero {
  text-align: center;
  margin-bottom: 48px;
}

.blog-hero h1 {
  font-family: Arial, sans-serif;
  font-weight: bold;
  font-size: clamp(32px, 5vw, 56px);
  color: var(--heading);
  margin-bottom: 12px;
}

.blog-hero p {
  font-size: 17px;
  color: var(--meta-text);
  max-width: 560px;
  margin: 0 auto;
}

/* ===== Card Grid ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

@media (max-width: 900px) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .card-grid { grid-template-columns: 1fr; } }

/* ===== Post Card ===== */
.post-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}

.post-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.card-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: var(--badge-bg);
  color: var(--badge-text);
  border: 1px solid var(--badge-border);
  border-radius: 4px;
  padding: 2px 8px;
  margin-bottom: 12px;
  align-self: flex-start;
}

.post-card h2 {
  font-family: Arial, sans-serif;
  font-weight: bold;
  font-size: 20px;
  color: var(--heading);
  margin-bottom: 8px;
  line-height: 1.3;
}

.card-meta {
  font-size: 13px;
  color: var(--meta-text);
  margin-bottom: 12px;
}

.card-excerpt {
  font-size: 15px;
  color: var(--text);
  line-height: 1.6;
  flex: 1;
  margin-bottom: 20px;
}

.read-more {
  font-weight: bold;
  font-size: 14px;
  color: var(--link);
  align-self: flex-start;
}

/* ===== Blog Footer ===== */
.blog-footer {
  text-align: center;
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--meta-text);
}

.blog-footer a {
  color: var(--link);
  font-weight: bold;
}

/* ===== Post Page ===== */
.post-back {
  display: inline-block;
  font-size: 14px;
  font-weight: bold;
  color: var(--link);
  margin-bottom: 24px;
}

.post-header { margin-bottom: 36px; }

.post-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: var(--badge-bg);
  color: var(--badge-text);
  border: 1px solid var(--badge-border);
  border-radius: 4px;
  padding: 2px 8px;
  margin-bottom: 16px;
}

.post-title {
  font-family: Arial, sans-serif;
  font-weight: bold;
  font-size: clamp(28px, 4vw, 48px);
  color: var(--heading);
  line-height: 1.2;
  margin-bottom: 16px;
}

.post-meta {
  font-size: 14px;
  color: var(--meta-text);
  margin-bottom: 36px;
}

.post-meta span { margin-right: 16px; }

/* ===== Post Body ===== */
.post-body { max-width: 720px; }

.post-body h2 {
  font-family: Arial, sans-serif;
  font-weight: bold;
  font-size: 24px;
  color: var(--heading);
  margin: 40px 0 12px;
}

.post-body h3 {
  font-family: Arial, sans-serif;
  font-weight: bold;
  font-size: 19px;
  color: var(--heading);
  margin: 28px 0 10px;
}

.post-body p { margin-bottom: 18px; }

.post-body ul,
.post-body ol {
  padding-left: 24px;
  margin-bottom: 18px;
}

.post-body li { margin-bottom: 6px; }

.post-body strong { font-weight: bold; }
.post-body em    { font-style: italic; }

.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 14px;
}

.post-body th {
  background: var(--card-bg);
  color: var(--heading);
  font-weight: bold;
  padding: 10px 14px;
  text-align: left;
  border: 1px solid var(--border);
}

.post-body td {
  padding: 8px 14px;
  border: 1px solid var(--border);
  color: var(--text);
}

.post-body tr:nth-child(even) td { background: var(--card-bg); }

.post-body-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* ===== Character Portrait (post pages) ===== */
.post-layout {
  display: flex;
  gap: 48px;
  align-items: flex-start;
}

.post-content {
  flex: 1;
  min-width: 0;
}

.char-portrait-wrap {
  flex-shrink: 0;
  position: sticky;
  top: 80px;
}

.char-portrait {
  width: 200px;
  border-radius: 10px;
  display: block;
}

@media (max-width: 820px) {
  .post-layout {
    flex-direction: column-reverse;
    gap: 24px;
  }

  .char-portrait-wrap {
    position: static;
    align-self: center;
  }

  .char-portrait {
    width: 150px;
  }
}
