/*
 * 站内主题适配层（后加载，覆盖上游 styles.css 的视觉表现）
 * 只改外观：颜色、字体、圆角、间距、层级；不改任何文案与功能。
 * 上游原始样式：css/styles.css（GPL-3.0-only, 晨钟酱Official）
 *
 * 设计对照（与博客前台一致）：
 *   浅色 base #F4F6F9 / panel #FFFFFF / line #DDE3EC / fg #0B1220 / accent #0284C7
 *   深色 base #070A0F / panel #0C1118 / line #283544 / fg #E6EDF5 / accent #38BDF8
 */

/* ---------- 设计令牌 ---------- */
:root {
  /* !important：app.js 会把品牌色写进 <html> 的内联样式，需要以作者级 !important 覆盖 */
  --brand: #0284c7 !important;
  --brand-dark: #0369a1 !important;
  --brand-soft: rgba(2, 132, 199, 0.1) !important;
  --accent: #0284c7;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --panel-2: #edf1f6; /* raised：输入框、次级底 */
  --ink: #0b1220;
  --muted: #4a5768;
  --faint: #64707f;
  --line: #dde3ec;
  --line-strong: #cfd8e3;
  --shadow: 0 1px 2px rgba(11, 18, 32, 0.04);
  --shadow-lg: 0 12px 40px rgba(11, 18, 32, 0.08);
  --radius: 14px;
  --radius-sm: 9px;
  --ok: #1a7054;
  --warn: #9a6a12;
  --danger: #b0302a;

  font-family: "MiSans", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --brand: #38bdf8 !important;
  --brand-dark: #0ea5e9 !important;
  --brand-soft: rgba(56, 189, 248, 0.14) !important;
  --accent: #38bdf8;
  --bg: #070a0f;
  --surface: #0c1118;
  --panel-2: #121a24;
  --ink: #e6edf5;
  --muted: #9aa9b8;
  --faint: #72808f;
  --line: #283544;
  --line-strong: #34445a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);
  --ok: #6ebe9c;
  --warn: #d6b062;
  --danger: #e07a74;
  color-scheme: dark;
}

/* ---------- 基础 ---------- */
body {
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* 恢复细滚动条（上游默认隐藏），与博客一致 */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
html::-webkit-scrollbar {
  display: block;
  width: 8px;
  height: 8px;
}
html::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 8px;
}
html::-webkit-scrollbar-track {
  background: transparent;
}

h2 {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
h3 {
  font-size: 16px;
  font-weight: 600;
}
a {
  color: var(--brand);
}
a:hover {
  text-decoration: none;
}
:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--brand) 75%, transparent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- 顶栏：与博客 header 同一语言（surface + 1px 下边线） ---------- */
.topbar {
  min-height: 64px;
  padding: 0 22px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--line);
  box-shadow: none;
  color: var(--ink);
}
.brand h1 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.brand-copy {
  min-width: 0;
}
.connection-chip {
  font-size: 12px;
  color: var(--muted);
}
.dot {
  width: 6px;
  height: 6px;
  background: var(--line-strong);
}
.dot.ok {
  background: var(--ok);
}
.dot.pending {
  background: var(--warn);
}
.dot.error {
  background: var(--danger);
}
.topbar .btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: none;
  font-size: 12.5px;
  min-height: 32px;
  padding: 5px 12px;
}
.topbar .btn:hover:not(:disabled) {
  background: var(--panel-2);
  border-color: var(--line-strong);
}
.sidebar-toggle {
  color: var(--muted);
}

/* ---------- 侧栏导航 ---------- */
.shell {
  grid-template-columns: 186px minmax(0, 1fr);
}
.sidebar {
  background: var(--bg);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
}
.nav {
  gap: 2px;
}
.nav button {
  font-size: 13.5px;
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-height: 40px;
  gap: 11px;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.nav button svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.6;
}
.nav button:hover {
  background: var(--panel-2);
  color: var(--ink);
}
.nav button.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 500;
}
.nav button.active:before {
  left: -12px;
  top: 9px;
  bottom: 9px;
  width: 2px;
  border-radius: 2px;
  background: var(--brand);
}
.sidebar-foot {
  color: var(--faint);
  font-size: 12px;
  line-height: 1.9;
}
.sidebar-foot a {
  color: var(--muted);
}

/* ---------- 工作区与卡片 ---------- */
.workspace {
  padding: 22px 28px 48px;
}
.page-title h2 {
  font-size: 20px;
  margin: 0;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.separator {
  border-top: 1px solid var(--line);
}

/* ---------- 按钮 ---------- */
.btn {
  font-size: 13px;
  min-height: 34px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  border: 1px solid transparent;
  color: #fff;
  box-shadow: none;
  font-weight: 500;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover:not(:disabled) {
  background: var(--brand-dark);
}
.btn.secondary {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
  box-shadow: none;
}
.btn.secondary:hover:not(:disabled) {
  background: var(--panel-2);
  border-color: var(--line-strong);
}
.btn.quiet {
  background: var(--panel-2);
  color: var(--muted);
}
.btn.danger {
  background: var(--danger);
}
.btn.danger:hover:not(:disabled) {
  background: var(--danger);
  filter: brightness(0.94);
}
.btn.small {
  min-height: 28px;
  padding: 3px 10px;
  font-size: 12px;
}

/* ---------- 表单 ---------- */
input:not([type="checkbox"]):not([type="range"]),
select,
textarea {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 13px;
  min-height: 38px;
  padding: 8px 11px;
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  outline: 2px solid color-mix(in srgb, var(--brand) 18%, transparent);
}
input::placeholder,
textarea::placeholder {
  color: var(--faint);
}
.field > span,
.field > label {
  color: var(--muted);
  font-size: 12px;
}
.field-row .btn {
  min-height: 38px;
}
.hint {
  color: var(--faint);
  font-size: 11.5px;
  line-height: 1.75;
}
.switch input {
  background: var(--line-strong);
}
.switch input:checked {
  background: color-mix(in srgb, var(--brand) 32%, transparent);
}
.switch input:checked:before {
  background: var(--brand);
}
.check input,
input[type="range"] {
  accent-color: var(--brand);
}

/* ---------- 展示块 ---------- */
.focus-box {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.stat-label {
  color: var(--faint);
  font-size: 11px;
}
.metric-text {
  color: var(--muted);
}
.info-wide {
  border-top: 1px solid var(--line);
}
.info-wide b {
  color: var(--faint);
  font-weight: 400;
}
.info-pairs dt {
  color: var(--faint);
}
.cpu-grid {
  color: var(--brand);
  font-size: 14px;
}
.empty {
  color: var(--faint);
  font-size: 12.5px;
}
.badge {
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 999px;
  font-size: 10.5px;
  padding: 2px 8px;
}

/* 日志/终端类文本块：等宽、深底、可滚动 */
.text-output,
.stats-output,
.script-list {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, monospace;
}
.text-output {
  padding: 12px 14px;
}
.script-editor {
  background: var(--panel-2);
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  padding: 12px;
}
.download-item {
  background: var(--panel-2);
  border-radius: var(--radius-sm);
}
.gallery-empty {
  color: var(--faint);
}

/* 进度条 / 滑块 */
.progress {
  background: var(--panel-2);
  height: 3px;
  border-radius: 3px;
}
.progress div {
  background: var(--brand);
}
.slider-value {
  color: var(--brand);
}
.ticks {
  color: var(--faint);
}
.battery-summary {
  color: var(--muted);
}

/* ---------- 连接入口（未连接设备时的首屏） ---------- */
.connection-entry {
  padding: 72px 0 48px;
}
.connection-entry .btn {
  min-width: 156px;
  min-height: 42px;
  font-size: 13.5px;
}
.connection-hint {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 2;
}
.connection-hint ol {
  display: inline-block;
  text-align: left;
  margin: 0 auto;
  padding-left: 1.25rem;
}
.connection-warning {
  color: var(--warn);
  font-size: 12px;
}
.connection-source {
  color: var(--faint);
  font-size: 12px;
  margin-top: 10px;
}
.connection-source a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.connection-status {
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- 弹层 / 提示 ---------- */
dialog {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.modal-head {
  border-bottom: 1px solid var(--line);
}
.modal-footer {
  border-top: 1px solid var(--line);
}
.toast {
  background: var(--ink);
  color: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  padding: 10px 16px;
  box-shadow: var(--shadow-lg);
}
.toast.error {
  background: var(--danger);
  color: #fff;
}

/* ---------- 深浅色细节修正 ---------- */
html[data-theme="dark"] .btn.secondary {
  background: var(--panel-2);
  border-color: var(--line);
}
html[data-theme="dark"] .topbar {
  background: color-mix(in srgb, var(--surface) 86%, transparent);
}
html[data-theme="dark"] .sidebar {
  background: var(--bg);
}
html[data-theme="dark"] .brand h1,
html[data-theme="dark"] .page-title h2 {
  color: var(--ink);
}
html[data-theme="dark"] .card {
  box-shadow: none;
}
html[data-theme="dark"] img {
  opacity: 0.94;
}

/* ---------- 窄屏 ---------- */
@media (max-width: 780px) {
  .topbar {
    padding: 10px 14px;
  }
  .brand h1 {
    font-size: 14.5px;
  }
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    background: var(--surface);
  }
  .workspace {
    padding: 16px 14px 40px;
  }
  .connection-entry {
    padding: 44px 0 32px;
  }
}
