:root {
  --ink: #0e1419;
  --ink-soft: #1a242c;
  --fog: #edf2f5;
  --sand: #e0c08a;
  --sand-deep: #c4a574;
  --ice: #9fd4e4;
  --bg: #0a1014;
  --bg-panel: rgba(18, 26, 33, 0.92);
  --bg-card: #182229;
  --bg-hover: #223039;
  --border: rgba(255, 255, 255, 0.14);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.78);
  --muted-soft: rgba(255, 255, 255, 0.58);
  --accent: var(--ice);
  --accent-2: var(--sand);
  --green: #8fd9a4;
  --amber: #e8c07a;
  --rose: #f0a8b6;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
  --radius: 12px;
  /* Serif for reading; soft humanist sans for chrome — less flat than Syne */
  --font-ui: "Nunito", "Segoe UI", sans-serif;
  --font-body: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-display: "Source Serif 4", Georgia, serif;
}

* {
  box-sizing: border-box;
}

/* Author display:flex/grid rules otherwise override the UA [hidden] stylesheet. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(ellipse 90% 70% at 78% 8%, rgba(126, 184, 201, 0.12), transparent 55%),
    radial-gradient(ellipse 70% 55% at 8% 92%, rgba(196, 165, 116, 0.1), transparent 50%),
    linear-gradient(165deg, #0a1014 0%, var(--ink) 45%, var(--ink-soft) 100%);
  background-attachment: fixed;
}

button {
  font: inherit;
  cursor: pointer;
}

h1, h2, h3,
.panel-head h2,
.select-header h1,
.run-card-title,
.detail-header h3,
#chartTitle {
  font-family: var(--font-display);
  font-optical-sizing: auto;
}

.loss-section-title,
.flow-label,
.spec-group-title,
.ref-obs-title,
.module-node .title,
.chart-btn,
.layer-tab,
.header-link,
.badge,
.spec-chip,
.compare-toggle {
  font-family: var(--font-ui);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.75rem;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(10, 16, 20, 0.82);
}

.app-header h1 {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: #ffffff;
}

.app-header p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-family: var(--font-body);
  line-height: 1.45;
}

.curator-bar {
  z-index: 9;
  border-bottom: 1px solid rgba(232, 200, 136, 0.35);
  background: rgba(28, 22, 12, 0.94);
}

.curator-bar[hidden] {
  display: none !important;
}

.curator-bar-inner {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  padding: 0.28rem 1rem;
  min-height: 0;
}

.curator-bar-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  width: 100%;
}

.curator-bar-btn {
  padding: 0.18rem 0.5rem !important;
  font-size: 0.75rem !important;
  line-height: 1.2;
}

.curator-maint-on {
  border-color: rgba(181, 74, 58, 0.65) !important;
  color: #f0c4bc !important;
  background: rgba(181, 74, 58, 0.22) !important;
}

html.gate-pending body {
  visibility: hidden;
}

.maintenance-page {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(196, 165, 116, 0.18), transparent),
    var(--bg, #14110c);
}

.maintenance-shell {
  max-width: 32rem;
  margin: 0 auto;
  padding: 4.5rem 1.5rem 3rem;
  text-align: center;
}

.maintenance-kicker {
  margin: 0 0 0.75rem;
  font-family: var(--font-ui, Nunito, sans-serif);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted, #9a8f7a);
}

.maintenance-shell h1 {
  margin: 0 0 0.85rem;
  font-family: var(--font-body, "Source Serif 4", Georgia, serif);
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  font-weight: 600;
  line-height: 1.2;
  color: var(--text, #f3ebe0);
}

.maintenance-lead {
  margin: 0 0 1.5rem;
  color: var(--muted, #9a8f7a);
  font-size: 1.02rem;
  line-height: 1.55;
}

.maintenance-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem 1.25rem;
}

.maintenance-admin-hint {
  margin: 1.25rem 0 0;
  font-size: 0.85rem;
  color: #c4a574;
}

.curator-link {
  color: #ffe6b8;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(232, 200, 136, 0.45);
}

.curator-link:hover {
  color: #fff6e0;
  border-bottom-color: rgba(255, 246, 224, 0.7);
}

.site-announcement {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.65rem 1.75rem 0.75rem;
  border-bottom: 1px solid rgba(232, 200, 136, 0.4);
  background: rgba(40, 28, 10, 0.95);
  color: #ffe6b8;
  font-size: 0.88rem;
  line-height: 1.45;
}

.site-announcement[hidden] {
  display: none !important;
}

.site-announcement-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1rem;
}

.site-announcement-label {
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #e8c888;
}

.site-announcement-all,
.site-announcement-more a {
  color: #ffe6b8;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(232, 200, 136, 0.4);
}

.site-announcement-all:hover,
.site-announcement-more a:hover {
  color: #fff6e0;
}

.site-announcement-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.site-announcement-list li {
  margin: 0;
  padding: 0;
}

.site-announcement-list p,
.site-announcement p {
  margin: 0;
  color: #fff6e0;
  white-space: pre-wrap;
  word-break: break-word;
}

.site-announcement-more {
  margin: 0;
  font-size: 0.78rem;
}

.announce-shell {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.announce-composer {
  margin-bottom: 1.5rem;
  padding: 1rem 1.1rem;
}

.announce-composer h2 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
  font-family: var(--font-ui);
}

.announce-composer textarea,
.announce-edit-ta {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg-card);
  resize: vertical;
  min-height: 4rem;
  box-sizing: border-box;
}

.announce-composer-actions,
.announce-item-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.announce-migrate {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

.announce-migrate p {
  margin: 0 0 0.45rem;
}

.announce-empty {
  color: var(--muted);
  font-size: 0.95rem;
}

.announce-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.announce-item {
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
}

.announce-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  margin-bottom: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.announce-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8a6a2a;
  background: rgba(232, 200, 136, 0.25);
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
}

.announce-item-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

.announce-delete {
  color: #b54a3a;
}

.announce-page .site-announcement,
.suggest-page .site-announcement {
  display: none !important;
}

.suggest-replies {
  margin-top: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.suggest-reply {
  padding: 0.55rem 0.7rem;
  border-left: 3px solid rgba(126, 184, 201, 0.65);
  background: rgba(126, 184, 201, 0.08);
  border-radius: 0 8px 8px 0;
}

.suggest-reply p {
  margin: 0.25rem 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
  font-size: 0.9rem;
}

.suggest-reply-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.suggest-reply-label {
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5a8a98;
}

.suggest-reply-form {
  margin-top: 0.55rem;
}

.suggest-reply-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg-card);
  resize: vertical;
  min-height: 3rem;
  box-sizing: border-box;
}

.suggest-del-btn {
  padding: 0.1rem 0.35rem !important;
  font-size: 0.7rem !important;
  color: #b54a3a;
}

.curator-bar-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
}

.curator-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(232, 200, 136, 0.55);
  background: rgba(232, 200, 136, 0.16);
  color: #e8c888;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.curator-pill-muted {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.78);
}

.curator-hint {
  display: none;
}

.curator-form {
  flex: 1 1 auto;
  justify-content: flex-end;
  gap: 0.3rem;
}

.curator-form input {
  flex: 0 1 9rem;
  max-width: 11rem;
  min-width: 5rem;
  padding: 0.2rem 0.4rem !important;
  font-size: 0.75rem !important;
}

body.curator-mode .app-header {
  border-bottom-color: rgba(232, 200, 136, 0.28);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(159, 212, 228, 0.14);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(360px, 0.9fr);
  gap: 1.25rem;
  padding: 1.25rem 1.75rem 2rem;
  max-width: 1500px;
  margin: 0 auto;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.layer-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.85rem 1rem 0;
}

.layer-tab {
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  border-radius: 8px;
  padding: 0.32rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  transition: 0.15s ease;
}

.layer-tab.active,
.layer-tab:hover {
  color: #ffffff;
  border-color: rgba(159, 212, 228, 0.55);
  background: rgba(159, 212, 228, 0.18);
}

.architecture {
  padding: 1rem 1.25rem 1.5rem;
  color: #ffffff;
}

.architecture .flow-label,
.architecture .block-section-label,
.architecture .module-node,
.architecture .module-node .title,
.architecture .module-node .subtitle,
.architecture .module-node .count,
.architecture .residual {
  color: #ffffff;
}

.architecture .module-node .subtitle {
  color: rgba(255, 255, 255, 0.82);
}


.loss-section {
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 1rem;
}

.loss-launch {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(126, 184, 201, 0.24);
  border-radius: 11px;
  background:
    linear-gradient(100deg, rgba(126, 184, 201, 0.1), transparent 55%),
    rgba(255, 255, 255, 0.025);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.loss-launch:hover,
.loss-launch:focus-visible {
  border-color: rgba(126, 184, 201, 0.52);
  background:
    linear-gradient(100deg, rgba(126, 184, 201, 0.16), transparent 62%),
    rgba(255, 255, 255, 0.04);
  outline: none;
}

.loss-launch:active {
  transform: translateY(1px);
}

.loss-launch:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.loss-launch-icon {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 9px;
  background: rgba(126, 184, 201, 0.14);
  color: var(--accent);
  font-size: 1rem;
  font-weight: 700;
}

.loss-launch-action {
  white-space: nowrap;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
}

.loss-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
}

.loss-section-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.loss-section-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.loss-section-info {
  font-size: 0.74rem;
  color: var(--muted);
}

@media (max-width: 560px) {
  .loss-launch-action {
    font-size: 0;
  }

  .loss-launch-action span {
    font-size: 1rem;
  }
}

.loss-range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  font-size: 0.74rem;
  color: var(--muted);
}

.loss-range label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.loss-range input[type="number"] {
  width: 5.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  padding: 0.28rem 0.4rem;
  font-size: 0.74rem;
}

.loss-range-sep {
  color: var(--muted);
}

.loss-range-compact {
  margin: 0;
}

.loss-range-compact input[type="number"] {
  width: 4.5rem;
}

.loss-chart-wrap {
  position: relative;
  height: 220px;
}

.loss-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.loss-section .chart-hint {
  margin: 0.35rem 0 0;
  font-size: 0.68rem;
}

.loss-view-toggle + .loss-view-toggle {
  margin-left: 0.15rem;
}

.loss-view-toggle {
  display: inline-flex;
  gap: 0.2rem;
  padding: 0.12rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
}

.loss-view-btn.active,
.loss-scale-btn.active,
.curve-scale-btn.active {
  border-color: rgba(126, 184, 201, 0.45);
  background: rgba(126, 184, 201, 0.16);
  color: var(--text);
}

.flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}

.flow-label {
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffffff;
  font-weight: 700;
}

.node-row {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  justify-content: center;
}

.module-node {
  position: relative;
  min-width: 130px;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  text-align: center;
  color: #ffffff;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.module-node.clickable {
  cursor: pointer;
}

.module-node.clickable:hover {
  transform: translateY(-2px);
  border-color: rgba(159, 212, 228, 0.5);
  background: rgba(159, 212, 228, 0.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.module-node.active {
  border-color: rgba(232, 200, 136, 0.65);
  background: rgba(232, 200, 136, 0.12);
  box-shadow: 0 0 0 1px rgba(232, 200, 136, 0.25), 0 12px 30px rgba(0, 0, 0, 0.28);
}

.module-node.disabled {
  opacity: 1;
  cursor: not-allowed;
  color: rgba(255, 255, 255, 0.72);
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
}

.module-node.disabled .title,
.module-node.disabled .subtitle {
  color: rgba(255, 255, 255, 0.72);
}

.module-node .title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffffff;
}

.module-node .subtitle {
  margin-top: 0.25rem;
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.72);
}

.module-node .count {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  background: rgba(159, 212, 228, 0.22);
  color: #ffffff;
}

.connector {
  width: 2px;
  height: 18px;
  background: linear-gradient(var(--accent), rgba(126, 184, 201, 0.15));
  border-radius: 999px;
}

.block-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 0.75rem;
  width: 100%;
}

.block-section {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.block-section-label {
  text-align: center;
  font-size: 0.74rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 0.15rem;
  font-family: var(--font-ui);
}

.residual {
  position: relative;
  padding-left: 0.75rem;
}

.residual::before {
  content: "+";
  position: absolute;
  left: -0.1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--amber);
  font-weight: 700;
}

.detail-panel {
  min-height: 680px;
  display: flex;
  flex-direction: column;
}

.detail-empty {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 2rem;
  color: var(--muted);
  text-align: center;
}

.detail-content {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.detail-content.visible {
  display: flex;
}

.detail-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.detail-header h3 {
  margin: 0 0 0.35rem;
  font-size: 1.12rem;
  font-weight: 600;
  color: #ffffff;
  line-height: 1.35;
  word-break: break-word;
}

.detail-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-all;
}

.spec-groups {
  padding: 0.75rem 1rem;
  overflow: auto;
  flex: 0 1 auto;
  max-height: min(180px, 28vh);
}

.spec-group {
  margin-bottom: 0.85rem;
}

.spec-group-title {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.spec-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.spec-chip {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  transition: 0.15s ease;
}

.spec-chip:hover {
  border-color: rgba(159, 212, 228, 0.5);
  background: rgba(159, 212, 228, 0.14);
  color: #ffffff;
}

.spec-chip.active {
  border-color: rgba(232, 200, 136, 0.65);
  background: rgba(232, 200, 136, 0.2);
  color: #ffffff;
}

.chart-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.85rem 1.1rem 1.15rem;
  border-top: 1px solid var(--border);
  overflow: auto;
}

.chart-meta {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.55rem;
  margin-bottom: 0;
  font-size: 0.84rem;
  color: var(--muted);
  flex-shrink: 0;
}

.chart-meta-top {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.55rem;
}

.chart-meta-text {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-width: 0;
  flex: 1 1 auto;
}

#chartTitle {
  font-size: 1rem;
  font-weight: 600;
  color: #ffffff;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: anywhere;
}

#chartInfo {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.chart-def {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
  gap: 0.55rem;
  margin-top: 0.2rem;
  padding: 0.75rem 0.85rem 0.85rem;
  border: 1px solid rgba(159, 212, 228, 0.18);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(159, 212, 228, 0.055), transparent 48%),
    rgba(255, 255, 255, 0.025);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  font-size: 0.84rem;
  line-height: 1.55;
  color: #ffffff;
  overflow: visible;
}

.chart-def-desc {
  flex: none;
  width: 100%;
  margin: 0;
  max-width: 88ch;
  font-size: 0.85rem;
  line-height: 1.58;
  color: rgba(255, 255, 255, 0.88);
  font-weight: 400;
  font-family: var(--font-body);
  white-space: normal;
  overflow-wrap: break-word;
}

.chart-def[hidden] {
  display: none;
}

.chart-def-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.42rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.chart-def-label {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(159, 212, 228, 0.78);
  font-family: var(--font-ui);
}

.chart-def-math {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 9px;
  background: rgba(5, 10, 14, 0.28);
  overflow: hidden;
}

.chart-def-eq {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  padding: 0.62rem 0.72rem;
  font-size: clamp(0.82rem, 0.76rem + 0.18vw, 0.94rem);
  scrollbar-width: thin;
  scrollbar-color: rgba(159, 212, 228, 0.42) transparent;
}

.chart-def-dense .chart-def-eq {
  font-size: clamp(0.76rem, 0.71rem + 0.16vw, 0.86rem);
}

.chart-def-eq::-webkit-scrollbar,
.ref-obs-formula::-webkit-scrollbar {
  height: 6px;
}

.chart-def-eq::-webkit-scrollbar-thumb,
.ref-obs-formula::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(159, 212, 228, 0.4);
}

.chart-def-eq:focus-visible {
  outline: 2px solid rgba(159, 212, 228, 0.72);
  outline-offset: -2px;
}

.formula-notation {
  padding-top: 0.1rem;
}

.formula-notation-title {
  margin-bottom: 0.38rem;
  color: rgba(159, 212, 228, 0.78);
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.formula-notation dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.34rem 0.75rem;
  margin: 0;
}

.formula-notation dl > div {
  display: grid;
  grid-template-columns: minmax(2.5rem, auto) 1fr;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.34rem 0.48rem;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
}

.formula-notation dt {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.formula-notation dt .katex {
  color: var(--accent);
  font-size: 1.05em;
}

.formula-notation dd {
  min-width: 0;
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-family: var(--font-body);
  font-size: 0.78rem;
  line-height: 1.42;
}

.ref-formula-notation {
  margin-top: 0.45rem;
}

.chart-def-eq .katex,
.ref-obs-formula .katex {
  font-size: 1em;
  color: #ffffff;
}

.chart-def-eq .katex-display {
  margin: 0;
  text-align: left;
}

.chart-def-eq .katex-display.fleqn {
  padding-left: 0;
}

.chart-def-eq .katex-display > .katex {
  text-align: left;
}

.chart-def-scroll-hint {
  margin: 0;
  padding: 0.28rem 0.72rem 0.38rem;
  border-top: 1px solid rgba(255, 255, 255, 0.055);
  color: rgba(255, 255, 255, 0.48);
  font: 600 0.66rem/1.35 var(--font-ui);
}

.chart-def-scroll-hint[hidden] {
  display: none;
}

.chart-def-sep {
  color: var(--muted);
  opacity: 0.7;
  user-select: none;
}

.chart-def-link {
  align-self: center;
  flex-shrink: 0;
  padding: 0.2rem 0.48rem;
  border: 1px solid rgba(232, 200, 136, 0.2);
  border-radius: 999px;
  background: rgba(232, 200, 136, 0.055);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--sand);
  text-decoration: none;
  font-family: var(--font-ui);
}

.chart-def-link:hover,
.chart-def-link:focus-visible {
  border-color: rgba(232, 200, 136, 0.42);
  background: rgba(232, 200, 136, 0.1);
  text-decoration: none;
}

@media (max-width: 720px) {
  .chart-def {
    gap: 0.48rem;
    padding: 0.65rem;
    border-radius: 10px;
  }

  .chart-def-desc {
    font-size: 0.82rem;
    line-height: 1.52;
  }

  .chart-def-eq,
  .chart-def-dense .chart-def-eq {
    padding: 0.55rem 0.6rem;
    font-size: 0.76rem;
  }
}

.chart-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.4rem;
  flex: 0 0 auto;
  max-width: none;
}

.chart-canvas-box {
  position: relative;
  flex: 1 1 280px;
  min-height: 280px;
  height: clamp(280px, 36vh, 420px);
}

.chart-btn {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.28rem 0.55rem;
  cursor: pointer;
  transition: 0.15s ease;
}

.chart-btn:hover {
  background: var(--bg-hover);
  border-color: rgba(126, 184, 201, 0.35);
}

.chart-btn[hidden] {
  display: none;
}

.chart-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.12rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
}

.chart-zoom-controls[hidden] {
  display: none;
}

.chart-zoom-controls .chart-zoom-btn {
  min-width: 1.8rem;
  padding-inline: 0.42rem;
  border-color: transparent;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
}

.compare-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

.compare-toggle:hover {
  background: var(--bg-hover);
}

.compare-toggle input {
  accent-color: var(--accent);
  margin: 0;
}

.compare-toggle[hidden] {
  display: none;
}

.layer-pick {
  margin: 0 0 0.65rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
}

.layer-pick[hidden] {
  display: none;
}

.layer-pick-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.layer-pick-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.layer-pick-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.layer-pick-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 500;
  padding: 0.22rem 0.5rem;
  cursor: pointer;
  user-select: none;
  transition: 0.15s ease;
}

.layer-pick-chip input {
  display: none;
}

.layer-pick-chip:hover {
  border-color: rgba(126, 184, 201, 0.4);
  color: var(--text);
}

.layer-pick-chip.active {
  color: var(--text);
  border-color: var(--chip-color, var(--accent));
  background: color-mix(in srgb, var(--chip-color, var(--accent)) 22%, var(--bg-card));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--chip-color, var(--accent)) 25%, transparent);
}

.layer-pick-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--chip-color, var(--accent));
}

.run-pick-status {
  margin: 0.4rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.run-pick-status[hidden] {
  display: none;
}

.run-pick-status.is-error {
  color: #b91c1c;
}

.chart-hint {
  margin: 0.35rem 0 0;
  font-size: 0.7rem;
  color: var(--muted);
}

.chart-hint[hidden] {
  display: none;
}

#curveChart {
  width: 100% !important;
  height: 100% !important;
  cursor: grab;
}

#curveChart:active {
  cursor: grabbing;
}

.chart-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2.5vh 2.5vw;
  background: rgba(8, 12, 16, 0.72);
  backdrop-filter: blur(6px);
}

.chart-overlay.visible {
  display: flex;
}

.chart-overlay[hidden] {
  display: none !important;
}

.chart-modal {
  display: flex;
  flex-direction: column;
  width: 95vw;
  height: 90vh;
  max-width: 1500px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.35);
  padding: 1rem 1.25rem 1.25rem;
}

.chart-modal-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--muted);
}

.chart-modal-head > .chart-meta-text {
  flex: 1 1 240px;
  min-width: 0;
}

.chart-modal-head > .chart-actions {
  flex: 1 1 720px;
  min-width: 0;
  justify-content: flex-end;
}

.chart-modal-head #fullChartTitle {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.reference-line-controls {
  display: flex;
  flex-wrap: wrap;
  flex: 1 1 520px;
  min-width: 0;
  max-width: 100%;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
}

.reference-line-controls[hidden] {
  display: none !important;
}

.reference-line-controls label {
  white-space: nowrap;
  color: var(--muted);
}

.reference-line-controls input {
  width: 7rem;
  min-width: 0;
  padding: 0.38rem 0.5rem;
  color: var(--text);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 7px;
  font: inherit;
}

.reference-line-controls input:focus {
  outline: 2px solid rgba(159, 212, 228, 0.25);
  border-color: var(--accent);
}

.reference-line-status {
  max-width: 12rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reference-line-list {
  display: flex;
  flex-wrap: wrap;
  flex: 1 0 100%;
  min-width: 0;
  gap: 0.3rem;
  align-items: center;
  max-width: 100%;
}

.reference-line-list:empty {
  display: none;
}

.reference-line-help {
  color: var(--muted);
  white-space: nowrap;
}

.reference-line-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.24rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-panel);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.reference-line-chip:hover {
  border-color: rgba(126, 184, 201, 0.55);
  background: var(--bg-hover);
}

.reference-line-swatch {
  width: 1rem;
  height: 0;
  border-top: 2px dashed currentColor;
}

.reference-line-remove {
  color: var(--muted);
  font-size: 0.78rem;
}

.full-run-pick {
  margin: 0.35rem 0 0.15rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
}

.full-run-pick[hidden] {
  display: none !important;
}

.full-run-pick-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.full-run-pick .layer-pick-list {
  max-height: 4.5rem;
  overflow: auto;
}

.chart-modal-body {
  flex: 1;
  min-height: 0;
  padding-top: 0.75rem;
  position: relative;
}

#curveChartFull {
  width: 100% !important;
  height: 100% !important;
  cursor: grab;
  touch-action: none;
}

#curveChartFull:active {
  cursor: grabbing;
}

#curveImage {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

#curveImage.visible {
  display: block;
}

.loading,
.error {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
}

.error {
  color: var(--rose);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.header-link {
  color: var(--fog);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  opacity: 0.82;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, opacity 0.15s ease, border-color 0.15s ease;
}

.header-link:hover {
  color: var(--sand);
  opacity: 1;
  border-bottom-color: rgba(196, 165, 116, 0.45);
  text-decoration: none;
}

.viewer-loading {
  min-height: calc(100vh - 88px);
  display: grid;
  place-items: center;
  padding: 2rem 1rem 5rem;
}

.viewer-loading-card {
  width: min(580px, 100%);
  padding: 1.35rem 1.45rem 1.25rem;
  border: 1px solid rgba(159, 212, 228, 0.22);
  border-radius: 14px;
  background:
    linear-gradient(145deg, rgba(159, 212, 228, 0.08), transparent 52%),
    var(--bg-panel);
  box-shadow: var(--shadow);
}

.viewer-loading-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
  font-family: var(--font-ui);
  color: #fff;
}

.viewer-loading-heading span {
  font-size: 0.88rem;
  font-weight: 700;
}

.viewer-loading-heading strong {
  color: var(--accent);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.viewer-progress {
  position: relative;
  height: 0.58rem;
  overflow: hidden;
  border: 1px solid rgba(159, 212, 228, 0.2);
  border-radius: 999px;
  background: rgba(5, 10, 14, 0.58);
}

.viewer-progress > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sand-deep), var(--ice));
  box-shadow: 0 0 16px rgba(159, 212, 228, 0.3);
  transition: width 0.2s ease;
}

.viewer-loading.is-indeterminate .viewer-progress > span {
  width: 34% !important;
  animation: viewer-progress-sweep 1.25s ease-in-out infinite;
}

.viewer-loading.is-error .viewer-progress > span {
  background: var(--rose);
}

.viewer-loading.is-error .viewer-loading-heading strong,
.viewer-loading.is-error #viewerLoadingStatus {
  color: var(--rose);
}

#viewerLoadingStatus {
  margin: 0.85rem 0 0;
  color: #fff;
  font: 700 0.9rem/1.4 var(--font-ui);
}

.viewer-loading-detail {
  min-height: 1.35em;
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

@keyframes viewer-progress-sweep {
  from {
    transform: translateX(-110%);
  }
  to {
    transform: translateX(310%);
  }
}

.training-config {
  color: var(--text);
  font-family: var(--font-body);
}

.training-config > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  color: var(--fog);
  font: 700 0.8rem/1.25 var(--font-ui);
}

.training-config > summary::-webkit-details-marker {
  display: none;
}

.training-config > summary::after {
  content: " +";
  color: var(--accent);
}

.training-config[open] > summary::after {
  content: " −";
}

.training-config-header {
  position: relative;
}

.training-config-header > summary {
  padding: 0.32rem 0.62rem;
  border: 1px solid rgba(159, 212, 228, 0.28);
  border-radius: 999px;
  background: rgba(159, 212, 228, 0.08);
}

.training-config-header > summary:hover {
  border-color: rgba(159, 212, 228, 0.5);
  background: rgba(159, 212, 228, 0.14);
}

.training-config-popover {
  position: absolute;
  top: calc(100% + 0.65rem);
  right: 0;
  z-index: 30;
  width: min(720px, calc(100vw - 2rem));
  max-height: min(76vh, 720px);
  overflow: auto;
  padding: 1rem;
  border: 1px solid rgba(159, 212, 228, 0.24);
  border-radius: 12px;
  background: rgba(14, 20, 25, 0.98);
  box-shadow: 0 22px 58px rgba(0, 0, 0, 0.55);
}

.training-config-intro strong {
  display: block;
  color: #fff;
  font: 700 0.92rem/1.35 var(--font-ui);
}

.training-config-intro p {
  margin: 0.28rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.training-config-intro .training-config-recording {
  color: rgba(232, 200, 136, 0.9);
}

.training-config-intro a {
  display: inline-block;
  margin-top: 0.42rem;
  color: var(--accent);
  font: 700 0.76rem/1.35 var(--font-ui);
  text-decoration: none;
}

.training-config-intro a:hover {
  text-decoration: underline;
}

.training-config-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.training-config-group {
  min-width: 0;
  padding: 0.65rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
}

.training-config-group h4 {
  margin: 0 0 0.42rem;
  color: rgba(159, 212, 228, 0.9);
  font: 700 0.68rem/1.3 var(--font-ui);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.training-config-group dl {
  display: grid;
  gap: 0.3rem;
  margin: 0;
}

.training-config-group dl > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}

.training-config-group dt,
.training-config-group dd {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.35;
}

.training-config-group dt {
  min-width: 0;
  color: var(--muted);
}

.training-config-group dd {
  flex-shrink: 0;
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.select-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.select-shell {
  width: min(920px, 100%);
}

.select-header {
  text-align: center;
  margin-bottom: 2rem;
}

.select-header h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.7rem, 3.5vw, 2.25rem);
  font-weight: 600;
  letter-spacing: -0.015em;
  color: #ffffff;
}

.select-header p {
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
}

.select-loading,
.select-error {
  text-align: center;
  color: var(--muted);
  padding: 2rem;
}

.select-error {
  color: var(--rose);
}

.run-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-items: start;
  gap: 1rem;
}

.run-card {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background:
    linear-gradient(165deg, rgba(196, 165, 116, 0.08), transparent 42%),
    var(--bg-panel);
  box-shadow: var(--shadow);
  color: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.run-card:hover,
.run-card:focus-within {
  transform: translateY(-2px);
  border-color: rgba(196, 165, 116, 0.4);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.run-card-open {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  color: inherit;
  text-decoration: none;
}

.run-card-action {
  color: var(--accent);
  font: 700 0.78rem/1.3 var(--font-ui);
}

.training-config-card {
  padding-top: 0.65rem;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.training-config-card > summary {
  color: var(--muted);
}

.training-config-card .training-config-body {
  padding-top: 0.8rem;
}

.training-config-card .training-config-groups {
  grid-template-columns: 1fr;
}

.run-card-title {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--sand);
  word-break: break-all;
}

.run-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.run-card-meta span {
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.run-card-sub {
  font-size: 0.8rem;
  color: var(--muted);
}

.ref-page {
  color-scheme: dark;
}

.ref-page .ref-shell {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1.25rem 1.75rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.ref-page .app-header p {
  max-width: 36rem;
}

.ref-toolbar {
  padding: 0.85rem 1rem;
}

.ref-toolbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}

.ref-toolbar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 320px;
  min-width: 0;
}

.ref-search-input {
  flex: 1 1 220px;
  min-width: 0;
  height: 2.35rem;
  padding: 0 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: #ffffff;
  font-size: 0.9rem;
  font-family: var(--font-ui);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.ref-search-input::placeholder {
  color: rgba(255, 255, 255, 0.42);
}

.ref-search-input:focus {
  border-color: rgba(159, 212, 228, 0.55);
  background: rgba(159, 212, 228, 0.06);
}

.ref-select {
  height: 2.35rem;
  min-width: 8.5rem;
  padding: 0 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background-color: #152028;
  background-image: none;
  color: #ffffff;
  font-size: 0.84rem;
  font-family: var(--font-ui);
  font-weight: 600;
  cursor: pointer;
  color-scheme: dark;
}

.ref-select:focus {
  outline: none;
  border-color: rgba(159, 212, 228, 0.55);
}

/* Native dropdown list (Windows/Chrome often ignores alpha backgrounds). */
.ref-select option,
.ref-select optgroup {
  background-color: #152028;
  color: #ffffff;
}

.ref-toolbar-aside {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem 0.85rem;
  flex: 0 1 auto;
}

.ref-count {
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-ui);
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.72);
  white-space: nowrap;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
}

.ref-pager {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.ref-page-jump {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  margin: 0;
}

.ref-page-input {
  width: 3.1rem;
  height: 2rem;
  padding: 0 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-ui);
  text-align: center;
  -moz-appearance: textfield;
}

.ref-page-input::-webkit-outer-spin-button,
.ref-page-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.ref-page-input:focus {
  outline: none;
  border-color: rgba(159, 212, 228, 0.55);
  background: rgba(159, 212, 228, 0.08);
}

.ref-page-input:disabled {
  opacity: 0.45;
}

.ref-page-total {
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-ui);
  color: rgba(255, 255, 255, 0.72);
  white-space: nowrap;
}

.ref-page-btn {
  min-width: 2.1rem;
  padding-left: 0.55rem;
  padding-right: 0.55rem;
  font-size: 1.1rem;
  line-height: 1;
}

.ref-catalog {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
}

@media (max-width: 720px) {
  .ref-toolbar-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .ref-toolbar-aside {
    justify-content: space-between;
  }

  .ref-select {
    flex: 1 1 auto;
    min-width: 0;
  }
}

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

.ref-obs {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  scroll-margin-top: 5rem;
}

.ref-obs-highlight {
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.ref-obs-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.45rem;
}

.ref-obs-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.ref-obs-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.ref-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--muted);
}

.ref-obs-desc {
  margin: 0 0 0.45rem;
  font-size: 0.92rem;
  line-height: 1.6;
  color: #ffffff;
  font-family: var(--font-body);
  word-break: break-word;
}

.ref-obs-formula {
  overflow-x: auto;
  padding: 0.35rem 0.15rem;
  font-size: 1.02rem;
}

.ref-obs-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.select-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  text-align: left;
}

.select-header-row > div {
  flex: 1;
  min-width: 240px;
}

.select-header-row .header-link {
  margin-top: 0.35rem;
  white-space: nowrap;
}

.select-header-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.1rem;
  align-items: center;
}

.chart-modal-body-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(200px, 260px);
  gap: 0.75rem;
  align-items: stretch;
  min-height: 0;
  flex: 1;
}

.chart-modal-canvas-wrap {
  position: relative;
  min-height: 320px;
  min-width: 0;
}

.chart-modal-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.notes-rail {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: min(70vh, 640px);
  overflow: auto;
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
}

.chart-modal.notes-expanded .chart-modal-canvas-wrap {
  display: none;
}

.chart-modal.notes-expanded .chart-modal-body-split {
  grid-template-columns: 1fr;
}

.chart-modal.notes-expanded .notes-rail {
  max-height: none;
  height: 100%;
  min-height: min(70vh, 720px);
  overflow: auto;
}

.chart-modal.notes-expanded .rail-note-form textarea {
  min-height: 6rem;
  font-size: 0.9rem;
}

.chart-modal.notes-expanded .notes-list {
  flex: 1;
}

.chart-modal.notes-expanded .note-card p,
.chart-modal.notes-expanded .note-comment p {
  font-size: 0.88rem;
  line-height: 1.5;
}

.chart-modal.notes-expanded #notesExpandBtn {
  border-color: rgba(232, 200, 136, 0.45);
  background: rgba(232, 200, 136, 0.14);
}

.notes-rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.notes-rail-empty {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

.note-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.55rem;
  background: var(--bg-panel);
  cursor: pointer;
}

.note-card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
  font-size: 0.7rem;
  color: var(--muted);
}

.note-card p {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.note-step {
  font-weight: 600;
  color: var(--accent);
}

.note-card-byline,
.note-card-actions,
.note-comment-byline {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.note-card-byline {
  flex: 1 1 auto;
  flex-wrap: wrap;
}

.note-card-actions {
  flex: 0 0 auto;
}

.note-author {
  max-width: 100%;
  overflow: hidden;
  color: var(--sand);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-rail-head-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.notes-identity {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--accent);
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rail-note-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border);
}

.rail-note-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  font: inherit;
  font-size: 0.8rem;
  color: var(--text);
  background: var(--bg-panel);
  resize: vertical;
  min-height: 4.2rem;
}

.rail-note-name-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.72rem;
  color: var(--muted);
}

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

.rail-note-name-label input,
.note-reply-box input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.45rem;
  font: inherit;
  font-size: 0.76rem;
  color: var(--text);
  background: var(--bg-panel);
}

.rail-note-form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.rail-note-mode-label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.45rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.rail-note-mode-label select {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.4rem;
  font: inherit;
  font-size: 0.75rem;
  color: var(--text);
  background: var(--bg-panel);
}

.rail-note-step-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.rail-note-general-hint {
  font-size: 0.7rem;
  line-height: 1.35;
  color: var(--muted-soft);
}

.rail-note-step-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.rail-note-step-label input {
  width: 4.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.28rem 0.4rem;
  font: inherit;
  font-size: 0.75rem;
  color: var(--text);
  background: var(--bg-panel);
}

.note-time {
  font-size: 0.66rem;
  color: var(--muted);
}

.note-comments {
  margin-top: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.note-comment {
  border-left: 2px solid rgba(232, 200, 136, 0.35);
  padding: 0.3rem 0.45rem;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 0 6px 6px 0;
}

.note-comment-reply {
  margin-left: 0.65rem;
  margin-top: 0.3rem;
}

.note-comment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.15rem;
  font-size: 0.66rem;
  color: var(--muted);
}

.note-comment-byline {
  flex-wrap: wrap;
}

.note-comment-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.note-navigate-btn {
  border: 1px solid rgba(126, 184, 201, 0.32);
  border-radius: 999px;
  padding: 0.12rem 0.42rem;
  background: rgba(126, 184, 201, 0.1);
  color: var(--accent);
  font: inherit;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
}

.note-navigate-btn:hover:not(:disabled),
.note-navigate-btn:focus-visible {
  border-color: rgba(126, 184, 201, 0.65);
  background: rgba(126, 184, 201, 0.2);
}

.note-navigate-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.note-comment p {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.note-reply-btn {
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.15rem 0;
}

.note-reply-btn:hover {
  text-decoration: underline;
}

.note-reply-root {
  margin-top: 0.35rem;
}

.note-reply-box {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.note-reply-box textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.45rem;
  font: inherit;
  font-size: 0.76rem;
  color: var(--text);
  background: var(--bg-panel);
  resize: vertical;
}

.note-reply-box-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.35rem;
}

.note-reply-status {
  margin: 0;
  font-size: 0.68rem;
  color: var(--muted);
}

.note-card {
  cursor: default;
}

.notes-admin {
  border: 1px dashed rgba(232, 200, 136, 0.45);
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  background: rgba(232, 200, 136, 0.08);
}

.notes-admin-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.notes-admin-form input {
  flex: 1 1 6rem;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.4rem;
  font: inherit;
  font-size: 0.75rem;
  color: var(--text);
  background: var(--bg-card);
}

.notes-admin-tag {
  font-size: 0.72rem;
  font-weight: 600;
  color: #e8c888;
  margin-right: auto;
}

.notes-admin-status {
  flex-basis: 100%;
  font-size: 0.68rem;
  color: var(--muted);
}

.note-delete {
  border: none;
  background: none;
  color: rgba(255, 138, 128, 0.85);
  cursor: pointer;
  font-size: 0.72rem;
  line-height: 1;
  padding: 0 0.15rem;
}

.note-delete:hover {
  color: #ff6b5e;
}

.note-identity {
  margin: 0;
  font-size: 0.74rem;
  color: var(--accent);
  font-weight: 600;
}

.note-modal {
  position: fixed;
  inset: 0;
  /* Must sit above .chart-overlay (z-index: 100), otherwise the form is invisible. */
  z-index: 9999;
  display: none;
  place-items: center;
  padding: 1rem;
  background: rgba(8, 12, 16, 0.78);
}

.note-modal.visible {
  display: grid !important;
}

.note-modal[hidden] {
  display: none !important;
}

#fullAddNoteBtn {
  border-color: rgba(232, 200, 136, 0.55);
  background: rgba(232, 200, 136, 0.16);
  color: #ffffff;
}

.note-dialog {
  width: min(480px, 100%);
  max-height: min(86vh, 720px);
  overflow: auto;
  background: #152028;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  padding: 1rem 1.1rem 1.15rem;
  color: #ffffff;
}

.note-dialog-head h3,
.note-dialog-step,
.note-modal-form label {
  color: #ffffff;
}

.note-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.note-dialog-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.note-dialog-step {
  margin: 0.35rem 0 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.note-modal-existing {
  margin-bottom: 0.85rem;
}

.note-modal-existing h4 {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.note-modal-existing .note-card {
  cursor: default;
  margin-bottom: 0.4rem;
}

.note-modal-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.note-modal-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.note-modal-form input,
.note-modal-form textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font: inherit;
  color: var(--text);
  background: var(--bg-card);
}

.note-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
}

.note-submit {
  background: rgba(126, 184, 201, 0.16);
  border-color: rgba(126, 184, 201, 0.4);
}

.note-token-hint,
.note-modal-status {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
}

.note-modal-status {
  color: var(--amber);
}

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

  .block-grid {
    grid-template-columns: 1fr;
  }

  .chart-modal-body-split {
    grid-template-columns: 1fr;
  }

  .notes-rail {
    max-height: 220px;
  }
}

@media (max-width: 720px) {
  .chart-overlay {
    padding: 1.25vh 1.5vw;
  }

  .chart-modal {
    width: 97vw;
    padding-inline: 0.75rem;
  }

  .chart-modal-head > .chart-actions {
    flex-basis: 100%;
    justify-content: flex-start;
  }

  .reference-line-controls {
    flex-basis: 100%;
  }

  .reference-line-list {
    width: 100%;
  }

  .training-config-groups {
    grid-template-columns: 1fr;
  }

  .training-config-popover {
    right: -0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .viewer-loading.is-indeterminate .viewer-progress > span {
    animation-duration: 2.5s;
  }

  .viewer-progress > span {
    transition: none;
  }
}

/* Discoveries */
.discoveries-shell {
  width: min(1160px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.discoveries-page .app-header {
  position: static;
}

.discovery-composer {
  padding: clamp(1rem, 2vw, 1.5rem);
  margin-bottom: 2.5rem;
}

.discovery-section-head,
.discovery-feed-head,
.discovery-card-head,
.discovery-reference-head,
.discovery-discussion-head,
.discovery-publish-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.discovery-section-head h2,
.discovery-feed-head h2,
.discovery-card-head h3 {
  margin: 0;
  color: #fff;
}

.discovery-section-head h2,
.discovery-feed-head h2 {
  font-size: clamp(1.35rem, 2vw, 1.75rem);
}

.discovery-kicker {
  margin: 0 0 0.25rem;
  color: var(--accent-2);
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.discovery-limit {
  color: var(--muted-soft);
  font-family: var(--font-ui);
  font-size: 0.72rem;
}

#discoveryForm {
  display: grid;
  gap: 1rem;
  margin-top: 1.2rem;
}

.discovery-field {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 600;
}

.discovery-field input,
.discovery-field textarea,
.discovery-reference-grid input,
.discovery-reference-grid select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.65rem 0.72rem;
  color: #fff;
  background: rgba(7, 12, 16, 0.72);
  font: inherit;
}

.discovery-field textarea {
  min-height: 10rem;
  resize: vertical;
  font-family: var(--font-body);
  font-size: 0.98rem;
  line-height: 1.58;
}

.discovery-field input:focus,
.discovery-field textarea:focus,
.discovery-reference-grid input:focus,
.discovery-reference-grid select:focus {
  outline: 2px solid rgba(159, 212, 228, 0.4);
  outline-offset: 1px;
  border-color: rgba(159, 212, 228, 0.72);
}

.discovery-name-field {
  max-width: 22rem;
}

.discovery-reference-builder {
  min-width: 0;
  margin: 0;
  border: 1px solid rgba(159, 212, 228, 0.24);
  border-radius: 12px;
  padding: 1rem;
  background: rgba(159, 212, 228, 0.035);
}

.discovery-reference-builder legend {
  padding: 0 0.35rem;
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.86rem;
  font-weight: 700;
}

.discovery-reference-builder > p {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.discovery-reference-grid {
  display: grid;
  grid-template-columns: minmax(10rem, 0.85fr) minmax(14rem, 1.25fr) minmax(14rem, 1.35fr);
  gap: 0.75rem;
  align-items: end;
}

.discovery-reference-grid label {
  display: grid;
  gap: 0.32rem;
  min-width: 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
}

.discovery-reference-grid select {
  overflow: hidden;
  text-overflow: ellipsis;
}

.discovery-add-reference {
  min-height: 2.55rem;
  color: #fff;
  border-color: rgba(159, 212, 228, 0.38);
  background: rgba(159, 212, 228, 0.12);
}

.discovery-inline-status,
.discovery-form-status,
.discovery-feed-status {
  margin: 0;
  min-height: 1.2em;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.76rem;
}

.discovery-inline-status {
  margin-top: 0.6rem !important;
}

.discovery-inline-status.is-error,
.discovery-form-status.is-error,
.discovery-feed-status.is-error {
  color: #ff9d92;
}

.discovery-draft-references,
.discovery-reference-list {
  display: grid;
  gap: 0.9rem;
  margin-top: 0.75rem;
}

.discovery-draft-reference,
.discovery-curve-reference {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(7, 12, 16, 0.55);
}

.discovery-reference-head,
.discovery-curve-reference figcaption {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.discovery-reference-head > div,
.discovery-curve-reference figcaption > div {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
}

.discovery-reference-head strong,
.discovery-curve-reference figcaption strong {
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.76rem;
  line-height: 1.35;
}

.discovery-reference-head span,
.discovery-curve-reference figcaption span {
  color: var(--muted-soft);
  font-family: var(--font-ui);
  font-size: 0.7rem;
}

.discovery-curve-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: rgba(159, 212, 228, 0.025);
}

.discovery-curve-toolbar .chart-btn:disabled,
.discovery-curve-key .chart-btn:disabled {
  cursor: wait;
  opacity: 0.42;
}

.discovery-axis-btn.active {
  border-color: rgba(126, 184, 201, 0.45);
  background: rgba(126, 184, 201, 0.16);
  color: var(--text);
}

.discovery-curve-view-status {
  flex: 1 1 13rem;
  min-height: 1em;
  color: var(--muted-soft);
  font-family: var(--font-ui);
  font-size: 0.68rem;
  line-height: 1.35;
}

.discovery-curve-view-status.is-error {
  color: #ff9d92;
}

.discovery-curve-hint {
  margin: 0;
  padding: 0.35rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted-soft);
  font-family: var(--font-ui);
  font-size: 0.66rem;
  line-height: 1.4;
}

.discovery-curve-key {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.018);
}

.discovery-curve-key-item {
  display: grid;
  grid-template-columns: 1.7rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  padding: 0.42rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  background: rgba(7, 12, 16, 0.36);
}

.discovery-curve-swatch {
  width: 1.7rem;
  border-top: 3px solid var(--curve-color);
  border-radius: 999px;
}

.discovery-curve-key-copy {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}

.discovery-curve-key-copy strong {
  overflow-wrap: anywhere;
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.35;
}

.discovery-curve-key-copy > span {
  color: var(--muted-soft);
  font-family: var(--font-ui);
  font-size: 0.66rem;
  line-height: 1.35;
}

.discovery-curve-state:empty {
  display: none;
}

.discovery-curve-key-item.is-error .discovery-curve-swatch {
  opacity: 0.38;
}

.discovery-curve-key-item.is-error .discovery-curve-state {
  display: block;
  color: #ff9d92;
}

.discovery-curve-key-item.is-error .chart-btn:disabled {
  cursor: not-allowed;
}

.discovery-curve-key-item.is-hidden .discovery-curve-swatch,
.discovery-curve-key-item.is-hidden .discovery-curve-key-copy {
  opacity: 0.42;
}

.discovery-curve-key-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}

.discovery-curve-visibility {
  min-width: 2.7rem;
  padding-inline: 0.42rem;
  font-size: 0.66rem;
}

.discovery-curve-key-item .header-link,
.discovery-curve-key-item .note-delete {
  align-self: center;
}

.discovery-curve-canvas {
  position: relative;
  height: 270px;
  padding: 0.5rem;
}

.discovery-curve-canvas canvas {
  cursor: grab;
  touch-action: none;
}

.discovery-curve-canvas canvas:active {
  cursor: grabbing;
}

body.discovery-chart-expanded {
  overflow: hidden;
}

body.discovery-chart-expanded::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 499;
  background: rgba(8, 12, 16, 0.78);
  backdrop-filter: blur(6px);
}

.discovery-curve-group.is-expanded {
  position: fixed;
  inset: 2vh 2vw;
  z-index: 500;
  display: flex;
  flex-direction: column;
  width: auto;
  height: auto;
  margin: 0;
  overflow: hidden;
  border-color: rgba(159, 212, 228, 0.42);
  background: #0b1117;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
}

.discovery-curve-group.is-expanded .discovery-curve-key {
  flex: 0 1 auto;
  max-height: 24vh;
  overflow: auto;
}

.discovery-curve-group.is-expanded .discovery-curve-canvas {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}

.discovery-curve-group.is-expanded .discovery-expand-curve {
  border-color: rgba(255, 157, 146, 0.45);
  color: #ffaaa1;
}

.discovery-chart-error {
  display: grid;
  place-items: center;
  height: 100%;
  margin: 0;
  color: #ff9d92;
  text-align: center;
}

.discovery-publish-row {
  align-items: center;
}

.discovery-publish-row p {
  max-width: 48rem;
  margin: 0;
  color: var(--muted-soft);
  font-size: 0.76rem;
  line-height: 1.45;
}

.discovery-publish-row .note-submit {
  flex: 0 0 auto;
  padding: 0.65rem 1rem;
  color: #fff;
}

.discovery-feed {
  display: grid;
  gap: 1rem;
}

.discovery-feed-head {
  align-items: center;
}

.discovery-list {
  display: grid;
  gap: 1.25rem;
}

.discovery-card {
  padding: clamp(1rem, 2.2vw, 1.5rem);
}

.discovery-card-head h3 {
  margin-top: 0.4rem;
  font-size: clamp(1.25rem, 2.5vw, 1.7rem);
  line-height: 1.25;
}

.discovery-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted-soft);
  font-family: var(--font-ui);
  font-size: 0.72rem;
}

.discovery-admin-delete {
  color: #ffaaa1;
  border-color: rgba(255, 107, 94, 0.42);
}

.discovery-body {
  margin: 1rem 0 0;
  color: rgba(255, 255, 255, 0.92);
  font-size: 1rem;
  line-height: 1.7;
  white-space: pre-wrap;
}

.discovery-discussion {
  margin-top: 1.2rem;
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
}

.discovery-discussion-head {
  align-items: baseline;
  margin-bottom: 0.5rem;
}

.discovery-discussion-head strong {
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.82rem;
}

.discovery-discussion-head span,
.discovery-anonymous {
  color: var(--muted-soft);
  font-family: var(--font-ui);
  font-size: 0.68rem;
}

.discovery-discussion .note-comment {
  margin-top: 0.55rem;
}

.discovery-discussion .note-reply-root {
  margin-top: 0.6rem;
}

.discovery-reply-box {
  margin-top: 0.65rem;
}

@media (max-width: 900px) {
  .discovery-reference-grid {
    grid-template-columns: 1fr 1fr;
  }

  .discovery-observable-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .discoveries-shell {
    width: min(100% - 1rem, 1160px);
    padding-top: 0.75rem;
  }

  .discoveries-page .app-header {
    align-items: flex-start;
    padding-inline: 1rem;
  }

  .discovery-section-head,
  .discovery-card-head,
  .discovery-publish-row {
    flex-direction: column;
  }

  .discovery-reference-grid {
    grid-template-columns: 1fr;
  }

  .discovery-observable-field {
    grid-column: auto;
  }

  .discovery-curve-canvas {
    height: 235px;
  }

  .discovery-curve-key-item {
    grid-template-columns: 1.5rem minmax(0, 1fr) auto;
  }

  .discovery-curve-swatch {
    width: 1.5rem;
  }

  .discovery-curve-toolbar {
    align-items: flex-start;
    padding-inline: 0.55rem;
  }

  .discovery-curve-view-status {
    flex-basis: 100%;
  }

  .discovery-curve-key-actions {
    align-items: flex-end;
    flex-direction: column;
  }

  .discovery-curve-group.is-expanded {
    inset: 0.35rem;
  }

  .discovery-curve-group.is-expanded .discovery-curve-key {
    max-height: 28vh;
  }

  .discovery-publish-row .note-submit {
    width: 100%;
  }
}
