/* ============================================
   FRACTION CALCULATOR — page-specific styles
   Accent: violet / purple — Math category
   Inherits variables from css/styles.css
   ============================================ */

/* ---- Page wrapper ---- */
.calc-page {
  position: relative; z-index: 1;
  max-width: 1320px; margin: 0 auto;
  padding: 48px 24px 80px;
  display: grid;
  grid-template-columns: 1fr 500px;
  grid-template-rows: auto auto;
  gap: 48px; align-items: start;
}
.calc-page-info {
  position: static;
}

/* ---- Breadcrumb ---- */
.calc-breadcrumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-dim); margin-bottom: 20px; flex-wrap: wrap;
}
.calc-breadcrumb a { color: var(--text-dim); transition: color var(--transition); }
.calc-breadcrumb a:hover { color: #8b5cf6; }
.calc-breadcrumb i { font-size: 10px; }

/* ---- Category tag — violet for Math ---- */
.calc-page-tag {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 12px 4px 8px;
  background: rgba(139,92,246,0.12); border: 1px solid rgba(139,92,246,0.28);
  border-radius: 100px; font-size: 12px; font-weight: 600; color: #8b5cf6;
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 18px;
}
body.light-theme .calc-page-tag {
  background: rgba(124,58,237,0.08); border-color: rgba(124,58,237,0.22); color: #7c3aed;
}

/* ---- Page title ---- */
.calc-page-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: clamp(28px, 3.2vw, 46px); font-weight: 800;
  line-height: 1.1; letter-spacing: -1.5px; color: var(--text); margin-bottom: 16px;
}
.calc-page-title span { color: #8b5cf6; }
body.light-theme .calc-page-title span { color: #7c3aed; }

.calc-page-desc { font-size: 16px; line-height: 1.75; color: var(--text-muted); margin-bottom: 32px; }

/* ---- Feature pills ---- */
.calc-features { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 40px; }
.calc-feature-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 100px;
  font-size: 13px; font-weight: 500; color: var(--text-muted);
}
.calc-feature-pill i { color: #8b5cf6; font-size: 12px; }
body.light-theme .calc-feature-pill i { color: #7c3aed; }

/* ---- SEO content ---- */
.calc-page-content {
  margin-top: 0;
  min-width: 0;
}

.calc-page-content.fade-up {
  opacity: 1;
  transform: none;
  animation: none;
  transition: none;
  visibility: visible;
}
.content-block { margin-bottom: 40px; }
.content-block h2 {
  font-family: 'Bricolage Grotesque', sans-serif; font-size: 22px; font-weight: 700;
  letter-spacing: -0.5px; color: var(--text); margin-bottom: 14px;
}
.content-block p { font-size: 15px; line-height: 1.8; color: var(--text-muted); margin-bottom: 10px; }
.content-block strong { color: var(--text); font-weight: 600; }

/* ============================================
   OP CARDS (4 operation rule cards)
   ============================================ */
.op-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0; }
.op-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.op-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow); }
.op-add { border-top: 3px solid #8b5cf6; }
.op-sub { border-top: 3px solid #f87171; }
.op-mul { border-top: 3px solid #34d399; }
.op-div { border-top: 3px solid #f59e0b; }
body.light-theme .op-add { border-top-color: #7c3aed; }
body.light-theme .op-sub { border-top-color: #dc2626; }
body.light-theme .op-mul { border-top-color: #059669; }
body.light-theme .op-div { border-top-color: #d97706; }

.op-card-header {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--bg-3); border-bottom: 1px solid var(--border);
}
.op-badge {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 8px;
  background: rgba(139,92,246,0.12); border: 1px solid rgba(139,92,246,0.2);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Bricolage Grotesque', sans-serif; font-size: 18px; font-weight: 800;
  color: #8b5cf6; line-height: 1;
}
.op-badge-sub { background: rgba(248,113,113,0.12); border-color: rgba(248,113,113,0.2); color: #f87171; }
.op-badge-mul { background: rgba(52,211,153,0.12); border-color: rgba(52,211,153,0.2); color: #34d399; }
.op-badge-div { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.2); color: #f59e0b; }
body.light-theme .op-badge        { background: rgba(124,58,237,0.08); border-color: rgba(124,58,237,0.18); color: #7c3aed; }
body.light-theme .op-badge-sub    { background: rgba(220,38,38,0.07); border-color: rgba(220,38,38,0.18); color: #dc2626; }
body.light-theme .op-badge-mul    { background: rgba(5,150,105,0.07); border-color: rgba(5,150,105,0.18); color: #059669; }
body.light-theme .op-badge-div    { background: rgba(217,119,6,0.07); border-color: rgba(217,119,6,0.18); color: #d97706; }
.op-card-header strong { font-size: 13px; font-weight: 700; color: var(--text); }
.op-formula {
  font-family: 'DM Mono', monospace; font-size: 12px; color: var(--text-muted);
  padding: 10px 16px; border-bottom: 1px solid var(--border); line-height: 1.7;
}
.op-note { font-size: 12px; line-height: 1.65; color: var(--text-dim); padding: 10px 16px 14px; margin: 0; }

/* ============================================
   ALGORITHM BOX
   ============================================ */
.frac-algo-box {
  background: var(--bg-3); border: 1px solid var(--border);
  border-left: 3px solid #8b5cf6; border-radius: var(--radius-sm); overflow: hidden; margin: 16px 0;
}
body.light-theme .frac-algo-box { border-left-color: #7c3aed; }
.frac-algo-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: #8b5cf6; padding: 9px 16px; background: var(--bg-2); border-bottom: 1px solid var(--border);
}
body.light-theme .frac-algo-title { color: #7c3aed; }
.frac-algo-body {
  font-family: 'DM Mono', monospace; font-size: 13px; line-height: 2;
  color: var(--text-muted); padding: 14px 18px;
}
.avar { color: #8b5cf6; font-weight: 700; }
body.light-theme .avar { color: #7c3aed; }

/* ============================================
   WORKED STEPS (example steps in SEO content)
   ============================================ */
.worked-steps { display: flex; flex-direction: column; gap: 0; margin: 18px 0; }
.ws-step {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 13px 16px; background: var(--surface); border: 1px solid var(--border);
  border-bottom: none; transition: background var(--transition);
}
.ws-step:first-child { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.ws-step:last-child  { border-bottom: 1px solid var(--border); border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.ws-step:hover { background: var(--bg-3); }
.ws-step-final { background: rgba(139,92,246,0.05); }
body.light-theme .ws-step-final { background: rgba(124,58,237,0.04); }
.ws-num {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(139,92,246,0.12); border: 1px solid rgba(139,92,246,0.25);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Bricolage Grotesque', sans-serif; font-size: 12px; font-weight: 800;
  color: #8b5cf6;
}
body.light-theme .ws-num { background: rgba(124,58,237,0.08); border-color: rgba(124,58,237,0.22); color: #7c3aed; }
.ws-body { display: flex; flex-direction: column; gap: 3px; }
.ws-body strong { font-size: 13px; font-weight: 700; color: var(--text); }
.ws-body span   { font-family: 'DM Mono', monospace; font-size: 13px; color: var(--text-muted); }

/* ---- FAQ ---- */
.faq-list { display: flex; flex-direction: column; gap: 8px; }
.faq-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; transition: border-color var(--transition); }
.faq-item:hover { border-color: var(--border-hover); }
.faq-question {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; background: transparent; border: none; cursor: pointer;
  font-family: 'DM Sans', sans-serif; font-size: 15px; font-weight: 600;
  color: var(--text); text-align: left; transition: color var(--transition);
}
.faq-question:hover { color: #8b5cf6; }
body.light-theme .faq-question:hover { color: #7c3aed; }
.faq-question i { font-size: 12px; color: var(--text-dim); flex-shrink: 0; transition: transform var(--transition), color var(--transition); }
.faq-item.open .faq-question i { transform: rotate(180deg); color: #8b5cf6; }
body.light-theme .faq-item.open .faq-question i { color: #7c3aed; }
.faq-answer { max-height: 0; overflow: hidden; transition: max-height 0.35s ease, padding 0.35s ease; font-size: 14px; line-height: 1.75; color: var(--text-muted); padding: 0 18px; }
.faq-item.open .faq-answer { max-height: 500px; padding: 0 18px 16px; }

/* ---- Also search ---- */
.also-search-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.also-search-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 100px;
  font-size: 13px; font-weight: 500; color: var(--text-muted); white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.also-search-chip:hover { background: rgba(139,92,246,0.1); border-color: #8b5cf6; color: #8b5cf6; }
body.light-theme .also-search-chip:hover { background: rgba(124,58,237,0.07); border-color: #7c3aed; color: #7c3aed; }

/* ============================================
   CALC CARD
   ============================================ */
.calc-panel { position: sticky; top: calc(var(--header-h) + 24px); }
.calc-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-lg), 0 0 60px rgba(139,92,246,0.07);
}
.calc-card-header {
  padding: 20px 24px 18px; background: var(--bg-2); border-bottom: 1px solid var(--border);
  display: none; align-items: center; gap: 12px;
}
@media (max-width: 1024px) { .calc-card-header { display: flex; } }
.calc-card-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: rgba(139,92,246,0.12); border: 1px solid rgba(139,92,246,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #8b5cf6; flex-shrink: 0;
}
body.light-theme .calc-card-icon { background: rgba(124,58,237,0.08); border-color: rgba(124,58,237,0.22); color: #7c3aed; }
.calc-card-header-text h3 { font-family: 'Bricolage Grotesque', sans-serif; font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.calc-card-header-text p  { font-size: 12px; color: var(--text-dim); }
.calc-card-body { padding: 24px; }

/* ---- Form label ---- */
.form-group { margin-bottom: 18px; }
.form-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.05em;
}
.form-label i { color: #8b5cf6; font-size: 12px; }
body.light-theme .form-label i { color: #7c3aed; }

/* ============================================
   4-OP TOGGLE ROW
   ============================================ */
.op-toggle-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.op-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-3); font-family: 'DM Sans', sans-serif;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.op-btn:hover { background: var(--surface); border-color: #8b5cf6; color: #8b5cf6; }
body.light-theme .op-btn:hover { border-color: #7c3aed; color: #7c3aed; }
.op-btn:active { transform: scale(0.96); }
.op-sym {
  font-family: 'Bricolage Grotesque', sans-serif; font-size: 22px; font-weight: 800;
  line-height: 1; color: inherit;
}

/* Active states — each op has its own colour */
.op-btn.active               { background: var(--surface); color: #8b5cf6; border-color: #8b5cf6; box-shadow: 0 0 0 2px rgba(139,92,246,0.2); }
.op-btn[data-op="sub"].active{ color: #f87171; border-color: #f87171; box-shadow: 0 0 0 2px rgba(248,113,113,0.15); }
.op-btn[data-op="mul"].active{ color: #34d399; border-color: #34d399; box-shadow: 0 0 0 2px rgba(52,211,153,0.15); }
.op-btn[data-op="div"].active{ color: #f59e0b; border-color: #f59e0b; box-shadow: 0 0 0 2px rgba(245,158,11,0.15); }
body.light-theme .op-btn.active                { color: #7c3aed; border-color: #7c3aed; }
body.light-theme .op-btn[data-op="sub"].active { color: #dc2626; border-color: #dc2626; }
body.light-theme .op-btn[data-op="mul"].active { color: #059669; border-color: #059669; }
body.light-theme .op-btn[data-op="div"].active { color: #d97706; border-color: #d97706; }

/* ============================================
   VISUAL FRACTION INPUT AREA
   ============================================ */
.frac-input-area {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin: 20px 0; flex-wrap: wrap;
}
.frac-input-group { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.frac-input-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-dim);
}

/* The visual fraction — numerator / line / denominator stacked */
.frac-visual {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; transition: border-color var(--transition), box-shadow var(--transition);
}
.frac-visual:focus-within {
  border-color: #8b5cf6; box-shadow: 0 0 0 3px rgba(139,92,246,0.15);
}
body.light-theme .frac-visual:focus-within { border-color: #7c3aed; box-shadow: 0 0 0 3px rgba(124,58,237,0.1); }

.frac-num-input,
.frac-den-input {
  width: 90px; padding: 10px 8px; border: none; background: transparent;
  font-family: 'Bricolage Grotesque', sans-serif; font-size: 20px; font-weight: 700;
  text-align: center; color: var(--text); outline: none;
  -moz-appearance: textfield;
  transition: background var(--transition);
}
.frac-num-input::-webkit-outer-spin-button,
.frac-num-input::-webkit-inner-spin-button,
.frac-den-input::-webkit-outer-spin-button,
.frac-den-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.frac-num-input:focus, .frac-den-input:focus { background: var(--surface); }
.frac-num-input::placeholder, .frac-den-input::placeholder {
  color: var(--text-dim); font-weight: 400; font-size: 16px;
}
.frac-num-input.error, .frac-den-input.error {
  background: var(--pink-dim) !important; color: var(--pink);
}

/* Horizontal fraction line */
.frac-visual-line {
  width: 100%; height: 2px; background: var(--border);
  transition: background var(--transition);
}
.frac-visual:focus-within .frac-visual-line { background: #8b5cf6; }
body.light-theme .frac-visual:focus-within .frac-visual-line { background: #7c3aed; }

/* Operator between fractions */
.frac-operator-display {
  font-family: 'Bricolage Grotesque', sans-serif; font-size: 28px; font-weight: 800;
  color: var(--text-muted); min-width: 32px; text-align: center;
  transition: color var(--transition);
}

/* Equals column */
.frac-equals-col {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.frac-eq-sign {
  font-family: 'Bricolage Grotesque', sans-serif; font-size: 28px; font-weight: 800;
  color: var(--text-dim);
}
.frac-result-preview {
  font-family: 'DM Mono', monospace; font-size: 13px; font-weight: 700;
  color: var(--text-dim); letter-spacing: -0.5px;
  max-width: 70px; text-align: center; line-height: 1.4;
}

/* Calculate button */
.calc-btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 14px 20px; background: var(--accent); color: #0c0f1a;
  font-family: 'Bricolage Grotesque', sans-serif; font-size: 16px; font-weight: 700;
  border: none; border-radius: var(--radius-sm); cursor: pointer;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  position: relative; overflow: hidden;
}
body.light-theme .calc-btn-primary { color: #fff; }
.calc-btn-primary::after { content: ''; position: absolute; inset: 0; background: #000; opacity: 0; transition: opacity 0.15s; }
.calc-btn-primary:hover { box-shadow: 0 4px 20px var(--accent-glow); }
.calc-btn-primary:hover::after { opacity: 0.06; }
.calc-btn-primary:active { transform: scale(0.98); }

/* Error toast */
.calc-error {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: var(--pink-dim); border: 1px solid rgba(251,113,133,0.3);
  border-radius: var(--radius-sm); color: var(--pink); font-size: 14px; font-weight: 500;
  margin-top: 12px; opacity: 0; transform: translateY(-6px);
  transition: opacity 0.3s ease, transform 0.3s ease; pointer-events: none;
}
.calc-error.show { opacity: 1; transform: translateY(0); pointer-events: auto; }

/* ============================================
   RESULT CARD
   ============================================ */
.result-card {
  margin-top: 20px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  display: none; opacity: 0; transform: translateY(8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.result-card.show { display: block; opacity: 1; transform: translateY(0); }

/* Hero */
.result-hero {
  padding: 20px 24px 18px;
  background: linear-gradient(135deg, rgba(139,92,246,0.08) 0%, transparent 60%);
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.result-hero-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  color: #8b5cf6; align-self: flex-start;
}
body.light-theme .result-hero-label { color: #7c3aed; }

/* ============================================
   LARGE FRACTION DISPLAY (result)
   ============================================ */
.result-frac-display {
  display: flex; align-items: center; gap: 8px;
}
.rfd-sign {
  font-family: 'Bricolage Grotesque', sans-serif; font-size: 36px; font-weight: 800;
  color: #f87171; line-height: 1; /* only visible for negatives */
}
body.light-theme .rfd-sign { color: #dc2626; }
.rfd-whole {
  font-family: 'Bricolage Grotesque', sans-serif; font-size: 52px; font-weight: 800;
  letter-spacing: -2px; color: var(--text); line-height: 1;
}
.rfd-frac {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface);
}
.rfd-num, .rfd-den {
  font-family: 'Bricolage Grotesque', sans-serif; font-size: 22px; font-weight: 800;
  color: var(--text); padding: 4px 12px; text-align: center; line-height: 1.2;
}
.rfd-line { width: 100%; height: 2px; background: #8b5cf6; }
body.light-theme .rfd-line { background: #7c3aed; }

/* ---- Decimal + Mixed badges ---- */
.result-badges { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.result-badge {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
}
.badge-label {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-dim);
}
.badge-val {
  font-family: 'DM Mono', monospace; font-size: 16px; font-weight: 700; color: var(--text);
}
.badge-decimal .badge-val { color: #8b5cf6; }
.badge-mixed  .badge-val { color: #34d399; }
body.light-theme .badge-decimal .badge-val { color: #7c3aed; }
body.light-theme .badge-mixed  .badge-val { color: #059669; }

/* ============================================
   PIE CHART SECTION
   ============================================ */
.pie-section { background: var(--surface); border-bottom: 1px solid var(--border); padding: 14px 20px 16px; }
.pie-section-title {
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dim);
}
.pie-section-title i { color: #8b5cf6; }
body.light-theme .pie-section-title i { color: #7c3aed; }
.pie-wrap { display: flex; align-items: center; gap: 20px; }
.pie-svg-wrap { position: relative; flex-shrink: 0; }
.pie-svg-wrap svg { display: block; }
.pie-bg-circle   { fill: var(--bg-3); }
.pie-fill-path   { fill: #8b5cf6; transition: d 0.4s ease; }
.pie-border-circle { stroke: var(--border); stroke-width: 1; }
body.light-theme .pie-fill-path { fill: #7c3aed; }

.pie-center-label {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  font-family: 'DM Mono', monospace; font-size: 11px; font-weight: 700;
  color: var(--text-dim); text-align: center; line-height: 1.3; pointer-events: none;
}
.pie-legend { display: flex; flex-direction: column; gap: 8px; }
.pie-legend-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; color: var(--text-dim);
}
.pie-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.pie-legend-fill  { background: #8b5cf6; }
.pie-legend-empty { background: var(--bg-3); border: 1px solid var(--border); }
body.light-theme .pie-legend-fill { background: #7c3aed; }

/* ============================================
   STEP-BY-STEP PANEL
   ============================================ */
.steps-section { background: var(--bg-2); }
.steps-title {
  display: flex; align-items: center; gap: 8px; padding: 12px 20px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dim); border-bottom: 1px solid var(--border); background: var(--bg-3);
}
.steps-title i { color: #8b5cf6; }
body.light-theme .steps-title i { color: #7c3aed; }

.steps-body { padding: 0; }
.step-row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 13px 20px; border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.step-row:last-child { border-bottom: none; }
.step-row:hover { background: var(--surface); }
.step-row.step-final { background: rgba(139,92,246,0.05); }
body.light-theme .step-row.step-final { background: rgba(124,58,237,0.04); }
.step-n {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
  background: rgba(139,92,246,0.12); border: 1px solid rgba(139,92,246,0.25);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Bricolage Grotesque', sans-serif; font-size: 11px; font-weight: 800;
  color: #8b5cf6; flex-shrink: 0; margin-top: 1px;
}
body.light-theme .step-n { background: rgba(124,58,237,0.08); border-color: rgba(124,58,237,0.2); color: #7c3aed; }
.step-content { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.step-label { font-size: 12px; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: 0.04em; }
.step-math {
  font-family: 'DM Mono', monospace; font-size: 13px; color: var(--text-muted); line-height: 1.6;
}
.step-highlight { color: #8b5cf6; font-weight: 700; }
body.light-theme .step-highlight { color: #7c3aed; }

/* ============================================
   TOPIC CLUSTER
   ============================================ */
.topic-cluster-section {
  position: relative; z-index: 1;
  background: var(--bg-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.topic-cluster-inner { max-width: 1320px; margin: 0 auto; padding: 56px 24px; }
.topic-cluster-header { max-width: 680px; margin-bottom: 40px; }
.topic-cluster-tag {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 12px 4px 8px; background: rgba(139,92,246,0.12); border: 1px solid rgba(139,92,246,0.22);
  border-radius: 100px; font-size: 12px; font-weight: 600; color: #8b5cf6;
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 16px;
}
body.light-theme .topic-cluster-tag { background: rgba(124,58,237,0.07); border-color: rgba(124,58,237,0.2); color: #7c3aed; }
.topic-cluster-header h2 { font-family: 'Bricolage Grotesque', sans-serif; font-size: clamp(22px,2.5vw,30px); font-weight: 800; letter-spacing: -0.8px; color: var(--text); margin-bottom: 12px; }
.topic-cluster-header p { font-size: 15px; line-height: 1.75; color: var(--text-muted); }
.cluster-grid { display: grid; grid-template-columns: 280px 1fr; gap: 24px; margin-bottom: 40px; align-items: start; }
.cluster-primary {
  background: var(--surface); border: 2px solid #8b5cf6; border-radius: var(--radius); padding: 22px; position: relative;
}
body.light-theme .cluster-primary { border-color: #7c3aed; }
.cluster-primary::before { content: ''; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(135deg, rgba(139,92,246,0.07) 0%, transparent 60%); pointer-events: none; }
.cluster-primary-label { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: #8b5cf6; margin-bottom: 10px; }
body.light-theme .cluster-primary-label { color: #7c3aed; }
.cluster-primary h3 { font-family: 'Bricolage Grotesque', sans-serif; font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 8px; position: relative; }
.cluster-primary p { font-size: 13px; line-height: 1.65; color: var(--text-muted); margin-bottom: 14px; position: relative; }
.cluster-keywords { display: flex; flex-wrap: wrap; gap: 6px; position: relative; }
.cluster-keywords span { padding: 3px 9px; background: rgba(139,92,246,0.1); border: 1px solid rgba(139,92,246,0.2); border-radius: 100px; font-size: 11px; font-weight: 600; color: #8b5cf6; }
body.light-theme .cluster-keywords span { background: rgba(124,58,237,0.07); border-color: rgba(124,58,237,0.18); color: #7c3aed; }
.cluster-links { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cluster-links h3 { font-family: 'Bricolage Grotesque', sans-serif; font-size: 14px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--bg-3); }
.cluster-link-list { display: flex; flex-direction: column; }
.cluster-link-item { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--border); transition: background var(--transition); }
.cluster-link-item:last-child { border-bottom: none; }
.cluster-link-item:hover { background: var(--bg-3); }
.cluster-link-icon { flex-shrink: 0; width: 34px; height: 34px; border-radius: 8px; background: rgba(139,92,246,0.1); display: flex; align-items: center; justify-content: center; font-size: 15px; color: #8b5cf6; }
body.light-theme .cluster-link-icon { background: rgba(124,58,237,0.07); color: #7c3aed; }
.cluster-link-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.cluster-link-text strong { font-size: 14px; font-weight: 600; color: var(--text); }
.cluster-link-text span   { font-size: 12px; color: var(--text-dim); }
.cluster-link-arrow { color: var(--text-dim); font-size: 12px; transition: transform var(--transition), color var(--transition); }
.cluster-link-item:hover .cluster-link-arrow { transform: translateX(3px); color: #8b5cf6; }
body.light-theme .cluster-link-item:hover .cluster-link-arrow { color: #7c3aed; }
.cluster-link-all { background: var(--bg-2); }
.cluster-crosslinks { padding-top: 32px; border-top: 1px solid var(--border); }
.cluster-crosslinks h3 { font-family: 'Bricolage Grotesque', sans-serif; font-size: 18px; font-weight: 700; letter-spacing: -0.3px; color: var(--text); margin-bottom: 6px; }
.cluster-crosslinks > p { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; }
.crosslink-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.crosslink-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 16px; display: flex; flex-direction: column; gap: 8px; transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition); }
.crosslink-card:hover { border-color: #8b5cf6; transform: translateY(-3px); box-shadow: var(--shadow); }
body.light-theme .crosslink-card:hover { border-color: #7c3aed; }
.crosslink-card i { font-size: 20px; color: #8b5cf6; }
body.light-theme .crosslink-card i { color: #7c3aed; }
.crosslink-card strong { font-family: 'Bricolage Grotesque', sans-serif; font-size: 14px; font-weight: 700; color: var(--text); }
.crosslink-card span { font-size: 12px; line-height: 1.5; color: var(--text-dim); }

/* Ad slot */
.ad-slot { position: relative; z-index: 1; max-width: 1320px; margin: 0 auto; padding: 0 24px 40px; }
.ad-slot > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

/* Fade-up */
.fade-up { opacity: 0; transform: translateY(16px); transition: opacity 0.5s ease, transform 0.5s ease; }
.fade-up.visible { opacity: 1; transform: translateY(0); }

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
  .calc-page { grid-template-columns: 1fr; padding: 32px 20px 60px; gap: 32px; }
  .calc-page-info { position: static; }
  .calc-panel { position: static; order: 2; }
  .calc-page-content { order: 3; }
  .cluster-grid { grid-template-columns: 1fr; }
  .crosslink-grid { grid-template-columns: 1fr 1fr; }
  .op-cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .calc-page { padding: 24px 16px 48px; }
  .op-cards { grid-template-columns: 1fr; }
  .frac-input-area { gap: 8px; }
  .frac-num-input, .frac-den-input { width: 72px; font-size: 18px; }
  .crosslink-grid { grid-template-columns: 1fr; }
  .topic-cluster-inner { padding: 36px 16px; }
  .op-toggle-row { grid-template-columns: repeat(2, 1fr); }
  .pie-wrap { flex-direction: column; align-items: flex-start; }
}

@media (min-width: 1025px) {
  .calc-page-info {
    grid-row: 1 / 2;
    grid-column: 1 / 2;
  }
  .calc-page-content {
    grid-row: 2 / 3;
    grid-column: 1 / 2;
  }
  .calc-panel {
    grid-row: 1 / 3;
    grid-column: 2 / 3;
    align-self: start;
    position: sticky;
    top: calc(var(--header-h) + 24px);
  }
}
