/* pH Titration Curve — clean, readable UI */

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --text: #e6edf3;
  --text-muted: #8b9cb3;
  --accent: #58a6ff;
  --accent-dim: #388bfd66;
  --success: #3fb950;
  --danger: #f85149;
  --border: #30363d;
  --radius: 8px;
  --font-sans: "DM Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Consolas", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  margin: 0 0 0.25rem 0;
  font-size: 1.75rem;
  font-weight: 600;
}

.subtitle, .hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}

.main {
  display: grid;
  gap: 1.5rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.panel h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.panel .hint {
  margin-bottom: 1rem;
}

/* Analyte */
.analyte-volume-row {
  margin-bottom: 1rem;
}

.analyte-volume-row label,
.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

input[type="number"],
input[type="text"],
select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

.species-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
}

.species-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface2);
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.species-item .name {
  font-weight: 500;
}

.species-item .conc {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.species-item .pkas {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.species-item .actions {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
}

.species-item-custom {
  background: rgba(230, 160, 80, 0.18);
  border-left: 3px solid rgba(230, 160, 80, 0.6);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
}

.btn-icon:hover {
  color: var(--text);
  background: var(--surface);
}

.btn-icon.danger:hover {
  color: var(--danger);
}

.add-species label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.add-row select {
  min-width: 180px;
}

.add-row input[type="number"] {
  width: 140px;
}

button {
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
}

button:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.add-species-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
}

.add-species-row .add-species {
  flex: 1;
  min-width: 280px;
}

.add-species-row .add-species-custom .add-row {
  flex-wrap: wrap;
}

.btn-remove-compound {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
}

.btn-remove-compound:hover {
  color: var(--danger);
}

.custom-compound {
  margin-top: 0.75rem;
}

/* Titrant */
.titrant-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.titrant-fields .field {
  min-width: 200px;
}

.titrant-fields input[type="checkbox"] {
  margin-right: 0.5rem;
}

/* Curve */
.curve-and-indicators {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.curve-wrap {
  position: relative;
  background: var(--bg);
  border-radius: var(--radius);
  overflow: hidden;
  flex: 0 0 auto;
}

.indicators-column {
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.indicators-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.indicators-checkbox {
  accent-color: var(--success);
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}

.indicators-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

.indicators-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  max-height: 450px;
  overflow-y: auto;
  padding: 0.25rem;
}

.indicator-item {
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
  cursor: pointer;
  border-radius: 4px;
  border: 1px solid transparent;
  line-height: 1.35;
}

.indicator-item:hover {
  background: var(--surface);
}

.indicator-item.selected {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.indicator-item .ind-name {
  font-weight: 500;
  color: var(--text);
}

.indicator-item .ind-meta {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.indicator-item .ind-color {
  font-weight: 500;
}

#curve-canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 500px;
}

.curve-legend {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.curve-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.curve-controls label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.curve-controls input {
  width: 80px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal[hidden] {
  display: none;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  min-width: 320px;
  max-width: 90vw;
}

.modal-content h3 {
  margin: 0 0 1rem 0;
  font-size: 1.1rem;
}

.modal-content .field {
  margin-bottom: 1rem;
}

.modal-content .field input[type="text"] {
  width: 100%;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer em {
  font-style: italic;
}

.footer a {
  color: #fff;
}

.footer a:hover {
  color: #fff;
  text-decoration: underline;
}
