.tfp {
  --tfp-surface: #08121d;
  --tfp-panel: rgba(255, 255, 255, 0.045);
  --tfp-line: rgba(255, 255, 255, 0.16);
  --tfp-text: #f1f6fb;
  --tfp-text-2: #c3c2b7;
  --tfp-accent: #58b8ff;
  box-sizing: border-box;
  width: min(1840px, 100%);
  margin: 0.1rem auto 0;
  padding: 12px 16px 12px;
  border: 1px solid rgba(124, 199, 255, 0.36);
  border-radius: 14px;
  background: var(--tfp-surface);
  color: var(--tfp-text);
  font: 17px/1.22 system-ui, sans-serif;
  text-align: left;
}

main.content > .applet-stage--tfp {
  width: min(1860px, calc(100% - 2rem));
  max-width: none;
  padding: 0.6rem;
}

.tfp * { box-sizing: border-box; }
.tfp [hidden] { display: none !important; }

.tfp h4 {
  margin: 0 0 5px;
  color: var(--tfp-text-2);
  font: 700 0.78em/1.2 system-ui, sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.tfp button {
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--tfp-text);
  font: 650 0.86em/1.1 system-ui, sans-serif;
  cursor: pointer;
}
.tfp button:hover:not(:disabled),
.tfp button:focus-visible { border-color: #72c8ff; }
.tfp button:disabled { color: #7d8b97; border-color: rgba(255, 255, 255, 0.12); cursor: default; }
.tfp button.is-active { border-color: var(--tfp-accent); background: var(--tfp-accent); color: #06101a; }
.tfp button.is-active:disabled { background: rgba(88, 184, 255, 0.4); color: #0a1620; }

.tfp__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 22px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--tfp-line);
}
.tfp__tabs, .tfp__presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tfp__presets > span { margin-right: 4px; color: var(--tfp-text-2); font-size: 0.86em; }
.tfp__tabs button { min-height: 36px; padding: 4px 16px; font-size: 0.95em; }

.tfp__body {
  display: grid;
  grid-template-columns: 500px minmax(0, 1fr);
  gap: 14px;
  margin-top: 10px;
}

.tfp__controls { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.tfp__controls .tfp__sect {
  padding: 6px 10px 7px;
  border: 1px solid var(--tfp-line);
  border-radius: 10px;
  background: var(--tfp-panel);
}

.tfp__seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 5px; }
.tfp__seg--compact { display: inline-grid; grid-auto-columns: auto; }
.tfp__seg--compact button { min-height: 30px; padding: 3px 10px; }
.tfp__small { margin-top: 4px; color: var(--tfp-text-2); font-size: 0.74em; line-height: 1.3; }
.tfp__link {
  margin-top: 6px;
  border-color: transparent !important;
  background: none !important;
  color: #8fd0ff !important;
  font-weight: 600 !important;
  text-decoration: underline;
  text-align: left;
}

.tfp__params { display: grid; gap: 1px; }
.tfp__param {
  display: grid;
  grid-template-columns: 158px minmax(0, 1fr) 96px;
  align-items: center;
  gap: 8px;
}
.tfp__param > span { color: #e3ecf3; font-size: 0.88em; white-space: nowrap; }
.tfp input[type="range"] { width: 100%; margin: 0; accent-color: #58b8ff; }
.tfp input[type="number"] {
  width: 100%;
  padding: 3px 6px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  background: #0f1c2a;
  color: #fff;
  font: 0.86em/1.2 system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

.tfp__channels {
  display: grid;
  grid-template-columns: 70px repeat(3, 1fr);
  gap: 4px;
  align-items: center;
  margin-bottom: 6px;
}
.tfp__corner { color: var(--tfp-text-2); font-size: 0.66em; }
.tfp__colhead, .tfp__rowhead { text-align: center; font-weight: 700; }
.tfp__rowhead { text-align: left; }
.tfp__chan { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 30px; padding: 3px 4px; font-size: 0.72em !important; }
.tfp__chan i { width: 16px; height: 6px; border-radius: 3px; background: var(--chan); flex: none; }
.tfp button.tfp__chan.is-active { background: rgba(255, 255, 255, 0.12); border-color: var(--chan); color: #fff; box-shadow: inset 0 0 0 2px var(--chan); }
.tfp button.tfp__chan.is-active i { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25); }

.tfp-nu { white-space: nowrap; }
.tfp-nu sub { font-size: 0.7em; }
.tfp-bar { text-decoration: overline; }

.tfp__controls .tfp__sect:last-child { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tfp__controls .tfp__sect:last-child h4 { grid-column: 1 / -1; margin-bottom: 0; }
.tfp__controls .tfp__sect:last-child button { text-align: left; min-height: 36px; }

.tfp__main { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.tfp__axes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 6px 10px;
  border: 1px solid var(--tfp-line);
  border-radius: 10px;
  background: var(--tfp-panel);
}
.tfp__axes label { display: flex; align-items: center; gap: 7px; font-size: 0.86em; color: #e3ecf3; white-space: nowrap; }
.tfp__axes label input { width: 96px; }
.tfp__axes-label { color: var(--tfp-text-2); font-size: 0.8em; }

.tfp__stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1290 / 560;
  border: 1px solid var(--tfp-line);
  border-radius: 10px;
  background: rgba(3, 8, 14, 0.8);
  overflow: hidden;
}
.tfp__canvas { position: absolute; display: none; background: #000; }
.tfp__svg { position: absolute; inset: 0; width: 100%; height: 100%; outline: none; touch-action: pan-y; }
.tfp__svg:focus-visible { box-shadow: inset 0 0 0 2px #72c8ff; }

.tfp__grid { stroke: rgba(255, 255, 255, 0.11); stroke-width: 1; }
.tfp__grid--x { stroke: rgba(255, 255, 255, 0.07); }
.tfp__grid--map { stroke: rgba(255, 255, 255, 0.22); stroke-dasharray: 2 5; }
.tfp__frame { fill: none; stroke: rgba(255, 255, 255, 0.45); stroke-width: 1.2; }
.tfp__tick { fill: #c3c2b7; font: 16px system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.tfp__axis-label { fill: #e3ecf3; font: 17px system-ui, sans-serif; }
.tfp__zero { stroke: rgba(255, 255, 255, 0.35); stroke-width: 1.2; }
.tfp__curve { fill: none; stroke-width: 3; stroke-linejoin: round; }
.tfp__hair { stroke: rgba(255, 255, 255, 0.55); stroke-width: 1.2; stroke-dasharray: 4 4; }
.tfp__dot { stroke: #06101a; stroke-width: 2; }
.tfp__empty { fill: #c3c2b7; font: 20px system-ui, sans-serif; }
.tfp__map-mark { fill: none; stroke: #fff; stroke-width: 2; }
.tfp__cbar-bg { fill: rgba(6, 12, 20, 0.78); stroke: rgba(255, 255, 255, 0.18); }

.tfp__tooltip {
  position: absolute;
  z-index: 3;
  min-width: 210px;
  max-width: 420px;
  padding: 7px 10px 8px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 9px;
  background: rgba(8, 16, 26, 0.96);
  color: var(--tfp-text);
  font-size: 0.8em;
  line-height: 1.3;
  pointer-events: none;
}
.tfp__tip-head { font-weight: 700; }
.tfp__tip-sub { margin-bottom: 4px; color: var(--tfp-text-2); font-size: 0.9em; }
.tfp__tip-row { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.tfp__tip-row strong { min-width: 62px; color: #fff; font-variant-numeric: tabular-nums; }
.tfp__tip-name { color: var(--tfp-text-2); }

.tfp__legend { display: flex; flex-wrap: wrap; gap: 6px 26px; font-size: 0.82em; }
.tfp__legend-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; }
.tfp__key { display: inline-flex; align-items: center; gap: 6px; color: #e3ecf3; }
.tfp__key-text { margin-right: 6px; }
.tfp__key-set { color: var(--tfp-text-2); }
.tfp__x { min-height: 22px !important; margin-left: 2px; padding: 0 7px !important; line-height: 1 !important; }

.tfp__foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 20px; color: #d7e6ef; font-size: 0.8em; }
.tfp__foot .tfp__small { margin: 0; }

.tfp__details-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: start; }
.tfp__details { padding: 4px 10px 6px; border: 1px solid var(--tfp-line); border-radius: 10px; background: var(--tfp-panel); font-size: 0.8em; }
.tfp__details summary { cursor: pointer; color: #e3ecf3; font-weight: 650; }
.tfp__code {
  display: block;
  margin-top: 4px;
  padding: 6px 8px;
  overflow-wrap: anywhere;
  border-radius: 6px;
  background: #0b1622;
  color: #cfe8ff;
  font: 0.92em/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
  user-select: all;
}
.tfp__table-host { max-height: 240px; margin-top: 5px; overflow: auto; }
.tfp__table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.tfp__table th, .tfp__table td { padding: 2px 8px; border-bottom: 1px solid var(--tfp-line); text-align: right; white-space: nowrap; }
.tfp__table th:first-child, .tfp__table td:first-child { text-align: left; }
.tfp__table th { position: sticky; top: 0; background: #0b1622; color: #e3ecf3; }

@media (max-width: 1100px) {
  .tfp { font-size: 15px; }
  .tfp__body { grid-template-columns: 1fr; }
  .tfp__param { grid-template-columns: 130px minmax(0, 1fr) 84px; }
  .tfp__details-row { grid-template-columns: 1fr; }
}

/* Inside reveal.js slides: override the heading, table and code styles. */
.reveal .tfp h4 {
  margin: 0 0 5px;
  color: var(--tfp-text-2);
  font: 700 0.78em/1.2 system-ui, sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-shadow: none;
}
.reveal .tfp table { margin: 0; font-size: inherit; }
.reveal .tfp .tfp__table th,
.reveal .tfp .tfp__table td { padding: 2px 8px; border-bottom: 1px solid var(--tfp-line); font-size: inherit; text-align: right; }
.reveal .tfp .tfp__table th:first-child,
.reveal .tfp .tfp__table td:first-child { text-align: left; }
.reveal .tfp code { max-height: none; padding: 6px 8px; font-size: 0.92em; }
.reveal .tfp sub { bottom: -0.25em; }
.reveal .tfp button { text-transform: none; box-shadow: none; }
