:root {
  --bg: #0f172a;
  --card: #1e293b;
  --surface: #162032;
  --border: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --topbar-h: 58px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top Bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  border-color: var(--primary);
  color: #93c5fd;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 0.98rem;
}

.brand-badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 4px 7px;
  border-radius: 6px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 7px;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover, .nav-link.active {
  color: var(--text);
  background: rgba(59, 130, 246, 0.18);
}

@media (max-width: 600px) {
  .topnav {
    display: none;
  }
}

/* Sidebar */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.65);
  z-index: 50;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 60;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

.sidebar-nav {
  list-style: none;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-item-link {
  width: 100%;
  text-decoration: none;
  background: transparent;
  border: 1px solid transparent;
  color: #cbd5e1;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-item-link:hover {
  background: rgba(148, 163, 184, 0.1);
}

.sidebar-item-link.active {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.45);
  color: #93c5fd;
}

/* Main & Content */
.main-content {
  flex: 1;
  padding: 20px 16px 32px;
}

.container {
  max-width: 720px;
  margin: 0 auto;
}

.card, .formula-card, .result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.hero-card {
  border-top: 3px solid var(--primary);
}

.hero-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.16);
  padding: 4px 10px;
  border-radius: 99px;
  margin-bottom: 10px;
}

.hero-card h1 {
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 8px;
}

.hero-desc {
  color: #cbd5e1;
  font-size: 0.94rem;
}

.solutions-section {
  margin-top: 8px;
}

.section-heading {
  margin-bottom: 12px;
}

.section-heading h2 {
  font-size: 1.15rem;
  color: #93c5fd;
}

.section-heading p {
  font-size: 0.84rem;
  color: var(--muted);
}

.solution-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.solution-num {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.45);
  color: #93c5fd;
  font-weight: 800;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.solution-card h3 {
  font-size: 1.1rem;
  color: var(--text);
}

.solution-sub {
  font-size: 0.82rem;
  color: var(--muted);
}

.solution-desc {
  color: #e2e8f0;
  font-size: 0.92rem;
  margin-bottom: 16px;
}

.action-link {
  display: block;
  text-align: center;
  text-decoration: none;
}

.page-title-box {
  text-align: center;
  margin-bottom: 18px;
}

.page-title-box h1 {
  font-size: 1.45rem;
  color: #60a5fa;
  margin-bottom: 4px;
}

.page-title-box p {
  font-size: 0.9rem;
  color: var(--muted);
}

.card h3 {
  font-size: 1.02rem;
  color: #93c5fd;
}

.card p {
  color: #e2e8f0;
  font-size: 0.92rem;
}

.feature-list {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #e2e8f0;
  font-size: 0.92rem;
}

.mt-6 {
  margin-top: 8px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 540px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #cbd5e1;
}

small {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 5px;
}

.input-row {
  display: flex;
  gap: 8px;
}

input[type="number"], input[type="text"], select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
}

input:focus, select:focus {
  border-color: var(--primary);
}

select {
  width: 130px;
  flex-shrink: 0;
}

.radio-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

@media (max-width: 480px) {
  .radio-group {
    grid-template-columns: 1fr;
  }
}

.radio-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0;
  transition: border-color 0.2s, background 0.2s;
}

.radio-card:has(input:checked) {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.radio-card input[type="radio"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

.options-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: 400;
  font-size: 0.85rem;
  cursor: pointer;
  color: #e2e8f0;
  margin-bottom: 0;
}

.checkbox-label input[type="checkbox"] {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.primary-btn {
  width: 100%;
  padding: 13px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.primary-btn:hover {
  background: var(--primary-hover);
}

.hidden {
  display: none;
}

.formula-card {
  border-left: 4px solid var(--primary);
  font-size: 0.9rem;
}

.formula-math {
  background: var(--bg);
  padding: 10px 12px;
  border-radius: 8px;
  font-family: monospace;
  margin-top: 8px;
  color: #93c5fd;
  font-size: 0.92rem;
  overflow-x: auto;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-exact {
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
}

.badge-approx {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-size: 0.8rem;
}

.gear-pill {
  background: #334155;
  padding: 3px 9px;
  border-radius: 5px;
  font-weight: 700;
  color: #fff;
  display: inline-block;
}

/* Centered Footer */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 18px 16px;
  font-size: 0.84rem;
  color: var(--muted);
  text-align: center;
}

.footer-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.footer-copy {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.footer-inner strong {
  color: var(--text);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  padding: 2px 4px;
}

.footer-links a:hover {
  color: #93c5fd;
}

/* PCD Diagram */
.pcd-svg-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 6px 0;
}

.pcd-svg {
  width: 100%;
  max-width: 280px;
  height: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.radio-group.two-col {
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 480px) {
  .radio-group.two-col {
    grid-template-columns: 1fr;
  }
}

.mt-12 {
  margin-top: 12px;
}

.divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.angle-big-result {
  font-size: 1.15rem;
  color: #f8fafc;
  margin-bottom: 10px;
}

.angle-big-result strong {
  color: #34d399;
}

.simple-result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.simple-res-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.86rem;
}

.simple-res-item span {
  color: var(--muted);
}

.simple-res-item strong {
  color: var(--text);
}
