/* ── Variables ────────────────────────────────────── */
:root {
  --bg: #ffffff;
  --text: #0f172a;
  --border: #e2e8f0;
  --accent: #2563eb;
  --muted: #64748b;
  --reply: #f1f5f9;
  --header: rgba(255, 255, 255, 0.85);
  --link-icon: #cbd5e1;
}

:root.dark {
  --bg: #0f172a;
  --text: #e2e8f0;
  --border: #1e293b;
  --accent: #60a5fa;
  --muted: #94a3b8;
  --reply: #1e293b;
  --header: rgba(15, 23, 42, 0.85);
  --link-icon: #475569;
}

/* ── Reset ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}

/* ── Header ─────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background .3s, border-color .3s;
}

.header-inner {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
}

header h1 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
header h1 a { color: var(--text); text-decoration: none; }

header nav { display: flex; align-items: center; gap: 12px; }

.gh-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: color .2s;
}
.gh-link:hover { color: var(--accent); }

.cal-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  transition: color .2s, border-color .2s;
  display: none;
}
.cal-toggle:hover { color: var(--accent); border-color: var(--accent); }

#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  transition: border-color .2s;
}
#theme-toggle:hover { border-color: var(--accent); }

/* ── Page layout ──────────────────────────────────── */
.page-wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  display: flex;
  gap: 40px;
  align-items: flex-start;
}

main {
  flex: 0 0 680px;
  max-width: 680px;
}

.intro {
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
  transition: border-color .3s;
}

.intro a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.intro a:hover { text-decoration: underline; }

/* ── Calendar sidebar ────────────────────────────── */
.cal-sidebar {
  flex: 0 0 220px;
  position: sticky;
  top: 70px;
}

#calendar {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  overflow: hidden;
  transition: border-color .3s;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cal-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.cal-nav {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 8px;
  font-size: 14px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .2s, border-color .2s;
}
.cal-nav:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.cal-nav:disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

.cal-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.cal-grid th {
  font-weight: 500;
  color: var(--muted);
  padding: 2px 0;
  text-align: center;
  font-size: 11px;
}

.cal-grid td {
  text-align: center;
  padding: 3px 0;
  color: var(--muted);
  font-size: 12px;
}

.cal-grid td a {
  display: inline-block;
  width: 24px;
  height: 24px;
  line-height: 24px;
  border-radius: 50%;
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  font-size: 12px;
  transition: background .2s, color .2s;
}

.cal-grid td a:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}

.cal-grid td a.active {
  color: var(--accent);
  font-weight: 600;
}

/* ── Day section ────────────────────────────────── */
.day { margin-bottom: 48px; scroll-margin-top: 80px; }
.day h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 24px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  transition: color .3s, border-color .3s;
}

/* ── Post card ──────────────────────────────────── */
.post {
  margin-bottom: 16px;
  padding: 16px 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  scroll-margin-top: 70px;
  transition: border-color .3s, background .3s;
}
.post.reply { background: var(--reply); }

.post-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
}
.post-meta time { font-weight: 500; }

.reply-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

a.reply-badge {
  text-decoration: none;
  transition: background .2s;
}
a.reply-badge:hover {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
}

.post-link {
  margin-left: auto;
  color: var(--link-icon);
  text-decoration: none;
  font-size: 12px;
  opacity: 0;
  transition: opacity .2s;
}
.post:hover .post-link { opacity: 1; }
.post-link:hover { color: var(--accent); }

.quote-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  transition: background .2s, border-color .2s;
}
.quote-link:hover {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-color: var(--accent);
}

/* ── Content ────────────────────────────────────── */
.post-content {
  font-size: 15px;
  line-height: 1.7;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.post-content p { margin-bottom: 8px; }
.post-content p:last-child { margin-bottom: 0; }
.post-content a {
  color: var(--accent);
  word-break: break-all;
}

/* ── Images ─────────────────────────────────────── */
.post-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.post-images img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* ── Calendar modal (mobile) ────────────────────── */
.cal-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.cal-modal-overlay[hidden] { display: none; }

.cal-modal-box {
  background: var(--bg);
  border-radius: 14px;
  padding: 20px;
  width: 300px;
  cursor: default;
  transition: background .3s;
}

.cal-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.cal-modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.cal-modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  line-height: 1;
}
.cal-modal-close:hover { color: var(--text); }

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 800px) {
  .cal-sidebar { display: none; }
  .cal-toggle { display: inline-flex; align-items: center; }
  .page-wrap { padding: 24px 16px 60px; }
  main { flex: none; max-width: none; }
  .page-wrap { display: block; }
  .post { padding: 12px 14px; }
  .post-content { font-size: 14px; }
  .day h2 { font-size: 18px; }
}

/* ── Print ──────────────────────────────────────── */
@media print { header, .post-link, .cal-sidebar, .cal-toggle { display: none; } }

/* ── Image lightbox ─────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.modal-overlay[hidden] { display: none; }
.modal-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
  cursor: default;
}
.modal-close {
  position: fixed;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 32px;
  color: #fff;
  cursor: pointer;
  opacity: 0.6;
  z-index: 201;
  line-height: 1;
  transition: opacity .2s;
}
.modal-close:hover { opacity: 1; }
