:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --surface: #ffffff;
  --surface-2: #efe9df;
  --border: #e1d9cc;
  --color-text: #2a2620;
  --color-text-secondary: #6b665e;
  --color-text-warning: #b36b00;
  --color-text-danger: #d4372c;
  --accent: #e9a15f;
  --accent-ink: #1d1409;
  --live: #e5484d;
  --radius: 14px;
  --content-w: 560px; /* 中央のコンテンツ幅。PC のトップだけ広げる（下の @media）。広告枠・配信ボタンの位置もこれに合わせる */
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--color-text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif; }
body { overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* fixed で表示領域にぴったり合わせる（100vh/100dvh はモバイルのアドレスバーでずれる） */
#app { position: fixed; inset: 0; max-width: var(--content-w); margin: 0 auto; }
.view { position: absolute; inset: 0; display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top); }
.scroll { flex: 1; overflow-y: auto; padding: 0 16px 16px; }

/* header */
.topbar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; min-height: 56px; }
.topbar h1, .topbar h2 { font-size: 18px; margin: 0; flex: 1; letter-spacing: .04em; }
.topbar .titles { flex: 1; min-width: 0; }
.topbar .titles .t1 { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .titles .t2 { font-size: 12px; color: var(--color-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* ロゴは余白が広いので、見える部分だけが収まるよう上下を詰める。白い縁取りのロゴなので、薄い影で背景から浮かせる */
.topbar .logo { line-height: 0; }
.logo img { display: block; height: 104px; width: auto; margin: -9px 0 -16px -16px; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .3)); }
.tagline { margin: 0 16px 12px; font-size: 14px; line-height: 1.7; color: var(--color-text); }
.tagline b { display: block; color: #9a5412; font-size: 21px; line-height: 1.4; font-weight: 800; letter-spacing: .02em; }
.tagline p { margin: 6px 0 0; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); display: grid; place-items: center; flex: none; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.spin svg { animation: spin .8s linear; }
@keyframes spin { to { transform: rotate(360deg); } }

/* tabs */
.tabs { display: flex; gap: 6px; margin: 0 16px 12px; padding: 4px; background: var(--surface); border-radius: 12px; }
.tabs button { flex: 1; min-height: 40px; border: 0; background: transparent; border-radius: 9px; color: var(--color-text-secondary); font-weight: 600; }
.tabs button.on { background: var(--surface-2); color: var(--color-text); }
.home-ad { margin: 0 16px 12px; overflow-x: auto; } /* タブの下の DLsite ランキング。横に長いときは枠内でスクロール */
.note { font-size: 12px; color: var(--color-text-secondary); margin: 4px 2px 12px; }
.resume { background: var(--surface); border: 1px solid var(--color-text-warning); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.resume-t { font-weight: 700; margin-bottom: 4px; }
.resume-s { font-size: 13px; color: var(--color-text-secondary); margin-bottom: 12px; }
.resume-b { display: flex; gap: 8px; }
.resume-b .btn { min-height: 46px; font-size: 14px; }
.empty { text-align: center; color: var(--color-text-secondary); padding: 48px 0; font-size: 14px; }

/* cards */
.card { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px; min-height: 76px; }
a.card { color: inherit; text-decoration: none; }
.card:active { background: var(--surface-2); }
.card .emoji { font-size: 40px; line-height: 1; width: 52px; text-align: center; flex: none; }
.card .info { flex: 1; min-width: 0; }
.card .meta-row { display: flex; align-items: center; gap: 10px; margin-bottom: 3px; }
.card .meta-row .badge { margin-left: auto; flex: none; }
.card .stats-row { gap: 16px; margin: 3px 0 0; }
.card .name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.card .sub { font-size: 13px; color: var(--color-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 性別アイコン（配信者名の前に付ける） */
.gi svg { width: 1em; height: 1em; vertical-align: -0.14em; }
.name .gi, .t1 .gi, #a-title .gi { margin-right: 6px; }
.gi-male { color: #6fa8ff; } .gi-female { color: #ff8fb8; } .gi-other { color: #b9a8ff; }
.badge { background: var(--live); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .08em; padding: 2px 7px; border-radius: 6px; }
.count { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--color-text-secondary); }
.count svg { width: 14px; height: 14px; }
.count.warn { color: var(--color-text-danger); font-weight: 700; }
.card .stats-row, .arch-info .meta-row { flex-wrap: wrap; }

.fab-bar { padding: 8px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }
/* 配信を始める: 右下に浮かぶ丸いボタン */
.fab-dock { position: sticky; bottom: calc(16px + env(safe-area-inset-bottom)); height: 0; z-index: 5; } /* 高さ0の枠。スクロール中は画面の下端に付いてきて、フッターの手前で止まる（フッターのリンクに重ならない） */
.fab { position: absolute; right: 16px; bottom: 0;
  height: 56px; padding: 0 22px 0 18px; border-radius: 28px; border: 0; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 16px; white-space: nowrap; box-shadow: 0 6px 16px rgba(0, 0, 0, .25); }
.fab svg { width: 24px; height: 24px; flex: none; }
.fab:active { transform: scale(.94); }
#v-home .scroll { padding-bottom: 104px; } /* 最後のカードがボタンに隠れないように */
/* トップ・視聴・アーカイブは広告などで縦に長くなるので、画面に固定せず、ページ全体をスクロールさせる（配信中・配信作成は固定のまま） */
html.flow, html.flow body { height: auto; }
html.flow body { overflow: visible; }
html.flow #app { position: relative; inset: auto; }
html.flow .view { position: relative; inset: auto; min-height: 100vh; min-height: 100dvh; }
html.flow .chat { flex: none; }
html.flow .chat-log { flex: none; max-height: 60vh; } /* コメント欄は枠の中だけスクロール */
html.home #v-home .scroll { flex: none; overflow: visible; }
html.home .foot { margin-top: auto; }
/* PC では横幅を広げる（一覧は1配信ごとに横いっぱい） */
@media (min-width: 900px) {
  html.home { --content-w: 1000px; }
  .tagline br { display: none; } /* 横幅があるので、タグラインは改行せず続けて表示する */
}
/* 広告枠: 中央のコンテンツの左右に、縦長の枠を置く。PC（マウス操作）の広い画面だけ。スマホ・タブレットでは出さない。
   出す画面はトップ・視聴・アーカイブ（html.ads）。両側の枠が収まる幅は、コンテンツ幅 + 432px（左 176px + 右 256px） */
.ad { display: none; position: fixed; top: 16px; width: 160px; }
.ad-l { left: calc(50% - var(--content-w) / 2 - 176px); }
/* 右の枠だけ 240px。DLsite ランキングの下に admax(160x600)を縦に並べ、合計が画面の高さを超えるときは、枠の中でスクロールする */
.ad-r { left: calc(50% + var(--content-w) / 2 + 16px); width: 240px; max-height: calc(100vh - 32px); overflow-y: auto; scrollbar-width: none; }
.ad-slot { width: 160px; height: 600px; }
#ad-right { width: 240px; height: auto; }
.ad-slot-sub { margin: 12px auto 0; }
@media (min-width: 1000px) and (hover: hover) and (pointer: fine) { html.ads:not(.home) .ad { display: block; } }
@media (min-width: 1440px) and (hover: hover) and (pointer: fine) { html.ads.home .ad { display: block; } }
/* トップページのフッター（規約・ポリシーへのリンク）: 一覧の外に置く。内容が短いときは画面の一番下に来る */
.foot { flex: none; text-align: center; padding: 0 0 env(safe-area-inset-bottom); border-top: 1px solid var(--border); background: var(--bg); }
.foot a { display: inline-block; padding: 14px 12px; font-size: 12px; color: var(--color-text-secondary); text-decoration: underline; }
.btn { display: block; width: 100%; min-height: 52px; border: 0; border-radius: 14px; background: var(--accent);
  color: var(--accent-ink); font-weight: 800; font-size: 16px; }
.btn:disabled { opacity: .5; }
.btn.ghost { background: var(--surface-2); color: var(--color-text); font-weight: 600; }
.btn.danger { background: var(--live); color: #fff; }

/* 一覧の絞り込み */
.filters { margin: 0 16px 8px; display: flex; flex-direction: column; gap: 6px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--color-text); font-size: 13px; font-weight: 600; white-space: nowrap; }
.chips button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
/* ジャンルの絞り込み: 絵文字を大きくしたタイル。選択中は枠と光で目立たせる */
.chips.tiles { gap: 8px; padding: 4px 2px 6px; }
.chips.tiles button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 64px; min-height: 76px; padding: 6px 8px; border-radius: 16px;
  border-color: color-mix(in srgb, var(--tc) 55%, transparent); background: color-mix(in srgb, var(--tc) 12%, var(--surface)); box-shadow: 0 0 10px color-mix(in srgb, var(--tc) 25%, transparent); }
.chips.tiles button .e { font-size: 30px; line-height: 1; }
.chips.tiles button .l { font-size: 12px; color: var(--color-text); }
.chips.tiles button.on { background: color-mix(in srgb, var(--tc) 28%, var(--surface)); border-color: var(--tc); box-shadow: 0 0 16px color-mix(in srgb, var(--tc) 70%, transparent); }
.chips.tiles button.on .l { color: var(--color-text); font-weight: 800; }
.chips.tiles button.all { --tc: var(--accent); font-size: 14px; font-weight: 800; }
.chips.tiles button.all.on, .chips.tiles button.all.on .l { background: var(--accent); color: var(--accent-ink); }
/* 一覧の途中の広告 */
.feed-ad { margin: 0 0 10px; }
.feed-ad.pending { height: 0; margin: 0; overflow: hidden; } /* 広告が出るまで（出なければずっと）は、場所を取らない */
.feed-ad-label { font-size: 11px; color: var(--color-text-secondary); margin: 0 2px 4px; }
.feed-ad-body { overflow: hidden; }
.feed-ad-frame { display: block; width: 100%; height: 0; border: 0; transform-origin: 0 0; }
/* 配信が0件のときの案内 */
.empty-live { text-align: center; padding: 8px 0 24px; }
/* サイトのイメージ画像（タグラインの上）。コンテンツの横幅いっぱいに出し、ロゴ（中央の下寄り）と更新ボタン（右上）は画像の上に重ねる */
.hero { position: relative; margin: 12px 16px; }
.hero .topbar { position: absolute; inset: 0; padding: 6px 8px 0 4px; min-height: 0; align-items: flex-start; pointer-events: none; }
.hero .topbar .icon-btn { margin-left: auto; pointer-events: auto; }
.hero .logo { position: absolute; left: 50%; top: 68%; transform: translate(-50%, -50%); flex: none; } /* 画像の中央、2人の手の高さあたり */
.hero .logo img { height: min(140px, 17vw); margin: 0; }
@media (min-width: 900px) { .hero .logo img { height: 180px; } } /* PC は画像が大きいので、ロゴも大きくする */
.hero-img { display: block; width: 100%; height: auto; border-radius: var(--radius); }
.empty-live p { margin: 0; font-size: 15px; line-height: 1.8; font-weight: 700; color: #9a5412; }

/* forms */
.field { margin-bottom: 18px; }
.field > label, .field > .lbl { display: block; font-size: 13px; color: var(--color-text-secondary); margin-bottom: 6px; }
.input { width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); outline: none; }
.input:focus { border-color: var(--accent); }
textarea.input { display: block; padding: 12px 14px; line-height: 1.5; resize: none; }
.genres { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.genres button { min-height: 64px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; }
.genres button .e { font-size: 24px; line-height: 1.1; }
.genres button.on { border-color: var(--accent); background: var(--surface-2); }
.seg { display: flex; padding: 4px; gap: 4px; background: var(--surface); border-radius: 12px; border: 1px solid var(--border); }
.seg button { flex: 1; min-height: 42px; border: 0; background: transparent; border-radius: 9px; font-weight: 700; color: var(--color-text-secondary); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.hint { font-size: 12px; color: var(--color-text-secondary); margin-top: 6px; }
.mic-row { display: flex; align-items: center; gap: 10px; }
.chip { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--color-text-secondary); }
.chip.ok { color: #1f8f4a; }
.mic-row .btn { width: auto; min-height: 44px; padding: 0 16px; font-size: 14px; }
/* 配信を始める前の注意: 見落とされないよう、枠で囲って目立たせる */
.rules { list-style: none; margin: 0; padding: 12px 14px; font-size: 14px; line-height: 1.7; font-weight: 700; color: var(--color-text);
  background: color-mix(in srgb, var(--color-text-warning) 12%, var(--surface)); border: 2px solid var(--color-text-warning); border-radius: var(--radius); }
.rules::before { content: "⚠️ 配信前にご確認ください"; display: block; margin-bottom: 6px; font-size: 15px; font-weight: 800; color: #9a5412; }
.rules li { margin: 0 0 6px; }
.rules li:last-child { margin-bottom: 0; }
.rules .ng { color: var(--color-text-danger); }
.rules a { color: #b45f10; }

/* time */
.time { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums;
  font-weight: 700; color: var(--color-text-secondary); transition: color .3s; }
.time.warn { color: var(--color-text-warning); }
.time.danger { color: var(--color-text-danger); }

/* stage (live / listen) */
.stage { padding: 4px 16px 12px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.stage .big-time { font-size: 52px; line-height: 1; }
.stage .cap { font-size: 12px; color: var(--color-text-secondary); }
.stats { display: flex; gap: 18px; align-items: center; color: var(--color-text-secondary); font-size: 14px; }
.rec { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--color-text-danger); }
.rec i { width: 10px; height: 10px; border-radius: 50%; background: var(--live); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.stage .btn { max-width: 280px; }
#v-live .chat { margin-bottom: 12px; }
/* 配信画面: ヘッダーは横幅いっぱいのカード、下部は固定バー（ミュート・音量・配信終了） */
.live-head { margin: 0 12px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.chat-h { padding: 12px 16px; font-weight: 700; border-bottom: 1px solid var(--border); }
.live-bar { display: flex; align-items: center; gap: 10px; margin: 0 12px calc(12px + env(safe-area-inset-bottom)); padding: 8px;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.live-bar .btn { width: auto; min-height: 48px; }
.live-bar #l-share { flex: 0 0 48px; padding: 0; font-size: 20px; }
.live-bar #l-mute { flex: 0 0 48px; padding: 0; font-size: 22px; }
.live-bar #l-stop { flex: 0 0 auto; padding: 0 16px; font-size: 14px; }
.live-bar .vol { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--color-text-secondary); }
.live-bar .vol input { flex: 1; min-width: 0; accent-color: var(--accent); }
.btn.muted { background: var(--color-text-warning); color: var(--accent-ink); font-weight: 800; }
.player { display: flex; align-items: center; gap: 16px; }
.play-btn { width: 64px; height: 64px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.play-btn svg { width: 28px; height: 28px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 40px; }
.bars i { width: 6px; height: 8px; border-radius: 3px; background: var(--surface-2); }
.bars.on i { background: var(--accent); animation: bar 0.9s ease-in-out infinite; }
.bars.on i:nth-child(2) { animation-delay: .15s; } .bars.on i:nth-child(3) { animation-delay: .3s; }
.bars.on i:nth-child(4) { animation-delay: .45s; } .bars.on i:nth-child(5) { animation-delay: .6s; }
@keyframes bar { 0%, 100% { height: 8px; } 50% { height: 36px; } }

/* chat */
/* 残りの高さを使うが、画面の端からは離してカード状に表示する */
.chat { flex: 1 1 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; margin: 0 12px calc(16px + env(safe-area-inset-bottom)); border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.chat-log { flex: 1; overflow-y: auto; padding: 10px 16px; display: flex; flex-direction: column; gap: 8px; }

@media (max-height: 640px) { .stage .big-time { font-size: 40px; } .stage { gap: 8px; padding-bottom: 8px; } }
.msg { font-size: 14px; line-height: 1.45; word-break: break-word; }
.msg b { color: #b45f10; margin-right: 6px; font-size: 13px; }
.msg.sys { color: var(--color-text-secondary); font-size: 12px; }
/* 入力欄は枠の上部。履歴はその下に、新しいコメントが上になるよう並べる */
.chat-form { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px; border-bottom: 1px solid var(--border); }
.chat-form .input { flex: 1; background: var(--bg); }
.chat-count { flex: 0 0 100%; margin-top: -2px; text-align: right; font-size: 11px; color: var(--color-text-secondary); }
.chat-count.low { color: var(--color-text-danger); font-weight: 700; }
.chat-form button { width: 64px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 800; min-height: 48px; }
.chat-form button:disabled { opacity: .5; }

/* archive view */
.arch-body { flex: none; padding: 12px 16px; display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
.arch-body .note { text-align: center; }
.arch-head { display: flex; align-items: center; gap: 14px; }
.arch-head .emoji { font-size: 48px; line-height: 1; width: 56px; text-align: center; flex: none; }
.arch-info { flex: 1; min-width: 0; }
.arch-info .name { font-size: 18px; font-weight: 800; }
.arch-info .meta-row { display: flex; align-items: center; gap: 16px; margin-top: 4px; }
.arch-info .sub { margin-top: 2px; font-size: 13px; color: var(--color-text-secondary); word-break: break-word; }
.arch-info .sub:empty { display: none; }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 700; }
.card-wrap { position: relative; margin-bottom: 10px; }
.card-wrap .card { margin-bottom: 0; padding-right: 66px; }
.copy-btn { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); font-size: 18px; }
.vis-opts { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 12px; }
.vis-opts .btn { padding: 10px 14px; }
.vis-opts .btn small { display: block; font-size: 12px; font-weight: 400; opacity: .8; margin-top: 2px; }
.link-btn { border: 0; background: transparent; color: #b45f10; font-size: 13px; min-height: 32px; padding: 0 4px; }
.msg .ng-btn { margin-left: 8px; padding: 0 8px; min-height: 22px; font-size: 11px; font-weight: 700; color: var(--color-text-secondary); background: transparent; border: 1px solid var(--border); border-radius: 999px; }
.msg .at { margin-left: 6px; font-size: 11px; color: var(--color-text-secondary); font-variant-numeric: tabular-nums; }
.arch-body audio { width: 100%; margin-top: 8px; }

/* modal / toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet { width: 100%; max-width: 560px; background: var(--surface); border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet h2 { margin: 0 0 4px; font-size: 18px; }
.sheet p { margin: 0 0 16px; font-size: 13px; color: var(--color-text-secondary); }
.sheet .row { display: flex; gap: 8px; margin-top: 14px; }
#toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border); padding: 10px 16px; border-radius: 999px; font-size: 14px;
  z-index: 20; max-width: 90%; text-align: center; opacity: 0; pointer-events: none; transition: opacity .25s; }
#toast.on { opacity: 1; }
#toast a { color: #b45f10; pointer-events: auto; }
