/* ===== テーマ変数 ===== */
:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --line: #dcd8cf;
  --line2: #c9c4b8;
  --text: #1c1f26;
  --muted: #5c5a55;
  --amber: #c2731c;
  --amber-hover: #a8611a;
  --on-amber: #ffffff;
  --thumb: #2b3140;
  --thumb-grad: linear-gradient(135deg, #343c48 0%, #262d38 100%);
  --overlay-text: #f2f0ea;
  --warn-bg: #fff4d6;
  --warn-line: #e0b24a;
  --warn-text: #6b4d00;
  --err-bg: #fde8e6;
  --err-line: #d9534f;
  --err-text: #8a1f1b;
  --ok-bg: #e4f3e6;
  --ok-line: #4caf6e;
  --ok-text: #1c5a2d;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #14181f;
  --surface: #1e242e;
  --line: #2a313d;
  --line2: #3a4250;
  --text: #f2f0ea;
  --muted: #b8b4aa;
  --amber: #e08a2e;
  --amber-hover: #c9771f;
  --on-amber: #14181f;
  --warn-bg: #3a2f14;
  --warn-line: #b88a2e;
  --warn-text: #f5d98a;
  --err-bg: #3d1c1a;
  --err-line: #d9534f;
  --err-text: #f6b3af;
  --ok-bg: #16301e;
  --ok-line: #4caf6e;
  --ok-text: #a9e3b8;
  color-scheme: dark;
}

/* ===== ベース ===== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--amber); }
a:hover { color: var(--amber-hover); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
input, textarea, select { font: inherit; }
svg { flex: 0 0 auto; }
[hidden] { display: none !important; }

#app { max-width: 520px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.screen { display: flex; flex-direction: column; flex: 1; }

/* ===== 共通部品 ===== */
.btn {
  height: 56px; display: flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 10px; font-size: 17px; font-weight: 700; width: 100%;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--amber); color: var(--on-amber); }
.btn-primary svg { stroke: var(--on-amber); }
.btn-outline { background: var(--surface); border: 1px solid var(--line2); color: var(--text); font-size: 16px; }
.btn-outline svg { stroke: var(--text); }
.btn-ghost { background: transparent; border: 1px solid var(--muted); color: var(--text); height: 52px; font-size: 16px; }
.btn-ghost svg { stroke: var(--text); }
.btn-sm { height: 44px; font-size: 15px; width: auto; padding: 0 16px; }
.btn-danger { background: transparent; border: 1px solid var(--err-line); color: var(--err-text); }
.btn-link {
  font-size: 15px; color: var(--amber); text-decoration: underline; line-height: 44px; display: inline-block;
}
.btn-link:hover { color: var(--amber-hover); }

.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 15px; font-weight: 700; color: var(--text); }
.input {
  height: 54px; width: 100%; padding: 0 16px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line2);
  font-size: 16px; color: var(--text); outline: none;
}
.input::placeholder { color: var(--muted); }
.input:focus { border-color: var(--amber); }
textarea.input { height: auto; min-height: 120px; padding: 14px 16px; line-height: 1.6; resize: vertical; }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 52px; }
.input-eye {
  position: absolute; right: 0; top: 0; width: 52px; height: 54px;
  display: flex; align-items: center; justify-content: center;
}
.input-eye svg { stroke: var(--muted); }
.code-input { text-align: center; letter-spacing: 8px; font-size: 24px; font-weight: 700; }
.help { font-size: 13px; color: var(--muted); line-height: 1.6; }
.center { text-align: center; }

.alert { padding: 12px 14px; border-radius: 10px; font-size: 15px; line-height: 1.6; border: 1px solid; }
.alert-error { background: var(--err-bg); border-color: var(--err-line); color: var(--err-text); }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-text); }
.alert-ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-text); }

.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); height: 44px; border-radius: 10px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line2);
}
.seg button { display: flex; align-items: center; justify-content: center; font-size: 15px; color: var(--text); border-left: 1px solid var(--line2); }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--amber); color: var(--on-amber); font-weight: 700; }

.badge { display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border-radius: 6px; background: var(--line); color: var(--text); font-size: 13px; }
.badge-amber { background: var(--amber); color: var(--on-amber); font-weight: 700; }
.badge-warn { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-text); }
.badge-ok { background: var(--ok-bg); border: 1px solid var(--ok-line); color: var(--ok-text); }
.badge-err { background: var(--err-bg); border: 1px solid var(--err-line); color: var(--err-text); }

.divider { height: 1px; background: var(--line); }
.divider-text { display: flex; align-items: center; gap: 12px; padding: 20px 24px; }
.divider-text .divider { flex: 1; }
.divider-text span { font-size: 13px; color: var(--muted); }

.iconbtn {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  border-radius: 10px; background: var(--surface); border: 1px solid var(--line);
}
.iconbtn svg { stroke: var(--text); }
.iconbtn:disabled { opacity: 0.35; }

.loading { padding: 40px 24px; text-align: center; color: var(--muted); font-size: 15px; }

/* ===== ヘッダー ===== */
.header {
  display: flex; flex-direction: column; gap: 10px; padding: 20px 20px 14px;
  border-bottom: 1px solid var(--line);
}
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.header-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.header-title .t { font-size: 20px; font-weight: 700; line-height: 1.3; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-title .s { font-size: 13px; color: var(--muted); line-height: 1.3; }
.header-user { display: flex; align-items: center; gap: 8px; }
.header-user .who { font-size: 13px; color: var(--muted); line-height: 1.3; text-align: right; max-width: 150px; }

/* ===== ログイン ===== */
.login-hero { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 88px 24px 40px; }
.login-mark { width: 64px; height: 64px; border-radius: 10px; background: var(--amber); display: flex; align-items: center; justify-content: center; }
.login-mark { color: var(--on-amber); }
.login-name { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.login-name .t { font-size: 24px; font-weight: 700; line-height: 1.3; color: var(--text); text-align: center; }
.login-name .s { font-size: 15px; color: var(--muted); line-height: 1.3; }
.login-hero.compact { padding: 48px 24px 28px; }
.form { display: flex; flex-direction: column; gap: 20px; padding: 0 24px; }
.form .links { display: flex; justify-content: center; padding: 4px 0; }
.form-foot { display: flex; flex-direction: column; gap: 10px; padding: 0 24px; }
.spacer { flex: 1; }
.page-foot { padding: 24px; font-size: 13px; color: var(--muted); text-align: center; line-height: 1.6; }
.form h2 { font-size: 20px; font-weight: 700; line-height: 1.4; margin: 0; }
.form p { margin: 0; font-size: 15px; line-height: 1.7; color: var(--text); }

/* ===== 一覧 ===== */
.chips { display: flex; gap: 8px; padding: 14px 20px 4px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; height: 44px; display: flex; align-items: center; padding: 0 18px;
  border-radius: 10px; background: var(--surface); border: 1px solid var(--line); color: var(--text); font-size: 15px;
}
.chip.on { background: var(--amber); border-color: var(--amber); color: var(--on-amber); font-weight: 700; }
.list-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 20px 6px; font-size: 13px; color: var(--muted); }
.list-meta .sort { display: flex; align-items: center; gap: 6px; }
.list-meta select { height: 32px; font-size: 13px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; }
.list-meta .flip { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 6px; background: var(--surface); border: 1px solid var(--line); }
.list-meta .flip svg { stroke: var(--text); }
.search-wrap { padding: 12px 20px 0; }
.search-wrap .input { height: 48px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; padding: 6px 20px 28px; }
.card { display: flex; flex-direction: column; align-items: stretch; gap: 8px; text-align: left; width: 100%; min-width: 0; -webkit-appearance: none; appearance: none; }
/* iOS Safari は <button> の子を幅いっぱいに伸ばさない（stretch が効かない）ので、幅は明示する */
.card > * { width: 100%; min-width: 0; }
.thumb {
  position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 10px; background: var(--thumb);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
/* aspect-ratio 非対応（iOS 14 以前）の 16:9 確保 */
@supports not (aspect-ratio: 16 / 9) {
  .thumb::before { content: ''; display: block; width: 0; padding-top: 56.25%; }
}
.thumb .grad { position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: var(--thumb-grad); }
.thumb img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb .initial { position: absolute; left: 8px; top: 4px; font-size: 22px; font-weight: 700; color: var(--overlay-text); opacity: 0.35; line-height: 1.3; }
.thumb .play { position: relative; flex: 0 0 auto; color: var(--overlay-text); display: flex; }
.thumb .pin { position: absolute; left: 6px; top: 6px; padding: 2px 6px; border-radius: 6px; background: rgba(20,24,31,0.85); color: var(--overlay-text); font-size: 13px; line-height: 1.4; display: flex; align-items: center; gap: 3px; }
.thumb .pin svg { stroke: var(--overlay-text); }
.thumb .tag { position: absolute; right: 6px; bottom: 6px; padding: 2px 6px; border-radius: 6px; background: rgba(20,24,31,0.85); color: var(--overlay-text); font-size: 13px; line-height: 1.4; white-space: nowrap; }
.thumb .tag.dur { font-variant-numeric: tabular-nums; font-weight: 700; }
.card .ttl { font-size: 16px; font-weight: 700; line-height: 1.4; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .date { font-size: 13px; color: var(--muted); line-height: 1.3; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); font-size: 15px; display: flex; flex-direction: column; gap: 16px; align-items: center; }

/* ===== 再生 ===== */
.back-row { display: flex; align-items: center; padding: 12px 12px 8px; }
.back-btn { height: 44px; display: flex; align-items: center; gap: 6px; padding: 0 10px; border-radius: 10px; color: var(--text); font-size: 16px; font-weight: 700; }
.back-btn svg { stroke: var(--text); }
.player-box { position: relative; width: 100%; aspect-ratio: 16 / 9; background: var(--thumb-grad); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.player-box img.cover { position: absolute; left: 0; top: 0; width: 100%; height: 100%; object-fit: cover; }
.player-box .lid { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; width: 100%; }
.player-box .lid-btn { width: 72px; height: 72px; border-radius: 36px; background: var(--amber); display: flex; align-items: center; justify-content: center; position: relative; }
.player-box .lid-btn { color: var(--on-amber); }
.player-box .lid-text { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; font-size: 13px; color: var(--overlay-text); }
.player-box .lid-tag { position: absolute; right: 10px; top: 10px; padding: 3px 8px; border-radius: 6px; background: rgba(20,24,31,0.85); color: var(--overlay-text); font-size: 13px; }
.player-box iframe { position: absolute; left: 0; top: 0; width: 100%; height: 100%; border: 0; background: #000; }
/* §13-6 持ち出し対策：再生画面（通常・全画面とも同じ要素）だけ 長押しメニュー／テキスト選択／ドラッグを止める。一覧・管理画面には適用しない */
.player-wrap { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.player-wrap img { -webkit-user-drag: none; pointer-events: none; }
/* 視聴者名の透かし（Vimeoのみ・app.js startWatermark）。pointer-events:none でプレーヤー操作を邪魔しない。四隅を約1.5秒かけて移動 */
.player-box .wm {
  position: absolute; z-index: 3; pointer-events: none; user-select: none;
  font-size: 13px; line-height: 1.2; color: #fff; opacity: .35; white-space: nowrap; max-width: 60%; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0,0,0,.8), 0 0 6px rgba(0,0,0,.6);
  transition: top 1.5s ease, left 1.5s ease, transform 1.5s ease;
}
.player-box .wm-tr { left: calc(100% - 12px); top: 10px; transform: translateX(-100%); }
.player-box .wm-br { left: calc(100% - 12px); top: calc(100% - 44px); transform: translate(-100%, -100%); }
.player-box .wm-bl { left: 12px; top: calc(100% - 44px); transform: translateY(-100%); }
.player-box .wm-tl { left: 12px; top: 10px; transform: none; }
/* 全画面では右上の閉じるボタン（44px＋余白）と重ならないよう、右上・左上の透かしを下げる */
#fsOverlay .player-box .wm-tr { left: calc(100% - 64px); top: calc(18px + env(safe-area-inset-top)); }
#fsOverlay .player-box .wm-tl { top: calc(18px + env(safe-area-inset-top)); }
.player-ctrl { display: flex; align-items: center; gap: 8px; padding: 14px 16px 6px; }
.player-ctrl .fs {
  flex: 0 0 auto; min-width: 92px; height: 48px; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 10px;
  border-radius: 10px; background: var(--surface); border: 1px solid var(--line2); color: var(--text); font-size: 15px; font-weight: 700; white-space: nowrap;
}
.player-ctrl .fs svg { stroke: var(--text); }
.player-ctrl .seg { flex: 1 1 0; min-width: 0; height: 48px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.seg.rate button { font-size: 13px; padding: 0 2px; white-space: nowrap; min-width: 0; }
.play-head { display: flex; flex-direction: column; gap: 10px; padding: 14px 20px 0; }
.play-head .cat { align-self: flex-start; }
.play-head h1 { font-size: 20px; font-weight: 700; line-height: 1.45; margin: 0; color: var(--text); }
.play-head .meta { display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--muted); }
.play-head .meta svg { stroke: var(--muted); }
.play-sep { padding: 18px 20px 0; }
.play-desc { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px 32px; }
.play-desc h2 { font-size: 16px; font-weight: 700; margin: 0; color: var(--text); }
.play-desc p { margin: 0; font-size: 16px; line-height: 1.8; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.play-admin { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 20px 28px; }

/* 全画面オーバーレイ */
#fsOverlay { position: fixed; inset: 0; z-index: 200; background: #000; display: flex; flex-direction: column; }
#fsOverlay .fs-top { position: absolute; right: 10px; top: calc(10px + env(safe-area-inset-top)); z-index: 2; }
#fsOverlay .fs-close { width: 44px; height: 44px; border-radius: 10px; background: rgba(20,24,31,0.8); display: flex; align-items: center; justify-content: center; }
#fsOverlay .fs-close svg { stroke: #f2f0ea; }
#fsOverlay .fs-stage { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
#fsOverlay .fs-stage .player-box { width: 100%; max-height: 100%; background: #000; }
#fsOverlay .fs-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); background: #14181f; }
#fsOverlay .fs-bar .snd { flex: 0 0 auto; min-width: 100px; padding: 0 10px; white-space: nowrap; height: 48px; display: flex; align-items: center; justify-content: center; gap: 6px; border-radius: 10px; background: #1e242e; border: 1px solid #3a4250; color: #f2f0ea; font-size: 15px; font-weight: 700; }
#fsOverlay .fs-bar .snd svg { stroke: #f2f0ea; }
#fsOverlay .fs-bar .seg { flex: 1 1 0; min-width: 0; height: 48px; grid-template-columns: repeat(5, minmax(0, 1fr)); background: #1e242e; border-color: #3a4250; }
#fsOverlay .fs-bar .seg button { color: #f2f0ea; border-color: #3a4250; }
#fsOverlay .fs-bar .seg button.on { background: #e08a2e; color: #14181f; }
@media (orientation: landscape) {
  #fsOverlay .fs-stage .player-box { height: 100%; aspect-ratio: auto; }
}

/* ===== 設定シート ===== */
.sheet-back { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,0.55); }
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 520px; z-index: 101;
  border-radius: 16px 16px 0 0; background: var(--surface); border-top: 1px solid var(--line2);
  display: flex; flex-direction: column; gap: 4px; padding: 10px 20px calc(28px + env(safe-area-inset-bottom));
  max-height: 90vh; overflow-y: auto;
}
.sheet .grab { display: flex; justify-content: center; padding: 0 0 12px; }
.sheet .grab div { width: 40px; height: 5px; border-radius: 3px; background: var(--line2); }
.sheet h2 { font-size: 20px; font-weight: 700; line-height: 1.3; color: var(--text); padding: 0 0 12px; margin: 0; }
.sheet .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 6px 0; border-top: 1px solid var(--line); }
.sheet .row .lbl { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; color: var(--text); }
.sheet .row .lbl svg { stroke: var(--text); }
.sheet .row .seg { width: 176px; background: var(--bg); }
.sheet .row.who { justify-content: flex-start; gap: 10px; }
.sheet .row.who svg { stroke: var(--muted); }
.sheet .row.who .n { font-size: 15px; color: var(--text); line-height: 1.3; }
.sheet .row.who .e { font-size: 13px; color: var(--muted); line-height: 1.3; word-break: break-all; }
.sheet .row.nav { min-height: 56px; }
.sheet .row.nav button { width: 100%; height: 56px; display: flex; align-items: center; justify-content: space-between; font-size: 16px; font-weight: 700; color: var(--text); }
.sheet .row.nav button svg { stroke: var(--text); }
.sheet .foot { display: flex; flex-direction: column; gap: 10px; padding: 16px 0 0; border-top: 1px solid var(--line); }
.sheet .foot .links { display: flex; justify-content: center; }

/* ===== 管理画面 ===== */
.tabs { display: flex; gap: 6px; padding: 14px 20px 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; height: 44px; display: flex; align-items: center; padding: 0 16px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); color: var(--text); font-size: 15px; }
.tab.on { background: var(--amber); border-color: var(--amber); color: var(--on-amber); font-weight: 700; }
.admin-body { display: flex; flex-direction: column; gap: 16px; padding: 16px 20px 40px; }
.admin-body h2 { font-size: 17px; font-weight: 700; margin: 0; color: var(--text); }
.admin-body h3 { font-size: 16px; font-weight: 700; margin: 0; color: var(--text); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
/* 動画行（動画タブ／アーカイブタブ共通）。スマホ＝「サムネ＋タイトル」の下に操作1行、PC(1100px〜)＝1行に横並び */
.vrow {
  display: grid; grid-template-columns: 96px minmax(0, 1fr); grid-template-areas: "thumb info" "ops ops";
  column-gap: 12px; row-gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); align-items: start;
}
.vrow:first-child { border-top: 0; }
.vrow .vthumb { grid-area: thumb; width: 96px; }
.vrow .vthumb .thumb { border-radius: 8px; }
.vrow .vthumb .thumb .play { display: none; }
.vrow .vthumb .thumb .initial { font-size: 16px; }
.vrow .vthumb .thumb .tag, .vrow .vthumb .thumb .pin { font-size: 11px; padding: 1px 5px; }
.vrow .vinfo { grid-area: info; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.vrow .vinfo .ttl { font-size: 16px; font-weight: 700; line-height: 1.4; color: var(--text); word-break: break-word; }
.vrow .vinfo .ttl .pinned { display: inline-flex; vertical-align: -1px; margin-right: 4px; color: var(--amber); }
.vrow .vinfo .ttl .pinned svg { stroke: var(--amber); }
.vrow .vinfo .sub { font-size: 13px; color: var(--muted); line-height: 1.4; }
.vrow .badges { display: flex; flex-wrap: wrap; gap: 6px; }
.vrow .badges .badge { height: 22px; padding: 0 7px; font-size: 12px; gap: 3px; }
.vrow .badges .badge svg { stroke: currentColor; }
.badge-off { background: var(--line); color: var(--muted); }
/* 操作：公開スイッチ｜↑↓｜編集｜⋯ */
.vrow .vops { grid-area: ops; display: flex; align-items: center; gap: 8px; min-width: 0; }
.vrow .vops .pub { margin-right: auto; }
.vrow .order { display: flex; flex-direction: row; gap: 4px; }
.vrow .vops .vedit { height: 44px; padding: 0 12px; font-size: 15px; gap: 4px; flex: 0 0 auto; }
.vrow .vops .vedit svg { width: 18px; height: 18px; }
.iconbtn.more { border-radius: 22px; }
.iconbtn.more svg { fill: var(--text); stroke: none; }
.iconbtn.more[aria-expanded="true"] { background: var(--line); }
/* 公開スイッチ（44px・ON=琥珀／OFF=グレー） */
.pub { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 4px; flex: 0 0 auto; }
.pub .sw { position: relative; width: 44px; height: 26px; border-radius: 13px; background: var(--line2); transition: background 0.15s ease; flex: 0 0 auto; }
.pub .sw .knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 10px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: transform 0.15s ease; }
.pub.on .sw { background: var(--amber); }
.pub.on .sw .knob { transform: translateX(18px); }
.pub .swl { font-size: 14px; font-weight: 700; color: var(--muted); }
.pub.on .swl { color: var(--text); }
/* ⋯メニュー（設定シートの部品を流用） */
.sheet.menu .mttl { font-size: 13px; color: var(--muted); line-height: 1.4; padding: 0 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet.menu .row.nav button { justify-content: flex-start; gap: 10px; font-weight: 500; }
.sheet.menu .row.nav button svg { stroke: var(--text); width: 18px; height: 18px; }
.sheet.menu .row.nav button.danger { color: var(--err-text); }
.sheet.menu .foot { padding: 8px 0 0; }
.preview-box { display: flex; gap: 12px; align-items: flex-start; }
.preview-box .thumb { width: 140px; flex: 0 0 140px; }
.preview-box .pinfo { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); word-break: break-all; line-height: 1.6; }
.kv { display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
.kv div { display: flex; justify-content: space-between; gap: 12px; }
.kv div span:first-child { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 14px; word-break: break-all; }
.sample { font-size: 14px; line-height: 1.7; }
.sample div { display: flex; gap: 8px; }
.trow { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-top: 1px solid var(--line); }
.trow:first-child { border-top: 0; }
.trow .t { font-size: 16px; font-weight: 700; }
.trow .s { font-size: 13px; color: var(--muted); }
.checkrow { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 16px; }
.checkrow input { width: 22px; height: 22px; }
.gap8 { display: flex; flex-direction: column; gap: 8px; }
.gap12 { display: flex; flex-direction: column; gap: 12px; }

/* トースト */
#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 300; background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 10px; font-size: 15px; max-width: 90%; text-align: center; }

/* =====================================================================
   PC／タブレット向けレイアウト（〜767px のスマホ表示は上の既存CSSのまま。
   ここはメディアクエリでの上書きだけ）
   ===================================================================== */
:root { --shadow: rgba(28, 31, 38, 0.18); }
:root[data-theme="dark"] { --shadow: rgba(0, 0, 0, 0.55); }
/* PC専用の部品はスマホでは出さない（DOMには常にある） */
.pc-only { display: none; }
.header-search { display: none; }
.others { display: none; }
/* 登録フォームの左右グループ。.panel と同じ縦gap(14px)なのでスマホの見た目は変わらない */
.vf-col { display: flex; flex-direction: column; gap: 14px; }

/* ===== タブレット（768px〜） ===== */
@media (min-width: 768px) {
  #app { max-width: 100%; padding: 0 24px; }

  /* ヘッダー：塾名（左）＋検索（中央）＋ログイン中＋歯車（右）を1行に。スクロールしても上に固定 */
  .header { position: sticky; top: 0; z-index: 50; background: var(--bg); padding: 16px 0 12px; }
  .header-row { gap: 24px; }
  .header-title { flex: 0 1 auto; max-width: 320px; }
  .header-search { display: block; flex: 1 1 auto; max-width: 560px; margin: 0 auto; min-width: 0; }
  .header-search .input { height: 44px; }
  .header-user { flex: 0 0 auto; }
  .header-user .who { max-width: none; white-space: nowrap; }
  .header-user .who br { display: none; }

  /* 一覧：チップと並び替えを同じ行に。ページ内の検索欄はヘッダーへ移動（非表示） */
  .list-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0 4px; }
  .list-bar .chips { flex: 1 1 auto; min-width: 0; padding: 0; }
  .list-bar .search-wrap { display: none; }
  .list-bar .list-meta { flex: 0 0 auto; padding: 0; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px 16px; padding: 12px 0 40px; }
  .card { border-radius: 10px; transition: transform 0.15s ease; }
  .card .thumb { transition: box-shadow 0.15s ease; }
  @media (hover: hover) {
    .card:hover { transform: translateY(-3px); }
    .card:hover .thumb { box-shadow: 0 10px 24px var(--shadow); }
    .card:hover .ttl { color: var(--amber); }
  }
  .empty { padding: 64px 24px; }

  /* 再生（タブレットは縦並びのまま。余白だけ整える） */
  .back-row { padding: 12px 0 8px; }
  .back-btn { margin-left: -10px; }
  #playerWrap .player-box { border-radius: 10px; }
  .player-ctrl { padding: 14px 0 6px; }
  .player-ctrl .seg { flex: 0 1 420px; }
  .play-head { padding: 14px 0 0; }
  .play-sep { padding: 18px 0 0; }
  .play-desc { padding: 18px 0 32px; }
  .play-admin { padding: 0 0 28px; }

  /* ログイン／コード入力／パスワード設定：中央に幅440pxのカード */
  .screen.auth { align-items: center; padding: 40px 0 0; }
  .auth-card {
    width: 440px; max-width: 100%; background: var(--surface); border: 1px solid var(--line);
    border-radius: 16px; padding: 32px; display: flex; flex-direction: column;
  }
  .auth-card .login-hero { padding: 8px 0 28px; }
  .auth-card .login-hero.compact { padding: 4px 0 24px; }
  .auth-card .form { padding: 0; }
  .auth-card .divider-text { padding: 20px 0; }
  .auth-card .form-foot { padding: 0; }
  .screen.auth .page-foot { padding: 24px 24px 40px; }
  .screen .form[style] { max-width: 520px; width: 100%; align-self: center; padding-left: 0; padding-right: 0; }

  /* 設定：下から出るシートではなく、歯車の下のドロップダウン（位置は app.js が歯車に合わせる） */
  .sheet-back:not(.menu-back) { background: transparent; }
  .sheet:not(.menu) {
    left: auto; bottom: auto; top: 72px; right: 24px; transform: none; width: 320px; max-width: calc(100vw - 48px);
    border-radius: 16px; border: 1px solid var(--line2); box-shadow: 0 16px 40px var(--shadow);
    padding: 8px 16px 16px; max-height: calc(100vh - 96px);
  }
  .sheet:not(.menu) .grab { display: none; }
  .sheet h2 { font-size: 17px; padding: 8px 0 8px; }
  .sheet .row { min-height: 52px; }
  .sheet .row.nav button { height: 52px; }
  .sheet .foot { padding: 12px 0 0; }
  .sheet .foot .btn-ghost { height: 48px; }

  /* 管理画面／運営者 */
  .tabs { padding: 16px 0 0; }
  .admin-body { padding: 16px 0 48px; }
}

/* ===== PC（1100px〜） ===== */
@media (min-width: 1100px) {
  #app { max-width: 1344px; padding: 0 32px; }
  .pc-only { display: block; }
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px 20px; }
  .sheet:not(.menu) { right: 32px; }

  /* 再生：左に動画（約68%）、右にサイドバー（タイトル・収録日・カテゴリ・説明・他の回） */
  .play-cols { display: grid; grid-template-columns: minmax(0, 68fr) minmax(0, 32fr); gap: 0 32px; align-items: start; padding-bottom: 40px; }
  .play-main { min-width: 0; }
  .play-side {
    min-width: 0; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto;
    display: flex; flex-direction: column; padding-top: 12px;
  }
  .player-ctrl { justify-content: flex-start; gap: 10px; }
  .player-ctrl .seg { flex: 0 1 380px; }
  .player-ctrl .snd.pc-only {
    display: flex; flex: 0 0 auto; min-width: 100px; height: 48px; align-items: center; justify-content: center; gap: 6px; padding: 0 10px;
    border-radius: 10px; background: var(--surface); border: 1px solid var(--line2); color: var(--text); font-size: 15px; font-weight: 700; white-space: nowrap;
  }
  .player-ctrl .snd.pc-only svg { stroke: var(--text); }
  .play-side .play-head { padding: 0; }
  .play-side .play-head h1 { font-size: 22px; }
  .play-side .play-sep { padding: 16px 0 0; }
  .play-side .play-desc { padding: 16px 0 20px; }
  .play-side .play-admin { padding: 0 0 20px; }
  .others { display: flex; flex-direction: column; gap: 4px; padding: 16px 0 8px; border-top: 1px solid var(--line); }
  .others h2 { font-size: 16px; font-weight: 700; margin: 0 0 6px; color: var(--text); }
  .others .orow { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px; border-radius: 10px; text-align: left; -webkit-appearance: none; appearance: none; }
  .others .orow:hover { background: var(--surface); }
  .others .orow.on { background: var(--surface); box-shadow: inset 0 0 0 1px var(--amber); }
  .others .orow .thumb { width: 112px; flex: 0 0 112px; border-radius: 6px; }
  .others .orow .thumb .play { display: none; }
  .others .orow .thumb .initial { font-size: 16px; }
  .others .orow .thumb .tag, .others .orow .thumb .pin { font-size: 11px; padding: 1px 5px; }
  .others .orow .oinfo { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
  .others .orow .ot { font-size: 15px; font-weight: 700; line-height: 1.4; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .others .orow .od { font-size: 13px; color: var(--muted); line-height: 1.3; }

  /* 管理画面：最大幅1100px。動画一覧は1行1本（サムネ｜タイトル・収録日・カテゴリ｜公開スイッチ｜↑↓｜編集｜⋯）・行高さ一定 */
  .tabs, .admin-body { max-width: 1100px; width: 100%; margin: 0 auto; }
  .vrow {
    grid-template-columns: 128px minmax(0, 1fr) auto; grid-template-areas: "thumb info ops";
    column-gap: 16px; row-gap: 0; align-items: center; padding: 10px 0;
  }
  .vrow .vthumb { width: 128px; }
  .vrow .vinfo .ttl { font-size: 15px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .vrow .vops { gap: 12px; }
  .vrow .vops .pub { margin-right: 4px; }
  .vrow .vops .vedit { padding: 0 14px; }
  /* ⋯メニュー：PCではボタン直下のドロップダウン（位置は app.js の positionMenu が付ける） */
  .sheet-back.menu-back { background: transparent; }
  .sheet.menu {
    left: auto; bottom: auto; top: 72px; right: 32px; transform: none; width: 260px; max-width: calc(100vw - 64px);
    border-radius: 12px; border: 1px solid var(--line2); box-shadow: 0 16px 40px var(--shadow);
    padding: 8px 10px 4px; max-height: calc(100vh - 96px);
  }
  .sheet.menu .grab, .sheet.menu .foot { display: none; }
  .sheet.menu .mttl { padding: 4px 6px 8px; }
  .sheet.menu .row { min-height: 48px; padding: 2px 0; }
  .sheet.menu .row.nav button { height: 46px; padding: 0 6px; border-radius: 8px; font-size: 15px; }
  .sheet.menu .row.nav button:hover { background: var(--bg); }

  /* 登録フォーム：左=URL＋プレビュー、右=タイトル・説明・カテゴリ・収録日 */
  #f-video { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; align-items: start; }
  #f-video > .btn { align-self: end; }
  .preview-box .thumb { width: 200px; flex: 0 0 200px; }

  /* 運営者：テナント一覧をテーブル風に */
  .trow { display: grid; grid-template-columns: minmax(0, 1fr) 160px auto auto; column-gap: 16px; align-items: center; }
  .trow .row-actions { flex-wrap: nowrap; }
}

/* ===== ワイドPC（1440px〜） ===== */
@media (min-width: 1440px) {
  .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
