:root {
  --bg: #FAFAFC;
  --bg2: #F2F2F6;
  --ink: #1D1D1F;
  --ink-2: #6E6E73;
  --ink-3: #A1A1A6;
  --line: rgba(0, 0, 0, 0.055);
  --card: #FFFFFF;
  --blue: #007AFF;
  --green: #34C759;
  --red: #FF3B30;
  --amber: #FF9F0A;
  --r-lg: 26px;
  --r-md: 18px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  --shadow-1: 0 1px 1.5px rgba(0, 0, 0, 0.035), 0 6px 20px -8px rgba(0, 0, 0, 0.09);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.04), 0 14px 40px -14px rgba(0, 0, 0, 0.16);
}

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

html, body { height: 100%; }

body {
  margin: 0;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  min-height: 100dvh;
  overscroll-behavior-y: contain;
}

.aura {
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 70vh;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(42% 55% at 22% 28%, rgba(0, 122, 255, 0.07), transparent 70%),
    radial-gradient(38% 50% at 82% 12%, rgba(120, 90, 255, 0.055), transparent 72%),
    radial-gradient(46% 60% at 50% 0%, rgba(255, 255, 255, 0.9), transparent 78%);
  filter: blur(6px);
  animation: drift 26s var(--ease) infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(0, 2.5%, 0) scale(1.06); }
}

.shell {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  margin: 0 auto;
  padding: max(12vh, 74px) 20px calc(90px + env(safe-area-inset-bottom, 0px));
}

.gate { animation: rise 0.6s var(--spring); }
.gate[hidden], .panel[hidden] { display: none; }

/* ── 搜索 ─────────────────────────────── */
.search { display: flex; gap: 10px; align-items: center; }

.field {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  height: 54px;
  padding: 0 14px 0 46px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: transform 0.42s var(--spring), box-shadow 0.42s var(--ease),
              border-color 0.3s var(--ease), background 0.3s var(--ease);
  will-change: transform;
}

.field.is-focus {
  transform: scale(1.018);
  background: #FFFFFF;
  border-color: rgba(0, 122, 255, 0.28);
  box-shadow: var(--shadow-2), 0 0 0 4px rgba(0, 122, 255, 0.08),
              inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.field.is-error {
  border-color: rgba(255, 59, 48, 0.4);
  box-shadow: var(--shadow-1), 0 0 0 4px rgba(255, 59, 48, 0.09);
  animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes shake {
  10%, 90% { transform: translateX(-1.5px) scale(1.018); }
  20%, 80% { transform: translateX(2.5px) scale(1.018); }
  30%, 50%, 70% { transform: translateX(-4px) scale(1.018); }
  40%, 60% { transform: translateX(4px) scale(1.018); }
}

.ico {
  position: absolute;
  left: 16px;
  width: 20px;
  height: 20px;
  color: var(--ink-3);
  transition: color 0.3s var(--ease), transform 0.4s var(--spring);
}

.field.is-focus .ico { color: var(--blue); transform: scale(1.06); }

.field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 15.5px;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.field input::placeholder { color: var(--ink-3); }

.clear {
  flex: none;
  width: 26px;
  height: 26px;
  margin-left: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.28s var(--ease), transform 0.36s var(--spring);
  pointer-events: none;
}

.clear.on { opacity: 1; transform: scale(1); pointer-events: auto; }
.clear:active { transform: scale(0.88); }

.go {
  flex: none;
  position: relative;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-md);
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 0 10px 24px -10px rgba(0, 0, 0, 0.55);
  transition: transform 0.4s var(--spring), opacity 0.3s var(--ease),
              box-shadow 0.4s var(--ease), background 0.3s var(--ease);
}

.go svg { width: 21px; height: 21px; }
.go:active:not(:disabled) { transform: scale(0.93); }
.go:disabled { opacity: 0.28; cursor: default; box-shadow: none; }
.go.loading { pointer-events: none; }
.go.loading svg { opacity: 0; }

.go.loading::after {
  content: "";
  position: absolute;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-top-color: #fff;
  animation: spin 0.72s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── 提示 ─────────────────────────────── */
.note {
  height: 18px;
  margin: 12px 4px 0;
  font-size: 12.5px;
  color: var(--red);
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.3s var(--ease), transform 0.4s var(--ease);
}

.note.on { opacity: 1; transform: translateY(0); }

/* ── 顶部条 ───────────────────────────── */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 26px;
  margin-bottom: 14px;
  animation: rise 0.5s var(--spring);
}

.dot-live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(52, 199, 89, 0.12);
  transition: background 0.4s var(--ease), box-shadow 0.4s var(--ease);
}

.dot-live.stale { background: var(--ink-3); box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.05); }

.exit {
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.3s var(--ease), color 0.3s var(--ease), transform 0.4s var(--spring);
}

.exit:hover { background: rgba(0, 0, 0, 0.04); }
.exit:active { transform: scale(0.94); color: var(--red); }

/* ── 卡片通用 ─────────────────────────── */
.out { display: flex; flex-direction: column; gap: 12px; }

.card {
  position: relative;
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  border: 1px solid rgba(0, 0, 0, 0.035);
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.95), transparent);
}

.rise {
  opacity: 0;
  transform: translateY(14px) scale(0.985);
  filter: blur(6px);
  animation: rise 0.72s var(--spring) forwards;
}

@keyframes rise {
  to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

/* 身份 */
.ident { padding: 20px 20px 17px; }

.ident-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  justify-content: space-between;
}

.ident-name {
  font-size: 18.5px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.3;
  word-break: break-all;
}

.ident-sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
  font-size: 12.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.ident-sub code {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  background: rgba(0, 0, 0, 0.04);
  padding: 3px 7px;
  border-radius: 7px;
}

.dot { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-3); opacity: 0.6; }

.pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 25px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 16%, transparent);
}

.pill.ok { color: #1B8A3A; background: rgba(52, 199, 89, 0.12); }
.pill.warn { color: #B26A00; background: rgba(255, 159, 10, 0.14); }
.pill.off { color: #C13026; background: rgba(255, 59, 48, 0.1); }

/* 环形 */
.ring-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 20px 16px 16px;
}

.ring { width: 104px; height: 104px; flex: none; transform: rotate(-90deg); }
.ring .track { fill: none; stroke: rgba(0, 0, 0, 0.055); stroke-width: 9; }

.ring .bar-path {
  fill: none;
  stroke: var(--blue);
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.5s var(--ease), stroke 0.6s var(--ease);
}

.ring-side { flex: 1; min-width: 0; }
.ring-label { font-size: 12px; color: var(--ink-3); }

.ring-time {
  margin-top: 4px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  line-height: 1.12;
}

.ring-meta {
  margin-top: 7px;
  font-size: 12.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

/* 网格 */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-1);
  border: 1px solid rgba(0, 0, 0, 0.035);
}

.cell { background: #fff; padding: 15px 17px 16px; }

.cell .k {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0.01em;
}

.cell .v {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.cell .u {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: 0;
  margin-left: 2px;
}

.cell .hint {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.01em;
}

/* 明细 */
.rows { padding: 4px 20px 6px; }

.row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.row:last-child { border-bottom: 0; }
.row .k { font-size: 13.5px; color: var(--ink-2); flex: none; }

.row .v {
  font-size: 13.5px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
  letter-spacing: -0.005em;
}

.row .v small { color: var(--ink-3); font-size: 11.5px; margin-left: 6px; }

/* 模型 */
.models { padding: 15px 18px; display: flex; flex-wrap: wrap; gap: 8px; }

.tag {
  display: inline-flex;
  align-items: center;
  height: 29px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(0, 122, 255, 0.075);
  color: #0062CC;
  font-size: 12.5px;
  font-weight: 500;
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  animation: rise 0.6s var(--spring) backwards;
}

/* 记录 */
.logs { padding: 6px 20px 8px; }

.log {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.log:last-child { border-bottom: 0; }
.log .t { font-size: 12.5px; color: var(--ink-2); }
.log .bar-mini {
  height: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.045);
  overflow: hidden;
}
.log .bar-mini i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--blue);
  transform-origin: left;
  animation: grow 0.9s var(--ease);
}
@keyframes grow { from { transform: scaleX(0); } }
.log .d { font-size: 12.5px; color: var(--ink); font-weight: 500; }
.log .d.zero { color: var(--ink-3); font-weight: 400; }

.section-title {
  padding: 14px 20px 2px;
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}

/* 骨架 */
.skeleton { display: flex; flex-direction: column; gap: 12px; }

.sk-card, .sk-cell {
  background: #fff;
  border-radius: var(--r-lg);
  height: 108px;
  box-shadow: var(--shadow-1);
  position: relative;
  overflow: hidden;
}

.sk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sk-cell { height: 84px; border-radius: var(--r-md); }

.sk-card::after, .sk-cell::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.035), transparent);
  animation: shimmer 1.5s var(--ease) infinite;
}

@keyframes shimmer { to { transform: translateX(100%); } }

.empty {
  display: grid;
  place-items: center;
  padding: 30px 0 0;
  opacity: 0;
  animation: rise 0.9s var(--ease) 0.1s forwards;
}

.empty i {
  width: 30px;
  height: 30px;
  border-radius: 11px;
  border: 1.6px solid rgba(0, 0, 0, 0.09);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* 中继设置 */
.cfg {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  transition: transform 0.42s var(--spring), opacity 0.3s var(--ease);
  z-index: 20;
  opacity: 0.38;
}

.cfg::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-3);
}

.cfg:hover { opacity: 1; }
.cfg:active { transform: scale(0.9); }
.cfg.set::after { background: var(--green); }

.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-wrap[hidden] { display: none; }

.scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade 0.32s var(--ease);
}

@keyframes fade { from { opacity: 0; } }

.sheet {
  position: relative;
  width: min(100%, 520px);
  padding: 10px 20px calc(22px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.04), 0 -20px 50px -20px rgba(0, 0, 0, 0.22);
  animation: up 0.5s var(--spring);
  display: grid;
  gap: 12px;
}

@keyframes up { from { transform: translateY(100%); } }

.grab {
  width: 36px;
  height: 4px;
  margin: 0 auto 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.12);
}

.sheet input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 15px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  outline: 0;
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.sheet input::placeholder { color: var(--ink-3); }

.sheet input:focus {
  border-color: rgba(0, 122, 255, 0.3);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.08);
}

.sheet .save {
  height: 50px;
  border: 0;
  border-radius: 15px;
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-size: 15.5px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.4s var(--spring);
}

.sheet .save:active { transform: scale(0.97); }

@media (max-width: 400px) {
  .shell { padding-top: 10vh; }
  .ident-name { font-size: 16.5px; }
  .ring-time { font-size: 23px; }
  .cell .v { font-size: 19px; }
  .ring { width: 92px; height: 92px; }
}
