.swap-row {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0.2rem 0 0.2rem 0;
}

.to-row-inline {
  /* No longer used for swap layout, kept for legacy */
}

.to-label-swap-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 0.2rem;
}

.swap-btn {
  background: linear-gradient(90deg, #ffb347 0%, #ffe082 100%);
  border: 1px solid #ff9800;
  border-radius: 0.5rem;
  width: 38px;
  height: 43px;
  min-width: 38px;
  min-height: 43px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(255, 179, 71, 0.13);
  cursor: pointer;
  transition: background 0.2s, border 0.2s, transform 0.1s;
    margin: 0 0.2rem;
    padding: 0;
}

.swap-btn img {
  display: block;
  margin: 0 auto;
  width: 30px;
  height: 35px;
}

.swap-btn:hover,
.swap-btn:focus {
  background: linear-gradient(90deg, #ffe082 0%, #ffb347 100%);
  border: 1.5px solid #ff9800;
  box-shadow: 0 2px 8px rgba(255, 179, 71, 0.18);
  /* No shrink on hover */
  transform: none;
}

.scientific-display {
  width: 100%;
  margin-bottom: 1rem;
}

.sci-buttons {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.7rem;
  width: 100%;
}

/* Convert Calculator */
.convert-calc {
  background: var(--fun-bg);
  color: var(--fun-fg);
  border-radius: 1.5rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
  padding: 1.5rem 2rem;
  min-width: 260px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 1rem;
  width: 340px;
}

.convert-panel {
  width: 100%;
}

.convert-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.convert-tab {
  font-size: 1rem;
  padding: 0.5rem 1.1rem;
  border-radius: 0.7rem;
  background: var(--accent);
  color: var(--fg);
  font-weight: bold;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.convert-tab.active,
.convert-tab:active {
  background: var(--button-hover);
}

/* Redesigned Convert UI for Apple-like look */
.convert-body {
  margin-top: 1.2rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1.2rem;
}

.convert-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
    width: 100%;
}

.convert-input,
.convert-output {
  font-size: 1.05rem;
    padding: 0.5rem 0.7rem;
    border-radius: 0.7rem;
  border: none;
  background: #f7f7fa;
  color: #222;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
  margin: 0;
  text-align: right;
  font-family: 'Share Tech Mono', 'Fira Mono', 'Consolas', monospace;
  font-weight: 500;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.convert-output {
  background: #fff;
  color: #333;
  border: none;
}

.convert-calc select {
  font-size: 1.05rem;
    border-radius: 0.7rem;
    padding: 0.5rem 0.7rem;
  margin: 0;
  background: linear-gradient(90deg, #ffe082 0%, #ffb347 100%);
  color: #222;
  font-weight: 500;
    border: 1.5px solid #ffb347;
    box-shadow: 0 1px 4px rgba(255, 179, 71, 0.13);
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    transition: background 0.2s, border 0.2s;
  }
  
  .convert-calc select:focus,
  .convert-calc select:hover {
    background: linear-gradient(90deg, #ffb347 0%, #ffe082 100%);
    border: 1.5px solid #ff9800;
}

.convert-calc select:focus,
.convert-input:focus {
  outline: 2px solid var(--accent);
}

.convert-label {
  font-size: 1.1rem;
  color: #888;
  margin-bottom: 0.2rem;
  margin-left: 0.2rem;
  font-weight: 500;
}

@media (max-width: 800px) {
  .convert-body {
    gap: 0.7rem;
  }

  .convert-input,
  .convert-output {
    font-size: 1.15rem;
    padding: 0.7rem 0.7rem;
    border-radius: 0.8rem;
  }

  .convert-calc select {
    font-size: 1rem;
    border-radius: 0.8rem;
    padding: 0.6rem 0.7rem;
  }
}

@media (max-width: 800px) {

  .scientific-calc,
  .convert-calc {
    width: 100vw;
    max-width: 340px;
    min-width: 0;
    padding: 1.2rem 0.5rem 1rem 0.5rem;
    box-sizing: border-box;
  }

  .convert-tabs {
    flex-wrap: wrap;
    gap: 0.3rem;
  }

  .convert-tab {
    font-size: 0.95rem;
    padding: 0.4rem 0.7rem;
    border-radius: 0.5rem;
  }
}

/* Top bar and dropdown menus */
.top-bar {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-bottom: 0.7rem;
  position: relative;
}

.menu-buttons {
  display: flex;
  gap: 0.7rem;
}

.menu-btn {
  font-size: 1.15rem;
  font-family: inherit;
  padding: 0.6rem 1.2rem;
  border-radius: 0.8rem;
  background: var(--accent);
  color: var(--fg);
  font-weight: bold;
  border: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.10);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.menu-btn:active {
  background: var(--button-hover);
  transform: scale(0.97);
}

.dropdown-menu {
  position: absolute;
  top: 2.7rem;
  right: 0;
  background: var(--button);
  border-radius: 0.8rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.13);
  display: flex;
  flex-direction: column;
  min-width: 140px;
  z-index: 10;
  padding: 0.3rem 0;
}

.dropdown-item {
  font-size: 1.08rem;
  font-family: inherit;
  padding: 0.7rem 1.2rem;
  background: none;
  border: none;
  text-align: left;
  color: var(--fg);
  cursor: pointer;
  border-radius: 0.5rem;
  transition: background 0.18s;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: var(--button-hover);
}
body {
  font-family: 'Comic Neue', 'Baloo 2', cursive, sans-serif;
  background: var(--bg);
  color: var(--fg);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: background 0.5s, color 0.5s;
}
:root {
  --bg: #f7f7fa;
  --fg: #222;
  --accent: #ffb347;
  --button: #fff;
  --button-hover: #ffe0b2;
  --display-bg: #fffbe7;
  --display-fg: #222;
  --fun-bg: #e0f7fa;
  --fun-fg: #00796b;
}
body.theme-dark {
  --bg: #23272f;
  --fg: #f7f7fa;
  --accent: #90caf9;
  --button: #2c2f36;
  --button-hover: #374151;
  --display-bg: #1a1d23;
  --display-fg: #f7f7fa;
  --fun-bg: #263238;
  --fun-fg: #90caf9;
}
body.theme-rainbow {
  --bg: linear-gradient(135deg, #f7b42c 0%, #fc575e 100%);
  --fg: #222;
  --accent: #fff176;
  --button: #fff;
  --button-hover: #ffe082;
  --display-bg: #fffde7;
  --display-fg: #fc575e;
  --fun-bg: #fff176;
  --fun-fg: #fc575e;
}

body.theme-rainbow button {
  color: #222 !important;
}
main {
  display: flex;
  flex-direction: row;
  gap: 2rem;
  margin-top: 2rem;
}
.calculator-section, .math-fun-section {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.calculator {
  background: var(--display-bg);
  border-radius: 2rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  padding: 2rem 1.5rem 1.5rem 1.5rem;
  margin-bottom: 1rem;
  width: 320px;
}
.display {
  background: var(--display-bg);
  color: var(--display-fg);
  border-radius: 1rem;
  padding: 1rem;
  margin-bottom: 1rem;
  min-height: 3.5rem;
  text-align: right;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  user-select: all;
  outline: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  font-family: 'Share Tech Mono', 'Fira Mono', 'Consolas', monospace;
}
.display-expression {
  font-size: 1.1rem;
  color: #888;
  min-height: 1.2rem;
  margin-bottom: 0.2rem;
  word-break: break-all;
}
.display-result {
  font-size: 2.2rem;
  color: var(--display-fg);
  min-height: 2.2rem;
  font-weight: bold;
  word-break: break-all;
}
.buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.7rem;
}
.buttons button,
.sci-buttons button {
  font-size: 1.6rem !important;
  font-family: 'Share Tech Mono', 'Fira Mono', 'Consolas', monospace;
  font-weight: 700;
  letter-spacing: 0.01em;
}
button {
  font-family: inherit;
  font-size: 1.35rem;
  border: none;
  border-radius: 1rem;
  background: var(--button);
  color: var(--fg);
  padding: 1rem 0.7rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.13), 0 1.5px 0 #fff inset;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  outline: none;
  font-weight: 600;
    letter-spacing: 0.01em;
}
button:active {
  background: var(--button-hover);
  transform: scale(0.97);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.10);
}
.theme-switcher {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.theme-switcher button {
  font-size: 1rem;
  padding: 0.5rem 1rem;
  border-radius: 0.7rem;
  background: var(--accent);
  color: var(--fg);
  font-weight: bold;
}
.math-fun-panel {
  background: var(--fun-bg);
  color: var(--fun-fg);
  border-radius: 1.5rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  padding: 1.5rem 2rem;
  min-width: 260px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 1rem;
}
.fun-instruction {
  font-size: 1.1rem;
  margin-bottom: 1.2rem;
  min-height: 3.5rem;
  text-align: center;
}
.fun-buttons {
  display: flex;
  gap: 1rem;
}
@media (max-width: 800px) {
  main {
    flex-direction: column;
    align-items: stretch;
    gap: 1.2rem;
    width: 100vw;
    min-width: 0;
    margin-top: 0.5rem;
    padding: 0 0.5rem;
  }
  .calculator-section, .math-fun-section {
    width: 100%;
    align-items: stretch;
    min-width: 0;
  }
  .calculator {
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    padding: 1.2rem 0.5rem 1rem 0.5rem;
    margin-bottom: 0.5rem;
    box-sizing: border-box;
  }
  .display {
    font-size: 1.3rem;
    padding: 0.7rem 0.5rem;
    min-height: 2.5rem;
  }
  .display-result {
    font-size: 1.5rem;
  }
  .display-expression {
    font-size: 0.95rem;
  }
  .buttons {
    gap: 0.4rem;
  }
  button {
    font-size: 1rem;
    padding: 0.6rem 0.2rem;
    border-radius: 0.7rem;
  }
  .theme-switcher {
    gap: 0.3rem;
    margin-bottom: 0.5rem;
  }
  .theme-switcher button {
    font-size: 0.95rem;
    padding: 0.4rem 0.7rem;
    border-radius: 0.5rem;
  }
  .math-fun-panel {
    min-width: 0;
    max-width: 100vw;
    width: 100%;
    padding: 1rem 0.5rem;
    margin-top: 0.5rem;
    font-size: 1rem;
    box-sizing: border-box;
  }
  .fun-instruction {
    font-size: 1rem;
    min-height: 2.2rem;
    margin-bottom: 1rem;
  }
  .fun-buttons {
    gap: 0.5rem;
    flex-direction: column;
    width: 100%;
  }
  .fun-buttons button {
    width: 100%;
    font-size: 1.1rem;
    padding: 0.7rem 0;
  }
}
