/* 大画面表示 */
html, body { height: 100%; }
body { background: #0a1020; color: #f1f5f9; overflow: hidden; --scale: 1; --n: 6; }
body.idle { cursor: none; }

#bg { position: fixed; inset: 0; z-index: 0; }
#bg img, #bg video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
#bg.img img, #bg.vid video { display: block; }
#dim { position: fixed; inset: 0; z-index: 1; background: #050a16; opacity: 0; pointer-events: none; transition: opacity .3s; }
body.has-bg #dim { opacity: var(--dim, .55); }

/* 上部バー */
.bar { position: relative; z-index: 3; height: 64px; display: flex; align-items: center; gap: 24px; padding: 0 28px;
  background: linear-gradient(180deg, rgba(5,10,22,.9), rgba(5,10,22,.6)); border-bottom: 1px solid rgba(255,255,255,.08); font-family: "Noto Sans JP", sans-serif; }
.brand { font-weight: 700; font-size: 22px; letter-spacing: .04em; display: flex; align-items: center; gap: 12px; }
.brand small { font-weight: 400; font-size: 13px; opacity: .55; letter-spacing: .08em; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: conic-gradient(from 200deg, #38bdf8, #a3e635, #fbbf24, #f472b6, #c084fc, #38bdf8); box-shadow: 0 0 0 3px rgba(255,255,255,.08); }
.status { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 16px; padding: 6px 14px; border-radius: 999px; background: rgba(255,255,255,.06); }
.status i { width: 10px; height: 10px; border-radius: 50%; background: #64748b; }
.status.on i { background: #ef4444; box-shadow: 0 0 0 0 rgba(239,68,68,.6); animation: pulse 1.6s infinite; }
.status.on { background: rgba(239,68,68,.14); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(239,68,68,.6); } 70% { box-shadow: 0 0 0 10px rgba(239,68,68,0); } 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); } }
.clock { font-size: 22px; font-variant-numeric: tabular-nums; opacity: .85; font-family: "Noto Sans", sans-serif; }

/* 言語見出し・本文 共通 */
.heads, .stage { position: relative; z-index: 2; }
.lname { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.lname .nat { font-weight: 700; font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lname .jn { font-size: 13px; opacity: .6; white-space: nowrap; font-family: "Noto Sans JP", sans-serif; }
.lname .badge-weak { font-size: 10px; }
.pending { display: inline-flex; gap: .3em; opacity: .55; }
.pending b { width: .35em; height: .35em; border-radius: 50%; background: currentColor; animation: dot 1.2s infinite; }
.pending b:nth-child(2) { animation-delay: .2s; } .pending b:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.err { opacity: .5; font-size: .6em; font-family: "Noto Sans JP", sans-serif; }
.interim { color: #94a3b8; }
.interim::after { content: "▍"; animation: blink 1s steps(1) infinite; margin-left: 2px; color: #38bdf8; }
@keyframes blink { 50% { opacity: 0; } }
.fresh { animation: fadein .5s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
mark { background: transparent; color: #fde68a; text-decoration: underline; text-decoration-color: rgba(253,230,138,.5); text-underline-offset: .18em; text-decoration-thickness: 2px; padding: 0; }

/* ===== 列表示：言語ごとの列、1文ごとに横がそろう ===== */
.layout-columns .heads { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 0 18px; padding: 16px 28px 10px; background: rgba(5,10,22,.55); }
.layout-columns .heads .h { border-top: 4px solid var(--lc); padding-top: 10px; }
.layout-columns .stage { height: calc(100vh - 64px - 74px); display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; padding: 0 28px 22px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 22vh); mask-image: linear-gradient(to bottom, transparent 0, #000 22vh); }
.layout-columns .grid { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 0 18px; }
.layout-columns .cell { padding: .55em 0 .6em; border-bottom: 1px solid rgba(255,255,255,.08); font-size: calc(var(--scale) * min(4.2vh, 10vw / var(--n))); line-height: 1.45; font-weight: 500; }
.layout-columns .r-old .cell { opacity: .38; font-size: calc(var(--scale) * min(3.2vh, 7.6vw / var(--n))); }
.layout-columns .r-prev .cell { opacity: .7; }
.layout-columns .r-cur .cell { border-bottom-color: rgba(56,189,248,.35); }
.layout-columns .grid > .rowwrap { display: contents; }
body.has-bg.layout-columns .heads { background: rgba(5,10,22,.7); }

/* ===== 帯表示：言語ごとに横長の帯、最新の1文を大きく ===== */
.layout-rows .heads { display: none; }
.layout-rows .stage { height: calc(100vh - 64px); display: grid; grid-template-rows: repeat(var(--n), minmax(0, 1fr)); padding: 10px 28px 16px; gap: 8px; }
.layout-rows .band { display: grid; grid-template-columns: 210px minmax(0, 1fr); align-items: center; gap: 22px; border-left: 5px solid var(--lc); padding: 4px 4px 4px 18px; background: rgba(15,23,42,.55); border-radius: 0 10px 10px 0; min-height: 0; overflow: hidden; }
.layout-rows .band .lname { flex-direction: column; gap: 2px; align-items: flex-start; }
.layout-rows .band .txtwrap { min-width: 0; max-height: 100%; overflow: hidden; display: flex; flex-direction: column; justify-content: center; height: 100%; }
.layout-rows .band .prev { font-size: calc(var(--fit, 1) * var(--scale) * 2vh); opacity: .45; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.6; }
.layout-rows .band .cur { font-size: calc(var(--fit, 1) * var(--scale) * min(4.6vh, 3vw)); font-weight: 600; line-height: 1.4; }

/* ===== 字幕：背景の画像・動画の下部に重ねる ===== */
.layout-subtitle .heads { display: none; }
.layout-subtitle .stage { position: fixed; left: 0; right: 0; bottom: 0; padding: 0 4vw 3.2vh; display: flex; flex-direction: column; justify-content: flex-end; max-height: calc(100vh - 80px); }
.layout-subtitle .subs { background: rgba(3,7,18,.78); border-radius: 14px; padding: 1.4vh 1.6vw; }
.layout-subtitle .subs:empty { display: none; }
/* ラベル列の幅は一番長いラベルに合わせる（全行で1つのグリッド） */
.layout-subtitle .subs { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 1.2vw; align-items: center; }
.layout-subtitle .sline { display: contents; font-size: calc(var(--fit, 1) * var(--scale) * min(3.3vh, 2.2vw)); line-height: 1.4; font-weight: 500; }
.layout-subtitle .sline > .tx { font-size: calc(var(--fit, 1) * var(--scale) * min(3.3vh, 2.2vw)); padding: .25em 0; }
.layout-subtitle .sline.ja > .tx { font-size: calc(var(--fit, 1) * var(--scale) * min(3.8vh, 2.5vw)); font-weight: 700; }
.layout-subtitle .sline + .sline > * { border-top: 1px solid rgba(255,255,255,.08); }
.layout-subtitle .tag { font-size: calc(var(--fit, 1) * var(--scale) * min(1.8vh, 1.2vw)); font-weight: 700; padding: .3em .7em; border-radius: 6px; background: var(--lc); color: #0a1020; text-align: center; white-space: nowrap; line-height: 1.5; background-clip: padding-box; }
.layout-subtitle .sline + .sline > .tag { border-top-color: transparent; margin-top: 0; }
/* 字幕は自前の黒帯があるので、背景はあまり暗くしない */
body.layout-subtitle.has-bg #dim { opacity: calc(var(--dim, .55) * .35); }

/* 空のとき */
.empty { position: fixed; inset: 64px 0 0 0; z-index: 2; display: none; align-items: center; justify-content: center; flex-direction: column; text-align: center; font-family: "Noto Sans JP", sans-serif; pointer-events: none; }
body.is-empty .empty { display: flex; }
.empty .e1 { font-size: clamp(18px, 2.4vw, 32px); margin: 0 0 12px; opacity: .8; }
.empty .e2 { font-size: clamp(13px, 1.3vw, 18px); margin: 0; opacity: .5; }

.credit { position: fixed; left: 12px; bottom: 6px; z-index: 3; font-size: 11px; opacity: .55; font-family: "Noto Sans", sans-serif; }
.credit a { color: inherit; }
body.layout-subtitle .credit { bottom: auto; top: 70px; }

/* 設定ボタンと引き出し */
.gear { position: fixed; right: 18px; bottom: 18px; z-index: 6; width: 52px; height: 52px; border-radius: 50%; border: 1px solid rgba(255,255,255,.2); background: rgba(15,23,42,.8); color: #fff; font-size: 24px; cursor: pointer; transition: opacity .3s; }
body.idle .gear { opacity: 0; pointer-events: none; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 92vw); z-index: 7; background: #f8fafc; color: #0f172a; transform: translateX(105%); transition: transform .25s; overflow-y: auto; box-shadow: -10px 0 40px rgba(0,0,0,.35); font-family: "Noto Sans JP", sans-serif; font-size: 14px; }
.drawer.open { transform: none; }
.dr-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid #e2e8f0; position: sticky; top: 0; background: #f8fafc; }
.dr-head b { font-size: 16px; }
.dr-head button { border: 0; background: none; font-size: 18px; cursor: pointer; color: #475569; }
.drawer section { padding: 14px 18px; border-bottom: 1px solid #e2e8f0; }
.drawer h3 { margin: 0 0 10px; font-size: 13px; color: #475569; font-weight: 700; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { border: 1px solid #cbd5e1; background: #fff; border-radius: 8px; padding: 7px 11px; cursor: pointer; color: #0f172a; }
.seg button.on { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }
.row2 { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { border: 1px solid #cbd5e1; background: #fff; border-radius: 8px; padding: 9px 14px; cursor: pointer; color: #0f172a; font-weight: 600; }
.btn.primary { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }
.btn.danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.hint { color: #64748b; font-size: 12px; line-height: 1.6; margin: 8px 0 0; }
.hint a { color: var(--c-accent); }
.rng { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.rng input { flex: 1; accent-color: var(--c-accent); }
.chk { display: flex; align-items: center; gap: 8px; margin-top: 10px; cursor: pointer; }
.langlist { margin: 0; line-height: 1.9; }
.langlist span { display: inline-block; padding: 1px 9px; margin: 0 4px 4px 0; border-radius: 999px; background: #e2e8f0; font-size: 12px; }

@media (max-width: 760px) {
  .bar { height: 52px; padding: 0 14px; gap: 10px; }
  .brand { font-size: 16px; } .brand small, .clock { display: none; }
  .layout-columns .stage { height: calc(100vh - 52px - 66px); padding: 0 12px 14px; }
  .layout-columns .heads { padding: 10px 12px 6px; gap: 0 10px; }
  .layout-columns .grid { gap: 0 10px; }
  .lname .nat { font-size: 14px; } .lname .jn { display: none; }
  .layout-rows .stage { height: calc(100vh - 52px); padding: 8px 10px; }
  .layout-rows .band { grid-template-columns: 76px minmax(0, 1fr); gap: 10px; padding-left: 10px; }
  .empty { inset: 52px 16px 0 16px; }
}
