:root {
  --bg: #0b1017;
  --panel: #121a24;
  --card: #17212e;
  --line: #22303f;
  --text: #e6edf5;
  --muted: #8b9bb0;
  --accent: #38bdf8;
  --accent2: #a78bfa;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: radial-gradient(1200px 700px at 15% -10%, #16283a 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font: 14px/1.5 "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 16, 23, .72);
  backdrop-filter: blur(6px);
  flex-wrap: wrap;
}

.brand {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo { color: var(--accent); }

.ver {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
  font-weight: 400;
}

.pills { display: flex; gap: 8px; flex-wrap: wrap; }

.pill {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  background: #0f1720;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
  transition: color .2s, border-color .2s, background .2s;
}

.pill.on {
  color: #06231b;
  background: linear-gradient(90deg, #4ade80, #22d3ee);
  border-color: transparent;
  font-weight: 600;
}

.pill.warn {
  color: #fca5a5;
  border-color: #7f1d1d;
  background: #1f1113;
}

/* ---------- 布局 ---------- */
main {
  flex: 1;
  display: flex;
  gap: 16px;
  padding: 16px;
  align-items: flex-start;
}

.stage {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.canvas-wrap {
  position: relative;
  background: #05080c;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 180px);
}

#view {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #05080c;
}

.hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  background: rgba(5, 8, 12, .78);
  color: var(--muted);
  padding: 20px;
}

.hint.hidden { display: none; }

.hint-title { font-size: 17px; color: var(--text); font-weight: 600; }
.hint-sub { font-size: 13px; max-width: 34em; }

.stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 0 2px;
}

.mic {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  flex: 0 1 380px;
}

.mic-label { font-size: 12px; color: var(--muted); white-space: nowrap; }

.mic-track {
  position: relative;
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: #16202b;
  overflow: hidden;
  border: 1px solid var(--line);
}

.mic-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #22d3ee, #4ade80 70%, #facc15 92%, #f87171);
  transition: width .06s linear;
}

.mic-db {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 62px;
  text-align: right;
}

.stage-note { font-size: 12px; color: #64748b; }

/* ---------- 侧栏 ---------- */
.panel {
  flex: 0 0 330px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: 2px;
}

.card {
  background: linear-gradient(180deg, var(--card), var(--panel));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.card h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.row > span {
  flex: 0 0 58px;
  font-size: 12px;
  color: var(--muted);
}

select {
  flex: 1;
  min-width: 0;
  background: #0e1620;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  font-size: 12px;
  outline: none;
}

select:focus { border-color: var(--accent); }

/* 侧栏里的文本输入（主播名） */
.txt {
  flex: 1;
  min-width: 0;
  background: #0e1620;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  font-size: 12px;
  outline: none;
}

.txt:focus { border-color: var(--accent); }

.btns { display: flex; gap: 8px; margin-top: 10px; }

.btn {
  flex: 1;
  cursor: pointer;
  background: #1b2635;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  transition: transform .08s, background .18s, border-color .18s, opacity .18s;
}

.btn:hover:not(:disabled) { background: #22303f; border-color: #31445a; }
.btn:active:not(:disabled) { transform: translateY(1px); }

.btn.primary {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  color: #06131c;
  font-weight: 700;
  border-color: transparent;
}

.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: linear-gradient(90deg, var(--accent), var(--accent2)); }

.btn:disabled { opacity: .42; cursor: not-allowed; }

.btn.mini {
  flex: 0 0 auto;
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 8px;
}

/* ---------- 滑条 ---------- */
.sliders { display: flex; flex-direction: column; gap: 9px; }

.slider {
  display: grid;
  grid-template-columns: 48px 1fr 30px;
  align-items: center;
  gap: 8px;
}

.s-name { font-size: 12px; color: var(--muted); }

.s-val {
  font-size: 12px;
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 16px;
  background: transparent;
  cursor: pointer;
  grid-column: 2 / 3;
  grid-row: 1;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, #2a3b4d, #1a2531);
  border: 1px solid var(--line);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border-radius: 50%;
  background: linear-gradient(180deg, #eaf6ff, #9fd8ff);
  border: 1px solid #3b82f6;
  box-shadow: 0 0 8px rgba(56, 189, 248, .55);
}

input[type="range"]::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: #22303f;
  border: 1px solid var(--line);
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #d7efff;
  border: 1px solid #3b82f6;
}

/* 滑条名称/数值放左，控件跨第 2 列整行：用 grid 重排 */
.slider {
  grid-template-columns: 48px 1fr 30px;
  grid-template-rows: auto;
}
.slider .s-name { grid-column: 1; grid-row: 1; }
.slider .s-val { grid-column: 3; grid-row: 1; }
.slider input[type="range"] { grid-column: 2; grid-row: 1; }

/* ---------- 复选框 ---------- */
.checks { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #b9c6d6;
  cursor: pointer;
}

.check input { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }

/* ---------- 说明 ---------- */
.tips ul { margin: 0; padding-left: 18px; }
.tips li { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.tips code {
  background: #0d151e;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 4px;
  color: #9fd8ff;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  background: #0f1a24;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  color: var(--text);
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  max-width: min(80vw, 560px);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  main { flex-direction: column; align-items: stretch; }
  .stage, .panel { width: 100%; }
  .panel { flex: 1 1 auto; max-height: none; }
  .canvas-wrap { max-height: none; }
}

/* ---------- 手机竖屏 ---------- */
@media (max-width: 700px) {
  body { font-size: 13px; }

  .topbar {
    padding: 8px 12px;
    gap: 6px;
    position: sticky;
    top: 0;
    z-index: 6;
    flex-direction: column;
    align-items: flex-start;
  }

  .brand { font-size: 14px; }
  .pills { gap: 6px; min-width: 0; }
  .pill { font-size: 11px; padding: 2px 8px; white-space: nowrap; }

  main { padding: 8px; gap: 10px; }

  /* min-height 会跟 aspect-ratio 打架把宽度撑出屏幕，手机上关掉 */
  .canvas-wrap { border-radius: 12px; min-height: 0; }

  .stage-bar { gap: 8px; flex-wrap: nowrap; }
  .mic { flex: 1 1 auto; min-width: 0; }
  .stage-note { display: none; }

  .panel { padding: 0; gap: 10px; }
  .card { padding: 12px; border-radius: 12px; }

  .btn { padding: 11px 10px; font-size: 14px; }
  .btn.mini { padding: 7px 12px; }

  .row > span { flex: 0 0 52px; }
  select { padding: 8px; font-size: 13px; }

  .slider { grid-template-columns: 44px 1fr 28px; }
  input[type="range"] { height: 24px; }
  input[type="range"]::-webkit-slider-thumb { width: 20px; height: 20px; margin-top: -8px; }

  .check { font-size: 13px; padding: 3px 0; }
  .check input { width: 17px; height: 17px; }

  .toast { bottom: 14px; left: 12px; right: 12px; transform: translateY(20px); max-width: none; }
  .toast.show { transform: translateY(0); }
}

/* 全屏播放（手机横屏直播时最有用） */
.canvas-wrap:fullscreen {
  aspect-ratio: auto;
  width: 100vw;
  height: 100vh;
  max-height: none;
  border: none;
  border-radius: 0;
  background: #000;
}

.canvas-wrap:fullscreen #view { height: 100vh; }
.canvas-wrap:fullscreen .hint { display: none; }

/* ============================================================
   浮动调整面板（右侧透明按钮 → 半透明面板浮在画面上方）
   ============================================================ */

.overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

/* 右侧透明触发按钮 */
.adjust-fab {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 5px 12px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-right: none;
  border-radius: 12px 0 0 12px;
  background: rgba(8, 14, 22, .16);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  color: rgba(255, 255, 255, .82);
  font: inherit;
  font-size: 11px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: background .18s, border-color .18s, color .18s, transform .18s, opacity .2s;
  -webkit-tap-highlight-color: transparent;
}

.adjust-fab .fab-ico { font-size: 15px; line-height: 1; letter-spacing: 0; }
.adjust-fab .fab-txt { writing-mode: vertical-rl; text-orientation: upright; }

.adjust-fab:hover,
.adjust-fab:focus-visible {
  background: rgba(56, 189, 248, .30);
  border-color: rgba(56, 189, 248, .75);
  color: #fff;
  outline: none;
}

.adjust-fab:active { transform: translateY(-50%) scale(.97); }

/* 面板打开时把按钮淡出，避免两套控件叠在一起 */
.adjust-fab.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(12px);
}

/* 半透明浮层 */
.adjust-sheet {
  position: absolute;
  z-index: 6;
  top: 8px;
  right: 8px;
  bottom: auto;
  max-height: calc(100% - 16px);
  width: min(330px, 86%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 12px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 14px;
  background: rgba(9, 15, 23, .42);
  -webkit-backdrop-filter: blur(16px) saturate(1.25);
  backdrop-filter: blur(16px) saturate(1.25);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .42);
  color: #eaf3fb;
  transform: translateX(calc(100% + 14px));
  opacity: 0;
  pointer-events: none;
  transition: transform .24s cubic-bezier(.22, .61, .36, 1), opacity .18s;
}

.adjust-sheet.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 2px;
}

/* 手机上才有的一条拖动条（点一下收起） */
.sheet-grip { display: none; }

.sheet-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
}

.sheet-hint {
  flex: 1;
  padding-left: 6px;
  font-size: 10px;
  color: rgba(200, 220, 240, .55);
}

.sheet-close {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  line-height: 1;
  font-size: 17px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .06);
  color: rgba(235, 245, 255, .9);
  cursor: pointer;
  transition: background .16s, border-color .16s;
}

.sheet-close:hover { background: rgba(56, 189, 248, .26); border-color: rgba(56, 189, 248, .6); }

/* 面板内的滑条：透明底、白字、加粗轨道 */
.adjust-sheet .slider { grid-template-columns: 46px 1fr 30px; }

.adjust-sheet .s-name { color: rgba(210, 228, 244, .88); font-size: 12px; }
.adjust-sheet .s-val { color: #fff; }

.adjust-sheet input[type="range"]::-webkit-slider-runnable-track {
  background: rgba(255, 255, 255, .16);
  border-color: rgba(255, 255, 255, .12);
}

.adjust-sheet input[type="range"]::-webkit-slider-thumb {
  background: linear-gradient(180deg, #ffffff, #a9e2ff);
  border-color: #7dd3fc;
  box-shadow: 0 0 10px rgba(56, 189, 248, .8);
}

.adjust-sheet input[type="range"]::-moz-range-track {
  background: rgba(255, 255, 255, .16);
  border-color: rgba(255, 255, 255, .12);
}

.adjust-sheet .check { color: rgba(226, 238, 248, .92); }

/* 形变分组标题 */
.sheet-sec {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  color: rgba(190, 228, 255, .82);
}
.sheet-sec::after {
  content: "";
  order: 1;
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, .14);
}
.sheet-sec .sec-note {
  order: 2;
  font-weight: 400;
  letter-spacing: 0;
  color: rgba(200, 220, 240, .45);
}

/* 形变滑条拉到高位时数字变亮 */
.adjust-sheet .s-val.strong { color: #4ade80; }

/* 形变状态行 / 上报状态行 */
.warp-status,
.pub-status {
  font-size: 10.5px;
  line-height: 1.5;
  color: rgba(200, 220, 240, .55);
  font-variant-numeric: tabular-nums;
  margin-top: 8px;
  word-break: break-all;
}
.warp-status.on,
.pub-status.on { color: #6ee7b7; }
.warp-status.warn,
.pub-status.warn { color: #fca5a5; }

.adjust-sheet .btn {
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .16);
  color: #eaf3fb;
}

.adjust-sheet .btn:hover:not(:disabled) {
  background: rgba(56, 189, 248, .24);
  border-color: rgba(56, 189, 248, .6);
}

/* 人脸状态行 */
.face-status {
  margin-top: 10px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
  word-break: break-all;
  font-variant-numeric: tabular-nums;
}

.face-status .dim { color: rgba(160, 184, 206, .8); }

/* 模型下载进度条 */
.face-bar-wrap {
  display: none;
  margin-top: 8px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .12);
  overflow: hidden;
}

.face-bar {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #38bdf8, #7dd3fc);
  transition: width .18s linear;
}

.face-status b { color: #9fd8ff; font-weight: 600; }
.face-status .warn { color: #fca5a5; }

@media (max-width: 700px) {
  /* 手机上按钮更窄、面板更宽 */
  .adjust-fab { padding: 9px 4px 11px; font-size: 10px; border-radius: 10px 0 0 10px; }
  .adjust-fab .fab-txt { display: none; }
  .adjust-fab .fab-ico { font-size: 17px; }

  /* 手机竖屏：面板从底部升起，相对视口定位（不跟着画面区域的高度被压扁），
     62vh 足够放完全部滑条，同时画面还完整露在上方 */
  .adjust-sheet {
    position: fixed;
    z-index: 30;
    top: auto;
    left: 6px;
    right: 6px;
    bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-height: 62vh;
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: rgba(9, 15, 23, .46);
    -webkit-backdrop-filter: blur(18px) saturate(1.3);
    backdrop-filter: blur(18px) saturate(1.3);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .46);
    transform: translateY(calc(100% + 12px));
    opacity: 0;
  }

  .adjust-sheet.open { transform: translateY(0); opacity: 1; }

  .sheet-grip {
    display: block;
    width: 42px;
    height: 4px;
    margin: -2px auto 2px;
    border-radius: 2px;
    background: rgba(255, 255, 255, .32);
  }

  .adjust-sheet .slider { grid-template-columns: 42px 1fr 26px; }
  .adjust-sheet input[type="range"] { height: 24px; }
  .adjust-sheet .s-name { font-size: 12.5px; }
  .adjust-sheet .s-val { font-size: 12px; }
  .adjust-sheet .btn { padding: 10px; }
}
