:root {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #172033;
    background: #f4f7fb;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

.page {
    width: min(900px, calc(100% - 32px));
    margin: 0 auto;
    padding: 48px 0;
}

.hero {
    margin-bottom: 28px;
}

.eyebrow {
    margin: 0 0 8px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #405f9f;
}

h1 {
    margin: 0;
    font-size: clamp(2.2rem, 5vw, 4rem);
    line-height: 1;
}

.intro {
    max-width: 700px;
    font-size: 1.1rem;
    line-height: 1.6;
    color: #4b5873;
}

.tool-card {
    padding: 28px;
    border: 1px solid #d9e2f2;
    border-radius: 20px;
    background: white;
    box-shadow: 0 18px 40px rgba(23, 32, 51, 0.08);
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}

.expression-entry {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: stretch;
}

.input-with-symbols {
    position: relative;
}

input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #bac7dd;
    border-radius: 12px;
    font: inherit;
}

.input-with-symbols input {
    padding-right: 132px;
}

input:focus {
    outline: 3px solid rgba(64, 95, 159, 0.25);
    border-color: #405f9f;
}

.inline-symbol-buttons {
    position: absolute;
    top: 50%;
    right: 8px;
    display: flex;
    gap: 6px;
    transform: translateY(-50%);
}

button {
    margin-top: 16px;
    padding: 12px 18px;
    border: 0;
    border-radius: 12px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    color: white;
    background: #405f9f;
}

button:hover {
    background: #314c82;
}

.symbol-button {
    width: 34px;
    height: 34px;
    margin-top: 0;
    padding: 0;
    border: 1px solid #bac7dd;
    border-radius: 999px;
    background: #eef3ff;
    color: #172033;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
}

.symbol-button:hover {
    background: #dfe8fb;
}

.primary-button {
    margin-top: 0;
    white-space: nowrap;
}

.input-note {
    margin: 8px 0 0;
    color: #69758d;
    font-size: 0.9rem;
    line-height: 1.4;
}

.output-panel {
    margin-top: 24px;
    padding: 22px;
    border-radius: 16px;
    background: #f4f7fb;
}

.answer-block {
    margin-bottom: 22px;
}

.answer-kicker {
    margin: 0 0 8px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #4b5873;
}

.main-answer {
    margin: 0;
    padding: 14px 16px;
    border: 1px solid #bac7dd;
    border-radius: 14px;
    background: white;
    font-family: Consolas, "Courier New", monospace;
    font-size: 1.1rem;
    font-weight: 600;
    color: #172033;
    white-space: nowrap;
    overflow-x: auto;
}

.main-answer.empty-output {
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    color: #69758d;
}

.working-section h2 {
    margin: 0 0 8px;
    font-size: 1rem;
    color: #4b5873;
}

.working-grid {
    display: grid;
    grid-template-columns: minmax(260px, 1.5fr) minmax(240px, 1fr);
    border: 1px solid #d9e2f2;
    border-radius: 12px;
    overflow: hidden;
    background: white;
}

.working-header {
    padding: 10px 12px;
    font-weight: 700;
    background: #eef3ff;
    border-bottom: 1px solid #d9e2f2;
}

.working-expression,
.working-law {
    padding: 12px;
    border-top: 1px solid #eef2f8;
}

.working-expression {
    font-family: Consolas, "Courier New", monospace;
    font-size: 1.05rem;
    white-space: nowrap;
    overflow-x: auto;
}

.working-law {
    color: #4b5873;
    line-height: 1.4;
}

.working-expression.start-row,
.working-law.start-row {
    background: #f8fbff;
}

.working-expression.step-row {
    background: white;
}

.working-law.step-row {
    background: #fbfdff;
}

.working-expression.no-change-row,
.working-law.no-change-row {
    background: #f7f7f8;
    color: #69758d;
}

.law-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.law-line {
    line-height: 1.4;
}

.working-note {
    margin: 10px 0 0;
    color: #69758d;
    font-size: 0.9rem;
    line-height: 1.4;
}

.empty-output {
    color: #69758d;
}

@media (max-width: 720px) {
    .page {
        width: min(100% - 24px, 900px);
        padding: 28px 0;
    }

    .tool-card {
        padding: 20px;
    }

    .expression-entry {
        grid-template-columns: 1fr;
    }

    .input-with-symbols input {
        padding-right: 132px;
    }

    .primary-button {
        width: 100%;
    }

    .main-answer {
        font-size: 1.35rem;
    }

    .working-grid {
        grid-template-columns: 1fr;
    }

    .working-header:nth-child(2) {
        display: none;
    }

    .working-law {
        border-top: 0;
        padding-top: 0;
    }
}