.kelly-page { padding-bottom: 0; }
.kelly-page a { color: var(--accent-cyan); }
.kelly-page button, .kelly-page select, .kelly-page input {
    font: inherit;
    color: var(--fg);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    min-height: 44px;
    padding: 9px 12px;
}
.kelly-page button { cursor: pointer; }
.kelly-page button:hover { border-color: var(--accent); }
.kelly-page button:disabled { opacity: 0.45; cursor: default; }
.kelly-page :focus-visible { outline: 2px solid var(--accent-cyan); outline-offset: 3px; }
.kelly-page [hidden] { display: none !important; }
.kelly-header { display: flex; align-items: center; flex-wrap: wrap; gap: 20px; padding: 16px max(20px, calc((100vw - 1260px) / 2)); border-bottom: 1px solid var(--border); }
.kelly-header .brand { margin-right: auto; }
.kelly-language { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.kelly-main { width: min(1260px, calc(100% - 40px)); margin: 36px auto; }
.kelly-heading { margin-bottom: 28px; max-width: 940px; }
.kelly-heading h1 { font-size: clamp(26px, 3vw, 38px); font-weight: 650; letter-spacing: -0.025em; line-height: 1.18; margin: 8px 0 18px; }
.kelly-subtitle { color: var(--accent); font-size: 14px; margin-bottom: 0; }
.kelly-heading > p:not(.kelly-subtitle) { color: var(--fg-muted); }
.kelly-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.kelly-actions a { padding: 10px 2px; }
#kelly-example { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 650; }
.kelly-heading .kelly-example-note { border-left: 3px solid var(--accent); padding-left: 12px; color: var(--accent); }
.kelly-layout { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.kelly-page fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 22px; padding: 20px; background: var(--bg-elev); min-width: 0; }
.kelly-page legend { font-size: 17px; font-weight: 650; padding: 0 8px; }
.kelly-field-grid, .kelly-meta-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.kelly-meta-fields { margin: 0 0 24px; }
.kelly-meta-fields label, .kelly-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.kelly-field label, .kelly-meta-fields label > span { font-size: 13px; color: var(--fg-muted); }
.kelly-input-unit { position: relative; }
.kelly-field input, .kelly-field select, .kelly-meta-fields input, .kelly-meta-fields select { width: 100%; min-width: 0; }
.kelly-field input { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-variant-numeric: tabular-nums; padding-right: 52px; }
.kelly-unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; font-size: 12px; color: var(--fg-muted); }
.kelly-field input::-webkit-inner-spin-button { -webkit-appearance: none; }
.kelly-field input { appearance: textfield; -moz-appearance: textfield; }
.kelly-field [aria-invalid="true"] { border-color: var(--fail); }
.kelly-field-error { color: var(--fail); font-size: 12px; line-height: 1.5; }
.kelly-multipliers { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.kelly-multipliers button { font-size: 12px; padding: 8px; flex: 1; }
.kelly-multipliers button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.kelly-results { border: 1px solid var(--border); border-top: 3px solid var(--accent); background: var(--bg-elev); border-radius: 8px; padding: 24px; }
.kelly-page h2 { font-size: 21px; font-weight: 650; margin: 0 0 16px; }
.kelly-page h3 { font-size: 14px; margin: 26px 0 12px; }
#kelly-status { border-left: 3px solid var(--neutral); padding: 8px 12px; font-size: 14px; }
#kelly-status[data-status="VALID"] { border-color: var(--pass); color: var(--pass); }
#kelly-status[data-status="VALID_CAPPED"], #kelly-status[data-status="SIZE_ROUNDS_TO_ZERO"], #kelly-status[data-status="AGGREGATE_RISK_EXHAUSTED"] { border-color: var(--accent); color: var(--accent); }
#kelly-status[data-status="NO_POSITIVE_EDGE"], #kelly-status[data-status="INVALID_INPUT"] { border-color: var(--fail); color: var(--fail); }
.kelly-quantity { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; border-bottom: 1px solid var(--border); padding: 10px 0 18px; }
.kelly-quantity > span { font-size: 14px; }
#kelly-shares { font: 600 clamp(28px, 4vw, 48px)/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace; overflow-wrap: anywhere; }
.kelly-results dl { margin: 0; }
.kelly-results dl > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.kelly-results dd { margin: 0; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-variant-numeric: tabular-nums; }
.kelly-results dt { color: var(--fg-muted); }
.kelly-ladder-row { position: relative; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.kelly-ladder-row > div { display: flex; gap: 10px; justify-content: space-between; position: relative; }
.kelly-ladder-row strong { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-variant-numeric: tabular-nums; }
.kelly-ladder-bar { display: block; height: 3px; margin-top: 8px; background: var(--accent-cyan); max-width: 100%; }
.kelly-ladder-row:last-child .kelly-ladder-bar { background: var(--accent); }
.kelly-negative { color: var(--fail); }
.kelly-note { color: var(--fg-muted); font-size: 12px; line-height: 1.6; }
#kelly-constraints { display: flex; gap: 6px; flex-wrap: wrap; padding: 0; list-style: none; margin: 10px 0 24px; }
#kelly-constraints li { font-size: 12px; border: 1px solid var(--border); border-radius: 4px; padding: 6px 10px; }
.kelly-page summary { cursor: pointer; padding: 12px 0; font-size: 14px; font-weight: 600; }
.kelly-warnings { color: var(--fg-muted); font-size: 12px; padding-left: 18px; line-height: 1.65; }
.kelly-warnings li + li { margin-top: 8px; }
#kelly-copy-status { font-size: 13px; min-height: 0; }
.kelly-chart-section { margin-top: 30px; padding: 24px; border: 1px solid var(--border); border-radius: 8px; }
.kelly-chart-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; }
.kelly-chart-heading label { display: flex; gap: 12px; align-items: center; font-size: 13px; }
.kelly-chart-heading h2 { margin: 0; }
#kelly-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
#kelly-chart text { fill: var(--fg-muted); font: 12px ui-monospace, "SFMono-Regular", Consolas, monospace; }
.kelly-chart-legend { display: flex; flex-wrap: wrap; gap: 22px; margin: 10px 0; font-size: 12px; }
.kelly-chart-legend span::before { content: ""; display: inline-block; width: 18px; height: 3px; background: var(--series); vertical-align: middle; margin-right: 7px; }
.kelly-table-scroll { overflow-x: auto; }
#kelly-sensitivity-table { width: 100%; border-collapse: collapse; font-size: 13px; }
#kelly-sensitivity-table td, #kelly-sensitivity-table th { padding: 10px; text-align: right; border-bottom: 1px solid var(--border); }
#kelly-sensitivity-table td { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }
.kelly-methodology { margin: 30px 0; max-width: 960px; font-size: 14px; color: var(--fg-muted); line-height: 1.75; }
.kelly-methodology summary { color: var(--fg); }
.kelly-footer { border-top: 1px solid var(--border); padding: 14px 0; font-size: 13px; }
.kelly-footer small { color: var(--fg-muted); }
@media (max-width: 850px) {
    .kelly-layout { grid-template-columns: 1fr; }
    .kelly-header { gap: 14px; padding: 12px 20px; }
    .kelly-main { margin: 24px auto; }
}
@media (max-width: 480px) {
    .kelly-main { width: calc(100% - 28px); }
    .kelly-page fieldset { padding: 14px; }
    .kelly-field-grid, .kelly-meta-fields { gap: 16px; grid-template-columns: 1fr; }
    .kelly-header > a:not(.brand) { font-size: 12px; }
    .kelly-results, .kelly-chart-section { padding: 18px; }
    .kelly-chart-heading label { flex-wrap: wrap; }
    .kelly-results dl > div { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .kelly-results dd { text-align: right; overflow-wrap: anywhere; }
}
