/* ═══════════════════════════════════════════════════════════
   BitwiseCalc — dark tech blue theme (哥飞标准升级)
   ═══════════════════════════════════════════════════════════ */
:root {
  --bg: #09090b;
  --surface: #18181b;
  --surface-el: #27272a;
  --border: #3f3f46;
  --border-hover: #38bdf8;
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --primary-muted: rgba(56, 189, 248, 0.08);
  --text: #e4e4e7;
  --text-heading: #fafafa;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;
  --accent: #38bdf8;
  --danger: #ef4444;
  --success: #4ade80;
  --warning: #fbbf24;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
a { color: var(--primary); text-decoration: none; transition: color .2s; }
a:hover { color: var(--primary-hover); }
strong { color: var(--text-heading); font-weight: 600; }
code {
  font-family: var(--font-mono);
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
  color: var(--primary);
  border: 1px solid var(--border);
}
img { max-width: 100%; height: auto; display: block; }

/* ── Nav ── */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.top-bar-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 20px;
  gap: 12px;
}
.top-bar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-heading);
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font-mono);
}
.top-bar .brand:hover { color: var(--primary); text-decoration: none; }
.top-bar .brand svg { width: 22px; height: 22px; }
.nav-links {
  display: flex;
  gap: 2px;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all .2s var(--ease);
  white-space: nowrap;
  text-decoration: none;
}
.nav-links a:hover { color: var(--text); background: var(--primary-muted); text-decoration: none; }
.nav-links a.active { color: var(--primary); background: var(--primary-muted); font-weight: 600; }
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 6px;
}

/* ── Container ── */
.container { max-width: 1000px; margin: 0 auto; padding: 0 20px; width: 100%; }

/* ── Hero ── */
.hero { padding: 40px 0 24px; text-align: center; }
.hero h1 { font-size: clamp(1.4rem, 2.8vw, 2rem); font-weight: 700; line-height: 1.25; color: var(--text-heading); max-width: 680px; margin: 0 auto 10px; }
.hero p { color: var(--text-muted); font-size: 1rem; max-width: 560px; margin: 0 auto; }
.hero .tagline { font-size: 0.85rem; color: var(--text-dim); margin-top: 8px; }

/* ── Header (内页) ── */
.page-header { padding: 28px 0 14px; text-align: center; }
.page-header h1 { font-size: clamp(1.2rem, 2.2vw, 1.6rem); font-weight: 700; color: var(--text-heading); }
.page-header p { color: var(--text-muted); font-size: 0.95rem; margin-top: 6px; }
.breadcrumb { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 10px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }

/* ── Tool Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin: 0 0 24px;
}
.card h2 { font-size: 1.1rem; font-weight: 600; color: var(--text-heading); margin-bottom: 16px; }
.card h3 { font-size: 0.95rem; font-weight: 600; color: var(--text-heading); margin: 16px 0 8px; }
.input-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.input-row label { font-size: 0.82rem; color: var(--text-muted); display: block; margin-bottom: 4px; }
.input-row input, .input-row select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 1rem;
  outline: none;
  transition: border .2s;
}
.input-row input:focus, .input-row select:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.input-row input { flex: 1; min-width: 120px; }
.input-row select { min-width: 80px; cursor: pointer; }
.input-group { flex: 1; min-width: 160px; }

.op-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0; }
.op-btn {
  padding: 10px 18px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-mono);
  transition: all .2s var(--ease);
}
.op-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-muted); }
.op-btn.active { background: var(--primary); color: #09090b; border-color: var(--primary); }
.op-btn:active { transform: scale(0.95); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s var(--ease);
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: #09090b; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
  background: var(--surface-el);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-secondary:active { transform: scale(0.97); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

.result-area {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
  margin-top: 16px;
  min-height: 60px;
}
.result-area .label { font-size: 0.78rem; color: var(--text-dim); margin-bottom: 4px; }
.result-area .value { font-size: 1.3rem; font-family: var(--font-mono); color: var(--success); word-break: break-all; }
.result-area .sub { font-size: 0.82rem; color: var(--text-muted); margin-top: 4px; font-family: var(--font-mono); }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 16px; }
.detail-box { background: var(--bg); border-radius: var(--radius); padding: 12px; border: 1px solid var(--border); }
.detail-box .lbl { font-size: 0.72rem; color: var(--text-dim); }
.detail-box .val { font-size: 0.88rem; font-family: var(--font-mono); word-break: break-all; }

/* ── Info Section ── */
.info-section { display: flex; flex-direction: column; gap: 20px; margin: 24px 0; }
.info-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; }
.info-card h2 { font-size: clamp(0.95rem, 1.6vw, 1.1rem); font-weight: 600; color: var(--text-heading); margin-bottom: 12px; }
.info-card h3 { font-size: 0.92rem; font-weight: 600; color: var(--text-heading); margin: 18px 0 8px; }
.info-card h3:first-child { margin-top: 0; }
.info-card p { color: var(--text-muted); font-size: 0.9rem; line-height: 1.75; margin-bottom: 12px; }
.info-card p:last-child { margin-bottom: 0; }
.info-card ul, .info-card ol { color: var(--text-muted); font-size: 0.9rem; line-height: 1.75; padding-left: 20px; margin-bottom: 12px; }
.info-card ul:last-child, .info-card ol:last-child { margin-bottom: 0; }
.info-card li { margin-bottom: 6px; }
.info-card li strong { color: var(--text); }

.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin: 24px 0; }

.faq-section { margin: 24px 0; }
.faq-item { border-bottom: 1px solid var(--border); padding: 14px 0; }
.faq-item:last-child { border-bottom: none; }
.faq-item h3 { font-size: 0.9rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.faq-item p { color: var(--text-muted); font-size: 0.86rem; line-height: 1.7; margin: 0; }

.related-section { margin: 24px 0; }
.related-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.related-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  transition: all .2s var(--ease);
}
.related-btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }

/* ── History ── */
.calc-history {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  border: 1px solid var(--border);
  margin: 16px 0;
}
.calc-history h3 { color: var(--primary); font-size: 0.92rem; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.history-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-family: var(--font-mono); font-size: 0.82rem; }
.history-item:last-child { border-bottom: none; }
.history-item .h-op { color: var(--primary); font-weight: 600; }
.history-item .h-result { color: var(--success); }
.history-item .h-ts { color: var(--text-dim); font-size: 0.72rem; }
.history-item .h-restore { background: transparent; border: 1px solid var(--border); color: var(--text-dim); padding: 2px 8px; border-radius: 4px; cursor: pointer; font-size: 0.72rem; }
.history-item .h-restore:hover { border-color: var(--primary); color: var(--primary); }
.history-clear { background: transparent; border: 1px solid var(--border); color: var(--danger); padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 0.72rem; }
.history-clear:hover { border-color: var(--danger); background: rgba(239,68,68,0.1); }

/* ── Footer ── */
.site-footer { margin-top: auto; padding: 28px 20px; border-top: 1px solid var(--border); background: var(--surface); }
.footer-inner { max-width: 1000px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-links a { color: var(--text-dim); font-size: 0.82rem; }
.footer-links a:hover { color: var(--primary); }
.footer-copy { color: var(--text-dim); font-size: 0.82rem; }

/* ── Back to Top ── */
.back-to-top {
  position: fixed; bottom: 24px; right: 24px; z-index: 50;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface-el); color: var(--text-muted);
  border: 1px solid var(--border); cursor: pointer;
  font-size: 16px; display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: all .25s var(--ease);
}
.back-to-top.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.back-to-top:hover { border-color: var(--primary); color: var(--primary); }

/* ── Animations ── */
@keyframes fadeIn { 0% { opacity: 0; } 100% { opacity: 1; } }
@keyframes slideUp { 0% { opacity: 0; transform: translateY(20px); } 100% { opacity: 1; transform: translateY(0); } }
.anim-fade { animation: fadeIn 0.5s ease-out forwards; }
.anim-up { animation: slideUp 0.5s var(--ease) forwards; }
.anim-delay-1 { animation-delay: 0.1s; }
.anim-delay-2 { animation-delay: 0.2s; }
.anim-delay-3 { animation-delay: 0.3s; }
.card, .info-card, .faq-item { animation: slideUp 0.5s var(--ease) both; }
.card { animation-delay: 0.05s; }
.info-card:nth-child(1) { animation-delay: 0.1s; }
.info-card:nth-child(2) { animation-delay: 0.15s; }
.info-card:nth-child(3) { animation-delay: 0.2s; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-links.open { display: flex; flex-wrap: wrap; position: absolute; top: 56px; left: 0; right: 0; padding: 12px 20px 16px; background: var(--bg); border-bottom: 1px solid var(--border); gap: 4px; }
  .nav-toggle { display: block; }
  .hero { padding: 28px 0 16px; }
  .card { padding: 16px; }
  .info-card { padding: 16px; }
  .input-row { flex-direction: column; }
  .input-group { min-width: unset; }
  .info-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .top-bar-inner { padding: 0 12px; }
  .container { padding: 0 12px; }
  .hero h1 { font-size: 1.2rem; }
  .card { padding: 12px; border-radius: var(--radius); }
  .info-card { padding: 14px; }
}
