:root {
  color-scheme: light;
  --bg: #eef1f5;
  --panel: #ffffff;
  --text: #16202a;
  --muted: #617080;
  --line: #d8dee6;
  --accent: #0f766e;
  --accent-dark: #0b5d57;
  --danger: #b42318;
  --shadow: 0 12px 32px rgba(20, 31, 43, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  padding: 0 14px;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

input {
  width: 220px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: 30px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.top-actions {
  display: flex;
  gap: 8px;
}

.config-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 0.7fr) minmax(180px, 0.7fr) auto;
  align-items: end;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  padding: 14px;
}

.compact-config {
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 0.55fr) auto;
}

.config-panel[hidden] {
  display: none;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.field input {
  width: 100%;
}

.layout,
.control-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
}

.control-layout {
  grid-template-columns: minmax(360px, 0.9fr) minmax(320px, 0.7fr);
}

.help-panel {
  min-height: 0;
  margin-bottom: 18px;
}

.projector-panel {
  min-height: 0;
  margin-bottom: 18px;
}

.projector-panel .panel-title {
  min-height: 56px;
}

.projector-panel select {
  width: min(360px, 46vw);
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.projector-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 16px;
}

.help-content {
  color: var(--muted);
  line-height: 1.7;
  padding: 14px 16px;
}

.help-content code {
  color: var(--text);
  overflow-wrap: anywhere;
}

.panel {
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.scene-panel,
.source-panel {
  min-height: 520px;
}

.panel-title {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.panel-title h2 {
  margin: 0;
  font-size: 18px;
}

.panel-title span {
  min-width: 32px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #edf7f6;
  color: var(--accent-dark);
  font-weight: 700;
}

.list,
.source-list {
  padding: 10px;
}

.scene-button,
.source-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.scene-button {
  min-height: 44px;
  padding: 0 12px;
}

.scene-button:hover,
.scene-button.active {
  border-color: #a7d9d4;
  background: #edf7f6;
  color: var(--accent-dark);
}

.scene-name,
.source-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.current-badge {
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  padding: 4px 8px;
}

.sources-empty {
  display: grid;
  min-height: 340px;
  place-items: center;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.compact-empty {
  min-height: 260px;
}

.source-row {
  min-height: 58px;
  border-color: var(--line);
  margin-bottom: 8px;
  padding: 10px 12px;
}

.source-meta {
  min-width: 0;
}

.source-kind {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.toggle {
  position: relative;
  width: 56px;
  height: 30px;
  flex: 0 0 auto;
}

.toggle input {
  width: 1px;
  height: 1px;
  opacity: 0;
}

.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #aab4bf;
  cursor: pointer;
}

.slider::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.22);
  transition: transform 0.15s ease;
}

.toggle input:checked + .slider {
  background: var(--accent);
}

.toggle input:checked + .slider::before {
  transform: translateX(26px);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(460px, calc(100vw - 40px));
  border-radius: 8px;
  background: #16202a;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--danger);
}

@media (max-width: 860px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .config-panel,
  .layout,
  .control-layout,
  .compact-config {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: auto;
  }

  .sources-empty {
    min-height: 260px;
  }
}
