.layout {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0.5rem 1.25rem 1.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.85fr);
  gap: 1.1rem;
  align-items: start;
}

.stage {
  display: grid;
  gap: 1rem;
}

.stage-frame {
  position: relative;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  background: linear-gradient(180deg, rgba(8, 24, 36, 0.9), rgba(6, 18, 28, 0.95));
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.stage-frame.drag-over {
  border-color: rgba(53, 208, 197, 0.7);
}

#solCanvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: manipulation;
}

.drop-hint {
  position: absolute;
  left: 50%;
  top: 1rem;
  transform: translateX(-50%);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: rgba(53, 208, 197, 0.16);
  border: 1px solid rgba(53, 208, 197, 0.45);
  color: var(--cyan);
  font-size: 0.82rem;
  font-weight: 600;
  pointer-events: none;
  animation: hintPulse 1.2s ease-in-out infinite;
}

@keyframes hintPulse {
  50% {
    opacity: 0.6;
  }
}

.shelf-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.shelf-head p {
  margin: 0.3rem 0 0.9rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.shelf-group + .shelf-group {
  margin-top: 0.9rem;
}

.shelf-group h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.55rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-soluble {
  background: var(--cyan);
}

.dot-insoluble {
  background: var(--amber);
}

.salt-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}

.salt-chip {
  position: relative;
  display: grid;
  gap: 0.15rem;
  justify-items: start;
  padding: 0.7rem 0.75rem 0.65rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.salt-chip:hover {
  transform: translateY(-2px);
  border-color: rgba(53, 208, 197, 0.4);
}

.salt-chip.active {
  border-color: rgba(53, 208, 197, 0.7);
  background: rgba(53, 208, 197, 0.1);
}

.salt-chip.insoluble.active {
  border-color: rgba(240, 180, 41, 0.7);
  background: rgba(240, 180, 41, 0.08);
}

.salt-chip:active {
  cursor: grabbing;
}

.salt-crystal {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  transform: rotate(18deg);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.25);
}

.salt-formula {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
}

.salt-formula sub,
.info-formula sub {
  font-size: 0.62em;
  line-height: 0;
  vertical-align: -0.25em;
}

.salt-name {
  color: var(--muted);
  font-size: 0.72rem;
}

.panel {
  display: grid;
  gap: 1rem;
}

.info-card.refresh {
  animation: infoSwap 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes infoSwap {
  from {
    opacity: 0.2;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.info-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.info-formula {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--cyan);
}

.info-card.is-insoluble .info-formula {
  color: var(--amber);
}

.info-card.is-insoluble .badge {
  border-color: rgba(240, 180, 41, 0.4);
  background: rgba(240, 180, 41, 0.1);
  color: var(--amber);
}

.info-head h2 {
  margin: 0.3rem 0 0;
  font-size: 1rem;
  font-weight: 600;
}

.info-desc {
  margin: 0.75rem 0 0.9rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.info-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  margin: 0;
}

.info-facts .full {
  grid-column: 1 / -1;
}

.info-facts dt {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.info-facts dd {
  margin: 0.2rem 0 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.ion-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0.2rem 0.35rem 0 0;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.82rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}

.ion-tag i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.control-card h3,
.meter-head h3 {
  margin: 0 0 0.55rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.segmented.dose {
  grid-template-columns: repeat(3, 1fr);
}

.seg-btn {
  display: grid;
  gap: 0.1rem;
  padding: 0.6rem 0.5rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.seg-btn span {
  color: var(--muted);
  font-size: 0.75rem;
}

.seg-btn.active {
  border-color: rgba(53, 208, 197, 0.7);
  background: rgba(53, 208, 197, 0.12);
}

.actions {
  display: grid;
  gap: 0.55rem;
}

.btn.small {
  padding: 0.55rem 0.8rem;
  font-size: 0.85rem;
}

.confirm-bar {
  margin-top: 0.85rem;
  padding: 0.8rem;
  border-radius: 12px;
  border: 1px solid rgba(240, 180, 41, 0.4);
  background: rgba(240, 180, 41, 0.08);
  animation: infoSwap 0.3s ease;
}

.confirm-bar p {
  margin: 0 0 0.6rem;
  font-size: 0.86rem;
  line-height: 1.45;
}

.confirm-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.meter-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.meter-head h3 {
  margin: 0;
}

.state-chip {
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--line);
  color: var(--muted);
  transition: color 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}

.state-chip[data-state="insaturada"] {
  color: var(--cyan);
  border-color: rgba(53, 208, 197, 0.45);
  background: rgba(53, 208, 197, 0.1);
}

.state-chip[data-state="saturada"] {
  color: var(--mint);
  border-color: rgba(154, 240, 216, 0.5);
  background: rgba(154, 240, 216, 0.1);
}

.state-chip[data-state="corpo-de-fundo"] {
  color: var(--amber);
  border-color: rgba(240, 180, 41, 0.5);
  background: rgba(240, 180, 41, 0.1);
  animation: chipPop 0.5s ease;
}

@keyframes chipPop {
  40% {
    transform: scale(1.1);
  }
}

.readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.readout .label {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}

.readout strong {
  font-size: clamp(1.1rem, 2.4vw, 1.4rem);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--mint));
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1), background 0.3s ease;
}

.progress-fill.full {
  background: linear-gradient(90deg, var(--mint), var(--amber));
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 50;
  padding: 0.45rem 0.75rem;
  border-radius: 12px;
  background: rgba(10, 28, 42, 0.92);
  border: 1px solid rgba(53, 208, 197, 0.6);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  pointer-events: none;
  transform: translate(-50%, -120%);
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .salt-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .info-formula {
    font-size: 1.7rem;
  }
}
