* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f4f6fb; color: #22304a; min-height: 100vh;
}
a { color: inherit; text-decoration: none; }

/* 顶栏 */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 28px; background: #fff; box-shadow: 0 1px 4px rgba(30,50,90,.08);
}
.brand { font-size: 20px; font-weight: 700; color: #2b5cff; }
.brand .sub { font-size: 12px; color: #8a97b1; font-weight: 400; margin-left: 8px; }
.nav { display: flex; align-items: center; gap: 12px; font-size: 14px; flex-wrap: wrap; }
.nav a { color: #5a6a8a; padding: 6px 10px; border-radius: 6px; }
.nav a.active, .nav a:hover { background: #eef3ff; color: #2b5cff; }
.nav-short { display: none; }
.userbox { display: flex; align-items: center; gap: 10px; }
.hello { font-size: 14px; color: #333; }
.link { color: #e05555 !important; }

/* 按钮 */
.btn {
  border: none; cursor: pointer; border-radius: 8px; padding: 9px 18px;
  font-size: 14px; background: #e8edf7; color: #33405f; transition: .15s;
  display: inline-block; text-decoration: none; text-align: center;
}
.btn.primary { background: #2b5cff; color: #fff; }
.btn.primary:hover { background: #1f4ae0; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.danger { background: #ffe9e9; color: #d33; }
.btn.added { background: #e6f7ec; color: #1a9c53; }

/* 搜索栏 */
.searchbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  max-width: 1200px; margin: 22px auto 0; padding: 0 24px;
}
.searchbar input {
  flex: 1; min-width: 260px; padding: 11px 16px; font-size: 15px;
  border: 2px solid #d8e0f0; border-radius: 10px; outline: none; background: #fff;
}
.searchbar input:focus { border-color: #2b5cff; }
.switch { font-size: 13px; color: #5a6a8a; display: flex; align-items: center; gap: 4px; cursor: pointer; }
.toggles { display: flex; gap: 14px; align-items: center; }

/* 布局 */
.layout {
  display: grid; grid-template-columns: 380px 1fr; gap: 20px;
  max-width: 1200px; margin: 18px auto; padding: 0 24px 40px;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.card {
  background: #fff; border-radius: 14px; padding: 22px;
  box-shadow: 0 2px 10px rgba(30,50,90,.06); align-self: start;
}
.placeholder { color: #9aa7c2; text-align: center; padding: 60px 10px; line-height: 1.9; }

/* 单词卡片内容 */
.w-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.w-word { font-size: 34px; font-weight: 700; color: #1a2b52; }
.w-phon { color: #2b5cff; font-size: 16px; }
.w-speak {
  border: none; background: #eef3ff; color: #2b5cff; border-radius: 50%;
  width: 34px; height: 34px; cursor: pointer; font-size: 15px;
}
.w-speak:hover { background: #2b5cff; color: #fff; }
.tag {
  font-size: 12px; padding: 3px 10px; border-radius: 20px; font-weight: 600;
}
.tag.lv1 { background: #e6f7ec; color: #1a9c53; }
.tag.lv2 { background: #fff4e0; color: #d98a09; }
.tag.lv3 { background: #ffe9e9; color: #d33; }
.w-pos { color: #8a97b1; font-style: italic; font-size: 14px; }
.w-section { margin-top: 16px; }
.w-section h4 {
  font-size: 12px; color: #8a97b1; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px;
}
.w-section p { font-size: 15px; line-height: 1.7; }
.ja-text { color: #7a5cd0; }
.w-ety { font-size: 14px; color: #4a5a7a; line-height: 1.8; background: #f7f9fd; padding: 10px 12px; border-radius: 8px; }
.w-phx { font-size: 14px; color: #2a8a6a; }
.roots { margin-top: 6px; }
.roots span {
  display: inline-block; background: #eef3ff; color: #2b5cff;
  font-size: 12px; padding: 2px 9px; border-radius: 12px; margin-right: 6px;
}
.vocab-btn { margin-top: 18px; width: 100%; }
.notfound { color: #d33; }
.suggest { margin-top: 10px; font-size: 13px; color: #5a6a8a; }
.suggest a { color: #2b5cff; margin-right: 10px; cursor: pointer; }

/* 图谱 */
.graph-wrap {
  background: #fff; border-radius: 14px; padding: 16px;
  box-shadow: 0 2px 10px rgba(30,50,90,.06); position: relative; min-height: 560px;
}
.legend { font-size: 13px; color: #5a6a8a; display: flex; gap: 16px; align-items: center; padding: 4px 6px 10px; }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.dot.root { background: #4a7dff; } .dot.syn { background: #2fbf71; } .dot.ant { background: #ef5b6b; }
.dot.sem { background: #a855f7; } .dot.mix { background: #64748b; }
.legend .hint { margin-left: auto; color: #aab6cf; font-size: 12px; }
#graph { width: 100%; height: 560px; display: block; }

.graph-node { cursor: pointer; }
.graph-node circle { stroke: #fff; stroke-width: 2; transition: r .15s; }
.graph-node:hover circle { stroke: #2b5cff; }
.graph-node text { font-size: 24px; fill: #33405f; text-anchor: middle; pointer-events: none; font-weight: 600; }
.graph-node.center circle { fill: #2b5cff !important; }
.graph-node.center text { fill: #2b5cff; font-weight: 800; font-size: 28px; }
.edge { stroke: #c8d3e8; stroke-width: 1.2; }
.edge.root { stroke: #b8cfff; } .edge.syn { stroke: #a9e8c5; } .edge.ant { stroke: #f5b6bf; stroke-dasharray: 4 3; }
.edge.sem { stroke: #e0c8f5; } .edge.mix { stroke: #d4dbe6; stroke-dasharray: 2 3; }

/* 登录页 */
.auth-wrap { max-width: 380px; margin: 60px auto; background: #fff; padding: 32px; border-radius: 14px; box-shadow: 0 4px 20px rgba(30,50,90,.08); }
.auth-wrap h2 { margin-bottom: 20px; color: #1a2b52; }
.auth-wrap input { width: 100%; padding: 10px 14px; margin-bottom: 12px; border: 2px solid #d8e0f0; border-radius: 8px; font-size: 14px; outline: none; }
.auth-wrap input:focus { border-color: #2b5cff; }
.auth-wrap .btn { width: 100%; }
.auth-msg { margin-top: 12px; font-size: 13px; min-height: 18px; }
.auth-msg.err { color: #d33; } .auth-msg.ok { color: #1a9c53; }
.auth-switch { text-align: center; margin-top: 14px; font-size: 13px; color: #8a97b1; }
.auth-switch a { color: #2b5cff; cursor: pointer; }

/* 生词本表格 */
.vocab-table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.vocab-table th, .vocab-table td { padding: 11px 12px; border-bottom: 1px solid #eef1f8; text-align: left; font-size: 14px; }
.vocab-table th { color: #8a97b1; font-weight: 600; font-size: 12px; }
.vocab-table td .w { font-weight: 700; color: #1a2b52; cursor: pointer; }
.vocab-table td .w:hover { color: #2b5cff; }
.filter-bar { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.filter-bar .btn.active { background: #2b5cff; color: #fff; }
.empty { text-align: center; color: #9aa7c2; padding: 50px 0; }

/* 日语发音按钮 */
.w-speak.ja { background: #f0e9ff; color: #7a5cd0; }
.w-speak.ja:hover { background: #7a5cd0; color: #fff; }
.ja-speak-hint { font-size: 11px; color: #b0a0e0; font-weight: 400; margin-left: 6px; }

/* 相关匹配列表 */
.extra-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.extra-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; background: #f7f9fd; border-radius: 8px; font-size: 14px;
  cursor: pointer; transition: .15s;
}
.extra-item:hover { background: #eef3ff; }
.extra-item b { color: #1a2b52; }
.extra-item .zh { color: #8a97b1; font-size: 13px; }

/* ===== 学习专题页 ===== */
.learn-tabs { display: flex; gap: 10px; margin: 20px auto 0; max-width: 1200px; padding: 0 24px; flex-wrap: wrap; }
.learn-tab {
  padding: 10px 20px; border-radius: 10px; background: #fff; cursor: pointer;
  font-size: 15px; color: #5a6a8a; box-shadow: 0 1px 4px rgba(30,50,90,.06); border: 2px solid transparent;
}
.learn-tab.active { background: #2b5cff; color: #fff; border-color: #2b5cff; }
.learn-panel { display: none; max-width: 1200px; margin: 20px auto 40px; padding: 0 24px; }
.learn-panel.active { display: block; }
.learn-panel h3 { color: #1a2b52; margin: 20px 0 12px; font-size: 17px; }
.learn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 10px; }
.learn-chip {
  background: #fff; border-radius: 10px; padding: 12px 8px; text-align: center;
  cursor: pointer; box-shadow: 0 1px 4px rgba(30,50,90,.06); transition: .15s;
  border: 2px solid transparent;
}
.learn-chip:hover { border-color: #2b5cff; transform: translateY(-2px); }
.learn-chip .sym { font-size: 26px; font-weight: 700; color: #1a2b52; display: block; }
.learn-chip .romaji { font-size: 12px; color: #8a97b1; margin-top: 2px; display: block; }
.learn-chip .example { font-size: 11px; color: #2b5cff; margin-top: 2px; display: block; }
.gojuon-table { width: 100%; border-collapse: separate; border-spacing: 6px; }
.gojuon-table td { text-align: center; }
.learn-note { background: #f7f9fd; padding: 12px 16px; border-radius: 10px; color: #5a6a8a; font-size: 14px; line-height: 1.8; margin-bottom: 16px; }

/* AI 解读 */
.ai-loading { margin-top: 16px; padding: 16px; background: #f0f4ff; border-radius: 10px; color: #2b5cff; font-size: 14px; text-align: center; }
.ai-err { margin-top: 12px; padding: 12px; background: #fff0f0; border-radius: 10px; color: #ef5b6b; font-size: 13px; }
.tag.ai-tag { background: #f3e8ff; color: #a855f7; border: 1px solid #e0c8f5; }

/* ===== 移动端适配 ===== */
@media (max-width: 640px) {
  .topbar { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .brand { font-size: 16px; }
  .brand .sub { display: none; }
  .nav { gap: 6px; font-size: 13px; width: 100%; justify-content: space-between; }
  .nav a { padding: 5px 8px; }
  .nav-full { display: none !important; }
  .nav-short { display: inline !important; }
  .searchbar { padding: 0 14px; gap: 8px; margin-top: 14px; }
  .searchbar input { min-width: 0; font-size: 14px; padding: 10px 12px; }
  .searchbar .btn { padding: 8px 12px; font-size: 13px; }
  .toggles { gap: 10px; width: 100%; justify-content: flex-end; }
  .layout { padding: 0 14px 30px; gap: 14px; }
  .card { padding: 16px; border-radius: 12px; }
  .w-word { font-size: 26px; }
  .w-speak { width: 30px; height: 30px; font-size: 13px; }
  .graph-wrap { padding: 8px; min-height: 400px; }
  #graph { height: 400px; }
  .graph-node text { font-size: 16px; }
  .graph-node.center text { font-size: 20px; }
  .vocab-table th, .vocab-table td { padding: 8px 6px; font-size: 13px; }
  .learn-tabs { padding: 0 14px; }
  .learn-panel { padding: 0 14px; }
}

/* ===== 图谱节点美化（扁平现代风） ===== */
.graph-node circle {
  stroke: #fff; stroke-width: 3;
  transition: transform .15s;
}
.graph-node:hover circle { stroke: #2b5cff; stroke-width: 3.5; }
.graph-node text {
  font-size: 14px; fill: #33405f; text-anchor: middle;
  pointer-events: none; font-weight: 600;
  paint-order: stroke; stroke: #fff; stroke-width: 4; stroke-linejoin: round;
}
.graph-node.center circle { fill: #2b5cff; }
.graph-node.root circle { fill: #4a7dff; }
.graph-node.syn circle { fill: #2fbf71; }
.graph-node.ant circle { fill: #ef5b6b; }
.graph-node.sem circle { fill: #a855f7; }
.graph-node.center text { font-size: 18px; font-weight: 800; fill: #fff; stroke: none; }
