*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4f;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --error: #ef4444;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.subtitle {
  color: var(--muted);
  margin: 0 0 1.25rem;
}

.mode-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.mode-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.mode-btn:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--text);
}

.mode-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.mode-btn.active:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 1rem;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

textarea {
  width: 100%;
  min-height: 280px;
  padding: 0.75rem;
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.8rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
}

input[type="password"] {
  width: 100%;
  padding: 0.75rem;
  font-size: 0.875rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
}

input[type="file"] {
  width: 100%;
  padding: 0.5rem;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
}

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--error);
  color: #fca5a5;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  white-space: pre-wrap;
}

.hidden {
  display: none !important;
}

.results-grid {
  display: grid;
  gap: 1.25rem;
  margin-top: 2rem;
}

.dendrogram-img {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
}

pre.json-out {
  margin: 0;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
  font-size: 0.75rem;
  max-height: 320px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.meta-row strong {
  color: var(--text);
}

.actions {
  margin-top: 1.25rem;
}
