/* ---------- Design tokens ---------- */
:root {
  --c-text: #222;
  --c-muted: #666;
  --c-bg: #fff;
  --c-page: #f6f7f9;
  --c-border: #b9b9b9;
  --c-accent: #3b6fd8;
  --c-sun: #d0021b;
  --c-sun-bg: #ffd9d9;
  --c-sat: #1a3fe0;
  --c-sat-bg: #d4f3fb;
  --c-holiday-mark: #f4a07a;
  --c-out-bg: #dcdcdc;
  --c-out-text: #a8a8a8;
  --c-emphasis: #b00000;
  --c-today: #f5b800;
  --radius: 6px;
  --gutter: 16px;
  --font: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--c-text);
  background: var(--c-page);
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Header / controls ---------- */
.site-header {
  background: var(--c-bg);
  border-bottom: 1px solid #e3e5ea;
}
@media (min-width: 860px) { .site-header { position: sticky; top: 0; z-index: 10; } }
.site-header__inner {
  max-width: 1280px; margin: 0 auto; padding: 8px var(--gutter);
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
}
.brand { font-weight: 700; color: var(--c-accent); text-decoration: none; font-size: 1.1rem; margin-right: auto; }
.controls { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.control-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.control-label { font-size: .8rem; color: var(--c-muted); }
.btn, .select {
  font: inherit; font-size: .9rem; height: 32px; padding: 0 10px;
  border: 1px solid #c8ccd4; border-radius: var(--radius); background: #fff; color: var(--c-text);
}
.btn { cursor: pointer; }
.btn:hover:not(:disabled) { background: #eef2fb; }
.btn:disabled { opacity: .4; cursor: default; }
.btn--accent { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }
.btn--accent:hover:not(:disabled) { background: #2f5cbb; }

/* ---------- Layout ---------- */
.layout { max-width: 1280px; margin: 0 auto; padding: 12px var(--gutter) 24px; }
.ads-on .layout { display: grid; gap: 16px; }
@media (min-width: 1200px) {
  .ads-on .layout { grid-template-columns: minmax(0, 1fr) 300px; }
}
.content { min-width: 0; }
.sidebar { display: none; }
@media (min-width: 1200px) { .ads-on .sidebar { display: block; } }

/* ---------- Calendar ---------- */
.calendar {
  background: var(--c-bg); border-radius: var(--radius); padding: 12px 16px 16px;
  min-height: 60vh; /* reserve space before data arrives */
}
.year-title {
  margin: 0 0 8px; font-size: 1.35rem; font-weight: 700;
  border-left: 6px solid var(--c-accent); border-bottom: 2px solid var(--c-accent);
  padding: 2px 8px;
}
.months { display: grid; gap: 12px 16px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .months { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 860px) { .months { grid-template-columns: repeat(3, 1fr); } }

.month-head { display: flex; flex-direction: column; margin: 6px 0 2px; }
.month-head h3 { margin: 0; font-size: 1.9rem; font-weight: 400; line-height: 1.1; }
.month-sub { font-size: .78rem; color: var(--c-text); }

.grid { width: 100%; border-collapse: collapse; table-layout: fixed; border: 2px solid #999; }
.grid th {
  font-weight: 400; font-size: .85rem; padding: 2px 0;
  border: 1px solid var(--c-border); border-bottom-width: 3px; border-bottom-style: double;
  background: #fff;
}
.grid th.sun { background: var(--c-sun-bg); color: var(--c-sun); }
.grid th.sat { background: var(--c-sat-bg); color: var(--c-sat); }

.day {
  border: 1px solid var(--c-border); text-align: center; vertical-align: top;
  height: 2.9em; padding: 2px 0 1px; background: #fff;
}
.day .num {
  display: inline-grid; place-items: center; width: 1.6em; height: 1.6em;
  border-radius: 50%; font-size: 1.05rem; line-height: 1;
}
.day .label { display: block; font-size: .68rem; color: #555; white-space: nowrap; letter-spacing: -.02em; }
.day .label.emphasis { color: var(--c-emphasis); }

.day.sun, .day.holiday { background: var(--c-sun-bg); }
.day.sun .num, .day.holiday .num { color: var(--c-sun); }
.day.sat { background: var(--c-sat-bg); }
.day.sat .num { color: var(--c-sat); }
.day.holiday .num { background: var(--c-holiday-mark); color: var(--c-sun); }
.day.today { box-shadow: inset 0 0 0 2px var(--c-today); }
.day.out { background: var(--c-out-bg); }
.day.out .num { color: var(--c-out-text); }

.holiday-list {
  list-style: none; margin: 4px 0 0; padding: 0;
  font-size: .75rem; color: var(--c-sun); display: flex; flex-wrap: wrap; gap: 0 10px;
}

/* ---------- Daily content (future: AI video) ---------- */
.daily { background: var(--c-bg); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px; }
.daily-heading { margin: 0 0 8px; font-size: 1rem; }
.daily-heading small { font-weight: 400; color: var(--c-muted); }
.daily-video { width: 100%; max-height: 60vh; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); }

/* ---------- Ads: collapsed when empty, fixed height when filled (no layout shift) ---------- */
.ad-slot:empty { display: none; }
.ad { display: block; overflow: hidden; text-align: center; }
.ad--middle, .ad--bottom { min-height: 280px; margin: 16px 0; }
.ad--side { min-height: 600px; }
.ad-slot--sticky { position: sticky; top: 64px; }

/* ---------- Footer ---------- */
.site-footer { text-align: center; color: var(--c-muted); padding: 16px; }

@media print {
  .site-header, .sidebar, .ad-slot, .ad, .daily, .site-footer { display: none !important; }
  body, .calendar { background: #fff; }
  .months { grid-template-columns: repeat(3, 1fr); }
}
