/* ==========================================================
   桌面智能灵动岛 — 网页端样式
   配色：暖光日记风 | 布局：左固定 + 右自适应双栏
   ========================================================== */

/* ========== CSS 变量 ========== */
:root {
  --primary: #F97316;
  --primary-light: #FB923C;
  --primary-dark: #EA580C;
  --warm-yellow: #FBBF24;
  --soft-coral: #FB7185;
  --success: #34D399;
  --danger: #F87171;
  --bg: #FFFBF5;
  --card: #FFFFFF;
  --warm-block: #FEF3C7;
  --text: #44403C;
  --text-secondary: #78716C;
  --text-tertiary: #A8A29E;
  --border: #F5F0EB;
  --shadow-card: 0 2px 8px rgba(249, 115, 22, 0.06);
  --shadow-float: 0 8px 32px rgba(249, 115, 22, 0.12);
  --shadow-modal: 0 16px 48px rgba(0, 0, 0, 0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  --sidebar-width: 380px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== Reset & Base ========== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
               'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
}

/* ========== 开幕动画 ========== */
.opening-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
.opening-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.opening-video {
  width: min(60vw, 60vh, 600px);
  height: min(60vw, 60vh, 600px);
  object-fit: contain;
  border-radius: var(--radius-lg);
}

.opening-skip {
  position: fixed;
  bottom: 40px;
  right: 40px;
  padding: 10px 24px;
  border: 2px solid var(--primary-light);
  background: var(--card);
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  z-index: 1000;
}
.opening-skip:hover {
  background: var(--primary);
  color: #FFF;
  border-color: var(--primary);
}

/* ========== 顶部栏 ========== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 52px;
  padding: 0 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.topbar-logo {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--text-secondary);
}

.topbar-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary);
  transition: background var(--transition);
}
.topbar-status-dot.online {
  background: var(--success);
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.5);
}
.topbar-status-dot.offline {
  background: var(--text-tertiary);
}

/* ========== 主布局：双栏 ========== */
.main-layout {
  display: flex;
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 24px;
  gap: 20px;
  /* 固定撑满视口（减掉顶部栏），各子项自动等高拉伸 */
  height: calc(100vh - 52px);
}

/* ========== 左侧栏 ========== */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  /* flex 撑满同行面板的高度 */
  overflow-y: auto;
}

/* ---- 宠物容器 ---- */
.pet-container {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0 auto 16px;
  cursor: pointer;
  user-select: none;
}

/* 宠物视频 */
.pet-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  z-index: 1;
  background: radial-gradient(circle at 40% 35%, #FFFBF5 0%, #FEF3C7 60%, #FDE68A 100%);
  transition: opacity 0.25s ease, transform 0.06s ease;
}

/* 外层光环（保留） */
.pet-container::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    var(--primary-light),
    var(--warm-yellow),
    var(--soft-coral),
    var(--primary-light)
  );
  opacity: 0.3;
  animation: pet-aura-rotate 4s linear infinite;
}

/* 火花粒子 */
.pet-sparkle {
  position: absolute;
  font-size: 16px;
  z-index: 2;
  pointer-events: none;
  animation: sparkle-float 2.5s ease-in-out infinite;
}
.sparkle-1 { top: 8px;  left: 28px;  animation-delay: 0s; }
.sparkle-2 { top: 18px; right: 24px;  animation-delay: 0.6s; }
.sparkle-3 { bottom: 20px; left: 16px;  animation-delay: 1.2s; }
.sparkle-4 { bottom: 12px; right: 20px; animation-delay: 1.8s; }

@keyframes sparkle-float {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.7; }
  50%      { transform: translateY(-10px) scale(1.3); opacity: 1; }
}

@keyframes pet-aura-rotate {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 阴影 */
.pet-shadow {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 90px;
  height: 10px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 50%;
  animation: shadow-pulse 3s ease-in-out infinite;
}

@keyframes shadow-pulse {
  0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.6; }
  50%      { transform: translateX(-50%) scale(0.75); opacity: 0.35; }
}

/* 状态标签 */
.pet-status-label {
  display: inline-block;
  background: var(--warm-block);
  color: var(--primary);
  padding: 5px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 20px;
  transition: all var(--transition);
}

/* ---- 三指标卡 ---- */
.indicator-row {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-bottom: 14px;
}

.indicator-card {
  flex: 1;
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 14px 8px;
  text-align: center;
  transition: transform var(--transition), box-shadow var(--transition);
}
.indicator-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.indicator-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}
.indicator-title {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ---- 设备信息 ---- */
.device-info-card {
  width: 100%;
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text-secondary);
}
.device-info-row {
  display: flex;
  justify-content: space-between;
}
.device-info-row:first-child {
  margin-bottom: 4px;
}

/* ========== 右侧面板 ========== */
.panel {
  flex: 1;
  min-width: 0;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- Tab 导航栏 ---- */
.tab-bar {
  display: flex;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 4px 12px;
  gap: 4px;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  font-family: inherit;
}
.tab-btn:hover {
  background: rgba(249, 115, 22, 0.06);
  color: var(--primary);
}
.tab-btn.active {
  background: var(--card);
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
}

.tab-badge {
  background: var(--danger);
  color: #FFF;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* ---- Tab 内容区 ---- */
.tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.tab-page {
  display: none;
  height: 100%;
}
.tab-page.active {
  display: block;
  height: auto;
  animation: tab-enter 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.tab-page.exiting {
  display: block !important;
  position: absolute;
  width: 100%;
  animation: tab-leave 0.18s cubic-bezier(0.55, 0.06, 0.68, 0.19);
}

@keyframes tab-enter {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes tab-leave {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(-24px); }
}

/* ========== 通用 Section ========== */
.section {
  margin-bottom: 28px;
}
.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
}

/* ========== DDL 提醒列表 ========== */
.ddl-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ddl-item {
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all var(--transition);
  cursor: pointer;
}
.ddl-item:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow-card);
}

.ddl-priority-bar {
  width: 4px;
  height: 42px;
  border-radius: 2px;
  flex-shrink: 0;
}
.ddl-priority-bar.high   { background: var(--danger); }
.ddl-priority-bar.medium { background: var(--warm-yellow); }
.ddl-priority-bar.low    { background: var(--text-tertiary); }

.ddl-priority-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.ddl-body {
  flex: 1;
  min-width: 0;
}
.ddl-title {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ddl-meta {
  font-size: 12px;
  margin-top: 2px;
}
.ddl-meta.urgent { color: var(--danger); font-weight: 500; }
.ddl-meta.soon   { color: #B45309; }
.ddl-meta.normal { color: var(--text-secondary); }

.ddl-badge {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}
.ddl-badge.high {
  background: #FEF2F2;
  color: var(--danger);
}
.ddl-badge.medium {
  background: #FEFCE8;
  color: #B45309;
}
.ddl-badge.low {
  background: #F5F0EB;
  color: var(--text-secondary);
}

/* ========== 快捷操作宫格 ========== */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.quick-action-card {
  background: linear-gradient(135deg, var(--bg), #FFF7ED);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.quick-action-card:hover {
  border-color: var(--primary-light);
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.10);
  transform: translateY(-2px);
}

.qa-icon {
  font-size: 28px;
  display: block;
  margin-bottom: 6px;
}
.qa-label {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

/* ========== 任务列表 ========== */
.tasks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.filter-bar {
  display: flex;
  gap: 6px;
}
.filter-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.filter-btn:hover {
  border-color: var(--primary-light);
  color: var(--primary);
}
.filter-btn.active {
  background: var(--primary);
  color: #FFF;
  border-color: var(--primary);
}

.btn-add {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #FFF;
  border: none;
  font-size: 20px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.btn-add:hover {
  background: var(--primary-dark);
  transform: rotate(90deg);
}

/* 任务列表 */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-item {
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: all var(--transition);
  position: relative;
}
/* 新建任务滑入 */
.task-item.task-enter {
  animation: task-slide-in 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}
/* 删除任务滑出 */
.task-item.task-leave {
  animation: task-slide-out 0.25s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards;
  pointer-events: none;
}

@keyframes task-slide-in {
  from { opacity: 0; transform: translateY(-16px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes task-slide-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(40px); }
}
.task-item:hover {
  box-shadow: var(--shadow-card);
}
.task-item.done {
  opacity: 0.55;
}
.task-item.done .task-title {
  text-decoration: line-through;
}
/* 完成/取消完成弹跳 */
.task-item.task-toggle {
  animation: task-toggle-bounce 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}
@keyframes task-toggle-bounce {
  0%   { transform: scale(1); }
  30%  { transform: scale(0.97); }
  60%  { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.task-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  margin-top: 2px;
  font-size: 12px;
  color: transparent;
}
.task-checkbox:hover {
  border-color: var(--success);
}
.task-item.done .task-checkbox {
  background: var(--success);
  border-color: var(--success);
  color: #FFF;
}

.task-body {
  flex: 1;
  min-width: 0;
}
.task-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.task-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.task-priority-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
}
.task-priority-tag.high   { background: #FEF2F2; color: var(--danger); }
.task-priority-tag.medium { background: #FEFCE8; color: #B45309; }
.task-priority-tag.low    { background: #F5F0EB; color: var(--text-secondary); }

.task-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.task-action-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 14px;
  transition: all var(--transition);
}
.task-action-btn:hover {
  background: #FEF2F2;
  color: var(--danger);
}
.task-action-btn.edit:hover {
  background: var(--bg);
  color: var(--primary);
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}
.empty-icon {
  font-size: 48px;
  margin-bottom: 10px;
}
.empty-state p {
  font-size: 14px;
}

/* 进度条 */
.task-progress {
  padding: 8px 0;
}
.progress-text {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-light), var(--primary));
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* ========== 对话页（flexbox 使输入框贴底） ====*/
#tab-chat.active {
  display: flex !important;
  flex-direction: column;
  min-height: 0;
}
#tab-home.active {
  display: block !important;
}

.chat-mode-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-shrink: 0;
}
.chat-mode-btn {
  padding: 6px 16px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.chat-mode-btn.active {
  background: var(--warm-block);
  border-color: var(--warm-yellow);
  color: var(--text);
  font-weight: 600;
}

.chat-messages {
  flex: 1;
  display: block;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  animation: msg-in 0.3s ease;
}
.chat-msg.user {
  align-self: flex-end;
}
.chat-msg.assistant {
  align-self: flex-start;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.6;
}
.chat-msg.user .msg-bubble {
  background: var(--primary);
  color: #FFF;
  border-bottom-right-radius: 4px;
}
.chat-msg.assistant .msg-bubble {
  background: var(--bg);
  color: var(--text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.msg-time {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
  padding: 0 4px;
}
.chat-msg.user .msg-time { text-align: right; }

.msg-push-btn {
  align-self: flex-end;
  margin-top: 4px;
  padding: 3px 10px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 11px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.msg-push-btn:hover {
  background: var(--warm-block);
  color: var(--primary);
}

/* 输入栏 */
.chat-input-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  transition: border-color var(--transition);
  flex-shrink: 0;
}
.chat-input-bar:focus-within {
  border-color: var(--primary-light);
}

.chat-voice-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--warm-block);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
  position: relative;
}
.chat-voice-btn:hover {
  background: var(--warm-yellow);
  transform: scale(1.08);
}
/* 录音中脉冲环 */
.chat-voice-btn.listening {
  background: var(--danger);
  color: #FFF;
  animation: voice-pulse 1s ease-in-out infinite;
}
.chat-voice-btn.listening::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--danger);
  opacity: 0.6;
  animation: voice-ring 1.2s ease-out infinite;
}
@keyframes voice-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.4); }
  50%      { transform: scale(1.05); box-shadow: 0 0 0 8px rgba(248, 113, 113, 0); }
}
@keyframes voice-ring {
  0%   { inset: -4px; opacity: 0.6; }
  100% { inset: -12px; opacity: 0; }
}

.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--text);
  outline: none;
  font-family: inherit;
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
}
.chat-input:focus {
  outline: none;
}
.chat-input::placeholder {
  color: var(--text-tertiary);
}

.chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #FFF;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}
.chat-send-btn:hover {
  background: var(--primary-dark);
  transform: scale(1.08);
}

/* ========== 设置页 ========== */
.settings-device-card {
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.sd-icon {
  font-size: 44px;
}
.sd-info {
  flex: 1;
}
.sd-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}
.sd-status {
  font-size: 13px;
  color: var(--success);
  margin-top: 2px;
}
.sd-uptime {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.sd-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-list {
  background: var(--bg);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.settings-item:last-child {
  border-bottom: none;
}
.settings-item.clickable {
  cursor: pointer;
}
.settings-item.clickable:hover {
  background: rgba(249, 115, 22, 0.04);
}
.si-arrow {
  font-size: 18px;
  color: var(--text-tertiary);
}
.si-value {
  font-size: 13px;
  color: var(--text-secondary);
}
.si-value.success {
  color: var(--success);
}

/* ---- 设备发现列表 ---- */
#discoveredDeviceList {
  margin-top: 0;
}

.discovered-device-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin: 6px 0;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
}
.discovered-device-card:hover {
  border-color: var(--primary-light);
  box-shadow: 0 2px 12px rgba(249, 115, 22, 0.1);
  transform: translateY(-1px);
}
.discovered-device-card.bound {
  border-color: var(--success);
  background: #F0FDF4;
}

.dd-icon {
  font-size: 28px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--warm-block);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.dd-info {
  flex: 1;
  min-width: 0;
}
.dd-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.dd-id {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 400;
}
.dd-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 3px;
}
.dd-meta span {
  white-space: nowrap;
}

.dd-action {
  flex-shrink: 0;
}
.dd-bound-badge {
  font-size: 11px;
  color: var(--success);
  font-weight: 600;
  padding: 4px 10px;
  background: #DCFCE7;
  border-radius: var(--radius-full);
}

/* ---- Toggle 开关 ---- */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 12px;
  transition: all var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #FFF;
  border-radius: 50%;
  transition: all var(--transition);
}
.toggle input:checked + .toggle-slider {
  background: var(--primary);
}
.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* ========== 弹窗 ========== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open {
  display: flex;
}

.modal-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
  animation: modal-in 0.25s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}
.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover {
  background: #FEF2F2;
  color: var(--danger);
}

.modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* 表单 */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.form-input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  transition: all var(--transition);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: textfield;
}
.form-input::-webkit-inner-spin-button,
.form-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.form-input::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
}
.form-input::-webkit-datetime-edit {
  color: var(--text);
}
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}
.form-textarea {
  resize: vertical;
  min-height: 54px;
}

.priority-select {
  display: flex;
  gap: 8px;
}
.priority-option {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-full);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.priority-option:hover {
  border-color: var(--primary-light);
}
.priority-option.active {
  border-color: var(--primary);
  background: #FFF7ED;
  color: var(--primary);
  font-weight: 600;
}

/* 按钮 */
.btn {
  padding: 10px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  font-family: inherit;
}
.btn-primary {
  background: var(--primary);
  color: #FFF;
}
.btn-primary:hover {
  background: var(--primary-dark);
}
.btn-cancel {
  background: var(--bg);
  color: var(--text-secondary);
}
.btn-cancel:hover {
  background: var(--border);
}
.btn-text {
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-family: inherit;
  transition: background var(--transition);
}
.btn-text:hover {
  background: rgba(249, 115, 22, 0.08);
}
.btn-text.danger {
  color: var(--danger);
}
.btn-text.danger:hover {
  background: #FEF2F2;
}

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  top: 70px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  background: var(--text);
  color: #FFF;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-modal);
  animation: toast-in 0.35s ease, toast-out 0.35s ease 2.5s forwards;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--primary); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(100%); }
}

/* ========== 滚动条美化 ========== */
::-webkit-scrollbar {
  width: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ========== Agent 设置页 ========== */
.agent-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.subsection-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.agent-soul-editor {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: 'SF Mono', 'Consolas', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  resize: vertical;
  min-height: 240px;
  outline: none;
  transition: border-color var(--transition);
}
.agent-soul-editor:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.08);
}

.agent-soul-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}

/* 内联表单组件 */
.inline-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: 'SF Mono', 'Consolas', monospace;
  color: var(--text);
  background: var(--bg);
  outline: none;
  width: 280px;
  transition: border-color var(--transition);
}
.inline-input:focus {
  border-color: var(--primary);
}
.inline-input::placeholder {
  color: var(--text-tertiary);
}

.inline-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  outline: none;
  cursor: pointer;
}

.btn-sm {
  padding: 6px 16px;
  font-size: 13px;
}

/* Memory 列表 */
.memory-item {
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  transition: background var(--transition);
}
.memory-item:hover {
  background: #FFF7ED;
}
.memory-item-info {
  flex: 1;
  min-width: 0;
}
.memory-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.memory-item-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}
.memory-item-actions {
  display: flex;
  gap: 4px;
}

/* 思考中省略号动画 */
.thinking-dots span {
  animation: dot-blink 1.4s infinite both;
  font-size: 18px;
  font-weight: 700;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-blink {
  0%, 20% { opacity: 0; }
  50% { opacity: 1; }
  100% { opacity: 0; }
}

/* ========== 响应式（窄屏） ========== */
@media (max-width: 900px) {
  .main-layout {
    flex-direction: column;
    padding: 12px;
  }
  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 16px;
    padding: 20px;
    position: static;
    max-height: none;
  }
  .pet-container {
    width: 120px;
    height: 120px;
    margin: 0;
  }
  .pet-sparkle { display: none; }
  .indicator-row { width: auto; flex: 1; }
  .device-info-card { width: 100%; }
  .quick-actions {
    grid-template-columns: 1fr;
  }
}
