:root {
  color-scheme: dark;
  --bg: #070b1a;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-2: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.12);
  --border-2: rgba(255, 255, 255, 0.2);
  --text: #e8edf7;
  --muted: #9aa6c0;
  --primary: #5aa9ff;
  --primary-strong: #2f7fd6;
  --primary-soft: rgba(90, 169, 255, 0.14);
  --radius: 14px;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.4);
  --glow: 0 0 18px rgba(90, 169, 255, 0.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  background:
    radial-gradient(1200px 720px at 82% -12%, rgba(90, 169, 255, 0.12), transparent 60%),
    radial-gradient(900px 640px at 8% 6%, rgba(150, 100, 255, 0.10), transparent 55%),
    linear-gradient(180deg, #070b1a 0%, #0a1026 58%, #070b1a 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

/* 星空画布：固定满屏，置于内容之下 */
#starfield {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

/* 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 22px;
  background: rgba(12, 18, 40, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}
.brand {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.5px;
  color: #fff;
  text-shadow: 0 0 20px rgba(90, 169, 255, 0.5);
}
.menu-btn {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  padding: 4px 10px;
  cursor: pointer;
  color: var(--text);
}
.search {
  margin-left: auto;
  width: 240px;
  max-width: 40vw;
  padding: 9px 12px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface-2);
  color: var(--text);
}
.search:focus { outline: none; border-color: var(--primary); box-shadow: var(--glow); background: rgba(255, 255, 255, 0.12); }
.search::placeholder { color: var(--muted); }

/* 布局 */
.layout { display: flex; align-items: stretch; min-height: calc(100vh - 120px); }

/* 侧边栏 */
.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: rgba(12, 18, 40, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  overflow-y: auto;
  max-height: calc(100vh - 120px);
  position: sticky;
  top: 57px;
}
.cat { margin-bottom: 18px; }
.cat-h {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0 10px 8px;
}
.cat-items { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; box-shadow: inset 0 0 0 1px rgba(90, 169, 255, 0.4); }

/* 主内容 */
#app { flex: 1; padding: 24px 28px; min-width: 0; }

.hero { margin-bottom: 26px; }
.hero h1 {
  font-size: 28px;
  margin: 0 0 8px;
  color: #fff;
  text-shadow: 0 0 26px rgba(90, 169, 255, 0.45);
}
.hero p { color: var(--muted); margin: 0; max-width: 640px; }

.cat-sec { margin-bottom: 28px; }
.cat-sec h2 { font-size: 18px; margin: 0 0 14px; color: #fff; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}
.card {
  display: block;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.card:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: var(--shadow), var(--glow); }
.card h3 { margin: 0 0 6px; font-size: 16px; color: #fff; }
.card p { margin: 0; color: var(--muted); font-size: 13px; }

/* 工具视图 */
.tool .back {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 14px;
  padding: 0 0 16px;
  font-weight: 500;
}
.tool .back:hover { text-shadow: var(--glow); }
/* iframe 型工具：同源嵌入，高度由 JS 同步 */
.tool-iframe {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: block;
  min-height: 600px;
  background: #0d1330;
  box-shadow: var(--shadow);
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  max-width: 880px;
}
.panel h2 { margin: 0 0 18px; font-size: 20px; color: #fff; }

/* 表单 */
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 160px; flex: 1 1 160px; }
.field label { font-size: 13px; color: var(--muted); }
.field input, .field select {
  padding: 9px 10px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  font-size: 15px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); box-shadow: var(--glow); }

.actions { margin: 8px 0 18px; display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  background: var(--primary);
  color: #04122a;
  border: none;
  border-radius: 8px;
  padding: 10px 22px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--glow);
}
.btn:hover { background: #79bbff; }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-2); box-shadow: none; }

.result {
  background: var(--primary-soft);
  border: 1px solid rgba(90, 169, 255, 0.35);
  border-radius: 8px;
  padding: 16px;
  font-size: 15px;
  min-height: 24px;
  color: var(--text);
}
.result .val { font-weight: 600; color: var(--primary); }
.hint { color: var(--muted); font-size: 13px; }
.note { color: var(--muted); font-size: 13px; margin-top: 12px; line-height: 1.7; }

/* 结果明细表 */
.res-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 6px;
}
.res-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.res-item .k { font-size: 12px; color: var(--muted); }
.res-item .v { font-size: 18px; font-weight: 600; color: var(--primary); margin-top: 2px; }
.res-item .u { font-size: 12px; color: var(--muted); font-weight: 400; }

/* 页脚 */
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 24px;
  border-top: 1px solid var(--border);
  background: rgba(12, 18, 40, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* 响应式：移动端侧边栏抽屉 */
@media (max-width: 760px) {
  .menu-btn { display: inline-block; }
  .layout { position: relative; }
  .sidebar {
    position: fixed;
    top: 57px;
    left: 0;
    bottom: 0;
    z-index: 15;
    width: 260px;
    flex: none;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 18px rgba(0, 0, 0, 0.5);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  #app { padding: 18px; }
}

/* 4K / 大屏：限制阅读宽度，避免过散 */
@media (min-width: 2400px) {
  #app { max-width: 1600px; }
  .topbar, .footer { max-width: 2000px; margin: 0 auto; }
}
