/* リモートレッスン — 画面の共通スタイル
   方向: 夜のレッスン室。暖かい炭色の地に、楽器の真鍮(ブラス)を 1 色だけ。
   書体は BIZ UDPGothic(子どもから年配の方まで読みやすい UD 書体)。 */
:root {
  --bg: #1b1917;
  --panel: #242120;
  --panel-2: #2e2a27;
  --panel-3: #38332f;
  --line: #3d3834;
  --line-strong: #56504a;
  --text: #f4efe7;
  --muted: #aba093;
  --accent: #d9a84f;
  --accent-soft: rgba(217, 168, 79, .16);
  --accent-ink: #1d1504;
  --ok: #7cc79b;
  --warn: #e3b062;
  --bad: #f08a8a;
  --bad-soft: rgba(240, 138, 138, .14);
  --shadow: 0 10px 30px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3);
  --r-s: 10px;
  --r-m: 14px;
  --r-l: 18px;
  color-scheme: dark;
  accent-color: var(--accent);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "BIZ UDPGothic", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  line-break: strict;
  -webkit-font-smoothing: antialiased;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2 { font-feature-settings: "palt"; letter-spacing: .01em; text-wrap: balance; }
h1 { font-size: 1.6rem; line-height: 1.35; margin: 0 0 8px; }
h2 { font-size: 1rem; margin: 28px 0 10px; color: var(--muted); font-weight: 700; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: .92rem; }
strong { color: var(--accent); font-weight: 700; }

/* ---- 部品 */
button {
  font: inherit;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--text);
  border-radius: var(--r-s);
  padding: 10px 18px;
  cursor: pointer;
  min-height: 44px;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
button:hover { background: var(--panel-3); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
button.primary:hover { background: #e4b65f; border-color: #e4b65f; }
button.danger { color: var(--bad); border-color: transparent; background: transparent; }
button.danger:hover { background: var(--bad-soft); }
button.quiet { background: transparent; border-color: transparent; color: var(--muted); }
button.quiet:hover { color: var(--text); background: var(--panel-2); }
input[type=text] {
  font: inherit;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-s);
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--text);
  min-height: 48px;
  caret-color: var(--accent);
}
input[type=text]::placeholder { color: var(--muted); opacity: 1; }
input[type=text]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select {
  font: inherit;
  padding: 8px 32px 8px 12px;
  border-radius: var(--r-s);
  border: 1px solid var(--line-strong);
  background: var(--panel-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23aba093' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  color: var(--text);
  max-width: 100%;
  min-height: 44px;
  appearance: none;
  -webkit-appearance: none;
}
.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.wrap { max-width: 680px; margin: 0 auto; padding: 36px 20px 64px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); padding: 20px; margin: 14px 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1 1 200px; }
.row > .push { margin-left: auto; }
.stack { display: grid; gap: 10px; }
.lead { font-size: 1.05rem; max-width: 36em; }
.note { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; background: var(--panel-2); border-radius: var(--r-m); font-size: .95rem; text-align: left; margin: 14px 0 0; }
.note .ic { color: var(--accent); margin-top: 2px; }
.note p { margin: 0; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; overflow-wrap: anywhere; }
.link-box { background: var(--bg); border: 1px solid var(--line); padding: 12px 14px; border-radius: var(--r-m); text-align: left; }
.link-box .mono { color: var(--text); display: block; margin: 2px 0 10px; }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.checklist li { display: flex; gap: 14px; align-items: flex-start; }
.checklist .ic { color: var(--accent); margin-top: 3px; }
.checklist p { margin: 0; }

/* ---- 部屋の一覧(先生) */
.room-list { display: grid; gap: 12px; }
.room-item { display: grid; gap: 10px; margin: 0; }
.room-item .name { font-weight: 700; font-size: 1.05rem; }
.room-item .created { margin-left: auto; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }

/* ---- 通話画面 */
.call { display: grid; grid-template-rows: auto 1fr auto; min-height: 100dvh; }
.call header {
  display: grid; grid-template-columns: 1fr auto 1fr; grid-template-areas: "title status stats";
  align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.call header .title-wrap { grid-area: title; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call header .title { font-weight: 700; }
.status { grid-area: status; font-size: .95rem; color: var(--text); display: flex; align-items: center; gap: 8px; justify-content: center; text-align: center; }
.status .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.status.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(124, 199, 155, .18); }
.status.warn .dot { background: var(--warn); animation: pulse 1.6s ease-in-out infinite; }
.status.bad .dot { background: var(--bad); }
.status.bad { color: var(--bad); }
.stats { grid-area: stats; font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
@media (max-width: 760px) {
  .call header { grid-template-columns: 1fr; grid-template-areas: "title" "status" "stats"; gap: 2px; padding: 8px 16px; line-height: 1.5; }
  .call header .title-wrap { font-size: .95rem; }
  .status { justify-content: flex-start; text-align: left; }
  .stats { text-align: left; white-space: normal; font-size: .78rem; }
  .stats:empty { display: none; }
}
.stage { position: relative; display: grid; place-items: center; padding: 16px; gap: 12px; }
/* 通話中は画面の高さに収める(映像は枠いっぱい・縦横比は中身に合わせて黒帯) */
body.in-call .call { height: 100dvh; overflow: hidden; }
body.in-call .stage { min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
body.in-call .tiles { flex: 1 1 0; min-height: 0; height: auto; max-width: none; grid-auto-rows: minmax(0, 1fr); }
body.in-call .tile { aspect-ratio: auto; height: auto; min-height: 0; }
/* 自分の小窓はカメラの縦横比のまま(スマホの縦カメラも細長い黒帯にしない) */
body.in-call .self-pip { height: auto; }
body.in-call .self-pip video { height: auto; }
.tiles { display: grid; gap: 12px; width: 100%; max-width: 1200px; grid-template-columns: 1fr; }
.tiles.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .tiles.two { grid-template-columns: 1fr; } }
.tile { position: relative; background: #000; border-radius: var(--r-m); overflow: hidden; aspect-ratio: 16 / 9; border: 1px solid var(--line); }
.tile video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.tile .label { position: absolute; left: 10px; bottom: 8px; background: rgba(27, 25, 23, .7); padding: 3px 10px; border-radius: 6px; font-size: .85rem; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.tile.self video { transform: scaleX(-1); }
.tile.self.rear video { transform: none; }
.self-pip { position: absolute; right: 28px; top: 28px; width: 26%; max-width: 260px; min-width: 120px; z-index: 2; box-shadow: var(--shadow); }
@media (max-width: 760px) { .self-pip { right: 24px; top: 24px; } }

.center-box { text-align: center; max-width: 480px; width: 100%; padding: 28px 24px; margin: 0; }
.center-box h1 { font-size: 1.6rem; }
.center-box .lobby-msg { margin: 0 auto; max-width: 30em; }
.center-box .link-box { margin-top: 18px; }
.center-box .audio-info { margin: 14px 0 0; }
.center-box .back { margin: 16px 0 0; }

.waiting-list { position: absolute; left: 20px; top: 20px; z-index: 3; display: grid; gap: 8px; max-width: 340px; width: calc(100% - 40px); }
.knock { background: var(--panel); border: 1px solid var(--accent); border-radius: var(--r-m); padding: 14px 16px; display: grid; gap: 8px; box-shadow: var(--shadow); animation: knock-in .36s cubic-bezier(.2, .8, .2, 1) both; }
.knock .name { font-weight: 700; font-size: 1.05rem; }
.knock .row { margin-top: 4px; }

.hidden { display: none !important; }
.tap-to-play { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(27, 25, 23, .6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 4; }

/* ---- 操作ボタン(下の帯) */
.controls { display: flex; gap: 6px; justify-content: center; align-items: center; flex-wrap: wrap; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); }
.ctl { display: grid; justify-items: center; gap: 2px; min-width: 76px; min-height: 60px; padding: 6px 10px; border-radius: 12px; background: transparent; border: 1px solid transparent; color: var(--text); line-height: 1.2; }
.ctl .lbl { font-size: .78rem; white-space: nowrap; }
.ctl:hover { background: var(--panel-2); }
.ctl .ic.when-off { display: none; }
.ctl.off .ic.when-on, .ctl.alt .ic.when-on { display: none; }
.ctl.off .ic.when-off, .ctl.alt .ic.when-off { display: block; }
.ctl.off { color: var(--bad); background: var(--bad-soft); }
.ctl.active { color: var(--accent); background: var(--accent-soft); }
.ctl.leave { color: var(--bad); }
.ctl.leave:hover { background: var(--bad-soft); }
.controls select { font-size: .9rem; max-width: 220px; }
.controls .sep { width: 1px; height: 36px; background: var(--line); margin: 0 6px; }

.gain { display: inline-flex; align-items: center; gap: 10px; min-height: 60px; padding: 0 16px; border-radius: 12px; background: var(--panel-2); font-size: .92rem; }
.gain .ic { color: var(--muted); }
.gain:has(input:enabled) .ic { color: var(--accent); }
.gain .gain-label { white-space: nowrap; }
.gain input[type=range] { -webkit-appearance: none; appearance: none; width: 140px; height: 28px; margin: 0; background: transparent; cursor: pointer; --p: 14.3%; }
.gain input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--accent) var(--p), var(--line-strong) var(--p)); }
.gain input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 50%; background: var(--accent); border: 3px solid var(--panel-2); box-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
.gain input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line-strong); }
.gain input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
.gain input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 3px solid var(--panel-2); }
.gain input[type=range]:disabled { opacity: .4; cursor: default; }
.gain input[type=range]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.gain output { min-width: 3.2em; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); text-align: left; }
.gain:has(input:disabled) output { color: var(--muted); }
.gain small { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.gain small:empty { display: none; }
@media (max-width: 760px) {
  .controls { gap: 2px; }
  .ctl { min-width: 64px; padding: 6px 6px; }
  .controls .sep { display: none; }
  .controls select { flex: 1 1 100%; max-width: none; }
  .gain { flex: 1 1 100%; flex-wrap: wrap; justify-content: center; min-height: 52px; margin-top: 4px; padding: 6px 12px; row-gap: 0; }
  .gain input[type=range] { flex: 1; max-width: 220px; }
  .gain small { flex: 1 1 100%; text-align: center; white-space: normal; }
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes knock-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .status.warn .dot { animation: none; }
  .knock { animation: none; }
  button { transition: none; }
}
