:root {
  --bg: #080b11;
  --bg-soft: #0e131c;
  --card: #121a25;
  --card-hi: #16202d;
  --line: #232f3f;
  --line-hi: #2a3748;
  --text: #e6edf7;
  --muted: #78869a;
  --faint: #4d5a6c;

  --up: #2fd6a5;
  --auth: #4c9cf7;
  --warn: #f2a93b;
  --down: #f2556f;
  --idle: #5b6879;

  --radius: 14px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(900px 520px at 82% -12%, rgba(47, 214, 165, 0.055), transparent 62%),
    radial-gradient(760px 460px at 8% 104%, rgba(76, 156, 247, 0.05), transparent 62%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.view[hidden] {
  display: none !important;
}

/* ---------------- 登录 ---------------- */

.view-login {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
}

.card-login {
  width: 100%;
  max-width: 352px;
  background: linear-gradient(180deg, var(--card-hi), var(--card));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px 22px 22px;
  box-shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--up);
  box-shadow: 0 0 0 3px rgba(47, 214, 165, 0.14), 0 0 14px rgba(47, 214, 165, 0.55);
  flex: 0 0 auto;
}

.brand-name {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.16em;
  color: var(--text);
}

.login-sub {
  margin: 6px 0 22px;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}

.field input {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  background: #0b111a;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

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

.field input:focus {
  border-color: #2f4a63;
  background: #0c1320;
  box-shadow: 0 0 0 3px rgba(76, 156, 247, 0.1);
}

.field input:disabled {
  opacity: 0.5;
}

/* 滑块验证 */

.slider {
  position: relative;
  height: 46px;
  margin: 18px 0 16px;
  border-radius: 11px;
  background: #0b111a;
  border: 1px solid var(--line);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.slider.solved {
  border-color: rgba(47, 214, 165, 0.4);
}

.slider.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.slider-track {
  position: absolute;
  inset: 0;
}

.slider-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: linear-gradient(90deg, rgba(47, 214, 165, 0.06), rgba(47, 214, 165, 0.22));
  border-right: 1px solid rgba(47, 214, 165, 0.45);
}

.slider-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.06em;
  pointer-events: none;
  transition: opacity 0.2s, color 0.2s;
}

.slider.solved .slider-text {
  color: var(--up);
  opacity: 0;
}

.slider-handle {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: linear-gradient(180deg, #223046, #1a2431);
  border: 1px solid var(--line-hi);
  color: #9fb1c7;
  cursor: grab;
  will-change: transform;
  transition: background 0.18s, color 0.18s, border-color 0.18s, box-shadow 0.18s;
}

.slider-handle:active {
  cursor: grabbing;
}

.slider.dragging .slider-handle {
  transition: none;
  color: #cfe0f5;
  border-color: #35506e;
  box-shadow: 0 4px 14px -4px rgba(0, 0, 0, 0.7);
}

.slider.solved .slider-handle {
  background: linear-gradient(180deg, #1f5e4d, #17513f);
  border-color: rgba(47, 214, 165, 0.55);
  color: #b7f5e2;
  cursor: default;
}

.slider.shake {
  animation: shake 0.36s var(--ease);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  22% { transform: translateX(-5px); }
  46% { transform: translateX(4px); }
  70% { transform: translateX(-3px); }
}

/* 按钮 */

.btn-primary {
  width: 100%;
  height: 46px;
  border: none;
  border-radius: 11px;
  background: linear-gradient(180deg, #2fd6a5, #24b98d);
  color: #06231b;
  font-size: 14.5px;
  font-weight: 650;
  font-family: inherit;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: filter 0.18s, transform 0.12s, box-shadow 0.18s;
  box-shadow: 0 10px 24px -14px rgba(47, 214, 165, 0.9);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary:disabled {
  background: #1a2331;
  color: var(--faint);
  cursor: not-allowed;
  box-shadow: none;
}

.msg {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--down);
  text-align: center;
  letter-spacing: 0.01em;
}

.msg.info {
  color: var(--warn);
}

/* ---------------- 仪表盘 ---------------- */

.view-dash {
  max-width: 880px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stamp {
  font-size: 11.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  margin-right: 2px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s, background 0.18s, transform 0.3s var(--ease);
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--line-hi);
  background: rgba(255, 255, 255, 0.03);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn.spin svg {
  animation: spin 0.7s linear infinite;
}

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

.summary {
  margin: 16px 0 14px;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.summary b {
  color: var(--text);
  font-weight: 600;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 11px;
}

.site {
  position: relative;
  background: linear-gradient(180deg, var(--card-hi), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px 12px;
  transition: border-color 0.2s, transform 0.2s var(--ease);
  overflow: hidden;
}

.site::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 2px;
  border-radius: 0 2px 2px 0;
  background: var(--idle);
  opacity: 0.7;
  transition: background 0.3s, opacity 0.3s;
}

.site[data-state="up"]::before { background: var(--up); opacity: 0.85; }
.site[data-state="auth"]::before { background: var(--auth); opacity: 0.8; }
.site[data-state="warn"]::before { background: var(--warn); opacity: 0.85; }
.site[data-state="down"]::before { background: var(--down); opacity: 1; }

.site:hover {
  border-color: var(--line-hi);
}

.site-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lamp {
  position: relative;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--idle);
  flex: 0 0 auto;
  transition: background 0.3s, box-shadow 0.3s;
}

.site[data-state="up"] .lamp {
  background: var(--up);
  box-shadow: 0 0 0 3px rgba(47, 214, 165, 0.1), 0 0 12px rgba(47, 214, 165, 0.6);
}

.site[data-state="auth"] .lamp {
  background: var(--auth);
  box-shadow: 0 0 0 3px rgba(76, 156, 247, 0.1), 0 0 12px rgba(76, 156, 247, 0.5);
}

.site[data-state="warn"] .lamp {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(242, 169, 59, 0.1), 0 0 12px rgba(242, 169, 59, 0.5);
}

.site[data-state="down"] .lamp {
  background: var(--down);
  box-shadow: 0 0 0 3px rgba(242, 85, 111, 0.12), 0 0 14px rgba(242, 85, 111, 0.65);
  animation: breathe 1.9s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.38; }
}

.site-domain {
  font-size: 14px;
  font-weight: 590;
  letter-spacing: -0.005em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
}

.tag {
  flex: 0 0 auto;
  font-size: 10.5px;
  font-weight: 550;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: rgba(91, 104, 121, 0.12);
  color: var(--muted);
}

.site[data-state="up"] .tag {
  color: var(--up);
  background: rgba(47, 214, 165, 0.1);
  border-color: rgba(47, 214, 165, 0.18);
}

.site[data-state="auth"] .tag {
  color: var(--auth);
  background: rgba(76, 156, 247, 0.1);
  border-color: rgba(76, 156, 247, 0.18);
}

.site[data-state="warn"] .tag {
  color: var(--warn);
  background: rgba(242, 169, 59, 0.1);
  border-color: rgba(242, 169, 59, 0.18);
}

.site[data-state="down"] .tag {
  color: var(--down);
  background: rgba(242, 85, 111, 0.1);
  border-color: rgba(242, 85, 111, 0.2);
}

.site-body {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}

.site-note {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  min-height: 17px;
  cursor: text;
  border-bottom: 1px dashed transparent;
  padding-bottom: 1px;
  transition: color 0.18s, border-color 0.18s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
}

.site-note:hover {
  color: #9aabc0;
  border-bottom-color: var(--line-hi);
}

.site-note.empty {
  color: var(--faint);
  font-style: italic;
}

.note-input {
  width: 100%;
  padding: 3px 7px;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--text);
  background: #0b111a;
  border: 1px solid #2f4a63;
  border-radius: 6px;
  outline: none;
}

.site-meta {
  margin: 0;
  font-size: 10.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex: 0 0 auto;
}

.foot {
  margin-top: 20px;
  font-size: 11px;
  color: var(--faint);
  text-align: center;
  letter-spacing: 0.03em;
}

/* 骨架 */

.skeleton .lamp {
  background: #263241;
  box-shadow: none;
  animation: breathe 1.4s ease-in-out infinite;
}

.skeleton .site-domain {
  color: #33404f;
}

/* ---------------- 移动端 ---------------- */

@media (max-width: 560px) {
  .view-dash {
    padding-left: 14px;
    padding-right: 14px;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .site {
    padding: 13px 14px 12px;
  }

  .site-domain {
    font-size: 13.5px;
  }

  .stamp {
    display: none;
  }

  .card-login {
    padding: 22px 18px 18px;
    border-radius: 16px;
  }
}

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