:root {
  color-scheme: light;
  --ink: #10212f;
  --muted: #607181;
  --line: #d9e2e8;
  --panel: #ffffff;
  --canvas: #edf3f5;
  --accent: #0b7a75;
  --accent-strong: #075d59;
  --danger: #c63535;
  --danger-strong: #a92828;
  --stage: #0b141a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(237, 243, 245, 0.94)),
    var(--canvas);
  color: var(--ink);
  font-family:
    "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 4px 22px;
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 5vw, 42px);
  letter-spacing: -0.02em;
}

h2 {
  margin-bottom: 6px;
  font-size: 20px;
}

.server-state {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
  font-size: 14px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #c6a748;
}

.server-state.ready .dot {
  background: #14956d;
}

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

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.6fr);
  gap: 18px;
}

.lobby-panel,
.join-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 14px 34px rgba(22, 47, 64, 0.07);
}

.lobby-panel {
  padding: 22px;
}

.join-panel {
  padding: 22px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.icon-button,
.control-button {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.icon-button:hover,
.control-button:hover {
  border-color: #9fb1bd;
  background: #f4f8f9;
}

.call-list {
  min-height: 220px;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 220px;
  border: 1px dashed #cbd8de;
  border-radius: 8px;
  color: #7a8994;
}

.empty-state svg {
  width: 30px;
  height: 30px;
}

.call-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.call-item + .call-item {
  margin-top: 12px;
}

.call-item strong {
  display: block;
  margin-bottom: 5px;
}

.call-item code {
  color: var(--muted);
  font-size: 13px;
}

.answer-button,
.primary-button,
.hangup-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  color: #fff;
}

.answer-button,
.primary-button {
  background: var(--accent);
}

.answer-button:hover,
.primary-button:hover {
  background: var(--accent-strong);
}

.answer-button {
  min-width: 104px;
  height: 42px;
  border-radius: 6px;
}

.join-panel label {
  display: block;
  margin-bottom: 18px;
}

.join-panel label span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.join-panel input {
  width: 100%;
  height: 48px;
  padding: 0 13px;
  border: 1px solid #c8d4da;
  border-radius: 6px;
  outline: none;
  color: var(--ink);
  background: #fff;
}

.join-panel input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 122, 117, 0.12);
}

.primary-button {
  width: 100%;
  height: 48px;
  border-radius: 6px;
}

.call-stage {
  position: relative;
  overflow: hidden;
  height: min(76vh, 760px);
  min-height: 520px;
  border-radius: 8px;
  background: var(--stage);
  box-shadow: 0 18px 48px rgba(8, 20, 28, 0.22);
}

.remote-video,
.remote-video video,
.local-video,
.local-video video {
  width: 100%;
  height: 100%;
}

.remote-video {
  position: relative;
}

.remote-video video,
.local-video video {
  display: block;
  object-fit: cover;
}

.waiting {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: #c4d0d7;
  background: radial-gradient(circle at 50% 40%, #1d2b34, #0b141a 65%);
}

.waiting svg {
  width: 34px;
  height: 34px;
}

.local-video {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 180px;
  height: 240px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: #17232b;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28);
}

.call-status {
  position: absolute;
  right: 18px;
  bottom: 18px;
  left: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(9, 18, 24, 0.78);
  color: #fff;
  backdrop-filter: blur(16px);
}

.call-status .label {
  color: #8fd1c7;
}

.call-status strong {
  font-size: 18px;
}

.call-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.control-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
}

.control-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

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

.control-button.off {
  color: #ffd1d1;
  background: rgba(198, 53, 53, 0.42);
}

.hangup-button {
  height: 44px;
  padding: 0 18px;
  border-radius: 6px;
  background: var(--danger);
}

.hangup-button:hover {
  background: var(--danger-strong);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  max-width: min(520px, calc(100% - 32px));
  padding: 12px 16px;
  border-radius: 6px;
  color: #fff;
  background: #16242e;
  box-shadow: 0 12px 28px rgba(7, 17, 23, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

@media (max-width: 820px) {
  .shell {
    width: min(100% - 22px, 720px);
    padding-top: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .call-stage {
    height: 76vh;
    min-height: 480px;
  }

  .local-video {
    top: 12px;
    right: 12px;
    width: 116px;
    height: 158px;
  }

  .call-status {
    right: 12px;
    bottom: 12px;
    left: 12px;
    align-items: flex-start;
    flex-direction: column;
  }

  .call-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid #d4a72c;
  border-radius: 999px;
  background: #fffbeb;
  color: #92600a;
  font-size: 13px;
  font-weight: 600;
  transition: 160ms ease;
}

.sound-toggle:hover {
  background: #fef3c7;
}

.sound-toggle.unlocked {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: #065f46;
}

.call-item.ringing {
  border-color: #10b981;
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.12), rgba(255, 255, 255, 0.96));
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.18);
  animation: call-shake 0.55s ease-in-out infinite;
}

.call-item-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mute-ring-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.mute-ring-button:hover {
  background: #f4f8f9;
  color: var(--ink);
}

.answer-button.ringing {
  background: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
  animation: answer-pulse 1.2s infinite;
}

@keyframes call-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-5px) rotate(-0.6deg); }
  30% { transform: translateX(5px) rotate(0.6deg); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

@keyframes answer-pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
  70% { box-shadow: 0 0 0 12px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
