/* ==========================================================================
   NexaCalculator — Proportion Edition Styles (v1.5.3)
   Minimal, spacious, zero-clutter layout with crisp hierarchy.
   ========================================================================== */

.nexa-prop-shell [hidden] {
    display: none !important;
}

.nexa-prop-shell {
    width: 100%;
    padding: 22px 24px 18px;
    border-top-left-radius: 11px;
    border-top-right-radius: 11px;
    background: var(--bg-surface);
    color: var(--text-main);
    font-family: 'Inter', 'Inter Fallback', sans-serif;
}

/* --- TOP BAR --- */
.nexa-prop-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 16px;
}

.nexa-prop-tabs {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.nexa-prop-tab {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--text-sub);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 7px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.nexa-prop-tab:hover {
    color: var(--text-main);
}

.nexa-prop-tab.is-active {
    background: var(--primary);
    color: #ffffff;
}

.nexa-prop-tab:focus-visible,
.nexa-options-btn:focus-visible,
.nexa-seg-btn:focus-visible,
.nexa-notation-btn:focus-visible,
.nexa-scale-op-btn:focus-visible,
.nexa-theme-btn:focus-visible,
.nexa-drawer-toggle:focus-visible,
.nexa-inline-copy-btn:focus-visible,
.nexa-link-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* --- GEAR OPTIONS POPOVER --- */
.nexa-prop-options-anchor {
    position: relative;
    flex-shrink: 0;
}

.nexa-options-btn {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-sub);
    width: 36px;
    height: 36px;
    border-radius: 9px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.nexa-options-btn:hover,
.nexa-options-btn[aria-expanded="true"] {
    border-color: var(--primary);
    color: var(--primary);
}

.nexa-options-popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 296px;
    max-width: calc(100vw - 24px);
    padding: 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.nexa-options-popover[hidden] {
    display: none;
}

.nexa-opt-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nexa-opt-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.nexa-opt-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-sub);
}

.nexa-prop-select {
    appearance: none;
    background: var(--bg-body) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 9px center;
    border: 1px solid var(--border);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 5px 26px 5px 10px;
    border-radius: 8px;
    cursor: pointer;
}

.nexa-prop-segmented {
    display: inline-flex;
    align-items: center;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.nexa-prop-segmented--2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
}

.nexa-prop-segmented--3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
}

.nexa-seg-btn,
.nexa-notation-btn,
.nexa-scale-op-btn,
.nexa-theme-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--text-sub);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
    min-width: 0;
    max-width: 100%;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nexa-opt-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 7px 6px;
    white-space: normal;
    line-height: 1.2;
}

.nexa-opt-stack .opt-main {
    font-size: 0.8rem;
    font-weight: 700;
}

.nexa-opt-stack .opt-sub {
    font-size: 0.68rem;
    font-weight: 500;
    opacity: 0.78;
}

.nexa-seg-btn:hover:not(.is-active),
.nexa-notation-btn:hover:not(.is-active),
.nexa-scale-op-btn:hover:not(.is-active),
.nexa-theme-btn:hover:not(.is-active) {
    color: var(--text-main);
}

.nexa-seg-btn.is-active,
.nexa-notation-btn.is-active,
.nexa-scale-op-btn.is-active,
.nexa-theme-btn.is-active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 6px var(--ring);
}

.nexa-seg-btn.is-active .opt-sub,
.nexa-notation-btn.is-active .opt-sub {
    color: #ffffff;
    opacity: 0.88;
}

/* --- PROMPT ROW --- */
.nexa-prop-prompt-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin-bottom: 10px;
    min-height: 24px;
}

.nexa-prop-shell .nexa-prop-prompt {
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--text-sub);
    margin: 0;
    line-height: 1.3;
    min-width: 0;
}

.nexa-prompt-right {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    white-space: nowrap;
}

.nexa-mode-pill {
    appearance: none;
    border: 1px solid var(--sc-badge-border);
    background: var(--sc-badge-bg);
    color: var(--primary);
    font-family: inherit;
    font-size: 0.74rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.nexa-link-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--text-sub);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 2px 4px;
    cursor: pointer;
}

.nexa-link-btn:hover {
    color: var(--primary);
}

.nexa-link-danger:hover {
    color: var(--danger);
}

.nexa-dot-sep {
    color: var(--text-sub);
    opacity: 0.45;
}

/* --- SPACIOUS EQUATION STAGE --- */
.nexa-prop-stage {
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px 20px;
    margin-bottom: 14px;
}

.nexa-prop-equation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 22px;
}

.nexa-prop-side {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 0;
    max-width: 240px;
}

.nexa-prop-equation.is-fraction .nexa-prop-side {
    flex-direction: column;
    gap: 12px;
    max-width: 200px;
}

.nexa-prop-equation.is-fraction .nexa-prop-op {
    display: block;
    width: 100%;
    height: 3px;
    background: var(--text-main);
    border-radius: 2px;
    opacity: 0.65;
}

.nexa-prop-equation.is-colon .nexa-prop-side,
.nexa-prop-equation.is-inverse .nexa-prop-side {
    flex-direction: row;
    gap: 10px;
}

.nexa-prop-equation.is-colon .nexa-prop-op::before {
    content: ':';
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-sub);
    line-height: 1;
}

.nexa-prop-equation.is-inverse .nexa-prop-op::before {
    content: '\00d7';
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.nexa-prop-equals {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    flex-shrink: 0;
}

.nexa-prop-equals--sm {
    font-size: 1.6rem;
    align-self: flex-end;
    padding-bottom: 12px;
}

/* --- INPUTS --- */
.nexa-prop-field-wrap {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nexa-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2px;
    min-height: 18px;
}

.nexa-prop-var-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-sub);
}

.nexa-solve-tag {
    display: none;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--primary);
    color: #ffffff;
    max-width: 78%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nexa-prop-field-wrap.is-solved .nexa-solve-tag {
    display: inline-block;
}

.nexa-prop-input {
    width: 100%;
    height: 52px;
    padding: 0 12px;
    font-family: inherit;
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    color: var(--text-main);
    background: var(--bg-surface);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.nexa-prop-input::placeholder {
    color: var(--text-sub);
    opacity: 0.4;
    font-weight: 600;
}

.nexa-prop-input:focus {
    outline: none;
    border-color: var(--primary);
    border-style: solid;
    box-shadow: 0 0 0 3px var(--ring);
}

.nexa-prop-field-wrap.is-solved .nexa-prop-input {
    border: 2px dashed var(--primary);
    background: var(--bg-summary);
    color: var(--primary);
}

.nexa-prop-field-wrap.is-solved .nexa-prop-input::placeholder {
    color: var(--primary);
    opacity: 0.85;
    font-weight: 800;
}

.nexa-prop-field-wrap.is-solved .nexa-prop-var-label {
    color: var(--primary);
}

.nexa-prop-field-wrap.is-error .nexa-prop-input {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.16);
}

/* --- TAB 2 & TAB 3 GRIDS --- */
.nexa-prop-scale-grid {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 14px;
}

.nexa-prop-scale-grid .nexa-prop-field-wrap {
    flex: 1 1 0;
    min-width: 0;
    max-width: 190px;
}

.nexa-prop-colon-sep {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
    padding-bottom: 10px;
}

.nexa-prop-factor-wrap {
    max-width: 165px;
    width: 100%;
    padding-left: 14px;
    border-left: 1px dashed var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nexa-prop-three-grid {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.nexa-prop-three-group {
    flex: 1;
    min-width: 0;
}

.nexa-prop-three-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.nexa-prop-three-row .nexa-prop-field-wrap {
    flex: 1 1 0;
    min-width: 0;
}

.nexa-prop-three-row .nexa-prop-input {
    height: 46px;
    padding: 0 6px;
    font-size: 1.02rem;
}

.nexa-prop-colon-sm {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-sub);
    padding-bottom: 10px;
}

/* --- SINGLE-ROW ANSWER CARD --- */
.nexa-prop-output {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nexa-prop-result-card {
    padding: 16px 20px;
    background: var(--bg-summary);
    border: 1px solid var(--sc-badge-border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.nexa-prop-result-card.is-error {
    background: rgba(220, 38, 38, 0.05);
    border-color: rgba(220, 38, 38, 0.25);
}

.nexa-prop-result-card.is-false {
    background: rgba(217, 119, 6, 0.07);
    border-color: rgba(217, 119, 6, 0.34);
}

.nexa-answer-left {
    min-width: 0;
}

.nexa-answer-top {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.nexa-status-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--primary);
    color: #ffffff;
}

.nexa-prop-result-card.is-error .nexa-status-badge {
    background: var(--danger);
}

.nexa-prop-result-card.is-false .nexa-status-badge {
    background: #d97706;
}

.nexa-eq-summary {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-sub);
}

.nexa-primary-val {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
    word-break: break-word;
}

.nexa-prop-result-card.is-error .nexa-primary-val {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-sub);
}

.nexa-inline-copy-btn {
    appearance: none;
    border: 1px solid var(--sc-badge-border);
    background: var(--bg-surface);
    color: var(--primary);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 8px 13px;
    border-radius: 9px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nexa-inline-copy-btn:hover {
    background: var(--primary);
    color: #ffffff;
}

.nexa-prop-result-card.is-error .nexa-inline-copy-btn {
    display: none;
}

/* --- SINGLE COMBINED DRAWER --- */
.nexa-prop-drawer {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-surface);
    overflow: hidden;
}

.nexa-prop-drawer[hidden] {
    display: none;
}

.nexa-drawer-toggle {
    width: 100%;
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    padding: 11px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.nexa-drawer-toggle:hover {
    background: var(--bg-body);
}

.nexa-drawer-toggle .nexa-chevron {
    color: var(--text-sub);
    transition: transform 0.2s ease;
}

.nexa-drawer-toggle[aria-expanded="true"] .nexa-chevron {
    transform: rotate(180deg);
}

.nexa-drawer-body {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.nexa-drawer-body[hidden] {
    display: none;
}

.nexa-prop-shell .nexa-steps-list {
    margin: 0;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--text-main);
}

.nexa-step-math {
    display: inline-block;
    max-width: 100%;
    margin-top: 3px;
    padding: 3px 8px;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.nexa-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}

.nexa-metric-box {
    padding: 9px 11px;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.nexa-metric-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-sub);
    margin-bottom: 2px;
}

.nexa-metric-value {
    display: block;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-main);
    word-break: break-word;
}

.nexa-prop-visual {
    padding: 10px 12px;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.nexa-vis-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-sub);
    margin-bottom: 8px;
}

.nexa-vis-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.nexa-vis-row:last-child {
    margin-bottom: 0;
}

.nexa-vis-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-main);
    min-width: 72px;
    flex-shrink: 0;
}

.nexa-vis-track {
    flex: 1;
    height: 11px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
    display: flex;
}

.nexa-vis-seg {
    height: 100%;
    transition: width 0.25s ease;
}

.nexa-vis-seg--1 { background: var(--primary); }
.nexa-vis-seg--2 { background: #10b981; }
.nexa-vis-seg--3 { background: #f59e0b; }

.nexa-vis-pct {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-sub);
    min-width: 54px;
    text-align: right;
}

.nexa-drawer-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    padding-top: 2px;
}

/* --- CLEAN 4-BUTTON SINGLE-ROW UTILITY BAR OVERRIDE --- */
.calculator-utilities.prop-utilities-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

/* --- DARK THEME & REVERSE CONTRAST SUPPORT (WCAG AA/AAA Hardened) --- */
body.dark-theme .nexa-prop-shell {
    --prop-accent: var(--dark-accent, var(--gradient-start, #818cf8));
    background: var(--bg-surface);
    color: var(--text-main);
}

body.dark-theme .nexa-prop-stage,
body.dark-theme .nexa-prop-tabs,
body.dark-theme .nexa-prop-segmented,
body.dark-theme .nexa-step-math,
body.dark-theme .nexa-metric-box,
body.dark-theme .nexa-prop-visual {
    background: var(--bg-body);
    border-color: var(--border);
    color: var(--text-main);
}

body.dark-theme .nexa-prop-select {
    background-color: var(--bg-body);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    border-color: var(--border);
    color: var(--text-main);
}

body.dark-theme .nexa-prop-input,
body.dark-theme .nexa-options-btn,
body.dark-theme .nexa-prop-drawer,
body.dark-theme .nexa-inline-copy-btn {
    background: #17212e;
    border-color: #2c3b4f;
    color: #f8fafc;
}

body.dark-theme .nexa-options-popover {
    background: #17212e;
    border-color: #2c3b4f;
    color: #f8fafc;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.55);
}

body.dark-theme .nexa-prop-input:focus {
    border-color: var(--prop-accent);
    box-shadow: 0 0 0 3px var(--ring);
}

body.dark-theme .nexa-prop-input::placeholder {
    color: #94a3b8;
    opacity: 0.65;
}

body.dark-theme .nexa-prop-equation.is-fraction .nexa-prop-op {
    background: #cbd5e1;
    opacity: 0.75;
}

body.dark-theme .nexa-prop-equals,
body.dark-theme .nexa-prop-colon-sep,
body.dark-theme .nexa-prop-equation.is-inverse .nexa-prop-op::before,
body.dark-theme .nexa-prop-field-wrap.is-solved .nexa-prop-var-label,
body.dark-theme .nexa-prop-field-wrap.is-solved .nexa-prop-input::placeholder,
body.dark-theme .nexa-inline-copy-btn,
body.dark-theme .nexa-mode-pill,
body.dark-theme .nexa-link-btn:hover,
body.dark-theme .nexa-options-btn:hover,
body.dark-theme .nexa-options-btn[aria-expanded="true"] {
    color: var(--prop-accent);
}

body.dark-theme .nexa-options-btn:hover,
body.dark-theme .nexa-options-btn[aria-expanded="true"],
body.dark-theme .nexa-inline-copy-btn {
    border-color: var(--sc-badge-border);
}

body.dark-theme .nexa-inline-copy-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

body.dark-theme .nexa-link-danger:hover {
    color: #f87171;
}

body.dark-theme .nexa-prop-result-card {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--sc-badge-border);
}

body.dark-theme .nexa-prop-result-card.is-error {
    background: rgba(220, 38, 38, 0.14);
    border-color: rgba(248, 113, 113, 0.4);
}

body.dark-theme .nexa-prop-result-card.is-error .nexa-primary-val {
    color: #fca5a5;
}

body.dark-theme .nexa-prop-result-card.is-false {
    background: rgba(217, 119, 6, 0.16);
    border-color: rgba(251, 191, 36, 0.42);
}

body.dark-theme .nexa-prop-field-wrap.is-solved .nexa-prop-input {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
    border-color: var(--prop-accent);
}

body.dark-theme .nexa-seg-btn.is-active,
body.dark-theme .nexa-notation-btn.is-active,
body.dark-theme .nexa-scale-op-btn.is-active,
body.dark-theme .nexa-theme-btn.is-active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

body.dark-theme .nexa-seg-btn.is-active .opt-sub,
body.dark-theme .nexa-notation-btn.is-active .opt-sub {
    color: #ffffff;
    opacity: 0.9;
}

body.dark-theme .nexa-drawer-toggle:hover {
    background: rgba(255, 255, 255, 0.04);
}

/* --- HIGH CONTRAST / REVERSE CONTRAST MODE (AAA Yellow/White on Pure Black) --- */
body.reverse-contrast .nexa-prop-shell {
    background: #000000;
    color: #ffffff;
}

body.reverse-contrast .nexa-prop-stage,
body.reverse-contrast .nexa-prop-tabs,
body.reverse-contrast .nexa-prop-segmented,
body.reverse-contrast .nexa-step-math,
body.reverse-contrast .nexa-metric-box,
body.reverse-contrast .nexa-prop-visual,
body.reverse-contrast .nexa-prop-input,
body.reverse-contrast .nexa-options-btn,
body.reverse-contrast .nexa-options-popover,
body.reverse-contrast .nexa-prop-drawer,
body.reverse-contrast .nexa-inline-copy-btn {
    background: #000000;
    border-color: #ffffff;
    color: #ffffff;
}

body.reverse-contrast .nexa-prop-select {
    background-color: #000000;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    border-color: #ffffff;
    color: #ffffff;
}

body.reverse-contrast .nexa-prop-input::placeholder {
    color: #d4d4d8;
    opacity: 0.8;
}

body.reverse-contrast .nexa-prop-equation.is-fraction .nexa-prop-op {
    background: #ffffff;
    opacity: 1;
}

body.reverse-contrast .nexa-prop-result-card {
    background: #000000;
    border: 2px solid #facc15;
}

body.reverse-contrast .nexa-prop-tab.is-active,
body.reverse-contrast .nexa-seg-btn.is-active,
body.reverse-contrast .nexa-notation-btn.is-active,
body.reverse-contrast .nexa-scale-op-btn.is-active,
body.reverse-contrast .nexa-theme-btn.is-active,
body.reverse-contrast .nexa-status-badge,
body.reverse-contrast .nexa-solve-tag {
    background: #facc15;
    color: #000000;
    font-weight: 800;
}

body.reverse-contrast .nexa-seg-btn.is-active .opt-sub,
body.reverse-contrast .nexa-notation-btn.is-active .opt-sub {
    color: #000000;
    opacity: 0.92;
}

body.reverse-contrast .nexa-prop-field-wrap.is-solved .nexa-prop-input {
    border-color: #facc15;
    color: #facc15;
    background: #000000;
}

body.reverse-contrast .nexa-prop-field-wrap.is-solved .nexa-prop-input::placeholder,
body.reverse-contrast .nexa-prop-field-wrap.is-solved .nexa-prop-var-label,
body.reverse-contrast .nexa-prop-equals,
body.reverse-contrast .nexa-prop-colon-sep,
body.reverse-contrast .nexa-prop-equation.is-inverse .nexa-prop-op::before,
body.reverse-contrast .nexa-mode-pill,
body.reverse-contrast .nexa-link-btn:hover,
body.reverse-contrast .nexa-options-btn:hover,
body.reverse-contrast .nexa-options-btn[aria-expanded="true"] {
    color: #facc15;
}

body.reverse-contrast .nexa-mode-pill,
body.reverse-contrast .nexa-options-btn:hover,
body.reverse-contrast .nexa-options-btn[aria-expanded="true"] {
    border-color: #facc15;
}

body.reverse-contrast .nexa-inline-copy-btn:hover {
    background: #facc15;
    border-color: #facc15;
    color: #000000;
}

body.reverse-contrast .nexa-drawer-toggle:hover {
    background: #141414;
}

/* --- RESPONSIVE MOBILE & SMALL DEVICES (680px -> 320px) --- */
@media (max-width: 680px) {
    .nexa-prop-shell {
        padding: 16px 14px 12px;
        border-radius: 0;
    }

    .nexa-prop-topbar {
        gap: 8px;
        margin-bottom: 12px;
    }

    .nexa-prop-tabs {
        flex: 1 1 auto;
        min-width: 0;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .nexa-prop-tab {
        padding: 8px 4px;
        font-size: 0.76rem;
        text-align: center;
        min-width: 0;
        white-space: normal;
        line-height: 1.2;
    }

    .nexa-options-btn {
        width: 40px;
        height: 40px;
    }

    .nexa-options-popover {
        width: min(296px, calc(100vw - 24px));
    }

    /* Prevent iOS Safari auto-zoom on focus (requires >= 16px) */
    .nexa-prop-select,
    .nexa-prop-input,
    .nexa-prop-three-row .nexa-prop-input {
        font-size: 16px;
    }

    .nexa-prop-stage {
        padding: 16px 12px;
    }

    .nexa-prop-equation {
        gap: 10px;
    }

    .nexa-prop-equation.is-fraction .nexa-prop-side {
        max-width: none;
    }

    .nexa-prop-equation.is-colon,
    .nexa-prop-equation.is-inverse {
        flex-direction: column;
        gap: 10px;
    }

    .nexa-prop-equation.is-colon .nexa-prop-side,
    .nexa-prop-equation.is-inverse .nexa-prop-side {
        width: 100%;
        max-width: 100%;
    }

    /* Keep First : Second side-by-side; move Factor cleanly to full row below */
    .nexa-prop-scale-grid {
        flex-wrap: wrap;
        gap: 10px;
    }

    .nexa-prop-scale-grid .nexa-prop-field-wrap {
        max-width: none;
    }

    .nexa-prop-factor-wrap {
        flex: 1 1 100%;
        border-left: 0;
        border-top: 1px dashed var(--border);
        padding-left: 0;
        padding-top: 10px;
        max-width: 100%;
    }

    .nexa-prop-three-grid {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .nexa-prop-equals--sm {
        align-self: center;
        padding-bottom: 0;
    }

    .nexa-prop-result-card {
        padding: 14px 14px;
    }

    .nexa-primary-val {
        font-size: 1.4rem;
    }

    .nexa-metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }

    .calculator-utilities.prop-utilities-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 420px) {
    .nexa-prop-shell {
        padding: 14px 10px 10px;
    }

    .nexa-prop-tab {
        padding: 7px 3px;
        font-size: 0.72rem;
    }

    .nexa-prop-prompt-row .nexa-prop-segmented {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        flex: 1 1 auto;
        min-width: 0;
    }

    .nexa-scale-op-btn {
        padding: 6px 4px;
        font-size: 0.72rem;
    }

    .nexa-prop-input {
        height: 46px;
        padding: 0 6px;
    }

    .nexa-prop-equals {
        font-size: 1.55rem;
    }

    .nexa-prop-colon-sep {
        font-size: 1.45rem;
        padding-bottom: 8px;
    }

    .nexa-vis-label {
        min-width: 58px;
        font-size: 0.72rem;
    }

    .nexa-vis-pct {
        min-width: 44px;
        font-size: 0.72rem;
    }
}

/* --- PRINT: AUTO-EXPAND STEPS --- */
@media print {
    .nexa-prop-topbar,
    .nexa-prompt-right,
    .nexa-inline-copy-btn,
    .nexa-drawer-foot {
        display: none !important;
    }

    .nexa-drawer-body {
        display: flex !important;
    }
}
