
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; max-width: 100%; }
/* Fixed-position dropdowns must not inherit max-width:100% — JS controls their width */
.kb-dropdown, .variable-dropdown { max-width: none; }

:root {
  --bg:        #f0ebe0;
  --bg-grid:   #e8e2d5;
  --white:     #ffffff;
  --teal:      #1a5276;
  --teal-dark: #154360;
  --teal-light:#2e86c1;
  --orange:    #c0392b;
  --orange-hover:#a93226;
  --border:    #b8c4c8;
  --border2:   #cdd9dd;
  --text:      #2c3e50;
  --text2:     #5d6d7e;
  --text3:     #909ea6;
  --preview-bg:#fdfcf8;
  --tab-active:#dde8f0;
  --serif:     'Merriweather', Georgia, serif;
  --sans:      'Source Sans 3', 'Segoe UI', sans-serif;
  --mono:      'Fira Code', monospace;
}

/* Dark Mode */
body.dark-mode {
  --bg:          #0d1117;
  --bg-grid:     #161b22;
  --white:       #161b22;
  --teal:        #58a6ff;
  --teal-dark:   #388bfd;
  --teal-light:  #79c0ff;
  --orange:      #f85149;
  --orange-hover:#da3633;
  --border:      #30363d;
  --border2:     #21262d;
  --text:        #c9d1d9;
  --text2:       #8b949e;
  --text3:       #6e7681;
  --preview-bg:  #0d1117;
  --tab-active:  #1f2937;
}
html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background-color: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  user-select: text;
  -webkit-user-select: text;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.app-wrapper {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
  max-width: 1460px;
  margin: 0 auto;
}

.page-wrap {
  flex: 1;
  max-width: 1020px;
  margin: 0 auto;
  padding: 22px 18px 40px;
}

@media (max-width: 1300px) {
  .app-wrapper { display: block; }
  .page-wrap { margin: 0 auto; }
}

.main-heading {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--teal);
  margin-bottom: 14px;
  letter-spacing: -0.3px;
  white-space: nowrap;
}

/* Two-column grid */
.two-col {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 22px;
  align-items: start;
  width: 100%;
}

.two-col > * {
  min-width: 0;
  width: 100%;
}

@media (max-width: 800px) {
  .two-col { grid-template-columns: 1fr; }
  .right-panel { order: -1; }
}

/* ============================================================
   KEYBOARD ROW
   ============================================================ */
.keyboard-row {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  position: relative;
}

.kb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 40px;
  padding: 0 10px;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 5px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
  user-select: none;
}

.kb-btn:hover { background: var(--teal-dark); }

.kb-btn.clr-btn {
  background: var(--orange);
  min-width: 48px;
}
.kb-btn.clr-btn:hover { background: var(--orange-hover); }
.kb-btn.active-dropdown { background: var(--teal-light); }

/* ── DROPDOWN: position:fixed — JS places & sizes it via positionDropdown() ── */
.kb-dropdown {
  position: fixed;
  top: 0;
  left: 0;
  background: var(--teal);
  border-radius: 6px;
  padding: 10px 12px;
  z-index: 9000;
  display: none;
  min-width: 200px;   /* JS overrides this to 0 on narrow screens */
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.kb-dropdown.show { display: block; }

.kb-dropdown-row {
  display: flex;
  gap: 5px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.kb-dropdown .dd-btn {
  background: var(--teal-dark);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
  font-family: var(--sans);
}
.kb-dropdown .dd-btn:hover { background: #0d3349; }

.kb-dropdown .dd-hint {
  color: #c5d8e8;
  font-size: 12.5px;
  line-height: 1.8;
  margin-top: 4px;
  font-family: var(--sans);
}
.kb-dropdown .dd-hint code {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(255,255,255,0.12);
  padding: 0 4px;
  border-radius: 3px;
}

/* f(x) dropdown */
.kb-dropdown.fx-dropdown {
  min-width: 300px;
}

.fx-group { margin-bottom: 6px; }
.fx-group .dd-btn {
  font-size: 13px;
  padding: 5px 10px;
  margin: 2px 2px;
}

/* π dropdown */
.kb-dropdown.pi-dropdown {
  min-width: 260px;
}

/* ============================================================
   INPUT ROW
   ============================================================ */
.input-row {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 10px;
}

.func-input {
  flex: 1;
  height: 42px;
  padding: 0 12px;
  font-family: var(--mono);
  font-size: 16px;
  color: var(--text);
  background: var(--white);
  border: 2px solid var(--border);
  border-right: none;
  border-radius: 5px 0 0 5px;
  outline: none;
  transition: border-color 0.2s;
  user-select: text;
  -webkit-user-select: text;
}
.func-input:focus { border-color: var(--teal-light); }

.go-btn {
  height: 42px;
  padding: 0 22px;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 0 5px 5px 0;
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.go-btn:hover { background: var(--teal-dark); }
.go-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ============================================================
   PREVIEW BOX
   ============================================================ */
.preview-label {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 10px;
  margin-top: 12px;
}

.preview-placeholder-text {
  color: var(--text3);
  font-style: italic;
  font-size: 14px;
  font-family: var(--sans);
}

.tex-watermark {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-family: var(--serif);
  font-size: 13px;
  color: var(--text3);
  opacity: 0.6;
  letter-spacing: 1px;
}

.hint-text {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 6px;
  line-height: 1.7;
}
.hint-text a { color: var(--teal); text-decoration: underline; cursor: pointer; }

/* ============================================================
   OPTIONS INLINE
   ============================================================ */
.options-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.opt-group {
  display: flex;
  align-items: center;
  gap: 5px;
}
.opt-group label {
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
}
.opt-input {
  width: 80px;
  height: 30px;
  padding: 0 8px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 4px;
  outline: none;
  transition: border-color 0.2s;
}
.opt-input:focus { border-color: var(--teal-light); }

.opt-quick {
  font-size: 12px;
  color: var(--teal);
  cursor: pointer;
  text-decoration: underline;
  margin-left: 2px;
}

/* ============================================================
   INTEGRAL DISPLAY
   ============================================================ */
.preview-box {
  background: var(--preview-bg);
  border: 1.5px solid var(--border2);
  border-radius: 6px;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  margin-bottom: 8px;
  position: relative;
  overflow: visible;
}

.integral-container {
  display: flex;
  align-items: center;
  gap: 0;
  position: relative;
  width: auto;
  justify-content: center;
}

.integral-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
}

.bound-input-small {
  width: 50px;
  height: 28px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text);
  background: var(--white);
  text-align: center;
  outline: none;
  transition: all 0.2s;
  margin: 2px 0;
}

.bound-input-small:focus {
  border-color: var(--teal-light);
  background: #f0f7ff;
}

.integral-symbol {
  font-size: 60px;
  color: var(--teal);
  font-weight: 400;
  line-height: 1.2;
  margin: 4px 8px;
  display: flex;
  align-items: center;
}

.integral-middle {
  font-size: 20px;
  color: var(--text);
  min-width: 150px;
  text-align: center;
  margin: 0 6px;
  font-style: italic;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}

.integral-right {
  font-size: 20px;
  font-family: var(--mono);
  color: var(--text);
  cursor: pointer;
  user-select: none;
  margin-left: 8px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.var-highlight {
  font-weight: bold;
  color: var(--teal);
  padding: 2px 6px;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
  display: inline-block;
}

.var-highlight:hover { background: #e8f4f8; }

/* ── VARIABLE DROPDOWN: position:fixed — JS places & sizes it ── */
.variable-dropdown {
  position: fixed;
  top: 0;
  left: 0;
  background: var(--teal);
  border-radius: 6px;
  padding: 12px;
  display: none;
  z-index: 9000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  width: 220px;   /* JS overrides min-width to 0 and max-width to vw-16 */
}

.variable-dropdown.show { display: block; }

.dropdown-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.var-opt {
  background: var(--teal-dark);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
  transition: background 0.12s;
  min-width: 35px;
}

.var-opt:hover { background: #0d3349; }

/* ============================================================
   STATUS BADGE & DARK MODE
   ============================================================ */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 10px;
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #aaa;
}
.status-dot.online { background: #27ae60; }
.status-dot.offline { background: #e74c3c; }
.status-dot.pulse { animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

.dark-mode-btn {
  padding: 6px 12px;
  background: var(--white);
  border: 1.5px solid var(--border2);
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  color: var(--text);
}

.dark-mode-btn:hover {
  border-color: var(--teal-light);
  background: var(--tab-active);
}

.dark-mode-btn .mode-icon { display: inline-block; }

/* ============================================================
   RIGHT PANEL — TABS
   ============================================================ */
.right-panel {
  background: var(--white);
  border: 1.5px solid var(--border2);
  border-radius: 6px;
  overflow: hidden;
}

.tab-bar {
  display: flex;
  border-bottom: 1.5px solid var(--border2);
  background: #edf2f5;
}

.tab-btn {
  padding: 9px 16px;
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--teal);
  background: transparent;
  border: none;
  border-right: 1.5px solid var(--border2);
  cursor: pointer;
  transition: background 0.15s;
}
.tab-btn:last-child { border-right: none; }
.tab-btn:hover { background: #dde8f0; }
.tab-btn.active {
  background: var(--white);
  border-bottom: 2px solid var(--white);
  margin-bottom: -1.5px;
  position: relative;
  z-index: 1;
}

.tab-panel { display: none; padding: 16px; }
.tab-panel.active { display: block; }

.tab-panel h3 {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.5;
}
.tab-panel p {
  font-size: 13.5px;
  color: var(--text2);
  margin-bottom: 10px;
  line-height: 1.7;
}
.tab-panel a { color: var(--teal); }

/* Examples grid */
.examples-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.ex-btn {
  background: #edf2f5;
  border: 1.5px solid var(--border2);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 13px;
  color: var(--teal);
  cursor: pointer;
  font-family: var(--mono);
  transition: all 0.12s;
}
.ex-btn:hover { background: var(--teal); color: #fff; }

/* Options panel */
.options-panel-grid { display: flex; flex-direction: column; gap: 10px; }
.opt-panel-row { display: flex; flex-direction: column; gap: 4px; }
.opt-panel-label { font-size: 12.5px; color: var(--text); font-weight: 600; margin-bottom: 2px; }
.opt-panel-input {
  padding: 7px 10px;
  font-family: var(--mono);
  font-size: 13px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  outline: none;
  color: var(--text);
}
.opt-panel-input:focus { border-color: var(--teal-light); }

/* Bound input group */
.bound-input-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

.bound-input {
  flex: 1;
  padding: 7px 10px !important;
  font-size: 13px !important;
  transition: all 0.2s;
}

.bound-input:focus {
  box-shadow: 0 0 0 3px rgba(26, 82, 118, 0.3);
  border-color: #1a5276;
}

.bound-quick-btn {
  padding: 7px 12px;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
  transition: background 0.15s;
  white-space: nowrap;
  min-width: 50px;
}

.bound-quick-btn:hover { background: var(--teal-dark); }

/* Checkboxes */
.checkbox-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.checkbox-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  padding: 2px 0;
}

.checkbox-item input {
  accent-color: var(--teal);
  cursor: pointer;
  margin-top: 2px;
  flex-shrink: 0;
}

.checkbox-item span {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  user-select: none;
}

/* ============================================================
   RESULT SECTION
   ============================================================ */
.result-section {
  background: var(--white);
  border: 1.5px solid var(--border2);
  border-radius: 6px;
  margin-top: 16px;
}

.section-header {
  padding: 10px 16px;
  border-bottom: 1.5px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f7f9fa;
  flex-wrap: wrap;
  gap: 6px;
}

.section-title {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  color: var(--teal);
  white-space: nowrap;
}

.section-body {
  padding: 18px 20px;
  min-height: 70px;
  overflow-x: auto;
  user-select: text;
  -webkit-user-select: text;
}

.result-placeholder {
  color: var(--text3);
  font-style: italic;
  font-size: 13.5px;
  font-family: var(--sans);
}

.result-math {
  font-size: 22px;
  overflow-x: auto;
  color: var(--text);
  max-width: 100%;
  display: block;
  user-select: text;
  -webkit-user-select: text;
}

.result-numeric {
  margin-top: 10px;
  padding: 8px 12px;
  background: #f0f4f8;
  border: 1.5px solid var(--border2);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--teal-dark);
}

.copy-btn {
  padding: 4px 12px;
  background: #edf2f5;
  border: 1.5px solid var(--border2);
  border-radius: 4px;
  font-size: 12px;
  color: var(--teal);
  cursor: pointer;
  font-family: var(--sans);
  font-weight: 600;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.copy-btn:hover { background: var(--teal); color: #fff; }

.engine-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: #e8f4f8;
  border: 1px solid #b8d8e8;
  border-radius: 20px;
  font-size: 11px;
  color: var(--teal);
  font-weight: 600;
  margin-top: 8px;
}

/* ============================================================
   STEPS SECTION
   ============================================================ */
.steps-section {
  background: var(--white);
  border: 1.5px solid var(--border2);
  border-radius: 6px;
  margin-top: 12px;
}

.show-steps-btn {
  padding: 5px 14px;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
  transition: background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.show-steps-btn:hover { background: var(--teal-dark); }
.show-steps-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.step-item {
  margin-bottom: 14px;
  padding: 12px 14px;
  background: #f7f9fa;
  border: 1.5px solid var(--border2);
  border-left: 4px solid var(--teal);
  border-radius: 0 5px 5px 0;
  user-select: text;
  -webkit-user-select: text;
}
.step-item:nth-child(even) { border-left-color: #2e86c1; }

.step-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  letter-spacing: 0.06em;
  margin-bottom: 5px;
  user-select: text;
  -webkit-user-select: text;
}

.step-explanation {
  font-size: 13.5px;
  color: var(--text2);
  margin-bottom: 5px;
  line-height: 1.6;
  user-select: text;
  -webkit-user-select: text;
}

.step-math {
  font-size: 17px;
  overflow-x: auto;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}

/* ============================================================
   CHECK ANSWER
   ============================================================ */
.check-section {
  background: var(--white);
  border: 1.5px solid var(--border2);
  border-radius: 6px;
  margin-top: 12px;
}

.toggle-check-btn {
  padding: 4px 12px;
  background: #edf2f5;
  border: 1.5px solid var(--border2);
  border-radius: 4px;
  font-size: 12px;
  color: var(--teal);
  cursor: pointer;
  font-family: var(--sans);
  font-weight: 600;
  transition: all 0.15s;
  white-space: normal;
  flex-shrink: 1;
  min-width: 0;
}
.toggle-check-btn:hover { background: var(--teal); color: #fff; }

.check-body { padding: 14px 18px; display: none; }
.check-body.open { display: block; }

.check-input-row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }

.check-input {
  flex: 1;
  min-width: 0;
  padding: 7px 12px;
  font-family: var(--mono);
  font-size: 14px;
  border: 2px solid var(--border);
  border-radius: 4px;
  outline: none;
  color: var(--text);
}
.check-input:focus { border-color: var(--teal-light); }

.check-submit-btn {
  padding: 7px 16px;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
  flex-shrink: 0;
}
.check-submit-btn:hover { background: var(--teal-dark); }

.check-result {
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 13.5px;
  font-weight: 600;
  display: none;
}
.check-result.correct { background: #eafaf1; border: 1.5px solid #a9dfbf; color: #1e8449; }
.check-result.incorrect { background: #fdedec; border: 1.5px solid #f1948a; color: #c0392b; }

/* ============================================================
   SPINNER / LOADING
   ============================================================ */
.loading-row { display: none; align-items: center; gap: 8px; color: var(--text3); font-size: 13px; min-width: 0; flex-shrink: 1; white-space: nowrap; }
.loading-row.show { display: flex; }
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border2);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   NOTIFICATION
   ============================================================ */
.notif {
  position: fixed; bottom: 20px; right: 16px; z-index: 999;
  padding: 10px 18px;
  background: var(--white);
  border: 1.5px solid var(--border2);
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  transform: translateY(20px); opacity: 0;
  transition: all 0.3s; pointer-events: none;
  font-family: var(--sans);
  max-width: calc(100vw - 32px);
}
.notif.show { transform: translateY(0); opacity: 1; }
.notif.green { border-color: #a9dfbf; color: #1e8449; }
.notif.red { border-color: #f1948a; color: #c0392b; }

/* ============================================================
   CANVAS ROW
   ============================================================ */
.canvas-row {
  display: flex;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 8px;
}
.dev-card-left {
  flex-shrink: 0;
  width: 160px;
  background: var(--white);
  border: 1.5px solid var(--border2);
  border-radius: 6px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.canvas-row .preview-box {
  flex: 1;
  margin-bottom: 0;
}
@media (max-width: 800px) {
  .canvas-row { flex-direction: column; }
  .dev-card-left {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 10px 14px;
  }
}
/* ============================================================
   DEV SIDEBAR + INLINE
   ============================================================ */
.dev-sidebar {
  width: 250px;
  flex-shrink: 0;
  position: sticky;
  top: 120px;
  left:20px;
  align-self: flex-start;
  background: var(--white);
  border: 1.5px solid var(--border2);
  border-radius: 8px;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
@media (max-width: 1300px) {
  .dev-sidebar { display: none; }
}
/* Developer inline card — shows on small screens below canvas */
/* .dev-inline {
  display: none;
}

@media (max-width: 1300px) {
  .dev-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px;
    background: var(--white);
    border: 1.5px solid var(--border2);
    border-radius: 6px;
    margin-bottom: 14px;
    flex-wrap: wrap;
  }
}

@media (max-width: 600px) {
  .dev-inline {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .dev-inline a {
    width: 48%;
    text-align: center;
    padding: 8px 14px;
    font-size: 13px;
  }
} */

.dev-inline {
  display: none;
}

@media (max-width: 1300px) {
  .dev-inline {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    background: var(--white);
    border: 1.5px solid var(--border2);
    border-radius: 6px;
    margin-bottom: 14px;
    margin-top: 14px;
  }
}
/* ============================================================
   FOOTER
   ============================================================ */
footer {
  text-align: center;
  margin-top: 30px;
  padding-top: 16px;
  border-top: 1px solid var(--border2);
  font-size: 12.5px;
  color: var(--text3);
  font-family: var(--sans);
}

/* ============================================================
   FALLBACK NOTICE
   ============================================================ */
.fallback-notice {
  padding: 7px 12px;
  background: #fef9e7;
  border: 1.5px solid #f9e79f;
  border-radius: 4px;
  color: #b7770d;
  font-size: 12.5px;
  margin-bottom: 8px;
  display: none;
}
.fallback-notice.show { display: block; }

/* ============================================================
   DARK MODE OVERRIDES
   ============================================================ */
body.dark-mode .section-header { background: #161b22; }
body.dark-mode .tab-bar { background: #161b22; }
body.dark-mode .tab-btn.active { background: #0d1117; border-bottom-color: #0d1117; }
body.dark-mode .step-item { background: #161b22; }
body.dark-mode .result-numeric { background: #161b22; color: #58a6ff; }
body.dark-mode .engine-badge { background: rgba(88,166,255,0.1); border-color: rgba(88,166,255,0.3); color: #58a6ff; }
body.dark-mode .func-input { background: #0d1117; color: #c9d1d9; }
body.dark-mode .bound-input-small { background: #0d1117; color: #c9d1d9; }
body.dark-mode .kb-dropdown { background: #1f2937; border: 1px solid #30363d; }
body.dark-mode .dd-btn { background: #161b22; }
body.dark-mode .dd-btn:hover { background: #21262d; }
body.dark-mode .ex-btn { background: #161b22; border-color: #30363d; color: #58a6ff; }
body.dark-mode .ex-btn:hover { background: #58a6ff; color: #0d1117; }
body.dark-mode .copy-btn, body.dark-mode .toggle-check-btn { background: #161b22; border-color: #30363d; color: #58a6ff; }
body.dark-mode .copy-btn:hover, body.dark-mode .toggle-check-btn:hover { background: #58a6ff; color: #0d1117; }
body.dark-mode .check-input { background: #0d1117; color: #c9d1d9; border-color: #30363d; }
body.dark-mode .notif { background: #161b22; border-color: #30363d; }
body.dark-mode .opt-panel-input { background: #0d1117; color: #c9d1d9; border-color: #30363d; }

/* ============================================================
   GRAPH SECTION
   ============================================================ */
.graph-section {
  background: var(--white);
  border: 1.5px solid var(--border2);
  border-radius: 6px;
  margin-top: 16px;
  overflow: visible;
  min-height: 450px;
}

.graph-container {
  width: 100%;
  height: 400px;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  position: relative;
}

#graphPlot {
  width: 100% !important;
  height: 100% !important;
  display: block !important;
}

/* ============================================================
   MOBILE RESPONSIVENESS
   ============================================================ */
@media (max-width: 600px) {
  .preview-box { padding: 10px 8px; overflow: hidden; }
  .integral-container { width: 100%; justify-content: flex-start; gap: 4px; }
  .integral-symbol { font-size: 42px; margin: 0 4px; }
  .bound-input-small { width: 38px; height: 24px; font-size: 10px; padding: 2px 4px; }
  .integral-middle { font-size: 14px; min-width: unset; flex: 1; margin: 0 4px; }
  .integral-right { font-size: 14px; margin-left: 4px; }

  .bound-input-group { display: flex; gap: 4px; align-items: center; flex-wrap: nowrap; width: 100%; }
  .bound-input-group .opt-panel-input { flex: 1; min-width: 0; height: 32px; padding: 6px 8px; font-size: 11px; border: 1.5px solid var(--border); border-radius: 4px; outline: none; color: var(--text); background: var(--white); }
  .bound-input-group .opt-panel-input:focus { border-color: var(--teal-light); }
  .bound-quick-btn { flex: 0 0 auto; height: 32px; padding: 0 8px; min-width: 45px; font-size: 10px; font-weight: 600; white-space: nowrap; background: var(--teal); color: #fff; border: none; border-radius: 4px; cursor: pointer; transition: background 0.15s; font-family: var(--sans); display: inline-flex; align-items: center; justify-content: center; }
  .bound-quick-btn:hover { background: var(--teal-dark); }

  .tab-btn { flex: 1; padding: 8px 10px; font-size: 12px; white-space: normal; word-break: break-word; line-height: 1.3; min-height: 44px; }
  .tab-bar { flex-wrap: nowrap; }
  .right-panel { border-radius: 6px; }
  .tab-panel { padding: 12px; }
  .tab-panel h3 { font-size: 13px; }
  .tab-panel p { font-size: 12.5px; }
  .options-panel-grid { gap: 8px; }
  .opt-panel-row { gap: 3px; }
  .opt-panel-label { font-size: 12px; margin-bottom: 4px; }
  .checkbox-item { padding: 4px 0; gap: 10px; }
  .checkbox-item span { font-size: 12px; line-height: 1.4; }
  .examples-grid { gap: 6px; }
  .ex-btn { padding: 6px 9px; font-size: 12px; flex: 1 1 calc(50% - 3px); }
  .two-col { grid-template-columns: 1fr; gap: 16px; }
  .page-wrap { padding: 16px 12px 30px; }
  .main-heading { font-size: 18px; margin-bottom: 12px; }
}

@media (max-width: 400px) {
  .bound-quick-btn { height: 30px; padding: 0 6px; min-width: 42px; font-size: 9px; }
  .bound-input-group .opt-panel-input { height: 30px; padding: 4px 6px; font-size: 10px; }
  .kb-btn { min-width: 36px; height: 34px; font-size: 13px; padding: 0 6px; }
  .tab-btn { font-size: 11px; padding: 7px 8px; min-height: 40px; }
  .ex-btn { font-size: 11px; padding: 5px 8px; }
}
