:root {
  --bg: #eef4f8;
  --card: #ffffff;
  --line: #cdd8e1;
  --text: #0f172a;
  --sub: #475569;
  --ok: #0f766e;
  --warn: #9a3412;
  --danger: #be123c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(160deg, #e6eef6 0%, #f8fbff 100%);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}

.global-statusbar {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid #d6e1ea;
  background: rgba(248, 251, 255, 0.92);
  backdrop-filter: saturate(140%) blur(6px);
}

.global-statusbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  min-height: 56px;
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.global-statusbar-left {
  display: flex;
  align-items: center;
}

.global-statusbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.global-back-btn {
  padding: 8px 12px;
}

.global-statusbar-user {
  font-size: 14px;
  color: var(--sub);
}

.global-logout-btn {
  padding: 8px 12px;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: min(480px, 100%);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  padding: 22px 18px;
  display: grid;
  gap: 10px;
}

.auth-title {
  margin: 0 0 4px;
  font-size: 22px;
}

.auth-label {
  font-size: 13px;
  color: var(--sub);
}

.auth-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

.auth-code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.auth-submit {
  margin-top: 6px;
  padding-top: 11px;
  padding-bottom: 11px;
}

.auth-tip {
  margin: 2px 0 0;
  min-height: 20px;
  color: #1d4ed8;
  font-size: 13px;
}

.home-page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.home-header h1 {
  margin: 0;
  font-size: 24px;
}

.home-user {
  margin: 4px 0 0;
  color: var(--sub);
  font-size: 14px;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.home-grid-single {
  min-height: calc(100vh - 180px);
  grid-template-columns: minmax(320px, 460px);
  align-content: center;
  justify-content: center;
}

.home-card {
  border: none;
  border-radius: 14px;
  padding: 16px;
  min-height: 280px;
  text-align: left;
  color: #fff;
  cursor: pointer;
  display: grid;
  align-content: start;
  gap: 10px;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.2);
}

.home-grid-single .home-card {
  min-height: 320px;
}

.home-card-title {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
}

.home-card-desc {
  font-size: 14px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.94);
}

.home-card-assess {
  background: linear-gradient(150deg, #0284c7, #0369a1);
}

.home-card-health {
  background: linear-gradient(150deg, #10b981, #0f766e);
}

.home-card-metrics {
  background: linear-gradient(150deg, #f97316, #ea580c);
}

.home-card-report {
  background: linear-gradient(150deg, #334155, #0f172a);
}

.crowd-page {
  min-height: calc(100vh - 56px);
  padding: 16px;
  display: grid;
  place-items: center;
  overflow-x: auto;
}

.crowd-grid {
  width: min(1040px, calc(100vw - 40px));
  aspect-ratio: 1734 / 645;
  height: auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 397fr 397fr 397fr 507fr;
  gap: 12px;
}

.crowd-right-col {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 4.5%;
  height: 100%;
}

.crowd-tile {
  border: none;
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background: transparent;
  height: 100%;
}

.crowd-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.crowd-tile span {
  position: absolute;
  top: 10%;
  left: 0;
  right: 0;
  text-align: center;
  color: #ffffff;
  font-weight: 700;
  font-size: 28px;
  letter-spacing: 1px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.scale-menu-page {
  min-height: calc(100vh - 56px);
  padding: 12px;
  display: grid;
  place-items: center;
  overflow-x: auto;
}

.scale-menu-grid {
  width: auto;
  display: grid;
  gap: 12px;
}

.scale-menu-grid.cols-2 {
  width: min(944px, calc(100vw - 40px));
  grid-template-columns: repeat(2, minmax(0, 1fr));
  justify-content: center;
}

.scale-menu-grid.elderly-center {
  width: min(472px, calc(100vw - 40px));
  grid-template-columns: minmax(0, 1fr);
  justify-content: center;
}

.scale-menu-tile {
  border: none;
  border-radius: 24px;
  padding: 0;
  overflow: hidden;
  position: relative;
  min-height: 0;
  height: auto;
  aspect-ratio: 804 / 287;
  background: transparent;
  box-shadow: 0 12px 28px rgba(2, 6, 23, 0.26);
}

.scale-menu-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scale-menu-tile span {
  position: absolute;
  top: 12%;
  left: 8%;
  right: 8%;
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.25;
  text-align: left;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.52);
}

.other-page-body {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  justify-items: center;
  align-items: center;
}

.other-page-body > .global-statusbar {
  width: 100%;
  justify-self: stretch;
  align-self: start;
}

.other-menu-page {
  width: min(1240px, calc(100vw - 24px));
  height: min(1020px, calc(100vh - 88px));
  max-height: 1020px;
  padding: 12px;
  display: grid;
  grid-template-columns: 560px 180px 480px;
  justify-content: center;
  align-content: center;
  justify-items: stretch;
  align-items: stretch;
  gap: 10px;
  margin: 0 auto;
}

.other-panel {
  background: #fff;
  border: 1px solid #98b4cf;
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
  height: 100%;
  max-height: 100%;
}

.other-left {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 10px;
}

.other-right {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
}

.other-col {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
  min-height: 0;
}

.other-panel h3,
.other-actions h3 {
  margin: 0;
  font-size: 18px;
  padding: 7px;
  text-align: center;
  border: 1px solid #c7d5e4;
  border-radius: 8px;
  background: #eff5fb;
  max-height: 66px;
}

.other-list {
  border: 1px solid #c7d5e4;
  border-radius: 8px;
  padding: 6px;
  overflow: auto;
  background: #fff;
  min-height: 0;
  height: 100%;
  max-height: 100%;
}

.other-list-item {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 8px 9px;
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 14px;
  line-height: 1.35;
}

.other-list-item.selected {
  background: #1d4ed8;
  color: #fff;
}

.other-list-item.selected-green {
  background: #15803d;
  color: #fff;
}

.other-list-item.selected-orange {
  background: #c2410c;
  color: #fff;
}

.other-list-item.favorite-default {
  background: #f59e0b;
  color: #fff;
}

.other-actions {
  background: linear-gradient(180deg, #7ea8ea, #5f8fdd);
  border-radius: 10px;
  padding: 10px 8px;
  display: grid;
  height: 100%;
  max-height: 100%;
  align-content: center;
  justify-items: center;
  gap: 12px;
}

.other-actions button {
  min-width: 132px;
  width: 132px;
  min-height: 48px;
  height: 56px;
  max-height: 56px;
  border-radius: 8px;
  font-size: 24px;
  font-weight: 700;
}

.other-check {
  color: #fff;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.other-tip {
  margin: 0;
  color: #475569;
  font-size: 12px;
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--sub);
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--sub);
}

input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.diagnosis-actions {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
}

.diagnosis-actions-left {
  justify-self: start;
}

.diagnosis-actions-center {
  justify-self: center;
  display: flex;
  gap: 8px;
}

.diagnosis-actions-right {
  justify-self: end;
}

button {
  border: none;
  border-radius: 10px;
  padding: 9px 13px;
  font-weight: 600;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.primary {
  background: var(--ok);
  color: #fff;
}

.ghost {
  background: #e2e8f0;
  color: #0f172a;
}

.danger {
  background: var(--danger);
  color: #fff;
}

.main-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 12px;
}

h2, h3 {
  margin: 0 0 8px;
}

video {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #1e293b;
  background: #020617;
  aspect-ratio: 16 / 9;
}

#localPreview {
  object-fit: cover;
  object-position: center;
}

.video-stack {
  position: relative;
  width: 100%;
  height: 0;
  padding-top: 56.25%;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #1e293b;
  background: #020617;
}

.question-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: cover;
  border: none;
  border-radius: 0;
  opacity: 0;
  transition: opacity 220ms ease-in-out;
  background: #020617;
}

.question-video.active {
  opacity: 1;
}

.frame-hold {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms linear;
  z-index: 3;
  background: #020617;
}

.frame-hold.active {
  opacity: 1;
}

.meta {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  font-size: 12px;
  color: var(--sub);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
}

.question {
  margin: 10px 0 0;
  font-size: 20px;
  line-height: 1.5;
  font-weight: 700;
  min-height: 3em;
}

.answer-hint {
  margin: 6px 0 0;
  color: #1d4ed8;
  font-size: 15px;
  line-height: 1.5;
  font-weight: 600;
  min-height: 3em;
}

.question-progress {
  margin-top: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 34px;
  color: #0f172a;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.subtitle-label {
  margin: 26px 0 10px;
  font-size: 14px;
  font-weight: 700;
  color: #1f2937;
}

.subtitle {
  border: 1px dashed var(--line);
  border-radius: 10px;
  min-height: 210px;
  max-height: 270px;
  overflow: auto;
  padding: 12px;
  color: var(--text);
  font-size: 18px;
  line-height: 1.6;
  white-space: pre-wrap;
}

pre {
  margin: 0;
  max-height: 260px;
  overflow: auto;
  background: #0b1020;
  color: #dbeafe;
  border-radius: 10px;
  border: 1px solid #1e293b;
  padding: 10px;
}

.hidden-ui {
  display: none !important;
}

@media (max-width: 1024px) {
  .home-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-grid-single {
    grid-template-columns: minmax(280px, 420px);
  }

  .config-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 640px) {
  .diagnosis-actions {
    grid-template-columns: 1fr;
  }

  .diagnosis-actions-left,
  .diagnosis-actions-center,
  .diagnosis-actions-right {
    justify-self: center;
  }

  .other-actions button {
    min-width: 90px;
    font-size: 20px;
  }

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

  .home-grid-single {
    min-height: calc(100vh - 150px);
  }

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

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(2, 6, 23, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-overlay.hidden {
  display: none;
}

.loading-panel {
  background: #ffffff;
  border-radius: 14px;
  padding: 20px 24px;
  min-width: 220px;
  display: grid;
  justify-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.2);
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 4px solid #dbe7f0;
  border-top-color: #0f766e;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(2, 6, 23, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}

.confirm-overlay.hidden {
  display: none;
}

.confirm-panel {
  width: min(88vw, 420px);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.22);
  padding: 18px;
  display: grid;
  gap: 14px;
}

.confirm-panel p {
  margin: 0;
  font-size: 16px;
  color: var(--text);
  line-height: 1.45;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
