/* ============ ECUACIONES ============ */
.page-head { padding-top: clamp(1.1rem, 3.5vw, 2.2rem); text-align: center; }

.eq-wrap {
    width: 100%; min-width: 0; max-width: 1160px;
    margin: 0 auto clamp(3rem, 8vw, 5rem);
    display: flex; flex-direction: column; gap: 20px;
}

/* Tarjetas glass */
.eq-card {
    background: var(--glass-bg);
    backdrop-filter: blur(14px) saturate(1.3);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: clamp(18px, 3vw, 28px);
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.eq-card:hover { border-color: var(--accent-soft); }

.eq-card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-bottom: 22px;
}
.eq-card-title {
    display: flex; align-items: center; gap: 8px;
    font-size: .72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 1.2px; color: var(--muted); margin: 0;
}
.eq-card-title i { font-size: 17px; }

/* ============ BARRA DE MODO (igual que integrales) ============ */
.eq-mtoc { display: none; }

.eq-mtoc-chip {
    flex-shrink: 0;
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: .75rem; font-weight: 600; letter-spacing: .2px;
    padding: 9px 15px; border-radius: 999px;
    cursor: pointer; white-space: nowrap; font-family: inherit;
    transition: all .2s ease;
}
.eq-mtoc-chip i { font-size: 16px; }
.eq-mtoc-chip:hover { color: var(--text); }
.eq-mtoc-chip.active {
    background: var(--accent-soft); color: var(--accent); border-color: var(--accent);
}

/* Móvil: fixed bar below topbar */
@media (max-width: 900px) {
    .eq-mtoc {
        display: flex;
        position: fixed;
        top: 14px; left: 74px; right: 14px; z-index: 2399;
        align-items: center; justify-content: center; gap: 7px;
        height: 52px; overflow-x: auto;
        scrollbar-width: none; -ms-overflow-style: none; pointer-events: auto;
        padding: 8px 12px;
        background: var(--glass-strong); backdrop-filter: blur(18px) saturate(1.4);
        -webkit-backdrop-filter: blur(18px) saturate(1.4);
        border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow-sm);
    }
    .eq-mtoc-chip { flex: 1; justify-content: center; }
    .eq-mtoc::-webkit-scrollbar { display: none; }
}

/* Desktop: fixed bar below bottombar */
@media (min-width: 901px) {
    .eq-mtoc {
        display: flex;
        position: fixed; z-index: 2401;
        align-items: center; justify-content: center; gap: 8px;
        overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
        padding: 7px 10px;
        background: var(--glass-strong); backdrop-filter: blur(18px) saturate(1.4);
        -webkit-backdrop-filter: blur(18px) saturate(1.4);
        border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow-sm);
        /* Centrado dinámico: se posiciona por JS igual que integrales */
    }
    .eq-mtoc::-webkit-scrollbar { display: none; }
}

/* ============ PREVIEW ============ */
.eq-preview {
    text-align: center; padding: 28px 18px; margin-bottom: 18px;
    min-height: 104px; color: #1a1a1a; font-size: 1.35rem;
    background: #ffffff; border: 1px solid var(--border);
    border-radius: 18px; display: flex; align-items: center; justify-content: flex-start;
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}
[data-theme="dark"] .eq-preview { background: #18181C; color: var(--text); }
.eq-preview .katex-display { margin: 0 auto; }
.eq-preview .katex { font-size: 1.5em; }
.eq-result .katex { font-size: 2.025rem; }
/* En celulares el latex del visor es menor */

/* ============ COMPROBAR RESULTADO ============ */
.rc-check { margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 14px; }
/* Pildora "Comprobar resultado" del visor de resultados */
.rc-check-chevron { margin-left: 2px; font-size: .92rem; transition: transform .18s ease; }
#rc-check-toggle[aria-expanded="true"] .rc-check-chevron { transform: rotate(180deg); }
#rc-check-toggle[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.rc-check-row { display: flex; align-items: stretch; gap: 12px; flex-wrap: wrap; }
.rc-check-box { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); padding: 10px 14px 12px; position: relative; transition: border-color .15s ease, box-shadow .15s ease; }
.rc-check-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.rc-check-label { display: flex; align-items: center; gap: 6px; font-size: .68rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.rc-check-label i { color: currentColor; font-size: .95rem; }
.rc-check-math { flex: 1 1 auto; overflow-x: auto; padding: 8px 0 4px; font-size: 1.05rem; min-height: 34px; }
.rc-check-math::-webkit-scrollbar { display: none; }
.rc-check-vs { align-self: center; flex: none; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 30px; color: var(--muted); font-size: 1.15rem; transition: color .15s ease; }
.rc-check-vs.ok { color: #22c55e; }
.rc-check-vs.bad { color: #ef4444; }
[data-theme="dark"] .rc-check-vs.ok { color: #4ade80; }
[data-theme="dark"] .rc-check-vs.bad { color: #f87171; }
/* Fila de controles: sustituir x= (titulo encima) + visor de la ecuacion */
.rc-check-controls { align-items: stretch; margin-bottom: 16px; gap: 10px; }
.rc-check-sustituir { display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 7px; flex: 0 1 auto; min-width: 190px; box-sizing: border-box; border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; background: var(--surface-2); font-size: .82rem; color: var(--muted); }
.rc-check-sustituir-row { display: flex; align-items: center; gap: 8px; }
/* Modo texto plano del valor de sustituir */
.rc-check-x0-text { display: none; width: 66px; min-width: 48px; box-sizing: border-box; border: none; background: transparent; color: var(--text); font-family: inherit; font-size: .95rem; padding: 4px 0; }
.rc-check-x0-text:focus { outline: none; }
.rc-check-var { font-weight: 700; color: var(--text); min-width: 16px; text-align: center; }
math-field.rc-check-x0 { flex: 1 1 auto; min-width: 90px; max-width: 220px; border: none; background: transparent; color: var(--text); padding: 0; font-size: .95rem; }
math-field.rc-check-x0::part(content) { min-height: 24px; padding: 4px 0 2px; }
/* Sin icono de las tres rayitas (menu) en el campo de sustitucion */
math-field.rc-check-x0::part(menu-toggle) { display: none !important; }
/* Panel de configuracion de tolerancia */
.rc-check-config { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 16px; margin-bottom: 12px; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 12px; background: var(--surface-2); }
.rc-check-config[hidden] { display: none; }
.rc-check-tol { width: 112px; box-sizing: border-box; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); padding: 6px 9px; font-family: inherit; font-size: .88rem; }
.rc-check-tol:focus { border-color: var(--accent); outline: none; }
.rc-check-tol-modo { border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); padding: 6px 8px; font-family: inherit; font-size: .84rem; }
.rc-check-tol-modo:focus { border-color: var(--accent); outline: none; }
.rc-check-tol-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rc-check-chip { border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 4px 10px; font-family: inherit; font-size: .78rem; font-weight: 600; cursor: pointer; transition: background .15s ease, color .15s ease, border-color .15s ease; }
.rc-check-chip:hover { border-color: var(--accent); color: var(--accent); }
.rc-check-chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
/* Visor de la ecuacion de la entrada principal (comparte renglon con Sustituir) */
.rc-check-box-eq { flex: 2 1 340px; }
.rc-check-box-eq .rc-check-math { font-size: 1.2rem; min-height: 40px; }
.rc-check-mode-btn { display: inline-flex; align-items: center; justify-content: center; flex: none; align-self: center; width: 36px; height: 32px; padding: 0; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent-soft); color: var(--accent); cursor: pointer; font-size: .95rem; transition: background .15s ease, color .15s ease, transform .15s ease; }
.rc-check-mode-btn:hover { background: var(--accent); color: var(--accent-text-on); transform: translateY(-1px); }
.rc-check-mode-btn:active { transform: translateY(0); }
/* Veredicto: banner con barra de color a la izquierda + boton de tolerancia */
.rc-check-verdict { display: none; margin-top: 12px; border: 1px solid transparent; border-radius: 10px; padding: 8px 10px 8px 14px; font-size: .9rem; line-height: 1.55; align-items: center; gap: 10px; }
.rc-check-verdict.ok { display: flex; background: color-mix(in srgb, #22c55e 10%, transparent); border-color: color-mix(in srgb, #22c55e 45%, transparent); color: #15803d; }
.rc-check-verdict.bad { display: flex; background: color-mix(in srgb, #ef4444 10%, transparent); border-color: color-mix(in srgb, #ef4444 45%, transparent); color: #b91c1c; }
.rc-check-verdict.neutral { display: flex; background: color-mix(in srgb, var(--accent) 8%, transparent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--muted); }
[data-theme="dark"] .rc-check-verdict.ok { color: #4ade80; }
[data-theme="dark"] .rc-check-verdict.bad { color: #f87171; }
[data-theme="dark"] .rc-check-verdict.neutral { color: #cbd5e1; }
.rc-check-verdict .katex { color: inherit; }
.rc-check-verdict-msg { flex: 1 1 auto; min-width: 0; }
.rc-check-verdict .rc-check-mode-btn { align-self: center; }
.rc-check-placeholder { color: var(--muted); opacity: .75; }
.rc-check-diff { margin-top: 6px; overflow-x: auto; color: var(--text); }
.rc-check-diff::-webkit-scrollbar { display: none; }
@media (max-width: 560px) {
    .rc-check-controls { flex-wrap: wrap; }
    .rc-check-sustituir { width: 100%; flex: 1 1 100%; padding: 8px 10px; gap: 6px; }
    math-field.rc-check-x0 { max-width: none; flex: 1 1 auto; }
    .rc-check-box-eq { flex-basis: 100%; }
    .rc-check-config { flex-direction: column; align-items: stretch; }
    .rc-check-tol, .rc-check-tol-modo { width: 100%; }
    /* Los dos lados quedan en el mismo renglon */
    .rc-check-row:not(.rc-check-controls) { flex-wrap: nowrap; }
    .rc-check-row:not(.rc-check-controls) .rc-check-box { flex: 1 1 0; min-width: 0; }
    .rc-check-row:not(.rc-check-controls) .rc-check-label { letter-spacing: .3px; }
    .rc-check-vs { width: auto; height: auto; justify-content: center; margin: 0; }
    .rc-check-box { padding: 10px 12px 12px; }
}
@media (max-width: 767px) {
    .eq-preview { padding: 22px 16px; min-height: 84px; }
    .eq-preview .katex { font-size: 1.15em; }
    .eq-result .katex { font-size: 1.5525rem; }
}
.eq-preview > * { flex-shrink: 0; margin: 0 auto; }
.eq-preview::-webkit-scrollbar { display: none; }

/* ============ INPUTS ============ */
.eq-inputs-section { margin-bottom: 8px; }
.eq-field-group { display: flex; flex-direction: column; gap: 5px; }
.eq-field-label { font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.eq-field-input {
    width: 100%; height: 46px; padding: 12px 20px; border: 1px solid var(--border);
    border-radius: 16px; background: var(--surface-2); color: var(--text);
    font-size: .92rem; font-family: inherit; outline: none; transition: border-color .2s;
}
.eq-field-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.eq-select-wrap {
    position: relative; display: flex; align-items: center;
    width: max-content; min-width: 76px; max-width: 100%;
}
.eq-field-select {
    width: auto; min-width: 76px; height: 46px; padding: 10px 36px 10px 18px;
    border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface-2); color: var(--text);
    font-size: .88rem; font-weight: 600; font-style: italic;
    font-family: "KaTeX_Math", "Cambria Math", "Latin Modern Math", Georgia, serif;
    outline: none; cursor: pointer;
    appearance: none; -webkit-appearance: none; text-align: center;
    transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
}
.eq-select-chevron {
    position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
    pointer-events: none; color: var(--muted); opacity: .7; font-size: 14px;
}
.eq-field-select:hover { border-color: var(--accent-soft); background: var(--surface); transform: translateY(-1px); }
.eq-field-select:focus { border-color: var(--accent); background: var(--surface-2); box-shadow: 0 0 0 3px var(--accent-soft); }

.eq-single-opts {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-top: 14px;
}

/* Angulos: pill Radianes / Grados (reutiliza .eq-domain-pill) */
.eq-domain-opt[data-angle="grados"].is-active { color: #b45309; background: color-mix(in srgb, #f59e0b 16%, transparent); border-color: color-mix(in srgb, #f59e0b 45%, transparent); }
[data-theme="dark"] .eq-domain-opt[data-angle="grados"].is-active { color: #fbbf24; }
.eq-angle-group select { display: none; }
@media (max-width: 900px) {
    .eq-single-opts { grid-template-columns: 1fr 1fr; }
    .eq-angle-group { grid-column: 1 / -1; }
}

/* Dominio: pill contenedora con dos pills dentro (Reales / Complejos) */
.eq-domain-pill {
    display: flex; align-items: stretch; gap: 4px; padding: 4px; height: 46px;
    border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2);
}
.eq-domain-opt {
    flex: 1 1 0; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    padding: 8px 8px; border: 1px solid transparent; border-radius: 999px;
    background: transparent; color: var(--muted);
    font-family: inherit; font-size: .84rem; font-weight: 700; letter-spacing: .2px;
    cursor: pointer; white-space: nowrap;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.eq-domain-opt .eq-domain-sym { font-size: .95rem; line-height: 1; }
.eq-domain-opt .eq-domain-sym .katex { font-size: 1.1em; }
.eq-word-short { display: none; }
.eq-domain-opt:hover { background: var(--surface); color: var(--text); border-color: var(--border); }
.eq-domain-opt.is-active { color: #15803d; background: color-mix(in srgb, #22c55e 16%, transparent); border-color: color-mix(in srgb, #22c55e 45%, transparent); }
.eq-domain-opt[data-dom="complejos"].is-active { color: #0369a1; background: color-mix(in srgb, #0ea5e9 16%, transparent); border-color: color-mix(in srgb, #0ea5e9 45%, transparent); }
[data-theme="dark"] .eq-domain-opt.is-active { color: #4ade80; }
[data-theme="dark"] .eq-domain-opt[data-dom="complejos"].is-active { color: #38bdf8; }
.eq-domain-opt:focus-visible { outline: 2px solid var(--border); outline-offset: 1px; }
.eq-domain-group select { display: none; }

/* ============ SISTEMA ============ */
.eq-system-grid {
    display: flex; flex-direction: column; gap: 12px;
}
.eq-sys-cell .smart-input-shell { width: 100%; }

/* Campo para escribir una incognita libre (opcion "Escribir variable") */
.eq-var-libre {
    width: 88px; height: 46px; padding: 12px 10px;
    border: 1px solid var(--border); border-radius: 16px;
    background: var(--surface-2); color: var(--text);
    font-size: .92rem; font-family: inherit; outline: none;
    text-align: center; transition: border-color .2s;
}
.eq-var-libre:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.eq-var-libre[hidden] { display: none; }

/* Panel "Resolver para": que variables despeja el sistema */
.eq-vars-group { margin-top: 16px; }
.eq-vars-input {
    max-width: 280px; letter-spacing: 3px;
}
.eq-vars-hint { margin: 0; font-size: .72rem; color: var(--muted); }

/* Boton agregar/eliminar ecuacion (estilo tri-btn-ghost) */
.eq-system-actions {
    display: flex; justify-content: center; gap: 12px; margin-top: 20px;
}
.eq-sys-action-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 11px 24px; border-radius: 999px;
    background: transparent; color: var(--text);
    border: 1px solid var(--border); font-size: .82rem; font-weight: 600;
    font-family: inherit; cursor: pointer;
    transition: all .25s ease;
}
.eq-sys-action-btn:hover {
    background: var(--surface-2);
    border-color: var(--accent-soft);
    transform: translateY(-2px);
}
.eq-sys-action-btn i { font-size: 16px; }
.eq-sys-action-remove {
    color: var(--muted); border-color: var(--border);
}
.eq-sys-action-remove:hover {
    background: var(--surface-2);
    border-color: var(--accent-soft);
    color: var(--text);
}

/* ============ CALC BUTTON ============ */
.eq-calc-btn {
    width: 100%; padding: 14px 24px; border-radius: 999px;
    background: var(--accent-soft); color: var(--accent);
    border: 1px solid var(--accent);
    font-size: .92rem; font-weight: 700; font-family: inherit;
    cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 9px;
    transition: all .3s cubic-bezier(0.4, 0, 0.2, 1); margin-top: 16px;
}
.eq-calc-btn:hover {
    background: var(--accent); color: var(--accent-text-on);
    transform: translateY(-3px) scale(1.01);
}
.eq-calc-btn i { font-size: 18px; }

/* ============ LOADING ============ */
.eq-loading {
    display: flex; align-items: center; gap: 12px; margin-top: 14px;
    padding: 12px 16px; border-radius: 12px; background: var(--surface-2);
}
.eq-loading-shimmer {
    width: 100%; height: 4px; border-radius: 4px;
    background: linear-gradient(90deg, var(--surface) 25%, var(--accent-soft) 50%, var(--surface) 75%);
    background-size: 200% 100%; animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.eq-loading-text { font-size: .78rem; font-weight: 600; color: var(--muted); white-space: nowrap; }

/* ============ RESULT ============ */
.eq-result-card { text-align: center; }

/* Zoom control in result card head */
.eq-zoom-ctl {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

.eq-zoom-ctl i {
    font-size: 13px;
}

.eq-zoom-ctl input[type="range"] {
    width: 90px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.eq-zoom-ctl input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

.eq-zoom-ctl input[type="range"]::-moz-range-thumb {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}
.eq-result {
    text-align: center; font-size: 1.05rem; color: var(--text);
    padding: 20px 18px; min-height: 50px; overflow-x: auto;
    background: #ffffff; border: 1px solid var(--border);
    border-radius: 18px; position: relative;
    scrollbar-width: none; -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.eq-result .katex-display,
.eq-result .katex {
    transform-origin: center center;
    transition: transform 0.2s ease;
}
.eq-result-math { overflow-x: auto; padding: 0 4px; scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; }
.eq-result-math::-webkit-scrollbar { display: none; }
.eq-result-math .katex-display { margin: .3em 0; }
[data-theme="dark"] .eq-result { background: #18181C; }
.eq-result .katex-display { margin: .3em auto; }
.eq-result::-webkit-scrollbar { display: none; }
.resultado-decimal { font-size: .88rem; color: var(--muted); margin-top: 6px; }
.result-meta { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.result-chip {
    padding: 4px 12px; border-radius: 999px; font-size: .72rem; font-weight: 600;
    background: var(--accent-soft); color: var(--accent);
}

/* ============ BOTON APROXIMAR ============ */
.eq-result-approx {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    margin-top: 12px; padding: 7px 16px; border-radius: 999px;
    background: transparent; color: var(--accent);
    border: 1px solid var(--accent-soft);
    font-size: .78rem; font-weight: 600; font-family: inherit;
    cursor: pointer; line-height: 1;
    transition: all .25s ease;
}
.eq-result-approx:hover {
    background: var(--accent-soft); color: var(--accent);
    transform: translateY(-2px);
    border-color: var(--accent);
}
.eq-result-approx:active { transform: translateY(0) scale(.97); }
.eq-result-approx-box {
    margin-top: 12px; padding: 10px 14px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 14px; text-align: center; overflow-x: auto;
}
.eq-result-approx-box .eq-result-math { overflow-x: auto; }
.eq-result-approx-box .katex-display { margin: .3em 0; }

/* Info button + explanation */
.eq-result-info {
    position: absolute; top: 10px; right: 10px;
    width: 28px; min-width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0; border: 1px solid transparent; border-radius: 50%;
    background: transparent; color: var(--muted);
    font-size: .72rem; font-family: inherit; cursor: pointer;
    transition: all .25s ease;
}
.eq-result-info i { font-size: 15px; }
.eq-result-info:hover { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }
.eq-result-explanation {
    display: none; text-align: left;
    margin-top: 14px; padding: 18px 22px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 14px; font-size: .82rem; line-height: 1.6; color: var(--muted);
}
.eq-result-explanation.open { display: block; }
.eq-result-expl-header {
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .8px;
    color: var(--accent); margin-bottom: 10px;
}
.eq-result-expl-header strong { color: var(--accent); font-weight: 700; }
.eq-result-explanation strong { color: var(--text); font-weight: 700; }
.eq-result-explanation ul { margin: 8px 0 0 18px; padding: 0; }
.eq-result-explanation li { margin-bottom: 4px; }

/* ============ COMPLEX SUGGESTION ============ */
.eq-complex-suggestion {
    display: flex; align-items: flex-start; gap: 10px;
    margin-top: 12px; padding: 14px 18px;
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    border: 1px solid var(--accent-soft);
    border-radius: 12px; font-size: .82rem; color: var(--text); line-height: 1.5;
    text-align: left;
}
.eq-complex-suggestion i {
    flex-shrink: 0; margin-top: 2px; color: var(--accent); font-size: 17px;
}
.eq-complex-suggestion strong { color: var(--accent); }
.eq-complex-switch-btn {
    display: inline-flex; align-items: center; gap: 4px;
    margin-top: 8px; padding: 7px 16px; border-radius: 999px;
    background: var(--accent-soft); color: var(--accent);
    border: 1px solid var(--accent); font-size: .78rem; font-weight: 600;
    font-family: inherit; cursor: pointer; transition: all .2s ease;
}
.eq-complex-switch-btn:hover {
    background: var(--accent); color: var(--accent-text-on);
    transform: translateY(-1px);
}

/* ============ GRAPH ============ */
.eq-graph-card { overflow: hidden; }
.eq-graph-head {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.eq-graph-canvas {
    width: 100%; min-width: 0; min-height: 380px;
    display: flex; align-items: center; justify-content: center;
    background: #ffffff; border: 1px solid var(--border);
    border-radius: 16px; padding: 16px; overflow: hidden;
    position: relative;
}
[data-theme="dark"] .eq-graph-canvas { background: #18181C; }
.eq-graph-canvas > * { max-width: 100%; }
.eq-graph-canvas .js-plotly-plot { width: 100% !important; height: auto !important; min-height: 360px; }
/* Solo el SVG principal: el selector amplio tambien rompia los iconos de la
   modebar (display:block los apilaba uno debajo de otro). */
.eq-graph-canvas svg.main-svg { display: block; margin: 0 auto; }
.eq-download-btn {
    padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface); color: var(--muted); cursor: pointer;
    font-size: 15px; display: inline-flex; align-items: center; justify-content: center;
    transition: all .2s;
}
.eq-download-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ============ FORMULAS ============ */
.eq-formulas {
    max-height: 400px; overflow-y: auto; padding-right: 4px;
}
.eq-formulas::-webkit-scrollbar { width: 5px; }
.eq-formulas::-webkit-scrollbar-track { background: transparent; }
.eq-formulas::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.formula-item {
    padding: 10px; text-align: center; border-radius: 8px;
    cursor: pointer; transition: background .2s; margin-bottom: 4px;
}
.formula-item:hover { background: var(--surface-2); }
.formula-item .katex { font-size: .95rem; }

.formula-row {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    padding: 10px; border-radius: 8px; cursor: pointer; transition: background .2s;
    flex-wrap: wrap; margin-bottom: 4px;
}
.formula-row:hover { background: var(--surface-2); }
.formula-title { font-size: .78rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.formula-math { text-align: center; }
.formula-math .katex { font-size: .92rem; }

.formula-category-title {
    text-align: center; font-size: .92rem; font-weight: 700;
    color: var(--accent); margin-top: 20px; margin-bottom: 10px; width: 100%;
}

/* Toast: estilos unificados en css/styles.css (.toast-copiado) */

/* ============ RESPONSIVE ============ */
@media (max-width: 600px) {
    .eq-card { padding: 18px; }
    /* Variable arriba; Dominio y Angulos juntos en el mismo renglon */
    .eq-single-opts { grid-template-columns: 1fr 1fr; }
    .eq-single-opts > .eq-field-group:first-child { grid-column: 1 / -1; }
    .eq-angle-group { grid-column: auto; }
    .eq-domain-group .eq-domain-word { display: none; }
    .eq-word-long { display: none; }
    .eq-word-short { display: inline; }
    .eq-calc-btn { font-size: .88rem; padding: 12px; }
    .eq-graph-canvas { min-height: 260px; padding: 10px; }
    .eq-graph-canvas .js-plotly-plot { width: 100% !important; height: auto !important; min-height: 250px; }
    .eq-card-head { flex-wrap: wrap; }

    .eq-zoom-ctl input[type="range"] {
        width: 64px;
        height: 5px;
    }

    .eq-zoom-ctl input[type="range"]::-webkit-slider-thumb {
        width: 16px;
        height: 16px;
    }

    .eq-zoom-ctl input[type="range"]::-moz-range-thumb {
        width: 16px;
        height: 16px;
    }
}

/* Single scroll context: html handles vertical scroll, body stays hidden
   overflow-x.  The previous body { overflow-x: clip } forced overflow-y to
   compute to auto, creating a competing body scrollbar. */

/* ============ HISTORIAL / TABS ============ */
.eq-historial-tabs {
    display: flex; flex-wrap: wrap; gap: 8px;
    align-items: center; justify-content: center;
    position: relative; margin-bottom: 12px; padding: 0 44px;
}
.eq-historial-pill {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; padding: 13px 10px; border-radius: 16px;
    background: var(--surface-2); border: 1px solid var(--border);
    color: var(--text); font-family: inherit; font-weight: 700;
    font-size: .82rem; cursor: pointer; text-align: center;
    transition: all .25s ease;
}
.eq-historial-pill i { font-size: 16px; flex-shrink: 0; }
.eq-historial-pill:hover { border-color: var(--accent-soft); transform: translateY(-2px); }
.eq-historial-pill.active {
    background: var(--accent); color: var(--accent-text-on); border-color: var(--accent);
}
.eq-historial-pill.active i { color: var(--accent-text-on); }

.eq-historial {
    max-height: 400px; overflow-y: auto; padding-right: 4px;
}
.eq-historial::-webkit-scrollbar { width: 5px; }
.eq-historial::-webkit-scrollbar-track { background: transparent; }
.eq-historial::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.historial-vacio {
    text-align: center; color: var(--muted); font-size: .85rem;
    padding: 22px 10px; border: 1px dashed var(--border); border-radius: 12px;
}
.historial-item {
    padding: 10px 12px; border-radius: 10px; background: var(--surface-2);
    margin-bottom: 8px; cursor: pointer;
    transition: background .2s, border-color .2s; border: 1px solid transparent;
}
.historial-item:hover { border-color: var(--border); }
.historial-item { position: relative; }
.historial-item .historial-item-del {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    line-height: 1;
    opacity: 0;
    transition: opacity .2s ease, color .2s ease, background .2s ease, border-color .2s ease;
}
.historial-item:hover .historial-item-del,
.historial-item .historial-item-del:focus-visible {
    opacity: 1;
}
.historial-item .historial-item-del:hover {
    color: #e11d48;
    border-color: #e11d48;
    background: color-mix(in srgb, #e11d48 12%, transparent);
}
@media (hover: none) {
    .historial-item .historial-item-del { opacity: 1; background: var(--surface); border-color: var(--border); }
}
.historial-item .historial-math { display: block; text-align: center; overflow-x: auto; }
.historial-item .historial-entrada {
    display: flex; align-items: baseline; gap: 7px;
    margin-top: 8px; padding-top: 7px; border-top: 1px dashed var(--border);
    font-size: .85rem;
}
.historial-item .historial-entrada-tag {
    flex: none; font-size: .64rem; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; color: var(--muted);
    border: 1px solid var(--border); border-radius: 99px; padding: 2px 7px;
}
.historial-item .historial-entrada-math { flex: 1 1 auto; min-width: 0; }
.historial-item .historial-entrada .katex { font-size: 1em; }
.historial-item .historial-entrada .katex-display { margin: 0; }
.historial-item .historial-decimal { display: block; text-align: center; font-size: .78rem; color: var(--muted); margin-top: 2px; }

/* Mobile: pills same row */
@media (max-width: 600px) {
    .eq-historial-tabs { flex-wrap: nowrap; padding: 0; gap: 6px; }
    .eq-historial-tabs .eq-historial-pill { flex: 1 1 0; min-width: 0; padding: 11px 6px; font-size: .74rem; white-space: nowrap; }
    .eq-historial-pill i { font-size: 1.05rem; }
}

/* ====== Historial persistente + copia de resultado (compartido) ====== */
.historial-item .historial-item-restaurar {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    line-height: 1;
    opacity: 0;
    transition: opacity .2s ease, color .2s ease, background .2s ease, border-color .2s ease;
}
.historial-item:hover .historial-item-restaurar,
.historial-item .historial-item-restaurar:focus-visible { opacity: 1; }
.historial-item .historial-item-restaurar:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}
@media (hover: none) {
    .historial-item .historial-item-restaurar { opacity: 1; background: var(--surface); border-color: var(--border); }
}

.rc-copy-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 18px;
    position: sticky;
    left: 0;
    background: #ffffff;
    padding: 10px 0;
    z-index: 1;
}
[data-theme="dark"] .rc-copy-row {
    background: #18181C;
}
.rc-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-size: .74rem;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.5;
    cursor: pointer;
    transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.rc-copy-btn i { font-size: .92rem; }
.rc-copy-btn:hover { color: var(--text); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* ============ ACCIONES DEL VISOR (limpiar / ejemplo / transformar) ============ */
.eq-preview-actions {
    display: flex; align-items: center; justify-content: flex-end; gap: 4px;
    margin: 0 0 22px;
}
.eq-prev-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    padding: 9px 15px; border-radius: 999px;
    border: 1px solid var(--border); background: transparent;
    color: var(--text); cursor: pointer; font-family: inherit; font-size: .82rem; font-weight: 700;
    transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
}
.eq-prev-btn i { flex-shrink: 0; font-size: 1.05rem; }
.eq-prev-btn:hover { background: var(--surface-2); border-color: var(--accent-soft); transform: translateY(-2px); }
.eq-prev-btn:active { transform: translateY(0); }
/* En movil solo iconos; en PC el label corto aparece */
.eq-prev-btn .eq-prev-label { display: none; }
@media (min-width: 768px) {
    .eq-prev-btn .eq-prev-label { display: inline; }
}

/* Modal de transformaciones */
.eq-transform-modal {
    position: fixed; inset: 0; z-index: 3000;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    padding: 20px;
}
.eq-transform-modal[hidden] { display: none; }
.eq-transform-modal:not([hidden]) { animation: rcModalFade var(--transition) both; }
.eq-transform-card {
    position: relative;
    width: 100%; max-width: 900px;
    max-height: min(86vh, 720px);
    overflow-y: auto;
    padding: clamp(1.6rem, 4vw, 2.4rem);
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
}
.eq-transform-modal:not([hidden]) .eq-transform-card { animation: rcModalPop var(--transition) both; }
.eq-transform-head { display: block; padding: 0; border: none; margin-bottom: 8px; }
.eq-transform-title { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 8px; padding-right: 40px; font-size: clamp(2.1rem, 5vw, 2.7rem); text-align: center; }
.eq-transform-title i { font-size: 26px; color: var(--accent); }
.eq-transform-close {
    position: absolute; top: 16px; right: 16px;
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border: none; border-radius: 12px;
    background: var(--surface-2); color: var(--text); font-size: 18px; cursor: pointer;
}
.eq-transform-close:hover { background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); color: var(--accent); }
.eq-transform-list { display: flex; flex-direction: column; gap: 8px; padding: 0; margin: 0; overflow: visible; }
.eq-transform-item {
    display: flex; align-items: center; gap: 13px;
    padding: 12px 16px; border-radius: 14px; text-align: left;
    border: 1px solid transparent; background: transparent; color: var(--text);
    font-weight: 600; font-size: .93rem; font-family: inherit; cursor: pointer;
    transition: all var(--transition);
}
.eq-transform-item:hover { background: var(--accent-soft); border-color: var(--accent); }
.eq-transform-nombre { display: inline-flex; align-items: center; gap: 13px; flex: 1 1 auto; min-width: 0; font-size: .93rem; font-weight: 600; color: var(--text); }
.eq-transform-nombre i { font-size: 20px; color: var(--accent); flex-shrink: 0; }
.eq-transform-math {
    flex-shrink: 0; max-width: 58%;
    overflow-x: auto; white-space: nowrap;
    font-size: 1.4rem; font-weight: 700; color: var(--text);
    background: var(--surface-2); padding: 6px 14px; border-radius: var(--r-sm);
}
.eq-transform-math::-webkit-scrollbar { display: none; }
.eq-transform-vacio { margin: 0; color: var(--muted); font-size: .95rem; text-align: center; }
@media (max-width: 560px) {
    .eq-transform-item { flex-wrap: wrap; gap: 8px 10px; }
    .eq-transform-nombre { flex: 1 1 100%; }
    .eq-transform-math { flex: 1 1 100%; max-width: none; }
}

/* Version bump v16 */

@media (max-width: 900px) {
    .content { padding-left: 12px; padding-right: 12px; }
}
