/* ========================================
   Komari Theme · LeeYee — Anthropic 风格探针主题
   设计令牌、字体、颜色、间距照搬 eeeeeeeeeeee.ee 博客：
   · 暖象牙底 ivory-medium #F0EEE6 / 墨岩文本 slate-dark #141413
   · 赤陶 accent #C6613F（斜体强调 + 选区色 rgba(204,120,92,.5)）
   · Source Serif 4 衬线标题 + Inter 细节标签 + JetBrains Mono
   · 1px 细边框方角卡片 / 滚动细节标签 / 方角按钮
   卡片信息排版参考 vps.888888810.xyz（LeeGlass）
   ======================================== */

/* ═══════════ 1. 设计令牌（同 eeeeeeeeeeee.ee） ═══════════ */
:root {
  --ivory-light: #FAF9F5;
  --ivory-medium: #F0EEE6;
  --ivory-dark: #E8E6DC;
  --slate-dark: #141413;
  --slate-medium: #3D3D3A;
  --slate-light: #5E5D59;
  --cloud-dark: #87867F;
  --cloud-medium: #B0AEA5;
  --cloud-light: #D1CFC5;
  --accent: #C6613F;
  --accent-soft: rgba(198, 97, 63, .10);
  --warn: #9A6B1E;
  --crit: #B23A2A;
  --border: rgba(20, 20, 19, .12);
  --border-strong: rgba(20, 20, 19, .22);
  --serif: 'Source Serif 4', Georgia, 'Noto Serif SC', 'Songti SC', 'SimSun', serif;
  --sans: 'Inter', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease-word: cubic-bezier(.16, 1, .3, 1);
  --ease: cubic-bezier(.33, 1, .68, 1);
  --pad-inline: clamp(1.5rem, 5vw, 4.5rem);
  --header-bg: rgba(240, 238, 230, .9);
  --shadow-hover: 0 24px 48px -24px rgba(20, 20, 19, .18);
}

/* ═══════════ 暗色模式（暖墨岩底 + 象牙文字 + 亮赤陶） ═══════════ */
html.dark {
  --ivory-light: #232220;
  --ivory-medium: #1B1A18;
  --ivory-dark: #2C2B28;
  --slate-dark: #F0EEE6;
  --slate-medium: #D8D6CD;
  --slate-light: #B0AEA5;
  --cloud-dark: #87867F;
  --cloud-medium: #5E5D59;
  --cloud-light: #3D3D3A;
  --accent: #D97757;
  --accent-soft: rgba(217, 119, 87, .16);
  --warn: #D9A441;
  --crit: #E0654F;
  --border: rgba(240, 238, 230, .12);
  --border-strong: rgba(240, 238, 230, .24);
  --header-bg: rgba(27, 26, 24, .88);
  --shadow-hover: 0 24px 48px -24px rgba(0, 0, 0, .6);
}

/* ═══════════ 2. Reset & Base ═══════════ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

button { font: inherit; }

html { scroll-behavior: smooth; scroll-padding-top: 96px; }

/* 隐藏右侧滚动条（保留滚动功能） */
html { scrollbar-width: none; -ms-overflow-style: none; }
html::-webkit-scrollbar { width: 0; height: 0; display: none; }

body {
  font-family: var(--serif);
  font-size: 16px; line-height: 1.65;
  color: var(--slate-medium);
  background-color: var(--ivory-medium);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}

::selection { background: rgba(204, 120, 92, .5); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--slate-dark); outline-offset: 3px; }

#app { min-height: 100vh; display: flex; flex-direction: column; }

main, .header-inner, .footer-inner {
  width: min(100%, 72rem);
  margin-inline: auto;
  padding-inline: var(--pad-inline);
}
main { flex: 1; }

/* 细节标签：小号大写无衬线 */
.detail-label, .page-subtitle, footer p, .header-status {
  font-family: var(--sans); font-weight: 500;
  font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--cloud-dark);
}

/* ═══════════ 3. 导航（Logo + 链接 + 主题切换） ═══════════ */
header {
  position: sticky; top: 0; z-index: 40;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  transition: background-color .3s var(--ease), border-color .3s var(--ease);
}
.header-inner { display: flex; align-items: center; gap: 28px; height: 76px; }
.logo a {
  font-family: var(--serif); font-size: 20px; font-weight: 600;
  color: var(--slate-dark); text-decoration: none; letter-spacing: -.01em;
}
.header-right { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.header-status { margin-right: 12px; font-family: var(--mono); letter-spacing: .08em; }
nav { display: flex; align-items: center; gap: 4px; }
nav a {
  font-family: var(--sans); font-size: 14px; font-weight: 500;
  color: var(--slate-light); text-decoration: none;
  padding: 8px 12px; min-height: 44px; display: inline-flex; align-items: center;
  transition: color .3s var(--ease), background-color .3s var(--ease);
}
nav a:hover { color: var(--slate-dark); background: var(--ivory-dark); }
nav a.active { color: var(--slate-dark); background: var(--ivory-dark); }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border: 1px solid transparent;
  background: transparent; color: var(--slate-light);
  cursor: pointer;
  transition: color .3s var(--ease);
}
.theme-toggle:hover { color: var(--accent); }
.theme-toggle svg { width: 20px; height: 20px; }

/* ═══════════ 4. 区块头（赤陶编号 + 衬线标题 + 细线） ═══════════ */
.page-header {
  display: flex; align-items: baseline; gap: 0;
  margin-top: clamp(2.5rem, 5vw, 4rem);
  margin-bottom: clamp(2rem, 4vw, 3rem);
  background: linear-gradient(var(--border), var(--border)) no-repeat center / 100% 1px;
}
/* 编号（赤陶） */
.page-header::before {
  content: attr(data-sec);
  order: 1;
  font-family: var(--sans); font-weight: 500;
  font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
  background: var(--ivory-medium);
}
/* 标签文字（云灰） */
.page-header::after {
  content: attr(data-label);
  order: 2;
  font-family: var(--sans); font-weight: 500;
  font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--cloud-dark);
  white-space: nowrap;
  background: var(--ivory-medium);
  padding-left: .4em;
  padding-right: 20px;
}
.page-header h2 {
  order: 3;
  font-family: var(--serif); font-weight: 500;
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -.015em; color: var(--slate-dark);
  background: var(--ivory-medium);
  padding-right: 20px;
}
/* 强调字（赤陶斜体） */
.page-header h2 em { font-style: italic; color: var(--accent); }
.page-subtitle {
  order: 4;
  margin-left: auto;
  padding-left: 20px;
  white-space: nowrap;
  background: var(--ivory-medium);
}

/* ═══════════ 5. 加载与空状态 ═══════════ */
.loading-state, .empty-state {
  text-align: center;
  padding: 120px 0;
  color: var(--cloud-dark);
  font-size: 15px;
}
.loading-state p { font-family: var(--sans); animation: pulse 1.4s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.empty-state code {
  font-family: var(--mono); font-size: .85em;
  background: var(--ivory-dark); padding: .2em .45em;
  color: var(--slate-dark);
}

/* ═══════════ 6. 总览统计栏 / 分组筛选 ═══════════ */
.stats-card {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--ivory-light); border: 1px solid var(--border);
  margin-bottom: 24px;
  animation: rise .6s var(--ease-word) backwards;
}
.stat-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 18px 22px;
  border-left: 1px solid var(--border);
}
.stat-item:first-child { border-left: none; }
.stat-item strong {
  font-family: var(--serif); font-weight: 600; font-size: 26px;
  letter-spacing: -.01em; color: var(--slate-dark);
  font-variant-numeric: tabular-nums;
}
.stat-item strong small {
  font-family: var(--mono); font-size: 12px; font-weight: 400;
  color: var(--cloud-dark);
}

/* 分组标签（方角细边框，激活反白） */
.group-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.tab-btn {
  min-height: 36px; padding: 0 14px;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  color: var(--slate-dark); background: transparent;
  border: 1px solid var(--border-strong);
  cursor: pointer; user-select: none;
  transition: background-color .3s var(--ease), color .3s var(--ease), border-color .3s var(--ease);
}
.tab-btn:hover:not(.active) { background: var(--ivory-dark); }
.tab-btn.active { background: var(--slate-dark); color: var(--ivory-light); border-color: var(--slate-dark); }

/* ═══════════ 7. 节点网格（一排三个，1px 细边框方角卡片） ═══════════ */
.node-list {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px;
}

.node-card {
  display: flex; flex-direction: column; gap: 11px;
  min-width: 0;                 /* 防止长内容撑破网格列宽 */
  padding: 20px 22px 18px;
  text-decoration: none;
  color: inherit;
  background: var(--ivory-light); border: 1px solid var(--border);
  animation: rise .6s var(--ease-word) backwards;
  transition: box-shadow .4s var(--ease), transform .4s var(--ease), border-color .4s var(--ease), background-color .3s var(--ease), opacity .3s var(--ease);
}
.node-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.node-card:nth-child(3n+1) { animation-delay: .02s; }
.node-card:nth-child(3n+2) { animation-delay: .06s; }
.node-card:nth-child(3n) { animation-delay: .10s; }

.node-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
  border-color: var(--border-strong);
}
.node-card.offline { opacity: .55; }
.node-card.offline:hover { opacity: .85; }

/* 卡片头：状态点 + 国旗 + 名称 + 标签 */
.node-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.node-head .dot { width: 8px; height: 8px; background: var(--cloud-medium); flex: none; }
.node-card.online .node-head .dot { background: var(--accent); animation: pulse 2.2s var(--ease) infinite; }
.node-flag { font-size: 15px; line-height: 1; }
.node-name {
  font-family: var(--serif); font-weight: 600;
  font-size: 17.5px; letter-spacing: -.01em; line-height: 1.3;
  color: var(--slate-dark);
}

/* 标签（等宽字体 + 描边） */
.category-tag {
  font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .12em;
  color: var(--accent); border: 1px solid var(--accent); padding: 3px 10px;
}
.category-tag.tag-plain { color: var(--cloud-dark); border-color: var(--border-strong); }
.category-tag.tag-warn { color: var(--warn); border-color: var(--warn); }
.category-tag.tag-crit { color: var(--crit); border-color: var(--crit); }

.node-sub {
  font-size: 13.5px; color: var(--slate-light);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 三列指标：标签 + 百分比 / 用量条 / 用量明细 */
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 2px; }
.metric { min-width: 0; }
.metric-top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; margin-bottom: 5px; }
.m-label {
  font-family: var(--sans); font-size: 10.5px; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase; color: var(--cloud-dark);
}
.m-value {
  font-family: var(--mono); font-size: 11.5px; color: var(--slate-dark);
  font-variant-numeric: tabular-nums;
}
.meter {
  display: block; height: 6px;
  border: 1px solid var(--border-strong);
  background: var(--ivory-dark);
}
.meter > i {
  display: block; height: 100%; width: 0;
  background: var(--accent);
  transition: width .6s var(--ease);
}
.meter > i.warn { background: var(--warn); }
.meter > i.crit { background: var(--crit); }
.metric-sub {
  font-family: var(--mono); font-size: 10px; color: var(--cloud-dark);
  margin-top: 5px; min-height: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 卡片底部：网速 / 负载 / 运行时间 / 流量 */
.node-foot {
  display: flex; flex-wrap: wrap; gap: 5px 14px;
  padding-top: 11px;
  border-top: 1px solid var(--border);
  font-family: var(--mono); font-size: 11px; color: var(--slate-light);
}

/* ═══════════ 8. 节点详情 ═══════════ */
.node-detail { animation: rise .6s var(--ease-word) backwards; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.detail-meta {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: -12px 0 28px;
  font-family: var(--sans); font-size: 12px; letter-spacing: .06em;
  color: var(--cloud-dark);
}

/* 实时监控：四指标条 */
.metrics-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.metric-block {
  min-width: 0;
  background: var(--ivory-light); border: 1px solid var(--border);
  padding: 16px 18px;
}

/* 网络 / 流量小方块 */
.net-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.net-tile {
  min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--ivory-light); border: 1px solid var(--border);
  padding: 14px 18px;
}
.t-label {
  font-family: var(--sans); font-size: 10.5px; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase; color: var(--cloud-dark);
}
.t-value {
  font-family: var(--mono); font-size: 13px; color: var(--slate-dark);
  font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 面板 */
.panel { margin-top: 40px; animation: rise .6s var(--ease-word) backwards; }
.panel-title {
  display: flex; align-items: baseline; flex-wrap: wrap;
  font-family: var(--serif); font-weight: 600; font-size: 20px;
  letter-spacing: -.01em; color: var(--slate-dark);
  margin-bottom: 16px;
}
.panel-title em {
  font-family: var(--mono); font-style: normal; font-size: 11px; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); margin-left: 8px;
}

/* 图表时间范围切换 */
.range-btns { margin-left: auto; display: inline-flex; gap: 6px; flex-wrap: wrap; }
.tab-btn.small { min-height: 28px; padding: 0 10px; font-size: 12px; }

/* 信息网格（大写标签 + 值，两列） */
.info-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 36px;
  background: var(--ivory-light); border: 1px solid var(--border);
  padding: 6px 22px;
}
.info-item {
  display: flex; align-items: baseline; gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.info-item:last-child,
.info-item:nth-last-child(2):nth-child(odd) { border-bottom: none; }
.i-label {
  flex: none; width: 88px;
  font-family: var(--sans); font-size: 11px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--cloud-dark);
}
.i-value { color: var(--slate-medium); font-size: 14.5px; word-break: break-word; }

/* 图表 */
.chart {
  border: 1px solid var(--border);
  background: var(--ivory-light);
  padding: 18px 16px 12px;
}
.chart-svg { display: block; width: 100%; height: auto; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-line { fill: none; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-label {
  font-family: var(--mono); font-size: 9.5px;
  fill: var(--cloud-dark);
}
.chart-legend {
  display: flex; gap: 18px; margin-top: 10px;
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--cloud-dark);
}
.chart-legend i {
  display: inline-block; width: 8px; height: 8px;
  margin-right: 6px; vertical-align: 0;
}
.chart-empty {
  padding: 40px 0; text-align: center;
  font-family: var(--sans); font-size: 13px; color: var(--cloud-dark);
}

/* 详情底部返回链接 */
.article-footer { margin: 56px 0 0; padding-top: 28px; border-top: 1px solid var(--border); }
.back-link {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--sans); font-size: 13.5px; font-weight: 500;
  color: var(--slate-dark); text-decoration: none;
  transition: color .3s var(--ease);
}
.back-link:hover { color: var(--accent); }

/* ═══════════ 9. 页脚（细线 + 细节标签） ═══════════ */
footer {
  border-top: 1px solid var(--border);
  padding: 40px 0 56px;
  margin-top: clamp(4.5rem, 9vw, 7.5rem);
  transition: border-color .3s var(--ease);
}
footer p + p { margin-top: 6px; }
footer a {
  color: var(--cloud-dark);
  text-decoration: underline;
  text-underline-offset: .2em; text-decoration-thickness: .06em;
  transition: color .3s var(--ease);
}
footer a:hover { color: var(--accent); }
#footer-extra { margin-top: 10px; font-family: var(--sans); font-size: 13px; color: var(--slate-light); }

/* ═══════════ 10. Responsive ═══════════ */
@media (max-width: 1080px) {
  .node-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-card { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-item { border-top: 1px solid var(--border); }
  .stat-item:nth-child(-n+2) { border-top: none; }
  .stat-item:nth-child(odd) { border-left: none; }
}
@media (max-width: 900px) {
  .metrics-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .net-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .node-list { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .page-header { flex-wrap: wrap; row-gap: 12px; }
  .header-status { display: none; }
  .info-grid { grid-template-columns: 1fr; }
  .info-item:nth-last-child(2):nth-child(odd) { border-bottom: 1px solid var(--border); }
  .info-item:last-child { border-bottom: none; }
}

/* ═══════════ 11. Motion preferences ═══════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  html { scroll-behavior: auto; }
}
