:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #20242e;
  --text: #e8eaf0;
  --muted: #9aa3b2;
  --accent: #3b82f6;
  --accent-hover: #2f6fe0;
  --danger: #e5484d;
  --border: #2a2f3a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.view {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
}

[hidden] { display: none !important; }

/* ---------- 首页 ---------- */
#home-view h1 { font-size: 28px; }
.sub { color: var(--muted); font-size: 14px; text-align: center; margin-bottom: 10px; max-width: 340px; }

button {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
button:hover { background: #2a2f3c; }
button:active { transform: scale(.97); }
button.primary { background: var(--accent); border-color: var(--accent); }
button.primary:hover { background: var(--accent-hover); }
button.danger { color: #ffb4b6; border-color: #5c2b2e; }
button.danger:hover { background: #3a2023; }
button.big { width: min(320px, 100%); padding: 14px; font-size: 17px; }
button:disabled { opacity: .5; cursor: default; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  width: min(320px, 100%);
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

#watch-form, #share-form { display: flex; flex-direction: column; gap: 10px; width: min(320px, 100%); }
.source-select {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  outline: none;
  text-align: center;
}
.source-select:focus { border-color: var(--accent); }
#room-input {
  font: inherit;
  font-size: 18px;
  letter-spacing: 3px;
  text-align: center;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  outline: none;
}
#room-input:focus { border-color: var(--accent); }

.status { color: var(--muted); font-size: 13px; min-height: 18px; text-align: center; }

/* ---------- 共享端 ---------- */
#share-view { justify-content: flex-start; padding: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.label { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.code { font-size: 30px; font-weight: 700; letter-spacing: 5px; color: var(--accent); }
#share-preview { flex: 1; width: 100%; max-height: 68vh; background: #000; object-fit: contain; }

/* ---------- 观看端 ---------- */
#watch-view { position: fixed; inset: 0; padding: 0; background: #000; }
#remote-video { width: 100%; height: 100%; object-fit: contain; background: #000; cursor: pointer; }
#watch-status {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  color: #cfd6e4;
}
.bottom-actions {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  background: rgba(15, 17, 21, .72);
  padding: 8px;
  border-radius: 12px;
  backdrop-filter: blur(8px);
  z-index: 5;
}

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: rgba(24, 27, 34, .95);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  max-width: min(90vw, 420px);
  text-align: center;
  z-index: 10;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
}

/* ---------- 画质设置面板 ---------- */
.share-settings-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
button.ghost {
  background: transparent;
  border-color: var(--border);
  padding: 6px 12px;
  font-size: 13px;
}
.setting-summary { color: var(--muted); font-size: 13px; }

.settings-panel, .quality-panel {
  width: 100%;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.quality-panel {
  position: fixed;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 420px);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(24, 27, 34, .96);
  backdrop-filter: blur(10px);
  z-index: 6;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.setting-label { color: var(--muted); font-size: 13px; min-width: 56px; }
.setting-value { color: var(--accent); font-size: 13px; font-weight: 600; min-width: 58px; }

.preset-group { display: flex; gap: 6px; }
.preset {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 8px;
}
.preset.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

input[type="range"] {
  flex: 1;
  min-width: 120px;
  accent-color: var(--accent);
}

select {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  outline: none;
}

.hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
