body {
  background: #f5f0e8;
  color: #2a2a2a;
  font-family: var(--font-mono);
  background-image: repeating-linear-gradient(
    transparent,
    transparent 27px,
    #ccc 27px,
    #ccc 28px
  );
  background-attachment: local;
}

.words-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
  background: rgba(245, 240, 232, 0.97);
  min-height: 100vh;
  position: relative;
}

.about-me {
  border-left: 3px solid #888;
  padding: 1rem 1.25rem;
  margin-bottom: 2.5rem;
  background: rgba(255,255,255,0.4);
  font-style: italic;
}

.words-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.filter-links {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
}

.filter-links a {
  opacity: 0.5;
  border-bottom: 1px solid transparent;
}
.filter-links a.active, .filter-links a:hover {
  opacity: 1;
  border-bottom-color: currentColor;
  text-decoration: none;
}

.search-form {
  display: flex;
  gap: 0.25rem;
}

.search-form input {
  background: transparent;
  border: none;
  border-bottom: 1px solid #888;
  padding: 0.2rem 0.4rem;
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  width: 160px;
}

.search-form button {
  background: none;
  border: none;
  font-size: 1rem;
  opacity: 0.6;
}
.search-form button:hover { opacity: 1; }

.article-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.article-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.5rem 0;
  border-bottom: 1px dashed #ccc;
  gap: 1rem;
}

.article-item a { flex: 1; }
.article-item a:hover { text-decoration: underline; }

.article-title { font-weight: normal; }
.article-body-preview { opacity: 0.75; }

.article-date {
  font-size: 0.78rem;
  opacity: 0.5;
  white-space: nowrap;
  flex-shrink: 0;
}

.article-detail { margin-bottom: 2rem; }
.article-detail .article-title { font-size: 1.4rem; margin-bottom: 0.5rem; }
.article-detail .article-date { display: block; margin-bottom: 1rem; }
.article-tags { font-size: 0.8rem; opacity: 0.6; margin-bottom: 1.5rem; }
.article-body { line-height: 1.9; white-space: pre-wrap; }

.pagination {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 2rem;
  font-size: 0.9rem;
}
.pagination a { opacity: 0.5; }
.pagination a.active, .pagination a:hover { opacity: 1; text-decoration: none; }

.back-link { font-size: 0.85rem; opacity: 0.6; }
.back-link:hover { opacity: 1; }

/* ── Sun lighting ──────────────────────────────────────────────────────────── */

/* CSS variable defaults — overridden by sun-lighting.js */
:root {
  --sun-shadow-x: 0px;
  --sun-shadow-y: 0px;
  --sun-shadow-blur: 0px;
  --sun-shadow-color: rgba(0,0,0,0);
  --sun-highlight-angle: 135deg;
  --sun-highlight-color: rgba(255,200,80,0);
}

/* Directional highlight overlay on the notepad container */
.sun-lighting-active .words-container::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    var(--sun-highlight-angle),
    var(--sun-highlight-color) 0%,
    transparent 60%
  );
  z-index: 0;
}

/* Lifts direct children above the ::before overlay */
.sun-lighting-active .words-container > * {
  position: relative;
  z-index: 1;
}

/* Directional text shadow on article titles */
.sun-lighting-active .article-title {
  text-shadow:
    var(--sun-shadow-x) var(--sun-shadow-y) var(--sun-shadow-blur) var(--sun-shadow-color);
}

/* ── Toggle button ───────────────────────────────────────────────────────────── */

.sun-toggle-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.12);
  background: rgba(245, 240, 232, 0.9);
  font-size: 1.125rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: var(--transition);
  filter: grayscale(1) opacity(0.5);
  z-index: 100;
  padding: 0;
}

.sun-toggle-btn:hover {
  filter: grayscale(0.5) opacity(0.75);
}
.sun-toggle-btn.is-on-day:hover  { box-shadow: 0 4px 12px rgba(138,106,48,0.3), 0 0 0 3px rgba(255,200,80,0.25); }
.sun-toggle-btn.is-on-night:hover { box-shadow: 0 4px 12px rgba(80,100,160,0.4), 0 0 0 3px rgba(150,170,220,0.2); }

.sun-toggle-btn.is-on-day {
  background: rgba(255, 240, 200, 0.95);
  border-color: rgba(138, 106, 48, 0.35);
  box-shadow: 0 2px 8px rgba(138,106,48,0.2), 0 0 0 3px rgba(255,200,80,0.15);
  filter: none;
}

.sun-toggle-btn.is-on-night {
  background: rgba(20, 25, 50, 0.9);
  border-color: rgba(150, 170, 220, 0.3);
  box-shadow: 0 2px 8px rgba(80,100,160,0.3), 0 0 0 3px rgba(150,170,220,0.1);
  filter: none;
  color: #c8d8f8;
}

/* Permission denied tooltip */
.sun-tooltip {
  position: fixed;
  bottom: calc(1.5rem + 44px + 0.5rem);
  right: 1.5rem;
  background: rgba(40,30,10,0.85);
  color: #f5f0e8;
  font-size: 0.75rem;
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  pointer-events: none;
  z-index: 101;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.article-body.handwriting {
  font-family: 'Caveat', cursive;
  font-size: 1.25rem;
  line-height: 1.8;
}

@media (max-width: 640px) {
  .words-container {
    padding: 1.5rem 1rem 3rem;
  }
  .words-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .search-form {
    width: 100%;
  }
  .search-form input {
    flex: 1;
    width: auto;
  }
}
