:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0d1115;
  color: #eef2f4;
  --bg-panel: #131a20;
  --bg-card: #0f161c;
  --bg-card-hover: #182027;
  --border-soft: #243038;
  --border-strong: #3a4751;
  --accent: #2486a8;
  --accent-strong: #38a2c6;
  --text-primary: #eef2f4;
  --text-secondary: #aab6bd;
  --text-tertiary: #7d8990;
  --ok: #5fc295;
  --warn: #e8b46a;
  --err: #df8a8a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  min-height: 100vh;
}

/* ---------- 左侧画面区 ---------- */
.stage {
  position: relative;
  display: grid;
  place-items: center;
  background: #050607;
  overflow: hidden;
}

.stage:fullscreen {
  width: 100vw;
  height: 100vh;
  background: #000;
}

.stage:fullscreen video {
  width: 100vw;
  height: 100vh;
}

video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #050607;
}

.fullscreen {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: auto;
  padding: 7px 14px;
  background: rgba(13, 17, 21, 0.78);
  border: 1px solid rgba(180, 205, 216, 0.35);
  border-radius: 999px;
  color: #d9e7ee;
  font-size: 12px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: background 0.15s ease;
}

.fullscreen:hover {
  background: rgba(36, 134, 168, 0.85);
}

.empty {
  position: absolute;
  color: #6c7980;
  font-size: 16px;
  letter-spacing: 0.5px;
}

/* ---------- 右侧面板 ---------- */
.panel {
  border-left: 1px solid var(--border-soft);
  background: var(--bg-panel);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  overflow-x: hidden;
}

.panel::-webkit-scrollbar {
  width: 6px;
}
.panel::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

/* 头部：标题 + 工具按钮 */
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
}

.panel-title h1 {
  font-size: 17px;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.panel-sub {
  display: block;
  margin-top: 3px;
  color: var(--text-tertiary);
  font-size: 11px;
  line-height: 1.3;
}

.panel-tools {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.icon-button {
  padding: 6px 10px;
  font-size: 11px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.icon-button:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

/* 分区 */
.section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.section-title {
  color: var(--text-tertiary);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding-left: 2px;
}

/* 状态网格 */
.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 32px;
  padding: 6px 9px;
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  background: var(--bg-card);
  overflow: hidden;
}

.status-row-wide {
  grid-column: 1 / -1;
}

.status-row span {
  color: var(--text-secondary);
  font-size: 11px;
  flex-shrink: 0;
}

.status-row strong {
  color: var(--text-primary);
  font-size: 11.5px;
  font-weight: 600;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-row.is-on {
  border-color: rgba(95, 194, 149, 0.5);
  background: rgba(95, 194, 149, 0.08);
}
.status-row.is-on strong { color: var(--ok); }

.status-row.is-warn {
  border-color: rgba(232, 180, 106, 0.5);
  background: rgba(232, 180, 106, 0.08);
}
.status-row.is-warn strong { color: var(--warn); }

.status-row.is-off {
  border-color: rgba(223, 138, 138, 0.4);
  background: rgba(223, 138, 138, 0.06);
}
.status-row.is-off strong { color: var(--err); }

/* 清晰度按钮组 */
.quality-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}

.quality-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.quality-option small {
  color: var(--text-tertiary);
  font-size: 9.5px;
  font-weight: 400;
  letter-spacing: 0.3px;
}

.quality-option:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  color: var(--text-primary);
}

.quality-option.active {
  background: var(--accent);
  border-color: var(--accent-strong);
  color: #fff;
}

.quality-option.active small {
  color: rgba(255, 255, 255, 0.75);
}

/* 操作按钮 */
.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.action-button {
  padding: 10px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.action-button:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

.action-button.primary {
  background: var(--accent);
  border-color: var(--accent-strong);
  color: #fff;
}

.action-button.primary:hover {
  background: var(--accent-strong);
}

/* primary 已开启：绿色填充 */
.action-button.primary.is-active {
  background: #3d8c66;
  border-color: var(--ok);
  color: #fff;
}
.action-button.primary.is-active:hover {
  background: #469c75;
}

/* 普通按钮（对方控制）已开启：浅绿描边 */
.action-button.is-active {
  background: rgba(95, 194, 149, 0.14);
  border-color: rgba(95, 194, 149, 0.6);
  color: var(--ok);
}
.action-button.is-active:hover {
  background: rgba(95, 194, 149, 0.22);
  color: #8fd9b1;
}

/* 普通按钮已关闭：浅红描边 */
.action-button.is-off {
  background: rgba(223, 138, 138, 0.08);
  border-color: rgba(223, 138, 138, 0.5);
  color: var(--err);
}
.action-button.is-off:hover {
  background: rgba(223, 138, 138, 0.15);
  color: #ecb0b0;
}

/* 客户端列表 */
.clients-section {
  min-height: 0;
}

.client-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 0;
}

.client-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 6px;
  padding: 7px 9px;
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 11.5px;
}

.client-role {
  font-weight: 700;
  color: var(--accent-strong);
}

.client-id,
.client-time {
  color: var(--text-tertiary);
  font-size: 10.5px;
}

.client-empty {
  padding: 12px 8px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 11px;
  border: 1px dashed var(--border-soft);
  border-radius: 7px;
  background: var(--bg-card);
}

/* 安卓端地址 */
.share-url {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.share-url code {
  display: block;
  padding: 7px 9px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  color: #b8e4f2;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
  line-height: 1.4;
}

/* 兼容老的样式 */
label {
  display: grid;
  gap: 8px;
  color: var(--text-secondary);
}

input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 14px;
}

button {
  border: none;
  background: none;
  font-family: inherit;
}

/* ---------- 响应式 ---------- */
@media (max-width: 880px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(320px, 60vh) auto;
  }

  .panel {
    border-left: 0;
    border-top: 1px solid var(--border-soft);
    max-height: none;
  }

  .status-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .panel {
    padding: 12px 10px;
  }

  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-tools {
    justify-content: flex-end;
  }
}
