:root {
  --bg: #f6f5f2;
  --fg: #2a2a2a;
  --sub: #070505;
  --card-bg: #ffffff;
  --border: #ffbf00;
  --accent: #5ce75c;
  --tag-bg: #efeaff;
  --tag-fg: #40d679;
  --link: #663fc7;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #eaf6e9;
    --fg: #0b0b0b;
    --sub: #7777d5;
    --card-bg: #d8d8d8;
    --border: #0058a1;
    --accent: #9bffd4;
    --tag-bg: #ffffff;
    --tag-fg: #ff0066;
    --link: #663fc7;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0 16px 64px;
  background: var(--bg);
  color: var(--fg);
  font-family: "Hiragino Sans", "Yu Gothic UI", "Segoe UI", system-ui, sans-serif;
  line-height: 1.7;
}

header {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 0 24px;
}

header h1 {
  margin: 0 0 8px;
  font-size: 1.8rem;
}

header p {
  margin: 0;
  color: var(--sub);
}

main {
  max-width: 720px;
  margin: 0 auto;
}

nav.sections {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 32px;
}

nav.sections a {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--fg);
  text-decoration: none;
  font-size: 0.9rem;
  background: var(--card-bg);
}

nav.sections a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.back-link {
  display: inline-block;
  margin-bottom: 24px;
  color: var(--link);
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link:hover {
  text-decoration: underline;
}

section h2 {
  font-size: 1rem;
  color: var(--sub);
  font-weight: normal;
  margin-bottom: 16px;
  letter-spacing: 0.05em;
}

.month-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}

.month-select-wrap label {
  font-size: 0.9rem;
  color: var(--sub);
}

.month-select-wrap select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--card-bg);
  color: var(--fg);
  font-size: 0.9rem;
}

.entry {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 20px 24px;
  margin-bottom: 16px;
}

.entry .date {
  font-family: "Consolas", monospace;
  font-size: 0.82rem;
  color: var(--sub);
}

.entry h3 {
  margin: 4px 0 10px;
  font-size: 1.15rem;
}

.entry .body {
  white-space: pre-wrap;
  margin: 0 0 12px;
}

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

.entry .tag {
  background: var(--tag-bg);
  color: var(--tag-fg);
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 5px;
}

.empty {
  color: var(--sub);
  font-size: 0.9rem;
}

/* ---- 画像ギャラリー ---- */

.images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin: 4px 0 14px;
}

.entry-image {
  margin: 0;
}

.entry-image img {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: contain;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: zoom-in;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.entry-image img:hover {
  transform: scale(1.03);
  border-color: var(--accent);
}

/* ドット絵など小さい画像を拡大してもぼやけさせない */
.entry-image.pixel img,
.lightbox-img.pixel {
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

.entry-image figcaption {
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--sub);
  text-align: center;
}

/* ---- ライトボックス（画像の拡大表示） ---- */

#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  padding: 32px;
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  cursor: zoom-out;
}

#lightbox.open {
  display: flex;
}

body.lightbox-open {
  overflow: hidden;
}

.lightbox-stage {
  width: min(92vw, 1200px);
  height: min(82vh, 900px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  cursor: default;
}

.lightbox-caption {
  margin-top: 16px;
  color: #fff;
  font-size: 0.9rem;
  text-align: center;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3);
}
