/* NovaForge 手机端样式
 * 与微信小程序版（weapp）视觉 1:1 对齐：浅/深色双主题、卡片式布局、品牌绿 #008a7f
 * rpx → px 按 375 逻辑宽度折算（1rpx = 0.5px）
 */

:root {
  --page-bg: #f4f7f6;
  --card-bg: #ffffff;
  --card-2: #f7faf9;
  --text-main: #0d1b18;
  --text-secondary: #46564f;
  --text-muted: #7c8d87;
  --line-color: #e6ece9;
  --field-bg: #f1f6f4;
  --brand: #008a7f;
  --brand-light: #12b3a3;
  --brand-deep: #006b62;
  --brand-soft: rgba(0, 138, 127, .10);
  --brand-glow: rgba(0, 138, 127, .24);
  --shadow-card: 0 2px 10px -4px rgba(10, 35, 30, .10), 0 1px 2px rgba(10, 35, 30, .04);
  --shadow-float: 0 18px 44px -22px rgba(10, 35, 30, .30);
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --skip-1: #c9cdd4;
}

body.theme-dark {
  --page-bg: #0a1110;
  --card-bg: #131d1b;
  --card-2: #182422;
  --text-main: #e9f4f1;
  --text-secondary: #b7c8c3;
  --text-muted: #879a95;
  --line-color: #24312e;
  --field-bg: #1b2725;
  --brand-deep: #12a396;
  --brand-soft: rgba(55, 217, 199, .12);
  --brand-glow: rgba(18, 163, 150, .32);
  --shadow-card: 0 2px 12px -4px rgba(0, 0, 0, .45);
  --shadow-float: 0 20px 48px -22px rgba(0, 0, 0, .7);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--page-bg);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC',
    'Hiragino Sans GB', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-main);
  background: var(--page-bg);
  overscroll-behavior: none;
}

input, textarea, button {
  font-family: inherit;
  outline: none;
  border: none;
  background: none;
  color: inherit;
}

#app {
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
  background: var(--page-bg);
  overflow: hidden;
}

.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--page-bg);
}

.view[hidden] { display: none; }

.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================ 顶部导航 ============================ */

.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: calc(var(--safe-top) + 8px) 16px 8px;
  background: var(--card-bg);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line-color);
  min-height: 48px;
}

.nav-back {
  width: 28px;
  margin-left: -8px;
  color: var(--text-main);
  font-size: 26px;
  line-height: 1;
  text-align: center;
}

.nav-back[hidden] { display: none; }

.nav-title {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-right {
  min-width: 28px;
  text-align: right;
  color: var(--brand);
  font-size: 13px;
}

/* ============================ 页面容器 ============================ */

.page-host {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.page-host.page-ai {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ============================ 底部标签栏 ============================ */

.tabbar {
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: var(--card-bg);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line-color);
}

.tab-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 12.5px;
  transition: background .18s ease, color .18s ease;
}

.tab-item-active {
  color: var(--brand);
  background: var(--brand-soft);
  font-weight: 700;
}

/* ============================ 通用组件 ============================ */

.card {
  background: var(--card-bg);
  border: 1px solid var(--line-color);
  border-radius: 8px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 0 8px;
  padding: 0 4px;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

.section-tip,
.section-count {
  font-size: 11px;
  color: var(--text-muted);
}

.empty-card {
  background: var(--card-bg);
  border: 1px solid var(--line-color);
  border-radius: 8px;
  padding: 21px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.7;
}

.empty-title {
  color: var(--text-main);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 5px;
  display: block;
}

.empty-text {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.7;
  display: block;
}

.connect-empty {
  margin-top: 12px;
  padding-top: 32px;
  padding-bottom: 32px;
}

.connect-button {
  min-width: 100px;
  height: 38px;
  margin-top: 13px;
  padding: 0 12px;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.button-busy,
.button-disabled { opacity: 0.55; }

.field-label {
  display: block;
  color: var(--text-secondary);
  font-size: 12px;
  margin-bottom: 5px;
}

.field {
  width: 100%;
  height: 42px;
  padding: 0 10px;
  margin-bottom: 11px;
  border: 1px solid var(--line-color);
  border-radius: 6px;
  background: var(--field-bg);
  color: var(--text-main);
  font-size: 13px;
}

.field::placeholder { color: var(--text-muted); }

/* ============================ 登录页 ============================ */

.login {
  min-height: 100%;
  padding: calc(var(--safe-top) + 48px) 20px calc(24px + var(--safe-bottom));
  background: var(--page-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.login .title {
  margin-bottom: 28px;
  color: var(--text-main);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.panel {
  padding: 16px 14px;
  border: 1px solid var(--line-color);
  border-radius: 6px;
  background: var(--card-bg);
}

.label {
  display: block;
  margin-bottom: 7px;
  color: var(--text-secondary);
  font-size: 12px;
}

.ha-input {
  width: 100%;
  height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line-color);
  border-radius: 4px;
  background: var(--field-bg);
  color: var(--text-main);
  font-size: 13px;
}

.ha-input::placeholder { color: var(--text-muted); }

.wx-button {
  height: 44px;
  margin-top: 12px;
  border-radius: 4px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.status {
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.6;
  word-break: break-all;
}

.status[hidden] { display: none; }

.demo-link {
  margin-top: 18px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 12px;
}

.more {
  margin-top: auto;
  padding-top: 24px;
}

.more-toggle {
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
}

.more-body {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line-color);
  border-radius: 6px;
  background: var(--card-bg);
}

.more-body[hidden] { display: none; }

.github-button {
  height: 40px;
  margin-bottom: 8px;
  border: 1px solid var(--line-color);
  border-radius: 4px;
  color: var(--text-main);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mail-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-color);
}

.mail-actions {
  display: flex;
  justify-content: flex-end;
  margin: -4px 0 8px;
}

.device-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-color);
}

.device-panel[hidden] { display: none; }

.device-title {
  display: block;
  color: var(--text-secondary);
  font-size: 12px;
  margin-bottom: 6px;
}

.device-code {
  display: block;
  color: var(--text-main);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 9px;
}

.device-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
}

.mini-button {
  height: 32px;
  padding: 0 11px;
  margin: 3px;
  border-radius: 4px;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mini-button-ghost {
  background: var(--card-bg);
  color: var(--text-secondary);
  border: 1px solid var(--line-color);
}

.device-tip {
  display: block;
  margin-top: 7px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.7;
}

.link-button {
  margin-top: 7px;
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
}

/* ============================ 首页 ============================ */

.home {
  min-height: 100%;
  padding-bottom: calc(20px + var(--safe-bottom));
  background: var(--page-bg);
}

.hero {
  padding: 15px 14px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--line-color);
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hero-info { min-width: 0; }

.greeting {
  display: block;
  color: var(--text-muted);
  font-size: 11.5px;
  margin-bottom: 3px;
}

.hero-title {
  display: block;
  color: var(--text-main);
  font-size: 18px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.add-button {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  margin-left: 10px;
  border-radius: 6px;
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-icon {
  color: #fff;
  font-size: 21px;
  line-height: 1;
  margin-top: -2px;
}

.content { padding: 12px 14px 0; }

.demo-banner {
  background: #fff7e8;
  color: #ad4e00;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 11.5px;
  margin-bottom: 10px;
}

.overview {
  background: var(--card-bg);
  border: 1px solid var(--line-color);
  border-radius: 8px;
  padding: 13px;
}

.overview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 13px;
}

.home-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
}

.connection-text {
  color: var(--text-muted);
  font-size: 11px;
}

.stats { display: flex; align-items: center; }

.stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.stat-item:not(:last-child)::after {
  content: '';
  position: absolute;
  right: 0;
  top: 4px;
  bottom: 4px;
  width: 1px;
  background: var(--line-color);
}

.stat-value {
  font-size: 17px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 3px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
}

.device-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}

.grid-item {
  width: 48.8%;
  min-height: 98px;
  margin-bottom: 8px;
}

.grid-item-busy { opacity: 0.55; }

.device-card {
  width: 100%;
  min-height: 98px;
  padding: 11px;
  border: 1px solid var(--line-color);
  border-radius: 8px;
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
}

.device-on {
  background: rgba(0, 179, 164, 0.1);
  border-color: rgba(0, 138, 127, 0.45);
}

.icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--field-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 9px;
}

.device-icon { font-size: 16px; line-height: 1; }

.device-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-state {
  font-size: 11px;
  color: var(--text-muted);
}

.device-readonly .device-state { font-weight: 500; }

/* ============================ 场景页 ============================ */

.scenes {
  min-height: 100%;
  padding: 14px 14px calc(24px + var(--safe-bottom));
  background: var(--page-bg);
}

.page-header { padding: 4px 2px 12px; }

.page-title {
  display: block;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-main);
}

.scene-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}

.scene-item { width: 48.8%; margin-bottom: 8px; }

.scene-card {
  min-height: 83px;
  padding: 11px;
  border-radius: 8px;
  background: var(--card-bg);
  border: 1px solid var(--line-color);
  display: flex;
  flex-direction: column;
}

.scene-card-busy { opacity: 0.55; }

.scene-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 11px;
}

.scene-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--field-bg);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scene-action {
  color: var(--brand);
  font-size: 11.5px;
}

.scene-name {
  color: var(--text-main);
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.automation-card {
  background: var(--card-bg);
  border: 1px solid var(--line-color);
  border-radius: 8px;
  padding: 0 12px;
}

.automation-row {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line-color);
}

.automation-row:last-child { border-bottom: none; }

.automation-info {
  flex: 1;
  min-width: 0;
  padding-right: 12px;
}

.automation-name {
  display: block;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.automation-state {
  color: var(--text-muted);
  font-size: 11px;
}

.automation-state-on { color: var(--brand); }

/* 开关 */
.switch {
  flex-shrink: 0;
  width: 46px;
  height: 26px;
  border-radius: 13px;
  background: var(--skip-1);
  position: relative;
  transition: background 0.18s ease;
}

.switch::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: transform 0.18s ease;
}

.switch.switch-on { background: var(--brand); }
.switch.switch-on::after { transform: translateX(20px); }
.switch.switch-disabled { opacity: 0.5; }

/* ============================ AI 页 ============================ */

.ai {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--page-bg);
  overflow: hidden;
}

.ai .header {
  flex-shrink: 0;
  padding: 12px 16px 8px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--line-color);
}

.header-top { display: flex; align-items: center; }

.ai-logo {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  margin-right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-info { flex: 1; min-width: 0; }

.header-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 2px;
}

.header-subtitle {
  display: block;
  color: var(--text-muted);
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-bar { margin-top: 10px; }

.model-scroll {
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.model-scroll::-webkit-scrollbar { display: none; }

.model-options {
  display: inline-flex;
  gap: 6px;
  padding-bottom: 2px;
}

.model-option {
  flex-shrink: 0;
  min-width: 98px;
  padding: 7px 8px;
  border-radius: 6px;
  background: var(--field-bg);
  border: 1px solid var(--line-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.model-option-active {
  background: rgba(0, 179, 164, 0.09);
  border-color: rgba(0, 179, 164, 0.28);
}

.model-name {
  color: var(--text-main);
  font-size: 11.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-tag {
  flex-shrink: 0;
  margin-left: 4px;
  color: var(--brand);
  font-size: 9px;
}

.knowledge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 0 2px;
}

.knowledge-info { flex: 1; min-width: 0; padding-right: 8px; }

.knowledge-title {
  display: block;
  color: var(--text-secondary);
  font-size: 11.5px;
}

.knowledge-desc {
  display: block;
  color: var(--text-muted);
  font-size: 9.5px;
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.knowledge-row .switch { width: 40px; height: 24px; border-radius: 12px; }
.knowledge-row .switch::after { width: 20px; height: 20px; }
.knowledge-row .switch.switch-on::after { transform: translateX(16px); }

.demo-tip {
  margin-top: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  background: #fff7e8;
  color: #ad4e00;
  font-size: 10px;
}

.offline-tip {
  flex-shrink: 0;
  margin: 8px 12px 0;
  padding: 8px 10px;
  border: 1px solid var(--line-color);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.6;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.offline-link {
  flex-shrink: 0;
  margin-left: 8px;
  color: var(--brand);
}

.message-scroll {
  flex: 1;
  min-height: 0;
  padding: 12px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.welcome-card {
  padding: 11px;
  margin-bottom: 14px;
  border-radius: 6px;
  background: var(--field-bg);
  border: 1px solid var(--line-color);
}

.welcome-title {
  display: block;
  color: var(--brand);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.welcome-text {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.8;
}

.message-row {
  display: flex;
  align-items: flex-start;
  margin-bottom: 12px;
}

.message-row-user { justify-content: flex-end; }

.avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line-color);
  border-radius: 50%;
  background: var(--card-bg);
  color: var(--brand);
  margin-right: 8px;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bubble {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.8;
  word-break: break-word;
}

.bubble-assistant {
  background: var(--card-bg);
  color: var(--text-main);
  border: 1px solid var(--line-color);
  border-top-left-radius: 2px;
}

.bubble-user {
  background: var(--brand-light);
  color: #fff;
  border-top-right-radius: 2px;
}

.message-text { white-space: pre-wrap; }

.message-attachments { margin-bottom: 6px; }

.message-image {
  width: 120px;
  height: 120px;
  border-radius: 6px;
  margin: 2px;
  object-fit: cover;
}

.message-file {
  display: block;
  max-width: 180px;
  padding: 5px 7px;
  margin: 3px 0;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.typing {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  font-size: 12px;
}

.typing-dots {
  color: var(--brand-light);
  margin-right: 4px;
  letter-spacing: 2px;
}

.scroll-bottom { height: 6px; }

.suggestion-area { flex-shrink: 0; padding: 0 12px 4px; }

.suggestion-scroll {
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.suggestion-scroll::-webkit-scrollbar { display: none; }

.suggestions {
  display: inline-flex;
  padding: 0 4px;
}

.suggestion {
  min-height: 28px;
  padding: 0 10px;
  margin-right: 5px;
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 11px;
  border: 1px solid var(--line-color);
  display: flex;
  align-items: center;
}

.pending-area {
  flex-shrink: 0;
  padding: 4px 16px;
  background: var(--card-bg);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.pending-area::-webkit-scrollbar { display: none; }

.pending-list { display: inline-flex; }

.pending-item {
  position: relative;
  width: 56px;
  height: 56px;
  margin-right: 8px;
  border-radius: 7px;
  background: var(--field-bg);
}

.pending-image {
  width: 56px;
  height: 56px;
  border-radius: 7px;
  object-fit: cover;
}

.pending-file {
  width: 56px;
  height: 56px;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.pending-file-type {
  color: var(--brand);
  font-size: 10px;
  margin-bottom: 3px;
}

.pending-file-name {
  width: 100%;
  color: var(--text-secondary);
  font-size: 8.5px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pending-remove {
  position: absolute;
  right: -4px;
  top: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #4e5969;
  color: #fff;
  font-size: 12px;
  line-height: 15px;
  text-align: center;
}

.chat-text-panel {
  flex-shrink: 0;
  margin: 0 12px 6px;
  padding: 10px;
  border: 1px solid var(--line-color);
  border-radius: 6px;
  background: var(--card-bg);
}

.chat-text-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-main);
  font-size: 12px;
  margin-bottom: 6px;
}

.chat-text-cancel { color: var(--text-muted); font-size: 11px; }

.chat-text-input {
  width: 100%;
  height: 90px;
  padding: 8px;
  border-radius: 6px;
  background: var(--field-bg);
  color: var(--text-main);
  font-size: 12px;
  resize: none;
  border: none;
}

.chat-text-add {
  height: 32px;
  margin-top: 6px;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.composer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: var(--card-bg);
  border-top: 1px solid var(--line-color);
}

.attach-button {
  flex-shrink: 0;
  width: 32px;
  height: 40px;
  color: var(--text-secondary);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.input-wrap {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 10px;
  border-radius: 6px;
  background: var(--field-bg);
  display: flex;
  align-items: center;
}

.input-wrap input {
  width: 100%;
  color: var(--text-main);
  font-size: 13px;
  background: none;
}

.input-wrap input::placeholder { color: var(--text-muted); }

.send-button {
  flex-shrink: 0;
  width: 44px;
  height: 40px;
  margin-left: 6px;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-size: 11.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.send-disabled { background: var(--skip-1); }

/* ============================ 我的 ============================ */

.me {
  min-height: 100%;
  padding: 14px 14px calc(28px + var(--safe-bottom));
  background: var(--page-bg);
}

.profile {
  display: flex;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line-color);
  border-radius: 8px;
  background: var(--card-bg);
}

.avatar-wrap {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--brand);
  margin-right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.avatar-text { color: #fff; font-size: 19px; font-weight: 500; }

.avatar-image {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: block;
  object-fit: cover;
}

.profile-info { flex: 1; min-width: 0; }

.profile-name {
  display: block;
  color: var(--text-main);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-sub {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.provider-tag {
  flex-shrink: 0;
  margin-left: 6px;
  color: var(--text-muted);
  font-size: 11px;
}

.stats-card {
  display: flex;
  align-items: center;
  margin-top: 10px;
  padding: 14px 0;
  border: 1px solid var(--line-color);
  border-radius: 8px;
  background: var(--card-bg);
}

.group { margin-top: 14px; }

.group-title {
  display: block;
  padding: 0 2px;
  margin-bottom: 5px;
  color: var(--text-secondary);
  font-size: 12px;
}

.group-card {
  border: 1px solid var(--line-color);
  border-radius: 8px;
  background: var(--card-bg);
  padding: 0 12px;
}

.row {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line-color);
}

.row:last-child { border-bottom: none; }

.row-main {
  flex: 1;
  min-width: 0;
  padding: 10px 8px 10px 0;
}

.row-label { color: var(--text-main); font-size: 14px; }

.row-desc {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
  margin-top: 3px;
  word-break: break-all;
}

.row-value-wrap {
  flex-shrink: 0;
  max-width: 45%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.row-value {
  color: var(--text-muted);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

.row-arrow { margin-left: 4px; color: var(--text-muted); font-size: 15px; }

.connection-form { padding: 12px 0; border-bottom: 1px solid var(--line-color); }

.connection-form .ha-input {
  height: 40px;
  margin-top: 10px;
  padding: 0 9px;
  border-radius: 6px;
  font-size: 12.5px;
}

.connection-form .connect-button {
  height: 40px;
  width: 100%;
  margin-top: 8px;
  border-radius: 6px;
  font-size: 13.5px;
}

.connect-status {
  display: block;
  margin-top: 7px;
  color: var(--text-secondary);
  font-size: 11.5px;
  line-height: 1.6;
}

.appearance-card { padding-top: 12px; padding-bottom: 12px; }

.appearance-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.theme-options {
  display: flex;
  padding: 2.5px;
  border-radius: 6px;
  background: var(--field-bg);
}

.theme-option {
  flex: 1;
  min-height: 32px;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-option-active {
  background: var(--card-bg);
  color: var(--brand);
  font-weight: 500;
}

.tencent-ok { color: var(--brand); }

.meeting-card { padding-top: 10px; padding-bottom: 10px; }

.meeting-form {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
}

.meeting-input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 9px;
  border-radius: 6px;
  background: var(--field-bg);
  color: var(--text-main);
  font-size: 12px;
}

.meeting-input::placeholder { color: var(--text-muted); }

.meeting-btn {
  flex-shrink: 0;
  padding: 0 11px;
  height: 36px;
  line-height: 36px;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
}

.meeting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-top: 1px solid var(--line-color);
}

.meeting-empty { padding: 8px 0; }

.logout {
  margin-top: 20px;
  height: 44px;
  border: 1px solid var(--line-color);
  border-radius: 6px;
  background: var(--card-bg);
  color: #f53f3f;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================ 添加设备 ============================ */

.add-device {
  min-height: 100%;
  padding: 14px 14px calc(28px + var(--safe-bottom));
  background: var(--page-bg);
}

.add-device .hero { margin-bottom: 12px; padding: 4px 2px 0; background: none; border: none; }

.hero-title {
  display: block;
  color: var(--text-main);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 3px;
}

.hero-subtitle { color: var(--text-muted); font-size: 12px; }

.notice {
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #fff7e8;
  color: #ad4e00;
  font-size: 11.5px;
}

.add-device .card { margin-bottom: 10px; padding: 13px; }

.scan-card { min-height: 90px; }

.scan-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.scan-heading-info { flex: 1; }

.card-title {
  display: block;
  color: var(--text-main);
  font-size: 14.5px;
  font-weight: 600;
  margin-bottom: 3px;
}

.card-tip {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  margin-bottom: 11px;
  line-height: 1.6;
}

.scanning-ring {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(0, 179, 164, 0.16);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: scan-rotate 0.9s linear infinite;
}

@keyframes scan-rotate {
  from { transform: rotate(0); }
  to { transform: rotate(360deg); }
}

.device-list { margin-top: 4px; border-top: 1px solid var(--line-color); }

.scan-item {
  display: flex;
  align-items: center;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line-color);
}

.scan-item:last-child { border-bottom: none; }

.scan-item-active { background: rgba(0, 179, 164, 0.08); }

.scan-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--field-bg);
  color: var(--brand);
  font-size: 14px;
  margin-right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scan-info { flex: 1; min-width: 0; }

.scan-name {
  display: block;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scan-host { color: var(--text-muted); font-size: 11px; }

.scan-pick {
  flex-shrink: 0;
  margin-left: 6px;
  color: var(--brand);
  font-size: 11.5px;
}

.scan-empty {
  margin-top: 10px;
  padding: 12px;
  border-radius: 6px;
  background: var(--field-bg);
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

.retry-button { margin-top: 8px; color: var(--brand); font-size: 12px; }

.submit {
  height: 42px;
  margin-top: 4px;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cancel-button {
  margin-top: 10px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

.add-device .status {
  padding: 9px 11px;
  border: 1px solid var(--line-color);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.7;
}

/* ============================ 浮层 ============================ */

.toast {
  position: fixed;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%) scale(0.96);
  max-width: 76%;
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 90;
  word-break: break-word;
}

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

.loading-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
}

.loading-mask[hidden] { display: none; }

.loading-box {
  min-width: 108px;
  padding: 16px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.74);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.loading-ring {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-top-color: #fff;
  border-radius: 50%;
  animation: scan-rotate 0.8s linear infinite;
}

.loading-text { color: #fff; font-size: 12px; }

.sheet-mask,
.dialog-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  z-index: 85;
  display: flex;
  justify-content: center;
}

.sheet-mask[hidden],
.dialog-mask[hidden] { display: none; }

.sheet-mask { align-items: flex-end; }

.sheet {
  width: 100%;
  max-width: 520px;
  padding-bottom: var(--safe-bottom);
  border-radius: 12px 12px 0 0;
  background: var(--card-bg);
  overflow: hidden;
}

.sheet-item {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  font-size: 15px;
  border-bottom: 1px solid var(--line-color);
}

.sheet-item:last-child { border-bottom: none; }

.sheet-cancel {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 15px;
    border-top: 6px solid var(--page-bg);
}

.dialog-mask { align-items: center; }

.dialog {
  width: 78%;
  max-width: 320px;
  border-radius: 12px;
  background: var(--card-bg);
  overflow: hidden;
}

.dialog-title {
  padding: 18px 18px 0;
  color: var(--text-main);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
}

.dialog-title:empty { display: none; }

.dialog-body {
  padding: 10px 18px 18px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.7;
  text-align: center;
  word-break: break-word;
}

.dialog-actions { display: flex; border-top: 1px solid var(--line-color); }

.dialog-btn {
  flex: 1;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  font-size: 15px;
}

.dialog-btn + .dialog-btn { border-left: 1px solid var(--line-color); }

.dialog-btn-danger { color: #f53f3f; }

.dialog-actions.single .dialog-btn { border-left: none; }

/* ============================ 窄屏微调 ============================ */

/* ============================ 补充样式（软件版重写新增） ============================ */

.nav-add {
  width: 28px;
  height: 28px;
  border-radius: 14px;
  background: var(--field-bg);
  color: var(--brand);
  font-size: 18px;
  line-height: 26px;
  text-align: center;
}

.topbar-scrolled { box-shadow: 0 8px 24px -18px rgba(10, 35, 30, .55); }

.scan-desc {
  display: block;
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.6;
  margin-top: 4px;
  text-align: center;
}

.message-file {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 7px 9px;
  border-radius: 6px;
  background: var(--field-bg);
  max-width: 100%;
}

.pending-file {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.file-type {
  flex-shrink: 0;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--brand);
  color: #fff;
  font-size: 9.5px;
  line-height: 14px;
}

.file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-main);
  font-size: 12px;
}

.submit-disabled { background: var(--skip-1); }

@media (max-width: 340px) {
  .hero,
  .content,
  .scenes,
  .me,
  .add-device { padding-left: 10px; padding-right: 10px; }
  .hero-title { font-size: 16px; }
  .ai .header { padding-left: 10px; padding-right: 10px; }
  .model-option { padding: 6px 5px; min-width: 84px; }
  .model-name { font-size: 10px; }
  .model-tag { display: none; }
  .message-scroll { padding-left: 10px; padding-right: 10px; }
  .composer { padding-left: 6px; padding-right: 6px; }
  .attach-button { width: 28px; }
  .provider-tag { display: none; }
  .row-value-wrap { max-width: 38%; }
}


/* ================= 登录页：邮箱主位 + 第三方图标 ================= */

.login-brand {
  text-align: center;
  margin: 8px 0 22px;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 6px 16px rgba(0, 138, 127, 0.22);
}

.login-brand .title {
  margin-top: 12px;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
}

.login-brand .status {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

.panel-tag {
  font-size: 11px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 6px;
  color: var(--brand);
  background: rgba(0, 138, 127, 0.12);
}

.code-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.code-row .field {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

.code-btn {
  flex: 0 0 auto;
  height: 44px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--brand);
  color: var(--brand);
  font-size: 13px;
  white-space: nowrap;
}

.code-btn.code-btn-busy {
  opacity: 0.5;
  border-color: var(--text-muted);
  color: var(--text-muted);
}

.primary-button {
  margin-top: 14px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.primary-button.primary-button-busy {
  opacity: 0.6;
}

.more {
  margin-top: 18px;
}

.more-title {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.provider-row {
  display: flex;
  gap: 10px;
}

.provider {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  padding: 12px 6px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border-radius: 14px;
  background: var(--card-bg);
  border: 1px solid var(--line-color);
  cursor: pointer;
}

.provider:active {
  transform: scale(0.98);
}

.provider-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  overflow: hidden;
}

.provider-icon svg {
  display: block;
}

.provider-icon-github {
  color: #24292f;
  background: #fff;
  border: 1px solid var(--line-color);
}

body.theme-dark .provider-icon-github {
  color: #fff;
  background: #0d1117;
  border-color: #30363d;
}

.provider-icon-gitee {
  color: #c71d23;
}

.provider-icon-weibo {
  color: #e6162d;
}

.provider-name {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.provider-soon {
  opacity: 0.5;
}

.provider-soon-tag {
  position: absolute;
  top: 5px;
  right: 6px;
  font-size: 9px;
  line-height: 1;
  color: var(--text-muted);
  background: var(--field-bg);
  padding: 2px 4px;
  border-radius: 4px;
}

.login .more .device-tip {
  display: block;
  margin-top: 10px;
}

.login .device-panel {
  margin-top: 16px;
}

@media (max-width: 340px) {
  .provider-name { font-size: 11px; }
  .code-btn { padding: 0 10px; font-size: 12px; }
}

/* ===== 登录页 v3：垂直居中 / 无小字 / 验证码按钮实心 / 授权浮层居中 ===== */
.view-login { padding: 0; background: var(--page-bg); overflow-y: auto; }
.view-login.active { display: flex; align-items: center; justify-content: center; }
.login-shell { width: 100%; min-height: 100%; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--safe-top) + 40px) 22px calc(40px + var(--safe-bottom)); }
.login-card { width: 100%; max-width: 380px; }

.login-brand { text-align: center; margin: 0 0 30px; }
.login-brand .brand-badge { display: inline-flex; align-items: center; justify-content: center;
  width: 58px; height: 58px; border-radius: 17px; background: linear-gradient(135deg, var(--brand), var(--brand-light));
  color: #fff; font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.login-brand .brand-name { margin-top: 13px; font-size: 22px; font-weight: 700; color: var(--text-main); letter-spacing: .5px; }

.field-group { display: block; }
.auth-field { width: 100%; height: 48px; box-sizing: border-box; padding: 0 14px;
  border: 1px solid var(--line-color); border-radius: 12px; background: var(--card-bg);
  color: var(--text-main); font-size: 15px; font-family: inherit; outline: none;
  -webkit-appearance: none; appearance: none; }
.auth-field::placeholder { color: var(--text-muted); }
.auth-field:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0, 138, 127, .10); }

.code-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.code-row .auth-field { flex: 1 1 auto; min-width: 0; }
.code-btn { flex: 0 0 auto; height: 48px; padding: 0 16px; border: 1px solid var(--brand);
  border-radius: 12px; background: var(--brand); color: #fff; font-size: 14px; font-weight: 600;
  white-space: nowrap; font-family: inherit; }
.code-btn:active { opacity: .85; }
.code-btn.code-btn-busy, .code-btn[disabled] { background: var(--skip-1); border-color: var(--skip-1); color: #fff; opacity: .9; }

.view-login .primary-button { width: 100%; margin-top: 16px; height: 48px; border: 0; border-radius: 12px;
  background: var(--brand); color: #fff; font-size: 16px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; font-family: inherit; }
.view-login .primary-button.primary-button-busy { opacity: .6; }

.agree-row { display: flex; align-items: flex-start; gap: 8px; margin-top: 16px; cursor: pointer; }
.agree-check { width: 16px; height: 16px; margin: 2px 0 0; flex: 0 0 auto; accent-color: var(--brand); }
.agree-text { font-size: 12px; line-height: 1.6; color: var(--text-secondary); }
.agree-link { color: var(--brand); }
.agreement-card { max-width: 360px; text-align: left; }
.agreement-card .oauth-card-title { text-align: center; }
.agreement-body { max-height: 46vh; overflow: auto; margin: 12px 0 16px;
  font-size: 13px; line-height: 1.8; color: var(--text-secondary); white-space: pre-wrap; }

.provider-block { margin-top: 30px; }
.provider-title { text-align: center; color: var(--text-secondary); font-size: 13px; margin-bottom: 15px; }
.view-login .provider-row { display: flex; align-items: flex-start; justify-content: center; gap: 26px; }
.view-login .provider { display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 0; border: 0; background: transparent; font-family: inherit; }
.view-login .provider-icon { display: flex; align-items: center; justify-content: center;
  width: 50px; height: 50px; border-radius: 15px; border: 1px solid var(--line-color);
  background: var(--card-bg); color: var(--text-main); }
.view-login .provider:active .provider-icon { background: var(--field-bg); }
.view-login .provider-icon-gitee { color: #c71d23; }
.view-login .provider-icon-weibo { color: #e6162d; }
.view-login .provider-name { font-size: 12px; color: var(--text-secondary); line-height: 1; }
.view-login .provider-soon { opacity: .4; }

.view-login .status { margin-top: 16px; text-align: center; font-size: 13px; line-height: 1.6; color: var(--text-secondary); }
.view-login .demo-link { margin-top: 24px; text-align: center; font-size: 14px; color: var(--text-secondary); }
.view-login .demo-link:active { opacity: .6; }
.view-login .device-tip { display: none !important; }

.oauth-mask { position: fixed; inset: 0; z-index: 900; padding: 26px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .42); }
.oauth-mask[hidden] { display: none; }
.oauth-card { width: 100%; max-width: 322px; box-sizing: border-box; padding: 24px 20px 18px;
  border-radius: 16px; background: var(--card-bg); text-align: center;
  box-shadow: 0 20px 52px rgba(0, 0, 0, .20); }
.oauth-card-title { font-size: 15px; font-weight: 600; color: var(--text-main); }
.oauth-card-code { margin: 16px 0 20px; font-size: 25px; font-weight: 700; letter-spacing: 5px;
  color: var(--brand); font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }
.oauth-card-actions { display: flex; flex-direction: column; gap: 10px; }
.mini-button { height: 42px; border: 1px solid var(--brand); border-radius: 11px;
  background: var(--brand); color: #fff; font-size: 14px; font-weight: 600; font-family: inherit; }
.mini-button:active { opacity: .85; }
.mini-button-ghost { background: var(--field-bg); border-color: var(--line-color); color: var(--text-secondary); }
.oauth-card .link-button { margin-top: 15px; font-size: 14px; color: var(--text-muted); }


/* ============================================================
 * 多端自适应层（v3）：平板 / 桌面 / 超宽屏
 * 手机竖屏保持原样；平板加宽居中；桌面切换为侧边导航 + 多列内容
 * ============================================================ */

/* ---------- 平板（>=768px）---------- */
@media (min-width: 768px) {
  #app { max-width: 760px; }
  body { font-size: 15px; }
  .content { padding: 16px 20px 0; }
  .hero { padding: 18px 20px; }
  .scenes { padding: 18px 20px calc(28px + var(--safe-bottom)); }
  .login-card { max-width: 420px; }
  .grid-item { width: 32%; }
  .scene-item { width: 32%; }
}

/* ---------- 桌面（>=1024px）：侧边导航 + 多列 ---------- */
@media (min-width: 1024px) {
  #app { max-width: none; }

  .view-app {
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .view-app .topbar {
    grid-column: 2;
    grid-row: 1;
    padding-left: 32px;
    padding-right: 32px;
    min-height: 56px;
  }
  .view-app .nav-title { text-align: left; font-size: 17px; }

  .view-app .page-host { grid-column: 2; grid-row: 2; }

  .view-app .tabbar {
    grid-column: 1;
    grid-row: 1 / span 2;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 6px;
    padding: 20px 14px;
    border-top: none;
    border-right: 1px solid var(--line-color);
  }
  .view-app .tab-item {
    flex: none;
    height: 46px;
    justify-content: flex-start;
    padding: 0 16px;
    border-radius: 10px;
    font-size: 14.5px;
    transition: background .15s ease;
  }
  .view-app .tab-item:hover { background: var(--field-bg); }
  .view-app .tab-item-active {
    background: rgba(0, 138, 127, .12);
    box-shadow: inset 3px 0 0 var(--brand);
    font-weight: 600;
  }
  body.theme-dark .view-app .tab-item-active {
    background: rgba(0, 194, 178, .18);
    box-shadow: inset 3px 0 0 var(--brand);
  }

  /* 内容区限宽居中，避免超宽屏单行过长 */
  .page-host > .home,
  .page-host > .scenes,
  .page-host > .me,
  .page-host > .add-device { max-width: 1120px; margin: 0 auto; }

  .content { padding: 22px 32px 0; }
  .hero { padding: 24px 32px; }
  .scenes { padding: 22px 32px calc(32px + var(--safe-bottom)); }

  /* 设备 / 场景卡片改为自适应多列 */
  .device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 12px;
    justify-content: initial;
  }
  .grid-item { width: auto; margin-bottom: 0; }

  .scene-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    justify-content: initial;
  }
  .scene-item { width: auto; margin-bottom: 0; }

  /* AI 页输入区限宽 */
  .page-host.page-ai > * { max-width: 1120px; margin-left: auto; margin-right: auto; width: 100%; }

  .login-card { max-width: 440px; }
}

/* ---------- 超宽屏（>=1600px）---------- */
@media (min-width: 1600px) {
  .page-host > .home,
  .page-host > .scenes,
  .page-host > .me,
  .page-host > .add-device { max-width: 1280px; }
  .device-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}

/* ============================================================
 * 深色模式修正：提示条 / 品牌色 / 阴影 / 开关
 * ============================================================ */
body.theme-dark {
  --brand: #00c2b2;
  --brand-light: #33d6c8;
  --skip-1: #4a5056;
  /* 深色下弱化文字提亮，保证正文/导航可读性 */
  --text-secondary: #d2d8dd;
  --text-muted: #a8b0b8;
  --line-color: #34383c;
}

body.theme-dark .demo-banner,
body.theme-dark .demo-tip,
body.theme-dark .notice {
  background: rgba(255, 176, 102, .14);
  color: #ffb066;
}

body.theme-dark .switch::after { background: #e8ebee; }
body.theme-dark .topbar-scrolled { box-shadow: 0 1px 6px rgba(0, 0, 0, .5); }
body.theme-dark .card,
body.theme-dark .device-card,
body.theme-dark .scene-card { box-shadow: none; }

/* ============================================================
 * 视觉升级层：与官网同一套令牌（品牌渐变 / 圆角 / 柔和投影）
 * 仅覆盖外观，不改变既有布局与交互
 * ============================================================ */

.home {
  background:
    radial-gradient(120% 240px at 50% 0%, rgba(0, 179, 164, .08), transparent 72%),
    var(--page-bg);
}

.view-login {
  background:
    radial-gradient(90% 320px at 50% 0%, rgba(0, 179, 164, .12), transparent 72%),
    var(--page-bg);
}

.card,
.overview,
.device-card,
.scene-card,
.automation-card,
.empty-card,
.stats-card,
.group-card,
.more-body,
.panel,
.meeting-card {
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.section-title,
.page-title,
.hero-title { letter-spacing: -.02em; }

.connect-button,
.wx-button,
.primary-button,
.mini-button,
.meeting-btn,
.submit {
  border-radius: 12px;
  background: linear-gradient(180deg, var(--brand), var(--brand-deep));
  box-shadow: 0 8px 18px -10px var(--brand-glow);
  transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease;
}

.connect-button:active,
.wx-button:active,
.primary-button:active,
.mini-button:active,
.meeting-btn:active,
.submit:active { transform: translateY(1px) scale(.99); }

.add-button {
  border-radius: 11px;
  background: linear-gradient(140deg, var(--brand-light), var(--brand) 60%, var(--brand-deep));
  box-shadow: 0 8px 18px -10px var(--brand-glow);
}

.icon-wrap,
.scene-icon { border-radius: 10px; }

.device-on {
  background: var(--brand-soft);
  border-color: var(--brand-glow);
}

.auth-field { background: var(--field-bg); }

.login-card {
  padding: 26px 22px 22px;
  border: 1px solid var(--line-color);
  border-radius: var(--radius-lg);
  background: var(--card-bg);
  box-shadow: var(--shadow-float), var(--shadow-card);
}

.composer {
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow-card);
}

.sheet { border-radius: 20px 20px 0 0; }
.dialog,
.oauth-card { border-radius: var(--radius-lg); box-shadow: var(--shadow-float); }
.toast { border-radius: 12px; box-shadow: var(--shadow-float); }

body.theme-dark .home {
  background:
    radial-gradient(120% 240px at 50% 0%, rgba(55, 217, 199, .10), transparent 72%),
    var(--page-bg);
}

body.theme-dark .view-login {
  background:
    radial-gradient(90% 320px at 50% 0%, rgba(55, 217, 199, .12), transparent 72%),
    var(--page-bg);
}

@media (min-width: 768px) {
  .device-card,
  .scene-card,
  .card { transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
  .device-card:hover,
  .scene-card:hover,
  .card:hover {
    transform: translateY(-2px);
    border-color: var(--brand-glow);
    box-shadow: var(--shadow-float);
  }
}
