/* ROBERIN bicycle speed calculator - The New workspace (20260713a)
 * Scope: .tn-bsc-* tool workspace only. Hero / design-note / meta / ads / article
 * skeleton are owned by the globally enqueued shared The New CSS.
 * Spacing uses container gap (not child margins) so the element reset can't eat it
 * (ledger #22/#37). All surfaces use scheme-flipping tokens (ledger #8). */

.tn-bsc-page {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  color: #1a1208;
  -webkit-text-fill-color: currentColor;
}

.tn-bsc-page,
.tn-bsc-page * {
  box-sizing: border-box;
}

.tn-bsc-tool {
  --bsc-ink: #1a1208;
  --bsc-muted: #5a4a30;
  --bsc-line: #b8a888;
  --bsc-soft: #ddd4be;
  --bsc-paper: #faf6ee;
  --bsc-wash: #f5efdf;
  --bsc-surface: rgba(255, 252, 244, 0.74);
  --bsc-card: rgba(255, 252, 244, 0.5);
  --bsc-band-bg: rgba(255, 252, 244, 0.4);
  --bsc-accent: #c44a00;
  --bsc-btn-sec-bg: #ede6d4;
  --bsc-btn-sec-hover: #dfd4bb;
  --bsc-btn-sec-text: #1a1208;
  --bsc-btn-pri-bg: #1a1208;
  --bsc-btn-pri-hover: #c44a00;
  --bsc-btn-pri-text: #faf6ee;
  margin: 0 auto 18px;
  border-top: 2px solid var(--bsc-ink);
  border-bottom: 1px solid var(--bsc-line);
  background: linear-gradient(180deg, var(--bsc-paper), var(--bsc-wash));
  color: var(--bsc-ink);
  -webkit-text-fill-color: var(--bsc-ink);
}

.tn-bsc-tool ul,
.tn-bsc-tool ol,
.tn-bsc-tool li,
.tn-bsc-tool dd {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tn-bsc-tool dl,
.tn-bsc-tool dt,
.tn-bsc-tool p {
  margin: 0;
  padding: 0;
}

.tn-bsc-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.94fr) minmax(0, 1.06fr);
  gap: 0;
  min-height: 420px;
}

.tn-bsc-input,
.tn-bsc-result {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
  padding: 18px;
}

.tn-bsc-input {
  border-right: 1px solid var(--bsc-line);
}

.tn-bsc-pane-label {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  min-height: 26px;
  margin: 0;
  border-bottom: 1px solid var(--bsc-ink);
  color: var(--bsc-muted);
  -webkit-text-fill-color: var(--bsc-muted);
  font: 700 12px/1.2 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tn-bsc-fields {
  display: grid;
  gap: 12px;
}

.tn-bsc-primary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tn-bsc-group[hidden] {
  display: none;
}

.tn-bsc-group--time {
  display: grid;
  gap: 5px;
  align-content: start;
}

.tn-bsc-field-label {
  display: block;
}

/* Field: label OUTSIDE control, 5px gap; control row owns the border (ledger #34/#35). */
.tn-bsc-field {
  display: grid;
  gap: 5px;
  min-width: 0;
  margin: 0;
  border: 0;
  background: none;
}

.tn-bsc-field > span,
.tn-bsc-field-label {
  padding: 0;
  color: var(--bsc-muted);
  -webkit-text-fill-color: var(--bsc-muted);
  font: 700 12px/1.3 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.02em;
}

.tn-bsc-control {
  display: flex;
  align-items: stretch;
  min-width: 0;
  height: 40px;
  border: 1px solid var(--bsc-line);
  background: var(--bsc-surface);
}

.tn-bsc-control input,
.tn-bsc-control select {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--bsc-ink);
  -webkit-text-fill-color: var(--bsc-ink);
  font: 700 16px/1 Georgia, "Times New Roman", serif;
  outline: 0;
  appearance: none;
  -webkit-appearance: none;
}

/* Native select affordance (ledger #33): visible chevron + quiet wash. */
.tn-bsc-control select {
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--bsc-muted) 50%), linear-gradient(135deg, var(--bsc-muted) 50%, transparent 50%);
  background-position: right 13px center, right 8px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.tn-bsc-control input::placeholder {
  color: var(--bsc-muted);
  opacity: 0.55;
}

.tn-bsc-control input:focus-visible,
.tn-bsc-control select:focus-visible {
  outline: 2px solid var(--bsc-accent);
  outline-offset: -2px;
}

/* Unit suffix chip: 1px divider is the allowed structural exception (ledger #30/#9). */
.tn-bsc-control--suffix b {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-left: 1px solid var(--bsc-soft);
  color: var(--bsc-muted);
  -webkit-text-fill-color: var(--bsc-muted);
  font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: nowrap;
}

.tn-bsc-time-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.tn-bsc-field--time .tn-bsc-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Secondary bands (details): quiet, no heavy chrome. */
.tn-bsc-band {
  border: 1px solid var(--bsc-soft);
  background: var(--bsc-band-bg);
}

.tn-bsc-band > summary {
  padding: 9px 12px;
  color: var(--bsc-muted);
  -webkit-text-fill-color: var(--bsc-muted);
  font: 700 12px/1.2 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
}

.tn-bsc-band > summary::-webkit-details-marker {
  display: none;
}

.tn-bsc-band > summary::after {
  content: "+";
  float: right;
  font-family: ui-monospace, monospace;
}

.tn-bsc-band[open] > summary::after {
  content: "\2212";
}

.tn-bsc-band-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0 12px 12px;
}

/* Command row */
.tn-bsc-command {
  display: grid;
  gap: 8px;
}

.tn-bsc-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tn-bsc-actions > button {
  display: grid;
  place-items: center;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--bsc-line);
  border-radius: 0;
  background: var(--bsc-btn-sec-bg);
  color: var(--bsc-btn-sec-text);
  -webkit-text-fill-color: var(--bsc-btn-sec-text);
  font: 700 13px/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tn-bsc-actions > button:hover {
  background: var(--bsc-btn-sec-hover);
}

.tn-bsc-actions > button:focus-visible {
  outline: 2px solid var(--bsc-accent);
  outline-offset: 2px;
}

.tn-bsc-actions > .tn-bsc-primary {
  border-color: var(--bsc-btn-pri-bg);
  background: var(--bsc-btn-pri-bg);
  color: var(--bsc-btn-pri-text);
  -webkit-text-fill-color: var(--bsc-btn-pri-text);
}

.tn-bsc-actions > .tn-bsc-primary:hover {
  background: var(--bsc-btn-pri-hover);
  border-color: var(--bsc-btn-pri-hover);
}

.tn-bsc-status {
  min-height: 18px;
  color: var(--bsc-muted);
  -webkit-text-fill-color: var(--bsc-muted);
  font: 600 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.tn-bsc-status[data-state="error"] {
  color: #b3341a;
  -webkit-text-fill-color: #b3341a;
}

.tn-bsc-status[data-state="success"] {
  color: #3f6d2f;
  -webkit-text-fill-color: #3f6d2f;
}

/* Result pane */
.tn-bsc-main {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--bsc-line);
  background: var(--bsc-surface);
}

.tn-bsc-main > span {
  color: var(--bsc-muted);
  -webkit-text-fill-color: var(--bsc-muted);
  font: 700 12px/1.2 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tn-bsc-main > strong {
  font: 700 clamp(28px, 6vw, 38px)/1.1 Georgia, "Times New Roman", serif;
  color: var(--bsc-ink);
  -webkit-text-fill-color: var(--bsc-ink);
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: 0;
  white-space: nowrap;
}

.tn-bsc-main > em {
  color: var(--bsc-muted);
  -webkit-text-fill-color: var(--bsc-muted);
  font: 600 13px/1.3 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-style: normal;
}

.tn-bsc-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tn-bsc-metrics > div {
  display: grid;
  gap: 3px;
  padding: 9px 11px;
  border: 1px solid var(--bsc-soft);
  background: var(--bsc-card);
}

.tn-bsc-metrics dt {
  color: var(--bsc-muted);
  -webkit-text-fill-color: var(--bsc-muted);
  font: 700 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.02em;
}

.tn-bsc-metrics dd {
  color: var(--bsc-ink);
  -webkit-text-fill-color: var(--bsc-ink);
  font: 700 15px/1.25 Georgia, "Times New Roman", serif;
  font-variant-numeric: tabular-nums lining-nums;
}

.tn-bsc-metrics--compact > div {
  padding: 7px 10px;
}

.tn-bsc-metrics--compact dd {
  font-size: 14px;
}

.tn-bsc-submetrics,
.tn-bsc-adjust {
  display: grid;
  gap: 10px;
}

.tn-bsc-submetrics-label {
  margin: 0;
  color: var(--bsc-muted);
  -webkit-text-fill-color: var(--bsc-muted);
  font: 700 12px/1.2 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Base vs final comparison (ledger #23/#28): flat horizontal bars, no left rail (#30). */
.tn-bsc-compare {
  display: grid;
  gap: 8px;
}

.tn-bsc-compare-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.tn-bsc-compare-name {
  color: var(--bsc-muted);
  -webkit-text-fill-color: var(--bsc-muted);
  font: 700 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.tn-bsc-compare-track {
  position: relative;
  display: block;
  block-size: 12px;
  border: 1px solid var(--bsc-soft);
  background: rgba(184, 168, 136, 0.16);
}

.tn-bsc-compare-fill {
  display: block;
  block-size: 100%;
  inline-size: 0;
  transition: inline-size 0.2s ease;
}

.tn-bsc-compare-fill--base {
  background: #b8a888;
}

.tn-bsc-compare-fill--final {
  background: var(--bsc-accent);
}

.tn-bsc-disclaimer {
  margin: 0;
  color: var(--bsc-muted);
  -webkit-text-fill-color: var(--bsc-muted);
  font: 500 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ---- Mobile ---- */
@media (max-width: 720px) {
  .tn-bsc-grid {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }
  .tn-bsc-input {
    border-right: 0;
    border-bottom: 1px solid var(--bsc-line);
  }
  .tn-bsc-primary-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .tn-bsc-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 400px) {
  .tn-bsc-band-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---- Dark / inverse / auto-dark (ledger #8/#14): scheme tokens + text-fill ---- */
body:is([data-scheme="dark"], [data-scheme="inverse"], [data-scheme="auto"][data-d="dark"], [data-scheme="auto"][data-l="dark"]):not([data-scheme="light"]) .tn-bsc-tool,
html[data-scheme="dark"] body:not([data-scheme="light"]) .tn-bsc-tool,
html[data-scheme="inverse"] body:not([data-scheme="light"]) .tn-bsc-tool {
  --bsc-ink: #efe6d2;
  --bsc-muted: #c3b492;
  --bsc-line: #6f6047;
  --bsc-soft: #574a37;
  --bsc-paper: #241d12;
  --bsc-wash: #2c2417;
  --bsc-surface: rgba(58, 48, 32, 0.5);
  --bsc-card: rgba(58, 48, 32, 0.5);
  --bsc-band-bg: rgba(58, 48, 32, 0.36);
  --bsc-accent: #e8823f;
  --bsc-btn-sec-bg: #33291a;
  --bsc-btn-sec-hover: #453720;
  --bsc-btn-sec-text: #efe6d2;
  --bsc-btn-pri-bg: #e8823f;
  --bsc-btn-pri-hover: #f2a061;
  --bsc-btn-pri-text: #241206;
  color: var(--bsc-ink);
  -webkit-text-fill-color: var(--bsc-ink);
}

body:is([data-scheme="dark"], [data-scheme="inverse"], [data-scheme="auto"][data-d="dark"], [data-scheme="auto"][data-l="dark"]):not([data-scheme="light"]) .tn-bsc-control select,
html[data-scheme="dark"] body:not([data-scheme="light"]) .tn-bsc-control select {
  background-image: linear-gradient(45deg, transparent 50%, var(--bsc-muted) 50%), linear-gradient(135deg, var(--bsc-muted) 50%, transparent 50%);
  background-position: right 13px center, right 8px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

@media (prefers-color-scheme: dark) {
  body[data-scheme="auto"]:not([data-scheme="light"]) .tn-bsc-tool {
    --bsc-ink: #efe6d2;
    --bsc-muted: #c3b492;
    --bsc-line: #6f6047;
    --bsc-soft: #574a37;
    --bsc-paper: #241d12;
    --bsc-wash: #2c2417;
    --bsc-surface: rgba(58, 48, 32, 0.5);
    --bsc-card: rgba(58, 48, 32, 0.5);
    --bsc-band-bg: rgba(58, 48, 32, 0.36);
    --bsc-accent: #e8823f;
    --bsc-btn-sec-bg: #33291a;
    --bsc-btn-sec-hover: #453720;
    --bsc-btn-sec-text: #efe6d2;
    --bsc-btn-pri-bg: #e8823f;
    --bsc-btn-pri-hover: #f2a061;
    --bsc-btn-pri-text: #241206;
    color: var(--bsc-ink);
    -webkit-text-fill-color: var(--bsc-ink);
  }
}
