/* ========================================
   Design Mirror — 全局样式 (Cloudflare 版)
   配色：黑 (#111) / 白 (#fff) / 蓝 (#2541ff)
   辅助：红 (#ee0a24) 仅用于停止按钮
   ======================================== */

:root {
  --ink: #111111;
  --paper: #ffffff;
  --accent: #2541ff;
  --accent-dark: #1c34cc;
  --danger: #ee0a24;
  --danger-dark: #c5091e;
  --line: #111111;
  --muted: #6f6f6f;
  --soft: #f5f5f5;
  --radius: 14px;
}

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

html, body {
  height: 100vh;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
  padding: 14px 24px;
  max-width: 1320px;
  margin: 0 auto;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

button { font-family: inherit; }

/* ========================================
   顶部导航
   ======================================== */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1.5px solid var(--line);
  margin-bottom: 14px;
  flex-shrink: 0;
}

.nav-left,
.nav-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  pointer-events: none;
  flex-shrink: 0;
  overflow: hidden;
}
.logo svg {
  width: 18px;
  height: 18px;
}

.nav-item {
  font-size: 14px;
  color: var(--ink);
  padding: 7px 16px;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
  position: relative;
  transition: all 0.15s;
}
.nav-item:hover:not(.active) {
  background: var(--soft);
}
.nav-item.active {
  background: var(--ink);
  color: var(--paper);
}

.round-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: var(--ink);
  flex-shrink: 0;
}
.round-btn svg {
  width: 18px;
  height: 18px;
}

/* ========================================
   卡片基础
   ======================================== */

.card {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-head {
  display: flex;
  align-items: center;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.card-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.card-body { padding: 12px 14px; }

.card-blue {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}
.card-blue .card-head {
  border-bottom-color: rgba(255, 255, 255, 0.22);
}
.card-blue .card-title { color: var(--paper); }

/* ========================================
   主区域网格
   ======================================== */

.main {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 14px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

@media (max-width: 920px) {
  .main { grid-template-columns: 1fr; }
}

/* ========================================
   左侧大卡
   ======================================== */

.card-large {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.preview-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  gap: 10px;
  overflow: hidden;
}

.preview-area {
  flex: 1;
  min-height: 140px;
  border-radius: 10px;
  background: var(--soft);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.placeholder {
  text-align: center;
  color: var(--muted);
  padding: 16px 14px;
}
.placeholder svg {
  width: 150px;
  height: 112px;
  margin-bottom: 8px;
}
.ph-text {
  font-size: 12px;
  line-height: 1.6;
  font-weight: 500;
}

#previewContainer { display: inline-block; position: relative; }
#previewCanvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--paper);
}

/* ========================================
   捕获模式
   ======================================== */

.modes-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  flex-shrink: 0;
  border-top: 1px solid #e0e0e0;
  padding-top: 10px;
  margin-top: 2px;
}
.modes-row .sub-card {
  padding: 10px 6px;
  gap: 4px;
  font-size: 12px;
}
.modes-row .sub-card svg {
  width: 22px;
  height: 22px;
}

.sub-card {
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.sub-card svg { width: 24px; height: 24px; }
.sub-card:hover { background: var(--soft); }
.sub-card.active {
  border-color: var(--accent);
  color: var(--accent);
}
.sub-card.disabled { opacity: 0.4; cursor: not-allowed; }

.start-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
  padding: 4px 0 2px;
}

/* ========================================
   按钮
   ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 18px 40px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn svg { width: 20px; height: 20px; }
.btn:hover { background: var(--soft); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  padding: 26px 64px;
  font-size: 24px;
  font-weight: 800;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
  border-radius: 999px;
}
.btn-primary svg { width: 28px; height: 28px; }
.btn-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn-danger {
  padding: 26px 64px;
  font-size: 24px;
  font-weight: 800;
  background: var(--danger);
  border-color: var(--danger);
  color: var(--paper);
  border-radius: 999px;
}
.btn-danger svg { width: 28px; height: 28px; }
.btn-danger:hover {
  background: var(--danger-dark);
  border-color: var(--danger-dark);
}

/* ========================================
   右侧堆叠
   ======================================== */

.aside {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  height: 100%;
}

.aside > .card {
  flex: 1 1 0;
  min-height: 0;
}
.aside > .card > .card-body {
  flex: 1;
  min-height: 0;
}

/* ========================================
   手机连接卡
   ======================================== */

.qr-card-body {
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-wrap {
  text-align: center;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.qr-box {
  width: min(140px, 100%);
  aspect-ratio: 1 / 1;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  margin: 0 auto;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.qr-box canvas {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  display: block;
}
.qr-box.hidden-canvas canvas { display: none; }
.qr-placeholder-text {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.qr-placeholder-text.error { color: var(--danger); }

.room-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.15em;
  padding: 4px 12px;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  display: inline-block;
}

.hint-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 3px;
}
.addr {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
  word-break: break-all;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink);
  flex-shrink: 0;
}
.dot.live {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 65, 255, 0.18);
}
.dot.connected { background: var(--ink); }

/* ========================================
   运行状态卡
   ======================================== */

.kpi-card-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
}

.kpi-horizontal {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 6px;
  flex: 1;
  min-height: 0;
}

.kpi-horizontal .kpi {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  padding: 8px 6px;
  text-align: center;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.kpi-horizontal .kpi .k {
  display: block;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.72);
  margin-bottom: 3px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-horizontal .kpi .v {
  font-size: 13px;
  font-weight: 700;
  color: var(--paper);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* ========================================
   画面参数卡
   ======================================== */

.sliders-card-body { padding: 14px 16px; }

.sliders-vertical {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.slider label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 4px;
  font-weight: 600;
}
.slider label .v-tag {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.slider input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  height: 18px;
}
.slider input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
}
.slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 50%;
  margin-top: -7px;
  cursor: pointer;
}
.slider input[type="range"]::-moz-range-track {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  border: none;
}
.slider input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}

/* ========================================
   框选叠层
   ======================================== */

.crop-overlay {
  position: absolute;
  inset: 0;
  cursor: crosshair;
  user-select: none;
  z-index: 10;
}
.crop-overlay.disabled {
  cursor: default;
  pointer-events: none;
}
.crop-mask {
  position: absolute;
  inset: 0;
  background: rgba(17, 17, 17, 0.55);
  pointer-events: none;
}
.crop-rect {
  position: absolute;
  border: 2px solid var(--accent);
  box-sizing: border-box;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.05);
}
.crop-rect.auto {
  border-style: dashed;
  border-color: var(--accent);
}
.crop-rect.hidden { display: none; }
.crop-rect .crop-size-label {
  position: absolute;
  bottom: -22px;
  right: 0;
  background: var(--accent);
  color: var(--paper);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 4px;
  white-space: nowrap;
}
.crop-hint {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--paper);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  pointer-events: none;
  z-index: 11;
}
.crop-hint.hidden { display: none; }
.crop-overlay.auto .crop-mask {
  background: rgba(17, 17, 17, 0.28);
}

/* ========================================
   帮助弹窗
   ======================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-overlay.show {
  display: flex;
}
.modal-card {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  max-width: 460px;
  width: 90%;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 {
  font-size: 16px;
  font-weight: 800;
}
.modal-close {
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.modal-close:hover { background: var(--soft); }
.modal-body {
  padding: 18px;
}
.modal-body ol {
  padding-left: 20px;
  line-height: 2;
  font-size: 14px;
}
.modal-body ol li {
  color: var(--ink);
}
.modal-body ol li strong {
  color: var(--accent);
}

/* ========================================
   手机端 viewer
   ======================================== */

body.viewer-body {
  background: var(--paper);
  padding: 16px 18px 24px;
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  height: auto;
  overflow: auto;
  display: block;
}
body.viewer-body .topbar {
  margin-bottom: 14px;
  padding-bottom: 14px;
}
body.viewer-body .nav-left { flex: 1; }
body.viewer-body .nav-right { flex-shrink: 0; }

.viewer-main {
  position: relative;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  min-height: calc(100vh - 110px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#stage {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
#stage.active {
  display: flex;
}

#viewerImg {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  transition: transform 0.05s linear;
  transform-origin: center center;
}

#vPlaceholder {
  text-align: center;
  color: var(--ink);
  padding: 32px 20px;
  position: relative;
  z-index: 10;
}
#vPlaceholder svg { width: 140px; height: 110px; margin-bottom: 12px; }
#vPlaceholder .vp-title {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 6px;
}
#vPlaceholder .vp-sub {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.overlay-info {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  z-index: 5;
}
.overlay-info .dot.live {
  background: var(--accent);
}

#hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 5;
}
#hint.show { opacity: 1; }

/* ========================================
   房间号输入 (viewer 手动连接)
   ======================================== */

.room-input-area {
  text-align: center;
  padding: 40px 20px;
  position: relative;
  z-index: 10;
}
.room-input-area .ri-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 8px;
}
.room-input-area .ri-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 20px;
}
.room-input-area .ri-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
}
.room-input-area input {
  width: 140px;
  padding: 12px 16px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 20px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--paper);
  outline: none;
}
.room-input-area input:focus {
  border-color: var(--accent);
}
.room-input-area input::placeholder {
  color: #ccc;
  letter-spacing: 0.05em;
  font-weight: 500;
}
.room-input-area button {
  padding: 12px 24px;
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  color: var(--paper);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.room-input-area button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}
.room-input-area button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
