:root {
  color-scheme: light;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Noto Sans SC", sans-serif;
  background: #f6f7fb;
  color: #1a1b1f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #ffffff 0%, #edf2ff 100%);
}

button,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 18px;
}

.main-panel {
  width: min(1200px, 100%);
  margin: 0 auto;
}

.login-screen,
.app-shell-content {
  width: 100%;
}

.login-card {
  max-width: 420px;
  margin: 0 auto;
  padding: 28px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 22px 60px rgba(34, 51, 110, 0.12);
  text-align: center;
}

.login-title {
  font-size: 1.55rem;
  font-weight: 700;
  margin-bottom: 20px;
}

.input-group {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
  text-align: left;
}

.input-group span {
  color: #5f6d92;
}

.input-group input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #d8e0f5;
  background: #fff;
  transition: box-shadow .12s ease, border-color .12s ease;
}

.input-group small {
  color: #7d86a4;
  font-size: 0.82rem;
  line-height: 1.4;
}

.input-group input:focus {
  outline: none;
  border-color: #5566ff;
  box-shadow: 0 6px 18px rgba(85,102,255,0.12);
}

select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #d8e0f5;
  background: #fff;
}

.primary-button,
.control-button,
.ghost-button,
.danger-button {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
}

.verification-row {
  display: flex;
  gap: 10px;
}

.verification-row input {
  flex: 1 1 auto;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #d8e0f5;
  background: #fff;
}

.verification-row button {
  width: auto;
  min-width: 110px;
}

.auth-links {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
}

.forgot-password-panel {
  margin-top: 8px;
  padding: 14px;
  border-radius: 18px;
  background: #f9fbff;
  border: 1px solid rgba(86, 92, 255, 0.12);
}

.forgot-password-title {
  font-weight: 700;
  margin-bottom: 12px;
  text-align: left;
  color: #33418f;
}

.hidden {
  display: none !important;
}

.primary-button {
  background: #5566ff;
  color: white;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.9);
  color: #33418f;
  border: 1px solid rgba(51, 65, 143, 0.12);
}

.link-button {
  background: transparent;
  border: none;
  color: #5566ff;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.danger-button {
  background: #f64e60;
  color: white;
  max-width: 160px;
}

.login-tip {
  color: #5f6d92;
  margin-top: 18px;
  line-height: 1.7;
}

.install-button {
  margin-top: 14px;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, #5566ff, #6b8cff);
  color: white;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 16px;
  position: relative;
}

.title-group {
  display: grid;
  gap: 6px;
}

.profile-menu {
  position: relative;
}

.profile-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(86, 92, 255, 0.14);
  cursor: pointer;
}

.profile-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5f6dff, #8eb9ff);
  color: white;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.profile-info {
  display: grid;
  gap: 2px;
  text-align: left;
}

.profile-name {
  font-weight: 700;
}

.profile-status {
  font-size: 0.88rem;
  color: #22c55e;
}

.profile-status.busy {
  color: #f97316;
}

.profile-status.offline {
  color: #9ca3af;
}

.profile-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 240px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  padding: 14px;
  z-index: 30;
}

.profile-dropdown-row {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.profile-dropdown-row label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  color: #33418f;
}

.profile-dropdown-row input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid #d8e0f5;
}

.profile-dropdown button {
  width: 100%;
  margin-bottom: 8px;
  display: block;
}

/* Ensure danger button inside dropdown aligns with other buttons */
.profile-dropdown .danger-button {
  max-width: none;
}

.app-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.sub-title {
  color: #5f6d92;
}

.workspace {
  display: grid;
  /* 默认仅显示通讯录（单列），避免未通话时视频占位 */
  grid-template-columns: 1fr;
  gap: 18px;
}

/* 当需要把视频面板与联系人并列显示（可选）可以添加一个类控制，默认不启用 */

.contact-panel {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 24px;
  padding: 18px;
  box-shadow: 0 20px 40px rgba(45, 71, 142, 0.08);
}

.panel-header {
  font-weight: 700;
  margin-bottom: 16px;
}

.contact-list {
  display: grid;
  gap: 12px;
}

.contact-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  border-radius: 18px;
  background: #f9fbff;
  border: 1px solid rgba(86, 92, 255, 0.12);
}

.contact-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.contact-meta {
  display: grid;
  gap: 6px;
}

.contact-subtitle {
  color: #5f6d92;
  font-size: 0.92rem;
  line-height: 1.4;
}

.contact-remark {
  color: #5566ff;
  font-size: 0.92rem;
  line-height: 1.4;
  cursor: pointer;
  transition: color .15s ease;
}

.contact-remark:hover {
  color: #33418f;
}

.search-panel {
  margin-bottom: 18px;
}

.search-row {
  display: flex;
  gap: 10px;
}

.search-row input {
  flex: 1 1 auto;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #d8e0f5;
  background: #fff;
}

.search-results {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.search-result-item {
  padding: 14px;
  border-radius: 18px;
  background: #f8fafc;
  border: 1px solid rgba(100, 116, 139, 0.14);
}

.search-result-item .search-label {
  color: #33418f;
  font-size: 0.92rem;
}

.contact-empty {
  padding: 20px;
  border-radius: 18px;
  background: #f3f4f6;
  color: #475569;
  border: 1px dashed rgba(100, 116, 139, 0.24);
}

.contact-avatar {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: linear-gradient(135deg, #5f6dff, #8eb9ff);
  color: white;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  font-weight: 700;
}

.contact-name {
  font-weight: 700;
}

.contact-status {
  font-size: 0.92rem;
  color: #5f6d92;
}

.contact-status.online {
  color: #22c55e;
}

.contact-status.busy {
  color: #f97316;
}

.contact-status.offline {
  color: #9ca3af;
}

.call-button {
  border-radius: 14px;
  padding: 10px 14px;
  background: #5566ff;
  color: #fff;
  min-width: 84px;
}

.call-button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.video-panel {
  /* 默认隐藏视频面板，只有 in-call 时弹出并占满全屏 */
  display: none;
  gap: 18px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 24px;
  padding: 20px;
  box-shadow: 0 20px 40px rgba(45, 71, 142, 0.08);
}

.in-call .video-panel { display: flex; }

.video-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.video-status {
  font-weight: 700;
}

.video-timer {
  color: #5f6d92;
}

.video-stage {
  position: relative;
}

.video-main {
  position: relative;
  background: #101828;
  border-radius: 22px;
  overflow: hidden;
  min-height: 240px;
  aspect-ratio: 16 / 9;
}

.video-preview {
  position: absolute;
  top: 18px;
  right: 18px;
  width: min(210px, 36%);
  aspect-ratio: 3 / 4;
  background: #101828;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.12);
  z-index: 2;
}

.video-main video,
.video-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #101828;
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.control-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.control-button,
.danger-button {
  flex: 1 1 auto;
  min-width: 130px;
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 22, 48, 0.56);
  z-index: 20;
}

.overlay-card {
  width: min(420px, 100%);
  padding: 24px;
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 26px 60px rgba(34, 51, 110, 0.16);
  text-align: center;
}

.overlay-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.overlay-text {
  color: #5f6d92;
  line-height: 1.8;
  margin-bottom: 16px;
}

.overlay-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #d8e0f5;
  background: #f8fbff;
  font-size: 0.98rem;
  color: #1f2937;
  margin-bottom: 18px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.overlay-input:focus {
  outline: none;
  border-color: #5566ff;
  box-shadow: 0 0 0 4px rgba(85, 102, 255, 0.12);
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.overlay-actions button {
  min-width: 120px;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .video-main {
    min-height: 220px;
  }

  .video-preview {
    width: min(180px, 34%);
    top: 14px;
    right: 14px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 12px;
  }

  .top-bar,
  .control-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .contact-item {
    flex-direction: column;
    align-items: stretch;
  }

  .call-button {
    width: 100%;
  }
}

/* In-call full screen layout (desktop and mobile behave the same) */
.in-call .contact-panel {
  display: none !important; /* hide only contacts panel */
}

.in-call .video-panel {
  position: fixed;
  inset: 0;
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: #000; /* black background for call */
}

.in-call .video-header {
  display: none; /* hide top header inside call to maximize video */
}

.in-call .video-stage {
  flex: 1 1 auto;
  display: block;
}

.in-call .video-main {
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 0;
  aspect-ratio: auto;
}

/* Controls fixed inside the call view */
.in-call .control-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22px;
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 0 12px;
  z-index: 60;
}

.in-call .control-button,
.in-call .danger-button {
  min-width: 56px;
  width: 56px;
  height: 56px;
  border-radius: 28px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
}

.in-call .danger-button {
  background: #f64e60;
}

/* Keep preview as PIP in top-right for in-call on all sizes */
.in-call .video-preview {
  position: absolute;
  top: 18px;
  right: 18px;
  width: min(180px, 30%);
  aspect-ratio: 3 / 4;
  z-index: 70;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.36);
}

/* When not in-call, the preview remains within the video panel as earlier rules */
