:root {
  --accent: 199, 89%, 68%;
  --accent-h: 199;
  --accent-s: 89%;
  --accent-l: 68%;
  --accent-rgb: 72, 187, 220;
  --glow: rgba(72, 187, 220, 0.25);
  --glow-strong: rgba(72, 187, 220, 0.45);
  --surface: 220, 28%, 18%;
  --surface-rgb: 38, 44, 58;
  --border: 220, 22%, 28%;
  --text: 210, 35%, 96%;
  --text-muted: 218, 18%, 62%;
  --bg-from: 222, 40%, 10%;
  --bg-to: 235, 35%, 7%;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: radial-gradient(ellipse 140% 90% at 50% -10%, hsl(218, 35%, 14%), hsl(222, 40%, 10%) 45%, hsl(235, 35%, 7%) 100%);
  color: hsl(var(--text));
  min-height: 100vh;
  position: relative;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.025'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}
.container {
  max-width: 72rem;
  margin: 0 auto;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  position: relative;
  z-index: 1;
}
.title {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-top: 1rem;
  background: linear-gradient(90deg, hsl(var(--accent-h), var(--accent-s), 78%), hsl(199, 70%, 72%), hsl(var(--accent-h), var(--accent-s), 78%));
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 24px var(--glow));
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both, shimmer 5s linear infinite;
}
.card {
  width: 100%;
  background: hsl(var(--surface));
  border: 1px solid hsl(var(--border));
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(var(--accent-rgb), 0.06), 0 0 32px rgba(var(--accent-rgb), 0.06);
  animation: cardIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
  transition: box-shadow 0.4s ease, transform 0.4s ease, border-color 0.4s ease;
}
.card:nth-child(2) { animation-delay: 0.08s; }
.card:nth-child(3) { animation-delay: 0.16s; }
.card:nth-child(4) { animation-delay: 0.24s; }
.card:hover {
  box-shadow: 0 8px 36px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(var(--accent-rgb), 0.12), 0 0 40px var(--glow);
  border-color: hsl(220, 22%, 35%);
  transform: translateY(-3px);
}
.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: hsl(var(--text));
  letter-spacing: -0.01em;
  animation: fadeIn 0.5s ease both;
}
.method-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.method-label {
  font-size: 1rem;
  color: hsl(var(--text-muted));
}
select {
  width: 16rem;
  padding: 0.55rem 1rem;
  border-radius: 9999px;
  background: hsl(220, 24%, 20%);
  border: 1px solid hsl(var(--border));
  color: hsl(var(--text));
  font-size: 0.875rem;
  outline: none;
  cursor: pointer;
  transition: all 0.35s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2348bbdc' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.15), 0 0 20px rgba(var(--accent-rgb), 0.1);
  animation: fieldIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}
select:hover {
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.25), 0 0 24px rgba(var(--accent-rgb), 0.15);
}
select:focus {
  box-shadow: 0 0 0 2px hsl(var(--accent)), 0 0 0 4px rgba(var(--accent-rgb), 0.2), 0 0 28px var(--glow-strong);
  border-color: hsl(var(--accent));
}
select option {
  background: hsl(var(--surface));
  color: hsl(var(--text));
  padding: 0.5rem;
}
.badge {
  display: inline-block;
  padding: 0.3rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(var(--accent-rgb), 0.2);
  color: hsl(var(--accent));
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  animation: scaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
.form-grid > * {
  animation: fieldIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.form-grid > *:nth-child(1) { animation-delay: 0.05s; }
.form-grid > *:nth-child(2) { animation-delay: 0.1s; }
.form-grid > *:nth-child(3) { animation-delay: 0.15s; }
.form-grid > *:nth-child(4) { animation-delay: 0.2s; }
.form-grid > *:nth-child(5) { animation-delay: 0.25s; }
.form-grid > *:nth-child(6) { animation-delay: 0.3s; }
.form-grid > *:nth-child(7) { animation-delay: 0.35s; }
.form-grid > *:nth-child(8) { animation-delay: 0.4s; }
.form-grid > *:nth-child(9) { animation-delay: 0.45s; }
.form-grid > *:nth-child(10) { animation-delay: 0.5s; }
.form-grid > *:nth-child(11) { animation-delay: 0.55s; }
.form-grid > *:nth-child(12) { animation-delay: 0.6s; }
.form-grid > *:nth-child(13) { animation-delay: 0.65s; }
.form-grid > *:nth-child(14) { animation-delay: 0.7s; }
.form-grid > *:nth-child(15) { animation-delay: 0.75s; }
.form-grid > *:nth-child(16) { animation-delay: 0.8s; }
.form-grid > *:nth-child(17) { animation-delay: 0.85s; }
.form-grid > *:nth-child(18) { animation-delay: 0.9s; }
.form-grid > *:nth-child(19) { animation-delay: 0.95s; }
.form-grid > *:nth-child(20) { animation-delay: 1s; }
.full-width {
  grid-column: 1 / -1;
}
label {
  display: block;
  font-size: 0.875rem;
  color: hsl(var(--text-muted));
  margin-bottom: 0.35rem;
  transition: color 0.3s ease;
}
input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 0.55rem 1rem;
  border-radius: 0.625rem;
  background: hsl(220, 24%, 20%);
  border: 1px solid hsl(var(--border));
  color: hsl(var(--text));
  font-size: 0.875rem;
  outline: none;
  transition: all 0.35s ease;
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.15), 0 0 20px rgba(var(--accent-rgb), 0.1);
}
input:hover {
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.25), 0 0 24px rgba(var(--accent-rgb), 0.15);
}
input:focus {
  box-shadow: 0 0 0 2px hsl(var(--accent)), 0 0 0 4px rgba(var(--accent-rgb), 0.2), 0 0 28px var(--glow-strong);
  border-color: hsl(var(--accent));
}
input::placeholder {
  color: hsl(var(--text-muted));
}
.input-with-suffix {
  position: relative;
}
.input-with-suffix input {
  padding-right: 2rem;
}
.suffix {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: hsl(var(--text-muted));
  font-weight: 600;
}
.convert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}
.convert-btn {
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, hsl(199, 75%, 52%), hsl(var(--accent)));
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(var(--accent-rgb), 0.4), 0 0 24px rgba(var(--accent-rgb), 0.15);
  transition: transform 0.3s ease, box-shadow 0.3s ease, filter 0.3s ease;
  animation: btnGlow 3s ease-in-out infinite;
}
.convert-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 28px rgba(var(--accent-rgb), 0.5), 0 0 36px var(--glow);
  filter: brightness(1.1);
}
.convert-btn:active {
  transform: scale(0.97);
  box-shadow: 0 2px 12px rgba(var(--accent-rgb), 0.35);
}
.button-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.solve-btn {
  padding: 0.6rem 2rem;
  border: none;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, hsl(199, 75%, 52%), hsl(var(--accent)));
  color: #fff;
  font-weight: 700;
  font-size: 0.9375rem;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(var(--accent-rgb), 0.4), 0 0 28px rgba(var(--accent-rgb), 0.15);
  transition: transform 0.3s ease, box-shadow 0.3s ease, filter 0.3s ease;
  animation: btnGlow 3s ease-in-out infinite;
}
.solve-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 32px rgba(var(--accent-rgb), 0.5), 0 0 40px var(--glow);
  filter: brightness(1.1);
}
.solve-btn:active {
  transform: scale(0.97);
  box-shadow: 0 2px 14px rgba(var(--accent-rgb), 0.35);
}
.enter-hint {
  font-size: 0.875rem;
  color: hsl(var(--text-muted));
  animation: fadeIn 0.5s ease-out 0.2s both;
}
kbd {
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
  background: hsl(var(--surface));
  color: hsl(var(--accent));
  font-size: 0.75rem;
  font-family: monospace;
  animation: fadeIn 0.4s ease both;
}
.error-box {
  width: 100%;
  padding: 1rem;
  border-radius: 1rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: hsl(0, 84%, 60%);
  font-size: 0.875rem;
  animation: scaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.table-wrapper {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
thead tr {
  background: rgba(var(--accent-rgb), 0.15);
}
th {
  padding: 0.75rem;
  text-align: left;
  font-weight: 700;
  color: hsl(var(--accent));
  white-space: nowrap;
}
td {
  padding: 0.75rem;
  font-family: monospace;
  white-space: nowrap;
}
tbody tr:nth-child(odd) {
  background: hsl(220, 22%, 22%);
}
tbody tr:nth-child(even) {
  background: hsl(var(--surface));
}
tbody tr {
  animation: rowReveal 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
td.highlight {
  color: hsl(var(--accent));
  font-weight: 600;
}
.tabs {
  display: flex;
  gap: 0.25rem;
  background: hsl(220, 22%, 22%);
  border-radius: 0.5rem;
  padding: 0.25rem;
  margin-bottom: 1rem;
  width: fit-content;
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.1), 0 0 16px rgba(var(--accent-rgb), 0.06);
  animation: fadeIn 0.5s ease both;
}
.tab-btn {
  padding: 0.4rem 1rem;
  border: none;
  border-radius: 0.375rem;
  background: transparent;
  color: hsl(var(--text-muted));
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}
.tab-btn.active {
  background: hsl(var(--surface));
  color: hsl(var(--text));
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 12px rgba(var(--accent-rgb), 0.1);
}
.tab-btn:hover:not(.active) {
  color: hsl(var(--text));
}
.tab-content {
  display: none;
  height: 350px;
}
.tab-content.active {
  display: block;
}
.result-box {
  width: 100%;
  text-align: center;
  animation: bounceIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.success-text {
  color: hsl(142, 80%, 45%);
  font-weight: 600;
  font-size: 1.125rem;
  margin-bottom: 0.5rem;
}
.root-text {
  color: hsl(var(--accent));
  font-size: 1.875rem;
  font-weight: 700;
  font-family: monospace;
  letter-spacing: 0.05em;
}
.back-link {
  color: hsl(var(--accent));
  text-decoration: none;
  font-size: 0.875rem;
  margin-top: 1rem;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.back-link:hover {
  opacity: 0.85;
  transform: translateX(-4px);
}
.hidden {
  display: none !important;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fieldIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes bounceIn {
  0% { opacity: 0; transform: scale(0.6) translateY(16px); }
  50% { opacity: 1; transform: scale(1.05) translateY(-4px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes rowReveal {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 4px 18px rgba(var(--accent-rgb), 0.4); }
  50% { box-shadow: 0 6px 32px rgba(var(--accent-rgb), 0.5), 0 0 36px var(--glow); }
}
@keyframes btnGlow {
  0%, 100% { box-shadow: 0 4px 18px rgba(var(--accent-rgb), 0.4), 0 0 28px rgba(var(--accent-rgb), 0.15); }
  50% { box-shadow: 0 6px 28px rgba(var(--accent-rgb), 0.5), 0 0 40px var(--glow); }
}
@keyframes methodEnter {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (max-width: 640px) {
  .title { font-size: 1.5rem; }
  .form-grid { grid-template-columns: 1fr; }
  select { width: 100%; }
  .tabs { width: 100%; }
  .tab-btn { flex: 1; text-align: center; font-size: 0.75rem; padding: 0.4rem 0.5rem; }
  .convert-row { flex-direction: column; align-items: flex-start; }
}
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px hsl(220, 24%, 20%) inset !important;
  -webkit-text-fill-color: hsl(var(--text)) !important;
}
.section-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid hsl(217, 33%, 25%); 
  background-color: hsl(217, 33%, 17%); 
  color: hsl(215, 20%, 65%);
  cursor: pointer;
  font-weight: bold;
  margin-right: 8px;
  transition: 0.3s;
}

.section-btn.active {
  background-color: hsl(230, 100%, 65%); 
  color: white;
}

.section {
  padding: 16px;
  border-radius: 12px;
  border: 1px solid hsl(217, 33%, 25%);
  background-color: hsl(217, 33%, 20%);
  margin-top: 12px;
}

.section-btn:hover {
  background-color: hsl(217, 33%, 25%);
  color: hsl(230, 100%, 65%);
}

/* ══════════════════════════════════════════
   GAUSSIAN ELIMINATION — UI STYLES
══════════════════════════════════════════ */

/* Controls row */
.gauss-controls {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.gauss-ctrl-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

/* Augmented matrix input section */
.gauss-matrix-wrap {
  margin-top: 0.5rem;
}
.gauss-matrix-hint {
  font-size: 0.85rem;
  color: hsl(var(--text-muted));
  margin-bottom: 0.75rem;
  font-style: italic;
}
.gauss-matrix-grid {
  display: grid;
  gap: 0.45rem;
  align-items: center;
}
.gauss-cell {
  text-align: center;
  padding: 0.45rem 0.4rem !important;
  font-family: monospace;
  font-size: 0.95rem;
}
.gauss-b {
  background: hsl(220, 30%, 23%) !important;
  border-color: hsl(var(--accent)) !important;
}
.gauss-sep {
  width: 2px;
  align-self: stretch;
  background: hsl(var(--accent));
  opacity: 0.5;
  border-radius: 2px;
  justify-self: center;
}

/* ── Step-by-step output ─────────────────── */
.gauss-output {
  font-family: 'Segoe UI', system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* Section headers  (Initial Matrix, Forward Elimination, etc.) */
.gs-header {
  font-size: 1rem;
  font-weight: 700;
  color: hsl(var(--accent));
  margin-top: 1rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid hsl(var(--border));
  letter-spacing: 0.01em;
}

/* Pivot column announcement */
.gs-pivot {
  font-size: 0.875rem;
  color: hsl(var(--text-muted));
  padding: 0.3rem 0.6rem;
  background: rgba(var(--accent-rgb), 0.07);
  border-radius: 0.4rem;
  border-left: 3px solid hsl(var(--accent));
}

/* Generic step line */
.gs-line {
  font-family: monospace;
  font-size: 0.9rem;
  padding: 0.35rem 0.6rem;
  border-radius: 0.45rem;
  animation: rowReveal 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Multiplier: m₂₁ = a₂₁ / a₁₁ = 4 / 2 = 2 */
.gs-multiplier {
  background: hsl(220, 25%, 22%);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.gs-lbl {
  color: hsl(142, 80%, 55%);
  font-weight: 700;
  min-width: 3.5rem;
}
.gs-eq {
  color: hsl(var(--text));
}
.gs-eq strong {
  color: hsl(52, 100%, 60%);
}

/* Row operation: E₂ − (2)·E₁ → E₂ */
.gs-rowop {
  background: rgba(var(--accent-rgb), 0.1);
  color: hsl(199, 90%, 75%);
  font-style: italic;
  border-left: 3px solid rgba(var(--accent-rgb), 0.6);
}
.gs-rowop strong {
  color: hsl(52, 100%, 60%);
  font-style: normal;
}

/* Matrix display */
.gauss-mat-wrap {
  overflow-x: auto;
  padding: 0.5rem 0;
  animation: rowReveal 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.gauss-mat {
  border-collapse: separate;
  border-spacing: 0;
  margin: 0 auto;
  font-family: monospace;
  font-size: 0.9rem;
}
.gauss-mat td {
  padding: 0.35rem 0.65rem;
  white-space: nowrap;
  background: transparent;
}
.gauss-mat tr:nth-child(odd) { background: transparent; }
.gauss-mat tr:nth-child(even) { background: transparent; }
.mat-cell {
  text-align: right;
  min-width: 3.5rem;
  color: hsl(var(--text));
  background: hsl(220, 22%, 22%);
  border: 1px solid hsl(var(--border));
}
.mat-b {
  color: hsl(var(--accent));
  font-weight: 600;
  background: hsl(220, 30%, 25%);
}
.mat-pipe {
  color: hsl(var(--accent));
  font-weight: 700;
  padding: 0 0.2rem;
  user-select: none;
}
.mat-brk-l, .mat-brk-r {
  color: hsl(var(--text-muted));
  font-size: 1.5rem;
  font-weight: 300;
  vertical-align: middle;
  padding: 0 0.15rem;
  user-select: none;
}

/* Back substitution step */
.gs-backsub {
  background: hsl(220, 25%, 22%);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.gs-backsub strong {
  color: hsl(142, 80%, 55%);
}
.gs-sub-detail {
  color: hsl(var(--text-muted));
  font-size: 0.82rem;
}

/* Final solution box */
.gs-solution {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.gs-sol-row {
  font-family: monospace;
  font-size: 1.125rem;
  background: linear-gradient(135deg, hsl(220, 30%, 23%), hsl(220, 28%, 26%));
  border: 1px solid hsl(var(--accent));
  border-radius: 0.6rem;
  padding: 0.5rem 1.25rem;
  color: hsl(var(--text));
  box-shadow: 0 0 16px rgba(var(--accent-rgb), 0.15);
  animation: bounceIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.gs-sol-row span {
  color: hsl(var(--accent));
  font-weight: 700;
  font-size: 1.25rem;
}

@media (max-width: 640px) {
  .gauss-controls { flex-direction: column; align-items: flex-start; }
  .gauss-cell { font-size: 0.8rem; }
  .gs-sol-row { font-size: 1rem; }
}

