:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-muted: #eef2f7;
  --text: #111827;
  --text-muted: #4b5563;
  --border: #cbd5e1;
  --primary: #0f62fe;
  --primary-hover: #0043ce;
  --success: #15803d;
  --success-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-bg: #fee2e2;
  --sim-banner-bg: #7c2d12;
  --sim-banner-fg: #fffbeb;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 18px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body {
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

.dev-only-banner {
  background: var(--sim-banner-bg);
  color: var(--sim-banner-fg);
  padding: 14px 16px;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  border-bottom: 4px solid #f59e0b;
}

.dev-only-sub {
  display: block;
  margin-top: 4px;
  font-size: 0.92rem;
  font-weight: 500;
  opacity: 0.95;
}

.app-shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.page-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
}

.nav-link {
  color: var(--primary);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: underline;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.card-title {
  margin: 0 0 12px 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.status-banner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--surface);
}

.status-banner.state-pending {
  background: var(--warn-bg);
  border-color: #f59e0b;
}

.status-banner.state-active {
  background: var(--success-bg);
  border-color: #16a34a;
}

.status-banner.state-ended {
  background: var(--danger-bg);
  border-color: #ef4444;
}

.status-badge {
  font-size: 1.2rem;
  font-weight: 800;
}

.status-detail {
  margin: 0;
  font-size: 1rem;
  color: var(--text-muted);
}

.error-box {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--danger-bg);
  border: 2px solid var(--danger);
  color: #7f1d1d;
  font-size: 1.02rem;
  font-weight: 600;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-label {
  font-size: 1.05rem;
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
}

.code-input {
  width: 100%;
  min-height: 60px;
  padding: 12px 16px;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  color: var(--text);
}

.code-input:focus,
.text-input:focus {
  outline: 3px solid rgba(15, 98, 254, 0.35);
  border-color: var(--primary);
}

.text-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 6px 0;
}

.checkbox-row input[type="checkbox"] {
  width: 24px;
  height: 24px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 58px;
  padding: 14px 18px;
  font-size: 1.2rem;
  font-weight: 800;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

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

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

.btn-ready {
  background: var(--success);
  color: #ffffff;
  min-height: 66px;
  font-size: 1.3rem;
}

.btn-secondary {
  background: var(--surface-muted);
  color: var(--text);
  border: 2px solid var(--border);
}

.btn-stop-huge {
  min-height: 74px;
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  background: var(--danger);
  color: #ffffff;
  border: 3px solid #991b1b;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.3);
}

.btn-stop-huge:not(:disabled):active {
  background: var(--danger-hover);
}

.video-stage-wrap {
  position: relative;
  width: 100%;
  background: #000000;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid #1e293b;
  aspect-ratio: 9 / 16;
  max-height: 72vh;
  margin: 0 auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.remote-video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000000;
  pointer-events: none;
}

.touch-overlay-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.stage-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.82);
  font-size: 1.1rem;
  font-weight: 600;
  pointer-events: none;
}

.control-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.control-bar .btn {
  min-height: 58px;
  font-size: 1.12rem;
  padding: 10px 8px;
}

.gesture-hint {
  margin: 10px 0 0 0;
  font-size: 0.96rem;
  color: var(--text-muted);
}

.step-note-label {
  display: block;
  margin-top: 14px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text, #0f172a);
}

.step-note-input {
  width: 100%;
  box-sizing: border-box;
  margin-top: 6px;
  min-height: 48px;
  padding: 10px 12px;
  font-size: 1.05rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
}


.assist-code-box {
  text-align: center;
  padding: 18px 12px;
  background: #f8fafc;
  border: 2px dashed var(--primary);
  border-radius: 12px;
  margin: 10px 0;
}

.assist-code-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 2.3rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: #0f172a;
  margin: 4px 0;
}

.assist-code-meta {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.sim-canvas-wrap {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  background: #000000;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid #334155;
}

.sim-canvas {
  display: block;
  width: 100%;
  height: auto;
}

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

.stat-item {
  background: var(--surface-muted);
  border-radius: 10px;
  padding: 10px 12px;
}

.stat-item-wide {
  grid-column: 1 / -1;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.12rem;
  font-weight: 800;
  margin-top: 2px;
  word-break: break-word;
}

.notes-list {
  margin: 0;
  padding-left: 22px;
  color: var(--text-muted);
  font-size: 0.98rem;
}

.notes-list li {
  margin-bottom: 8px;
}

.details-block summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text-muted);
  padding: 4px 0;
}

.details-body {
  margin-top: 10px;
}

@media (max-width: 420px) {
  html {
    font-size: 17px;
  }

  .assist-code-value {
    font-size: 1.9rem;
  }

  .control-bar {
    grid-template-columns: 1fr;
  }
}

.mode-item {
  margin: 0 0 10px 0;
  line-height: 1.5;
}
.mode-status {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
}
.mode-status-ok {
  background: #dcfce7;
  color: #166534;
}
.mode-status-no {
  background: #fee2e2;
  color: #991b1b;
}
.mode-status-later {
  background: #fef3c7;
  color: #92400e;
}
#capabilityBanner {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 10px;
}


/* 只看模式下带对方打开远程触控的步骤按钮 */
.guide-panel { margin: 12px 0; padding: 12px; border: 2px solid #dc2626; border-radius: 12px; background: #fff7f7; }
.guide-title { margin: 0 0 4px; font-weight: 700; font-size: 17px; }
.guide-note { margin: 0 0 10px; font-size: 14px; color: #475569; }
.guide-steps { display: grid; gap: 8px; }
.guide-step { min-height: 48px; padding: 8px 12px; font-size: 16px; text-align: left; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; color: #0f172a; }
.guide-step.is-current { border-color: #2563eb; background: #2563eb; color: #fff; font-weight: 700; }
.guide-hide { border-color: #dc2626; color: #dc2626; font-weight: 700; }
