/* ==========================
   全局
========================== */

* {
  box-sizing: border-box;
}

:root {
  --primary: #2878f0;
  --primary-dark: #155fc9;
  --primary-light: #edf5ff;

  --text: #243247;
  --text-light: #66758a;

  --bg: #f4f7fb;
  --white: #ffffff;

  --border: #e4eaf2;

  --success: #21a366;
  --danger: #e55353;

  --shadow:
    0 8px 30px rgba(30, 70, 120, 0.08);
}

body {
  margin: 0;
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    Arial,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ==========================
   主布局
========================== */

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

/* ==========================
   侧边栏
========================== */

.sidebar {
  min-height: 100vh;
  background: linear-gradient(180deg, #1f6fe5 0%, #398af1 100%);
  color: white;
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 42px;
  padding-left: 8px;
}

.brand-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(255,255,255,0.18);
  font-size: 28px;
}

.brand-title {
  font-size: 21px;
  font-weight: 700;
}

.brand-subtitle {
  font-size: 12px;
  opacity: 0.8;
  margin-top: 3px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-btn {
  width: 100%;
  min-height: 56px;
  padding: 0 18px;
  border: none;
  border-radius: 14px;
  background: transparent;
  color: rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 17px;
  cursor: pointer;
  transition: 0.2s ease;
}

.nav-btn:hover {
  background: rgba(255,255,255,0.12);
}

.nav-btn.active {
  color: var(--primary);
  background: white;
  box-shadow: 0 5px 18px rgba(20,70,140,0.12);
}

.nav-icon {
  width: 30px;
  text-align: center;
  font-size: 22px;
}

.sidebar-bottom {
  margin-top: auto;
}

.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  opacity: 0.9;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #41e18a;
  display: inline-block;
}

.voice-btn {
  width: 100%;
  min-height: 50px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 14px;
  background: rgba(255,255,255,0.12);
  color: white;
  font-size: 16px;
  cursor: pointer;
}

/* ==========================
   主区域
========================== */

.main {
  padding: 24px 30px 20px;
  overflow-y: auto;
  min-width: 0;
}

/* ==========================
   卡片
========================== */

.card {
  background: white;
  border-radius: 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(220,230,240,0.65);
}

/* ==========================
   顶栏
========================== */

.topbar {
  min-height: 84px;
  padding: 16px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.clock {
  font-size: 30px;
  font-weight: 700;
}

.date {
  margin-top: 5px;
  color: var(--text-light);
  font-size: 14px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-btn {
  width: 48px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.top-btn:hover {
  background: var(--primary-light);
}

.online-status {
  padding: 9px 13px;
  background: #effaf4;
  color: var(--success);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

/* ==========================
   页面切换
========================== */

.view {
  display: none;
  margin-top: 22px;
}

.view.active {
  display: block;
}

/* ==========================
   首页欢迎
========================== */

.welcome {
  margin: 8px 2px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.welcome h1 {
  margin: 0;
  font-size: 29px;
}

.welcome p {
  margin: 8px 0 0;
  color: var(--text-light);
  font-size: 15px;
}

.welcome-time {
  padding: 12px 18px;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow);
  color: var(--primary);
  font-weight: 700;
}

/* ==========================
   首页网格
========================== */

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr);
  gap: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.card-title {
  font-size: 20px;
  font-weight: 700;
}

.card-subtitle {
  margin-top: 6px;
  color: var(--text-light);
  font-size: 13px;
}

.weather-card,
.reminder-card {
  padding: 23px;
}

.refresh-btn {
  border: none;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 10px;
  padding: 8px 13px;
  cursor: pointer;
  font-size: 14px;
}

/* ==========================
   城市选择
========================== */

.city-selector {
  margin-top: 20px;
}

.city-label {
  display: block;
  margin-bottom: 9px;
  font-size: 14px;
  color: var(--text-light);
}

.city-control {
  display: grid;
  grid-template-columns: 180px minmax(140px, 1fr) 78px;
  gap: 9px;
}

.city-select,
.city-input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid #dce3ed;
  background: white;
  font-size: 15px;
  outline: none;
}

.city-select:focus,
.city-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(40,120,240,0.1);
}

.city-submit {
  height: 44px;
}

.btn {
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  padding: 0 16px;
  min-height: 44px;
  font-size: 15px;
  cursor: pointer;
  transition: 0.2s;
}

.btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.city-results {
  margin-top: 8px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(30,70,120,0.08);
  max-height: 220px;
  overflow-y: auto;
}

.city-result {
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f0f3f7;
  font-size: 14px;
}

.city-result:last-child {
  border-bottom: none;
}

.city-result:hover {
  background: var(--primary-light);
}

.city-result strong {
  color: var(--text);
}

.city-result span {
  color: var(--text-light);
  margin-left: 6px;
}

.hidden {
  display: none !important;
}

/* ==========================
   天气
========================== */

.weather-status {
  margin-top: 12px;
  min-height: 22px;
  color: var(--text-light);
  font-size: 13px;
}

.weather-main {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 26px;
}

.weather-temperature {
  font-size: 66px;
  line-height: 1;
  font-weight: 700;
  color: var(--primary);
}

.temperature-unit {
  font-size: 25px;
  vertical-align: top;
  margin-left: 3px;
}

.weather-description {
  border-left: 1px solid var(--border);
  padding-left: 25px;
}

#weatherText {
  font-size: 25px;
  font-weight: 700;
}

.weather-city {
  margin-top: 7px;
  font-size: 16px;
  color: var(--text-light);
}

.weather-update {
  margin-top: 5px;
  font-size: 12px;
  color: #93a0b2;
}

.weather-details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 24px;
}

.weather-item {
  min-height: 74px;
  border-radius: 14px;
  background: #f8fafc;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.weather-item-icon {
  font-size: 25px;
}

.weather-item-label {
  color: var(--text-light);
  font-size: 12px;
}

.weather-item-value {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 700;
}

/* ==========================
   提醒
========================== */

.reminder-content {
  margin-top: 35px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.reminder-icon {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff5e8;
  font-size: 34px;
}

.reminder-info h3 {
  margin: 0;
  font-size: 21px;
}

.reminder-info p {
  margin: 7px 0;
  color: var(--text-light);
  line-height: 1.7;
  font-size: 14px;
}

.reminder-time {
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.reminder-btn {
  width: 100%;
  margin-top: 30px;
}

/* ==========================
   主动关怀
========================== */

.section-title {
  margin: 26px 2px 14px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 22px;
}

.section-title span {
  color: var(--text-light);
  font-size: 13px;
}

.care-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.care-card {
  min-height: 110px;
  background: white;
  border-radius: 17px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
}

.care-icon {
  width: 55px;
  height: 55px;
  border-radius: 16px;
  background: var(--primary-light);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 27px;
}

.care-card h3 {
  margin: 0;
  font-size: 17px;
}

.care-card p {
  margin: 7px 0 0;
  color: var(--text-light);
  font-size: 13px;
}

/* ==========================
   页面标题
========================== */

.page-title {
  margin-bottom: 20px;
}

.page-title h1 {
  margin: 0;
  font-size: 28px;
}

.page-title p {
  color: var(--text-light);
  margin-top: 7px;
}

/* ==========================
   进度
========================== */

#med .card {
  padding: 25px;
}

.progress {
  width: 100%;
  height: 16px;
  background: #edf1f5;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 22px;
}

#progressBar {
  width: 30%;
  height: 100%;
  background: linear-gradient(90deg, #2878f0, #61a2ff);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.progress-text {
  margin-top: 10px;
  color: var(--primary);
  font-weight: 700;
}

/* ==========================
   健康
========================== */

.health-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.health-card {
  padding: 25px;
}

.health-icon {
  font-size: 38px;
}

.health-card h3 {
  margin-bottom: 5px;
}

.health-card p {
  color: var(--text-light);
  line-height: 1.8;
}

/* ==========================
   设置
========================== */

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.settings-grid .card {
  padding: 24px;
}

.font-settings {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.font-settings button {
  min-width: 70px;
  height: 44px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}

.font-settings button.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

.setting-info {
  color: var(--text-light);
  margin-top: 20px;
}

.setting-info strong {
  color: var(--text);
  margin-left: 5px;
}

.danger-btn {
  margin-top: 12px;
  background: #f05c5c;
}

.danger-btn:hover {
  background: #d94747;
}

/* ==========================
   footer
========================== */

.footer {
  margin-top: 30px;
  padding: 15px;
  text-align: center;
  color: #9aa7b8;
  font-size: 12px;
}

/* ==========================
   🆕 图片识别样式
========================== */

.recog-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 820px) {
  .recog-grid {
    grid-template-columns: 1fr;
  }
}

.recog-upload-area {
  border: 3px dashed var(--primary-light);
  border-radius: 20px;
  padding: 30px 20px;
  text-align: center;
  transition: 0.25s ease;
  cursor: pointer;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #f9fcff;
}

.recog-upload-area:hover {
  border-color: var(--primary);
  background: #f0f7ff;
}

.recog-upload-area.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.recog-upload-area .upload-icon {
  font-size: 56px;
}

.recog-upload-area .upload-text {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-light);
}

.recog-upload-area .upload-hint {
  font-size: 15px;
  color: var(--text-light);
}

.recog-upload-area .upload-btn {
  margin-top: 8px;
  padding: 12px 32px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 30px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

.recog-upload-area .upload-btn:hover {
  background: var(--primary-dark);
}

.recog-preview {
  margin-top: 14px;
  max-width: 100%;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  display: none;
}

.recog-preview img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 12px;
  object-fit: contain;
}

.recog-preview.show {
  display: block;
}

.recog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  justify-content: center;
}

.recog-actions .action-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 30px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.recog-actions .action-btn.primary {
  background: var(--primary);
  color: #fff;
}

.recog-actions .action-btn.primary:hover {
  background: var(--primary-dark);
}

.recog-actions .action-btn.secondary {
  background: var(--bg);
  color: var(--text);
}

.recog-actions .action-btn.secondary:hover {
  background: #e2e8f0;
}

.recog-result-box {
  background: var(--bg);
  border-radius: 12px;
  padding: 18px 20px;
  min-height: 120px;
  font-size: 18px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  flex: 1;
}

.recog-result-box .placeholder {
  color: var(--text-light);
  font-size: 17px;
}

.recog-result-box .loading {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--primary);
  font-weight: 500;
}

.recog-result-box .loading .spinner {
  width: 28px;
  height: 28px;
  border: 4px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.recog-result-box .result-text {
  font-size: 19px;
}

.recog-history {
  margin-top: 20px;
}

.recog-history h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.recog-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
}

.recog-history-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--bg);
  border-radius: 12px;
  font-size: 16px;
  transition: 0.2s;
}

.recog-history-item:hover {
  background: #e2e8f0;
}

.recog-history-item .h-time {
  font-size: 14px;
  color: var(--text-light);
  flex-shrink: 0;
}

.recog-history-item .h-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recog-history-empty {
  color: var(--text-light);
  font-size: 16px;
  padding: 12px 0;
}

.recog-stats {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 12px;
}

.recog-stats .stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  color: var(--text-light);
}

.recog-stats .stat-item strong {
  color: var(--text);
  font-weight: 700;
}

.camera-container {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  margin-top: 12px;
  display: none;
}

.camera-container.show {
  display: block;
}

.camera-container video {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  display: block;
}

.camera-container .cam-overlay {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
}

.camera-container .cam-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 30px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

.camera-container .cam-btn.capture {
  background: #fff;
  color: #000;
}

.camera-container .cam-btn.capture:hover {
  background: #f0f0f0;
}

.camera-container .cam-btn.close {
  background: rgba(255,255,255,0.3);
  color: #fff;
}

.camera-container .cam-btn.close:hover {
  background: rgba(255,255,255,0.5);
}

.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(60, 45, 42, 0.92);
  color: #fff;
  padding: 14px 32px;
  border-radius: 40px;
  font-size: 18px;
  font-weight: 500;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  backdrop-filter: blur(8px);
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================
   响应式
========================== */

@media (max-width: 1100px) {
  .app {
    grid-template-columns: 210px minmax(0,1fr);
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .care-grid {
    grid-template-columns: 1fr;
  }
  .health-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 800px) {
  .app {
    display: block;
  }
  .sidebar {
    min-height: auto;
    padding: 14px;
    position: sticky;
    top: 0;
    z-index: 20;
  }
  .brand {
    margin-bottom: 12px;
  }
  .nav {
    flex-direction: row;
    overflow-x: auto;
  }
  .nav-btn {
    min-width: 110px;
  }
  .sidebar-bottom {
    display: none;
  }
  .main {
    padding: 15px;
  }
  .city-control {
    grid-template-columns: 1fr;
  }
  .weather-main {
    flex-direction: column;
    align-items: flex-start;
  }
  .weather-description {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: 15px;
  }
  .weather-details {
    grid-template-columns: 1fr;
  }
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .recog-grid {
    grid-template-columns: 1fr;
  }
  .recog-upload-area {
    min-height: 160px;
    padding: 20px;
  }
  .recog-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .recog-actions .action-btn {
    justify-content: center;
  }
}