/* ===== 暗金主题(dark + gold accent,手机可读对比度已核) ===== */
:root {
  --bg: #0e0c09;
  --card: #1a1712;
  --card2: #211d15;
  --border: #2e2820;
  --text: #e8e3d5;
  --muted: #9c9480;
  --gold: #d4a847;
  --gold-soft: #8a6f2e;
  --danger: #e05c4f;
  --ok: #22c55e;
  --info: #3b82f6;
  --canceled: #9ca3af;
  --radius: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  overscroll-behavior-y: none;
}
#app { min-height: 100%; display: flex; flex-direction: column; }

.topbar {
  padding: calc(env(safe-area-inset-top) + 14px) 18px 12px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(14, 12, 9, .9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 10;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  position: relative;
  width: 30px; height: 30px; border-radius: 8px;
  background: #0a0908;
  border: 1px solid var(--gold-soft);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--gold); font-size: 15px;
}
.logo::after {
  content: ''; position: absolute;
  width: 5px; height: 5px; border-radius: 50%;
  right: 4px; bottom: 4px; background: var(--ok);
}
h1 { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.icon-btn {
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  width: 34px; height: 34px; border-radius: 10px; font-size: 16px; line-height: 1;
}

/* 底部 tab */
.tabs {
  position: sticky; top: calc(env(safe-area-inset-top) + 56px); z-index: 9;
  display: flex; gap: 6px;
  padding: 10px 16px;
  background: rgba(14, 12, 9, .96);
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1; padding: 9px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); color: var(--muted); font-size: 14px; font-weight: 600;
}
.tab.active {
  background: var(--gold); color: #161006; border-color: var(--gold);
  font-weight: 700;
}

.view { flex: 1; padding: 14px 16px calc(env(safe-area-inset-bottom) + 130px); max-width: 640px; width: 100%; margin: 0 auto; }
.view.hidden { display: none; }
.hidden { display: none !important; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.card-title { font-size: 14px; color: var(--muted); margin-bottom: 10px; font-weight: 600; }

/* 状态卡片 */
.status-line { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px rgba(34, 197, 94, .7); }
.dot.off { background: var(--danger); }
.dot.busy { background: var(--info); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.status-sub { margin-top: 6px; font-size: 12px; color: var(--muted); }

/* 指令输入 */
#rc-prompt {
  width: 100%; background: var(--card2); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; font-size: 15px; line-height: 1.5; font-family: inherit;
  resize: none; outline: none;
}
#rc-prompt:focus { border-color: var(--gold-soft); }
.rc-controls { display: flex; gap: 8px; margin-top: 10px; }
#rc-mode {
  flex: 1; background: var(--card2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 10px; font-size: 13px;
}
.btn-gold {
  background: var(--gold); color: #161006; border: none;
  border-radius: 10px; padding: 9px 20px; font-size: 14px; font-weight: 700;
}
.btn-gold:disabled { opacity: .45; }
.rc-check { display: flex; align-items: center; gap: 7px; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.rc-check input { accent-color: var(--gold); }

/* 任务列表 */
.rc-tasks { display: flex; flex-direction: column; gap: 8px; }
.task {
  background: var(--card2); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 12px;
}
.task-line1 { display: flex; align-items: center; gap: 8px; }
.badge {
  font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 99px;
  flex: none;
}
.badge.running { background: rgba(59, 130, 246, .16); color: var(--info); }
.badge.done { background: rgba(34, 197, 94, .14); color: var(--ok); }
.badge.failed { background: rgba(224, 92, 79, .16); color: var(--danger); }
.badge.canceled, .badge.interrupted { background: rgba(156, 163, 175, .14); color: var(--canceled); }
.task-prompt {
  flex: 1; font-size: 13.5px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.task-line2 {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 7px; font-size: 11.5px; color: var(--muted);
}
.task-actions { display: flex; gap: 6px; }
.task-btn {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: 4px 10px; font-size: 11.5px;
}
.task-btn.danger { color: var(--danger); border-color: rgba(224, 92, 79, .4); }
.empty-mini { font-size: 13px; color: var(--muted); text-align: center; padding: 18px 0; }

/* 任务详情抽屉 */
.task-detail {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .55);
  z-index: 40; display: flex; align-items: flex-end;
}
.task-detail-card {
  width: 100%; background: var(--card);
  border-radius: 20px 20px 0 0; border-top: 1px solid var(--gold-soft);
  padding: 14px 16px calc(env(safe-area-inset-bottom) + 14px);
  max-height: 75vh; display: flex; flex-direction: column; gap: 10px;
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .4; } }
.task-detail-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 15px; }
.td-tail {
  background: #0a0908; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 12px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
  overflow-y: auto; flex: 1; min-height: 80px; max-height: 40vh;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
#td-actions { display: flex; gap: 8px; }

/* 随记 */
.notes { display: flex; flex-direction: column; gap: 10px; }
.note {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 15px 10px;
  animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.note-text { white-space: pre-wrap; word-break: break-word; font-size: 15.5px; line-height: 1.6; }
.note-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px; color: var(--muted); font-size: 12px;
}
.note-del {
  background: none; border: none; color: var(--danger);
  font-size: 12px; padding: 4px 8px; margin: -4px -8px;
}
.compose {
  position: fixed; left: 16px; right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + calc(env(safe-area-inset-top) + 104px));
  max-width: 608px; margin: 0 auto;
  background: var(--card2); border-radius: var(--radius);
  padding: 10px 12px 8px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .55);
  border: 1px solid var(--gold-soft);
}
.compose textarea {
  width: 100%; background: transparent; border: none; outline: none;
  resize: none; color: var(--text); font-size: 16px; line-height: 1.5; font-family: inherit;
}
.compose-row { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.char-count { color: var(--muted); font-size: 12px; }
.offline {
  position: fixed; top: calc(env(safe-area-inset-top) + 52px); left: 16px; right: 16px; z-index: 30;
  background: rgba(224, 92, 79, .14); color: #f3b5ac;
  border: 1px solid rgba(224, 92, 79, .35);
  padding: 8px 14px; border-radius: 10px; font-size: 13px; text-align: center;
}
.empty { text-align: center; color: var(--muted); margin-top: 90px; font-size: 14px; line-height: 1.8; }
.empty-icon { font-size: 44px; margin-bottom: 8px; }
.loading { text-align: center; color: var(--muted); margin-top: 60px; }
