:root {
  --bg: #0f0f14;
  --surface: #1a1a22;
  --surface-2: #24242e;
  --text: #ececf1;
  --muted: #9a9aab;
  --accent: #7c5cff;
  --live: #ff3b4e;
  --danger: #ff6b6b;
  --twitch: #9146ff;
  --youtube: #ff0033;
  --kick: #53fc18;
  --twitcasting: #1e90ff;
  --niconico: #d9d9d9;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.5;
}
header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(15, 15, 20, 0.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--surface-2);
}
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 10px; }
.header-actions { display: flex; gap: 8px; }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
.hint, .empty { color: var(--muted); font-size: 14px; }
.empty { text-align: center; padding: 32px 0; }

button, input, select { font: inherit; color: inherit; }
button {
  border: 0; border-radius: 10px; padding: 8px 14px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600;
}
button.ghost { background: var(--surface-2); color: var(--text); font-weight: 500; }
button.danger { background: transparent; color: var(--danger); padding: 6px 0; font-weight: 500; }
button:disabled { opacity: 0.5; cursor: default; }
input, select {
  background: var(--surface-2); border: 1px solid transparent; border-radius: 10px;
  padding: 9px 12px; min-width: 0;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card { background: var(--surface); border-radius: var(--radius); padding: 10px; }
.follow {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  background: var(--surface-2); color: var(--text); padding: 10px; border-radius: 12px;
  border: 2px solid transparent; transition: border-color .15s, background .15s;
}
.card.following .follow { border-color: var(--accent); background: rgba(124, 92, 255, 0.15); }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--bg); flex: none; }
.card.live .avatar { box-shadow: 0 0 0 2px var(--live); }
.name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-badge { background: var(--live); color: #fff; font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 6px; }
.bell { font-size: 12px; color: var(--muted); }
.card.following .bell { color: var(--accent); }

.accounts { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px;
  padding: 2px 4px 2px 8px; border-radius: 999px; background: var(--bg);
  border-left: 3px solid var(--c, var(--muted));
}
.chip a { color: var(--text); text-decoration: none; }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--live); }
.chip .status { color: var(--muted); }
.chip button { background: none; color: var(--muted); padding: 0 4px; font-weight: 400; }

details.add-account { margin-top: 8px; font-size: 13px; }
details.add-account summary { color: var(--muted); cursor: pointer; }
details.add-account form { margin-top: 8px; }
.row { display: flex; gap: 6px; }
.row input { flex: 1; }

.panel { margin-top: 24px; background: var(--surface); border-radius: var(--radius); padding: 14px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }

#toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(150%);
  background: var(--surface-2); padding: 10px 16px; border-radius: 12px; max-width: calc(100% - 32px);
  transition: transform .25s; box-shadow: 0 6px 24px rgba(0,0,0,.4);
}
#toast.show { transform: translateX(-50%) translateY(0); }

.results { list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.results .hint { color: var(--muted); font-size: 13px; padding: 4px 2px; }
.result { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border-radius: 10px; padding: 8px; min-width: 0; }
.avatar.sm { width: 32px; height: 32px; }
.result-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.result-text strong, .result-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-text span { color: var(--muted); font-size: 12px; }
.result button { padding: 6px 12px; flex: none; }

.legal { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; padding: 24px 16px 40px; font-size: 13px; }
.legal a { color: inherit; opacity: .7; }

#paywall { border: 0; border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 20px; max-width: 420px; width: calc(100% - 32px); }
#paywall::backdrop { background: rgba(0, 0, 0, .6); }
#paywall h2 { margin: 0 0 8px; }
#paywall button { width: 100%; margin-top: 8px; }
.paywall-list { padding-left: 20px; margin: 8px 0; }

/* ---------- ログイン前（ウェルカム） ---------- */
.hero { max-width: 420px; margin: 0 auto; padding: 24px 0 8px; text-align: center; }
.hero-icon { border-radius: 20px; box-shadow: 0 8px 28px rgba(124, 92, 255, .35); }
.hero-title { font-size: 26px; line-height: 1.35; margin: 18px 0 10px; letter-spacing: .01em; }
.hero-sub { color: var(--muted); font-size: 15px; margin: 0 0 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; list-style: none; padding: 0; margin: 0 0 22px; }
.chips li { background: var(--surface-2); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.features { list-style: none; padding: 0; margin: 0 0 26px; display: grid; gap: 10px; text-align: left; }
.features li { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 2px; }
.features strong { font-size: 15px; }
.features span { color: var(--muted); font-size: 13px; }
.hero-actions { display: grid; gap: 10px; }
.hero-actions button { padding: 14px 16px; font-size: 16px; border-radius: 12px; }
.hero-actions button.apple { background: #fff; color: #000; }
.fine { color: var(--muted); font-size: 12px; margin: 16px 0 0; }
.fine a { color: inherit; text-decoration: underline; }

#toast:empty { display: none; }

/* カード下部：「リストから外す」は控えめに右下へ */
.card-foot { display: flex; justify-content: flex-end; margin-top: 6px; }
button.unfollow { font-size: 12px; font-weight: 400; padding: 10px 6px; margin: -4px -6px -6px 0; opacity: .9; line-height: 1.4; }
details.add-account summary { padding: 8px 0; font-size: 15px; color: var(--text); }

.hint.small { font-size: 12px; margin: 6px 0 0; }

/* ---------- ログイン後の画面（整理） ---------- */
.list-title { font-size: 16px; margin: 22px 0 4px; }
#add-streamer { margin-top: 0; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: rgba(124, 92, 255, .16); border: 1px solid rgba(124, 92, 255, .5); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 14px; font-size: 13px; }
.banner button { padding: 8px 12px; font-size: 13px; }

/* 通知スイッチ */
.notify-toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px; color: var(--muted); user-select: none; }
.notify-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.notify-toggle .track { position: relative; width: 38px; height: 22px; border-radius: 999px; background: var(--surface-2); border: 1px solid #3a3a48; transition: background .15s; }
.notify-toggle .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #9a9aab; transition: transform .15s, background .15s; }
.notify-toggle input:checked + .track { background: var(--accent); border-color: var(--accent); }
.notify-toggle input:checked + .track::after { transform: translateX(16px); background: #fff; }
.notify-toggle input:focus-visible + .track { outline: 2px solid #fff; outline-offset: 2px; }
.card.muted .follow { opacity: .55; background: var(--surface-2); border-color: transparent; }
.card.muted .follow .notify-toggle { opacity: 1; }

/* フッター（ログアウト・アカウント削除） */
.legal button { padding: 6px 12px; font-size: 13px; }

.legal { flex-direction: column; align-items: center; gap: 12px; }
.legal-links { display: flex; gap: 16px; }
.legal-actions { display: flex; gap: 10px; align-items: center; }
.legal-actions button.danger { padding: 6px 4px; }

/* 名前を広く使う: LIVE はアイコンに重ね、名前は2行まで */
.avatar-wrap { position: relative; flex: none; display: inline-flex; }
.avatar-wrap .live-badge { position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%); font-size: 9px; padding: 1px 6px; line-height: 1.4; box-shadow: 0 0 0 2px var(--surface-2); }
.follow .name { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-all; line-height: 1.3; }
.follow { padding-bottom: 14px; }
.notify-toggle { flex: none; }

/* スイッチは縦並び（スイッチの下に「通知」）にして、横幅を節約 */
.notify-toggle { flex-direction: column; gap: 2px; }
.notify-toggle .toggle-text { font-size: 10px; line-height: 1; }
.follow { gap: 8px; }

/* カード下部: 左「名前を変更」／右「リストから外す」 */
.card-foot { justify-content: space-between; align-items: center; }
button.link { background: none; color: var(--muted); font-size: 12px; font-weight: 400; padding: 10px 6px; margin: -4px 0 -6px -6px; text-decoration: underline; text-underline-offset: 3px; }

/* iPhone は 16px 未満の入力欄に触れると画面が拡大されるため、16px にそろえる */
input, select, textarea { font-size: 16px; }

/* 画面が横にはみ出して拡大されたように見えるのを防ぐ */
html, body { overflow-x: hidden; max-width: 100%; touch-action: manipulation; }
.grid { grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); }
.card { min-width: 0; }
.chip { max-width: 100%; min-width: 0; }
.chip a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* display を指定した要素でも hidden 属性で確実に隠す（通知許可済みなのに案内帯が残る不具合の修正） */
[hidden] { display: none !important; }

/* 小さいボタンも、指で押しやすいように、押せる範囲を広げる */
.chip button { padding: 6px 10px; margin: -6px -4px -6px 0; }
button.link { padding: 10px 4px; }
button.danger { padding: 10px 0; }

/* 通知の文字を押すと、その配信を開ける */
#toast.tappable { cursor: pointer; text-decoration: underline; }


/* ---------- はじめての人向け・共有・評価 ---------- */
.onboard { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-top: 12px; }
.onboard h3 { margin: 0 0 8px; font-size: 16px; }
.onboard ol { margin: 0 0 12px; padding-left: 20px; line-height: 1.8; font-size: 14px; }
.genre-chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 8px 0 0; }
.genre-chips button { background: var(--surface-2); border-radius: 999px; padding: 10px 16px; font-size: 14px; font-weight: 500; }
.card-foot { gap: 4px; flex-wrap: wrap; }
