/* Claude のような、温かみのある落ち着いた見た目。基本の色はアプリのアイコンの紫
   （赤地に白い三角は YouTube のロゴと見間違えやすいので使わない）。外部のフォントは読み込まない */
:root {
  color-scheme: light dark;
  --bg: #faf9f5; --panel: #ffffff; --sunk: #f0eee6; --line: #e8e6dc; --line-strong: #d6d3c6;
  --text: #1f1e1d; --muted: #73726c;
  --accent: #6e4ff0; --accent-text: #ffffff; --accent-soft: #ece8fd;
  --shadow: 0 1px 2px rgba(31, 30, 29, 0.04), 0 6px 24px rgba(31, 30, 29, 0.06);
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #262624; --panel: #30302e; --sunk: #1f1e1d; --line: #3a3a37; --line-strong: #4a4945;
    --text: #f5f4ef; --muted: #a6a39a;
    --accent: #9a7bff; --accent-text: #1e2032; --accent-soft: #3a3352;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.35);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow-x: hidden; }
body {
  margin: 0; height: 100dvh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 15px/1.7 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-underline-offset: 3px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
input[type="range"], input[type="checkbox"] { accent-color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { opacity: 0.35; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ヘッダー */
.bar { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-family: var(--serif); font-size: 18px; font-weight: 600; }
.mark { width: 22px; height: 22px; stroke: none; }
.header-actions { display: flex; gap: 2px; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; color: var(--muted); }
.icon-button:hover:not(:disabled) { background: var(--sunk); color: var(--text); }

.scroll { flex: 1; min-height: 0; overflow-y: auto; }

/* 全体の操作 */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; max-width: 1200px; margin: 4px auto 0; padding: 10px 16px; }
.transport { display: flex; align-items: center; gap: 6px; }
.chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 13px; font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--line-strong); }
.play { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--bg); }
.play svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.seek { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 240px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.seek input { flex: 1; }
.sync { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.switch { display: flex; align-items: center; gap: 6px; cursor: pointer; }

.notice { max-width: 1200px; margin: 8px auto 0; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); font-size: 14px; }

/* 動画の一覧。プレーヤーの最小サイズ（200×200）を守るため、カードの幅は 356px 以上 */
.grid { --card-min: 420px; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(var(--card-min), 100%), 1fr)); gap: 20px; max-width: 1200px; margin: 0 auto; padding: 12px 16px 24px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.player { position: relative; aspect-ratio: 16 / 9; background: #000; }
.player > div, .player > iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player .message { display: flex; align-items: center; justify-content: center; padding: 16px; color: #ccc; text-align: center; font-size: 13px; }
.meta { padding: 12px 14px 0; }
.meta .video-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta .detail { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta .wait { margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--accent); }
.badge { white-space: nowrap; flex: none; display: inline-block; font-size: 11px; padding: 0 8px; border-radius: 999px; margin-right: 6px; background: var(--accent-soft); color: var(--text); }
.card-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px 14px; font-size: 13px; }
.card-controls .mute { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 999px; background: var(--sunk); }
.card-controls .mute svg { width: 18px; height: 18px; }
.card-controls .mute[aria-pressed="true"] { background: var(--accent-soft); }
.card-controls .volume { flex: 1; min-width: 100px; }
.lag { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.lag button { padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); }
.lag span { min-width: 4.5em; text-align: center; font-variant-numeric: tabular-nums; }
.card-controls .remove { margin-left: auto; color: var(--muted); font-size: 12px; }
.card-controls .remove:hover { color: var(--text); }

/* 動画がないとき：中央に見出しと入力欄だけ */
.empty { max-width: 720px; min-height: calc(100% - 90px); margin: 0 auto; padding: 0 16px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 18px; text-align: center; }
.hero-mark { width: 40px; height: 40px; stroke: none; }
.small-mark { width: 32px; height: 32px; }
.hero-title { margin: 0; font-family: var(--serif); font-weight: 500; font-size: clamp(26px, 4.4vw, 38px); letter-spacing: 0.02em; }
.hero-hint { margin: 0; max-width: 560px; color: var(--muted); font-size: 13px; }
.text-button { color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }

/* 入力欄（中央と画面の下で同じ形） */
.composer-box { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 760px; margin: 0 auto; padding: 8px 8px 8px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.composer-box:focus-within { border-color: var(--line-strong); }
.composer-box input { flex: 1; min-width: 0; border: 0; background: transparent; color: inherit; font: inherit; font-size: 16px; padding: 8px 0; outline: none; }
.composer-box input::placeholder { color: var(--muted); }
.composer-box.hero { padding-top: 12px; padding-bottom: 12px; }
.send { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--accent); color: var(--accent-text); }
.send svg { width: 18px; height: 18px; stroke-width: 2.2; }
.composer { flex: none; padding: 8px 16px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(to bottom, transparent, var(--bg) 30%); }
body.is-empty .composer { display: none; }

.queue { max-width: 1200px; margin: 0 auto; padding: 0 16px 16px; }
.queue h2 { font-size: 13px; font-weight: 600; color: var(--muted); }
.queue-items { display: flex; flex-wrap: wrap; gap: 8px; }
.queue-items button { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 13px; }
.footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; padding: 24px 16px 32px; font-size: 12px; color: var(--muted); }

/* モーダル */
.modal { max-width: 480px; width: calc(100% - 32px); padding: 28px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(20, 20, 19, 0.45); backdrop-filter: blur(2px); }
.modal h2 { margin: 8px 0 12px; font-family: var(--serif); font-weight: 500; font-size: 24px; }
.modal h3 { margin: 18px 0 4px; font-size: 14px; }
.modal ol { padding-left: 20px; }
.links { padding-left: 20px; }
.small { font-size: 13px; color: var(--muted); }
.primary, .wide { display: block; width: 100%; margin-top: 16px; padding: 11px; border-radius: 12px; font-weight: 600; }
.primary { background: var(--accent); color: var(--accent-text); }
.wide:not(.primary) { background: var(--sunk); }

@media (max-width: 600px) {
  .controls { gap: 10px; }
  .transport { width: 100%; justify-content: space-between; }
  .seek { min-width: 0; flex-basis: 100%; }
  .grid { padding: 8px 0 20px; gap: 12px; }
  .card { border-radius: 0; border-left: 0; border-right: 0; box-shadow: none; }
}

/* 追加ボタン（文字入り） */
.send { width: auto; padding: 0 16px 0 12px; gap: 6px; display: flex; align-items: center; font-weight: 600; font-size: 14px; height: 40px; }
.send svg { width: 16px; height: 16px; }

/* 共有・検索の画面 */
.panel-page { max-width: 1000px; margin: 0 auto; padding: 24px 16px 32px; display: flex; flex-direction: column; gap: 14px; }
#shared { max-width: 760px; }
.eyebrow { margin: 0; color: var(--muted); font-size: 13px; }
.page-title { margin: 0; font-family: var(--serif); font-weight: 500; font-size: clamp(22px, 3vw, 30px); }
.lead { margin: 0; color: var(--muted); font-size: 14px; }
.search-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.section-title { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 20px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.pick-list { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 10px; }
.pick { display: flex; align-items: center; gap: 14px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; cursor: pointer; }
.pick:has(input:checked) { border-color: var(--accent); }
.pick.disabled { opacity: 0.5; cursor: default; }
.pick input { width: 20px; height: 20px; flex: none; }
.thumb { width: 128px; aspect-ratio: 16 / 9; flex: none; border-radius: 9px; background: #141413; object-fit: cover; }
.item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.item-title { font-weight: 600; font-size: 14px; line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item-sub { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; min-width: 0; }
.item-sub span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge.live { background: color-mix(in srgb, #e5484d 22%, transparent); }
.pick-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 12px; }
.primary-button { height: 46px; padding: 0 22px; border-radius: 14px; background: var(--accent); color: var(--accent-text); font-weight: 600; }
.result-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 12px; }
.result { display: flex; align-items: center; gap: 14px; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
.result .thumb { width: 160px; border-radius: 10px; }
.add-button { height: 40px; flex: none; display: flex; align-items: center; gap: 4px; padding: 0 14px 0 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); font-weight: 600; font-size: 13px; }
.add-button svg { width: 16px; height: 16px; }
.add-button:disabled { opacity: 0.4; }
.fallback { margin: 4px 0 0; padding: 14px 18px; border-radius: 14px; background: var(--sunk); color: var(--muted); font-size: 13px; }
.fallback a { color: var(--text); }

/* 一緒に配信していた人 */
.suggestions { max-width: 1200px; margin: 0 auto; padding: 0 16px 24px; }
.suggestions-box { padding: 18px 20px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; }
.suggestion-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-top: 12px; }
.suggestion { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; }
.suggestion .thumb { width: 112px; border-radius: 8px; }
.icon-add { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.icon-add svg { width: 16px; height: 16px; }
.card-controls .remove { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; }
.card-controls .remove svg { width: 18px; height: 18px; }
body.has-panel .empty { display: none; }
@media (max-width: 600px) { .result-list { grid-template-columns: 1fr; } .result .thumb, .thumb { width: 104px; } }

/* 大きさ */
.size { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.size input { width: 120px; }
.card.large { grid-column: 1 / -1; }
.card-controls .enlarge { padding: 4px 10px; border-radius: 999px; font-size: 12px; color: var(--muted); }
.card-controls .enlarge:hover { color: var(--text); }
.card.large .player { max-height: calc(100dvh - 220px); aspect-ratio: auto; height: min(calc((100vw - 32px) * 9 / 16), calc(100dvh - 220px)); }

/* 全画面：操作バーと動画だけにする */
body.is-fullscreen .footer, body.is-fullscreen .suggestions, body.is-fullscreen .composer, body.is-fullscreen #notice { display: none; }
body.is-fullscreen .grid, body.is-fullscreen .controls { max-width: none; }
.icon-button.active { color: var(--accent); }

/* 配信の時間帯（ガントチャート） */
.timeline { max-width: 1200px; margin: 0 auto 4px; padding: 10px 16px 6px; --label: 140px; }
.timeline-axis { position: relative; height: 18px; margin-left: var(--label); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.timeline-axis span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.timeline-rows { display: flex; flex-direction: column; gap: 4px; }
.timeline-row { display: flex; align-items: center; gap: 0; }
.timeline-label { width: var(--label); flex: none; padding-right: 10px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline-track { position: relative; flex: 1; height: 16px; border-radius: 6px; background: var(--sunk); cursor: pointer; }
.timeline-bar { position: absolute; top: 2px; bottom: 2px; border-radius: 4px; background: color-mix(in srgb, var(--accent) 45%, transparent); }
.timeline-row.main .timeline-bar { background: var(--accent); }
.timeline-bar.live { background: repeating-linear-gradient(45deg, color-mix(in srgb, #e5484d 55%, transparent) 0 6px, color-mix(in srgb, #e5484d 35%, transparent) 6px 12px); }
.timeline-cursor { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--text); pointer-events: none; }
body.is-fullscreen .timeline { max-width: none; }
@media (max-width: 600px) { .timeline { --label: 84px; } }

/* 共有リンクを開いたときに見る動画を選ぶモーダル */
.shared-modal { max-width: 680px; }
.shared-modal .eyebrow { margin: 0; }
.shared-modal h2 { margin-top: 2px; }
.shared-modal .pick-list { max-height: min(52vh, 460px); overflow-y: auto; padding: 2px; }
.pick-buttons { display: flex; gap: 8px; }
.secondary-button { height: 46px; padding: 0 18px; border-radius: 14px; background: var(--sunk); font-weight: 600; }
@media (max-width: 600px) { .pick-actions { flex-direction: column; align-items: stretch; } .pick-buttons > * { flex: 1; } .shared-modal .thumb { width: 88px; } }

/* 検索結果・候補の1行の中身 */
.result-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.result-info .thumb { width: 120px; border-radius: 8px; }

/* 共有リンクの選ぶ一覧：時間帯の横棒と並び替え */
.shared-modal { max-width: 920px; }
.shared-modal .pick-list { --pick-info: 380px; }
.pick-axis { position: relative; height: 18px; margin: 0 92px 0 calc(var(--pick-info) + 40px); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pick-axis span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.shared-modal .pick { gap: 10px; padding: 10px 12px; cursor: grab; }
.shared-modal .pick.base { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.shared-modal .pick.dragging { opacity: 0.5; }
.shared-modal .pick.drop-target { border-style: dashed; }
.drag-handle { color: var(--muted); flex: none; }
.drag-handle svg { width: 18px; height: 18px; stroke-width: 3; }
.pick-main { width: var(--pick-info); flex: none; display: flex; align-items: center; gap: 12px; min-width: 0; cursor: pointer; }
.pick-main .thumb { width: 104px; }
.pick-track { position: relative; flex: 1; height: 16px; border-radius: 6px; background: var(--sunk); min-width: 60px; }
.pick-bar { position: absolute; top: 2px; bottom: 2px; border-radius: 4px; background: color-mix(in srgb, var(--accent) 45%, transparent); }
.pick.base .pick-bar { background: var(--accent); }
.pick.disabled .pick-bar { background: var(--line-strong); }
.pick-moves { display: flex; flex-direction: column; gap: 2px; flex: none; }
.pick-moves button { width: 28px; height: 22px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); font-size: 12px; line-height: 1; }
.badge.base-badge { background: var(--accent); color: var(--accent-text); }
@media (max-width: 760px) {
  .shared-modal .pick { flex-wrap: wrap; } .pick-main { width: calc(100% - 70px); } .pick-track { flex-basis: 100%; order: 5; } .pick-axis { display: none; }
}

/* ドラッグで選んでいる期間 */
.range-band { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--accent) 16%, transparent); border-left: 1px solid var(--accent); border-right: 1px solid var(--accent); pointer-events: none; }

/* 検索結果：動画ごとの配信の時間帯の横棒と、上の時間軸 */
.search-summary { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.log-list { position: relative; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; overflow: clip; background: var(--panel); user-select: none; }
.log-row { display: grid; grid-template-columns: minmax(0, 400px) minmax(120px, 1fr) 84px; align-items: center; gap: 14px; padding: 8px 12px; }
.log-row + .log-row { border-top: 1px solid var(--line); }
.log-axis { position: sticky; top: 0; z-index: 1; padding-top: 10px; padding-bottom: 6px; background: var(--panel); }
.log-axis-track { position: relative; height: 26px; border-radius: 6px; background: var(--sunk); cursor: col-resize; touch-action: none; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.log-axis-track span { position: absolute; top: 6px; transform: translateX(-50%); white-space: nowrap; pointer-events: none; }
.log-track { position: relative; height: 20px; border-radius: 6px; background: var(--sunk); overflow: hidden; cursor: col-resize; touch-action: none; }
.log-bar { position: absolute; top: 3px; bottom: 3px; border-radius: 4px; background: var(--accent); }
.log-current { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--accent) 14%, transparent); border-left: 1px dashed var(--accent); border-right: 1px dashed var(--accent); }
.log-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.log-row .result-info .thumb { width: 96px; flex: none; }
.log-row .add-button { width: 84px; justify-content: center; }
.log-list .range-band { z-index: 2; }
@media (max-width: 760px) {
  .log-row { grid-template-columns: minmax(0, 1fr) 84px; }
  .log-row .log-track, .log-axis-track { grid-column: 1 / -1; grid-row: 2; }
  .log-axis > div:empty { display: none; }
}
.search-more { align-self: center; height: 40px; }
