/* Ants & Algebra — sibling of Ants & Apples */
#ants-algebra-root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #fdfaf5;
  color: #222;
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
}

.banner-container {
  margin: -16px -16px 16px -16px;
  line-height: 0;
}

#ants-algebra-root #banner {
  width: 100%;
  height: auto;
  display: block;
}

#ants-algebra-root header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

#ants-algebra-root .header-left {
  display: flex;
  gap: 6px;
  align-items: center;
}

#ants-algebra-root .pill-btn {
  border: none;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.8rem;
  background: #ddd;
  color: #222;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

#ants-algebra-root .pill-btn.primary {
  background: #e3f2fd;
  color: #1976d2;
  font-weight: 600;
}

#ants-algebra-root .pill-btn.print {
  background: #e0f5e5;
  color: #2e7d32;
  font-weight: 600;
  border: none;
  cursor: pointer;
}

#ants-algebra-root .pill-btn.music {
  background: #f0e4ff;
  color: #5b21b6;
  font-weight: 600;
  border: none;
  cursor: pointer;
}

#ants-algebra-root .pill-btn:active {
  transform: scale(0.97);
}

#ants-algebra-root main {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Mode tabs */
.mode-tabs {
  display: flex;
  gap: 6px;
  width: 100%;
  max-width: 400px;
  margin-bottom: 10px;
}

.mode-tab {
  flex: 1;
  border: 1px solid #d1d9e6;
  background: #fff;
  color: #555;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 8px 6px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.mode-tab:hover:not(.active) {
  background: #f0f4f8;
}

.mode-tab.active {
  background: #1976d2;
  color: #fff;
  border-color: #1976d2;
  box-shadow: 0 2px 8px rgba(25, 118, 210, 0.35);
}

/* Settings rows (per-mode controls) */
.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #f0f4f8;
  padding: 6px 10px;
  border-radius: 14px;
  border: 1px solid #d1d9e6;
  margin-bottom: 12px;
  width: 100%;
  max-width: 400px;
  box-sizing: border-box;
}

.settings-row .divider {
  width: 1px;
  height: 22px;
  background: #d1d9e6;
}

.settings-row .label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #555;
}

.toggle-btn {
  border: 1px solid #d1d9e6;
  background: #fff;
  color: #555;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  min-width: 84px;
}

.toggle-btn:hover {
  background: #f0f4f8;
}

.toggle-btn.active {
  background: #1976d2;
  color: #fff;
  border-color: #1976d2;
}

.toggle-btn.warn.active {
  background: #c62828;
  border-color: #c62828;
}

.len-btn {
  border: 1px solid #d1d9e6;
  background: #fff;
  color: #555;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
}

.len-btn.active {
  background: #1976d2;
  color: #fff;
  border-color: #1976d2;
}

/* Make the problem font shrink for longer chain equations */
.problem-text.compact {
  font-size: 1.6rem;
}

.problem-text.tiny {
  font-size: 1.3rem;
}

.problem-text .paren {
  white-space: nowrap;
}

.problem-text .xvar {
  color: #1976d2;
}

/* Operation picker */
.op-settings {
  display: flex;
  gap: 12px;
  background: #f0f4f8;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid #d1d9e6;
  margin: 8px 0 16px 0;
}

.op-btn {
  border: none;
  background: transparent;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 1.4rem;
  font-weight: 800;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
}

.op-btn.active {
  background: #1976d2;
  color: #fff;
  box-shadow: 0 2px 8px rgba(25, 118, 210, 0.4);
}

.op-btn:hover:not(.active) {
  background: #e1e7ef;
}

/* Problem box */
.problem-box {
  background: #fff;
  border: 1px solid #e1e7ef;
  border-radius: 24px;
  padding: 28px 20px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.problem-text {
  font-size: 2.4rem;
  font-weight: 800;
  color: #333;
  font-family: 'Courier New', Courier, monospace;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 15px;
}

.x-label {
  font-size: 1.8rem;
  font-weight: 700;
  color: #1976d2;
}

.x-label .xvar,
.problem-text .xvar {
  font-family: "Times New Roman", Times, serif;
  font-style: italic;
  font-weight: 800;
  color: #1976d2;
}

.x-input {
  width: 70px;
  height: 50px;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 700;
  border: 2px solid #1976d2;
  border-radius: 10px;
  background: #fff;
  color: #1976d2;
  caret-color: transparent;
}

.x-input:focus {
  outline: none;
  background: #e3f2fd;
}

/* Controls */
.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  width: 100%;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 1rem;
  font-weight: 700;
  background: #333;
  color: #fdfaf5;
  cursor: pointer;
}

.btn.secondary {
  background: #777;
}

.btn:active {
  transform: scale(0.97);
}

.message {
  margin-top: 6px;
  min-height: 22px;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
}

/* Status line */
.status {
  font-size: 0.85rem;
  color: #666;
  text-align: center;
  margin-top: 12px;
  line-height: 1.4;
}

.status .accent {
  font-weight: 700;
  color: #1976d2;
}

/* Keypad */
.keypad {
  margin-top: 14px;
  width: 100%;
  max-width: 320px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.key {
  background: #fff;
  border: 1px solid #d1d9e6;
  border-radius: 12px;
  padding: 14px 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: #333;
  cursor: pointer;
  text-align: center;
  user-select: none;
}

.key:active {
  transform: scale(0.96);
  background: #f0f4f8;
}

.key.action {
  background: #1976d2;
  color: #fff;
  border-color: #1976d2;
}

.key.action.clear {
  background: #777;
  border-color: #777;
}

.key.action.neg {
  background: #555;
  border-color: #555;
}
