.fraction-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 32px;
  margin-bottom: 32px;
}
.fraction-card h2 {
  font-size: 18px;
  margin: 0 0 4px;
}
.fraction-card .card-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 24px;
}

/* ===== Fraction input row ===== */
.fraction-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.fraction-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.fraction-whole {
  width: 52px;
  height: 64px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f7f9fc;
  text-align: center;
  font-size: 18px;
  font-family: inherit;
}
.fraction-whole::placeholder { color: var(--text-muted); font-size: 11px; }
.fraction-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}
.fraction-stack input {
  width: 64px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  text-align: center;
  font-size: 16px;
  font-family: inherit;
  color: var(--text-primary);
}
.fraction-stack input:focus, .fraction-whole:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.fraction-divider {
  width: 64px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
}
.fraction-op {
  height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  font-family: inherit;
}
.fraction-equals {
  height: 52px;
  padding: 0 24px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  transition: filter 0.15s ease;
}
.fraction-equals:hover { filter: brightness(1.08); }

/* ===== Result ===== */
.fraction-result {
  margin-top: 24px;
  padding: 20px;
  border-radius: var(--radius-md);
  background: #f7f9fc;
  min-height: 24px;
}
.fraction-result.is-error {
  color: #dc2626;
  background: #fbeded;
  font-size: 14px;
}
.result-main {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}
.result-frac {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
}
.result-mixed {
  font-size: 16px;
  color: var(--text-secondary);
}
.result-decimal {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-secondary);
}
.frac-bar {
  display: flex;
  gap: 2px;
  margin-top: 14px;
  height: 20px;
}
.frac-bar-seg {
  flex: 1;
  background: #e2e6ed;
  border-radius: 3px;
}

/* ===== Steps ===== */
.fraction-steps {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.fraction-steps[hidden] {
  display: none;
}
.step {
  padding-left: 14px;
  border-left: 2px solid var(--accent-tint);
}
.step-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent);
  margin-bottom: 4px;
}
.step p {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ===== Secondary tools ===== */
.secondary-tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 48px;
}
.tool-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
}
.tool-card h3 {
  font-size: 15px;
  margin: 0 0 4px;
}
.tool-card .card-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0 0 16px;
}
.tool-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.tool-form input[type="text"] {
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
  font-family: inherit;
  width: 110px;
}
.tool-form input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.tool-form button {
  height: 40px;
  padding: 0 18px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}
.tool-result {
  margin-top: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  min-height: 20px;
}
.tool-result.is-error {
  color: #dc2626;
  font-weight: 500;
  font-size: 13px;
}

.mode-toggle {
  position: relative;
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 8px;
  background: #f3f5f8;
  width: 180px;
  height: 36px;
  margin-bottom: 14px;
}
.mode-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 4px);
  height: calc(100% - 6px);
  background: var(--accent);
  border-radius: 6px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.mode-toggle.fraction-active .mode-toggle-thumb {
  transform: translateX(calc(100% + 2px));
}
.mode-toggle button {
  position: relative;
  z-index: 1;
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #2e3340;
  transition: color 0.3s ease;
}
.mode-toggle button.active { color: #fff; }

/* ===== Original content sections ===== */
.fraction-guide {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 32px;
  margin-bottom: 48px;
}
.fraction-guide h2 {
  font-size: 20px;
  margin: 32px 0 10px;
}
.fraction-guide h2:first-child { margin-top: 0; }
.fraction-guide p {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin: 0 0 12px;
}
.fraction-guide .callout {
  background: #f7f9fc;
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--text-primary);
  margin: 12px 0;
}
.faq-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.faq-item:last-child { border-bottom: none; }
.faq-item h3 {
  font-size: 15px;
  margin: 0 0 6px;
}
.faq-item p {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.6;
}

@media (max-width: 640px) {
  .fraction-card { padding: 20px; }
  .fraction-row { justify-content: center; }
  .fraction-whole { width: 44px; }
  .fraction-stack input { width: 52px; }
  .fraction-divider { width: 52px; }
}
