/* 4-Link Calculator — page-specific styles. Reuses theme tokens from styles.css. */

.fl-app {
  max-width: 1500px;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 1rem;
  align-items: start;
}

/* ===== Controls panel ===== */
.fl-controls {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent-a);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0.5rem;
}
.fl-controls h2 { font-size: 0.95rem; margin-bottom: 0.6rem; }
.fl-layout-note {
  font-size: 0.75rem; color: var(--text-muted); line-height: 1.4;
  margin: 0.4rem 0 0.8rem; min-height: 2.4em;
}

.fl-field { margin-bottom: 0.6rem; }
.fl-field label { display: block; font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 0.2rem; }

.fl-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.fl-grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.5rem; }

/* coordinate rows: label + x/y/z cells */
.fl-coords { margin-top: 0.4rem; }
.fl-coord-row {
  display: grid;
  grid-template-columns: 5.2rem 1fr 1fr 1fr;
  gap: 0.3rem;
  align-items: center;
  margin-bottom: 0.3rem;
}
.fl-coord-label { font-size: 0.72rem; color: var(--text-secondary); }
.fl-coord-cell { display: flex; align-items: center; gap: 0.2rem; }
.fl-coord-cell span { font-size: 0.65rem; color: var(--text-muted); width: 0.7rem; }
.fl-coord-input { padding: 0.3rem 0.3rem; font-size: 0.78rem; }

.fl-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.8rem; }
.fl-check { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; color: var(--text-secondary); margin-top: 0.6rem; }
.fl-check input { width: auto; }

/* ===== Main viz column ===== */
.fl-main { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

.fl-readouts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 0.6rem;
}
.fl-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
}
.fl-card.fl-ok { border-left-color: var(--success); }
.fl-card.fl-warn { border-left-color: var(--accent-a); }
.fl-card.fl-na { border-left-color: var(--border); }
.fl-card-title { font-size: 0.7rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.03em; }
.fl-card-value { font-size: 1.25rem; font-weight: 700; color: var(--text-primary); margin: 0.1rem 0; }
.fl-card-sub { font-size: 0.68rem; color: var(--text-muted); line-height: 1.3; }
.fl-card.fl-ok .fl-card-sub b { color: var(--success); }
.fl-card.fl-warn .fl-card-sub b { color: var(--accent-hover); }

.fl-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  box-shadow: var(--shadow);
}
/* Panel titles are <h2 class="fl-panel-title"> so the document outline is
   h1 -> h2 -> h3; they must stay visually identical to the old h3. */
.fl-panel h3,
.fl-panel h2.fl-panel-title { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 0.5rem; font-weight: 600; }

#fl-3d { width: 100%; height: 420px; border-radius: var(--radius); overflow: hidden; background: #12182b; }
#fl-3d canvas { display: block; width: 100% !important; height: 100% !important; }

.fl-views2d { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.fl-canvas { width: 100%; height: 320px; display: block; background: #16213e; border-radius: var(--radius); touch-action: none; cursor: grab; }
.fl-canvas:active { cursor: grabbing; }

.fl-plots { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.fl-plot-wrap { position: relative; height: 280px; }

.fl-legend { display: flex; flex-wrap: wrap; gap: 0.8rem; font-size: 0.72rem; color: var(--text-secondary); margin-top: 0.4rem; }
.fl-legend span { display: inline-flex; align-items: center; gap: 0.3rem; }
.fl-swatch { width: 0.8rem; height: 0.25rem; border-radius: 2px; display: inline-block; }

/* ===== Responsive ===== */
@media (max-width: 980px) {
  .fl-app { grid-template-columns: 1fr; }
  .fl-controls { position: static; }
  .fl-views2d, .fl-plots { grid-template-columns: 1fr; }
}
@media (max-width: 500px) {
  .fl-coord-row { grid-template-columns: 4.4rem 1fr 1fr 1fr; }
  #fl-3d { height: 320px; }
}

/* ===== Print ===== */
@media print {
  .site-nav, .fl-controls, .fl-actions, #fl-3d, .fl-canvas { display: none; }
  .fl-app { grid-template-columns: 1fr; }
  .fl-card { background: #fff; color: #000; border-color: #ccc; }
  .fl-card-value, .fl-card-title { color: #000; }
}
