/* playground.css - editor de Python a pantalla completa (/playground). Usa las variables --c-* de course.css. */
html:has(body.pg-body), .pg-body { height: 100%; }
.pg-body { margin: 0; overflow: hidden; background: var(--c-panel); color: var(--c-text); }
.pg { height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: var(--c-panel); }

/* ---- barra superior ---- */
.pg-bar { flex: 0 0 auto; display: flex; align-items: center; gap: 1rem; padding: 1rem; box-sizing: border-box; border-bottom: 1px solid var(--c-border); background: var(--c-panel); }
.pg-brand { white-space: nowrap; flex: 0 0 auto; }
.pg-title-wrap { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; padding-left: .9rem; border-left: 1px solid var(--c-border); }
.pg-kicker { font-size: .72rem; color: var(--c-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-title { margin: 0; font-size: 1rem; font-weight: 700; color: var(--c-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-bar > .pg-title { padding-left: .9rem; border-left: 1px solid var(--c-border); }
.pg-bar-right { margin-left: auto; display: flex; align-items: center; gap: .4rem; }
.pg-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--c-text); cursor: pointer; }
.pg-icon-btn:hover { background: color-mix(in srgb, var(--c-text) 8%, transparent); }
.pg-icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- zona principal ---- */
.pg-main { flex: 1 1 auto; display: flex; min-height: 0; }
.pg-left { flex: 0 0 auto; width: 40%; min-width: 260px; display: flex; flex-direction: column; min-height: 0; background: var(--c-panel); }
.pg-left-scroll { flex: 1; overflow: auto; padding: 1rem 1.1rem 4rem; }
.pg-left .exercise-hero-meta { margin-bottom: .4rem; }
.pg-h { font-size: 1rem; margin: .5rem 0 .4rem; }
.pg-help { margin: 1rem 0 .5rem; }
.pg-left .solution-box { margin-top: .75rem; }
.pg-right { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; min-height: 0; position: relative; }

/* ---- separadores ---- */
.pg-gutter { flex: 0 0 auto; background: var(--c-border); position: relative; touch-action: none; }
.pg-gutter::after { content: ''; position: absolute; inset: 0; background: var(--c-primary); opacity: 0; transition: opacity .12s; }
.pg-gutter:hover::after, .pg-gutter:focus-visible::after, .pg-gutter.is-drag::after { opacity: .55; }
.pg-gutter:focus-visible { outline: none; }
.pg-gutter-v { width: 5px; cursor: col-resize; }
.pg-gutter-h { height: 5px; cursor: row-resize; }
.pg-gutter-v::before, .pg-gutter-h::before { content: ''; position: absolute; z-index: 2; }
.pg-gutter-v::before { inset: 0 -4px; }
.pg-gutter-h::before { inset: -4px 0; }
.pg-dragging, .pg-dragging * { cursor: inherit; user-select: none; }

/* ---- editor ---- */
.pg-editor { flex: 1 1 0; min-height: 90px; position: relative; }
.pg-editor .CodeMirror { position: absolute; inset: 0; height: auto !important; width: auto !important; font: 14px/1.55 'Fira Code', ui-monospace, monospace; background: var(--c-panel); color: var(--c-text); }
.pg-editor .CodeMirror-gutters { background: var(--c-panel); border-right: 1px solid var(--c-border); }
.pg-editor textarea#runner-code { position: absolute; inset: 0; width: 100%; height: 100%; box-sizing: border-box; padding: .8rem; border: 0; resize: none; background: var(--c-panel); color: var(--c-text); font: 14px/1.55 'Fira Code', ui-monospace, monospace; tab-size: 4; }
.pg-editor .CodeMirror-lines { padding-bottom: 24px; }
.pg-editor .CodeMirror-cursor { border-left-color: var(--c-text); }
[data-theme="dark"] .pg-editor .CodeMirror-linenumber { color: #7b8494; }
[data-theme="dark"] .pg-editor .cm-keyword { color: #c792ea; }
[data-theme="dark"] .pg-editor .cm-builtin { color: #82aaff; }
[data-theme="dark"] .pg-editor .cm-string, [data-theme="dark"] .pg-editor .cm-string-2 { color: #c3e88d; }
[data-theme="dark"] .pg-editor .cm-number { color: #f78c6c; }
[data-theme="dark"] .pg-editor .cm-comment { color: #7f8aa3; }
[data-theme="dark"] .pg-editor .cm-def { color: #82aaff; }
[data-theme="dark"] .pg-editor .cm-variable-2, [data-theme="dark"] .pg-editor .cm-variable-3 { color: #ffcb6b; }
[data-theme="dark"] .pg-editor .cm-operator, [data-theme="dark"] .pg-editor .cm-meta { color: #89ddff; }
[data-theme="dark"] .pg-editor .CodeMirror-selected { background: rgba(120, 140, 200, .3); }

/* ---- barra de herramientas del editor ---- */
.pg-toolbar { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .5rem .9rem; border-bottom: 1px solid var(--c-border); background: color-mix(in srgb, var(--c-text) 3%, var(--c-panel)); }
.pg-file { display: inline-flex; align-items: center; gap: .45rem; padding: .3rem .75rem; border: 1px solid var(--c-border); border-radius: 8px; background: var(--c-panel); color: var(--c-text); font: 600 .8rem 'Fira Code', ui-monospace, monospace; white-space: nowrap; }
.pg-file svg { color: var(--c-primary); }
.pg-fab { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; justify-content: flex-end; }
.pg-fab [hidden] { display: none !important; }
.pg-fab-btn { height: 34px; box-sizing: border-box; display: inline-flex; align-items: center; gap: .45rem; padding: 0 .95rem; border: 1px solid transparent; border-radius: 8px; font-family: inherit; font-weight: 600; font-size: .85rem; line-height: 1; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, color .12s; }
.pg-fab-btn:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.pg-fab-btn:disabled { opacity: .5; cursor: not-allowed; }
.pg-fab-run { background: var(--c-primary); color: #fff; }
.pg-fab-run:hover:not(:disabled) { background: var(--c-primary-dark); }
.pg-fab-submit { background: #16a34a; color: #fff; }
.pg-fab-submit:hover:not(:disabled) { background: #15803d; }
.pg-fab-test { background: var(--c-panel); color: var(--c-text); border-color: var(--c-border); }
.pg-fab-test:hover:not(:disabled) { border-color: #16a34a; color: #16a34a; }
.pg-fab-stop { background: color-mix(in srgb, #dc2626 10%, var(--c-panel)); color: #dc2626; border-color: color-mix(in srgb, #dc2626 35%, var(--c-border)); }
.pg-fab-stop:hover:not(:disabled) { background: color-mix(in srgb, #dc2626 18%, var(--c-panel)); }
.pg-fab-sec { background: transparent; color: var(--c-muted); }
.pg-fab-sec:hover:not(:disabled) { background: color-mix(in srgb, var(--c-text) 8%, transparent); color: var(--c-text); }
html[data-theme="dark"] .pg-fab-stop { color: #f87171; }

/* ---- consola ---- */
.pg-console { flex: 0 0 auto; height: 34%; min-height: 90px; display: flex; flex-direction: column; background: var(--c-panel); }
.pg-tabs { flex: 0 0 auto; display: flex; align-items: center; gap: .15rem; padding: 0 .6rem; border-bottom: 1px solid var(--c-border); }
.pg-tab { padding: .5rem .85rem; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--c-muted); font-family: inherit; font-weight: 600; font-size: .85rem; line-height: 1; cursor: pointer; }
.pg-tab.is-attn::after { content: ''; display: inline-block; width: 7px; height: 7px; margin-left: .4rem; border-radius: 50%; background: #d97706; vertical-align: middle; }
.pg-tab:hover { color: var(--c-text); }
.pg-tab.is-active { color: var(--c-text); border-bottom-color: var(--c-primary); }
.pg-status { margin-left: auto; font-size: .8rem; color: var(--c-muted); }
.pg-tip { font-size: .75rem; color: var(--c-muted); margin-left: .9rem; white-space: nowrap; }
.pg-pane { display: none; flex: 1 1 0; min-height: 0; overflow: auto; flex-direction: column; }
.pg-pane.is-active { display: flex; }
.pg-pane .runner-output, .pg-pane textarea { flex: 1; width: 100%; box-sizing: border-box; min-height: 0; margin: 0; padding: .6rem .9rem; border: 0; background: transparent; color: var(--c-text); font: 13px/1.5 'Fira Code', ui-monospace, monospace; white-space: pre-wrap; overflow-wrap: anywhere; resize: none; overflow: auto; }
.pg-pane textarea:focus { outline: none; }
.pg-pane .runner-output.is-error { color: #dc2626; }
.pg-pane-label { padding: .5rem .9rem 0; font-size: .78rem; color: var(--c-muted); }
.pg-pane-note { margin: 0; padding: .5rem .9rem 0; font-size: .78rem; color: var(--c-muted); }
.pg-pane .runner-tests, .pg-pane .runner-submit-msg, .pg-pane .runner-history { border-top: 0; }
.pg-pane .runner-submit-msg { padding: .5rem .9rem; }

/* ---- movil ---- */
.pg-mobile-tabs { display: none; }
@media (max-width: 860px) {
  .pg-bar { gap: .5rem; padding: 0 .6rem; }
  .pg-brand .logo-text, .pg-tip { display: none; }
  .pg-bar > .pg-title, .pg-title-wrap { padding-left: 0; border-left: 0; }
  .pg-main { flex-direction: column; }
  .pg-gutter-v { display: none; }
  .pg-left { width: 100% !important; flex: 1 1 0; }
  .pg-right { flex: 1 1 0; }
  .pg[data-view="code"] .pg-left { display: none; }
  .pg[data-view="statement"] .pg-right { display: none; }
  .pg-mobile-tabs { display: flex; flex: 0 0 auto; border-top: 1px solid var(--c-border); background: var(--c-panel); }
  .pg-mobile-tabs button { flex: 1; padding: .75rem; border: 0; background: transparent; color: var(--c-muted); font-family: inherit; font-weight: 600; font-size: .9rem; line-height: 1; cursor: pointer; border-top: 2px solid transparent; }
  .pg-mobile-tabs button.is-active { color: var(--c-primary); border-top-color: var(--c-primary); }
  .pg-file { display: none; }
  .pg-toolbar { padding: .45rem .6rem; }
  .pg-fab-btn { padding: 0 .7rem; font-size: .82rem; }
  .pg-console { height: 38%; }
}

/* ---- pagina del ejercicio: tarjeta «Empezar» ---- */
.start-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 1.5rem 0; padding: 1.1rem 1.25rem; border: 1px solid var(--c-border); border-radius: 12px; background: var(--c-panel); }
.start-card p { margin: 0; color: var(--c-muted); max-width: 38rem; }
.start-card .start-btn { display: inline-flex; align-items: center; gap: .5rem; padding: .7rem 1.4rem; border-radius: 999px; background: var(--c-primary); color: #fff; font-weight: 700; text-decoration: none; box-shadow: 0 4px 14px rgba(79, 70, 229, .3); }
.start-card .start-btn:hover { background: var(--c-primary-dark); }

/* ---- autocompletado (intellisense) ---- */
.pg-hint { position: fixed; z-index: 1000; margin: 0; padding: .25rem; list-style: none; min-width: 11rem; max-width: 22rem; max-height: 220px; overflow-y: auto; background: var(--c-panel); border: 1px solid var(--c-border); border-radius: 10px; box-shadow: 0 10px 28px rgba(16, 24, 40, .18); font: 13px/1.4 'Fira Code', ui-monospace, monospace; }
.pg-hint[hidden] { display: none; }
.pg-hint li { display: flex; align-items: center; gap: .5rem; padding: .22rem .5rem; border-radius: 6px; cursor: pointer; color: var(--c-text); }
.pg-hint li.is-sel, .pg-hint li:hover { background: var(--c-primary-soft); }
.pg-hint-k { flex: 0 0 auto; width: 1.25rem; height: 1.25rem; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; font: 700 .72rem/1 system-ui, sans-serif; color: #fff; background: #64748b; }
.pg-hint-k.k-function { background: #7c3aed; }
.pg-hint-k.k-class { background: #d97706; }
.pg-hint-k.k-module { background: #0891b2; }
.pg-hint-k.k-keyword { background: #db2777; }
.pg-hint-k.k-param { background: #16a34a; }
.pg-hint-k.k-property { background: #4f46e5; }
.pg-hint-n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html[data-theme="dark"] .pg-hint { box-shadow: 0 10px 28px rgba(0, 0, 0, .5); }

/* ---- ajustes del editor (modal con pestanas a la izquierda) ---- */
.pg-editor .CodeMirror, .pg-editor textarea#runner-code { font-size: var(--pg-fs, 14px); }
.pg-settings { padding: 0; border: 1px solid var(--c-border); border-radius: 16px; background: var(--c-panel); color: var(--c-text); width: min(44rem, calc(100vw - 2rem)); height: min(42rem, calc(100vh - 2rem)); max-width: none; max-height: none; box-shadow: 0 20px 60px rgba(16, 24, 40, .38), 0 0 0 1px rgba(16, 24, 40, .06); overflow: hidden; }
.pg-settings[open] { display: flex; }
.pg-settings::backdrop { background: transparent; }
.pg-set-nav { flex: 0 0 13.5rem; display: flex; flex-direction: column; gap: .4rem; padding: 1.1rem .8rem .9rem; border-right: 1px solid var(--c-border); background: color-mix(in srgb, var(--c-text) 4%, var(--c-panel)); }
.pg-set-nav h2 { margin: 0 .5rem .6rem; font-size: 1rem; text-align: left; color: var(--c-text); }
.pg-set-tabs { display: flex; flex-direction: column; gap: 2px; }
.pg-set-tab { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem .7rem; border: 0; border-radius: 8px; background: transparent; color: var(--c-muted); font: inherit; font-size: .9rem; font-weight: 600; text-align: left; cursor: pointer; }
.pg-set-tab svg { flex: 0 0 auto; width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pg-set-tab:hover { background: color-mix(in srgb, var(--c-text) 7%, transparent); color: var(--c-text); }
.pg-set-tab[aria-selected="true"] { background: var(--c-primary-soft); color: var(--c-primary); }
.pg-set-nav .pg-set-reset { margin-top: auto; align-self: flex-start; }
.pg-set-main { position: relative; flex: 1; min-width: 0; overflow-y: auto; padding: 1.3rem 1.6rem 1.5rem; }
.pg-set-x { position: absolute; top: .6rem; right: .6rem; width: 30px; height: 30px; color: var(--c-muted); }
.pg-set-pane[hidden] { display: none; }
.pg-set-pane h3 { margin: 0 2rem 1rem 0; font-size: 1.15rem; text-align: left; color: var(--c-text); }
.pg-set-item { padding: .9rem 0; border-top: 1px solid var(--c-border); }
.pg-set-pane h3 + .pg-set-item { border-top: 0; padding-top: 0; }
.pg-set-line { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.pg-set-text { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.pg-set-text strong { font-size: .92rem; color: var(--c-text); }
.pg-set-text small { font-size: .8rem; line-height: 1.4; color: var(--c-muted); }
.pg-set-label { display: block; margin-bottom: .45rem; font-size: .88rem; font-weight: 600; color: var(--c-text); }
.pg-set-val { flex: 0 0 auto; padding: .15rem .5rem; border-radius: 6px; background: var(--c-primary-soft); color: var(--c-primary); font-weight: 700; font-size: .82rem; font-variant-numeric: tabular-nums; }
.pg-switch { flex: 0 0 auto; position: relative; width: 40px; height: 23px; padding: 0; border: 0; border-radius: 999px; background: color-mix(in srgb, var(--c-text) 22%, var(--c-panel)); cursor: pointer; transition: background .18s; }
.pg-switch span { position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .18s; }
.pg-switch[aria-checked="true"] { background: var(--c-primary); }
.pg-switch[aria-checked="true"] span { transform: translateX(17px); }
.pg-switch:focus-visible, .pg-seg button:focus-visible, .pg-set-slider input:focus-visible, .pg-set-reset:focus-visible, .pg-set-tab:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
#set-complete-opts.is-off { opacity: .45; pointer-events: none; }
.pg-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; max-width: 24rem; padding: 3px; gap: 3px; border-radius: 10px; background: color-mix(in srgb, var(--c-text) 7%, var(--c-panel)); }
.pg-seg button { padding: .42rem .5rem; border: 0; border-radius: 7px; background: transparent; color: var(--c-muted); font: inherit; font-size: .82rem; font-weight: 600; line-height: 1.2; cursor: pointer; transition: background .15s, color .15s; }
.pg-seg button:hover { color: var(--c-text); }
.pg-seg button[aria-pressed="true"] { background: var(--c-panel); color: var(--c-primary); box-shadow: 0 1px 3px rgba(16, 24, 40, .16); }
html[data-theme="dark"] .pg-seg button[aria-pressed="true"] { background: color-mix(in srgb, var(--c-primary) 22%, var(--c-panel)); box-shadow: none; }
.pg-set-slider { display: flex; align-items: center; gap: .6rem; margin-top: .9rem; max-width: 24rem; }
.pg-set-slider input { flex: 1; min-width: 0; accent-color: var(--c-primary); cursor: pointer; }
.pg-set-aa { font-weight: 700; color: var(--c-muted); line-height: 1; }
.pg-set-aa-s { font-size: .75rem; }
.pg-set-aa-l { font-size: 1.15rem; }
.pg-set-reset { padding: .35rem .8rem; border: 1px solid var(--c-border); border-radius: 8px; background: transparent; color: var(--c-muted); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; }
.pg-set-reset:hover { border-color: var(--c-primary); color: var(--c-primary); }
.pg-keys { margin: 0; }
.pg-keys > div { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .65rem 0; border-top: 1px solid var(--c-border); font-size: .9rem; }
.pg-keys > div:first-child { border-top: 0; padding-top: 0; }
.pg-keys dt { color: var(--c-text); }
.pg-keys dd { margin: 0; color: var(--c-muted); white-space: nowrap; }
.pg-keys kbd { display: inline-block; min-width: 1.5rem; padding: .12rem .4rem; border: 1px solid var(--c-border); border-bottom-width: 2px; border-radius: 6px; background: color-mix(in srgb, var(--c-text) 5%, var(--c-panel)); color: var(--c-text); font: 600 .78rem/1.3 'Fira Code', ui-monospace, monospace; text-align: center; }
@media (max-width: 640px) {
  .pg-settings[open] { flex-direction: column; height: min(40rem, calc(100vh - 2rem)); }
  .pg-set-nav { flex: 0 0 auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .4rem; padding: .7rem .8rem; border-right: 0; border-bottom: 1px solid var(--c-border); }
  .pg-set-nav h2 { display: none; }
  .pg-set-tabs { flex-direction: row; flex: 1; }
  .pg-set-tab { width: auto; padding: .4rem .6rem; font-size: .82rem; }
  .pg-set-tab svg { display: none; }
  .pg-set-nav .pg-set-reset { margin: 0 0 0 auto; }
  .pg-set-main { padding: 1rem 1.1rem 1.2rem; }
}
.pg-set-item > .pg-set-text + .pg-seg { margin-top: .7rem; }
.pg-seg-3 { max-width: 26rem; }

/* ---- temas de codigo (variables --ed-* puestas por editor-settings.js cuando hay un tema elegido) ---- */
.pg-editor.has-ct { background: var(--ed-bg); }
.pg-editor.has-ct .CodeMirror { background: var(--ed-bg); color: var(--ed-fg); }
.pg-editor.has-ct .CodeMirror-gutters { background: var(--ed-bg); border-right-color: color-mix(in srgb, var(--ed-fg) 14%, var(--ed-bg)); }
.pg-editor.has-ct .CodeMirror-linenumber { color: var(--ed-gfg); }
.pg-editor.has-ct .CodeMirror-cursor { border-left-color: var(--ed-cur); }
.pg-editor.has-ct .CodeMirror-selected { background: var(--ed-sel); }
.pg-editor.has-ct .CodeMirror-focused .CodeMirror-selected { background: var(--ed-sel); }
.pg-editor.has-ct .cm-variable, .pg-editor.has-ct .cm-property { color: var(--ed-fg); }
.pg-editor.has-ct .cm-keyword { color: var(--ed-kw); }
.pg-editor.has-ct .cm-builtin { color: var(--ed-bi); }
.pg-editor.has-ct .cm-string, .pg-editor.has-ct .cm-string-2 { color: var(--ed-st); }
.pg-editor.has-ct .cm-number, .pg-editor.has-ct .cm-atom { color: var(--ed-nu); }
.pg-editor.has-ct .cm-comment { color: var(--ed-co); }
.pg-editor.has-ct .cm-def { color: var(--ed-de); }
.pg-editor.has-ct .cm-variable-2, .pg-editor.has-ct .cm-variable-3 { color: var(--ed-v2); }
.pg-editor.has-ct .cm-operator, .pg-editor.has-ct .cm-meta { color: var(--ed-op); }
.pg-editor.has-ct .CodeMirror-matchingbracket { color: var(--ed-fg); background: var(--ed-sel); }

/* selector de temas */
.pg-ct-hint { display: none; }
html:not([data-theme="dark"]) .pg-ct-hint[data-mode="light"], html[data-theme="dark"] .pg-ct-hint[data-mode="dark"] { display: block; }
.pg-ct-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.6rem, 1fr)); gap: .6rem; margin-top: .8rem; }
.pg-ct-card { display: flex; flex-direction: column; gap: .4rem; padding: 4px 4px .45rem; border: 1px solid var(--c-border); border-radius: 10px; background: var(--c-panel); color: var(--c-text); font: inherit; font-size: .8rem; font-weight: 600; text-align: left; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.pg-ct-card:hover { border-color: color-mix(in srgb, var(--c-primary) 55%, var(--c-border)); }
.pg-ct-card[aria-checked="true"] { border-color: var(--c-primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c-primary) 28%, transparent); }
.pg-ct-card:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.pg-ct-prev { display: block; padding: .45rem .55rem; border-radius: 7px; font: 11px/1.45 'Fira Code', ui-monospace, monospace; white-space: pre; overflow: hidden; }
.pg-ct-name { padding: 0 .35rem; }

/* ---- boton de solucion (barra del editor) ---- */
.pg-sol { height: 34px; box-sizing: border-box; display: inline-flex; align-items: center; gap: .45rem; padding: 0 .85rem; border: 1px solid var(--c-border); border-radius: 8px; background: var(--c-panel); color: var(--c-text); font-family: inherit; font-weight: 600; font-size: .82rem; line-height: 1; cursor: pointer; white-space: nowrap; font-variant-numeric: tabular-nums; transition: border-color .15s, color .15s, background .15s; }
.pg-sol svg { color: var(--c-primary); flex: none; }
.pg-sol:hover:not(:disabled) { border-color: var(--c-primary); color: var(--c-primary); }
.pg-sol:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.pg-sol:disabled { cursor: not-allowed; opacity: .75; background: color-mix(in srgb, var(--c-text) 5%, var(--c-panel)); }
.pg-sol.is-ready { border-color: #16a34a; color: #15803d; background: color-mix(in srgb, #16a34a 10%, var(--c-panel)); }
.pg-sol.is-ready svg { color: #16a34a; }
[data-theme="dark"] .pg-sol.is-ready { color: #4ade80; }
.pg-sol-dev { margin-left: .5rem; border-style: dashed; color: #b45309; }
.pg-sol-dev:hover:not(:disabled) { border-color: #b45309; color: #b45309; }
[data-theme="dark"] .pg-sol-dev { color: #fbbf24; }

/* ---- menu de usuario en la cabecera del editor: siempre desplegable (tambien en movil) ---- */
.pg-bar-right .user-menu { display: inline-block; }
.pg-bar-right .user-menu-list { position: absolute; right: 0; top: calc(100% + 8px); padding: .3rem 0; border: 1px solid var(--c-border); box-shadow: 0 8px 24px rgba(16, 24, 40, .18); background: var(--c-panel); }

.pg > .env-banner { flex: 0 0 auto; }

/* ---- enlaces de la cabecera: son los mismos del curso (.main-header .nav-links); en movil solo queda el menu de usuario ---- */
.pg-bar .nav-links { margin-left: auto; }
@media (max-width: 900px) {
  .pg-bar .nav-links { position: static; right: auto; width: auto; height: auto; padding: 0; gap: .4rem; flex-direction: row; align-items: center; background: transparent; box-shadow: none; border: 0; border-radius: 0; transition: none; }
  .pg-bar .nav-links::before { content: none; }
  .pg-bar .nav-links > a { display: none; }
  .pg-bar .nav-links .user-menu { display: inline-block; }
}

/* ---- Menu del editor (Archivo, Editar, Ejecutar, Ver, Ayuda) ---- */
.pg-menubar { position: relative; flex: 0 0 auto; display: flex; align-items: center; }
.pgm-compact { display: none; align-items: center; gap: .4rem; padding: .35rem .7rem; border: 1px solid var(--c-border); border-radius: 8px; background: var(--c-panel); color: var(--c-text); font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; }
.pgm-compact:hover, .pg-menubar.is-open .pgm-compact { border-color: var(--c-primary); color: var(--c-primary); }
.pgm-groups { display: flex; gap: .1rem; }
.pgm { position: relative; }
.pgm-top { border: 0; background: none; color: var(--c-text); font: inherit; font-size: .9rem; padding: .3rem .65rem; border-radius: 6px; cursor: pointer; }
.pgm-top:hover, .pgm.is-open > .pgm-top { background: rgba(79, 70, 229, .1); color: var(--c-primary); }
.pgm-dd { display: none; position: absolute; top: calc(100% + 4px); left: 0; min-width: 16rem; z-index: 70; padding: .3rem 0; background: var(--c-panel); border: 1px solid var(--c-border); border-radius: 10px; box-shadow: 0 10px 28px rgba(16, 24, 40, .22); }
.pgm.is-open > .pgm-dd { display: block; }
.pgm-dd button, .pgm-dd a { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; width: 100%; padding: .42rem .9rem; border: 0; background: none; color: var(--c-text); font: inherit; font-size: .88rem; text-align: left; text-decoration: none; cursor: pointer; }
.pgm-dd button:hover, .pgm-dd a:hover { background: rgba(79, 70, 229, .08); color: var(--c-primary); }
.pgm-dd button[disabled] { opacity: .45; cursor: default; background: none; color: var(--c-muted); }
.pgm-dd kbd { font: inherit; font-size: .76rem; color: var(--c-muted); }
.pgm-dd hr { margin: .3rem 0; border: 0; border-top: 1px solid var(--c-border); }
.pgm-ck { display: inline-block; width: 1rem; margin-right: .1rem; color: var(--c-primary); }
.pgm-dd [aria-checked="true"] .pgm-ck::before { content: "✓"; }
.pgm-dd [role="menuitemcheckbox"] { justify-content: flex-start; gap: .3rem; }
html[data-theme="dark"] .pgm-top:hover, html[data-theme="dark"] .pgm.is-open > .pgm-top { background: rgba(129, 140, 248, .16); color: #c7d2fe; }
html[data-theme="dark"] .pgm-dd { background: #131a2e; border-color: #26304f; box-shadow: 0 10px 28px rgba(0, 0, 0, .55); }
html[data-theme="dark"] .pgm-dd button:hover, html[data-theme="dark"] .pgm-dd a:hover { background: rgba(129, 140, 248, .16); color: #c7d2fe; }
/* Modo compacto: un unico boton "Menu" con todos los grupos en un panel */
.pg-menubar.is-compact .pgm-compact { display: inline-flex; }
.pg-menubar.is-compact .pgm-groups { display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 70; width: 17.5rem; max-height: calc(100dvh - 5rem); overflow-y: auto; flex-direction: column; gap: 0; padding: .3rem 0; background: var(--c-panel); border: 1px solid var(--c-border); border-radius: 10px; box-shadow: 0 10px 28px rgba(16, 24, 40, .22); }
.pg-menubar.is-compact.is-open .pgm-groups { display: flex; }
.pg-menubar.is-compact .pgm-top { display: block; width: 100%; padding: .55rem .9rem .15rem; border-radius: 0; background: none !important; cursor: default; font-size: .68rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--c-muted) !important; text-align: left; }
.pg-menubar.is-compact .pgm-dd { display: block; position: static; min-width: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: none; }
html[data-theme="dark"] .pg-menubar.is-compact .pgm-groups { background: #131a2e; border-color: #26304f; box-shadow: 0 10px 28px rgba(0, 0, 0, .55); }
@media (max-width: 640px) { .pgm-compact span { display: none; } .pgm-compact { padding: .4rem .55rem; } }
/* Ver: ocultar enunciado / consola */
.pg.hide-left #pg-left, .pg.hide-left #pg-gutter-v { display: none; }
.pg.hide-console #pg-console, .pg.hide-console #pg-gutter-h { display: none; }

/* Editor libre: el titulo no se ve en la cabecera (sigue para lectores de pantalla y buscadores) */
.pg-bar > .pg-title.pg-title-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Buscar y reemplazar ---- */
.pg-editor { position: relative; }
.pg-find { position: absolute; top: .5rem; right: 1.2rem; z-index: 20; display: flex; align-items: flex-start; gap: .1rem; padding: .35rem; max-width: calc(100% - 2rem); background: var(--c-panel); color: var(--c-text); border: 1px solid var(--c-border); border-radius: 10px; box-shadow: 0 8px 24px rgba(16, 24, 40, .22); }
.pg-find[hidden] { display: none; }
.pgf-tg { align-self: stretch; width: 22px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--c-muted); cursor: pointer; display: grid; place-items: center; }
.pgf-tg:hover { background: rgba(79, 70, 229, .1); color: var(--c-primary); }
.pgf-tg svg { transition: transform .15s; }
.pgf-tg[aria-expanded="true"] svg { transform: rotate(90deg); }
.pgf-body { display: flex; flex-direction: column; gap: .3rem; }
.pgf-line { display: flex; align-items: center; gap: .2rem; }
.pgf-in { width: 13rem; min-width: 0; padding: .3rem .5rem; border: 1px solid var(--c-border); border-radius: 6px; background: var(--c-panel); color: var(--c-text); font: inherit; font-size: .86rem; }
.pgf-in:focus { outline: 2px solid var(--c-primary); outline-offset: -1px; border-color: transparent; }
.pg-find.is-empty #pgf-q { border-color: #dc2626; }
.pgf-count { min-width: 3.4rem; padding: 0 .3rem; font-size: .76rem; color: var(--c-muted); text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pgf-b { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 .3rem; border: 0; border-radius: 6px; background: none; color: var(--c-text); font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer; }
.pgf-b:hover { background: rgba(79, 70, 229, .1); color: var(--c-primary); }
.pgf-b[aria-pressed="true"] { background: rgba(79, 70, 229, .18); color: var(--c-primary); }
.pgf-txt { font-weight: 600; padding: 0 .55rem; white-space: nowrap; border: 1px solid var(--c-border); }
.pgf-b:focus-visible, .pgf-tg:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 1px; }
.CodeMirror .cm-find-match { background: rgba(250, 204, 21, .38); border-radius: 2px; }
.CodeMirror .cm-find-current { background: rgba(249, 115, 22, .55); border-radius: 2px; }
html[data-theme="dark"] .pg-find { background: #131a2e; border-color: #26304f; box-shadow: 0 8px 24px rgba(0, 0, 0, .55); }
html[data-theme="dark"] .pgf-in { background: #0f1528; border-color: #26304f; }
html[data-theme="dark"] .pgf-b:hover, html[data-theme="dark"] .pgf-tg:hover { background: rgba(129, 140, 248, .16); color: #c7d2fe; }
html[data-theme="dark"] .pgf-b[aria-pressed="true"] { background: rgba(129, 140, 248, .26); color: #c7d2fe; }
@media (max-width: 640px) { .pg-find { right: .5rem; left: .5rem; max-width: none; } .pgf-in { width: 100%; flex: 1; } .pgf-body { flex: 1; min-width: 0; } .pgf-count { min-width: 2.6rem; } }

/* ---- Revision del codigo (pyflakes) ---- */
.CodeMirror .cm-lint-error { text-decoration: underline wavy #dc2626; text-underline-offset: 3px; text-decoration-skip-ink: none; }
.CodeMirror .cm-lint-warn { text-decoration: underline wavy #d97706; text-underline-offset: 3px; text-decoration-skip-ink: none; }
.pg-lint-gutter { width: 14px; }
.pg-lint-dot { display: block; width: 8px; height: 8px; margin: 6px 0 0 3px; border-radius: 50%; cursor: help; }
.pg-lint-dot.is-error { background: #dc2626; }
.pg-lint-dot.is-warn { background: #f59e0b; }
.pg-lint-pill { position: absolute; right: 1.2rem; bottom: .6rem; z-index: 15; display: inline-flex; gap: .6rem; align-items: center; padding: .25rem .7rem; border: 1px solid var(--c-border); border-radius: 999px; background: var(--c-panel); color: var(--c-text); font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer; box-shadow: 0 4px 14px rgba(16, 24, 40, .16); font-variant-numeric: tabular-nums; }
.pg-lint-pill[hidden] { display: none; }
.pg-lint-pill:hover { border-color: var(--c-primary); }
.pg-lint-pill .pl-e { color: #dc2626; }
.pg-lint-pill .pl-w { color: #d97706; }
.pg-lint-pill:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
html[data-theme="dark"] .pg-lint-pill { background: #131a2e; border-color: #26304f; box-shadow: 0 4px 14px rgba(0, 0, 0, .45); }
html[data-theme="dark"] .pg-lint-pill .pl-e { color: #f87171; }
html[data-theme="dark"] .pg-lint-pill .pl-w { color: #fbbf24; }
html[data-theme="dark"] .CodeMirror .cm-lint-error { text-decoration-color: #f87171; }
html[data-theme="dark"] .CodeMirror .cm-lint-warn { text-decoration-color: #fbbf24; }

/* Ajustes y restablecer: ya no se ven en la barra (estan en el menu Ver y Archivo); los botones siguen en la pagina porque el menu los usa. */
.pg-off { display: none !important; }
