/* bicial base styles — clean scaffold */

:root {
  --bg: #0f172a;
  --panel: #111827;
  --card: #0b1220;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --brand: #60a5fa;
  --border: #1f2937;
  /* Softer, high-contrast link colors */
  --link: #a7c7ff;
  --link-hover: #d2e2ff;
}

* {
  box-sizing: border-box;
}
/* Let the body grow with content and fill at least the viewport */
body {
  min-height: 100vh;
}
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial,
    sans-serif;
  background: linear-gradient(180deg, #0b1220 0%, #0a1629 100%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Global link styles */
a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
a:hover,
a:focus {
  color: var(--link-hover);
}
a:focus-visible {
  outline: 2px solid var(--link-hover);
  outline-offset: 2px;
  border-radius: 4px;
  text-decoration: none;
}

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

.site-header {
  padding: 2rem 0 1rem;
  text-align: center;
}
.title {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.2;
  letter-spacing: 0.2px;
}
.subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.site-main {
  padding: 0 0 2.5rem;
}

.card {
  background: radial-gradient(
      1200px 300px at 0% 0%,
      rgba(55, 96, 251, 0.15),
      transparent
    ),
    radial-gradient(800px 200px at 100% 0%, rgba(55, 96, 251, 0.1), transparent),
    var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  position: relative;
}

.controls-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  align-items: center;
  margin: 1rem 0;
}
.controls-row.compact {
  grid-template-columns: none;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  gap: 1rem 2rem;
  justify-content: start;
  align-items: center;
}

.control {
  display: grid;
  grid-template-columns: max-content 1fr;
  align-items: center;
  column-gap: 0.75rem;
}
.label {
  color: var(--muted);
  font-size: 0.95rem;
}
/* Make selected controls shrink to content width */
.control-inline {
  justify-self: start;
  grid-template-columns: max-content max-content;
}

.select,
.input,
.range,
.btn {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0a0f1d;
  color: var(--text);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.05);
}

.select,
.input {
  height: 40px;
  padding: 0 0.75rem;
  font-size: 0.95rem;
}
.range {
  height: 34px;
  width: 100%;
}
.range::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--brand);
}
.range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
}

.table-container {
  margin: 1.25rem 0;
}
.placeholder {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 2rem 0;
}

/* Table styles */
.fat {
  width: 100%;
  border-collapse: collapse;
}
.fat th,
.fat td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.fat thead th {
  color: var(--muted);
  font-weight: 600;
}
.fat input[type="number"] {
  width: 9ch;
  text-align: right;
}
/* Remove bottom border on the very last row */
.fat tbody tr:last-child td {
  border-bottom: none;
}
/* Subtle background for frequency inputs; desaturated on CI side */
.fat input.ear-input {
  background: #ffedd5; /* light orange */
}
#fatContainer[data-ci-side="L"] .fat input.ear-input[data-ear="L"],
#fatContainer[data-ci-side="R"] .fat input.ear-input[data-ear="R"] {
  background: #e2e8f0; /* slate-200 like, greyish blue */
  color: black; /* dark text for contrast on light bg */
}
/* Keep focus visible */
.fat input.ear-input:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.45);
  outline-offset: 1px;
}
.fat .btn-icon {
  width: 2.2em;
  height: 2.2em;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0a0f1d;
  color: var(--text);
  cursor: pointer;
}
.fat .btn-icon:hover {
  border-color: #2a3a5a;
}
.fat .btn-icon:disabled {
  opacity: 0.45;
  color: var(--muted);
  cursor: not-allowed;
  filter: grayscale(0.6);
  pointer-events: none;
}
.fat .btn-icon.is-on {
  background: rgba(96, 165, 250, 0.2);
  border-color: #3b82f6;
}
.fat .lr {
  font-size: 1.05rem;
}
.fat .single {
  font-size: 1rem;
}
.fat .row-check {
  transform: translateY(1px);
}
.fat .adj {
  width: 140px;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.actions-group {
  display: inline-flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.btn {
  padding: 0.6rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover {
  border-color: #2a3a5a;
}
.btn svg {
  margin-right: 0.5rem;
  vertical-align: -2px;
}

/* Icon button (help) */
.icon-button {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #0a0f1d;
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 700;
  cursor: pointer;
  font-size: 20px;
}
.icon-button:hover {
  border-color: #2a3a5a;
}

/* Help view */
.hidden {
  display: none;
}
.help {
  margin-top: 0.5rem;
}
/* vizView uses default .help styles, no fullscreen overlay */
.help-content {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0a0f1d;
}
.help-content h1,
.help-content h2,
.help-content h3 {
  margin-top: 1.1em;
}
.help-content a {
  color: var(--link);
}
.help-content code {
  background: rgba(255, 255, 255, 0.05);
  padding: 0.1em 0.3em;
  border-radius: 4px;
}

/* Center the visualization title */
#vizContent h2 {
  text-align: center;
}

.site-footer {
  border-top: none;
  padding: 0.25rem 0 0.5rem;
  color: var(--muted);
  text-align: center;
  background: transparent;
  margin-top: -2rem;
  position: relative;
  z-index: 1;
}

/* Segmented radio group styles */
.segmented {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #0a0f1d;
}
.segmented input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.segmented label {
  padding: 0.45rem 0.7rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
  border-right: 1px solid var(--border);
}
.segmented {
  white-space: nowrap;
}
.segmented label:last-of-type {
  border-right: 0;
}
.segmented input:checked + label {
  background: var(--brand);
  color: white;
}
.segmented input:not(:checked) + label:hover {
  background: rgba(96, 165, 250, 0.12);
  color: var(--text);
}
.segmented input:focus-visible + label {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

/* Narrow numeric inputs where appropriate (with a bit of room for steppers) */
.input-narrow {
  width: 11ch;
}
.input-narrow-3 {
  width: 8.5ch;
}

/* Toast notifications */
.toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}
.toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(480px, 90vw);
  padding: 10px 12px;
  border: 1px solid rgba(34, 197, 94, 0.35); /* green-500 */
  background: rgba(34, 197, 94, 0.12);
  color: var(--text);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  transform: translateY(8px);
  opacity: 0;
  transition: transform 0.18s ease, opacity 0.18s ease;
  cursor: pointer;
}
.toast.show {
  transform: translateY(0);
  opacity: 1;
}
.toast-icon {
  color: #22c55e; /* green-500 */
  font-size: 1.1rem;
}
.toast-text {
  line-height: 1.25;
}
