/* ── 南通 FMO 集群 · Apple 极简风格 ── */

@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-Regular.ttf") format("truetype");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-Medium.ttf") format("truetype");
  font-weight: 500; font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-Bold.ttf") format("truetype");
  font-weight: 700; font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-Thin.ttf") format("truetype");
  font-weight: 300; font-display: swap;
}

:root {
  --bg: #f5f5f7;
  --panel: #ffffff;
  --separator: rgba(0,0,0,.08);
  --text: #1d1d1f;
  --muted: #86868b;
  --accent: #0071e3;
  --accent-soft: rgba(0,113,227,.08);
  --green: #34c759;
  --red: #ff3b30;
  --radius-lg: 20px;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.05);
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC",
    "Hiragino Sans GB", "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* 强制 hidden 生效（防止 display:flex 等覆盖） */
[hidden] { display: none !important; }

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
}

/* ── 顶栏：毛玻璃 ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: rgba(245,245,247,.82);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--separator);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo {
  font-family: var(--mono); font-weight: 700; font-size: 15px;
  width: 40px; height: 40px; border-radius: 12px;
  background: #1d1d1f; color: #fff;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: .02em;
}
.brand h1 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.subtitle { font-size: 12px; color: var(--muted); font-weight: 400; letter-spacing: .02em; }

.status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted);
  background: rgba(0,0,0,.04);
  border: 1px solid var(--separator);
  padding: 6px 14px; border-radius: 999px;
  white-space: nowrap;
}
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: #c7c7cc; transition: background .3s; }
.status.online .dot { background: var(--green); }
.status.offline .dot { background: var(--red); }

/* ── 面板通用 ── */
.panel {
  background: var(--panel);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px 24px;
}
.panel-title {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; font-weight: 600; color: var(--muted);
  letter-spacing: .02em; margin-bottom: 18px;
}
.panel-tag {
  font-family: var(--mono);
  background: rgba(0,0,0,.04); padding: 2px 10px; border-radius: 999px;
  font-size: 11px; color: var(--muted);
}

/* 实时动态「查看详细」按钮 */
.tl-toggle {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(0,113,227,.2);
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  transition: background .2s, transform .15s, opacity .2s;
}
.tl-toggle:hover { background: rgba(0,113,227,.14); }
.tl-toggle:active { transform: scale(.96); }
.tl-toggle:disabled { opacity: .4; cursor: default; background: rgba(0,0,0,.04); color: var(--muted); border-color: transparent; }

/* ── 布局 ── */
.layout {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  gap: 20px;
  padding: 24px 32px 0;
  flex: 1;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}
.speaker-panel { flex: 1 1 0; max-width: 620px; min-width: 0; min-height: 440px; }
.right-col { flex: 0 0 320px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }

/* ── 说话人面板 ── */
.speaker-panel {
  position: relative; overflow: hidden;
  transition: border-color .3s, box-shadow .3s, transform .2s;
  min-height: 380px;
}
.speaker-panel.speaking {
  border-color: rgba(0,113,227,.35);
  box-shadow: 0 0 0 1px rgba(0,113,227,.25), 0 8px 32px rgba(0,113,227,.12);
}

/* 无人说话空状态 */
.speaker-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 300px; color: var(--muted);
}
.speaker-empty p { margin-top: 18px; font-size: 14px; letter-spacing: .02em; }
.idle-ring {
  width: 64px; height: 64px; border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,.12);
  position: relative;
  animation: ring 2.6s ease-in-out infinite;
}
.idle-ring::after {
  content: ""; position: absolute; inset: 12px; border-radius: 50%;
  background: rgba(0,0,0,.05);
}
@keyframes ring { 0%,100%{transform:scale(1);opacity:.55} 50%{transform:scale(1.06);opacity:1} }

.speaker { display: flex; flex-direction: column; align-items: center; padding: 24px 8px 10px; animation: fadeIn .35s ease; }
@keyframes fadeIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:none} }

.avatar {
  width: 84px; height: 84px; border-radius: 50%;
  background: linear-gradient(135deg, #0071e3, #5ac8fa);
  color: #fff; font-family: var(--mono); font-weight: 700; font-size: 32px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px rgba(0,113,227,.32);
  margin-bottom: 16px;
  letter-spacing: .02em;
}
.speaker-info { text-align: center; width: 100%; }
.callsign {
  font-family: var(--mono); font-weight: 700; font-size: 30px;
  letter-spacing: .04em;
}
.name { font-size: 13px; color: var(--muted); margin: 6px 0 0; min-height: 16px; }

.meta-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  width: 100%; max-width: 420px; margin: 16px auto 0;
}
.meta {
  background: var(--bg); border-radius: 14px; padding: 12px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.meta label { font-size: 11px; color: var(--muted); font-weight: 500; }
.meta span { font-family: var(--mono); font-size: 15px; font-weight: 500; }

/* 波形 */
.wavebox {
  width: 100%; max-width: 420px; height: 56px;
  margin: 18px auto 0;
  background: var(--bg); border-radius: 12px;
  padding: 6px;
}
.wavebox canvas { width: 100%; height: 100%; display: block; }

.meter {
  width: 100%; max-width: 420px; margin-top: 28px; height: 4px;
  border-radius: 2px; background: rgba(0,0,0,.06); overflow: hidden;
}
.meter-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--green), var(--accent));
  border-radius: 2px; transition: width .2s ease;
}

/* ── 设备列表 ── */
.devices-panel { max-height: 100%; }
.device-list { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }
.device {
  display: flex; align-items: center; gap: 12px;
  border-radius: 14px; padding: 10px 12px;
  transition: background .2s, border-color .2s;
  border: 1px solid transparent;
  position: relative;
}
.device:hover { background: rgba(0,0,0,.03); }
.device.active { background: var(--accent-soft); border-color: rgba(0,113,227,.2); }
.device .d-avatar {
  width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0;
  background: rgba(0,0,0,.05);
  font-family: var(--mono); font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center; color: var(--accent);
}
.device.active .d-avatar { background: var(--accent); color: #fff; }
.device .d-info { flex: 1; min-width: 0; }
.device .d-callsign { font-family: var(--mono); font-weight: 600; font-size: 13px; }
.device .d-sub { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device .d-state { font-family: var(--mono); font-size: 11px; font-weight: 500; flex-shrink: 0; }
.device .d-state.idle { color: var(--muted); }
.device .d-state.talking { color: var(--accent); }

/* TELE 上下行频率悬停提示 */
.d-tip-float {
  position: fixed; z-index: 9999;
  min-width: 168px;
  background: rgba(29,29,31,.92);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  color: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  animation: tipIn .15s ease;
}
@keyframes tipIn { from{opacity:0;transform:translateY(3px)} to{opacity:1;transform:none} }
.d-tip-float .tip-title { font-size: 12px; font-weight: 600; margin-bottom: 8px; letter-spacing: .01em; }
.d-tip-float .tip-body { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; }
.d-tip-float .tip-body span { font-size: 11px; color: rgba(255,255,255,.65); }
.d-tip-float .tip-body b { font-family: var(--mono); font-size: 12px; font-weight: 500; text-align: right; color: #5ac8fa; }

/* ── 时间线（卡片式）── */
.timeline-panel {
  display: flex; flex-direction: column;
  max-height: 320px;
  transition: max-height .3s ease;
}
.timeline-panel.expanded { max-height: 520px; }
.timeline {
  list-style: none; overflow-y: auto; flex: 1;
  -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 8px;
  padding: 2px;
}
.tl-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 12px;
  font-size: 12px;
  transition: transform .15s ease;
}
.tl-card:first-child {
  background: var(--accent-soft);
  border: 1px solid rgba(0,113,227,.15);
}
.timeline .t-time {
  font-family: var(--mono); color: var(--muted);
  font-variant-numeric: tabular-nums; flex-shrink: 0; font-size: 10px;
}
.timeline .t-tag {
  font-family: var(--mono); flex-shrink: 0; font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; letter-spacing: .04em;
}
.timeline .t-tag.rig { background: var(--accent-soft); color: var(--accent); }
.timeline .t-tag.tele { background: rgba(255,149,0,.14); color: #ff9500; }
.timeline .t-tag.sys { background: rgba(0,0,0,.05); color: var(--muted); }
.timeline .t-body {
  color: var(--text); flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── 页脚 ── */
.foot {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 24px 16px 28px; font-size: 11px; color: var(--muted);
  letter-spacing: .03em;
}
.foot a {
  color: inherit; text-decoration: none;
  transition: color .2s;
}
.foot a:hover { color: var(--accent); }
.foot-call {
  font-family: var(--mono); font-weight: 700; font-size: 15px;
  color: var(--text); letter-spacing: .05em;
}
.foot-icp {
  font-family: var(--mono); font-size: 11px;
  display: inline-flex; align-items: center; gap: 6px;
}
.foot-icp::before {
  content: ""; width: 14px; height: 14px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2386868b'><path d='M12 2C8.1 2 5 5.1 5 9v2.2c-1.2.6-2 1.9-2 3.3V16c0 2.2 1.8 4 4 4h10c2.2 0 4-1.8 4-4v-1.5c0-1.4-.8-2.7-2-3.3V9c0-3.9-3.1-7-7-7zm-3 13c0 .6-.4 1-1 1s-1-.4-1-1v-3c0-.6.4-1 1-1s1 .4 1 1v3zm8 0c0 .6-.4 1-1 1s-1-.4-1-1v-3c0-.6.4-1 1-1s1 .4 1 1v3z'/></svg>") no-repeat center;
  background-size: contain;
}
.foot-time { font-family: var(--mono); font-size: 10px; opacity: .7; }

/* ── 历史详情弹窗 ── */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.4);
  -webkit-backdrop-filter: saturate(140%) blur(6px);
  backdrop-filter: saturate(140%) blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--panel);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0,0,0,.2);
  width: 100%; max-width: 520px;
  max-height: 80vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modalIn .25s ease;
}
@keyframes modalIn { from{opacity:0;transform:translateY(12px) scale(.98)} to{opacity:1;transform:none} }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--separator);
  font-size: 14px; font-weight: 600;
}
.modal-close {
  font-size: 15px; width: 30px; height: 30px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.05); color: var(--muted);
  cursor: pointer; transition: background .2s;
}
.modal-close:hover { background: rgba(0,0,0,.1); }
.hist-list {
  list-style: none; overflow-y: auto; flex: 1;
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px 20px 20px;
  -webkit-overflow-scrolling: touch;
}

/* ── 滚动条 ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* ── 移动端适配 ── */
@media (max-width: 860px) {
  .layout { flex-direction: column; align-items: stretch; padding: 12px 12px 0; gap: 12px; }
  .right-col { flex: 1 1 auto; width: 100%; }
  .speaker-panel { flex: none; width: 100%; max-width: none; min-height: 320px; }
  .timeline-panel { margin: 0; width: auto; max-height: 260px; }
  .topbar { padding: 10px 14px; }
  .brand h1 { font-size: 15px; }
  .logo { width: 34px; height: 34px; font-size: 13px; border-radius: 10px; }
  .subtitle { display: none; }
  .panel { padding: 18px 16px; border-radius: 16px; }
  .avatar { width: 68px; height: 68px; font-size: 26px; }
  .callsign { font-size: 24px; }
  .name { font-size: 12px; }
  .meta-grid { max-width: none; }
  .wavebox { max-width: none; }
  .device-list { max-height: 260px; }
  .foot { padding: 16px; flex-wrap: wrap; gap: 8px; }

  /* 弹窗全屏化 */
  .modal-mask { padding: 0; align-items: flex-end; }
  .modal {
    max-width: none; max-height: 78vh;
    border-radius: 20px 20px 0 0;
    width: 100%;
  }
  .hist-list { padding: 12px 14px 20px; }
}
