:root {
  color-scheme: light dark;
  --paper: #EDEFF2;
  --surface: #F7F8FA;
  --ink: #1F2430;
  --muted: #5E6675;
  --line: #CDD2DA;
  --carpet: #A8243A;
  --carpet-deep: #7E1A2C;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1B1E25;
    --surface: #23272F;
    --ink: #E7E9ED;
    --muted: #9AA1AD;
    --line: #353A45;
    --carpet: #E2576B;
    --carpet-deep: #A8243A;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 var(--font);
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--carpet); outline-offset: 2px; }

/* ヘッダーと、アイコンのカーペットにちなんだ菱形の帯 */
.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 10px;
  max-width: 760px;
  margin: 0 auto;
}
.wordmark {
  white-space: nowrap;
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
  text-decoration: none;
}
.site-header nav { display: flex; gap: 12px; font-size: 0.85rem; white-space: nowrap; }
.site-header nav a { text-decoration: none; color: var(--muted); }
.site-header nav a[aria-current="page"] { color: var(--ink); font-weight: 700; }
.carpet {
  height: 10px;
  background:
    linear-gradient(135deg, var(--carpet) 25%, transparent 25%) -5px 0 / 10px 10px,
    linear-gradient(225deg, var(--carpet) 25%, transparent 25%) -5px 0 / 10px 10px,
    linear-gradient(315deg, var(--carpet) 25%, transparent 25%) 0 0 / 10px 10px,
    linear-gradient(45deg, var(--carpet) 25%, transparent 25%) 0 0 / 10px 10px,
    var(--carpet-deep);
}

main { max-width: 760px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.15rem; margin: 8px 0 12px; }
h2 { font-size: 1rem; margin: 28px 0 8px; }
.muted { color: var(--muted); font-size: 0.875rem; }
.error { color: var(--carpet); font-size: 0.9rem; }

/* 入力 */
form.row { display: flex; gap: 8px; margin: 8px 0; }
input {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}
button {
  font: inherit;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  white-space: nowrap;
}
button.quiet { background: transparent; color: var(--ink); border-color: var(--line); font-weight: 400; }
button.danger { background: var(--carpet); border-color: var(--carpet); color: #fff; }
button:disabled { opacity: 0.5; cursor: default; }

/* 検索履歴 */
.history { list-style: none; padding: 0; margin: 4px 0 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.history li {
  display: flex; align-items: center;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface);
  max-width: 100%;
}
.history button {
  background: transparent; border: 0; color: var(--ink);
  font-weight: 400; font-size: 0.875rem;
}
.history-word {
  padding: 5px 4px 5px 12px;
  overflow: hidden; text-overflow: ellipsis; max-width: 14em;
}
.history-remove { padding: 5px 10px 5px 6px; color: var(--muted) !important; }

/* 動画の一覧 */
.videos { list-style: none; padding: 0; margin: 0; }
.videos li { border-bottom: 1px solid var(--line); }
.videos a {
  display: grid;
  grid-template-columns: 136px 1fr;
  gap: 12px;
  padding: 10px 0;
  text-decoration: none;
}
.thumb { position: relative; width: 136px; aspect-ratio: 16 / 9; background: var(--line); border-radius: 6px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .len {
  position: absolute; right: 4px; bottom: 4px;
  font-size: 0.7rem; font-weight: 700; color: #fff;
  background: rgba(0, 0, 0, 0.75); padding: 0 4px; border-radius: 3px;
}
.video-title {
  font-size: 0.95rem; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.more { display: block; width: 100%; margin: 16px 0; }

/* 再生画面 */
.player { position: relative; aspect-ratio: 16 / 9; background: #000; margin: 0 -16px; }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.description { white-space: pre-wrap; font-size: 0.9rem; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }

/* プレイリスト */
a.button {
  display: inline-block; text-decoration: none; font-weight: 700;
  padding: 10px 14px; border-radius: 10px;
  background: var(--ink); color: var(--paper); border: 1px solid var(--ink);
}
.queue {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  padding: 10px 12px; margin: 12px 0 0;
  border-left: 4px solid var(--carpet); background: var(--surface);
}
.queue-name { font-weight: 700; text-decoration: none; }
.queue .actions { margin: 0 0 0 auto; }
.add-panel { padding: 10px 12px; background: var(--surface); border-radius: 10px; margin: 4px 0 8px; }
.pick { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.plist { list-style: none; padding: 0; margin: 0; }
.plist li { border-bottom: 1px solid var(--line); padding: 8px 0; }
.plist-item { display: grid; grid-template-columns: 136px 1fr; gap: 12px; text-decoration: none; }
.plist-tools { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; }
.plist-tools button { padding: 4px 12px; font-size: 0.85rem; }
.list li > span.muted { flex: none; }
.grow { flex: 1; min-width: 0; text-decoration: none; overflow-wrap: anywhere; }

/* ブロックリスト */
.list { list-style: none; padding: 0; margin: 0; }
.list li {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.list li > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list li button { padding: 6px 10px; font-size: 0.85rem; }
/* タップで開閉する一覧 */
.fold { margin: 28px 0 8px; }
.fold > summary {
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before {
  content: "";
  width: 0; height: 0;
  border-left: 6px solid currentColor;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  transition: transform 0.15s;
}
.fold[open] > summary::before { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) { .fold > summary::before { transition: none; } }

.unlock-state { padding: 10px 12px; border-left: 4px solid var(--carpet); background: var(--surface); }

.notice { text-align: center; padding: 48px 0; }
.notice strong { display: block; font-size: 1.05rem; margin-bottom: 4px; }

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