:root {
    --ink: #14231f;
    --muted: #68756f;
    --paper: #f5f1e8;
    --card: #fffdf8;
    --line: #d8d4c9;
    --coral: #e5684b;
    --teal: #276a62;
    --yellow: #f2c45e;
    --shadow: 0 18px 45px rgba(20, 35, 31, .09);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    font-family: Georgia, 'Times New Roman', serif;
}
body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    content: '';
    opacity: .45;
    background-image: radial-gradient(#b6afa0 0.7px, transparent 0.7px);
    background-size: 17px 17px;
    pointer-events: none;
}
button, input { font: inherit; }
button { cursor: pointer; }
.app-shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 24px 0; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-size: 1.16rem; letter-spacing: .02em; }
.brand img { width: 42px; height: 42px; }
.brand strong { font-family: 'Trebuchet MS', sans-serif; font-size: .82rem; letter-spacing: .1em; text-transform: uppercase; }
.status-pill { display: flex; align-items: center; gap: 8px; color: var(--muted); font: 600 .69rem 'Trebuchet MS', sans-serif; letter-spacing: .1em; text-transform: uppercase; cursor: pointer; }
.status-pill:hover, .status-pill:focus-visible { color: var(--teal); }
.status-pill:focus-visible { outline: 2px solid var(--coral); outline-offset: 5px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px rgba(39, 106, 98, .12); }
.install-dialog { width: min(420px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--ink); background: var(--card); }
.install-dialog::backdrop { background: rgba(20, 35, 31, .48); }
.install-dialog form { padding: 30px; }
.install-dialog h2 { margin: 10px 0 14px; font-size: 1.7rem; font-weight: 400; line-height: 1.1; }
.install-dialog p { margin: 0 0 25px; color: var(--muted); font-size: 1rem; line-height: 1.5; }
.install-dialog button { border: 0; padding: 12px 18px; color: #fffaf0; background: var(--coral); font: 700 .75rem 'Trebuchet MS', sans-serif; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.install-dialog button:hover, .install-dialog button:focus-visible { background: #c95138; }
.hero { max-width: 720px; padding: 40px 0 28px; animation: rise .65s ease both; }
.eyebrow, .section-label { color: var(--coral); font: 700 .7rem 'Trebuchet MS', sans-serif; letter-spacing: .16em; text-transform: uppercase; }
.eyebrow span { margin-left: 10px; color: var(--muted); }
h1 { margin: 17px 0 18px; font-size: clamp(3.2rem, 7vw, 6.4rem); font-weight: 400; line-height: .91; letter-spacing: -.065em; }
h1 em { color: var(--teal); font-style: italic; }
.intro { max-width: 465px; margin: 0; color: var(--muted); font-size: 1.14rem; line-height: 1.6; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(290px, .7fr); gap: 22px; align-items: stretch; }
.factor-card, .result-card { min-height: 340px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.factor-card { display: flex; flex-direction: column; justify-content: space-between; padding: clamp(24px, 4vw, 43px); padding-block: clamp(12px, 2vw, 22px); background: var(--card); }
.result-card { padding: clamp(24px, 4vw, 37px); padding-block: clamp(12px, 2vw, 19px); background: var(--teal); color: var(--card); animation: rise .65s .1s ease both; }
.card-heading { display: flex; justify-content: space-between; gap: 16px; }
.card-heading h2 { margin: 10px 0 0; font-size: 1.65rem; font-weight: 400; }
.card-mark { color: #9b9c8d; font: 700 .66rem 'Trebuchet MS', sans-serif; letter-spacing: .08em; }
.equation { display: flex; align-items: baseline; gap: 8px; margin: 54px 0 46px; white-space: nowrap; }
.equation label { display: inline-flex; align-items: baseline; gap: 3px; font-size: clamp(1.5rem, 4vw, 2.6rem); }
.equation input { width: 2.6em; padding: 3px 2px; border: 0; border-bottom: 2px solid var(--ink); border-radius: 0; outline: 0; color: var(--ink); background: transparent; font-size: 1em; text-align: center; transition: border-color .2s, background .2s; }
.equation input:focus { border-color: var(--coral); background: #fff4e8; }
.equation sup { font-size: .52em; }
.operator { font-size: 1.9rem; }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; color: var(--muted); font: .76rem 'Trebuchet MS', sans-serif; }
.card-footer button { display: inline-flex; align-items: center; gap: 18px; border: 0; padding: 14px 17px 14px 20px; color: #fffaf0; background: var(--coral); font: 700 .75rem 'Trebuchet MS', sans-serif; letter-spacing: .08em; text-transform: uppercase; transition: transform .2s, background .2s; }
.card-footer button:hover, .card-footer button:focus-visible { background: #c95138; transform: translateY(-2px); }
.card-footer button span:last-child { font-size: 1.15rem; }
.result-card .section-label { color: var(--yellow); }
.result-placeholder { margin-top: 67px; color: var(--yellow); font-size: clamp(1.9rem, 4vw, 3rem); line-height: 1.15; overflow-wrap: anywhere; }
.result-card.has-result .result-placeholder { color: #fffaf0; }
.explanation { max-width: 250px; margin: 25px 0 0; color: rgba(255, 253, 248, .7); font-size: .98rem; line-height: 1.5; }
.footer { display: flex; justify-content: space-between; margin: 70px 0 25px; color: #8b8b7e; font: .67rem 'Trebuchet MS', sans-serif; letter-spacing: .11em; text-transform: uppercase; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 730px) {
    .app-shell { width: min(100% - 28px, 540px); }
    .topbar { padding: 16px 0; }
    .status-pill { font-size: .58rem; }
    .hero { padding: 32px 0 21px; }
    h1 { font-size: clamp(3rem, 15vw, 5rem); }
    .workspace { grid-template-columns: 1fr; }
    .factor-card, .result-card { min-height: 0; }
    .result-card { min-height: 265px; }
    .result-placeholder { margin-top: 47px; }
    .footer { margin-top: 48px; }
}
@media (max-width: 430px) {
    .card-mark { display: none; }
    .equation { gap: 3px; margin: 45px 0 40px; }
    .equation label { font-size: clamp(1.22rem, 7vw, 1.8rem); }
    .operator { font-size: 1.4rem; }
    .card-footer { align-items: flex-start; flex-direction: column; }
    .card-footer button { width: 100%; justify-content: space-between; }
    .footer span:first-child { max-width: 120px; }
}
