:root {
  color-scheme: light dark;
  --ink: #0f172a;
  --muted: #55657a;
  --line: #d7dee8;
  --panel: #ffffff;
  --page: #f8fafc;
  --accent: #1d4ed8;
  --warning: #b45309;
  --danger: #b91c1c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e2e8f0;
    --muted: #a3b1c2;
    --line: #2a3950;
    --panel: #0f172a;
    --page: #020617;
    --accent: #7dd3fc;
    --warning: #fbbf24;
    --danger: #fca5a5;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.masthead h1 {
  margin: 0;
  font-size: 1.9rem;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.25rem 0 0;
  font-size: 1.05rem;
}

.privacy {
  margin: 0.75rem 0 0;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--accent);
  background: var(--panel);
  font-size: 0.95rem;
}

.drop-zone {
  margin: 1.5rem 0 0;
  padding: 1.5rem 1rem;
  border: 2px dashed var(--line);
  border-radius: 10px;
  background: var(--panel);
  text-align: center;
  transition: border-color 120ms ease, background 120ms ease;
}

.drop-zone.is-dragging {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
}

.field-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.file-input {
  font: inherit;
  color: inherit;
  max-width: 100%;
  min-height: 44px;
  padding: 0.4rem;
}

.file-input::file-selector-button {
  font: inherit;
  font-size: 0.9rem;
  min-height: 44px;
  margin-right: 0.6rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--page);
  color: var(--ink);
  cursor: pointer;
}

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

.file-name {
  margin: 0.75rem 0 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.status {
  min-height: 1.5rem;
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.spinner {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  margin-right: 0.4rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -0.1rem;
  animation: spin 0.8s linear infinite;
}

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

.panel {
  margin: 1rem 0;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  min-width: 0;
}

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

.panel-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem 1rem;
  margin: 1rem 0 0;
}

.facts dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.facts dd {
  margin: 0.15rem 0 0;
  font-variant-numeric: tabular-nums;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  min-width: 0;
}

select {
  font: inherit;
  font-size: 0.9rem;
  min-height: 44px;
  max-width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
}

.button {
  font: inherit;
  font-size: 0.9rem;
  min-height: 44px;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

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

.button.secondary {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.toggle button {
  font: inherit;
  font-size: 0.9rem;
  min-height: 44px;
  padding: 0.5rem 0.8rem;
  border: 0;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
}

.toggle button + button {
  border-left: 1px solid var(--line);
}

.toggle button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--page);
}

.chart {
  width: 100%;
  min-height: 340px;
  margin-top: 1rem;
  overflow: hidden;
}

.chart-summary {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}

.chart-note {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
}

.note {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
}

.details {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.details summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.details p,
.details ul {
  margin: 0.5rem 0 0;
  overflow-wrap: anywhere;
}

.warning {
  border-color: var(--warning);
}

.error {
  border-color: var(--danger);
}

.empty {
  border-color: var(--muted);
}

.panel p {
  overflow-wrap: anywhere;
}

.preview summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  align-items: baseline;
  min-height: 44px;
  cursor: pointer;
}

.preview-title {
  font-weight: 600;
  font-size: 1.05rem;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

table.channels,
table.readings {
  width: 100%;
  margin-top: 0.75rem;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

table.channels {
  font-size: 0.9rem;
}

table.readings {
  font-size: 0.85rem;
}

table.channels th,
table.channels td,
table.readings th,
table.readings td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

table.channels th,
table.readings th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table.readings .number {
  text-align: right;
}

.muted {
  color: var(--muted);
  font-weight: 400;
}

.footer {
  margin-top: 2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.footer a {
  color: var(--accent);
}

.loading {
  padding: 3rem 1.25rem;
  text-align: center;
  color: var(--muted);
}

#blazor-error-ui {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.9rem 1.25rem;
  background: #fef3c7;
  color: #78350f;
  box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
}

#blazor-error-ui .dismiss {
  float: right;
  cursor: pointer;
}

#blazor-error-ui a {
  margin-left: 0.5rem;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
