/* Spherical Unitary Explorer (/dissemination/spherical/explorer/) */

.explorer .lede { font-size: var(--step-1); line-height: 1.55; }
.explorer .note { max-width: var(--measure); }

/* status line: loading / ready / busy / error */
.sph-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.7rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--surface);
  font-size: var(--step--1);
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 2;
}
.sph-status-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  border: 2px solid var(--muted);
  flex: none;
}
.sph-status[data-state="loading"] .sph-status-dot,
.sph-status[data-state="busy"] .sph-status-dot {
  border-color: var(--rule);
  border-top-color: var(--accent);
  animation: sph-spin 0.9s linear infinite;
}
.sph-status[data-state="ready"] .sph-status-dot { border-color: var(--link); background: var(--link); }
.sph-status[data-state="error"] { color: var(--accent); border-color: var(--accent); }
.sph-status[data-state="error"] .sph-status-dot { border-color: var(--accent); background: var(--accent); }
.sph-status-text { flex: 1 1 16rem; }
@keyframes sph-spin { to { transform: rotate(360deg); } }

.sph-small-button {
  font: inherit;
  font-weight: 600;
  padding: 0.15rem 0.7rem;
  border: 1px solid var(--muted);
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.sph-small-button:hover { border-color: var(--accent); color: var(--accent); }

/* forms beside results */
.sph-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}
@media (min-width: 1000px) {
  .sph-layout { grid-template-columns: minmax(20rem, 25rem) minmax(0, 1fr); gap: 2rem; }
}
.sph-forms { display: grid; gap: 1rem; min-width: 0; }

.sph-card {
  display: grid;
  gap: 0.8rem;
  padding: 1rem 1.1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 3px;
  min-width: 0;
}
.sph-card h2 {
  font-size: var(--step-1);
}
.sph-card label {
  display: grid;
  gap: 0.25rem;
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--ink);
}
.sph-card .sph-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}
.sph-row { display: flex; flex-wrap: wrap; gap: 0.8rem 1rem; align-items: end; }
.sph-row > label { flex: 0 1 auto; }
.sph-hint { font-size: var(--step--1); color: var(--muted); }

.sph-card input[type="text"],
.sph-card input[type="number"],
.sph-card select,
.sph-card textarea {
  font: inherit;
  font-weight: 400;
  font-size: var(--step-0);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.35rem 0.5rem;
  min-width: 0;
  max-width: 100%;
}
.sph-card input[type="text"], .sph-card textarea { font-family: var(--mono); font-size: 0.95rem; }
.sph-card textarea { resize: vertical; line-height: 1.45; }
.sph-card input:focus, .sph-card select:focus, .sph-card textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}
.sph-card .sph-num { width: 5.5rem; }
.sph-card .sph-wide input[type="text"], .sph-card .sph-wide textarea { width: 100%; }
.sph-file-input input[type="file"] { font: inherit; font-weight: 400; font-size: var(--step--1); color: var(--muted); max-width: 100%; }
.sph-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.sph-actions .button { font-family: inherit; cursor: pointer; background: transparent; }
.sph-actions .button.primary { background: var(--ink); }
.sph-actions .button:disabled { opacity: 0.45; cursor: not-allowed; }
.sph-actions .button:disabled:hover { border-color: var(--ink); color: var(--ink); }
.sph-actions .button.primary:disabled:hover { background: var(--ink); color: var(--paper); }

/* results */
.sph-output { display: grid; gap: 0.75rem; min-width: 0; }
.sph-output-head { font-size: var(--step-1); }
.sph-results {
  display: grid;
  gap: 0.9rem;
  align-content: start;
  min-width: 0;
  min-height: 8rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 3px;
  font-size: var(--step--1);
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.sph-results:focus { outline: none; }
.sph-placeholder { color: var(--muted); }
.sph-result-title { font-size: var(--step-1); }
.sph-results h3 { font-size: var(--step-0); }
.sph-results h4 { margin: 0; font-size: var(--step--1); font-weight: 600; }
.sph-results hr, .sph-help-example hr { border: 0; border-top: 1px solid var(--rule); width: 100%; margin: 0.2rem 0; }
.sph-group { font-weight: 600; }
.sph-message { color: var(--muted); border-left: 3px solid var(--rule); padding-left: 0.8rem; }
.sph-error { color: var(--accent); font-weight: 500; }
.sph-file { color: var(--muted); }
.sph-summary { font-family: var(--mono); font-size: 0.85rem; }
.sph-summary strong:first-child { font-family: var(--sans); }
.sph-verdict {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  padding: 0 0.4rem;
  border: 1px solid currentColor;
  border-radius: 3px;
  margin-left: 0.3rem;
  white-space: nowrap;
}
.sph-yes { color: var(--link); }
.sph-no { color: var(--accent); }

.sph-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--rule);
  border-radius: 3px;
}
table.sph-table {
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.4;
}
table.sph-table th, table.sph-table td {
  padding: 0.3rem 0.65rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}
table.sph-table th {
  font-family: var(--sans);
  font-weight: 600;
  background: var(--paper);
}
table.sph-table td + td, table.sph-table th + th { border-left: 1px solid var(--rule); }
table.sph-table tr:last-child > td { border-bottom: 0; }
table.sph-list td { white-space: normal; min-width: 5rem; }
table.sph-list td:first-child { white-space: nowrap; }

.sph-diagram {
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.4rem 0.8rem;
  background: var(--paper);
}
.sph-diagram > summary { cursor: pointer; font-weight: 600; color: var(--link); }
.sph-diagram[open] { display: grid; gap: 0.6rem; padding-bottom: 0.8rem; }
.sph-results pre, .sph-pre {
  margin: 0;
  padding: 0.7rem 0.9rem;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.45;
  overflow-wrap: normal;
}

/* root systems, help, about */
.sph-section { display: grid; gap: 1.1rem; margin-top: 1.5rem; min-width: 0; }
.sph-roots-form { width: fit-content; max-width: 100%; }
.sph-root-results { min-height: 0; }
.sph-section .data-prose pre {
  margin: 0;
  padding: 0.7rem 0.9rem;
  width: fit-content;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow-x: auto;
  font-size: 0.85rem;
}
.sph-help-example {
  display: grid;
  gap: 0.8rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 3px;
  font-size: var(--step--1);
  overflow-wrap: anywhere;
}
.sph-help-example p { font-family: var(--mono); font-size: 0.85rem; }
.sph-help-example p.sph-group { font-family: var(--sans); }
.sph-help h3 { margin-top: 0.5rem; }
