/* ===== Base / Tokens ===== */
:root {
  --ink: #1f2933;
  --muted: #6b7280;
  --border: #cfd6df;
  --soft-border: #e5e9ef;
  --card: #ffffff;
  --bg: #f7f8fa;
  /* Left timeline column width (desktop) */
  --timeline_col_w: 280px;
  /* Fixed filter bar clearance (layout spacing, not the control height itself) */
  --top_clearance: 92px;
  /* Fixed filter bar height (JS may override with an exact px value) */
  --filter_h: var(--top_clearance);
  /* Timeline header height (independent from filter bar) */
  --timeline_head_h: 56px;
  /* Site header height (0 when no header; set on body.has_site_header) */
  --header_h: 0;
  /* Liquid Glass base tone (slightly darker than pure white) */
  --glass-base: 232 234 238;

  /* Liquid Glass tuning knobs */
  --glass-alpha: 0.72;
  --glass-alpha-soft: 0.32;
  --glass-tint: 15 23 42;
  --glass-tint-alpha: 0.055;
  --glass-border: rgba(255, 255, 255, 0.55);
  --glass-border-soft: rgba(255, 255, 255, 0.40);
  --glass-shadow: 0 18px 55px rgba(15, 23, 42, 0.15);
  --glass-blur-filter: 18px;
  --glass-blur-panel: 26px;
}

/* ===== Base / Reset ===== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0 16px 48px;
  background:
    radial-gradient(980px 640px at 18% -10%, rgba(37, 99, 235, 0.07), transparent 56%),
    radial-gradient(760px 520px at 112% 8%, rgba(255, 255, 255, 0.22), transparent 62%),
    radial-gradient(980px 680px at 40% 120%, rgba(15, 23, 42, 0.06), transparent 58%),
    var(--bg);
  font-family: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", "Times New Roman", serif;
  color: var(--ink);
}

/* Avoid layout shift when content height toggles (detail open/close) */
html {
  scrollbar-gutter: stable;
}


/* Honor the HTML `hidden` attribute even when author CSS sets display. */
[hidden] {
  display: none !important;
}
/* Timeline drawer acts like a modal on mobile: avoid background scroll chaining */
html.is_timeline_modal,
html.is_timeline_modal body {
  overscroll-behavior: none;
}

.sr_only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

svg {
  display: block;
}

/* ===== Layout ===== */
/* When bio-header.html: header is present, reserve space and offset filter bar */
body.has_site_header {
  --header_h: 96px;
}

/* ヘッダー＝上部エリア全体。角は直角。ロゴ・メニューに上・左の余白を確保 */
body.has_site_header > div:first-child {
  border-radius: 0;
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 12px 20px 12px 24px;
  box-sizing: border-box;
}

/* ヘッダー固定・body はスクロールさせず、メイン列（.main_scroll_column）のみスクロール。フッターは最下部で表示 */
@media (min-width: 641px) {
  body.has_site_header {
    overflow: hidden;
    height: 100vh;
  }
  body.has_site_header > div:first-child {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 800;
    background: var(--card);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  }
  body.has_site_header .page_wrap {
    height: 100vh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  body.has_site_header .content_layout {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    align-items: stretch;
  }
  body.has_site_header .timeline_nav {
    margin-top: 0;
    overflow: hidden;
  }
  body.has_site_header .main_scroll_column {
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
  }
  body.has_site_header .diary_list {
    min-height: 0;
  }
  body.has_site_header .site_footer {
    margin-top: 48px;
  }
}

.page_wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding-top: calc(var(--header_h) + var(--top_clearance)); /* header + fixed filter bar */
}

.filter_bar {
  position: fixed;
  top: var(--header_h);
  left: 0;
  right: 0;
  z-index: 600;
  background: transparent;
  padding: 0 16px;
  border-bottom: none;
  box-shadow: none;
  /* Let empty area (timeline column) pass clicks through */
  pointer-events: none;
}

.filter_shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  /* Align filter content with the right column (leave timeline column blank) */
  display: grid;
  grid-template-columns: var(--timeline_col_w) minmax(0, 1fr);
  column-gap: 18px;
  pointer-events: auto;
}

.filter_shell::before {
  content: "";
  grid-column: 2;
  grid-row: 1;
  background: var(--card);
  border: 1px solid var(--soft-border);
  border-top: none;
  border-radius: 0 0 16px 16px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

/* ===== Filter (Liquid preview / Apple-ish) =====
   ON:  <div class="filter_shell" data-filter-style="liquid">
   OFF: remove the attribute (back to solid)
*/
.filter_shell[data-filter-style="liquid"] {
  background: transparent;
  border: none;
  box-shadow: none;
}

.filter_shell[data-filter-style="liquid"]::before {
  background:
    linear-gradient(180deg, rgb(var(--glass-base) / var(--glass-alpha)), rgb(var(--glass-base) / calc(var(--glass-alpha) - 0.08))),
    radial-gradient(900px 520px at 0% 0%, rgba(37, 99, 235, 0.08), transparent 55%),
    linear-gradient(180deg, rgb(var(--glass-tint) / var(--glass-tint-alpha)), transparent 70%);
  border: 1px solid var(--glass-border);
  border-top: none;
  box-shadow:
    var(--glass-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    inset 0 -1px 0 rgba(15, 23, 42, 0.05);
  -webkit-backdrop-filter: saturate(185%) blur(var(--glass-blur-filter));
  backdrop-filter: saturate(185%) blur(var(--glass-blur-filter));
}

.filter_shell[data-filter-style="liquid"] .category_row__label {
  color: rgba(17, 24, 39, 0.62);
}

.filter_shell[data-filter-style="liquid"] .category_row__control {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.55));
  box-shadow:
    0 10px 22px rgba(15, 23, 42, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.75);
  transition: box-shadow 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.filter_shell[data-filter-style="liquid"] .category_row__control:hover {
  box-shadow:
    0 14px 28px rgba(15, 23, 42, 0.13),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.filter_shell[data-filter-style="liquid"] .category_row__control:active {
  transform: translateY(1px);
}

.filter_shell[data-filter-style="liquid"] .category_row__control.is_open {
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow:
    0 14px 30px rgba(37, 99, 235, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.filter_shell[data-filter-style="liquid"] .filter_count {
  color: rgba(17, 24, 39, 0.62);
}

.filter_row {
  display: flex;
  align-items: center;
  gap: 16px;
  grid-column: 2;
  grid-row: 1;
  padding: 12px;
  /* 表示カテゴリの高さをタイムラインの年代ヘッダと揃える */
  min-height: var(--timeline_head_h);
  box-sizing: border-box;
}

.filter_row .category_selector {
  flex: 1 1 auto;
  min-width: 420px;
  max-width: 780px;
}

.filter_count {
  margin-left: auto;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
}

.diary_list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Allow `#diary_ID` hash links to land without being covered by the fixed filter bar */
.detail_card {
  scroll-margin-top: calc(var(--header_h) + var(--filter_h) + 12px);
}

/* ===== Content Layout (Timeline + List) ===== */
.content_layout {
  display: grid;
  grid-template-columns: var(--timeline_col_w) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.timeline_nav {
  position: sticky;
  top: 0;
  z-index: 10;
  /* PCでは右カラム上部に固定フィルタが乗るため、左カラムは空きが出る。
     年代パネルはその空き領域も使って最上部から開始する。 */
  margin-top: calc(-1 * var(--top_clearance));
}

.timeline_tab {
  display: none;
}

.timeline_backdrop {
  display: none;
}

.timeline_shell {
  padding: 0;
  border-radius: 20px;
  border: 1px solid var(--soft-border);
  background: var(--card);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.10);
  /* When viewport height is small, allow the whole timeline to scroll
     so the year list doesn't get pushed off-screen. */
  max-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* Hide scrollbar (keep scrolling) */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* legacy Edge/IE */
}

.timeline_shell::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.timeline_fixed {
  flex: 0 0 auto;
}

.timeline_fixed .timeline_head {
  /* タイムライン側は太くしない（フィルタの高さとは独立） */
  height: var(--timeline_head_h);
  min-height: 0;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.timeline_scroll {
  flex: 1 1 auto;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 10px 12px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.timeline_scroll::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* reuse the same liquid attribute concept as filter_shell */
.timeline_shell[data-filter-style="liquid"] {
  /* Focus tuning (brighten panel only while focused) */
  --tl-glass-alpha-top: calc(var(--glass-alpha) - 0.04);
  --tl-glass-alpha-bottom: var(--glass-alpha-soft);
  --tl-glass-tint-alpha: var(--glass-tint-alpha);
  --tl-glass-border: var(--glass-border-soft);
  --tl-glass-inner-top: 0.80;
  --tl-glass-inner-bottom: 0.06;
  background:
    linear-gradient(180deg, rgb(var(--glass-base) / var(--tl-glass-alpha-top)), rgb(var(--glass-base) / var(--tl-glass-alpha-bottom))),
    radial-gradient(1200px 600px at -10% 0%, rgba(37, 99, 235, 0.10), transparent 52%),
    radial-gradient(800px 500px at 110% 20%, rgba(255, 255, 255, 0.18), transparent 60%),
    linear-gradient(180deg, rgb(var(--glass-tint) / var(--tl-glass-tint-alpha)), transparent 70%);
  border: 1px solid var(--tl-glass-border);
  box-shadow:
    var(--glass-shadow),
    inset 0 1px 0 rgba(255, 255, 255, var(--tl-glass-inner-top)),
    inset 0 -1px 0 rgba(15, 23, 42, var(--tl-glass-inner-bottom));
  -webkit-backdrop-filter: saturate(185%) blur(var(--glass-blur-panel));
  backdrop-filter: saturate(185%) blur(var(--glass-blur-panel));
  transition: background 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.timeline_shell[data-filter-style="liquid"]:focus-within {
  /* Brighter greys when the user is interacting with the timeline */
  --tl-glass-alpha-top: 0.84;
  --tl-glass-alpha-bottom: 0.50;
  --tl-glass-tint-alpha: 0.035;
  --tl-glass-border: rgba(255, 255, 255, 0.52);
  --tl-glass-inner-top: 0.86;
  box-shadow:
    var(--glass-shadow),
    0 0 0 1px rgba(37, 99, 235, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, var(--tl-glass-inner-top)),
    inset 0 -1px 0 rgba(15, 23, 42, var(--tl-glass-inner-bottom));
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .filter_shell[data-filter-style="liquid"]::before {
    background: rgb(var(--glass-base) / 0.92);
  }

  .timeline_shell[data-filter-style="liquid"] {
    background: rgb(var(--glass-base) / 0.92);
  }
}

.timeline_head {
  padding: 6px 8px 10px;
}

.timeline_head_row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.timeline_title {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.01em;
  color: rgba(17, 24, 39, 0.88);
  margin: 0;
  line-height: 1.1;
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
}

.timeline_action {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.30);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
  color: rgba(17, 24, 39, 0.72);
  font-weight: 900;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.timeline_action:disabled {
  opacity: 0.55;
  cursor: default;
}

.timeline_meta {
  margin-top: 2px;
  font-size: 13px;
  color: rgba(17, 24, 39, 0.56);
  white-space: nowrap;
  margin-bottom: 0;
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
}


.timeline_decade_list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: none;
  overflow: visible;
  padding: 4px 0;
}

.timeline_year_list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: none;
  overflow: visible;
  padding: 4px 0 8px 28px;
  border-top: none;
}

/* When the year list is collapsed, remove the container entirely (no "ghost" panel). */
.timeline_year_list[data-collapsed="1"] {
  display: none !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.timeline_decade_btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 11px;
  border: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  touch-action: manipulation;
  text-align: left;
  font-size: 14px;
  letter-spacing: 0.01em;
  color: rgba(17, 24, 39, 0.76);
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
  white-space: nowrap;
}

.timeline_decade_btn.is_active {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.18)),
    linear-gradient(180deg, rgba(37, 99, 235, 0.24), rgba(37, 99, 235, 0.12));
  color: rgba(17, 24, 39, 0.94);
  box-shadow:
    0 10px 22px rgba(37, 99, 235, 0.16),
    0 1px 0 rgba(255, 255, 255, 0.30),
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    inset 0 0 0 1px rgba(37, 99, 235, 0.22);
}

.timeline_decade_btn:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px rgba(37, 99, 235, 0.40),
    0 12px 24px rgba(15, 23, 42, 0.12);
}

.timeline_decade_badge {
  margin-left: auto;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.26);
  border: 0;
  color: rgba(17, 24, 39, 0.56);
}

.timeline_item_icon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.18);
  border: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  color: rgba(37, 99, 235, 0.90);
  font-size: 12px;
  line-height: 1;
}

.timeline_decade_btn.is_active .timeline_item_icon,
.timeline_year.is_active .timeline_item_icon {
  background: rgba(37, 99, 235, 0.16);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.82),
    inset 0 0 0 1px rgba(37, 99, 235, 0.22);
  color: rgba(37, 99, 235, 0.98);
}

.timeline_item_chev {
  margin-left: 2px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  color: rgba(17, 24, 39, 0.42);
  transform: rotate(0deg);
  transition: transform 160ms ease, color 160ms ease;
}

.timeline_decade_btn.is_active .timeline_item_chev {
  transform: rotate(90deg);
  color: rgba(17, 24, 39, 0.60);
}

.timeline_year {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 11px;
  border: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  touch-action: manipulation;
  text-align: left;
  font-size: 14px;
  color: rgba(17, 24, 39, 0.78);
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
  white-space: nowrap;
}

.timeline_year_row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline_year_row .timeline_year {
  flex: 1 1 auto;
  width: auto;
}

.timeline_year_row :is(.timeline_year, .timeline_life_btn) {
  min-height: 36px;
}

.timeline_life_btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.20)),
    linear-gradient(180deg, rgba(37, 99, 235, 0.18), rgba(37, 99, 235, 0.08));
  box-shadow:
    0 8px 18px rgba(37, 99, 235, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.70);
  color: rgba(17, 24, 39, 0.90);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.02em;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
}

.timeline_life_btn:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px rgba(37, 99, 235, 0.40),
    0 10px 22px rgba(15, 23, 42, 0.10);
}

.timeline_item_label {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* Apply hover styles only on devices that actually support hover.
   On touch devices (e.g. iOS Safari), :hover can “stick” and sometimes makes the first tap feel unresponsive. */
@media (hover: hover) and (pointer: fine) {
  .timeline_action:hover {
    background: rgba(255, 255, 255, 0.42);
  }

  .timeline_decade_btn:hover {
    background: rgba(255, 255, 255, 0.22);
  }

  .timeline_year:hover {
    background: rgba(255, 255, 255, 0.22);
  }

  .timeline_life_btn:hover {
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.26)),
      linear-gradient(180deg, rgba(37, 99, 235, 0.22), rgba(37, 99, 235, 0.10));
  }
}

.timeline_year.is_active {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.18)),
    linear-gradient(180deg, rgba(37, 99, 235, 0.24), rgba(37, 99, 235, 0.12));
  color: rgba(17, 24, 39, 0.94);
  box-shadow:
    0 10px 22px rgba(37, 99, 235, 0.16),
    0 1px 0 rgba(255, 255, 255, 0.30),
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    inset 0 0 0 1px rgba(37, 99, 235, 0.22);
}

.timeline_year:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px rgba(37, 99, 235, 0.40),
    0 12px 24px rgba(15, 23, 42, 0.12);
}

.timeline_year:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.timeline_year:disabled .timeline_item_icon {
  color: rgba(107, 114, 128, 0.55);
}

.timeline_decade_btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.timeline_decade_btn:disabled:hover {
  background: transparent;
}

.timeline_decade_btn:disabled .timeline_item_icon {
  color: rgba(107, 114, 128, 0.55);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.timeline_decade_btn:disabled .timeline_decade_badge {
  background: rgba(255, 255, 255, 0.18);
  color: rgba(17, 24, 39, 0.44);
}

.year_anchor {
  height: 0;
  scroll-margin-top: calc(var(--top_clearance) + 14px);
}

/* ===== Category Selector (merged from tag-sample2) ===== */
.category_selector {
  position: relative;
  width: 100%;
  min-width: 0;
}

.category_row {
  display: grid;
  grid-template-columns: minmax(min-content, 100px) 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.category_row__label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  min-width: 0;
  overflow: visible;
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
}

.category_row__control {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
  overflow: hidden;
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
}

.category_row__control:focus,
.category_row__control:focus-visible {
  outline: none;
}

.category_row__control.is_open {
  border-color: #2563eb;
  box-shadow: none;
  position: relative;
  z-index: 1000;
}

.category_row__left {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  line-height: 1.3;
}

.category_row__right {
  flex: 0 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  line-height: 1.3;
}

.category_row__icon {
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 14px;
  color: var(--muted);
  margin-left: 2px;
}

.category_row__count {
  display: none;
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
  z-index: 998;
}

.backdrop.is_open {
  opacity: 1;
  pointer-events: auto;
}

.category_panel {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  border: 1px solid var(--soft-border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14);
  z-index: 999;
  overflow: hidden;
  max-height: calc(100dvh - 24px);
}

.category_panel.is_open {
  display: block;
  border-color: #2563eb;
}

.category_panel__header {
  padding: 12px;
  border-bottom: 1px solid var(--soft-border);
}

.category_panel__title {
  font-size: 13px;
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
}

.category_panel__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
}

.btn--ghost {
  color: #374151;
}

.btn--primary {
  border-color: #2563eb;
  background: #2563eb;
  color: #fff;
}

.cat_chip_area {
  padding: 10px 12px 12px;
}

.cat_chip_grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-height: none;
  overflow: auto;
  padding-right: 2px;
}

.cat_chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 10px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  cursor: pointer;
  user-select: none;
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
}

.cat_chip__dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #9ca3af;
  flex: 0 0 auto;
}

.cat_chip__label {
  font-size: 13px;
  line-height: 1.2;
}

.cat_chip__count {
  font-size: 12px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  color: #6b7280;
}

.cat_chip.is_on {
  border-color: rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}

.cat_chip.is_on .cat_chip__dot {
  background: #2563eb;
}

@media (max-width: 640px) {
  .category_row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .category_row__control {
    padding: 12px 12px;
  }

  .cat_chip_grid {
    gap: 8px;
  }

  .cat_chip {
    padding: 11px 10px 11px 12px;
  }
}

.detail_card {
  position: relative;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 32px 36px 40px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
}

.detail_blocks {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail_block {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--soft-border);
}

.detail_block:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.block_date {
  padding-bottom: 0;
  border-bottom: none;
}

.block_main {
  padding-top: 2px;
  margin-top: -6px;
}

/* ===== Header ===== */
.date_row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.block_date .date_label {
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.02em;
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
  line-height: 1.05;
}

.meta_row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
  justify-content: flex-end;
  align-items: center;
  min-width: 220px;
}

.meta_tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
}

.meta_tag_icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
}

.title_row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 12px;
  row-gap: 6px;
  align-items: end;
}

.detail_title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.2;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.btn_minor {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  justify-self: end;
}

.btn_icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  line-height: 1;
  font-size: 12px;
  color: var(--muted);
}

.btn_minor[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Context / Chips ===== */
.context_section {
  margin-top: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px 18px;
}

.context_dl {
  margin: 0;
}

.context_dl dt,
.context_dl dd {
  margin: 0;
}

.context_subsection + .context_subsection {
  margin-top: 0;
}

.context_meta {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
}

/* 人物/場所はスペース優先: なるべく1行、溢れたら横スクロール */
.context_meta--singleline {
  margin-top: 0;
}

.context_meta--singleline .context_item {
  flex: 1 1 auto;
  min-width: 0;
}

.context_meta--singleline .chip_row {
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: nowrap;
  overflow: hidden;
  gap: 6px;
}

.context_item--ellipsis {
  width: 100%;
  min-width: 0;
}

/* 人物/場所: 独立した四角チップ + 末尾… */
.chip_row--ellipsis .chip {
  flex: 0 0 auto;
  max-width: none;
}

.chip_box {
  border-radius: 6px;
}

.chip_row--ellipsis .chip_text {
  display: block;
  white-space: nowrap;
}

.chip_ellipsis {
  flex: 0 0 auto;
}

.context_item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.context_item svg {
  width: 16px;
  height: 16px;
}

.context_icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  line-height: 1;
  font-size: 13px;
  color: var(--muted);
}

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

.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--soft-border);
  background: var(--card);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  min-width: 0;
}

.chip_dense {
  padding: 4px 10px;
  font-size: 11px;
}

.chip_text {
  min-width: 0;
}

.chip_clickable {
  cursor: pointer;
}

.chip_clickable:hover {
  border-color: var(--border);
}

.chip_clickable:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.8);
  outline-offset: 2px;
}

/* ===== Popup Modal ===== */
.modal_overlay {
  position: fixed;
  inset: 0;
  padding: 18px 12px;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal_overlay[data-open="true"] {
  display: flex;
}

.modal_panel {
  width: min(860px, 100%);
  max-height: min(78vh, 820px);
  overflow: hidden;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 22px 80px rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
}

.modal_header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--soft-border);
  gap: 10px;
}

.modal_title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--ink);
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal_close {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 10px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
}

.modal_body {
  padding: 14px 16px 18px;
  overflow: auto;
}

.modal_body :is(h1, h2, h3, h4, h5) {
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
}

.modal_body p {
  margin: 0 0 12px;
  line-height: 1.9;
}

/* ===== Diary body / Drawer ===== */
.diary_text {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.section_heading {
  margin: 14px 0 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.4;
  color: var(--muted);
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
}

.sub_heading {
  margin: 14px 0 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.4;
  color: var(--muted);
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
}

.diary_text p {
  margin: 0;
  font-size: 15px;
  line-height: 1.9;
}

/* 本文内の見出し的要素（将来の拡張用） */
.diary_text h2,
.diary_text h3,
.diary_text h4 {
  margin: 0;
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
  letter-spacing: 0.04em;
  line-height: 1.4;
}

.diary_text h2 {
  font-size: 16px;
  font-weight: 800;
  margin-top: 10px;
}

.diary_text h3 {
  font-size: 15px;
  font-weight: 800;
  margin-top: 10px;
}

.diary_text h4 {
  font-size: 14px;
  font-weight: 800;
  margin-top: 8px;
}

.detail_panel {
  margin-top: 14px;
  display: none;
}

.detail_panel[data-open="true"] {
  display: block;
}

.detail_drawer {
  margin-top: 8px;
  border: 1px solid var(--soft-border);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink);
  background: #fcfcfd;
}

.detail_drawer p {
  margin: 0;
}

/* ===== Photos (main) ===== */
.photo_section {
  margin-top: 12px;
}

.photo_divider {
  border: none;
  border-top: 1px solid var(--soft-border);
  margin: 14px 0 12px;
}

.photo_carousel {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  gap: 10px;
  align-items: center;
}

.photo_stage--carousel {
  max-width: none;
  margin: 0;
  cursor: zoom-in;
}

.photo_nav {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
}

.photo_nav[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.photo_controls {
  margin-top: 10px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.photo_counter {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.06em;
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
}

.photo_hint {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* Photo popup modal */
.photo_modal_overlay {
  position: fixed;
  inset: 0;
  padding: 18px 12px;
  background: rgba(15, 23, 42, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.photo_modal_overlay[data-open="true"] {
  display: flex;
}

.photo_modal_panel {
  width: min(980px, 100%);
  max-height: min(86vh, 920px);
  overflow: hidden;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 22px 80px rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
}

.photo_modal_header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--soft-border);
  gap: 10px;
}

.photo_modal_title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--ink);
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo_modal_close {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 10px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
}

.photo_modal_body {
  padding: 12px 12px 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.photo_modal_viewport {
  flex: 1 1 auto;
  min-height: 220px;
  background: #0f172a;
  border: 2px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  position: relative;
}

.photo_modal_img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transform-origin: center;
  cursor: grab;
}

.photo_modal_img:active {
  cursor: grabbing;
}

.photo_modal_toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.photo_modal_status {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
}

.photo_stage {
  max-width: 760px;
  margin: 0 auto;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid var(--border);
  background: #0f172a;
}

.photo_stage img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

.photo_caption {
  margin-top: 14px;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: center;
}

/* ===== Related ===== */
.related_section {
  border-top: none;
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.related_groups {
  margin-top: 10px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.related_groups dt,
.related_groups dd {
  margin: 0;
}

.related_divider {
  border: none;
  border-top: 1px solid var(--soft-border);
  margin: 12px 0 10px;
}

.reference_actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.reference_panel {
  display: none;
}

.reference_panel[data-open="true"] {
  display: block;
}

.reference_drawer {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reference_item {
  border: 2px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: #0f172a;
}

.reference_item :is(img, video) {
  width: 100%;
  height: auto;
  display: block;
}

.reference_iframe_wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

.reference_iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.reference_link {
  display: block;
  padding: 12px;
  background: var(--card);
  color: var(--ink);
  text-decoration: underline;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference_caption {
  margin: 0;
  padding: 10px 12px;
  background: var(--card);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.related_group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  min-height: 24px;
  width: 100%;
  min-width: 0;
}

.related_value {
  display: flex;
  align-items: center;
  flex: 1 1 220px;
  flex-wrap: wrap;
  gap: 3px 5px;
  min-width: 0;
}

.related_first {
  display: inline-flex;
  min-width: 0;
}

.related_lead {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-width: 0;
}

.related_label {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  flex-shrink: 0;
  height: 24px;
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
}

.related_icon {
  display: inline-flex;
  color: var(--muted);
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  line-height: 1;
  font-size: 14px;
}

.related_value .chip_row {
  flex: 1 1 220px;
  display: flex;
  flex-wrap: wrap;
  gap: 3px 5px;
  min-width: 0;
  justify-content: flex-start;
}

/* Related chips: allow shrinking + ellipsis without breaking layout */
.related_section .chip {
  max-width: 100%;
}

.related_section .chip_text {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.related_section .chip_dense {
  height: 24px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  :root {
    --top_clearance: 88px;
    --timeline_col_w: 230px;
  }

  body {
    padding: 0 14px 40px;
  }

  .filter_bar {
    padding: 0 14px;
  }

  .filter_row {
    gap: 12px;
  }

  .filter_shell {
    column-gap: 14px;
  }

  /* Tablet: keep timeline vertical (no horizontal scroll) */
  .content_layout {
    gap: 14px;
  }

  .detail_card {
    padding: 28px 22px 32px;
  }

  .detail_title {
    font-size: 18px;
  }
}

@media (max-width: 640px) {
  :root {
    --top_clearance: 60px;
  }

  /* スマホでもヘッダー固定・イベントボックスのみスクロール */
  body.has_site_header {
    overflow: hidden;
    height: 100dvh;
  }
  body.has_site_header > div:first-child {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 800;
    background: var(--card);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  }
  body.has_site_header .page_wrap {
    height: 100dvh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  body.has_site_header .content_layout {
    flex: 1 1 0;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  body.has_site_header .main_scroll_column {
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    min-width: 0;
    flex: 1 1 0;
    width: 100%;
    -webkit-overflow-scrolling: touch;
  }
  body.has_site_header .diary_list {
    min-height: 0;
    min-width: 0;
    width: 100%;
  }
  body.has_site_header .site_footer {
    margin-top: 36px;
  }

  body {
    padding: 0 12px 36px;
  }

  .filter_bar {
    padding: 0 12px;
  }

  .filter_shell {
    display: block;
    padding: 10px;
    background: var(--card);
    border: 1px solid var(--soft-border);
    border-top: none;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.07);
  }

  .filter_shell::before {
    content: none;
  }

  .filter_shell[data-filter-style="liquid"] {
    /* slightly lighter/"thinner" panel */
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-top: none;
    box-shadow:
      0 14px 40px rgba(15, 23, 42, 0.12),
      inset 0 1px 0 rgba(255, 255, 255, 0.7);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    backdrop-filter: saturate(180%) blur(16px);
  }

  .filter_row {
    grid-column: auto;
    grid-row: auto;
    padding: 0;
    gap: 10px;
  }

  .filter_row .category_selector {
    min-width: 0;
  }

  /* Mobile: make the selector more compact; ラベル「表示カテゴリ」が欠けないよう min-content を許容 */
  .category_row {
    grid-template-columns: minmax(min-content, 72px) 1fr;
    gap: 10px;
  }

  .category_row__label {
    display: block;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: rgba(17, 24, 39, 0.62);
    font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
      BlinkMacSystemFont, sans-serif;
  }

  /* Mobile: shorten selector summary text */
  .category_row__right {
    display: none;
  }

  .category_row__control {
    padding: 9px 12px;
    min-height: 34px;
    border-radius: 999px;
  }

  .category_row__left,
  .category_row__right {
    font-size: 12px;
  }

  /* Restore right-end visible count (separate from selected-category count) */
  .category_row__count {
    display: none;
  }

  .filter_count {
    display: block;
    margin-left: auto;
    font-size: 12px;
  }

  /* Smartphone: timeline becomes an off-canvas drawer with a visible tab */
  .content_layout {
    grid-template-columns: 1fr;
    min-width: 0;
    /* Shared timeline tokens (tab is a sibling of nav, so vars must live here) */
    /* Handle color (category blue) */
    --tl-tab: 37 99 235;
    /* Panel accent follows the handle for a cohesive liquid tint */
    --tl-accent: var(--tl-tab);
    --tl-accent-ink: rgb(var(--tl-accent) / 0.86);
    --tl-accent-soft: rgb(var(--tl-accent) / 0.18);
    --tl-peek: 10px; /* how much the drawer peeks when closed */
    /* Handle size (a bit wider for easier grabbing) */
    --tl-tab-w: 30px;
    --tl-tab-h: 108px;
    /* How much the tab is buried into the left screen edge (≈1/3 of width) */
    --tl-tab-bury: 10px;
  }

  .timeline_nav {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    width: min(320px, 86vw);
    z-index: 900;
    margin-top: 0;
    /* IMPORTANT: Don't transform this container.
       A transformed ancestor breaks viewport-fixed children (tab/handle). */
    transform: none;
    /* Closed: don't block taps on the page. */
    pointer-events: none;
  }

  .timeline_nav.is_open {
    transform: none;
    pointer-events: auto;
  }

  .timeline_tab {
    display: inline-flex;
    /* Thin handle at mid screen */
    position: fixed;
    top: 46dvh;
    /* Slightly off-screen so it feels embedded */
    left: calc(env(safe-area-inset-left) - var(--tl-tab-bury));
    transform: translateY(-50%);
    width: var(--tl-tab-w);
    height: var(--tl-tab-h);
    /* Keep the label 100% visible even when the tab is buried */
    padding-left: var(--tl-tab-bury);
    padding-right: 2px;
    border-radius: 999px;
    border: 2px solid rgb(var(--tl-tab) / 0.98);
    /* Category-blue handle + black text */
    background:
      linear-gradient(180deg, rgba(236, 252, 255, 0.92), rgba(210, 246, 255, 0.72)),
      linear-gradient(180deg, rgb(var(--tl-tab) / 0.62), rgb(var(--tl-tab) / 0.26));
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    box-shadow:
      0 20px 46px rgba(15, 23, 42, 0.26),
      0 0 0 1px rgb(var(--tl-tab) / 0.30),
      0 0 30px rgb(var(--tl-tab) / 0.28),
      inset 0 1px 0 rgba(255, 255, 255, 0.92);
    color: rgba(17, 24, 39, 0.94);
    text-shadow:
      0 1px 0 rgba(255, 255, 255, 0.70),
      0 0 6px rgb(var(--tl-tab) / 0.38);
    font-weight: 900;
    letter-spacing: 0.08em;
    font-size: 12px;
    font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", system-ui, -apple-system,
      BlinkMacSystemFont, sans-serif;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    pointer-events: auto;
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
    /* Must stay above the peeking drawer strip */
    z-index: 920;
    /* Make the pulse clearly noticeable (still soft, but visible) */
    animation: timeline_tab_glow 1.8s ease-in-out infinite;
    filter: saturate(1.04) contrast(1.04);
  }

  @keyframes timeline_tab_glow {
    0%,
    100% {
      box-shadow:
        0 20px 46px rgba(15, 23, 42, 0.26),
        0 0 0 1px rgb(var(--tl-tab) / 0.28),
        0 0 20px rgb(var(--tl-tab) / 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.90);
      border-color: rgb(var(--tl-tab) / 0.82);
      filter: saturate(1.02) contrast(1.02);
    }
    50% {
      box-shadow:
        0 22px 50px rgba(15, 23, 42, 0.28),
        0 0 0 1px rgb(var(--tl-tab) / 0.44),
        0 0 72px rgb(var(--tl-tab) / 0.70),
        inset 0 1px 0 rgba(255, 255, 255, 0.92);
      border-color: rgb(var(--tl-tab) / 0.98);
      filter: saturate(1.28) contrast(1.12);
    }
  }

  .timeline_tab::after {
    content: "";
    position: absolute;
    inset: 10px 7px;
    border-radius: 999px;
    background: rgb(var(--tl-tab) / 0.26);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
    pointer-events: none;
    animation: timeline_tab_inner 1.8s ease-in-out infinite;
  }

  @keyframes timeline_tab_inner {
    0%,
    100% {
      background: rgb(var(--tl-accent) / 0.22);
    }
    50% {
      background: rgb(var(--tl-tab) / 0.62);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .timeline_tab,
    .timeline_tab::after {
      animation: none;
    }
  }

  .timeline_tab::before {
    content: none;
  }

  .timeline_tab:active {
    transform: translateY(1px);
  }

  /* When the drawer is open, the tab isn't needed (backdrop tap / swipe close). */
  .timeline_tab.is_open {
    opacity: 0;
    pointer-events: none;
  }

  .timeline_backdrop {
    display: block;
    position: fixed;
    inset: 0;
    /* Dim the page behind the drawer (modal feel) */
    background: rgba(0, 0, 0, 0.14);
    opacity: 0;
    pointer-events: none;
    transition:
      opacity 260ms cubic-bezier(0.35, 0, 0.2, 1),
      background-color 260ms cubic-bezier(0.35, 0, 0.2, 1);
    /* Must stay behind the timeline panel */
    z-index: 890;
  }

  /* Backdrop: thin at the beginning of open, then deepen */
  .timeline_nav.is_opening .timeline_backdrop {
    background: rgba(0, 0, 0, 0.14);
  }

  .timeline_nav.is_open .timeline_backdrop {
    opacity: 1;
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.32);
  }

  .timeline_shell {
    /* Focus tuning (brighten drawer while focused) */
    /* Base layer is intentionally a bit thicker than PC so content behind doesn't show through too much */
    --tl-drawer-alpha-top: 0.90;
    --tl-drawer-alpha-bottom: 0.74;
    --tl-drawer-tint-alpha: 0.032;
    --tl-drawer-border: rgba(255, 255, 255, 0.34);
    --tl-drawer-inner-top: 0.78;
    --tl-drawer-inner-blue: 0.10;
    position: relative;
    margin-top: 0;
    height: 100dvh;
    border-radius: 0 20px 20px 0;
    overflow: hidden;
    overscroll-behavior: contain;
    z-index: 891;
    /* No inner top clearance; header stays fixed. */
    padding: 0;
    border-top: none;

    /* Liquid panel */
    background:
      linear-gradient(180deg, rgb(var(--glass-base) / var(--tl-drawer-alpha-top)), rgb(var(--glass-base) / var(--tl-drawer-alpha-bottom))),
      radial-gradient(900px 600px at 0% 0%, rgb(var(--tl-accent) / 0.06), transparent 58%),
      radial-gradient(900px 600px at 100% 20%, rgba(255, 255, 255, 0.16), transparent 60%),
      linear-gradient(180deg, rgb(var(--glass-tint) / var(--tl-drawer-tint-alpha)), transparent 70%);
    border: 1px solid var(--tl-drawer-border);
    box-shadow:
      0 26px 70px rgba(15, 23, 42, 0.24),
      0 0 0 1px rgb(var(--tl-accent) / var(--tl-drawer-inner-blue)),
      inset 0 1px 0 rgba(255, 255, 255, var(--tl-drawer-inner-top));
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    backdrop-filter: saturate(180%) blur(24px);

    /* Off-canvas slide (closed shows a small peek) */
    transform: translateX(calc(-100% + var(--tl-peek)));
    transition: transform 220ms cubic-bezier(0.2, 0.9, 0.2, 1);
    will-change: opacity, transform;
    /* Closed: don't intercept taps */
    pointer-events: none;
  }

  .timeline_nav.is_open .timeline_shell:focus-within {
    /* Brighter greys while interacting (keyboard/touch focus) */
    --tl-drawer-alpha-top: 0.92;
    --tl-drawer-alpha-bottom: 0.80;
    --tl-drawer-tint-alpha: 0.026;
    --tl-drawer-border: rgba(255, 255, 255, 0.44);
    --tl-drawer-inner-top: 0.84;
    --tl-drawer-inner-blue: 0.14;
    box-shadow:
      0 28px 78px rgba(15, 23, 42, 0.22),
      0 0 0 1px rgb(var(--tl-accent) / var(--tl-drawer-inner-blue)),
      0 0 0 2px rgba(255, 255, 255, 0.12),
      inset 0 1px 0 rgba(255, 255, 255, var(--tl-drawer-inner-top));
  }

  .timeline_fixed {
    flex: 0 0 auto;
  }

  .timeline_scroll {
    flex: 1 1 auto;
    overflow: auto;
    padding: 8px 12px 16px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  /* スクロール時にタップと誤認識されないよう、縦パンを優先 */
  .timeline_scroll .timeline_decade_btn,
  .timeline_scroll .timeline_year {
    touch-action: pan-y;
  }

  .timeline_nav.is_open .timeline_shell {
    transform: translateX(0);
    pointer-events: auto;
  }

  /* Header pinned to the top inside the drawer */
  .timeline_head {
    position: sticky;
    top: 0;
    z-index: 2;
    height: var(--timeline_head_h);
    padding: 8px 12px;
    margin: 0 0 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.70), rgba(255, 255, 255, 0.52));
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    backdrop-filter: saturate(180%) blur(16px);
  }

  .timeline_fixed .timeline_head {
    height: var(--timeline_head_h);
  }

  .timeline_title {
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 0.01em;
    color: rgba(17, 24, 39, 0.90);
  }

  .timeline_action {
    border-color: rgba(255, 255, 255, 0.40);
    background: rgba(255, 255, 255, 0.28);
  }

  .timeline_meta {
    font-size: 12px;
    color: rgba(17, 24, 39, 0.56);
  }

  .timeline_decade_list {
    padding: 8px 6px 10px;
  }

  /* Year list is inserted under the selected decade button; style it as a nested panel */
  .timeline_year_list {
    border-top: none;
    margin: 6px 0 10px 8px;
    padding: 6px 6px 10px 28px;
    border-left: none;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
  }

  .timeline_decade_btn {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
  }

  .timeline_decade_btn.is_active {
    background:
      linear-gradient(180deg, rgb(var(--tl-accent) / 0.16), rgb(var(--tl-accent) / 0.10)),
      rgba(255, 255, 255, 0.14);
    color: rgba(17, 24, 39, 0.92);
  }

  .timeline_decade_badge {
    background: rgba(255, 255, 255, 0.24);
    border-color: transparent;
    color: rgba(17, 24, 39, 0.56);
  }

  .timeline_decade_btn.is_active .timeline_decade_badge {
    background: rgba(255, 255, 255, 0.34);
    color: rgba(17, 24, 39, 0.64);
  }

  .timeline_year {
    background: transparent;
    border-color: transparent;
  }

  .timeline_year.is_active {
    background:
      linear-gradient(180deg, rgb(var(--tl-accent) / 0.16), rgb(var(--tl-accent) / 0.10)),
      rgba(255, 255, 255, 0.14);
    color: rgba(17, 24, 39, 0.92);
  }

  .timeline_decade_list,
  .timeline_year_list {
    max-height: none;
  }

  .detail_card {
    padding: 16px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    box-sizing: border-box;
    word-break: break-word;
  }

  .detail_card img,
  .detail_card video,
  .detail_card iframe {
    max-width: 100%;
    height: auto;
  }

  .detail_card .photo_stage,
  .detail_card .photo_carousel,
  .detail_card .reference_drawer {
    max-width: 100%;
    overflow: hidden;
  }

  .diary_list {
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  .detail_title {
    font-size: 18px;
  }

  /* Smartphone: meta row goes above date when wrapped */
  .date_row {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 2px;
  }

  .block_date .date_label {
    font-size: 14px;
  }

  .meta_row {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
    min-width: auto;
    gap: 6px;
  }

  .block_main {
    margin-top: 10px;
  }

  .title_row {
    row-gap: 4px;
    grid-template-columns: 1fr;
    align-items: start;
  }

  .title_row .btn_minor {
    justify-self: start;
  }

  .context_section {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .diary_list {
    gap: 14px;
  }

  .filter_bar {
    padding: 0 12px;
  }

  .filter_shell {
    padding: 8px;
    background: var(--card);
    border: 1px solid var(--soft-border);
    border-top: none;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.07);
  }

  .filter_row {
    flex-wrap: nowrap;
    gap: 8px;
  }

  .filter_row .category_selector {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
  }

  /* Smartphone: keep "表示カテゴリ" on a single row; ラベルが欠けないよう min-content を許容 */
  .filter_shell .category_row {
    grid-template-columns: minmax(min-content, 68px) 1fr;
    gap: 8px;
  }

  .filter_shell .category_row__control {
    padding: 8px 12px;
    min-height: 32px;
    border-radius: 999px;
  }

  .filter_count {
    flex: 0 0 auto;
    text-align: right;
    font-size: 11px;
  }

  .photo_carousel {
    padding: 0;
    gap: 8px;
  }

  .photo_nav {
    background: var(--card);
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }
  .photo_controls {
    gap: 8px;
  }

  .photo_modal_overlay {
    padding: 12px 10px;
  }

  .photo_modal_panel {
    max-height: 92vh;
    border-radius: 14px;
  }

  .photo_modal_viewport {
    min-height: 180px;
  }

  .related_group {
    align-items: flex-start;
    gap: 4px 6px;
  }

  /* Smartphone: first line = label + first chip, remaining chips start from left edge */
  .related_group .chip_row {
    flex-basis: 100%;
  }

  /* First line (label + first chip) must never overflow */
  .related_lead {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    width: 100%;
    min-width: 0;
  }

  .related_lead .chip {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
  }

  .related_section .chip_dense {
    max-width: 100%;
  }

  .related_section .chip_text {
    max-width: 100%;
  }

  .photo_stage {
    border-radius: 14px;
  }
}

/* ===== 遠距離ジャンプ時の loading overlay ===== */
.bio-timeline-loading {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(247, 248, 250, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  pointer-events: none;
}

.bio-timeline-loading.is_active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.bio-timeline-loading__spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--soft-border);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: bio-timeline-spin 0.6s linear infinite;
}

@keyframes bio-timeline-spin {
  to {
    transform: rotate(360deg);
  }
}
