/* 字体定义与变量 */
@font-face {
  font-family: 'GoogleSansCode';
  src: url('./fonts/GoogleSansCode-VariableFont_MONO,wght.ttf') format('truetype-variations'),
       url('./fonts/GoogleSansCode-VariableFont_MONO,wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #ffffff;
  --text-main: #000000;
  --text-sub: #666666;
  --text-faint: #999999;
  --line: #e0e0e0;
  --line-subtle: #f0f0f0;
  --row-hover: #f5f5f5;
  --row-active: #ebebeb;
  --font-mono: 'GoogleSansCode', Menlo, Monaco, Consolas, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bar-height: 28px;
}

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

::selection {
  background: #000000;
  color: #ffffff;
}

html, body {
  background: var(--bg);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 24px 32px;
}

/* 顶部系统条：严格对齐基线与统一交互尺寸 */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand-text {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-main);
  white-space: nowrap;
}

nav.nav-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-tab-btn {
  height: var(--bar-height);
  padding: 0 10px;
  font-size: 12px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-sub);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  border-radius: 2px;
  white-space: nowrap;
  transition: all 0.1s ease;
}

.nav-tab-btn:hover {
  color: var(--text-main);
  background: var(--line-subtle);
}

.nav-tab-btn.active {
  color: var(--text-main);
  border-color: var(--line);
  background: #ffffff;
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-sub);
}

.telemetry-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: 4px;
}

.telemetry-inline span strong {
  font-weight: 500;
  color: var(--text-main);
}

/* 按钮与下拉列表统一尺寸与高度对齐 */
.action-btn {
  height: var(--bar-height);
  padding: 0 10px;
  font-size: 11px;
  font-family: inherit;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  user-select: none;
  line-height: 1;
}

.action-btn:hover {
  background: var(--line-subtle);
  border-color: #999;
}

.action-btn:active {
  background: var(--line);
}

select.native-select {
  height: var(--bar-height);
  padding: 0 8px;
  font-size: 11px;
  font-family: var(--font-sans);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--text-main);
  cursor: pointer;
  outline: none;
  line-height: 1;
}

select.native-select:hover {
  border-color: #999;
}

/* 视图容器 */
.view-container {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.page-view {
  display: none;
  flex: 1;
  flex-direction: column;
}

.page-view.active {
  display: flex;
}

/* 视图 1：时钟页 */
.view-clock {
  justify-content: center;
  margin: 60px 0 40px;
}

.time-wrapper {
  display: flex;
  align-items: baseline;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 350;
  letter-spacing: -0.04em;
  line-height: 0.9;
  user-select: none;
  flex-wrap: nowrap;
}

.time-primary {
  font-size: clamp(48px, 15vw, 190px);
  color: var(--text-main);
}

.time-fraction {
  font-size: clamp(20px, 5.5vw, 68px);
  color: var(--text-faint);
  margin-left: 12px;
  letter-spacing: -0.02em;
}

.date-row {
  margin-top: 24px;
  font-size: clamp(13px, 1.8vw, 18px);
  color: var(--text-sub);
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.cur-tz-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-main);
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 2px;
}

/* 时区条 */
.tz-strip {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tz-flex-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  font-size: 12px;
}

.tz-link-item {
  color: var(--text-sub);
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
}

.tz-link-item:hover {
  color: var(--text-main);
}

.tz-link-item.active {
  color: var(--text-main);
  border-bottom-color: var(--text-main);
  font-weight: 500;
}

.tz-select-inline {
  margin-left: auto;
}

select.tz-picker {
  height: var(--bar-height);
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #ffffff;
  padding: 0 8px;
  font-size: 11px;
  font-family: var(--font-sans);
  color: var(--text-main);
  cursor: pointer;
  outline: none;
}

select.tz-picker:hover {
  border-color: #999;
}

/* 视图 2：延迟检测与 15 个节点列表 */
.view-latency {
  padding: 28px 0 20px;
}

.table-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
  gap: 12px;
}

.table-main-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.table-desc-text {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 2px;
}

.table-state-indicator {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-sub);
  white-space: nowrap;
}

.table-scroll-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.node-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 580px;
}

.node-table th {
  text-align: left;
  padding: 8px 10px;
  font-weight: 500;
  color: var(--text-sub);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  white-space: nowrap;
}

.node-table th.num-col,
.node-table td.num-col {
  text-align: right;
  font-family: var(--font-mono);
}

.node-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--line-subtle);
  color: var(--text-main);
  white-space: nowrap;
}

.node-table tr {
  cursor: pointer;
}

.node-table tr:hover td {
  background: var(--row-hover);
}

.node-table tr.is-active td {
  background: var(--row-active);
  font-weight: 500;
}

.node-name {
  font-family: var(--font-mono);
}

.latency-val.fast {
  font-weight: 600;
}

.status-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #ffffff;
  color: var(--text-sub);
}

.status-badge.active {
  background: var(--text-main);
  border-color: var(--text-main);
  color: #ffffff;
}

/* 全屏沉浸模式浮层与状态 */
.fullscreen-exit-btn {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--text-main);
  padding: 6px 14px;
  font-size: 11px;
  font-family: var(--font-sans);
  cursor: pointer;
  border-radius: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  z-index: 1000;
}

.fullscreen-exit-btn:hover {
  border-color: #000000;
}

body.fullscreen-mode {
  padding: 24px;
  justify-content: center;
}

body.fullscreen-mode header,
body.fullscreen-mode .tz-strip {
  display: none !important;
}

body.fullscreen-mode .fullscreen-exit-btn {
  display: block;
}

body.fullscreen-mode .view-clock {
  margin: 0;
  align-items: center;
  text-align: center;
}

body.fullscreen-mode .time-wrapper {
  justify-content: center;
}

body.fullscreen-mode .date-row {
  justify-content: center;
}

/* 移动端与窄屏适配优化 */
@media (max-width: 820px) {
  body {
    padding: 16px 14px;
  }

  header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding-bottom: 12px;
  }

  .header-left {
    justify-content: space-between;
    width: 100%;
  }

  .header-right {
    flex-wrap: wrap;
    justify-content: space-between;
    width: 100%;
    gap: 6px 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line-subtle);
  }

  .telemetry-inline {
    width: 100%;
    justify-content: space-between;
    margin-right: 0;
    margin-bottom: 2px;
  }

  .header-right .action-btn,
  .header-right select.native-select {
    flex: 1 1 auto;
    font-size: 11px;
  }

  .view-clock {
    margin: 36px 0 24px;
  }

  .time-wrapper {
    flex-wrap: wrap;
  }

  .time-fraction {
    margin-left: 0;
    width: 100%;
    margin-top: 2px;
  }

  .tz-flex-wrap {
    gap: 6px 12px;
  }

  .tz-select-inline {
    margin-left: 0;
    width: 100%;
    margin-top: 4px;
  }

  select.tz-picker {
    width: 100%;
  }

  .table-header-bar {
    flex-direction: column;
    gap: 4px;
  }

  .node-table {
    min-width: 520px;
  }
}
