:root {
  --red: #e63946;
  --black: #0a0a0a;
  --muted: #6b6b6b;
  --white: #ffffff;
  --green: #2a9d8f;
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(0, 0, 0, 0.08);
  --max-w: 720px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--white);
  color: var(--black);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Sticky glass header */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: var(--glass-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--glass-border);
  animation: headerFloat 6s ease-in-out infinite;
}

@keyframes headerFloat {
  0%, 100% {
    background: rgba(255, 255, 255, 0.72);
    border-color: rgba(0, 0, 0, 0.08);
  }
  50% {
    background: rgba(255, 255, 255, 0.84);
    border-color: rgba(230, 57, 70, 0.25);
  }
}

.header-inner {
  max-width: var(--max-w);
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.site-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--black);
  text-decoration: none;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.site-name:hover {
  color: var(--red);
}

.brand-247 {
  display: inline-block;
  background: var(--red);
  color: #fff;
  border-radius: 5px;
  padding: 1px 5px;
  font-weight: 700;
  letter-spacing: 0;
}

/* Header nav */
.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.site-nav a {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}

.site-nav a:hover {
  color: var(--red);
  background: rgba(230, 57, 70, 0.06);
}

.site-nav a.active {
  color: var(--red);
  background: rgba(230, 57, 70, 0.1);
}

/* Main content */
main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 40px 20px 60px;
}

.page-title {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.page-sub {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 48px;
}

/* Homepage sections */
section {
  margin-bottom: 56px;
}

section[id] {
  scroll-margin-top: 72px;
}

.section-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--black);
  margin-bottom: 20px;
}

/* Cards */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 16px 18px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  transition: border-color 0.15s ease, background 0.15s ease;
  opacity: 0;
  transform: translateY(6px);
  animation: fadeUp 0.35s ease forwards;
}

.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.2s; }
.card:nth-child(5) { animation-delay: 0.25s; }
.card:nth-child(6) { animation-delay: 0.3s; }
.card:nth-child(n+7) { animation-delay: 0.35s; }

@keyframes fadeUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card:hover {
  border-color: rgba(230, 57, 70, 0.35);
  background: rgba(255, 255, 255, 0.9);
}

.card:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.card-title {
  font-size: 17px;
  font-weight: 500;
  color: var(--black);
  margin-bottom: 4px;
  transition: color 0.15s ease;
}

.card:hover .card-title {
  color: var(--red);
}

.card-desc {
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.card-date {
  font-size: 13px;
  color: var(--muted);
  opacity: 0.85;
}

.empty {
  font-size: 15px;
  color: var(--muted);
  padding: 8px 0;
}

/* Formula panels */
.panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 28px 24px;
  margin-bottom: 32px;
  transition: border-color 0.2s;
}

.panel:hover {
  border-color: rgba(230, 57, 70, 0.25);
}

.panel-num {
  font-size: 13px;
  font-weight: 600;
  color: var(--red);
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.panel h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 18px;
}

.formula-box {
  background: rgba(0,0,0,0.03);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 22px;
  overflow-x: auto;
  font-size: 1.15em;
}

.steps {
  margin-bottom: 22px;
}

.step {
  margin-bottom: 16px;
  padding-left: 4px;
}

.step-num {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}

.step-math {
  font-size: 15px;
  margin-bottom: 4px;
  overflow-x: auto;
}

.step-explain {
  font-size: 14px;
  color: var(--muted);
}

/* Inputs */
.inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.input-group {
  flex: 1 1 140px;
  min-width: 120px;
}

.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 5px;
}

.input-group input,
.input-group select {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: rgba(255,255,255,0.9);
  color: var(--black);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-group input:focus,
.input-group select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.15);
}

/* Results */
.result-box {
  background: rgba(0,0,0,0.025);
  border-radius: 12px;
  padding: 16px 18px;
  font-size: 15px;
}

.result-main {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  transition: color 0.2s;
}

.result-main.positive { color: var(--green); }
.result-main.negative { color: var(--red); }

.result-sub {
  font-size: 14px;
  color: var(--muted);
}

/* Progress bar */
.progress-track {
  height: 6px;
  background: rgba(0,0,0,0.06);
  border-radius: 3px;
  margin-top: 12px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--red);
  border-radius: 3px;
  width: 0%;
  transition: width 0.25s ease;
}

/* Special elements */
.tracker {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 14px;
  margin-top: 10px;
}
.tracker span {
  background: rgba(0,0,0,0.04);
  padding: 4px 10px;
  border-radius: 6px;
}

.side-by-side {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}
@media (max-width: 520px) {
  .side-by-side { grid-template-columns: 1fr; }
}

.compare-box {
  background: rgba(0,0,0,0.03);
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
}

.wrong-method {
  opacity: 0.55;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

.toggle-group {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.toggle-btn {
  flex: 1;
  padding: 9px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: rgba(255,255,255,0.8);
  cursor: pointer;
  transition: all 0.15s;
}
.toggle-btn.active {
  background: var(--red);
  color: white;
  border-color: var(--red);
}

.year-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 12px;
}
.year-table th,
.year-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.year-table th {
  font-weight: 500;
  color: var(--muted);
  font-size: 13px;
}

.bars {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  margin: 10px 0 6px;
  background: rgba(0,0,0,0.06);
}
.bar-a { background: var(--red); transition: width 0.25s; }
.bar-b { background: #457b9d; transition: width 0.25s; }

.breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}
.break-item {
  background: rgba(0,0,0,0.04);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
}

.swap-btn {
  margin-top: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  background: rgba(0,0,0,0.04);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.swap-btn:hover {
  background: rgba(230, 57, 70, 0.08);
  border-color: rgba(230, 57, 70, 0.3);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--glass-border);
  padding: 28px 20px 40px;
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.footer-inner .site-nav {
  margin-left: 0;
}

.footer-copy {
  font-size: 13px;
  color: var(--muted);
  opacity: 0.85;
}

a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  section {
    margin-bottom: 48px;
  }
}
