:root {
  color-scheme: light;
  --bg: #ededed;
  --panel: #fff;
  --text: #222;
  --muted: #666;
  --line: #ccc;
  --link: #1769aa;
  --youtube: #c00;
  font-family: Arial, "Noto Sans JP", sans-serif;
  font-size: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { display: flex; min-height: 100vh; flex-direction: column; margin: 0; background: var(--bg); color: var(--text); line-height: 1.35; }
a { color: var(--link); }
button, input, textarea { font: inherit; }
[hidden], .video-card[hidden] { display: none !important; }

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

.site-header { background: #292929; color: #fff; border-bottom: 3px solid #65429a; }
.site-header__inner, .site-layout, .site-footer__inner {
  width: min(1280px, calc(100% - 16px));
  margin-inline: auto;
}
.site-header__inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}
.brand { margin: 0; font-size: 1.35rem; line-height: 1.2; }
.brand a { color: #fff; text-decoration: none; }
.brand small, .site-header__inner > span { color: #bbb; font-size: .75rem; font-weight: normal; }
.nav-toggle { display: none; padding: 2px 6px; border: 1px solid #777; background: #444; color: #fff; }
.site-layout { display: grid; flex: 1 0 auto; grid-template-columns: 190px minmax(0, 1fr); align-items: stretch; background: #fff; }
.sidebar { padding: 6px; border-right: 1px solid #bbb; background: #2e2e2e; color: #ddd; }
.site-search { flex: 1 1 520px; max-width: 680px; margin-left: auto; }
.site-search div { display: flex; }
.site-search input { min-width: 0; width: 100%; height: 29px; padding: 2px 6px; border: 1px solid #777; }
.site-search button { display: grid; flex: 0 0 32px; width: 32px; place-items: center; padding: 0; border: 1px solid #777; border-left: 0; background: #555; color: #fff; cursor: pointer; }
.site-search button svg { display: block; fill: currentColor; }
.nav-list { margin: 0; padding: 0; list-style: none; }
.nav-list li { border-bottom: 1px solid #444; }
.nav-list a { display: block; padding: 4px 6px; color: #ddd; text-decoration: none; }
.nav-list a:hover, .nav-list li.active > a { background: #65429a; color: #fff; }
.nav-list--sub a { padding-left: 12px; font-size: .9rem; }
.nav-group { margin-top: 5px; border: 1px solid #484848; background: #292929; }
.nav-group summary { padding: 4px 6px; color: #ccc; background: #242424; cursor: pointer; font-size: .85rem; font-weight: bold; }
.nav-group summary:hover, .nav-group[open] summary { background: #383838; color: #fff; }
.nav-group[open] summary { border-bottom: 1px solid #484848; }
.nav-group .nav-list li:last-child { border-bottom: 0; }
.main-content { min-width: 0; padding: 6px; }
.page-title { display: flex; align-items: baseline; gap: 8px; margin: -6px -6px 6px; padding: 4px 7px; border-bottom: 1px solid #bbb; background: #f1f1f1; }
.page-title h1 { min-width: 0; margin: 0; font-size: 1rem; }
.page-title h1 small { margin-left: 6px; color: var(--muted); font-size: .75rem; font-weight: normal; }
.page-title .load-status { flex: none; margin-left: auto; font-size: .75rem; white-space: nowrap; }

.toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  padding: 5px 7px;
  border: 1px solid #bbb;
  background: #f8f8f8;
}
.search-field { display: grid; grid-template-columns: auto minmax(0, 520px); align-items: center; gap: 6px; }
.search-field span { font-weight: bold; }
.search-field input { height: 30px; padding: 3px 7px; border: 1px solid #999; background: #fff; }
.result-count { margin: 0; color: var(--muted); white-space: nowrap; }
.view-controls { display: flex; gap: 3px; }
.view-controls button { padding: 2px 7px; border: 1px solid #999; background: #eee; color: #333; cursor: pointer; }
.view-controls button.active { border-color: #542d91; background: #65429a; color: #fff; }

.video-list { border: 1px solid #bbb; background: var(--panel); }
.video-card {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 8px;
  padding: 6px;
  border-bottom: 1px solid var(--line);
  content-visibility: auto;
  contain-intrinsic-size: auto 110px;
}
.video-card:last-child { border-bottom: 0; }
.thumbnail-link { align-self: start; text-decoration: none; }
.thumbnail {
  display: block;
  width: 160px;
  height: 90px;
  min-width: 120px;
  min-height: 70px;
  background: #26232d;
  object-fit: cover;
}
.thumbnail-action { display: block; margin-top: 2px; color: var(--youtube); font-size: .75rem; text-align: center; }
.video-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; color: var(--muted); font-size: .78rem; }
.video-title { margin: 1px 0 2px; font-size: 1rem; font-weight: normal; line-height: 1.3; }
.tags { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 3px; }
.tag { padding: 0 4px; border: 1px solid #bbb; background: #eee; color: #555; font-size: .72rem; }

.toc { border-top: 1px solid #ddd; }
.toc summary { padding: 3px 1px 2px; cursor: pointer; color: #542d91; font-weight: bold; }
.toc-list { margin: 0; padding: 0; list-style: none; }
.toc-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 3px 6px;
  padding: 1px 1px 0;
  border-top: 1px dotted #ddd;
}
.segment-link { display: grid; grid-template-columns: 4.3rem minmax(0, 1fr); gap: 4px; line-height: 1.25; text-decoration: none; }
.segment-time { color: var(--youtube); font-variant-numeric: tabular-nums; font-weight: bold; }
.segment-title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.share-button { min-height: 25px; padding: 2px 7px; border: 1px solid #999; background: #eee; cursor: pointer; color: #333; font-size: .85rem; white-space: nowrap; }
.toc-item .share-button { min-height: 22px; padding-block: 0; }
.share-button:hover { background: #ddd; }
.share-preview {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding: 3px 5px;
  border: 1px solid #bbb;
  background: #f4f4f4;
}
.share-preview textarea { width: 100%; min-height: 3.4rem; padding: 4px 6px; border: 1px solid #999; background: #fff; color: #222; font-size: .9rem; line-height: 1.35; resize: vertical; }
.empty-toc { margin: 2px 0; color: var(--muted); font-size: .8rem; }

.panel { margin-bottom: 7px; padding: 7px; border: 1px solid #bbb; background: #fff; }
.panel h2, .section-title { margin: 0 0 5px; font-size: .95rem; }
.section-title small { color: var(--muted); font-size: .8rem; font-weight: normal; }
.panel p { margin: 0 0 5px; }
.panel p:last-child { margin-bottom: 0; }
.plain-list { margin: 0; padding-left: 1.4rem; }
.inline-control { display: inline-block; margin-inline: 1px; padding: 0 4px; border: 1px solid #999; background: #eee; font-size: .8rem; }
.status-list { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 5px 0; }
.status-list div { display: flex; gap: 5px; }
.status-list dt { font-weight: bold; }
.status-list dd { margin: 0; }
.quick-links { font-weight: bold; }
.help-panel summary { cursor: pointer; font-weight: bold; }
.help-panel[open] summary { margin-bottom: 4px; }
.secondary-results { margin-top: 12px; }
.list-help { margin: 0 0 5px; }
.search-help { margin: 0 0 7px; }
.search-notice { margin: 0 0 6px; padding: 5px 7px; border: 1px solid #c99; background: #fff2f2; }
.program-list { border: 1px solid #bbb; background: #fff; }
.program-result { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 6px; padding: 4px; border-bottom: 1px solid #ccc; content-visibility: auto; contain-intrinsic-size: auto 78px; }
.program-result:last-child { border-bottom: 0; }
.program-result__thumbnail img { display: block; width: 120px; height: 70px; object-fit: cover; }
.program-result__body { min-width: 0; }
.program-result__line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px; }
.program-result__line .share-preview { grid-column: 1 / -1; }
.program-result__meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; margin-top: 2px; color: var(--muted); font-size: .78rem; }
.program-result__video-title { color: #888; font-size: .78rem; }
.tag-index { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
.tag-index li { padding: 2px 5px; border: 1px solid #bbb; background: #eee; line-height: 1.2; }
.tag-index span { color: #666; }
.ballad-list { border: 1px solid #bbb; background: #fff; }
.ballad-entry { padding: 5px 7px; border-bottom: 1px solid #ccc; }
.ballad-entry:last-child { border-bottom: 0; }
.ballad-entry__heading { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; }
.ballad-entry__heading h2 { min-width: 0; margin: 0; overflow-wrap: anywhere; font-size: .95rem; font-weight: normal; }
.ballad-entry__heading time { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.ballad-entry__segments ul { display: grid; grid-template-columns: 1fr; gap: 1px; margin: 3px 0 0; padding-left: 1.4rem; }
.ballad-entry__segments li { break-inside: avoid; }
.load-status { color: var(--muted); }
.empty-results { margin: 0; padding: 7px; color: var(--muted); }
.pagination { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 5px 10px; margin: 8px 0 2px; padding: 4px; border: 1px solid #bbb; background: #f8f8f8; }
.pagination--top { margin: 0 0 6px; }
.pagination__status { color: var(--muted); white-space: nowrap; }
.pagination__links { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px; }
.pagination a, .pagination strong { min-width: 2rem; padding: 3px 7px; border: 1px solid #999; background: #eee; text-align: center; text-decoration: none; }
.pagination strong { border-color: #542d91; background: #65429a; color: #fff; }
.pagination__ellipsis { padding-inline: 2px; color: var(--muted); }
.pagination__jump { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.pagination__jump input[type="number"] { width: 4.2rem; height: 27px; padding: 2px 4px; border: 1px solid #999; }
.pagination__jump button { min-height: 27px; padding: 2px 7px; border: 1px solid #999; background: #eee; cursor: pointer; }

.site-footer { padding: 7px 0; border-top: 1px solid #111; background: #292929; color: #ddd; }
.site-footer__inner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding-right: 70px; }
.youtube-attribution img { display: block; width: 180px; height: auto; }
.footer-links { display: flex; flex-wrap: wrap; gap: 10px; font-size: .75rem; }
.footer-links a { color: #ddd; }
.back-to-top { position: fixed; right: 10px; bottom: 10px; z-index: 4; padding: 5px 8px; border: 1px solid #777; background: rgba(41, 41, 41, .92); color: #fff; text-decoration: none; }
.back-to-top:hover { background: #65429a; color: #fff; }

:focus-visible { outline: 2px solid #e07b00; outline-offset: 1px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@media (max-width: 960px) {
  .video-card__body { display: contents; }
  .video-card .thumbnail-link { grid-column: 1; grid-row: 1 / span 3; }
  .video-card .video-meta { grid-column: 2; grid-row: 1; }
  .video-card .video-title { grid-column: 2; grid-row: 2; }
  .video-card .tags { grid-column: 2; grid-row: 3; }
  .video-card .toc { grid-column: 1 / -1; grid-row: 4; }
}

@media (max-width: 600px) {
  :root { font-size: 13px; }
  .site-header__inner, .site-layout, .site-footer__inner { width: calc(100% - 8px); }
  .site-header__inner { flex-wrap: wrap; justify-content: flex-start; }
  .site-header__inner > span { margin-left: auto; }
  .site-search { order: 4; flex-basis: 100%; max-width: none; margin-left: 0; }
  .nav-toggle { display: inline-block; }
  .site-layout { display: block; }
  .sidebar { display: none; min-height: 0; border-right: 0; border-bottom: 1px solid #bbb; }
  .nav-open .sidebar { display: block; }
  .nav-list--sub a { padding: 5px 10px; }
  .main-content { padding: 4px; }
  .page-title { margin: -4px -4px 4px; }
  .toolbar { grid-template-columns: auto minmax(0, 1fr) auto; padding: 4px; }
  .search-field { grid-template-columns: minmax(0, 1fr); }
  .search-field span { display: none; }
  .video-card { grid-template-columns: 120px minmax(0, 1fr); gap: 5px; padding: 4px; }
  .thumbnail { width: 120px; height: 70px; aspect-ratio: auto; }
  .thumbnail-action { font-size: .7rem; }
  .video-meta { display: block; }
  .video-meta time { margin-left: 6px; }
  .share-preview { grid-template-columns: 1fr; }
  .program-result { grid-template-columns: 120px minmax(0, 1fr); }
}

.thumbnail-action { display: block; padding-top: 2px; font-size: .75rem; }
.legal-text { white-space: pre-wrap; overflow-wrap: anywhere; }
