:root {
  /* Color Palette */
  --color-text: #f3f4ff;
  --color-muted: #8f95b2;
  --color-link: #3f82ff;
  --color-primary: #2a72f8;
  --color-link-t-20: rgba(63,130,255,0.2);
  --color-link-t-30: rgba(63,130,255,0.3);
  --color-link-t-60: rgba(63,130,255,0.6);
  --color-success: #44ff44;
  --color-orange-light: #ff9944;
  --color-danger: #ff4444;
  --color-fail: #ef4444;
  --color-yellow: #ffaa00;
  --color-warning: #ff6600;
  --toast-bg: #10b981;

  /* Backgrounds */
  --bg-body: #0b1020;
  --bg-header-footer: #0d1220;
  --bg-surface-1: #151a2c;
  --bg-surface-2: #1a202c;
  --bg-surface-tested: #1e2a3a;
  --bg-overlay: rgba(0,0,0,0.2);
  --bg-disabled: #3a3f55;

  /* Borders */
  --border-strong: 1px solid #252b41;
  --border-light: 1px solid rgba(255,255,255,0.08);
  --border-medium: 1px solid rgba(255,255,255,0.1);

  /* Radii & Transitions */
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --radius-full: 999px;
  --transition-fast: all 0.2s;
}

/* ==================== Base & Global ==================== */
body {
  background: var(--bg-body); color: var(--color-text);
  font-family: system-ui, sans-serif;
  padding: 0; margin: 0;
  overflow-x: hidden;
}
a { text-decoration: none; transition: var(--transition-fast); }
h1 { font-size: 28px; margin: 4px 0 4px 0; line-height: 1.2; color: var(--color-success); }
h1 span { color: var(--color-text); }
p { line-height: 1.7; letter-spacing: 0.02em; margin: 12px 0 0 0; }

/* ==================== Utility Classes ==================== */
/* Typography */
.color-muted { color: var(--color-muted); }
.color-link { color: var(--color-link); }
.color-success { color: var(--color-success); }
.color-orange-light { color: var(--color-orange-light); }
.color-danger { color: var(--color-danger); }
.color-yellow { color: var(--color-yellow); }
.color-warning { color: var(--color-warning); }
.color-primary { color: var(--color-primary); }
.font-bold { font-weight: bold; }
.font-semibold { font-weight: 600; }
.text-12 { font-size: 12px; }
.text-12-muted { font-size: 12px; color: var(--color-muted); }
.text-13 { font-size: 13px; }
.text-14 { font-size: 14px; }
.text-16 { font-size: 16px; }
.text-18 { font-size: 18px; }
.text-48 { font-size: 48px; }
.text-left { text-align: left; }
.text-center { text-align: center; }
.whitespace-nowrap { white-space: nowrap; }

/* ==================== Components ==================== */

/* Layout */
.container, .header-content, .footer-content { max-width: 1080px; margin: 0 auto; width: calc(100% - 20px); }
.risk-score, .info-item, .site-tools, .footer-links { display: flex; align-items: center; }
/* Spacing */
.info-item > *:not(:last-child) { margin-right: 6px; }
.risk-score > *:not(:last-child) { margin-right: 10px; }
.footer-links > *:not(:last-child) { margin-right: 20px; }

.page-header {
  position: -webkit-sticky; position: sticky; top: 0; z-index: 100;
  background: rgba(13, 18, 32, 0.95);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: var(--border-strong);
  padding: 12px 0;
  width: 100%;
}
.site-footer { background: var(--bg-header-footer); border-top: var(--border-strong); padding: 20px 0; margin-top: 25px; }
.header-content, .footer-content { display: flex; align-items: center; justify-content: space-between; }

.site-name { font-size: 18px; line-height: 1; font-weight: bold; display: flex; align-items: center; color: var(--color-muted); }
.site-name:hover { color: var(--color-link); }
.site-name > *:not(:last-child) { margin-right: 8px; }

.header-link { padding: 6px 12px; border-radius: var(--radius-sm); color: var(--color-muted); font-size: 14px; white-space: nowrap; }
.header-link:hover { background: rgba(63,130,255,0.1); color: var(--color-text); }

.footer-content a, .footer-copyright { font-size: 13px; color: var(--color-muted); }
.footer-content a:hover { color: var(--color-link); }

.subtitle { margin-bottom:20px; color: var(--color-muted); }
.card { background: var(--bg-surface-1); border: var(--border-strong); border-radius: var(--radius-lg); padding:16px; margin-bottom:20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; }
.card-header > *:not(:last-child) { margin-right: 10px; }
.card-title { font-size:24px; font-weight: bold; margin: 0; }
.card-title span { color: var(--color-muted); padding: 0 8px; }

.meta { color: var(--color-muted); margin-bottom:12px; }
.meta-bold { font-weight: bold; margin-top: 6px; }

/* Table */
table { width:100%; border-collapse:collapse; margin-top:10px; font-size: 13px; }
th, td { padding:8px; border-bottom: var(--border-light); }
th:first-child { white-space: nowrap; }
th { text-align:left; color: var(--color-muted); }

/* 表格收起/展开 */
.toggleable-row { display: none; }
.toggleable-row.visible { display: table-row; }
.toggle-btn {
  display: block;
  width: 100%;
  padding: 3px 0;
  background: var(--bg-surface-2);
  border: none;
  color: var(--color-link);
  cursor: pointer;
  font-size: 11px;
  text-align: center;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  transition: var(--transition-fast);
}
.toggle-btn:hover { background: var(--bg-overlay); }

/* Button */
.btn { background: var(--color-link-t-20); border:1px solid var(--color-link-t-60); padding:4px 8px;
  border-radius: var(--radius-sm); color: var(--color-text); cursor:pointer; flex-shrink: 0;
  font-size: 14px; white-space: nowrap; transition: var(--transition-fast); position: relative; }
.btn .unicode-symbol { display: inline-block; transform: scale(1.14); }
.btn:hover:not(:disabled) { background: var(--color-link-t-30); }
.btn:disabled { background: var(--bg-disabled); border-color: var(--bg-disabled); cursor: wait; color: var(--color-muted); }
.btn-mask { position: absolute; inset: 0; border: inherit; border-radius: inherit; display: flex; align-items: center;
  justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.2s; background: var(--bg-disabled); }
.btn.loading .btn-mask { opacity: 1; pointer-events: auto; }
.btn-small { padding: 2px 6px; font-size: 12px; }

/* IP Address Specific */
.ipv6-break { word-break: break-all; overflow-wrap: break-word; }
#main-ip { font-size: 24px; white-space: nowrap; }
#main-ip.ipv6 { font-size: max(13px, min(4.2vw, 24px)); }
#cf-uag { max-width: 100%; word-break: break-word; white-space: normal; }

/* Speed Test Section */
.speed-card { display: flex; flex-direction: column; }
.speed-card > *:not(:last-child) { margin-bottom: 5px; }
.grid-cols-4p { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 15px; }
.card-sf2 { background: var(--bg-surface-2); border: var(--border-strong); border-radius: var(--radius-md); padding:12px; overflow: visible; }
.card-sf2.tested { background: var(--bg-surface-tested); }
.card-content { display: flex; justify-content: space-between; align-items: center; }
.card-sf2.card-content:hover { background: var(--bg-surface-tested); }
.card-content a:hover { text-decoration: underline; }
.card-content > *:not(:last-child) { margin-right: 10px; }
.left-content { display: flex; flex-direction: column; flex: 1; min-width: 0; overflow: hidden; }
.left-content > *:not(:last-child) { margin-bottom: 8px; }
.site-header { display: flex; align-items: center; min-width: 0; }
.site-header > *:not(:last-child) { margin-right: 6px; }
.favicon { width: 20px; height: 20px; object-fit: contain; flex-shrink: 0; }
.favicon.emoji { font-size: 18px; line-height: 20px; display: inline-flex; align-items: center; justify-content: center; }
.domain { font-weight: 600; color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.dots-container { display: flex; }
.dots-container > *:not(:last-child) { margin-right: 4px; }
.dot7 { width: 7px; height: 7px; background-color: rgba(255,255,255,0.15); flex-shrink: 0; border-radius: 50%; }
.stats-row { display: flex; flex-direction: column; flex-shrink: 0; justify-content: center; }
.stats-row > *:not(:last-child) { margin-bottom: 4px; }

/* Badge */
.badge { display: inline-flex; align-items: center; justify-content: space-between; padding: 2px 6px; border-radius: var(--radius-full); font-size: 11px; white-space: nowrap; }
.badge > *:not(:last-child) { margin-right: 3px; }
.badge-soft { background: rgba(255, 255, 255, 0.05); border: var(--border-medium); color: var(--color-muted); }
.badge-sm { border-radius: var(--radius-md); }
.dot6 { width: 6px; height: 6px; background-color: rgba(255,255,255,0.15); flex-shrink: 0; border-radius: 50%;}
.badge-value { font-family: monospace; font-weight: 600; text-align: right; min-width: 28px; }

/* Legend & Info */
.chart-guide, .area-bg-overlay { display: flex; align-items: center; background: var(--bg-overlay); border-radius: var(--radius-md); margin-top: 10px; }
.chart-guide { justify-content: center; padding: 12px; }
.chart-guide > *:not(:last-child) { margin-right: 20px; }
.area-bg-overlay { flex-wrap: wrap; margin-top: 12px; padding: 6px; }
.area-bg-overlay > * { margin: 6px; }

.dot10 { width: 10px; height: 10px; flex-shrink: 0; border-radius: 50%; }

.info-label { font-weight: 600; color: var(--color-muted); font-size: 12px; }
.info-value { color: var(--color-text); font-size: 12px; }

.dot7.bgc-blink { animation: blink 0.6s infinite; }
@keyframes blink {
  0%, 100% { opacity: 1; background: rgba(255,255,255,0.3); }
  50% { opacity: 0.3; background: rgba(255,255,255,0.1); }
}

/* Safari-specific override for symbol size */
@supports (-webkit-touch-callout: none) {
  .btn .unicode-symbol {
    display: inline-block; /* 必须，否则scale无效*/
    transform: scale(2) translateY(-0.1em);
  }
}

/* Background colors */
.bgc-success { background-color: var(--color-success); }
.bgc-primary { background-color: var(--color-primary); }
.bgc-yellow { background-color: var(--color-yellow); }
.bgc-warning { background-color: var(--color-warning); }
.bgc-fail { background-color: var(--color-fail); }

/* Layout */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

/* ========== Parking Page Specific Styles ========== */

.row-2-1 { grid-template-columns: 2fr 1fr !important; }

.intro-section { text-align: left; display: flex; flex-direction: column; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form input {
    width: 100%; box-sizing: border-box; padding: 8px 12px;
    border: var(--border-strong); border-radius: var(--radius-sm);
    color: var(--color-text); background: var(--bg-surface-2);
    font-size: 16px; /* iOS不自动放大的最小尺寸 */
    transition: var(--transition-fast);
}
.login-form input:focus { outline: none; border-color: var(--color-link-t-60); background: var(--bg-surface-1); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.w-full { width: 100%; }
.mt-4 { margin-top: 4px; } /* Tailwind同名异类 */
.mt-8 { margin-top: 8px; } /* Tailwind同名异类 */
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }

.btn-icon { background: none; border: none; color: var(--color-muted); cursor: pointer; padding: 0; transition: color 0.2s; }
.btn-icon:hover { color: var(--color-text); }
.btn-icon svg { vertical-align: middle; }
.icon-24 { width: 24px; height: 24px; }
.icon-20 { width: 20px; height: 20px; }

.toast {
    position: fixed;
    background: var(--toast-bg);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    z-index: 9999;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.modal-overlay {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 50;
    padding: 0 16px;
}
.modal-content { max-width: 28rem; width: 100%; transition: all 0.3s; transform: scale(0.95); opacity: 0; }
.modal-content.active { transform: scale(1); opacity: 1; }
.hidden { display: none !important; }

/* ========== Media Queries ========== */
@media (max-width: 1080px) {
  .grid-cols-4p { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .card-sf2 { padding: 10px; }
  .stats-row { flex-shrink: 1; min-width: 0; }
  .badge-value { min-width: 24px; }
}
@media (max-width: 800px) {
  .grid-cols-4p { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card-sf2 { padding: 8px; }
  .card-content > *:not(:last-child) { margin-right: 6px; }
  .left-content > *:not(:last-child) { margin-bottom: 6px; }
  .footer-content { flex-direction: column; text-align: center; }
  .footer-content > *:not(:last-child) { margin-bottom: 12px; }
}
@media (max-width: 600px) {
  .header-content > *:not(:last-child) { margin-right: 8px; }
  .chart-guide { padding: 10px; }
  .chart-guide > *:not(:last-child) { margin-right: 12px; }
  .area-bg-overlay { padding: 6px; }
  .area-bg-overlay > * { margin: 4px; }
}
@media (max-width: 540px) {
  .grid-cols-4p { grid-template-columns: 1fr; }
  .footer-copyright span:last-child { display: block; margin-top: 12px; }
  /* .footer-copyright a { font-size: 11px; } */
  .row-2-1 { grid-template-columns: 1fr !important; gap: 6px; } /* Parking - 特有样式 */
  .row-2-1 .card:first-child { margin-bottom: 12px; } /* Parking - 特有样式 */
}