/* Otoolia — Calculatrice graphique */
.cx { --cx-r: 14px; }
.cx-top { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cx-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.cx-tabs button { font: inherit; font-weight: 600; font-size: .95rem; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--ot-border); background: var(--ot-surface); color: var(--ot-text); cursor: pointer; }
.cx-tabs button[aria-selected="true"] { background: var(--ot-text); color: var(--ot-bg); border-color: var(--ot-text); }
.cx-set { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .85rem; }
.cx-dig { display: inline-flex; gap: 6px; align-items: center; color: var(--ot-text-soft); font-weight: 600; } .cx-dig .ot-select { width: auto; padding: 5px 8px; }
.cx-view { background: var(--ot-surface); border: 1px solid var(--ot-border); border-radius: var(--ot-radius-l); padding: 14px; box-shadow: var(--ot-shadow); }
/* Calculs */
.cx-calc { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 980px) { .cx-calc { grid-template-columns: minmax(0, 1fr) 260px; } .cx-histwrap, .cx-entry, .cx-err, .cx-keys { grid-column: 1; } .cx-side { grid-column: 2; grid-row: 1 / span 5; } }
.cx-histwrap { min-height: 220px; max-height: 52vh; overflow-y: auto; border: 1px solid var(--ot-border); border-radius: var(--cx-r); background: var(--ot-surface-2); padding: 6px 10px; }
.cx-hist { list-style: none; margin: 0; padding: 0; }
.cx-h { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 16px; padding: 8px 2px; border-bottom: 1px solid var(--ot-border); }
.cx-h:last-child { border-bottom: 0; }
.cx-hin, .cx-hout { font: inherit; border: 0; background: none; color: var(--ot-text); cursor: pointer; padding: 4px 6px; border-radius: 8px; font-size: 1.1rem; text-align: left; max-width: 100%; overflow-x: auto; }
.cx-hout { margin-left: auto; font-weight: 600; color: var(--ot-brand); text-align: right; }
.cx-hin:hover, .cx-hout:hover { background: color-mix(in srgb, var(--ot-brand) 10%, transparent); }
.cx-empty { color: var(--ot-text-soft); font-size: .92rem; margin: 40px 10px; text-align: center; }
.cx-entry { display: flex; gap: 8px; align-items: stretch; }
.cx-field { flex: 1; min-width: 0; font-size: 1.35rem; padding: 8px 12px; border: 2px solid var(--ot-brand); border-radius: var(--cx-r); background: var(--ot-surface); color: var(--ot-text);
  --caret-color: var(--ot-brand); --selection-background-color: color-mix(in srgb, var(--ot-brand) 25%, transparent); --placeholder-color: var(--ot-text-soft); --primary: var(--ot-brand); }
.cx-field::part(menu-toggle) { display: none; }
.cx-go { font-size: 1.4rem; min-width: 64px; border-radius: var(--cx-r); }
.cx-err { margin: 0; color: var(--ot-danger); font-weight: 600; font-size: .92rem; }
.cx-keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; }
.cx-keys button { min-height: 44px; border: 1px solid var(--ot-border); border-radius: 10px; background: var(--ot-surface-2); color: var(--ot-text); cursor: pointer; font: inherit; font-size: .95rem; padding: 2px 4px; overflow: hidden; }
.cx-keys button:hover { border-color: var(--ot-brand); background: var(--ot-surface); }
.cx-keys2 { margin-top: -4px; }
.cx-side { display: grid; gap: 10px; align-content: start; }
.cx-box { border: 1px solid var(--ot-border); border-radius: var(--cx-r); padding: 8px 12px; background: var(--ot-surface-2); }
.cx-box summary { cursor: pointer; font-weight: 700; }
.cx-varlist { list-style: none; padding: 0; margin: 6px 0; display: grid; gap: 4px; }
.cx-varlist li { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 4px 6px; background: var(--ot-surface); border-radius: 8px; overflow-x: auto; }
.cx-varlist button { border: 0; background: none; cursor: pointer; color: var(--ot-text-soft); font-size: 1rem; }
/* Fonctions et graphique */
.cx-graphlay { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 980px) { .cx-graphlay { grid-template-columns: 360px minmax(0, 1fr); } }
.cx-funcs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cx-fn { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 6px; align-items: center; padding: 6px 8px; border: 1px solid var(--ot-border); border-left: 4px solid var(--c); border-radius: 10px; background: var(--ot-surface); }
.cx-fvis { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--c); background: transparent; cursor: pointer; padding: 0; }
.cx-fvis.is-on { background: var(--c); }
.cx-fname { font-size: 1.05rem; white-space: nowrap; }
.cx-ffield { font-size: 1.1rem; padding: 4px 6px; border: 1px solid var(--ot-border); border-radius: 8px; background: var(--ot-surface); color: var(--ot-text); min-width: 0; --caret-color: var(--ot-brand); }
.cx-ffield::part(menu-toggle) { display: none; }
.cx-fdel { border: 0; background: none; cursor: pointer; color: var(--ot-text-soft); font-size: 1.2rem; }
.cx-fmeta { grid-column: 1 / -1; font-size: .85rem; color: var(--ot-text-soft); overflow-x: auto; min-height: 1.2em; }
.cx-err2 { color: var(--ot-danger); font-weight: 600; }
.cx-pts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; max-height: 220px; overflow-y: auto; }
.cx-pt { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; padding: 3px 8px; border: 1px solid var(--ot-border); border-radius: 999px; background: var(--ot-surface); font-variant-numeric: tabular-nums; }
.cx-pt i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.cx-gbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.cx-win { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: .85rem; color: var(--ot-text-soft); margin-left: auto; }
.cx-win .ot-input { width: 62px; padding: 4px 6px; font-size: .85rem; min-height: 0; }
.cx-canvasbox { position: relative; border: 1px solid var(--ot-border); border-radius: var(--cx-r); overflow: hidden; touch-action: none; }
#cx-canvas { display: block; width: 100%; cursor: crosshair; }
.cx-tip { position: absolute; pointer-events: none; background: var(--ot-surface); border: 1px solid var(--ot-border); border-radius: 8px; padding: 4px 8px; font-size: .8rem; box-shadow: var(--ot-shadow); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cx-tablewrap { max-height: 60vh; }
#cx-printhost { margin-top: 14px; }
#cx-printhost .ot-panel { margin: 0; }
/* MathLive : clavier virtuel au-dessus de la bannière cookies */
.ML__keyboard { z-index: 1000 !important; }
@media (max-width: 640px) { .cx-tabs button { padding: 8px 12px; font-size: .88rem; } .cx-field { font-size: 1.2rem; } .cx-win { margin-left: 0; } }
.cx-opts { position: relative; }
.cx-opts summary { cursor: pointer; list-style: none; font-weight: 600; padding: 6px 12px; border: 1px solid var(--ot-border); border-radius: 999px; background: var(--ot-surface); }
.cx-opts summary::-webkit-details-marker { display: none; }
.cx-optsbox { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; display: grid; gap: 8px; min-width: 230px; padding: 12px; background: var(--ot-surface); border: 1px solid var(--ot-border); border-radius: 12px; box-shadow: var(--ot-shadow-h, var(--ot-shadow)); }
.cx-optsbox .ot-select { width: 100%; }
.cx-unit { font-size: .7rem; font-weight: 700; color: var(--ot-text-soft); border: 1px solid var(--ot-border); border-radius: 6px; padding: 0 5px; order: -1; }
.cx-dig { display: none; }
.cx-edit { display: flex; gap: 6px; flex-wrap: wrap; margin-top: -4px; }
.cx-edit button { min-width: 48px; min-height: 40px; border: 1px solid var(--ot-border); border-radius: 10px; background: var(--ot-surface); color: var(--ot-text); cursor: pointer; font: inherit; font-size: 1.05rem; }
.cx-edit button:hover { border-color: var(--ot-brand); }
.cx-edit .cx-ac { margin-left: auto; color: var(--ot-danger); font-weight: 800; font-size: .9rem; }
@media (min-width: 980px) { .cx-edit { grid-column: 1; } }
/* Tableau de valeurs : colonnes resserrées, choix des colonnes */
#cx-table { width: auto; min-width: 280px; }
#cx-table th, #cx-table td { padding: 5px 18px 5px 10px; }
#cx-table th { white-space: nowrap; }
.cx-tcols { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 8px; }
.cx-tlab { font-size: .85rem; font-weight: 600; color: var(--ot-text-soft); }
.cx-tchip { font: inherit; font-size: .95rem; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--ot-border); background: var(--ot-surface); color: var(--ot-text); cursor: pointer; margin: 0 4px 4px 0; }
.cx-tchip.is-on { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, var(--ot-surface)); box-shadow: inset 0 0 0 1px var(--c); }
.cx-tcust { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.cx-tcustlist { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.cx-tcustlist:empty { display: none; }
.cx-tcustlist li { display: flex; align-items: center; gap: 4px; min-width: 220px; flex: 0 1 320px; }
.cx-tcustlist .cx-ffield { flex: 1; }
/* Version 2 : onglets nombreux, actions sur les résultats */
.cx-tabs { flex-wrap: wrap; max-width: 100%; }
.cx-tabs button { white-space: nowrap; flex: none; padding: 8px 13px; font-size: .92rem; }
@media (max-width: 640px) { .cx-tabs { gap: 5px; } .cx-tabs button { padding: 6px 10px; font-size: .84rem; } }
.cx-top { flex-wrap: wrap; }
.cx-top > .cx-tabs { flex: 1 1 100%; }
.cx-acts { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 8px; vertical-align: middle; }
.cx-acts button { font: inherit; font-size: .74rem; font-weight: 600; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--ot-border); background: var(--ot-surface); color: var(--ot-text-soft); cursor: pointer; }
.cx-acts button:hover { border-color: var(--ot-brand); color: var(--ot-brand); }
.cx-tag { color: var(--ot-brand); border-color: color-mix(in srgb, var(--ot-brand) 40%, var(--ot-border)); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-res { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 10px; border: 1px solid var(--ot-border); border-radius: 10px; background: var(--ot-surface-2); margin: 6px 0; }
.cx-res .cx-rv { font-size: 1.15rem; }
.cx-mod h3 { font-size: 1rem; margin: 14px 0 6px; }
.cx-mod .sp-f .ot-input { width: 120px; }
.cx-seg { margin-bottom: 10px; }
.cx-mini { width: 100%; display: block; border: 1px solid var(--ot-border); border-radius: 12px; background: var(--ot-surface); }
.cx-two { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 980px) { .cx-two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
/* Équations */
.eq-grid { display: grid; gap: 6px; margin: 8px 0; overflow-x: auto; }
.eq-row { display: flex; align-items: center; gap: 4px; flex-wrap: nowrap; }
.eq-row .ot-input { width: 70px; padding: 6px 8px; text-align: right; }
.eq-var { font-style: italic; font-family: "KaTeX_Math", serif; font-size: 1.1rem; margin-right: 4px; }
.eq-op { color: var(--ot-text-soft); font-weight: 700; padding: 0 2px; }
/* Suites */
.sq-item { display: flex; flex-wrap: wrap; }
.sq-item .cx-ffield { flex: 1 1 200px; }
.sq-item .cx-fdel { margin-left: auto; }
.sq-type, .sq-name, .sq-t { width: auto; flex: 0 0 auto; padding: 4px 6px; font-size: .85rem; }
.sq-name { font-weight: 700; color: var(--c); }
.sq-item .cx-fmeta { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 12px; }
.sq-init { display: contents; }
.sq-init .sp-note { align-self: center; }
.sq-py { font-family: var(--ot-mono); font-size: .88rem; background: var(--ot-surface); border: 1px solid var(--ot-border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; margin: 8px 0 0; }
/* Statistiques */
.st-gridwrap { max-height: 420px; overflow: auto; border: 1px solid var(--ot-border); border-radius: 10px; }
.st-grid { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.st-grid th { position: sticky; top: 0; background: var(--ot-surface-2); font-size: .8rem; padding: 4px; border-bottom: 1px solid var(--ot-border); z-index: 1; }
.st-grid td { border-bottom: 1px solid var(--ot-border); padding: 0; }
.st-grid td:first-child { font-size: .72rem; color: var(--ot-text-soft); text-align: center; width: 30px; background: var(--ot-surface-2); }
.st-c { width: 100%; min-width: 60px; border: 0; background: transparent; padding: 6px 8px; font: inherit; font-size: .9rem; color: var(--ot-text); text-align: right; }
.st-c:focus { outline: 2px solid var(--ot-brand); outline-offset: -2px; background: var(--ot-surface); }
.st-sum { display: grid; gap: 4px; }
.st-sum .cx-res { margin: 0; padding: 4px 8px; }
.st-lab { font-size: .8rem; color: var(--ot-text-soft); min-width: 140px; }
#cx-v-prob .sp-main { margin: 0; }
/* Probabilités : résultat principal */
.pb-big { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 10px 0 6px; }
.pb-big small { flex-basis: 100%; font-size: .9rem; color: var(--ot-text-soft); }
.pb-big b { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.pb-big span { color: var(--ot-text-soft); }
.pb-res .cx-acts { margin-top: 6px; }
/* ---------- Python ---------- */
.py-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.py-sp { flex: 1; }
.py-namef { display: inline-flex; align-items: center; gap: 2px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.py-namef input { width: 150px; font-family: inherit; }
.py-namef span { color: var(--ot-text-soft); }
.py-bar .ot-select { width: auto; max-width: 210px; }
.py-menu .cx-optsbox { display: flex; flex-direction: column; gap: 2px; min-width: 250px; right: 0; left: auto; }
.py-menu .cx-optsbox button { text-align: left; background: none; border: 0; padding: 7px 10px; border-radius: 8px; color: var(--ot-text); font: inherit; cursor: pointer; }
.py-menu .cx-optsbox button:hover:not(:disabled) { background: var(--ot-surface-2); }
.py-menu .cx-optsbox button:disabled { opacity: .45; cursor: default; }
.py-menu .cx-optsbox .sp-ck { padding: 2px 10px 6px 26px; font-size: .85rem; }
.py-menu .cx-optsbox .sp-note { max-width: 300px; padding: 4px 10px 0; margin: 0; }
.py-danger { color: var(--ot-danger) !important; }
.py-viewer { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; margin-bottom: 10px; border-radius: 10px; background: var(--ot-surface-2); border: 1px solid var(--ot-border); }
.py-viewer #py-vtitle { font-weight: 600; flex: 1 1 260px; }
.py-viewer .is-on { border-color: var(--ot-brand); }
.py-main { display: grid; grid-template-columns: 170px minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.py-side h3 { margin: 0 0 6px; font-size: 1rem; }
.py-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 420px; overflow: auto; }
.py-file { width: 100%; text-align: left; border: 1px solid transparent; background: none; padding: 6px 8px; border-radius: 8px; font: .92rem ui-monospace, Menlo, Consolas, monospace; color: var(--ot-text); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.py-file small { color: var(--ot-text-soft); }
.py-file:hover { background: var(--ot-surface-2); }
.py-file.is-on { background: var(--ot-surface-2); border-color: var(--ot-brand); font-weight: 700; }
.py-ed { border: 1px solid var(--ot-border); border-radius: 10px; overflow: hidden; background: var(--ot-surface); min-height: 360px; }
.py-ed.is-drop { outline: 3px dashed var(--ot-brand); }
.py-ed .cm-editor { min-height: 360px; max-height: 70vh; font-size: 14px; }
.py-ed .cm-scroller { font-family: ui-monospace, Menlo, Consolas, "DejaVu Sans Mono", monospace; }
.py-ed .cm-editor.cm-focused { outline: none; }
.py-ed .cm-gutters { background: var(--ot-surface-2); color: var(--ot-text-soft); border-right: 1px solid var(--ot-border); }
.py-ed .cm-activeLine, .py-ed .cm-activeLineGutter { background: color-mix(in srgb, var(--ot-brand) 7%, transparent); }
.py-ed .cm-content { caret-color: var(--ot-text); color: var(--ot-text); }
.py-ed .cm-cursor { border-left-color: var(--ot-text); }
.py-ed .cm-selectionBackground, .py-ed .cm-focused .cm-selectionBackground { background: color-mix(in srgb, var(--ot-brand) 25%, transparent) !important; }
.py-ed .cm-tooltip { background: var(--ot-surface); border: 1px solid var(--ot-border); color: var(--ot-text); }
.py-ed .cm-tooltip-autocomplete ul li[aria-selected] { background: var(--ot-brand); color: #fff; }
.py-ed .tok-keyword { color: #a626a4; font-weight: 600; }
.py-ed .tok-string, .py-ed .tok-string2 { color: #2e7d32; }
.py-ed .tok-number, .py-ed .tok-bool, .py-ed .tok-atom { color: #c45500; }
.py-ed .tok-comment { color: #7a7f87; font-style: italic; }
.py-ed .tok-variableName.tok-definition, .py-ed .tok-propertyName.tok-definition { color: #1a5fd0; }
.py-ed .tok-className, .py-ed .tok-typeName { color: #b26b00; }
.py-ed .tok-operator, .py-ed .tok-punctuation { color: var(--ot-text-soft); }
[data-theme="dark"] .py-ed .tok-keyword { color: #d38cf0; }
[data-theme="dark"] .py-ed .tok-string, [data-theme="dark"] .py-ed .tok-string2 { color: #8fd18f; }
[data-theme="dark"] .py-ed .tok-number, [data-theme="dark"] .py-ed .tok-bool, [data-theme="dark"] .py-ed .tok-atom { color: #f5a65b; }
[data-theme="dark"] .py-ed .tok-comment { color: #8b95a3; }
[data-theme="dark"] .py-ed .tok-variableName.tok-definition { color: #7fb2ff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .py-ed .tok-keyword { color: #d38cf0; }
  :root:not([data-theme="light"]) .py-ed .tok-string { color: #8fd18f; }
  :root:not([data-theme="light"]) .py-ed .tok-number, :root:not([data-theme="light"]) .py-ed .tok-bool { color: #f5a65b; }
  :root:not([data-theme="light"]) .py-ed .tok-comment { color: #8b95a3; }
  :root:not([data-theme="light"]) .py-ed .tok-variableName.tok-definition { color: #7fb2ff; }
}
.py-hint { margin: 4px 2px 0; }
.py-screenbox { margin-bottom: 10px; }
.py-screen { position: relative; width: 100%; max-width: 640px; aspect-ratio: 320 / 222; border: 1px solid var(--ot-border); border-radius: 8px; overflow: hidden; background: #fff; }
.py-screen:focus { outline: 2px solid var(--ot-brand); }
.py-screen canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.py-pad { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 8px; }
.py-pad button { padding: 10px 0; border-radius: 10px; border: 1px solid var(--ot-border); background: var(--ot-surface-2); color: var(--ot-text); font-size: 1rem; touch-action: none; user-select: none; -webkit-user-select: none; }
.py-pad button:active { background: var(--ot-brand); color: #fff; }
.py-conhead { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.py-conhead b { flex: 1; }
.py-console { background: #10151d; color: #e6edf3; border-radius: 10px; padding: 10px 12px; min-height: 160px; max-height: 380px; overflow: auto; font: 13.5px/1.45 ui-monospace, Menlo, Consolas, "DejaVu Sans Mono", monospace; }
.py-console pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: inherit; }
.py-err { color: #ff8f8f; }
.py-sep { color: #7fb2ff; }
.py-inrow { display: flex; align-items: center; gap: 6px; }
.py-ps { color: #7fb2ff; }
.py-cin { flex: 1; min-width: 0; background: transparent; border: 0; border-bottom: 1px dashed #7fb2ff; color: #fff; font: inherit; padding: 2px 0; outline: none; }
.py-cin::placeholder { color: #7f8b99; }
.py-errline { margin-top: 6px; border: 0; background: none; color: var(--ot-danger); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
@media (max-width: 1100px) { .py-main { grid-template-columns: 150px minmax(0, 1fr); } .py-runcol { grid-column: 1 / -1; } }
@media (max-width: 700px) {
  .py-main { grid-template-columns: minmax(0, 1fr); }
  .py-side { order: 3; } .py-list { flex-direction: row; flex-wrap: wrap; } .py-file { width: auto; }
  .py-ed, .py-ed .cm-editor { min-height: 260px; }
  .py-namef input { width: 110px; }
}
#sp-printdoc .pd-code { font: 10pt/1.4 ui-monospace, Menlo, Consolas, "DejaVu Sans Mono", monospace; white-space: pre-wrap; margin: 0; }
#sp-printdoc .pd-ln { display: inline-block; width: 2.6em; color: #888; text-align: right; margin-right: 1em; user-select: none; }
#sp-printdoc .pd-screen { width: 320px; image-rendering: pixelated; border: 1px solid #ccc; }
