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

html,
body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f4f6;
  color: #042f00;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.app-header {
  border-bottom: 1px solid rgba(209, 213, 219, 0.9);
  background: #ffffff;
}

.header-inner {
  padding: 1.5rem 0 1rem 0;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
}

.brand-logo {
  height: 32px;
  width: auto;
}

.brand-text {
  display: flex;
  flex-direction: row;
}

.app-header h1 {
  margin: 0 0 0.25rem 0;
  font-size: 1.6rem;
  letter-spacing: 0.08em;
  color: #042f00;
}

.subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: #6b7280;
}

.app-main {
  flex: 1;
  padding: 1.5rem 0 2.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel {
  background: #ffffff;
  border-radius: 0.75rem;
  border: 1px solid rgba(209, 213, 219, 0.9);
  padding: 1.2rem 1.3rem 1.4rem 1.3rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.panel h2 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.panel-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.panel h3 {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.98rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}

.field-label {
  font-size: 0.85rem;
  color: #4b5563;
}

textarea,
input[type="number"] {
  width: 100%;
  max-width: 100%;
  border-radius: 0.5rem;
  border: 1px solid rgba(209, 213, 219, 0.9);
  padding: 0.6rem 0.75rem;
  background: #f9fafb;
  color: #111827;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 0.85rem;
  resize: vertical;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.input-invalid {
  border-color: #b91c1c !important;
  box-shadow: 0 0 0 1px rgba(185, 28, 28, 0.25);
}

.input-error {
  margin: 0.1rem 0 0 0;
  font-size: 0.78rem;
  color: #b91c1c;
}

textarea::placeholder {
  color: #9ca3af;
}

textarea:focus,
input[type="number"]:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.35);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.stacked-on-mobile {
  gap: 0.75rem;
}

/* For the sequence view grid, always stack vertically */
.grid-2.stacked-on-mobile {
  grid-template-columns: 1fr;
}

@media (max-width: 768px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.strategy-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.85rem;
}

.strategy-options label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(209, 213, 219, 0.9);
  background: #f9fafb;
}

.expert-card {
  display: none;
}

.expert-card > summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.85rem;
  font-weight: 500;
  color: #042f00;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.expert-card[open] > summary {
  margin-bottom: 0.4rem;
}

.expert-card > summary::before {
  content: "▸";
  font-size: 0.7rem;
  color: #6b7280;
}

.expert-card[open] > summary::before {
  content: "▾";
}

.expert-inner {
  margin-top: 0.2rem;
}

.strategy-options input[type="radio"] {
  accent-color: #3b82f6;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0;
}

.actions-centered {
  justify-content: center;
}

.icon-btn {
  border-radius: 999px;
  border: none;
  background: #ffffff;
  color: #4b5563;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.1rem;
}

.icon-btn:hover {
  background: #f3f4f6;
}

.material-symbols-outlined {
  font-variation-settings:
    "FILL" 0,
    "wght" 400,
    "GRAD" 0,
    "opsz" 24;
  font-size: 20px;
}

button {
  border-radius: 999px;
  border: 1px solid rgba(209, 213, 219, 0.9);
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  background: #ffffff;
  color: #111827;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.06s ease,
    box-shadow 0.1s ease;
}

button.primary {
  border-color: #042f00;
  background: #042f00;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 10px 26px rgba(4, 47, 0, 0.35);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
}

button:not(:disabled):hover {
  border-color: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
}

button.primary:not(:disabled):hover {
  box-shadow: 0 14px 34px rgba(4, 47, 0, 0.5);
}

.status {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  min-height: 1.1rem;
}

.status.info {
  color: #374151;
}

.status.error {
  color: #b91c1c;
}

.status.success {
  color: #166534;
}

.result-summary {
  font-size: 0.85rem;
  color: #111827;
  margin-bottom: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
}

.result-pill {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(209, 213, 219, 0.9);
  font-size: 0.8rem;
}

.result-pill.good {
  border-color: #16a34a;
  color: #14532d;
}

.result-pill.warn {
  border-color: #f97316;
  color: #9a3412;
}

.seq-view {
  max-height: 16rem;
  border-radius: 0.6rem;
  border: 1px solid rgba(209, 213, 219, 0.9);
  padding: 0.6rem 0.7rem;
  background: #f9fafb;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 0.78rem;
  line-height: 1.4;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.codon-diff {
  border-radius: 0.6rem;
  border: 1px solid rgba(209, 213, 219, 0.9);
  padding: 0.6rem 0.7rem;
  background: #f9fafb;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  min-height: 2.2rem;
  max-height: 14rem;
  overflow: auto;
}

.codon-block {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 0.25rem 0.4rem;
  margin: 0.1rem 0.25rem 0.1rem 0;
  border-radius: 0.5rem;
  border: 1px solid transparent;
}

.codon-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.08rem 0.38rem;
  margin: 0.05rem 0.12rem 0.05rem 0;
  border-radius: 0.42rem;
  border: 1px solid transparent;
}

.codon-chip.same {
  color: #6b7280;
}

.codon-chip.changed {
  background: rgba(22, 163, 74, 0.08);
  border-color: rgba(22, 163, 74, 0.7);
  color: #14532d;
}

.codon-chip.origin-only,
.codon-chip.new-only {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.7);
  color: #7f1d1d;
}

.codon-chip-index {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-right: 0.15rem;
}

.codon-aa {
  font-size: 0.75rem;
}

.codon-seq {
  font-size: 0.8rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-top: 0.4rem;
}

.data-table th,
.data-table td {
  padding: 0.35rem 0.45rem;
  border-bottom: 1px solid rgba(229, 231, 235, 1);
  color: #111827;
}

.data-table thead th {
  text-align: left;
  color: #111827;
  background: #f3f4f6;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table tbody tr:nth-child(even) {
  background: #f9fafb;
}

.data-table tbody tr:nth-child(odd) {
  background: #ffffff;
}

.flag-ok {
  color: #166534;
}

.flag-unwanted {
  color: #b91c1c;
}

.muted {
  color: #6b7280;
  font-size: 0.8rem;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.loading-overlay.hidden {
  display: none;
}

.hidden {
  display: none;
}

.loading-modal {
  background: #ffffff;
  border-radius: 0.75rem;
  padding: 1.1rem 1.4rem 1.3rem 1.4rem;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.2);
  border: 1px solid rgba(209, 213, 219, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.spinner {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  border: 3px solid #e5e7eb;
  border-top-color: #3b82f6;
  animation: spin 0.8s linear infinite;
}

.loading-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #111827;
}

.loading-progress {
  margin: 0;
  font-size: 0.82rem;
  color: #6b7280;
  text-align: center;
}

.loading-footnote {
  margin: 0.35rem 0 0 0;
  font-size: 0.74rem;
  color: #9ca3af;
  text-align: center;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.settings-overlay.hidden {
  display: none;
}

.settings-modal {
  background: #ffffff;
  border-radius: 0.75rem;
  padding: 0.9rem 1.1rem 1.1rem 1.1rem;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.2);
  border: 1px solid rgba(209, 213, 219, 0.9);
  max-width: 460px;
  width: 100%;
}

/* Info modal: wider and scrollable */
.info-modal {
  max-width: min(640px, 92vw);
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.info-modal .settings-header {
  flex-shrink: 0;
  padding: 0.9rem 1.1rem 0.4rem 1.1rem;
}

.info-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 1.1rem 1.1rem 1.1rem;
  margin-top: 0.2rem;
}

.info-modal-body h4 {
  margin: 1rem 0 0.4rem 0;
  font-size: 0.95rem;
}

.info-modal-body p,
.info-modal-body ul,
.info-modal-body ol {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.info-modal-body ul,
.info-modal-body ol {
  padding-left: 1.25rem;
}

.info-modal-body code {
  font-size: 0.85em;
  padding: 0.1rem 0.35rem;
  background: #f3f4f6;
  border-radius: 0.25rem;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.settings-header h3 {
  margin: 0;
  font-size: 1rem;
}

.app-footer {
  border-top: 1px solid rgba(209, 213, 219, 0.9);
  padding: 0.75rem 0 0.9rem 0;
  background: #f9fafb;
  font-size: 0.8rem;
}

