:root {
  color-scheme: dark;
  --green: #7cff6b;
  --green-dim: #57d148;
  --green-deep: #1a3d22;
  --bg: #070807;
  --card: #101410;
  --card-edge: #1d271d;
  --text: #e8f5e6;
  --muted: #7a8a7c;
  --amber: #e6b84d;
  --red: #ff5c5c;
  --dot-idle: #6b6b6b;
  --dot-on: #32d74b;
  --dot-off: #ff5c5c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Segoe UI Variable Display", "Segoe UI", "Avenir Next", "Century Gothic", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  letter-spacing: -0.01em;
}

h1, h2, strong, button, input, .code, .code-input, .res-chip, .topbar-code {
  font-family: inherit;
  letter-spacing: -0.03em;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

button {
  appearance: none;
  min-height: 40px;
  border: 1px solid var(--green-deep);
  border-radius: 999px;
  padding: 8px 18px;
  background: var(--green);
  color: #06120a;
  font-weight: 800;
  cursor: pointer;
}

button:hover:not(:disabled) { background: var(--green-dim); }
button:disabled { opacity: 0.35; cursor: not-allowed; }

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  min-height: 40px;
  padding: 0;
  background: transparent;
  color: var(--text);
  border-radius: 50%;
}

.icon-btn:hover:not(:disabled) { background: #1a1a1a; }

.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn--danger { color: var(--red); }
.icon-btn--danger:hover:not(:disabled) { background: #2a0c0c; }

.icon-btn.is-copied { color: var(--green); }

.btn-big {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 32px;
  font-size: 17px;
}

.btn-big svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--card-edge);
  border-radius: 8px;
  padding: 10px 12px;
  background: #111;
  color: var(--text);
}

input::placeholder { color: var(--muted); }
input:focus {
  border-color: var(--green);
  outline: none;
}

.status {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.status.ok { color: var(--green); }
.status.err { color: var(--red); }

.brand-mark {
  margin: 0;
  color: var(--green);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.3em;
}

.cook-logo {
  display: block;
  width: 180px;
  overflow: visible;
}

.cook-logo .cook-bubble-shadow path { fill: var(--green); }
.cook-logo .cook-bubble path { fill: #000; }
.cook-logo .cook-letters path { fill: #fff; }

.cook-logo--sm { width: 240px; }

.cook-logo--login {
  margin: 0 0 24px;
  justify-self: center;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dot-idle);
  box-shadow: 0 0 0 3px rgba(107, 107, 107, 0.18);
}

.dot[data-state="on"] {
  background: var(--dot-on);
  box-shadow: 0 0 0 3px rgba(50, 215, 75, 0.22);
}

.dot[data-state="off"] {
  background: var(--dot-off);
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.22);
}

/* ── 登录：浅色卡片 ── */
.page-login {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.login-card {
  display: grid;
  gap: 6px;
  justify-items: stretch;
  width: min(360px, calc(100% - 32px));
  border: 0;
  border-radius: 16px;
  padding: 36px 28px 28px;
  background: #f4f7f1;
  color: #1a1a1a;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.login-card label {
  color: #5a635c;
  font-size: 12px;
  font-weight: 700;
}

.login-card input {
  margin-bottom: 10px;
  background: #fff;
  border-color: #d5ddd6;
  color: #111;
}

.login-card input:focus { border-color: var(--green); }

.login-card button { margin-top: 8px; }

.login-card .status {
  margin-top: 8px;
  text-align: center;
  color: #6b746d;
}

.login-card .status.err { color: #c62828; }

/* ── 选择任务 ── */
.page-choose {
  color-scheme: light;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 18%, #d8f8b8 0%, transparent 36%),
    radial-gradient(circle at 88% 82%, #c8f08a 0%, transparent 32%),
    #eef6e8;
  color: #161916;
}

.choose-main {
  display: grid;
  flex: 1;
  place-content: center;
  gap: 36px;
  justify-items: center;
  padding: 24px;
}

.doors {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 300px));
  gap: 20px;
}

.door {
  display: grid;
  gap: 18px;
  justify-items: center;
  align-content: center;
  min-height: 220px;
  border: 0;
  border-radius: 28px;
  background: #fff;
  color: #161916;
  box-shadow: 0 12px 32px rgba(20, 40, 10, 0.08);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.door:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 36px rgba(20, 40, 10, 0.12);
}

.door svg {
  width: 64px;
  height: 64px;
  fill: var(--green);
  stroke: none;
}

.door .door-cut { fill: #fff; }

.door strong {
  font-size: 18px;
  font-weight: 800;
}

.userbar {
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid #d7e3ce;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.55);
}

.avatar {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--green);
  color: #06120a;
  font-size: 13px;
  font-weight: 800;
}

.userbar small {
  color: #6b746d;
  font-size: 12px;
}

.page-choose .icon-btn {
  color: #161916;
  border-color: transparent;
}

.page-choose .icon-btn svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
}

.page-choose .icon-btn:hover:not(:disabled) { background: #e4efd8; }

.userbar .icon-btn { margin-left: auto; }

/* ── 顶栏 ── */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border-bottom: 1px solid var(--card-edge);
  padding: 0 10px;
}

.topbar-spring { flex: 1; }

.route-chip {
  width: 22px;
  height: 22px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
}

.route-chip svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.route-chip.is-direct { color: var(--green); }
.route-chip.is-relay { color: var(--amber); }

.res-chip {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.topbar-code {
  color: var(--green);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

/* ── 共享 / 观看 ── */
.page-share,
.page-watch {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.share-main,
.watch-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  min-height: 0;
  padding: 24px;
}

.lobby {
  display: grid;
  gap: 20px;
  justify-items: center;
  width: min(460px, 100%);
}

.plaque {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: 1px solid #222;
  border-radius: 14px;
  padding: 26px 16px;
  background: var(--card);
}

.code {
  color: var(--green);
  font-size: clamp(34px, 8vw, 46px);
  font-weight: 800;
  letter-spacing: 0.18em;
}

.quality {
  display: grid;
  gap: 12px;
  width: min(460px, 100%);
}

.is-live .quality {
  position: fixed;
  z-index: 5;
  top: 58px;
  right: 12px;
  width: 300px;
  border: 1px solid var(--card-edge);
  border-radius: 10px;
  padding: 14px;
  background: var(--card);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.quality-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.quality-option { cursor: pointer; }

.quality-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.quality-option__body {
  display: grid;
  gap: 2px;
  justify-items: center;
  border: 1px solid var(--card-edge);
  border-radius: 8px;
  padding: 12px 6px;
  background: #111;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.quality-option__body span { font-size: 11px; }

.quality-option input:checked + .quality-option__body {
  border-color: var(--green);
  background: var(--green-deep);
  color: var(--text);
}

.quality-option input:disabled + .quality-option__body { opacity: 0.35; }

.helper {
  margin: 0;
  color: var(--amber);
  font-size: 12px;
  text-align: center;
}

.viewers {
  display: grid;
  gap: 8px;
  width: 100%;
}

.viewers-label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.viewer-list { display: grid; gap: 6px; }

.viewer-card {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--card-edge);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--card);
}

.viewer-card.is-empty { display: none; }

.viewer-card__avatar {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: #000;
  font-size: 12px;
  font-weight: 800;
}

.viewer-card strong { display: block; font-size: 14px; }

.viewer-card span {
  color: var(--muted);
  font-size: 11px;
}

.viewer-card.is-direct span { color: var(--green); }
.viewer-card.is-relay span { color: var(--amber); }
.viewer-card.is-relay .viewer-card__avatar {
  background: #3c2f12;
  color: var(--amber);
}

.stage {
  position: relative;
  display: none;
  flex: 1;
  place-items: center;
  align-self: stretch;
  min-height: 0;
  overflow: hidden;
  border-radius: 10px;
  background: #000;
}

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

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

.is-live .share-main,
.is-watching .watch-main { padding: 10px; }

.is-live .lobby,
.is-watching .join-box { display: none; }

.is-live .stage,
.is-watching .stage { display: grid; }

.join-box {
  display: grid;
  gap: 14px;
  width: min(380px, 100%);
}

.code-input {
  min-height: 56px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-align: center;
  text-transform: uppercase;
}

.join-box .status { text-align: center; }

.stage:fullscreen,
.stage:-webkit-full-screen {
  border-radius: 0;
  background: #000;
}

@media (max-width: 640px) {
  .doors { grid-template-columns: 1fr; }
  .door { min-height: 160px; }
  .topbar { flex-wrap: wrap; padding: 8px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
