body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  padding: 0;
  background: #f5f5f5;
}

.container {
  max-width: 800px;
  margin: 2rem auto;
  background: #ffffff;
  border-radius: 10px;
  padding: 1.5rem 1.75rem;
  border: 1px solid #dddddd;
  box-sizing: border-box;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
}

h1 {
  margin: 0 0 0.4rem 0;
  font-size: 1.6rem;
}

.subtitle {
  margin: 0 0 1rem 0;
  font-size: 0.9rem;
  color: #555;
  line-height: 1.4;
}

.subtitle code {
  background: #f0f0f0;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

textarea {
  width: 100%;
  min-height: 70px;
  max-height: 220px;
  resize: vertical;
  box-sizing: border-box;
  padding: 0.6rem 0.7rem;
  font-size: 0.95rem;
  border-radius: 6px;
  border: 1px solid #cccccc;
  outline: none;
}

textarea:focus {
  border-color: #2684ff;
  box-shadow: 0 0 0 2px rgba(38, 132, 255, 0.15);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.6rem;
  margin-bottom: 0.8rem;
  justify-content: space-between;
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

button {
  border-radius: 5px;
  border: 1px solid #cccccc;
  background: #f3f3f3;
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

button:hover {
  background: #e5e5e5;
}

button:active {
  transform: scale(0.98);
}

#analyzeBtn {
  background: #2684ff;
  border-color: #2684ff;
  color: #ffffff;
}

#analyzeBtn:hover {
  background: #1c6fd6;
}

.hint {
  font-size: 0.8rem;
  color: #555;
  max-width: 260px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.25rem;
}

.pill {
  font-size: 0.8rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  border: 1px solid #cccccc;
  background: #f7f7f7;
  cursor: pointer;
}

.pill:hover {
  background: #eeeeee;
}

#messages {
  margin-top: 0.3rem;
}

.message {
  margin-bottom: 0.7rem;
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
}

.message.error {
  background: #ffe5e5;
  border: 1px solid #ff9a9a;
  color: #8b0000;
}

.message.info {
  background: #e8f0ff;
  border: 1px solid #a4c1ff;
  color: #123c7b;
}

.section-title {
  margin-top: 1rem;
  margin-bottom: 0.4rem;
  font-size: 1rem;
  font-weight: 600;
  border-bottom: 1px solid #dddddd;
  padding-bottom: 0.2rem;
}

.card {
  margin-top: 0.4rem;
  padding: 0.7rem 0.8rem;
  border-radius: 6px;
  border: 1px solid #dddddd;
  background: #fafafa;
  font-size: 0.9rem;
}

.balanced-equation {
  font-family: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 1rem;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  background: #ffffff;
  border: 1px solid #dddddd;
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
  box-sizing: border-box;
}

.molecule {
  border-top: 1px solid #e0e0e0;
  padding-top: 0.5rem;
  margin-top: 0.5rem;
}

.molecule:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.molecule-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.molecule-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.badge {
  font-size: 0.8rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #cccccc;
}

.molecule-meta {
  font-size: 0.82rem;
  color: #555;
  margin-bottom: 0.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.6rem;
}

pre.lewis {
  background: #ffffff;
  border-radius: 4px;
  border: 1px solid #dddddd;
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
  overflow-x: auto;
  margin: 0.2rem 0 0.4rem;
  white-space: pre;
  font-family: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.description {
  font-size: 0.83rem;
  color: #444;
}

.legend {
  margin-top: 0.8rem;
  font-size: 0.8rem;
  color: #555;
  background: #f3f6ff;
  border-radius: 4px;
  padding: 0.4rem 0.5rem;
  border: 1px solid #d5defc;
}

@media (max-width: 640px) {
  .container {
    margin: 1rem;
    padding: 1.1rem 1.2rem;
  }
}
