/* ============================================================
   Clash 规则面板 — 样式表
   结构：变量 → 基础 → 布局 → 组件 → 分区 → 响应式
   ============================================================ */

/* ---------- 变量 ---------- */
:root {
  --bg: #0b0f14;
  --bg-elev: #111820;
  --surface: #151d27;
  --surface-2: #1a2430;
  --surface-3: #202c3a;
  --line: #24313f;
  --line-soft: #1c2734;
  --text: #e8eef5;
  --text-dim: #9aa8b8;
  --text-faint: #8494a6;
  --accent: #4d8dff;
  --accent-hi: #6ea2ff;
  --accent-soft: rgba(77, 141, 255, 0.14);
  --ok: #34d17a;
  --ok-soft: rgba(52, 209, 122, 0.13);
  --warn: #f0b429;
  --warn-soft: rgba(240, 180, 41, 0.13);
  --danger: #f2596b;
  --danger-soft: rgba(242, 89, 107, 0.13);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 44px -22px rgba(0, 0, 0, 0.85);
  --ring: 0 0 0 3px rgba(77, 141, 255, 0.22);
  --sidebar-w: 232px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

:root[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f7;
  --line: #dde5ee;
  --line-soft: #e8eef5;
  --text: #14202e;
  --text-dim: #5b6b7c;
  --text-faint: #74849a;
  --accent: #2f6fe4;
  --accent-hi: #1f5cd0;
  --accent-soft: rgba(47, 111, 228, 0.1);
  --ok: #12a05c;
  --ok-soft: rgba(18, 160, 92, 0.11);
  --warn: #b47500;
  --warn-soft: rgba(180, 117, 0, 0.11);
  --danger: #d63a4d;
  --danger-soft: rgba(214, 58, 77, 0.1);
  --shadow: 0 14px 34px -22px rgba(23, 42, 66, 0.4);
  --ring: 0 0 0 3px rgba(47, 111, 228, 0.18);
}

/* ---------- 基础 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(760px 420px at 8% -8%, var(--accent-soft), transparent 62%),
    radial-gradient(620px 360px at 100% 0%, var(--ok-soft), transparent 58%);
}

h1, h2, h3, p, dl, dd, figure {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

input, textarea, select {
  font: inherit;
  color: inherit;
}

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

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mono {
  font-family: var(--mono);
  font-size: 0.9em;
  letter-spacing: -0.01em;
}

.hint {
  margin-top: 10px;
  color: var(--text-faint);
  font-size: 12.5px;
  line-height: 1.55;
}

.hint.bad {
  color: var(--danger);
}

/* ---------- 品牌 ---------- */
.brand,
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(150deg, var(--accent-hi), var(--accent));
  box-shadow: 0 6px 16px -8px var(--accent);
}

.brand-mark .icon {
  width: 17px;
  height: 17px;
  stroke-width: 2;
}

.brand-text {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.brand-text em {
  margin-left: 6px;
  font-style: normal;
  font-weight: 500;
  color: var(--text-dim);
}

/* ---------- 登录 ---------- */
.login-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  width: min(392px, 100%);
  padding: 32px 30px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.login-card .login-brand {
  margin-bottom: 26px;
}

.login-card h1 {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.login-card .sub {
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 13.5px;
}

.login-card .field {
  margin-top: 22px;
}

.login-card .btn.primary {
  margin-top: 22px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 16px;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.checkbox input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.form-error {
  min-height: 18px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 13px;
}

/* ---------- 外壳 ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 26px;
  height: 100vh;
  padding: 22px 16px 16px;
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
}

.sidebar .brand {
  padding: 0 6px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  transition: background 130ms ease, color 130ms ease;
}

.nav-item .icon {
  width: 17px;
  height: 17px;
  color: var(--text-faint);
  transition: color 130ms ease;
}

.nav-item:hover {
  background: var(--surface-3);
  color: var(--text);
}

.nav-item:hover .icon {
  color: var(--text-dim);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active .icon {
  color: var(--accent);
}

.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

/* ---------- 状态点 ---------- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.status-pill .dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--text-faint);
}

.status-pill.ok {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 34%, transparent);
  background: var(--ok-soft);
}

.status-pill.ok .dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}

.status-pill.bad {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 34%, transparent);
  background: var(--danger-soft);
}

.status-pill.bad .dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.status-pill.sm {
  padding: 4px 9px;
  font-size: 11.5px;
}

/* ---------- 主内容 ---------- */
.content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 60px;
  padding: 0 26px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-title {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.panels {
  width: 100%;
  max-width: 1000px;
  padding: 26px;
  margin: 0 auto;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: rise 220ms ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .panel {
    animation: none;
  }
}

/* ---------- 卡片 ---------- */
.card {
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.card-head h2 {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.005em;
}

.card-sub {
  margin-top: 3px;
  color: var(--text-faint);
  font-size: 12.5px;
}

.chip-muted {
  flex: 0 0 auto;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 11.5px;
  white-space: nowrap;
}

.tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 500;
}

/* ---------- 统计卡 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 14px;
}

.stat {
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-label {
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.stat-value {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 680;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.stat-value.ok {
  color: var(--ok);
}

.stat-value.bad {
  color: var(--danger);
}

.stat-foot {
  margin-top: 5px;
  color: var(--text-faint);
  font-size: 11.5px;
}

/* ---------- 快捷操作 ---------- */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.quick {
  display: grid;
  gap: 2px;
  justify-items: start;
  padding: 13px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-align: left;
  transition: border-color 130ms ease, background 130ms ease, transform 90ms ease;
}

.quick .icon {
  margin-bottom: 6px;
  color: var(--text-faint);
  transition: color 130ms ease;
}

.quick:hover {
  background: var(--surface-3);
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
}

.quick:hover .icon {
  color: var(--accent);
}

.quick:active {
  transform: translateY(1px);
}

.quick-title {
  font-size: 13px;
  font-weight: 600;
}

.quick-sub {
  color: var(--text-faint);
  font-size: 11.5px;
}

/* ---------- 表单控件 ---------- */
.field {
  display: block;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 600;
}

.field-grid {
  display: grid;
  gap: 16px 16px;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-grid .span-all {
  grid-column: 1 / -1;
}

input[type="text"],
input[type="password"],
input[type="number"],
input:not([type]),
textarea,
select {
  width: 100%;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  transition: border-color 130ms ease, box-shadow 130ms ease;
}

textarea {
  min-height: 96px;
  resize: vertical;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
}

select {
  appearance: none;
  padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-faint) 50%),
    linear-gradient(135deg, var(--text-faint) 50%, transparent 50%);
  background-position: calc(100% - 17px) calc(50% + 1px), calc(100% - 12px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}

input[readonly] {
  background: var(--surface-2);
  color: var(--text-dim);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

input.invalid,
textarea.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  flex: 1;
  min-width: 0;
}

.input-with-action {
  position: relative;
}

.input-with-action input {
  padding-right: 38px;
}

.input-with-action .reveal {
  position: absolute;
  top: 50%;
  right: 5px;
  transform: translateY(-50%);
}

/* ---------- 开关 ---------- */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 130ms ease;
}

.switch-row:hover {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
}

.switch-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.switch-sub {
  display: block;
  margin-top: 1px;
  color: var(--text-faint);
  font-size: 11.5px;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 23px;
  margin: 0;
  appearance: none;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 160ms cubic-bezier(0.3, 0.8, 0.4, 1), background 160ms ease;
}

.switch:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.switch:checked::after {
  transform: translateX(17px);
  background: #fff;
}

.switch:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 130ms ease, border-color 130ms ease, transform 90ms ease, opacity 130ms ease;
}

.btn .icon {
  width: 16px;
  height: 16px;
}

.btn:hover {
  background: var(--surface-3);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px -12px var(--accent);
}

.btn.primary:hover {
  filter: brightness(1.06);
  border-color: transparent;
}

.btn.ghost {
  background: transparent;
}

.btn.ghost:hover {
  background: var(--surface-2);
}

.btn.danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--danger) 38%, transparent);
  color: var(--danger);
}

.btn.danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn.sm {
  padding: 6px 11px;
  font-size: 12.5px;
}

.btn.block {
  width: 100%;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  transition: background 130ms ease, color 130ms ease, border-color 130ms ease;
}

.icon-btn:hover {
  background: var(--surface-3);
  border-color: var(--line);
  color: var(--text);
}

.icon-btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.only-mobile {
  display: none;
}

/* ---------- 订阅块 ---------- */
.sub-block + .sub-block {
  margin-top: 16px;
}

.sub-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.sub-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
}

/* ---------- Chip 编辑器 ---------- */
.chip-group + .chip-group {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}

.chip-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.chip-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 600;
}

.chip-title .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
}

.chip-group[data-tone="ok"] .chip-title .dot {
  background: var(--ok);
}

.chip-group[data-tone="accent"] .chip-title .dot {
  background: var(--accent);
}

.chip-group[data-tone="danger"] .chip-title .dot {
  background: var(--danger);
}

.chip-count {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 11px;
}

.chip-filter {
  width: 118px !important;
  margin-left: auto;
  padding: 4px 9px !important;
  border-radius: 999px !important;
  background: var(--surface-2) !important;
  font-size: 12px !important;
}

.chip-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 8px 9px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color 130ms ease, box-shadow 130ms ease;
}

.chip-box:focus-within {
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.chips {
  display: contents;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 3px 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  animation: chip-in 140ms ease both;
}

@keyframes chip-in {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chip {
    animation: none;
  }
}

.chip[data-tone="ok"] {
  border-color: color-mix(in srgb, var(--ok) 30%, var(--line));
  background: var(--ok-soft);
  color: color-mix(in srgb, var(--ok) 82%, var(--text));
}

.chip[data-tone="accent"] {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  background: var(--accent-soft);
  color: color-mix(in srgb, var(--accent) 82%, var(--text));
}

.chip[data-tone="danger"] {
  border-color: color-mix(in srgb, var(--danger) 30%, var(--line));
  background: var(--danger-soft);
  color: color-mix(in srgb, var(--danger) 82%, var(--text));
}

.chip button {
  position: relative;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: inherit;
  opacity: 0.55;
  transition: opacity 120ms ease, background 120ms ease;
}

/* 扩大实际可点击区域到 24px，视觉尺寸保持不变 */
.chip button::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
}

.chip button:hover {
  opacity: 1;
  background: rgba(128, 128, 128, 0.22);
}

.chip button .icon {
  width: 11px;
  height: 11px;
  stroke-width: 2.4;
}

.chip-input {
  flex: 1;
  min-width: 130px;
  padding: 3px 4px !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  font-family: var(--mono);
  font-size: 12px !important;
}

.chip-empty {
  padding: 3px 4px;
  color: var(--text-faint);
  font-size: 12px;
}

.errors {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.errors li {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

.errors li::before {
  content: "•";
  flex: 0 0 auto;
}

/* ---------- 用量 ---------- */
.usage-row {
  display: grid;
  grid-template-columns: 76px minmax(80px, 1fr) minmax(128px, auto);
  align-items: center;
  gap: 12px;
  padding: 7px 0;
}

.usage-row + .usage-row {
  border-top: 1px solid var(--line-soft);
}

.usage-name {
  color: var(--text-dim);
  font-size: 12.5px;
}

.usage-val {
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

.bar {
  height: 7px;
  overflow: hidden;
  background: var(--surface-3);
  border-radius: 999px;
}

.bar > i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--ok));
  transition: width 320ms cubic-bezier(0.3, 0.8, 0.4, 1), background 200ms ease;
}

.bar > i.warn {
  background: linear-gradient(90deg, var(--warn), var(--danger));
}

.bar > i.over {
  background: var(--danger);
}

/* ---------- 提示条 ---------- */
.callout {
  display: flex;
  gap: 11px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.callout .icon {
  margin-top: 1px;
  color: var(--text-faint);
}

.callout strong {
  display: block;
  font-size: 13px;
  font-weight: 650;
}

.callout p {
  margin-top: 3px;
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.55;
}

.callout.warn {
  border-color: color-mix(in srgb, var(--warn) 30%, var(--line));
  background: var(--warn-soft);
}

.callout.warn .icon,
.callout.warn strong {
  color: var(--warn);
}

.callout.danger {
  border-color: color-mix(in srgb, var(--danger) 30%, var(--line));
  background: var(--danger-soft);
}

.callout.danger .icon,
.callout.danger strong {
  color: var(--danger);
}

/* ---------- KV ---------- */
.kv {
  display: grid;
  grid-template-columns: minmax(96px, auto) 1fr;
  gap: 9px 18px;
  font-size: 13px;
}

.kv dt {
  color: var(--text-faint);
}

.kv dd {
  color: var(--text);
}

/* ---------- 保存栏 ---------- */
.save-bar {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px 9px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 20px 46px -18px rgba(0, 0, 0, 0.65);
  transform: translateX(-50%);
  animation: save-in 200ms cubic-bezier(0.3, 0.9, 0.4, 1) both;
}

@keyframes save-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .save-bar {
    animation: none;
  }
}

.save-hint {
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
}

.save-bar .btn {
  margin: 0;
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(6, 9, 13, 0.66);
  backdrop-filter: blur(3px);
  animation: fade 160ms ease both;
}

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

.modal-card {
  display: flex;
  flex-direction: column;
  width: min(780px, 100%);
  max-height: min(82vh, 760px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 30px 70px -24px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  animation: pop 180ms cubic-bezier(0.3, 0.9, 0.4, 1) both;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal,
  .modal-card {
    animation: none;
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 14px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  font-size: 14px;
  font-weight: 650;
}

.code {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 16px 20px;
  overflow: auto;
  background: var(--bg);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  white-space: pre;
  tab-size: 2;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
}

.modal-foot .btn-row {
  margin: 0;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  max-width: min(520px, calc(100% - 32px));
  padding: 10px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.7);
  color: var(--text);
  font-size: 13px;
  transform: translateX(-50%);
  animation: toast-in 200ms cubic-bezier(0.3, 0.9, 0.4, 1) both;
}

.toast.error {
  border-left-color: var(--danger);
  color: color-mix(in srgb, var(--danger) 70%, var(--text));
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none;
  }
}

/* ---------- 遮罩 ---------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 24;
  background: rgba(6, 9, 13, 0.5);
  backdrop-filter: blur(2px);
}

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .field-grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 25;
    width: 264px;
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform 220ms cubic-bezier(0.3, 0.9, 0.4, 1);
    box-shadow: 24px 0 60px -30px rgba(0, 0, 0, 0.8);
  }

  .sidebar.open {
    transform: none;
  }

  .only-mobile {
    display: grid;
  }

  .panels {
    padding: 18px 16px 96px;
  }

  .topbar {
    padding: 0 16px;
  }

  .field-grid.two,
  .field-grid.three {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .login-card {
    padding: 26px 22px 22px;
  }

  .card {
    padding: 16px;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .stat {
    padding: 14px 16px;
  }

  .stat-value {
    font-size: 19px;
  }

  .usage-row {
    grid-template-columns: 66px minmax(60px, 1fr);
    gap: 4px 10px;
  }

  .usage-val {
    grid-column: 2;
    text-align: left;
  }

  .input-row {
    flex-direction: column;
  }

  .input-row .btn {
    width: 100%;
  }

  .save-bar {
    left: 12px;
    right: 12px;
    bottom: 12px;
    justify-content: space-between;
    transform: none;
    border-radius: var(--radius);
  }

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

  .topbar-title {
    font-size: 15px;
  }

  .chip-filter {
    width: 92px !important;
  }

  .modal {
    padding: 12px;
  }

  .modal-card {
    max-height: 88vh;
  }
}
