:root {
  color-scheme: light;
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: #f7f4ef;
  color: #221f1a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #ddd2c3;
  background: rgba(247, 244, 239, 0.96);
  backdrop-filter: blur(12px);
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.topbar p {
  margin: 6px 0 0;
  color: #6d6254;
  font-size: 13px;
}

.rights-note {
  max-width: 560px;
}

#resultMeta {
  font-weight: 700;
}

.searchbox,
.sortbox {
  display: grid;
  gap: 6px;
  color: #5d554c;
  font-size: 12px;
  font-weight: 700;
}

.searchbox {
  width: min(440px, 42vw);
}

.sortbox {
  width: 160px;
}

.searchbox input,
.sortbox select {
  width: 100%;
  height: 42px;
  border: 1px solid #cabba8;
  border-radius: 6px;
  padding: 0 14px;
  background: #fffdf9;
  color: #221f1a;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
}

.searchbox input:focus,
.sortbox select:focus {
  outline: 3px solid #d9b26f;
  outline-offset: 1px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 0;
  min-height: calc(100vh - 79px);
}

.results {
  padding: 22px;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.video-card {
  overflow: hidden;
  border: 1px solid #ded3c4;
  border-radius: 8px;
  background: #fffdf9;
  box-shadow: 0 1px 2px rgba(56, 45, 28, 0.06);
}

.thumb-link {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  background: #15110d;
}

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

.duration-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 3px 6px;
  border-radius: 4px;
  background: rgba(15, 13, 11, 0.86);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.card-body {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.channel-name {
  margin: 0;
  color: #8c6b35;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
}

.card-title {
  min-height: 48px;
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
}

.card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

button,
.youtube-link {
  border: 1px solid #8c6b35;
  border-radius: 6px;
  padding: 8px 10px;
  background: #8c6b35;
  color: white;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

button.secondary,
.youtube-link.secondary {
  border-color: #c8baa6;
  background: #fffdf9;
  color: #4e463c;
}

.detail {
  position: sticky;
  top: 79px;
  height: calc(100vh - 79px);
  overflow: auto;
  border-left: 1px solid #ddd2c3;
  background: #efe8dc;
}

.detail-empty,
.detail-body {
  padding: 22px;
}

.detail-empty h2,
.detail-content h2 {
  margin: 0 0 12px;
  font-size: 20px;
  line-height: 1.45;
}

.detail-empty p,
#detailSummary {
  margin: 0;
  color: #5a5147;
  line-height: 1.75;
}

.detail-content img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #15110d;
}

.duration {
  margin: 0 0 8px;
  color: #746653;
  font-size: 13px;
  font-weight: 700;
}

.keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 14px;
}

.keyword {
  padding: 5px 8px;
  border: 1px solid #d8c9b5;
  border-radius: 999px;
  background: #fffaf2;
  color: #4f4438;
  font-size: 12px;
  font-weight: 700;
}

.chapters {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.chapters li {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 8px;
  align-items: start;
  color: #4f463b;
  font-size: 13px;
  line-height: 1.5;
}

.chapters span {
  color: #8c6b35;
  font-weight: 800;
}

.empty-state {
  padding: 24px;
  border: 1px solid #ded3c4;
  border-radius: 8px;
  background: #fffdf9;
  color: #675e53;
}

mark {
  border-radius: 3px;
  background: #ffe19b;
  color: inherit;
}

@media (max-width: 900px) {
  .topbar {
    position: static;
    display: grid;
  }

  .searchbox {
    width: 100%;
  }

  .sortbox {
    width: 100%;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .detail {
    position: static;
    height: auto;
    border-top: 1px solid #ddd2c3;
    border-left: 0;
  }
}

@media (max-width: 520px) {
  .topbar,
  .results {
    padding: 16px;
  }

  .video-grid {
    grid-template-columns: 1fr;
  }
}
