/* Calculus Derivative Calculator — The New multi-locale workspace. 20260905c
 *
 * One vertical axis for the whole workspace: the field bar, the preset row and the metric
 * row all sit on `repeat(12, minmax(0,1fr))` with the same 10px gap, so column boundaries
 * line up at every breakpoint (ledger #42, 추가 필수 확인 #22).
 *
 * `.tn-related-links` and `.tn-source-links` are intentionally absent: the shared
 * fixed-partials CSS owns those for every data-tn-fixed-partials page.
 *
 * The element reset below never touches `p` padding — the notation line, the status row
 * and the notice are paragraphs that own border, background and padding (추가 필수 확인 #3).
 */
.tn-cdc-page,
.tn-cdc-page * { box-sizing: border-box; }

.tn-cdc-page {
  --cdc-paper: #faf6ee;
  --cdc-wash: #f5efdf;
  --cdc-panel: #fffaf0;
  --cdc-ink: #1a1208;
  --cdc-muted: #5a4a30;
  --cdc-line: #b8a888;
  --cdc-soft-line: #ddd4be;
  --cdc-accent: #c44a00;
  --cdc-primary-bg: #1a1208;
  --cdc-primary-ink: #fff7e8;
  --cdc-secondary-bg: #ede6d4;
  --cdc-secondary-ink: #1a1208;
  --cdc-error-bg: #f7e3da;
  --cdc-error-ink: #7e2816;
  --cdc-error-line: #c7836e;
  --cdc-good-bg: #e3efe6;
  --cdc-good-ink: #235c3d;
  --cdc-good-line: #8fb79f;
  --cdc-plot-f: #5a4a30;
  --cdc-plot-d: #c44a00;
  --cdc-guide: #b8a888;
  width: min(1180px, calc(100vw - 10px));
  max-width: 100%;
  min-width: 0;
  margin: 0 auto;
  color: var(--cdc-ink);
  -webkit-text-fill-color: var(--cdc-ink);
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

/* `style.css` ships `.cs-main-content .entry-content ul:not(…)` at (0,3,1), which paints
   square markers and a 32px indent onto the rule chips and the chart legend. A plain
   scoped reset loses that cascade, so the tool-only reset is marked important and the
   components that need inner padding restate theirs (kill list #1). The Article lists are
   outside `.tn-cdc-tool` and stay owned by the shared fixed-partials CSS. */
.tn-cdc-page .tn-cdc-tool :is(ul, ol) { list-style: none !important; padding: 0 !important; margin: 0 !important; }
.tn-cdc-page .tn-cdc-tool li { list-style: none !important; padding: 0 !important; margin: 0 !important; }
.tn-cdc-page .tn-cdc-tool .tn-cdc-rule { padding: 0 9px !important; }
.tn-cdc-page .tn-cdc-tool :is(code, pre, kbd, samp) { padding: 0; border: 0; border-radius: 0; background: none; background-color: transparent; color: inherit; -webkit-text-fill-color: inherit; font-family: inherit; }

.tn-cdc-tool {
  margin: 0 0 18px;
  color: var(--cdc-ink);
  -webkit-text-fill-color: var(--cdc-ink);
  background:
    linear-gradient(90deg, rgba(184, 168, 136, .13) 1px, transparent 1px) 0 0 / 18px 18px,
    linear-gradient(0deg, rgba(184, 168, 136, .10) 1px, transparent 1px) 0 0 / 18px 18px,
    var(--cdc-paper);
  border: 1px solid var(--cdc-line);
  padding: 12px;
  overflow: hidden;
}

.tn-cdc-workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; min-width: 0; }

.tn-cdc-pane {
  min-width: 0;
  display: grid;
  grid-template-rows: auto;
  align-content: start;
  row-gap: 12px;
  background: color-mix(in srgb, var(--cdc-panel) 92%, transparent);
  border: 1px solid var(--cdc-line);
  padding: 12px;
}

.tn-cdc-kicker {
  margin: 0;
  color: var(--cdc-muted);
  -webkit-text-fill-color: var(--cdc-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* ---------------------------------------------------------------- input band */

.tn-cdc-fieldbar {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  min-width: 0;
}

.tn-cdc-field--expr { grid-column: span 6; }
.tn-cdc-field--variable { grid-column: span 2; }
.tn-cdc-field--order { grid-column: span 2; }
.tn-cdc-field--point { grid-column: span 2; }

.tn-cdc-field {
  display: grid;
  grid-template-rows: auto auto;
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
  align-content: start;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--cdc-muted);
  -webkit-text-fill-color: var(--cdc-muted);
  font-size: 12.5px;
  line-height: 1.2;
  font-weight: 800;
}

/* Label reset only. `:not(.tn-cdc-control)` matters: the control is also a direct span
   child, and at specificity (0,1,1) this rule would otherwise beat `.tn-cdc-control`
   (0,1,0) and strip its inner padding (추가 필수 확인 #3). */
.tn-cdc-field > span:not(.tn-cdc-control) { display: block; margin: 0; padding: 0; }

.tn-cdc-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 40px;
  padding: 0 10px;
  background: var(--cdc-panel);
  border: 1px solid var(--cdc-line);
}

.tn-cdc-control input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--cdc-ink);
  -webkit-text-fill-color: var(--cdc-ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: normal;
  outline: 0;
}

.tn-cdc-control input::placeholder,
.tn-cdc-control input::-webkit-input-placeholder { color: var(--cdc-muted); -webkit-text-fill-color: var(--cdc-muted); font-weight: 400; opacity: .35; }
.tn-cdc-control:has(input:focus-visible),
.tn-cdc-control:has(select:focus-visible) { outline: 2px solid var(--cdc-accent); outline-offset: -1px; }

/* The evaluation point reads `x = 2`, so its label is a prefix rather than a unit suffix:
   the marker sits before the input and owns the divider on its right (ledger #48 keeps the
   label and the value as one block instead of pushing them to opposite borders). */
.tn-cdc-control--prefix b {
  border-left: 0;
  border-right: 1px solid var(--cdc-soft-line);
  padding-left: 0;
  padding-right: 8px;
}

.tn-cdc-control b {
  flex: 0 0 auto;
  color: var(--cdc-muted);
  -webkit-text-fill-color: var(--cdc-muted);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12.5px;
  font-weight: 800;
  font-variant-numeric: lining-nums tabular-nums;
  border-left: 1px solid var(--cdc-soft-line);
  padding-left: 8px;
}

/* The native select keeps its accessibility but gets a visible chevron and the same flat
   palette as the text controls (ledger #33). */
.tn-cdc-control--select { padding-right: 8px; }
.tn-cdc-control select {
  appearance: none;
  -webkit-appearance: none;
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  height: 100%;
  margin: 0;
  padding: 0 18px 0 0;
  border: 0;
  background: transparent;
  color: var(--cdc-ink);
  -webkit-text-fill-color: var(--cdc-ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  outline: 0;
}
.tn-cdc-control--select::after {
  content: "";
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  margin-left: -14px;
  border-right: 2px solid var(--cdc-muted);
  border-bottom: 2px solid var(--cdc-muted);
  transform: translateY(-2px) rotate(45deg);
  pointer-events: none;
}

.tn-cdc-seg {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  height: 40px;
  border: 1px solid var(--cdc-line);
  overflow: hidden;
}

.tn-cdc-seg button {
  appearance: none;
  -webkit-appearance: none;
  height: 100%;
  min-width: 0;
  margin: 0;
  padding: 0 4px;
  border: 0;
  border-right: 1px solid var(--cdc-line);
  background: var(--cdc-panel);
  color: var(--cdc-muted);
  -webkit-text-fill-color: var(--cdc-muted);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: lining-nums tabular-nums;
  line-height: 1;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tn-cdc-seg button:last-child { border-right: 0; }
.tn-cdc-seg button[aria-pressed="true"] { background: var(--cdc-primary-bg); color: var(--cdc-primary-ink); -webkit-text-fill-color: var(--cdc-primary-ink); }

.tn-cdc-notation {
  margin: 0;
  padding: 9px 11px;
  background: var(--cdc-wash);
  border: 1px solid var(--cdc-soft-line);
  color: var(--cdc-muted);
  -webkit-text-fill-color: var(--cdc-muted);
  font-size: 12px;
  line-height: 1.5;
  font-weight: 700;
}
.tn-cdc-notation b { color: var(--cdc-ink); -webkit-text-fill-color: var(--cdc-ink); font-weight: 800; }

.tn-cdc-quick { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px; min-width: 0; }
.tn-cdc-chip { grid-column: span 2; }
.tn-cdc-quick .tn-cdc-button { grid-column: span 2; }

.tn-cdc-chip {
  appearance: none;
  -webkit-appearance: none;
  min-width: 0;
  height: 34px;
  margin: 0;
  padding: 0 8px;
  border: 1px solid var(--cdc-soft-line);
  background: var(--cdc-wash);
  color: var(--cdc-muted);
  -webkit-text-fill-color: var(--cdc-muted);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  outline: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tn-cdc-chip[aria-pressed="true"] { background: var(--cdc-primary-bg); color: var(--cdc-primary-ink); -webkit-text-fill-color: var(--cdc-primary-ink); border-color: var(--cdc-primary-bg); }

.tn-cdc-button {
  appearance: none;
  -webkit-appearance: none;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--cdc-line);
  background: var(--cdc-secondary-bg);
  color: var(--cdc-secondary-ink);
  -webkit-text-fill-color: var(--cdc-secondary-ink);
  font-family: "Noto Sans KR", system-ui, sans-serif;
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  outline: none;
}

.tn-cdc-button:focus-visible,
.tn-cdc-seg button:focus-visible,
.tn-cdc-chip:focus-visible,
.tn-cdc-mini:focus-visible { outline: 2px solid var(--cdc-accent); outline-offset: 2px; }

.tn-cdc-status {
  margin: 0;
  padding: 9px 11px;
  background: var(--cdc-wash);
  border: 1px solid var(--cdc-soft-line);
  color: var(--cdc-muted);
  -webkit-text-fill-color: var(--cdc-muted);
  font-size: 12.5px;
  line-height: 1.45;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.tn-cdc-status[data-tone="error"] { background: var(--cdc-error-bg); border-color: var(--cdc-error-line); color: var(--cdc-error-ink); -webkit-text-fill-color: var(--cdc-error-ink); }
.tn-cdc-status[data-tone="done"] { background: var(--cdc-good-bg); border-color: var(--cdc-good-line); color: var(--cdc-good-ink); -webkit-text-fill-color: var(--cdc-good-ink); }

/* ---------------------------------------------------------------- result */

.tn-cdc-verdict {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--cdc-line);
  background: var(--cdc-panel);
}

.tn-cdc-verdict-value {
  min-width: 0;
  margin: 0;
  color: var(--cdc-ink);
  -webkit-text-fill-color: var(--cdc-ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 22px;
  line-height: 1.35;
  font-weight: 800;
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: normal;
  overflow-wrap: anywhere;
}
.tn-cdc-verdict-label {
  grid-column: 1 / 2;
  grid-row: 2;
  min-width: 0;
  margin: 0;
  color: var(--cdc-muted);
  -webkit-text-fill-color: var(--cdc-muted);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12.5px;
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: .04em;
}
.tn-cdc-verdict .tn-cdc-mini { grid-column: 2; grid-row: 1 / span 2; }

.tn-cdc-mini {
  appearance: none;
  -webkit-appearance: none;
  height: 34px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid var(--cdc-soft-line);
  background: var(--cdc-wash);
  color: var(--cdc-muted);
  -webkit-text-fill-color: var(--cdc-muted);
  font-family: "Noto Sans KR", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  outline: none;
}
.tn-cdc-mini:disabled { opacity: .5; cursor: not-allowed; }

.tn-cdc-point-label {
  margin: 0;
  color: var(--cdc-muted);
  -webkit-text-fill-color: var(--cdc-muted);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: .04em;
}

.tn-cdc-metrics { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px; align-items: stretch; min-width: 0; }
.tn-cdc-metric { grid-column: span 3; }
.tn-cdc-metric {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 5px;
  margin: 0;
  padding: 10px 11px;
  border: 1px solid var(--cdc-soft-line);
  background: var(--cdc-panel);
}
.tn-cdc-metric dt { margin: 0; color: var(--cdc-muted); -webkit-text-fill-color: var(--cdc-muted); font-size: 12px; line-height: 1.2; font-weight: 800; letter-spacing: .04em; }
.tn-cdc-metric dd {
  margin: 0;
  color: var(--cdc-ink);
  -webkit-text-fill-color: var(--cdc-ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 800;
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: normal;
  overflow-wrap: anywhere;
}
.tn-cdc-metric small { color: var(--cdc-muted); -webkit-text-fill-color: var(--cdc-muted); font-size: 11.5px; line-height: 1.4; font-weight: 600; }

/* Derivative ladder. */
.tn-cdc-ladder { display: grid; gap: 6px; min-width: 0; }
.tn-cdc-ladder-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.tn-cdc-ladder-title { color: var(--cdc-muted); -webkit-text-fill-color: var(--cdc-muted); font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.tn-cdc-table-wrap { width: 100%; max-width: 100%; min-width: 0; border: 1px solid var(--cdc-soft-line); background: var(--cdc-panel); }
.tn-cdc-ladder-table { width: 100%; border-collapse: collapse; color: var(--cdc-ink); -webkit-text-fill-color: var(--cdc-ink); font-size: 13px; line-height: 1.45; table-layout: fixed; }
.tn-cdc-ladder-table th,
.tn-cdc-ladder-table td { padding: 7px 9px; border-right: 1px solid var(--cdc-soft-line); border-bottom: 1px solid var(--cdc-soft-line); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.tn-cdc-ladder-table tr > :last-child { border-right: 0; }
.tn-cdc-ladder-table tbody tr:last-child > * { border-bottom: 0; }
.tn-cdc-ladder-table thead th { background: var(--cdc-primary-bg); color: var(--cdc-primary-ink); -webkit-text-fill-color: var(--cdc-primary-ink); font-weight: 800; white-space: nowrap; }
.tn-cdc-ladder-table col.tn-cdc-col-name { width: 16%; }
.tn-cdc-ladder-table col.tn-cdc-col-value { width: 20%; }
.tn-cdc-ladder-table tbody th {
  background: var(--cdc-wash);
  color: var(--cdc-ink);
  -webkit-text-fill-color: var(--cdc-ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 800;
  white-space: nowrap;
}
.tn-cdc-ladder-table td {
  background: var(--cdc-panel);
  color: var(--cdc-ink);
  -webkit-text-fill-color: var(--cdc-ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 800;
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: normal;
}
.tn-cdc-ladder-table tbody tr[data-current="true"] th,
.tn-cdc-ladder-table tbody tr[data-current="true"] td { background: var(--cdc-wash); }

/* Applied rules. */
.tn-cdc-rules-block { display: grid; gap: 6px; min-width: 0; }
.tn-cdc-rules-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.tn-cdc-rules-title { color: var(--cdc-muted); -webkit-text-fill-color: var(--cdc-muted); font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.tn-cdc-rules-note { color: var(--cdc-muted); -webkit-text-fill-color: var(--cdc-muted); font-size: 11.5px; font-weight: 700; font-variant-numeric: lining-nums tabular-nums; }
.tn-cdc-rules { display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; margin: 0; padding: 0; list-style: none; }
.tn-cdc-rule {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--cdc-soft-line);
  background: var(--cdc-wash);
  color: var(--cdc-muted);
  -webkit-text-fill-color: var(--cdc-muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

/* Function / derivative plot. The frame renders on the empty first paint; only the two
   curves and the markers wait for input (추가 필수 확인 #10/#15). */
.tn-cdc-chart-block { display: grid; gap: 6px; min-width: 0; }
.tn-cdc-chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.tn-cdc-chart-title { color: var(--cdc-muted); -webkit-text-fill-color: var(--cdc-muted); font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.tn-cdc-chart-note { color: var(--cdc-muted); -webkit-text-fill-color: var(--cdc-muted); font-size: 11.5px; font-weight: 700; font-variant-numeric: lining-nums tabular-nums; }
.tn-cdc-legend { display: flex; flex-wrap: wrap; gap: 12px; margin: 0; padding: 0; list-style: none; }
.tn-cdc-legend li { display: inline-flex; align-items: center; gap: 6px; color: var(--cdc-muted); -webkit-text-fill-color: var(--cdc-muted); font-size: 11.5px; font-weight: 800; }
.tn-cdc-legend i { display: inline-block; width: 16px; height: 0; border-top: 2px dashed var(--cdc-plot-f); }
.tn-cdc-legend li + li i { border-top: 2px solid var(--cdc-plot-d); }
.tn-cdc-chart { width: 100%; min-width: 0; height: 210px; border: 1px solid var(--cdc-soft-line); background: var(--cdc-panel); }
.tn-cdc-chart svg { display: block; width: 100%; height: 100%; }
.tn-cdc-chart .cdc-grid { stroke: var(--cdc-soft-line); stroke-width: 1; }
.tn-cdc-chart .cdc-frame { fill: none; stroke: var(--cdc-line); stroke-width: 1; }
.tn-cdc-chart .cdc-axis { stroke: var(--cdc-line); stroke-width: 1; }
.tn-cdc-chart .cdc-guide { stroke: var(--cdc-guide); stroke-width: 1; stroke-dasharray: 3 3; }
.tn-cdc-chart .cdc-line-f { fill: none; stroke: var(--cdc-plot-f); stroke-width: 1.75; stroke-dasharray: 5 4; stroke-linejoin: round; stroke-linecap: round; }
.tn-cdc-chart .cdc-line-d { fill: none; stroke: var(--cdc-plot-d); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.tn-cdc-chart .cdc-dot-f { fill: var(--cdc-plot-f); }
.tn-cdc-chart .cdc-dot-d { fill: var(--cdc-plot-d); }
.tn-cdc-chart .cdc-tick { fill: var(--cdc-muted); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 10px; font-weight: 700; font-variant-numeric: lining-nums tabular-nums; }

.tn-cdc-notice {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: var(--cdc-wash);
  border: 1px solid var(--cdc-soft-line);
  color: var(--cdc-muted);
  -webkit-text-fill-color: var(--cdc-muted);
  font-size: 12px;
  line-height: 1.5;
  font-weight: 700;
}

/* Article-side worked-example table. */
.tn-cdc-page .tn-cdc-example-wrap { width: 100%; max-width: 100%; margin-top: 12px; overflow-x: auto; overscroll-behavior-inline: contain; border: 1px solid var(--cdc-line); background: var(--cdc-panel); }
.tn-cdc-page .tn-cdc-example-wrap:focus-visible { outline: 2px solid var(--cdc-accent); outline-offset: 2px; }
.tn-cdc-page .tn-cdc-example-table { width: 100%; min-width: 460px; border-collapse: collapse; color: var(--cdc-ink); -webkit-text-fill-color: var(--cdc-ink); font-size: 13px; line-height: 1.45; }
.tn-cdc-page .tn-cdc-example-table th,
.tn-cdc-page .tn-cdc-example-table td { padding: 9px 10px; border-right: 1px solid var(--cdc-soft-line); border-bottom: 1px solid var(--cdc-soft-line); text-align: left; vertical-align: top; }
.tn-cdc-page .tn-cdc-example-table tr > :last-child { border-right: 0; }
.tn-cdc-page .tn-cdc-example-table tbody tr:last-child > * { border-bottom: 0; }
.tn-cdc-page .tn-cdc-example-table thead th { background: var(--cdc-primary-bg); color: var(--cdc-primary-ink); -webkit-text-fill-color: var(--cdc-primary-ink); font-weight: 800; }
.tn-cdc-page .tn-cdc-example-table tbody th { background: var(--cdc-wash); color: var(--cdc-ink); -webkit-text-fill-color: var(--cdc-ink); font-weight: 800; }
.tn-cdc-page .tn-cdc-example-table td { background: var(--cdc-panel); color: var(--cdc-muted); -webkit-text-fill-color: var(--cdc-muted); font-weight: 600; font-variant-numeric: lining-nums tabular-nums; }

/* ---------------------------------------------------------------- breakpoints */

@media (max-width: 1000px) {
  .tn-cdc-fieldbar,
  .tn-cdc-quick,
  .tn-cdc-metrics { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .tn-cdc-field--expr { grid-column: span 6; }
  .tn-cdc-field--variable,
  .tn-cdc-field--order,
  .tn-cdc-field--point { grid-column: span 2; }
  .tn-cdc-chip { grid-column: span 2; }
  .tn-cdc-quick .tn-cdc-button { grid-column: span 6; }
  .tn-cdc-metric { grid-column: span 3; }
}

@media (max-width: 640px) {
  .tn-cdc-tool { padding: 8px; }
  .tn-cdc-pane { padding: 10px; }
  .tn-cdc-verdict { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .tn-cdc-verdict-value { font-size: 19px; }
  .tn-cdc-verdict-label { grid-column: 1; grid-row: 2; }
  .tn-cdc-verdict .tn-cdc-mini { grid-column: 1; grid-row: 3; width: 100%; }
  .tn-cdc-chart { height: 180px; }
}

/* The field bar, preset row and metric row keep the same track count at every breakpoint
   so the vertical column axis stays aligned (ledger #42). */
@media (max-width: 560px) {
  .tn-cdc-fieldbar,
  .tn-cdc-quick,
  .tn-cdc-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tn-cdc-field--expr,
  .tn-cdc-field--point { grid-column: span 2; }
  .tn-cdc-field--variable,
  .tn-cdc-field--order { grid-column: span 1; }
  .tn-cdc-chip { grid-column: span 1; }
  .tn-cdc-quick .tn-cdc-button { grid-column: span 2; }
  .tn-cdc-metric { grid-column: span 1; }

  /* The ladder becomes a stacked card per row rather than a horizontally scrolling grid,
     so long Indonesian and Spanish column names keep their meaning (ledger #36). */
  .tn-cdc-ladder-table,
  .tn-cdc-ladder-table tbody { display: block; }
  .tn-cdc-ladder-table thead { display: none; }
  .tn-cdc-ladder-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-bottom: 1px solid var(--cdc-soft-line);
  }
  .tn-cdc-ladder-table tbody tr:last-child { border-bottom: 0; }
  .tn-cdc-ladder-table tbody th,
  .tn-cdc-ladder-table tbody td {
    display: block;
    min-width: 0;
    border-right: 0;
    border-bottom: 0;
    padding: 6px 8px;
    background: none;
    overflow-wrap: anywhere;
  }
  .tn-cdc-ladder-table tbody td:nth-of-type(1) { grid-column: 1 / -1; }
  .tn-cdc-ladder-table tbody :is(th, td)::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    color: var(--cdc-muted);
    -webkit-text-fill-color: var(--cdc-muted);
    font-size: 11px;
    line-height: 1.2;
    font-weight: 800;
  }
}

@media (max-width: 420px) {
  .tn-cdc-seg button { font-size: 12px; }
  .tn-cdc-metric dd { font-size: 15px; }
  .tn-cdc-control input,
  .tn-cdc-control select { font-size: 15px; }
}

/* ---------------------------------------------------------------- schemes */

body:is([data-scheme="dark"], [data-scheme="inverse"], [data-scheme="auto"][data-l="dark"], [data-scheme="auto"][data-d="dark"]) .tn-cdc-page,
html[data-scheme="dark"] body:not([data-scheme="light"]) .tn-cdc-page {
  --cdc-paper: #201811;
  --cdc-wash: #2b2119;
  --cdc-panel: #241c15;
  --cdc-ink: #f7ecd8;
  --cdc-muted: #d3c2a4;
  --cdc-line: #6f5d40;
  --cdc-soft-line: #4c3f2c;
  --cdc-accent: #ff8a3d;
  --cdc-primary-bg: #3d2f1e;
  --cdc-primary-ink: #ffe9c6;
  --cdc-secondary-bg: #33281c;
  --cdc-secondary-ink: #f7ecd8;
  --cdc-error-bg: #3a211c;
  --cdc-error-ink: #ffc2b3;
  --cdc-error-line: #854d40;
  --cdc-good-bg: #22301f;
  --cdc-good-ink: #b9e0c2;
  --cdc-good-line: #4e6b52;
  --cdc-plot-f: #d3c2a4;
  --cdc-plot-d: #ff9f5e;
  --cdc-guide: #6f5d40;
  color: var(--cdc-ink);
  -webkit-text-fill-color: var(--cdc-ink);
}

@media (prefers-color-scheme: dark) {
  body[data-scheme="auto"] .tn-cdc-page {
    --cdc-paper: #201811;
    --cdc-wash: #2b2119;
    --cdc-panel: #241c15;
    --cdc-ink: #f7ecd8;
    --cdc-muted: #d3c2a4;
    --cdc-line: #6f5d40;
    --cdc-soft-line: #4c3f2c;
    --cdc-accent: #ff8a3d;
    --cdc-primary-bg: #3d2f1e;
    --cdc-primary-ink: #ffe9c6;
    --cdc-secondary-bg: #33281c;
    --cdc-secondary-ink: #f7ecd8;
    --cdc-error-bg: #3a211c;
    --cdc-error-ink: #ffc2b3;
    --cdc-error-line: #854d40;
    --cdc-good-bg: #22301f;
    --cdc-good-ink: #b9e0c2;
    --cdc-good-line: #4e6b52;
    --cdc-plot-f: #d3c2a4;
    --cdc-plot-d: #ff9f5e;
    --cdc-guide: #6f5d40;
    color: var(--cdc-ink);
    -webkit-text-fill-color: var(--cdc-ink);
  }
}

body:is([data-scheme="dark"], [data-scheme="inverse"], [data-scheme="auto"][data-l="dark"], [data-scheme="auto"][data-d="dark"]) .tn-cdc-control :is(input, select),
html[data-scheme="dark"] body:not([data-scheme="light"]) .tn-cdc-control :is(input, select) { color: var(--cdc-ink); -webkit-text-fill-color: var(--cdc-ink); color-scheme: dark; }
@media (prefers-color-scheme: dark) { body[data-scheme="auto"] .tn-cdc-control :is(input, select) { color: var(--cdc-ink); -webkit-text-fill-color: var(--cdc-ink); color-scheme: dark; } }

/* The sitewide dark rule paints every `tn-`-prefixed node cream with !important. The
   pressed states below own a dark surface, so the text token has to win back explicitly
   (kill list #15). */
body:is([data-scheme="dark"], [data-scheme="inverse"], [data-scheme="auto"][data-l="dark"], [data-scheme="auto"][data-d="dark"]) .tn-cdc-page .tn-cdc-tool :is(.tn-cdc-seg button[aria-pressed="true"], .tn-cdc-chip[aria-pressed="true"]),
html[data-scheme="dark"] body:not([data-scheme="light"]) .tn-cdc-page .tn-cdc-tool :is(.tn-cdc-seg button[aria-pressed="true"], .tn-cdc-chip[aria-pressed="true"]),
body:is([data-scheme="dark"], [data-scheme="inverse"], [data-scheme="auto"][data-l="dark"], [data-scheme="auto"][data-d="dark"]) .tn-cdc-page :is(.tn-cdc-ladder-table thead th, .tn-cdc-example-table thead th),
html[data-scheme="dark"] body:not([data-scheme="light"]) .tn-cdc-page :is(.tn-cdc-ladder-table thead th, .tn-cdc-example-table thead th) {
  color: var(--cdc-primary-ink) !important;
  -webkit-text-fill-color: var(--cdc-primary-ink) !important;
}

@media (prefers-color-scheme: dark) {
  body[data-scheme="auto"] .tn-cdc-page .tn-cdc-tool :is(.tn-cdc-seg button[aria-pressed="true"], .tn-cdc-chip[aria-pressed="true"]),
  body[data-scheme="auto"] .tn-cdc-page :is(.tn-cdc-ladder-table thead th, .tn-cdc-example-table thead th) {
    color: var(--cdc-primary-ink) !important;
    -webkit-text-fill-color: var(--cdc-primary-ink) !important;
  }
}
