body {
    font-family: 'JetBrains Mono', monospace; 
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background-image: var(--background-image-url);
  background-size: cover;
  background-position: center;
  filter: blur(8px);
  transform: scale(1.1);
}

footer {
  display: inline-block;
  text-align: center;
  margin-top: 40px;
  padding: 20px;
  font-size: .8rem;
  background-color: rgba(49, 50, 68, 0.75);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  color: var(--primary-text-color);
}

footer p {
  margin: 5px 0;
}

.container {
    max-width: 950px;
    margin: auto;
    background: #1e2229;
    padding: 35px;
    border-radius: 12px;
    box-shadow: 0 6px 25px rgba(0,0,0,0.12);
    color: #f0f2f5; /* All text within the container is now white */
}
h1, h2, h3, h4 {
    color: #f0f2f5; /* Headings are now white */
}
h1 {
    text-align: center;
    border-bottom: 3px solid #3498db;
    padding-bottom: 15px;
    margin-bottom: 30px;
    font-size: 2.5em;
}
h2 {
    color: #838cff;
    margin-top: 40px;
    font-size: 1.8em;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}
h3 {
    color: #838cff;
    margin-top: 30px;
    font-size: 1.4em;
}
h4 {
    color: #838cff;
    margin-top: 20px;
    font-size: 1.2em;
}
.formula-block {
    background: #2c3e50; /* Changed formula block background for better contrast */
    padding: 20px 25px;
    border-radius: 10px;
    border: 1px solid #cce7ed;
    margin: 30px 0;
    font-size: 1.1em;
}
.formula-block p {
    margin-bottom: 10px;
}
.formula-block strong {
    color: #838cff;
}
.formula-line {
    font-family: 'JetBrains Mono', monospace;
    background-color: #3e5163; /* Adjusted formula line background */
    padding: 5px 10px;
    border-radius: 6px;
    display: block;
    margin-top: 8px;
    margin-bottom: 8px;
    white-space: pre-wrap;
    word-break: break-all;
    color: #333; /* Formula text is now white */
    font-size: 0.95em;
}
.centered-formula {
    display: table;
    margin-left: auto;
    margin-right: auto;
}
code {
    background-color: #1b1717ce; /* Adjusted inline code background */
    padding: 3px 7px;
    border-radius: 5px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: bold;
    color: #f0f2f5;
    white-space: nowrap;
}
ul {
    list-style-type: disc;
    padding-left: 25px;
}
li {
    margin-bottom: 12px;
}
p {
    margin-bottom: 15px;
}
.highlight {
    background-color: #10151f; /* Adjusted highlight background */
    padding: 10px 15px;
    border-left: 5px solid #007bff;
    margin-top: 20px;
    margin-bottom: 20px;
    border-radius: 5px;
}

/* Calculator Specific Styles */
.calculator {
    background: #1e2229; /* Calculator background is now the same as the container */
    border: 1px solid #ddd;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 40px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.calculator h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 25px;
    border-bottom: none;
    color: #f0f2f5;
}
.input-group {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}
.input-group label {
    margin-bottom: 5px;
    font-weight: bold;
    color: #f0f2f5; /* Labels are now white */
    font-size: 0.95em;
}
.input-group input[type="number"],
.input-group input[type="text"] {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1em;
    width: calc(100% - 22px);
    background-color: #2c3e50; /* Input fields have a dark background */
    color: #f0f2f5; /* Text inside input fields is white */
}
.input-group input[type="number"]:focus,
.input-group input[type="text"] :focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}
.calculator button {
    display: block;
    width: 100%;
    padding: 15px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease;
}
.calculator button:hover {
    background-color: #218838;
}
.calculator .result {
    margin-top: 25px;
    padding: 15px;
    border-radius: 8px;
    font-size: 1.3em;
    font-weight: bold;
    text-align: center;
    background-color: #d4edda; /* Kept the result background colors for readability */
    border: 1px solid #c3e6cb;
    color: #155724;
}
.calculator .result.error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #ffffff;
}
.calculator .result.success-result {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}
a {
    color: #3498db; /* Ensure links are visible */
}

/* Mobile-only overrides — desktop stays exactly the same */
@media (max-width: 768px) {
  .container {
    padding: 16px;
    margin: 12px;
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  }

  /* Smaller headings only on phones */
  h1 { font-size: 1.8em; margin-bottom: 20px; padding-bottom: 10px; }
  h2 { font-size: 1.35em; }
  h3 { font-size: 1.15em; }
  h4 { font-size: 1.05em; }

  .calculator { padding: 16px; }
  .formula-block { padding: 16px; font-size: 1rem; }
  .input-group { margin-bottom: 12px; }

  /* Inputs fill width on phones */
  .input-group input[type="number"],
  .input-group input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    font-size: 1rem;
  }
  /* Fix the focus selector (mobile-only so desktop visuals are unchanged) */
  .input-group input[type="number"]:focus,
  .input-group input[type="text"]:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
  }

  /* Prevent long content from breaking layout on phones */
  .formula-line {
    white-space: pre;       /* keep spacing */
    overflow-x: auto;       /* allow horizontal scroll */
    word-break: normal;
  }
  code {
    white-space: normal;    /* allow wrapping */
    overflow-wrap: anywhere;
  }

  /* Lighter, non-fixed background for performance/readability on phones */
  body::before {
    position: absolute;     /* no fixed backdrop on mobile */
    filter: blur(4px);
    transform: none;
    opacity: 0.35;
  }

  /* Comfortable tap targets */
  button, .calculator button, input {
    min-height: 44px;
    touch-action: manipulation;
  }

  /* Footer should span width on phones */
  footer {
    display: block;
    margin: 24px 12px 0;
    padding: 12px;
    font-size: 0.9rem;
    width: auto;
  }

  /* Safe areas for notched devices */
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

/* Very small devices */
@media (max-width: 360px) {
  .container { padding: 12px; margin: 8px; }
  .calculator button { padding: 12px; font-size: 1rem; }
}

@media (max-width: 768px) {
  body::before {
    /* Match desktop on mobile */
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    background-image: var(--background-image-url);
    background-size: cover;
    background-position: center;
    filter: blur(8px);
    transform: scale(1.1);
    opacity: 1;              /* override any previous dimming */
    will-change: transform;  /* optional: smoother on mobile GPUs */
  }
}