/* Outils interactifs NSI : comparateur, mini-quiz, encapsulation */

.mini-quiz {
  margin: 1.25rem 0;
  padding: 1.15rem 1.25rem;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}

.mini-quiz__title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 800;
  color: #0f172a;
}

.mini-quiz__q {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.45;
}

.mini-quiz__opts {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}

.mini-quiz__opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.85rem;
  border-radius: 10px;
  border: 2px solid #e2e8f0;
  background: #fff;
  color: #334155;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.mini-quiz__opt:hover:not(:disabled) {
  border-color: #ffb199;
  background: #eef2ff;
}

.mini-quiz__opt.is-correct {
  border-color: #10b981;
  background: #ecfdf5;
  color: #047857;
}

.mini-quiz__opt.is-wrong {
  border-color: #f87171;
  background: #fef2f2;
  color: #b91c1c;
}

.mini-quiz__opt:disabled {
  cursor: default;
}

.mini-quiz__feedback {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.mini-quiz__feedback.ok {
  color: #047857;
}

.mini-quiz__feedback.ko {
  color: #b91c1c;
}

.mini-quiz__score {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid #e2e8f0;
  font-weight: 700;
  color: #ef4a34;
}

/* Comparateur algorithmes */
.page-recherche .algo-compare-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  max-width: 40rem;
  margin: 0 auto 1.25rem;
}

.page-recherche .algo-compare-nav a {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-light);
  text-decoration: none;
}

.page-recherche .algo-compare-nav a:hover {
  color: var(--primary);
}

/* Comparateur : suit le theme clair / sombre du site */
.algo-compare {
  max-width: 40rem;
  margin: 0 auto 2rem;
  padding: 1.35rem 1.4rem 1.5rem;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  color: var(--text-dark);
}

.algo-compare__intro {
  margin: 0 0 1.2rem;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
}

.algo-compare__title {
  margin: 0 0 0.45rem;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-dark);
  line-height: 1.4;
}

.algo-compare__lead {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-light);
  line-height: 1.6;
}

.algo-compare__lead strong {
  color: var(--text-dark);
  font-weight: 700;
}

.algo-compare__control {
  margin-bottom: 1.1rem;
  padding: 0.95rem 1rem;
  border-radius: 12px;
  background: var(--light-bg);
  border: 1px solid var(--border);
}

.algo-compare__control-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.algo-compare__control label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-dark);
}

.algo-compare__control label em {
  font-style: normal;
  font-weight: 800;
  color: var(--primary-dark);
}

.algo-compare__n-value {
  font-variant-numeric: tabular-nums;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary-dark);
  line-height: 1.3;
  white-space: nowrap;
}

.algo-compare__n-value.is-large {
  font-size: 1.05rem;
}

.algo-compare__control input[type="range"] {
  width: 100%;
  height: 6px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.algo-compare__ticks {
  display: flex;
  justify-content: space-between;
  gap: 0.15rem;
  margin-top: 0.5rem;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-light);
  line-height: 1.35;
  flex-wrap: wrap;
}

.algo-compare__ticks span {
  white-space: nowrap;
}

.algo-compare__ratio-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0.35rem 0.5rem;
  margin-bottom: 1.15rem;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  background: rgba(239, 74, 52, 0.08);
  border: 1px solid rgba(239, 74, 52, 0.2);
}

.algo-compare__ratio-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
}

.algo-compare__ratio {
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--primary-dark);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.algo-compare__ratio.is-large {
  font-size: 1.25rem;
}

.algo-compare__ratio-sub {
  font-size: 0.8rem;
  color: var(--text-light);
}

.algo-compare__viz {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.algo-compare__panel {
  display: flex;
  flex-direction: column;
  padding: 0.85rem 0.9rem 0.75rem;
  border-radius: 12px;
  background: var(--light-bg);
  border: 1px solid var(--border);
  min-height: 11rem;
}

.algo-compare__panel--seq {
  border-top: 3px solid #f97316;
}

.algo-compare__panel--dic {
  border-top: 3px solid var(--primary);
}

.algo-compare__panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.algo-compare__panel-name {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--text-dark);
}

.algo-compare__panel-cpx {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: rgba(239, 74, 52, 0.1);
  color: var(--text-light);
}

.algo-compare__panel-val {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.algo-compare__panel-val.is-large {
  font-size: 1.15rem;
}

.algo-compare__panel--seq .algo-compare__panel-val {
  color: #c2410c;
}

.algo-compare__panel--dic .algo-compare__panel-val {
  color: var(--primary-dark);
}

.algo-compare__panel-unit {
  margin: 0.15rem 0 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-light);
}

.algo-compare__meter {
  margin-top: auto;
  height: 5.5rem;
  display: flex;
  align-items: flex-end;
  padding: 0 0.15rem;
  background: #e2e8f0;
  border-radius: 8px 8px 4px 4px;
}

.algo-compare__fill {
  width: 100%;
  border-radius: 6px 6px 3px 3px;
  transition: height 0.4s cubic-bezier(0.33, 1, 0.68, 1);
  min-height: 14%;
}

.algo-compare__fill--seq {
  background: linear-gradient(180deg, #fb923c 0%, #ea580c 100%);
}

.algo-compare__fill--dic {
  background: linear-gradient(180deg, #ffb199 0%, #ef4a34 100%);
}

.algo-compare__scale-note {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  color: var(--text-light);
  line-height: 1.45;
  text-align: center;
}

.algo-compare__scale-note em {
  font-style: normal;
  font-weight: 600;
  color: var(--text-dark);
}

.algo-compare__insight {
  margin: 0;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: rgba(239, 74, 52, 0.08);
  border: 1px solid rgba(239, 74, 52, 0.18);
  font-size: 0.88rem;
  color: var(--text-dark);
  line-height: 1.55;
}

html.theme-dark .page-recherche .algo-compare-nav a {
  color: #94a3b8;
}

html.theme-dark .page-recherche .algo-compare-nav a:hover {
  color: var(--primary-light);
}

html.theme-dark .algo-compare {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

html.theme-dark .algo-compare__title {
  color: #f1f5f9;
}

html.theme-dark .algo-compare__lead {
  color: #94a3b8;
}

html.theme-dark .algo-compare__lead strong {
  color: #e2e8f0;
}

html.theme-dark .algo-compare__control {
  background: #0f172a;
  border-color: #475569;
}

html.theme-dark .algo-compare__control label {
  color: #e2e8f0;
}

html.theme-dark .algo-compare__control label em {
  color: var(--primary-light);
}

html.theme-dark .algo-compare__n-value {
  color: #f1f5f9;
}

html.theme-dark .algo-compare__ratio-wrap {
  background: rgba(239, 74, 52, 0.15);
  border-color: rgba(255, 138, 114, 0.35);
}

html.theme-dark .algo-compare__ratio {
  color: var(--primary-light);
}

html.theme-dark .algo-compare__panel {
  background: #0f172a;
  border-color: #475569;
}

html.theme-dark .algo-compare__panel-name {
  color: #f1f5f9;
}

html.theme-dark .algo-compare__panel-cpx {
  background: rgba(0, 0, 0, 0.25);
  color: #94a3b8;
}

html.theme-dark .algo-compare__panel--seq .algo-compare__panel-val {
  color: #fdba74;
}

html.theme-dark .algo-compare__panel--dic .algo-compare__panel-val {
  color: #ffb199;
}

html.theme-dark .algo-compare__meter {
  background: #334155;
}

html.theme-dark .algo-compare__insight {
  background: rgba(239, 74, 52, 0.15);
  border-color: rgba(255, 138, 114, 0.3);
  color: #e0e7ff;
}

/* Encapsulation TCP/IP */
.page-topic .cheatsheet-content .tcp-encap-block__title {
  margin: 1.25rem 0 0.4rem;
  padding: 0;
  border: none;
  background: none;
  box-shadow: none;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-dark, #0f172a);
}

.page-topic .cheatsheet-content .tcp-encap-block__lead {
  margin: 0 0 0.85rem;
  font-size: 0.9rem;
  color: var(--text-light, #64748b);
  line-height: 1.5;
}

.tcp-encap-demo {
  padding: 1.1rem 1.15rem 1rem;
  border-radius: 14px;
  background: linear-gradient(160deg, #f8fafc 0%, #eef2ff 100%);
  border: 1px solid #ffb199;
  box-shadow: 0 4px 18px rgba(239, 74, 52, 0.08);
}

.tcp-encap-stack {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.tcp-encap-step {
  opacity: 0.55;
  transition: opacity 0.4s ease;
}

.tcp-encap-step.is-active {
  opacity: 1;
}

.tcp-encap-step__meta {
  margin-bottom: 0.35rem;
}

.tcp-encap-step__name {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-dark, #1e293b);
}

.tcp-encap-step.is-active .tcp-encap-step__name {
  color: var(--primary-dark, #ef4a34);
}

.tcp-encap-rail {
  width: 100%;
  height: 2rem;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.06);
  display: flex;
  align-items: center;
  padding: 0 0.15rem;
}

.tcp-encap-bar {
  display: flex;
  align-items: stretch;
  height: 1.5rem;
  width: var(--bar-w, 45%);
  min-width: 4.5rem;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
  transition: width 0.5s cubic-bezier(0.33, 1, 0.68, 1), box-shadow 0.35s ease;
}

.tcp-encap-step.is-active .tcp-encap-bar {
  box-shadow: 0 0 0 2px rgba(239, 74, 52, 0.45), 0 4px 14px rgba(239, 74, 52, 0.2);
}

.tcp-encap-part {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.tcp-encap-part--payload {
  flex: 1;
  min-width: 2rem;
  background: linear-gradient(90deg, #64748b, #94a3b8);
}

.tcp-encap-step--app .tcp-encap-part--payload {
  background: linear-gradient(90deg, #c93620, #ef4a34);
}

.tcp-encap-step--app.is-active .tcp-encap-bar {
  box-shadow: 0 0 0 2px rgba(239, 74, 52, 0.5), 0 4px 16px rgba(239, 74, 52, 0.25);
}

.tcp-encap-part--tcp {
  width: 2.25rem;
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
}

.tcp-encap-part--ip {
  width: 2rem;
  background: linear-gradient(180deg, #10b981, #047857);
}

.tcp-encap-part--eth {
  width: 2.35rem;
  background: linear-gradient(180deg, #fbbf24, #b45309);
}

.tcp-encap-connector {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-light, #64748b);
  padding: 0.15rem 0;
  line-height: 1.3;
}

.tcp-encap-foot {
  margin: 0.65rem 0 0;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light, #64748b);
}

html.theme-dark .page-topic .cheatsheet-content .tcp-encap-block__title {
  color: #f1f5f9;
}

html.theme-dark .page-topic .cheatsheet-content .tcp-encap-block__lead {
  color: #94a3b8;
}

html.theme-dark .tcp-encap-demo {
  background: linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
  border-color: #475569;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

html.theme-dark .tcp-encap-step__name {
  color: #cbd5e1;
}

html.theme-dark .tcp-encap-step.is-active .tcp-encap-step__name {
  color: #ffb199;
}

html.theme-dark .tcp-encap-rail {
  background: rgba(0, 0, 0, 0.25);
}

html.theme-dark .tcp-encap-connector,
html.theme-dark .tcp-encap-foot {
  color: #94a3b8;
}

html.theme-dark .tcp-encap-part--payload {
  background: linear-gradient(90deg, #475569, #64748b);
}

html.theme-dark .tcp-encap-step--app .tcp-encap-part--payload {
  background: linear-gradient(90deg, #c93620, #ef4a34);
}

html.theme-dark .mini-quiz {
  background: #1e293b;
  border-color: #334155;
}

html.theme-dark .mini-quiz__title {
  color: #f1f5f9;
}

html.theme-dark .mini-quiz__q {
  color: #e2e8f0;
}

html.theme-dark .mini-quiz__opt {
  background: #0f172a;
  border-color: #475569;
  color: #e2e8f0;
}

/* Visualiseur recherche (liste + cible) */
.search-viz {
  max-width: 52rem;
  margin: 0 auto 1.5rem;
  padding: 1.2rem 1.25rem;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--border, #e2e8f0);
  box-shadow: var(--shadow-md, 0 4px 20px rgba(15, 23, 42, 0.06));
}

.search-viz__setup {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
  align-items: end;
  margin-bottom: 1rem;
}

.search-viz__setup .search-viz__btn--secondary {
  grid-column: 1 / -1;
  justify-self: start;
}

.search-viz__target-input {
  width: 100%;
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border, #e2e8f0);
  font-family: inherit;
  font-weight: 600;
}

.search-viz__absent {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-light, #64748b);
  cursor: pointer;
  grid-column: 1 / -1;
}

.search-viz__field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-light, #64748b);
  margin-bottom: 0.35rem;
}

.search-viz__field--n,
.search-viz__field--speed {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: var(--light-bg, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
}

.search-viz__field--speed {
  margin-bottom: 0.85rem;
}

.search-viz__field--n label,
.search-viz__field--speed label {
  margin-bottom: 0;
  color: var(--text-dark, #334155);
}

.search-viz__field-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.search-viz__n-value,
.search-viz__speed-value {
  font-variant-numeric: tabular-nums;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary-dark, #ef4a34);
  line-height: 1.2;
  white-space: nowrap;
}

.search-viz__speed-value {
  font-size: 1.1rem;
}

.search-viz__field input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 8px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.search-viz__field input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: #cbd5e1;
}

.search-viz__field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--primary, #ef4a34);
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
}

.search-viz__field input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: #cbd5e1;
}

.search-viz__field input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--primary, #ef4a34);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
}

.search-viz__ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 0.45rem;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-light, #64748b);
}

.search-viz__list-meta {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-light, #64748b);
}

.search-viz__result {
  margin: 0 0 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.45;
}

.search-viz__result[hidden] {
  display: none !important;
}

.search-viz__result--found {
  background: rgba(34, 197, 94, 0.12);
  border: 2px solid #16a34a;
  color: #166534;
}

.search-viz__result--miss {
  background: rgba(239, 68, 68, 0.08);
  border: 2px solid #f87171;
  color: #991b1b;
}

.search-viz__field select {
  width: 100%;
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border, #e2e8f0);
  font-family: inherit;
  font-weight: 600;
}

.search-viz__modes {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-viz__mode {
  flex: 1;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 2px solid var(--border, #e2e8f0);
  background: var(--light-bg, #f8fafc);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-dark, #334155);
}

.search-viz__mode.is-active {
  border-color: var(--primary, #ef4a34);
  background: rgba(239, 74, 52, 0.1);
  color: var(--primary-dark, #ef4a34);
}

.search-viz__board-wrap {
  margin-bottom: 0.75rem;
  overflow: visible;
}

.search-viz__board {
  width: 100%;
}

.search-viz__indices {
  display: none !important;
}

.search-viz__grid {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  contain: layout style;
}

.search-viz--grid20 .search-viz__indices,
.search-viz--grid20 .search-viz__grid {
  display: grid;
  grid-template-columns: repeat(20, minmax(2rem, 1fr));
  gap: 0.3rem;
}

.search-viz--grid20 .search-viz__indices {
  margin-bottom: 0.35rem;
}

.search-viz--grid20 .search-viz-idx {
  min-width: 0;
}

.search-viz--running .search-viz-cell {
  transition: none !important;
}

.search-viz--grid20 .search-viz-cell {
  min-width: 0;
  max-width: none;
  padding: 0.45rem 0.15rem;
}

.search-viz--grid20 .search-viz-cell__val {
  font-size: 0.78rem;
}

@media (max-width: 520px) {
  .search-viz--grid20 .search-viz__indices,
  .search-viz--grid20 .search-viz__grid {
    grid-template-columns: repeat(10, minmax(1.65rem, 1fr));
  }
}

.search-viz--finished .search-viz-cell.is-out,
.search-viz--finished .search-viz-cell.is-past {
  opacity: 0.35;
}

.search-viz--finished .search-viz-cell.is-in:not(.is-found) {
  opacity: 0.55;
}

.search-viz--finished .search-viz-cell.is-found {
  opacity: 1;
  transform: scale(1.08);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.45);
  z-index: 1;
  position: relative;
}

.search-viz-cell {
  flex: 0 0 2.5rem;
  min-height: 2.35rem;
  padding: 0.5rem 0.2rem;
  border-radius: 8px;
  text-align: center;
  background: #fff;
  border: 1.5px solid #94a3b8;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  contain: layout style paint;
  transition: background 0.15s, border-color 0.15s, opacity 0.2s, transform 0.2s;
}

.search-viz-cell__val {
  font-size: 0.9rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
}

.search-viz-cell.is-past {
  background: #cbd5e1;
  opacity: 0.85;
}

.search-viz-cell.is-current {
  background: #fef08a;
  border-color: #eab308;
  box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.35);
}

.search-viz-cell.is-found {
  background: #86efac;
  border-color: #16a34a;
}

.search-viz-cell.is-out {
  opacity: 0.28;
  background: #f1f5f9;
}

.search-viz-cell.is-in {
  background: #e0e7ff;
}

.search-viz-cell.is-mid {
  background: #ffb199;
  border-color: #ef4a34;
  box-shadow: 0 0 0 2px rgba(239, 74, 52, 0.4);
}

.search-viz__status {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  color: var(--text-dark, #334155);
  line-height: 1.5;
}

.search-viz__stats {
  margin: 0 0 0.85rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary-dark, #ef4a34);
}

.search-viz__hint {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  color: var(--text-light, #64748b);
}

.search-viz__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.search-viz__btn {
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  border: none;
  background: var(--primary, #ef4a34);
  color: #fff;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.search-viz__btn--secondary {
  background: var(--light-bg, #f1f5f9);
  color: var(--text-dark, #334155);
  border: 1px solid var(--border, #e2e8f0);
}

.search-viz__btn--ghost {
  background: transparent;
  color: var(--text-light, #64748b);
  border: 1px dashed var(--border, #cbd5e1);
  width: 100%;
}

.search-viz__btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Arbre OS */
.os-tree-block {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border, #e2e8f0);
}

.os-tree-block__title {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 800;
}

.os-tree-block__lead {
  margin: 0 0 0.65rem;
  font-size: 0.85rem;
  color: var(--text-light, #64748b);
  line-height: 1.45;
}

.os-tree-path-line {
  margin: 0 0 0.65rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.os-tree-demo {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: var(--light-bg, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  max-width: 22rem;
}

.os-tree-toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.os-tree-cmd {
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: 2px solid #ef4a34;
  background: #ef4a34;
  color: #fff;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(239, 74, 52, 0.35);
}

.os-tree-cmd:hover {
  background: #ef4a34;
  filter: brightness(1.05);
}

.os-tree-root,
.os-tree-children {
  list-style: none;
  margin: 0;
  padding: 0;
}

.os-tree-children {
  padding-left: 1.15rem;
  border-left: 1px dashed #cbd5e1;
  margin-left: 0.35rem;
}

.os-tree-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0.15rem 0;
}

.os-tree-toggle {
  width: 1.4rem;
  height: 1.4rem;
  padding: 0;
  border: 1px solid #94a3b8;
  border-radius: 4px;
  background: #f1f5f9;
  color: #1e293b;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
}

.os-tree-label {
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary-dark, #c93620);
  cursor: pointer;
  padding: 0.15rem 0.25rem;
  border-radius: 4px;
}

.os-tree-label:hover,
.os-tree-label.is-cwd {
  background: rgba(239, 74, 52, 0.15);
}

.os-tree-row--file {
  padding-left: 1.6rem;
  font-size: 0.8rem;
  color: var(--text-light, #64748b);
}

.os-tree-file-icon {
  opacity: 0.5;
}

html.theme-dark .search-viz {
  background: #1e293b;
  border-color: #334155;
}

/* Grille toujours lisible : cases claires, chiffres foncés (pas héritage du thème sombre) */
html.theme-dark .search-viz-cell {
  background: #f8fafc;
  border-color: #64748b;
}

html.theme-dark .search-viz-cell__val {
  color: #0f172a;
}

html.theme-dark .search-viz-cell.is-past {
  background: #e2e8f0;
  border-color: #94a3b8;
  opacity: 1;
}

html.theme-dark .search-viz-cell.is-past .search-viz-cell__val {
  color: #475569;
}

html.theme-dark .search-viz-cell.is-current {
  background: #fef08a;
  border-color: #ca8a04;
}

html.theme-dark .search-viz-cell.is-current .search-viz-cell__val {
  color: #713f12;
}

html.theme-dark .search-viz-cell.is-found {
  background: #86efac;
  border-color: #16a34a;
}

html.theme-dark .search-viz-cell.is-found .search-viz-cell__val {
  color: #14532d;
}

html.theme-dark .search-viz-cell.is-out {
  background: #e2e8f0;
  opacity: 0.45;
}

html.theme-dark .search-viz-cell.is-out .search-viz-cell__val {
  color: #64748b;
}

html.theme-dark .search-viz-cell.is-in {
  background: #e0e7ff;
  border-color: #ff8a72;
}

html.theme-dark .search-viz-cell.is-in .search-viz-cell__val {
  color: #8a4308;
}

html.theme-dark .search-viz-cell.is-mid {
  background: #ffb199;
  border-color: #ef4a34;
}

html.theme-dark .search-viz-cell.is-mid .search-viz-cell__val {
  color: #1e1b4b;
}

html.theme-dark .search-viz__list-meta,
html.theme-dark .search-viz__status {
  color: #e2e8f0;
}

html.theme-dark .search-viz__field--n,
html.theme-dark .search-viz__field--speed {
  background: #0f172a;
  border-color: #475569;
}

html.theme-dark .search-viz__field--n label,
html.theme-dark .search-viz__field--speed label {
  color: #e2e8f0;
}

html.theme-dark .search-viz__n-value,
html.theme-dark .search-viz__speed-value {
  color: #ffb199;
}

html.theme-dark .search-viz__ticks {
  color: #94a3b8;
}

html.theme-dark .search-viz__field input[type="range"]::-webkit-slider-runnable-track {
  background: #475569;
}

html.theme-dark .search-viz__field input[type="range"]::-moz-range-track {
  background: #475569;
}

html.theme-dark .search-viz__field input[type="range"]::-webkit-slider-thumb {
  border-color: #1e293b;
}

html.theme-dark .search-viz__field input[type="range"]::-moz-range-thumb {
  border-color: #1e293b;
}

html.theme-dark .search-viz-mode,
html.theme-dark .search-viz__field select {
  background: #0f172a;
  border-color: #475569;
  color: #e2e8f0;
}

html.theme-dark .os-tree-demo {
  background: #0f172a;
  border-color: #475569;
}

html.theme-dark .os-tree-cmd {
  background: #ef4a34;
  border-color: #ffb199;
  color: #fff;
  box-shadow: 0 2px 12px rgba(239, 74, 52, 0.45);
}

html.theme-dark .os-tree-toggle {
  background: #475569;
  border-color: #94a3b8;
  color: #f8fafc;
}

html.theme-dark .search-viz__result--found {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

html.theme-dark .search-viz__result--miss {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}

html.theme-dark .search-viz__target-input {
  background: #0f172a;
  border-color: #475569;
  color: #f1f5f9;
}

@media (max-width: 560px) {
  .algo-compare__viz {
    grid-template-columns: 1fr;
  }

  .algo-compare__panel-val {
    font-size: 1.45rem;
  }

  .search-viz__setup {
    grid-template-columns: 1fr;
  }

}
