.tool-widget:has(.average-calc-app) { padding: 0; overflow: hidden; border: 0; background: transparent; box-shadow: none; }
.average-calc-app { --avg-accent: #38bdf8; --avg-border: rgba(148, 163, 184, .18); --avg-muted: #94a3b8; width: 100%; }
.avg-shell {
    padding: 1.15rem; border: 1px solid var(--avg-border); border-radius: 20px;
    background: radial-gradient(circle at 0 0, rgba(14, 165, 233, .15), transparent 35%), linear-gradient(180deg, #111827, #0b1220);
    box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
}
.avg-head, .avg-head-actions, .avg-card-head, .avg-card-head > div, .avg-input-tools, .avg-results-head, .avg-distribution-head, .avg-track-labels {
    display: flex; align-items: center; justify-content: space-between; gap: .7rem; flex-wrap: wrap;
}
.avg-head { margin-bottom: 1rem; }
.avg-eyebrow { margin: 0 0 .2rem; color: var(--avg-accent); font-size: .68rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.avg-head h2 { margin: 0; color: #f8fafc; font-size: 1.2rem; }
.avg-head p:not(.avg-eyebrow) { margin: .25rem 0 0; color: var(--avg-muted); font-size: .78rem; }
.avg-text-btn { border: 0; padding: .2rem 0; background: transparent; color: #7dd3fc; font: inherit; font-size: .75rem; font-weight: 800; cursor: pointer; }
.avg-text-btn:hover { color: #e0f2fe; }
.avg-text-btn--danger { color: #fca5a5; }
.avg-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 1rem; }
.avg-card { min-width: 0; padding: 1rem; border: 1px solid var(--avg-border); border-radius: 16px; background: rgba(15, 23, 42, .76); }
.avg-card-head { margin-bottom: .75rem; }
.avg-card-head h3, .avg-results-head h3 { margin: 0; color: #f1f5f9; font-size: .9rem; }
.avg-step { width: 1.4rem; height: 1.4rem; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(145deg, #38bdf8, #0284c7); color: #07111f; font-size: .7rem; font-weight: 900; }
.avg-detected { padding: .24rem .55rem; border-radius: 999px; background: rgba(56, 189, 248, .09); color: #7dd3fc; font-size: .66rem; font-weight: 800; }
.avg-detected.has-error { background: rgba(248, 113, 113, .09); color: #fca5a5; }
.avg-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.avg-input-card textarea {
    width: 100%; min-height: 180px; box-sizing: border-box; resize: vertical; padding: .85rem;
    border: 1px solid var(--avg-border); border-radius: 12px; background: rgba(2, 8, 20, .62); color: #f8fafc;
    font: inherit; font-size: .92rem; line-height: 1.6;
}
.avg-input-card textarea:focus { outline: 0; border-color: rgba(56, 189, 248, .65); box-shadow: 0 0 0 3px rgba(14, 165, 233, .14); }
.avg-help { margin: .45rem 0 0; color: var(--avg-muted); font-size: .68rem; line-height: 1.4; }
.avg-input-tools { justify-content: flex-start; margin-top: .75rem; }
.avg-tool-btn { padding: .4rem .65rem; border: 1px solid var(--avg-border); border-radius: 9px; background: rgba(30, 41, 59, .62); color: #cbd5e1; font-size: .68rem; font-weight: 800; cursor: pointer; }
.avg-tool-btn:hover { border-color: rgba(56, 189, 248, .45); color: #7dd3fc; }
.avg-variance-select { display: inline-flex; align-items: center; gap: .4rem; margin-left: auto; color: var(--avg-muted); font-size: .68rem; }
.avg-variance-select select { min-height: 34px; padding: .3rem .6rem; border: 1px solid var(--avg-border); border-radius: 8px; background: #111827; color: #e2e8f0; font: inherit; font-size: .7rem; }
.avg-primary-btn { width: 100%; min-height: 46px; margin-top: .8rem; border: 0; border-radius: 11px; background: linear-gradient(135deg, #0ea5e9, #6366f1); color: #fff; font: inherit; font-weight: 800; cursor: pointer; }
.avg-primary-btn:hover { filter: brightness(1.06); }
.avg-error { margin-top: .65rem; padding: .65rem .75rem; border: 1px solid rgba(248, 113, 113, .3); border-radius: 9px; background: rgba(248, 113, 113, .08); color: #fca5a5; font-size: .74rem; }
.avg-summary-card { display: flex; flex-direction: column; }
.avg-mean-hero { flex: 1; min-height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; margin-bottom: .75rem; border: 1px solid rgba(56, 189, 248, .18); border-radius: 14px; background: radial-gradient(circle, rgba(14, 165, 233, .14), transparent 68%); text-align: center; }
.avg-mean-hero span { color: var(--avg-muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; }
.avg-mean-hero strong { margin: .2rem 0; max-width: 100%; color: #7dd3fc; font-size: clamp(1.8rem, 4vw, 2.8rem); letter-spacing: -.05em; overflow-wrap: anywhere; }
.avg-mean-hero small { color: var(--avg-muted); font-size: .68rem; }
.avg-core-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.avg-core-stats > div, .avg-stat-grid > div { min-width: 0; padding: .65rem .7rem; border: 1px solid rgba(148, 163, 184, .1); border-radius: 10px; background: rgba(2, 8, 20, .3); }
.avg-core-stats span, .avg-stat-grid span { display: block; color: var(--avg-muted); font-size: .65rem; }
.avg-core-stats strong, .avg-stat-grid strong { display: block; margin-top: .18rem; color: #e2e8f0; font-size: .8rem; overflow-wrap: anywhere; }
.avg-results { margin-top: 1rem; padding: 1rem; border: 1px solid rgba(52, 211, 153, .18); border-radius: 16px; background: rgba(6, 78, 59, .06); }
.avg-results-head { margin-bottom: .75rem; }
.avg-results-head > span { color: #86efac; font-size: .68rem; font-weight: 800; }
.avg-stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .55rem; }
.avg-distribution { margin-top: .9rem; padding: .8rem; border: 1px solid var(--avg-border); border-radius: 12px; background: rgba(2, 8, 20, .28); }
.avg-distribution-head { margin-bottom: 1.45rem; color: #cbd5e1; font-size: .72rem; font-weight: 800; }
.avg-distribution-head small { color: var(--avg-muted); font-weight: 600; }
.avg-track { position: relative; height: 8px; border-radius: 999px; background: rgba(148, 163, 184, .16); }
.avg-track-fill { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(90deg, #0ea5e9, #34d399); opacity: .75; }
.avg-marker { position: absolute; top: 50%; width: 12px; height: 12px; transform: translate(-50%, -50%); border: 2px solid #0b1220; border-radius: 50%; background: #fff; }
.avg-marker b { position: absolute; bottom: calc(100% + .32rem); left: 50%; transform: translateX(-50%); color: #cbd5e1; font-size: .58rem; font-style: normal; white-space: nowrap; }
.avg-marker--mean { background: #38bdf8; }
.avg-marker--median { background: #34d399; }
.avg-track-labels { margin-top: .45rem; color: var(--avg-muted); font-size: .65rem; }
.average-calc-app button:focus-visible, .average-calc-app select:focus-visible { outline: 3px solid rgba(56, 189, 248, .45); outline-offset: 3px; }
@media (max-width: 900px) { .avg-grid { grid-template-columns: 1fr; } .avg-stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) {
    .avg-shell { padding: .85rem; border-radius: 16px; }
    .avg-input-tools { align-items: stretch; }
    .avg-variance-select { width: 100%; margin-left: 0; justify-content: space-between; }
    .avg-variance-select select { flex: 1; }
    .avg-stat-grid { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { .average-calc-app *, .average-calc-app *::before, .average-calc-app *::after { transition-duration: .01ms !important; } }
