:root {
    --brand: #10b981;
    --brand-dark: #059669;
    --brand-light: #ecfdf5;
    --ink-1: #111827;
    --ink-2: #4b5563;
    --ink-3: #9ca3af;
    --bg-main: #f9fafb;
    --card-bg: #ffffff;
    --border: #e5e7eb;

    --accent: #3b82f6;
    --danger: #ef4444;
    --warning: #f59e0b;
}

body {
    background-color: var(--bg-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-container {
    max-width: 900px;
    width: 100%;
    margin: 2rem auto;
    padding: 0 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.calculator-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border);
}

.app-title {
    font-size: 2.5rem;
    color: var(--brand);
    text-align: center;
    margin-bottom: 0.5rem;
    font-family: 'Inter', sans-serif;
    font-weight: 800;
}

.app-subtitle {
    text-align: center;
    color: var(--ink-2);
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.input-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.mode-toggle {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.mode-btn {
    background: var(--bg-main);
    color: var(--ink-2);
    border: 2px solid var(--border);
    padding: 0.5rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.mode-btn.active {
    background: var(--brand);
    color: white;
    border-color: var(--brand);
}

.mode-btn:hover:not(.active) {
    background: var(--border);
    color: var(--ink-1);
}

.equation-row {
    display: flex;
    justify-content: center;
    width: 100%;
}

.editor-wrapper {
    position: relative;
    width: 100%;
    max-width: 500px;
}

.math-editor {
    width: 100%;
    font-size: 1.5rem;
    padding: 1rem;
    border: 3px solid var(--border);
    border-radius: 12px;
    background: var(--bg-main);
    color: var(--ink-1);
    transition: all 0.3s ease;
    min-height: 60px;
}

.math-editor:focus-within {
    border-color: var(--brand);
    background: var(--card-bg);
    box-shadow: 0 0 0 4px var(--brand-light);
}

.placeholder-overlay {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-3);
    font-size: 1.2rem;
    pointer-events: none;
    transition: opacity 0.2s;
    font-family: 'Inter', sans-serif;
}

.controls-row {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.calculate-btn {
    background: var(--brand);
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.calculate-btn:hover {
    background: var(--brand-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.btn-secondary {
    background: var(--bg-main);
    color: var(--ink-2);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
    color: var(--ink-1);
    box-shadow: none;
}

.error-msg {
    color: var(--danger);
    background: #fef2f2;
    padding: 1rem;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    margin-top: 1rem;
    border: 1px solid #fecaca;
}

.hidden {
    display: none !important;
}

/* Steps Section */
.results-title {
    font-size: 2rem;
    color: var(--ink-1);
    text-align: center;
    margin-bottom: 2rem;
}

.steps-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.step-card {
    background: var(--bg-main);
    border-radius: 16px;
    padding: 1.5rem;
    border-left: 4px solid var(--brand);
}

.step-title {
    font-size: 1.2rem;
    color: var(--brand-dark);
    margin-bottom: 1rem;
    font-weight: 700;
}

.step-content {
    color: var(--ink-1);
    font-size: 1.1rem;
    line-height: 1.6;
    overflow-x: auto;
}

.katex-display {
    margin: 1rem 0 !important;
}

.final-result-box {
    margin-top: 3rem;
    padding: 2rem;
    background: var(--brand-light);
    border: 2px solid var(--brand);
    border-radius: 16px;
    text-align: center;
}

.final-result-box h3 {
    color: var(--brand-dark);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.final-latex-text {
    font-size: 1.5rem;
    font-weight: bold;
}

@media (max-width: 640px) {
    .calculator-card {
        padding: 1.5rem;
    }

    .app-title {
        font-size: 2rem;
    }

    .calculate-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Footer and Header Overrides to match Parabola's style.css global brand */
.site-header {
    --brand: #0A5B63 !important;
    --accent: #FFC955 !important;
}

.site-footer {
    --brand: #0A5B63 !important;
}

.site-footer .footer-nav a {
    color: var(--brand) !important;
}

.site-footer .back-link {
    color: var(--brand) !important;
}

/* ============================================================
   Avviso «strumento in ricostruzione»
   ------------------------------------------------------------
   Sta sopra i comandi. Oro del tema come filo verticale e velo di
   fondo — l'oro qui e' fondo e bordo, mai la scritta: --accent su
   bianco fa 1,94:1 e non si legge. Il testo e' --ink sul velo
   --accent-soft, che misura molto sopra la soglia AA.

   Non e' un messaggio d'errore e non usa il rosso: lo strumento non
   e' rotto, e dirlo col colore sbagliato sarebbe la prima cosa che
   il visitatore capisce male.
   ============================================================ */
.avviso-ricostruzione {
    background: var(--accent-soft);
    /* NON `var(--accent)`: l'app di ruffini lo riscrive su :root (blu #3b82f6,
       vedi l'inizio di questo foglio), e il filo uscirebbe blu. `--accent-rgb`
       non e' scavalcato da nessuna delle tre app e vale l'oro vero del tema,
       254 168 0. Misurato in pagina, non dedotto. */
    border-left: 4px solid rgb(var(--accent-rgb));
    border-radius: var(--radius-sm);
    padding: 0.9rem 1.1rem;
    margin-bottom: 1.2rem;
    color: var(--ink);
    font-size: 0.95rem;
    line-height: 1.55;
    text-align: left;
}

.avviso-ricostruzione p {
    margin: 0 0 0.5rem;
}

.avviso-ricostruzione p:last-child {
    margin-bottom: 0;
}

.avviso-ricostruzione .avviso-titolo {
    font-weight: 800;
}

.avviso-ricostruzione .avviso-coda {
    color: var(--ink-2);
    font-size: 0.9rem;
}

/* Il campo e il pulsante spenti si devono VEDERE spenti: se restassero
   identici, il visitatore proverebbe a scriverci e penserebbe che il
   sito e' rotto — cioe' l'opposto di quello che dice l'avviso. */
math-field[read-only],
.calculate-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
