:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --primary: #1668dc;
  --primary-dark: #0f4faf;
  --danger: #c24136;
  --danger-dark: #9f332b;
  --ok: #188a52;
  --warn: #b7791f;
  --shadow: 0 14px 40px rgba(18, 32, 56, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

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

.app-shell.narrow {
  width: min(820px, calc(100vw - 32px));
}

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

.toolbar,
.hero-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px;
  margin-bottom: 16px;
}

.hero-panel {
  margin-top: 10vh;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.25;
}

h2 {
  font-size: 16px;
  line-height: 1.3;
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
}

.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.grid.two {
  grid-template-columns: minmax(0, 0.95fr) minmax(360px, 1.05fr);
}

.viewer-layout {
  grid-template-columns: minmax(300px, 0.6fr) minmax(420px, 1.4fr);
}

.grid > .panel {
  padding: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.toolbar-status,
.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #f8fafc;
  font-size: 13px;
}

.pill.ok {
  color: var(--ok);
  border-color: rgba(24, 138, 82, 0.25);
  background: rgba(24, 138, 82, 0.08);
}

.pill.warn {
  color: var(--warn);
  border-color: rgba(183, 121, 31, 0.25);
  background: rgba(183, 121, 31, 0.08);
}

.pill.bad {
  color: var(--danger);
  border-color: rgba(194, 65, 54, 0.25);
  background: rgba(194, 65, 54, 0.08);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid.compact {
  grid-template-columns: 1fr;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
}

.input:focus {
  outline: 2px solid rgba(22, 104, 220, 0.18);
  border-color: rgba(22, 104, 220, 0.65);
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  color: var(--text);
  font-size: 14px;
}

.actions {
  margin-top: 14px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  text-decoration: none;
  cursor: pointer;
}

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

.button.primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.button.danger {
  border-color: var(--danger);
  color: #fff;
  background: var(--danger);
}

.button.danger:hover:not(:disabled) {
  background: var(--danger-dark);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.message {
  min-height: 34px;
  margin-top: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
}

.preview-panel {
  min-width: 0;
}

.video-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 8px;
  background: #0d1117;
}

.video-frame.large {
  min-height: 320px;
}

video,
canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #0d1117;
}

.hidden {
  display: none;
}

.connections {
  display: grid;
  gap: 10px;
}

.connections.empty {
  color: var(--muted);
  font-size: 14px;
}

.connection-card {
  display: grid;
  grid-template-columns: minmax(160px, 0.8fr) repeat(4, minmax(100px, 1fr));
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.connection-card strong,
.stats-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

.connection-card span,
.stats-grid span {
  color: var(--muted);
  font-size: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.stats-grid > div {
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

@media (max-width: 900px) {
  .toolbar,
  .hero-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .grid.two,
  .viewer-layout {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .connection-card {
    grid-template-columns: 1fr;
  }
}
