:root {
    --bg: #080a12;
    --card: rgba(20, 24, 38, 0.82);
    --card2: rgba(30, 35, 54, 0.8);
    --text: #f7f8ff;
    --muted: #9da5bc;
    --border: rgba(255,255,255,.09);
    --accent: #8b5cf6;
    --accent2: #3b82f6;
    --green: #22c55e;
    --danger: #ef4444;
    --shadow: 0 20px 60px rgba(0,0,0,.35);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 10% 10%, rgba(139,92,246,.18), transparent 30%),
        radial-gradient(circle at 90% 20%, rgba(59,130,246,.15), transparent 30%),
        var(--bg);
    color: var(--text);
}

button,
textarea,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.app {
    width: min(1150px, calc(100% - 30px));
    margin: auto;
}

header {
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 25px;
    font-weight: 900;
}

.tagline {
    color: var(--muted);
    font-size: 13px;
    margin-top: 2px;
}

.icon-btn {
    width: 45px;
    height: 45px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--card);
    color: white;
}

.hero {
    padding: 55px 0 40px;
    text-align: center;
}

.badge {
    display: inline-block;
    padding: 8px 13px;
    border: 1px solid rgba(139,92,246,.35);
    background: rgba(139,92,246,.1);
    border-radius: 999px;
    color: #c4b5fd;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .6px;
}

h1 {
    font-size: clamp(42px, 7vw, 78px);
    line-height: .98;
    margin: 25px 0 20px;
    letter-spacing: -3px;
}

h1 span {
    background: linear-gradient(90deg, #a78bfa, #60a5fa);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero > p {
    max-width: 650px;
    margin: auto auto 30px;
    color: var(--muted);
    font-size: 17px;
}

.question-box {
    max-width: 850px;
    margin: auto;
    padding: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    text-align: left;
}

textarea {
    width: 100%;
    min-height: 125px;
    resize: vertical;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    padding: 20px;
    font-size: 18px;
}

textarea::placeholder,
input::placeholder {
    color: #707890;
}

.input-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
}

#charCount {
    color: var(--muted);
    font-size: 12px;
}

#solveBtn {
    border: 0;
    border-radius: 13px;
    padding: 13px 22px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: white;
    font-weight: 800;
}

.examples {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
}

.examples button,
.category-grid button {
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--muted);
    border-radius: 999px;
    padding: 9px 13px;
    transition: .2s;
}

button:hover {
    transform: translateY(-2px);
}

.examples button:hover,
.category-grid button:hover {
    color: white;
    border-color: rgba(139,92,246,.5);
}

.hidden {
    display: none !important;
}

.answer-section {
    margin: 25px 0 60px;
}

.result-card,
.interpretations,
.tool-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.result-top {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.result-top small {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 1px;
    font-weight: 800;
}

#questionShown {
    margin-top: 7px;
    font-size: 17px;
}

.favorite {
    border: 0;
    background: transparent;
    color: #fbbf24;
    font-size: 32px;
}

.answer-label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    margin-top: 35px;
}

.big-answer {
    font-size: clamp(40px, 7vw, 70px);
    line-height: 1;
    font-weight: 900;
    margin: 10px 0;
    background: linear-gradient(90deg, #fff, #b9c4ff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    word-break: break-word;
}

.answer-note {
    color: var(--muted);
}

.equation-box,
.working-box {
    margin-top: 25px;
    padding: 18px;
    border-radius: 16px;
    background: rgba(0,0,0,.18);
    border: 1px solid var(--border);
}

.equation-box strong {
    display: block;
    margin-bottom: 8px;
}

#equation {
    font-family: monospace;
    font-size: 18px;
}

.working-title {
    font-weight: 800;
    margin-bottom: 12px;
}

#working {
    color: #c4c9d8;
    line-height: 1.8;
}

.work-line {
    padding: 3px 0;
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.result-actions button,
.check-box button,
.tool-panel button {
    border: 1px solid var(--border);
    background: var(--card2);
    color: white;
    padding: 11px 15px;
    border-radius: 12px;
}

.check-box {
    margin-top: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.check-box input,
.tool-input {
    flex: 1;
    min-width: 180px;
    border: 1px solid var(--border);
    background: rgba(0,0,0,.2);
    color: white;
    outline: none;
    padding: 11px;
    border-radius: 12px;
}

#checkResult {
    width: 100%;
    font-weight: 700;
}

.interpretations {
    margin-top: 15px;
}

.interpretation {
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-top: 8px;
}

.tools,
.categories,
.history-section {
    margin: 60px 0;
}

h2 {
    margin-bottom: 20px;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.tool {
    text-align: left;
    padding: 20px;
    border: 1px solid var(--border);
    background: var(--card);
    color: white;
    border-radius: 18px;
    transition: .2s;
}

.tool span {
    display: block;
    font-size: 28px;
    margin-bottom: 12px;
}

.tool b {
    display: block;
}

.tool small {
    display: block;
    margin-top: 5px;
    color: var(--muted);
}

.tool:hover {
    border-color: rgba(139,92,246,.5);
    transform: translateY(-4px);
}

.tool-panel {
    margin-bottom: 50px;
}

.tool-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tool-panel-head button {
    padding: 8px 12px;
}

.tool-form {
    display: grid;
    gap: 10px;
    margin-top: 15px;
}

.tool-result {
    margin-top: 18px;
    padding: 18px;
    border-radius: 15px;
    background: rgba(139,92,246,.1);
    font-size: 18px;
}

.category-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-heading p {
    color: var(--muted);
}

#clearHistory {
    border: 1px solid var(--border);
    background: var(--card);
    color: #fca5a5;
    padding: 9px 13px;
    border-radius: 10px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 8px;
}

.history-question {
    font-weight: 700;
}

.history-answer {
    color: #a78bfa;
    margin-top: 3px;
}

.history-item button {
    border: 0;
    background: transparent;
    color: var(--muted);
}

footer {
    padding: 40px 0;
    border-top: 1px solid var(--border);
    color: var(--muted);
    display: flex;
    justify-content: space-between;
}

footer b {
    color: white;
}

body.light {
    --bg: #eef2ff;
    --card: rgba(255,255,255,.85);
    --card2: rgba(245,247,255,.95);
    --text: #121526;
    --muted: #667085;
    --border: rgba(0,0,0,.09);
}

body.light .big-answer {
    color: #171a2b;
}

body.light textarea,
body.light input {
    color: #171a2b;
}

body.light footer b {
    color: #171a2b;
}

@media (max-width: 800px) {
    .tool-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    h1 {
        letter-spacing: -2px;
    }
}

@media (max-width: 550px) {
    .app {
        width: min(100% - 18px, 1150px);
    }

    header {
        height: 70px;
    }

    .hero {
        padding-top: 35px;
    }

    .tool-grid {
        grid-template-columns: 1fr 1fr;
    }

    .result-card,
    .interpretations,
    .tool-panel {
        padding: 20px;
    }

    footer {
        flex-direction: column;
        gap: 8px;
    }

    .history-item {
        align-items: flex-start;
    }
}
/* =========================================================
   UPGRADE: random example button + new tool form bits
   ========================================================= */

.random-example {
    display: inline-block;
    margin-top: 14px;
    padding: 12px 22px;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #8b5cf6, #3b82f6);
    box-shadow: 0 4px 14px rgba(139, 92, 246, .45);
    transition: transform .12s ease, filter .12s ease;
}

.random-example:hover {
    transform: translateY(-2px);
    filter: brightness(1.12);
}

.random-example:active {
    transform: translateY(1px);
}

.tool-form hr {
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, .14);
    margin: 18px 0;
}

body.light .tool-form hr {
    border-top-color: rgba(0, 0, 0, .12);
}

.tool-form label {
    display: block;
    font-weight: 700;
    font-size: 14px;
    opacity: .85;
    margin-bottom: 6px;
}
