/* 表示ビュー：文字が主役。装飾は最小、大小と余白で見せる。 */
:root {
  --bg: #0d0e12; --ink: #f3f1ea; --sub: #7c808b; --accent: #ffd23f; --accent2: #62d0ff; --stroke: transparent;
  --font: "Hiragino Sans", "Yu Gothic", "Noto Sans CJK JP", sans-serif;
  --w-strong: 900; --w-light: 500; --base: 40px;
}
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font);
  font-feature-settings: "palt" 1;           /* 和文はプロポーショナル詰め */
  font-synthesis: none;                      /* 擬似ボールド・擬似斜体を作らない */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .6s ease;
}
#stage { position: fixed; inset: 0; overflow: hidden; contain: strict; }

/* ---- 語 ---- */
.w {
  position: absolute; left: 0; top: 0;
  white-space: pre; line-height: 1.12;
  font-weight: var(--w-strong); color: var(--ink);
  transform-origin: 0 0;
}
.wi { display: inline-block; transform-origin: 50% 60%; }
.w .c { display: inline-block; }
.s-h  { font-size: .8em; font-weight: var(--w-light); letter-spacing: .01em; }   /* かなを引く */
.s-ka { font-size: 1.04em; letter-spacing: -.03em; }                              /* カタカナは字面が小さく見えるので少し大きく */
.s-l  { letter-spacing: 0; font-feature-settings: "kern" 1; }
.s-n  { font-variant-numeric: tabular-nums; letter-spacing: 0; }
.s-p  { font-weight: var(--w-light); }

.w.v { writing-mode: vertical-rl; text-orientation: mixed; line-height: 1.04; }
.w.v .s-n { text-orientation: upright; }
.w.v .tcy { text-combine-upright: all; }
.w.v .s-h { font-size: .82em; }

.k-new { color: var(--accent); }
.k-registered { color: var(--accent2); }
.w .bar {
  position: absolute; left: .04em; right: .04em; bottom: -.04em; height: .07em;
  background: var(--accent); transform-origin: 0 50%; border-radius: .04em;
}
.w.v .bar { left: auto; right: -.14em; top: .04em; bottom: .04em; width: .07em; height: auto; transform-origin: 50% 0; }

.w.aging { opacity: .5; transition: opacity 2.6s ease; }

/* ---- テーマ別 ---- */
.theme-sumi .w { color: var(--ink); }
.theme-sumi .k-new { color: var(--accent); }
.theme-pop .s-h { font-size: .84em; }
.theme-fude .s-h { font-size: .84em; }
.theme-fude .w { letter-spacing: -.01em; }
.theme-dot .w, .theme-dot #caption { text-shadow: 0 0 .16em rgba(120, 255, 170, .38); }
.theme-dot .s-h { font-size: .9em; }
.theme-dot .k-new { text-shadow: 0 0 .2em rgba(255, 228, 92, .5); }
.theme-clear { background: transparent; }
.theme-clear .w, .theme-clear #caption {
  text-shadow: 0 0 .05em var(--stroke), 0 0 .05em var(--stroke), 0 0 .1em var(--stroke), 0 .05em .16em rgba(0,0,0,.55);
}

/* ---- カンペ：下から積み上がる ---- */
.layout-kanpe #stage { display: flex; flex-direction: column; justify-content: flex-end; }
.layout-kanpe .flow {
  display: flex; flex-wrap: wrap; align-items: baseline; align-content: flex-end;
  gap: calc(var(--base) * .18) calc(var(--base) * .55);
  padding: 6vh 6vw 6vh;
}
.layout-kanpe.has-cap .flow { padding-bottom: calc(var(--base) * 2.2); }
.layout-kanpe .w { position: relative; transform-origin: 50% 50%; }

/* ---- テロップ：下部を横に流れる ---- */
.ticker { position: absolute; left: 0; right: 0; bottom: 7vh; height: calc(var(--base) * 2.2); }
.layout-ticker.has-cap .ticker { bottom: calc(var(--base) * 2.2); }
.track { position: absolute; left: 0; bottom: 0; display: flex; align-items: baseline; gap: calc(var(--base) * .8); white-space: nowrap; will-change: transform; }
.layout-ticker .w { position: relative; }

/* ---- 字幕ライン（最新の発話） ---- */
#caption {
  position: fixed; left: 6vw; right: 6vw; bottom: 4.5vh;
  font-size: calc(var(--base) * .5); line-height: 1.55; font-weight: var(--w-light);
  color: var(--sub); text-align: center;
  word-break: auto-phrase; text-wrap: balance;   /* 文節で折り返す（Chrome） */
  opacity: 0; transform: translateY(.3em);
  transition: opacity .5s ease, transform .5s ease, color .4s ease;
  pointer-events: none;
}
#caption.on { opacity: 1; transform: none; }
#caption.final { color: var(--ink); }
.layout-ticker #caption { bottom: 3vh; }

#hint {
  position: fixed; inset: 0; display: grid; place-items: center;
  color: var(--sub); font-size: calc(var(--base) * .5); font-weight: var(--w-light);
  opacity: 0; transition: opacity .6s ease; pointer-events: none; letter-spacing: .08em;
}
#hint.on { opacity: .7; }

.calm .w.aging { transition-duration: 1s; }
@media (prefers-reduced-motion: reduce) { #caption { transition: none; } }

/* Free のクレジット表示（Plus 以上で消える） */
#credit {
  position: fixed; right: 2.4vw; bottom: 2.4vh; display: none; align-items: center; gap: .45em;
  font-family: "Zen Kaku Gothic New", var(--font); font-weight: 900; font-size: max(10px, calc(var(--base) * .28));
  letter-spacing: .16em; line-height: 1; color: var(--sub); opacity: .75; pointer-events: none;
}
#credit i { width: .55em; height: .55em; border-radius: 50%; background: #e0352b; }
.has-credit #credit { display: flex; }
.theme-clear #credit { color: #fff; text-shadow: 0 0 .2em rgba(0,0,0,.8); }

/* 別窓の書体切り替えバー（マウスを動かすと出る） */
#picker {
  position: fixed; top: 16px; right: 16px; z-index: 10; max-width: calc(100vw - 32px);
  display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 12px;
  background: rgba(18, 19, 23, .86); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .1); border-radius: 14px; box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
  font-family: "Hiragino Sans", "Yu Gothic UI", "Noto Sans CJK JP", system-ui, sans-serif; font-feature-settings: "palt" 1;
  color: #ecebe6; text-shadow: none; letter-spacing: 0;
  opacity: 0; transform: translateY(-6px); pointer-events: none; transition: opacity .25s ease, transform .25s ease;
}
.ui-on #picker { opacity: 1; transform: none; pointer-events: auto; }
.ui-idle { cursor: none; }
.pk-label { font-size: 10.5px; letter-spacing: .16em; color: #9b9da4; font-weight: 700; }
.pk-row { display: flex; align-items: flex-start; gap: 6px; overflow-x: auto; scrollbar-width: none; }
#picker button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.pk-theme { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 44px; flex: none; }
.pk-tile { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 9px; font-size: 19px; line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); }
.pk-name { font-size: 10.5px; color: #9b9da4; white-space: nowrap; }
.pk-theme[aria-pressed="true"] .pk-tile { box-shadow: 0 0 0 2px rgba(18, 19, 23, 1), 0 0 0 4px #ffd23f; }
.pk-theme[aria-pressed="true"] .pk-name { color: #ecebe6; font-weight: 700; }
.pk-theme.plus .pk-tile::after { content: "+"; position: absolute; right: -4px; top: -4px; width: 14px; height: 14px; border-radius: 50%;
  background: #ffd23f; color: #151309; font: 900 10px/14px system-ui, sans-serif; text-align: center; }
.pk-theme.locked .pk-tile { filter: grayscale(.7) brightness(.6); }
.pk-theme.locked { cursor: not-allowed; }
.pk-follow, .pk-fs { height: 40px; padding: 0 10px !important; border-radius: 9px; border: 1px solid rgba(255, 255, 255, .16) !important;
  font-size: 12px; font-weight: 700; color: #c9c9c4 !important; flex: none; }
.pk-follow[aria-pressed="true"] { border-color: #ffd23f !important; color: #ffd23f !important; }
.pk-fs { margin-left: 4px; }
.pk-follow:hover, .pk-fs:hover { background: rgba(255, 255, 255, .06) !important; }
#picker button:focus-visible { outline: 2px solid #ffd23f; outline-offset: 2px; border-radius: 9px; }
.pk-note { margin: 0; font-size: 11.5px; color: #ffd23f; display: none; }
.pk-note.on { display: block; }
.pk-accents { align-items: center; }
.pk-follow.small { height: 26px; font-size: 11.5px; }
.pk-acc { width: 22px; height: 22px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2); }
.pk-acc[aria-pressed="true"] { box-shadow: 0 0 0 2px rgba(18, 19, 23, 1), 0 0 0 4px #ecebe6; }
.pk-acc.locked { opacity: .35; cursor: not-allowed; }
