/* ============================================================
 * 神经网络演示网页 · 深色主题（配色参考 coze_gen / GitHub Dark）
 * 表格优化范式保留自 DataVisualPlatform
 * ============================================================ */
:root {
  --bg-deep: #0d1117;
  --bg-surface: #161b22;
  --bg-elevated: #21262d;
  --bg-hover: #30363d;
  --border: #30363d;
  --border-subtle: #21262d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent-blue: #58a6ff;
  --accent-purple: #bc8cff;
  --accent-cyan: #39c5cf;
  --accent-green: #3fb950;
  --accent-orange: #f0883e;
  --accent-red: #f85149;
  --accent-yellow: #e3b341;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .45);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(88,166,255,.08), transparent 60%), var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
.app { display: flex; flex-direction: column; min-height: 100vh; }

/* ---------- 顶部 ---------- */
.topbar {
  background: var(--bg-surface); color: var(--text-primary);
  padding: 16px 28px; display: flex; align-items: center; gap: 16px;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 16px rgba(0,0,0,.35);
}
.topbar .logo { font-size: 30px; }
.topbar h1 { font-size: 1.5rem; letter-spacing: .5px; }
.topbar .en { font-size: 1rem; opacity: .75; font-weight: 400; }
.topbar .tag {
  margin-left: auto; font-size: 12px; background: rgba(88,166,255,.12);
  color: var(--accent-blue); border: 1px solid rgba(88,166,255,.25);
  padding: 6px 12px; border-radius: 999px;
}

/* ---------- 布局 ---------- */
.layout { display: flex; flex: 1; gap: 18px; padding: 18px; max-width: 1500px; margin: 0 auto; width: 100%; }

/* 侧边导航 */
.sidebar {
  width: 250px; flex-shrink: 0;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; align-self: flex-start;
  position: sticky; top: 18px; max-height: calc(100vh - 36px); overflow: auto;
}
.sidebar .cat { margin-bottom: 14px; }
.sidebar .cat-title {
  font-size: 12px; font-weight: 800; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px; margin: 6px 4px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: 9px; cursor: pointer;
  font-size: 14px; color: var(--text-primary); margin-bottom: 4px;
  border: 1px solid transparent; transition: all .15s;
}
.nav-item:hover { background: var(--bg-hover); border-color: var(--border); }
.nav-item.active { background: var(--accent-blue); color: #0d1117; font-weight: 700; box-shadow: 0 4px 14px rgba(88,166,255,.35); }
.nav-item .badge { margin-left: auto; font-size: 10px; background: var(--bg-hover); color: var(--text-muted); padding: 1px 7px; border-radius: 999px; }
.nav-item.active .badge { background: rgba(13,17,23,.18); color: #0d1117; }
.nav-item.soon { color: var(--text-muted); cursor: default; }
.nav-item.soon:hover { background: transparent; border-color: transparent; }

/* 主内容 */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px;
}
.card h2 { color: var(--text-primary); margin-bottom: 4px; font-size: 1.3rem; }
.card .desc { color: var(--text-secondary); font-size: 13.5px; line-height: 1.7; margin: 10px 0 16px; }
.formula {
  background: var(--bg-elevated); border-left: 4px solid var(--accent-blue);
  border-radius: 6px; padding: 10px 14px; font-size: 14px;
  font-family: 'Consolas', 'Monaco', monospace; color: var(--text-primary);
  margin-bottom: 16px; overflow-x: auto;
}

/* ---------- 控件 ---------- */
.controls { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: flex-end; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--text-secondary); }
.field input[type=number], .field select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-elevated); color: var(--text-primary);
  font-size: 14px; font-family: inherit; min-width: 90px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent-blue); }
.btn {
  border: none; border-radius: 9px; padding: 10px 20px;
  font-size: 14px; font-weight: 700; cursor: pointer; transition: all .15s;
  font-family: inherit;
}
.btn-primary { background: var(--accent-blue); color: #0d1117; }
.btn-primary:hover { background: #79c0ff; transform: translateY(-1px); }
.btn-ghost { background: var(--bg-hover); color: var(--accent-blue); }
.btn-ghost:hover { background: var(--border); }
.btn:active { transform: scale(.97); }

/* ---------- 矩阵编辑器 ---------- */
.mat-grid { display: inline-grid; gap: 4px; margin: 4px 0; }
.mat-grid input {
  width: 54px; height: 38px; text-align: center; font-size: 14px;
  border: 1px solid var(--border); border-radius: 7px; background: var(--bg-elevated);
  color: var(--text-primary); font-family: 'Consolas', monospace;
}
.mat-grid input:focus { outline: none; border-color: var(--accent-blue); box-shadow: 0 0 0 2px rgba(88,166,255,.25); }
.mat-block { display: flex; align-items: center; gap: 14px; margin: 8px 0 14px; }
.mat-block .mat-label { font-weight: 700; color: var(--text-primary); font-size: 14px; min-width: 64px; }
.mat-block .mat-op { font-size: 20px; color: var(--accent-blue); font-weight: 800; }

/* ---------- 结果区 ---------- */
.result-head { display: flex; align-items: center; gap: 10px; margin: 18px 0 8px; }
.result-head h3 { color: var(--text-primary); font-size: 1.05rem; }
.result-head .pill {
  font-size: 11px; background: rgba(63,185,80,.14); color: var(--accent-green);
  border: 1px solid rgba(63,185,80,.3); padding: 2px 10px; border-radius: 999px;
}

/* ---------- 表格优化（源自 DataVisualPlatform，适配深色） ---------- */
.table-wrap {
  overflow-x: auto; border: 1px solid var(--border);
  border-radius: 10px; margin: 8px 0 18px; max-height: 460px;
}
table.nn {
  border-collapse: collapse; width: 100%; font-size: 13px; background: var(--bg-surface);
}
table.nn thead th {
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(180deg, var(--bg-elevated), var(--bg-surface));
  color: var(--accent-blue); font-weight: 700; padding: 10px 12px; text-align: center;
  white-space: nowrap; border-right: 1px solid var(--border);
  border-bottom: 2px solid var(--accent-blue);
}
table.nn tbody td {
  padding: 9px 12px; text-align: center; border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle); white-space: nowrap; color: var(--text-primary);
}
table.nn tbody td:first-child {
  font-weight: 700; color: var(--accent-blue); background: var(--bg-elevated); text-align: left;
}
table.nn tbody td:last-child { border-right: none; }
table.nn tbody tr:nth-child(even) { background: rgba(255,255,255,.03); }
table.nn tbody tr:hover { background: rgba(88,166,255,.10); }
table.nn tbody tr:hover td { background: transparent; }
table.nn tbody tr:hover td:first-child { background: rgba(88,166,255,.14); }
/* 数值单元格：等宽、右对齐 */
table.nn td.num { text-align: right; font-family: 'Consolas', 'Monaco', monospace; color: var(--text-primary); }
table.nn td.label-cell { font-weight: 700; color: var(--text-secondary); text-align: left; }
/* 热力图单元格 */
table.nn td.heat { font-weight: 600; font-family: 'Consolas', monospace; }
/* 滚动条美化 */
.table-wrap::-webkit-scrollbar { width: 9px; height: 9px; }
.table-wrap::-webkit-scrollbar-track { background: var(--bg-deep); border-radius: 6px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 6px; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: #484f58; }

.note { font-size: 13px; color: var(--text-secondary); line-height: 1.7; margin: 4px 0 12px; }
.note b { color: var(--text-primary); }

/* 注意力可视化（节点图） */
.att-flow { display: flex; gap: 30px; flex-wrap: wrap; align-items: center; margin: 10px 0 18px; }
.att-col { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.att-node {
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elevated); border: 2px solid var(--accent-blue); color: var(--text-primary);
  font-weight: 700; font-size: 13px;
}
.att-arrow { font-size: 22px; color: var(--accent-blue); }

/* ---------- 响应式 ---------- */
@media (max-width: 980px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; position: static; max-height: none; }
}
