:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2f3d;
  --text: #e8eaed;
  --text-muted: #9aa0a6;
  --primary: #4f8cff;
  --primary-hover: #3a7bff;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --radius: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.header-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.header-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: normal;
}

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

.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: #3a4050;
}

.camera-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  padding: 16px;
}

.camera-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.camera-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.camera-name {
  font-size: 0.9375rem;
  font-weight: 500;
}

.camera-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-dot.live {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.status-dot.connecting {
  background: var(--warning);
  animation: pulse 1s infinite;
}

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

@keyframes pulse {
  50% { opacity: 0.4; }
}

.video-wrap {
  position: relative;
  background: #000;
  aspect-ratio: 16 / 9;
  cursor: pointer;
}

.video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  pointer-events: none;
  z-index: 2;
}

.tap-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 120px;
  height: 44px;
  border: none;
  border-radius: 22px;
  background: rgba(79, 140, 255, 0.9);
  color: #fff;
  font-size: 0.9375rem;
  cursor: pointer;
  z-index: 2;
}

.ios-hint {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.75rem;
  border-radius: 6px;
  z-index: 2;
  line-height: 1.4;
}

.wechat-tip,
.browser-tip {
  background: #fef3c7;
  color: #92400e;
  padding: 10px 16px;
  font-size: 0.875rem;
  text-align: center;
  border-bottom: 1px solid #fcd34d;
}

.camera-actions {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
}

.camera-actions .btn {
  flex: 1;
  padding: 6px 12px;
  font-size: 0.8125rem;
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-state p {
  margin-bottom: 8px;
}

.empty-state .hint {
  font-size: 0.875rem;
}

.hidden {
  display: none !important;
}

.dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
  color: var(--text);
  max-width: 400px;
  width: calc(100% - 32px);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.dialog form {
  padding: 24px;
}

.dialog h2 {
  font-size: 1.125rem;
  margin-bottom: 20px;
}

.dialog label {
  display: block;
  margin-bottom: 16px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.dialog input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.75rem;
  line-height: 1.4;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}

.fullscreen-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  display: flex;
  flex-direction: column;
}

.fullscreen-overlay video {
  flex: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.btn-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 101;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.fs-title {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: #fff;
  font-size: 1rem;
}

@media (max-width: 480px) {
  .header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .header-actions {
    justify-content: stretch;
  }

  .header-actions .btn {
    flex: 1;
  }

  .camera-grid {
    grid-template-columns: 1fr;
    padding: 12px;
  }
}
