.npgy-app {
    --npgy-primary: #174a73;
    --npgy-primary-dark: #103652;
    --npgy-accent: #2f7db4;
    --npgy-soft: #eef5fa;
    --npgy-softer: #f7fafc;
    --npgy-border: #c8d6e2;
    --npgy-text: #1d2730;
    --npgy-muted: #5c6872;
    --npgy-success: #17643a;
    --npgy-success-bg: #edf8f1;
    --npgy-error: #a61b1b;
    --npgy-error-bg: #fff1f1;
    --npgy-warning: #805100;
    --npgy-warning-bg: #fff7e6;
    --npgy-radius: 14px;
    max-width: 1040px;
    margin: 1.5rem auto;
    overflow: hidden;
    border: 1px solid var(--npgy-border);
    border-radius: var(--npgy-radius);
    background: #fff;
    box-shadow: 0 10px 32px rgba(20, 54, 80, 0.09);
    color: var(--npgy-text);
    font-family: inherit;
    line-height: 1.55;
}

.npgy-app *,
.npgy-app *::before,
.npgy-app *::after {
    box-sizing: border-box;
}

.npgy-header {
    padding: 1.5rem clamp(1rem, 3vw, 2rem);
    background: linear-gradient(135deg, var(--npgy-primary-dark), var(--npgy-primary));
    color: #fff;
}

.npgy-eyebrow {
    margin: 0 0 0.3rem;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.npgy-title {
    margin: 0;
    color: #fff;
    font-size: clamp(1.55rem, 3.5vw, 2.25rem);
    line-height: 1.2;
}

.npgy-lead {
    max-width: 760px;
    margin: 0.5rem 0 0;
    color: rgba(255, 255, 255, 0.92);
}

.npgy-setup {
    display: grid;
    gap: 1rem;
    padding: 1.2rem clamp(1rem, 3vw, 2rem);
    border-bottom: 1px solid var(--npgy-border);
    background: var(--npgy-softer);
}

.npgy-mode-group,
.npgy-field {
    min-width: 0;
}

.npgy-label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 750;
}

.npgy-mode-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.25rem;
    border: 1px solid var(--npgy-border);
    border-radius: 10px;
    background: #fff;
}

.npgy-mode-tab {
    min-height: 42px;
    padding: 0.55rem 0.9rem;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--npgy-primary-dark);
    cursor: pointer;
    font: inherit;
    font-weight: 750;
}

.npgy-mode-tab:hover {
    background: var(--npgy-soft);
}

.npgy-mode-tab.is-active {
    border-color: var(--npgy-primary);
    background: var(--npgy-primary);
    color: #fff;
}

.npgy-mode-description {
    margin: 0.45rem 0 0;
    color: var(--npgy-muted);
    font-size: 0.92rem;
}

.npgy-filter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.npgy-select,
.npgy-input {
    width: 100%;
    min-height: 46px;
    padding: 0.65rem 0.75rem;
    border: 1px solid #aebfcd;
    border-radius: 8px;
    background: #fff;
    color: var(--npgy-text);
    font: inherit;
}

.npgy-select:focus,
.npgy-input:focus,
.npgy-button:focus-visible,
.npgy-mode-tab:focus-visible,
.npgy-text-button:focus-visible,
.npgy-option:focus-within,
.npgy-solution-summary:focus-visible {
    outline: 3px solid #174a73;
    outline-offset: 2px;
}

.npgy-start-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
}

.npgy-availability {
    margin: 0;
    color: var(--npgy-muted);
    font-size: 0.9rem;
}

.npgy-button {
    appearance: none;
    min-height: 44px;
    padding: 0.65rem 1rem;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    font-weight: 750;
    line-height: 1.25;
}

.npgy-button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.npgy-button--primary {
    background: var(--npgy-primary);
    color: #fff;
}

.npgy-button--primary:hover:not(:disabled) {
    background: var(--npgy-primary-dark);
}

.npgy-button--secondary {
    border-color: var(--npgy-primary);
    background: #fff;
    color: var(--npgy-primary);
}

.npgy-button--secondary:hover:not(:disabled) {
    background: var(--npgy-soft);
}

.npgy-button--ghost {
    border-color: var(--npgy-border);
    background: #f7f9fa;
    color: var(--npgy-text);
}

.npgy-text-button {
    appearance: none;
    padding: 0.25rem 0;
    border: 0;
    border-bottom: 1px solid currentColor;
    background: transparent;
    color: var(--npgy-primary);
    cursor: pointer;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
}

.npgy-local-progress {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
    padding: 0.8rem clamp(1rem, 3vw, 2rem);
    border-bottom: 1px solid var(--npgy-border);
    background: #fff;
}

.npgy-local-progress-title {
    margin: 0;
    color: var(--npgy-primary-dark);
    font-size: 1rem;
}

.npgy-progress-stats {
    display: flex;
    flex: 1 1 420px;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.npgy-progress-stat {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: var(--npgy-soft);
}

.npgy-progress-value {
    color: var(--npgy-primary-dark);
}

.npgy-progress-label {
    color: var(--npgy-muted);
    font-size: 0.82rem;
}

.npgy-workspace {
    padding: clamp(1rem, 3vw, 2rem);
    background: #fff;
}

.npgy-welcome {
    padding: clamp(1rem, 3vw, 1.5rem);
    border: 1px solid var(--npgy-border);
    border-radius: 12px;
    background: var(--npgy-softer);
}

.npgy-section-title {
    margin: 0 0 1rem;
    color: var(--npgy-primary-dark);
    font-size: clamp(1.25rem, 3vw, 1.6rem);
}

.npgy-welcome-steps {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: welcome-step;
}

.npgy-welcome-step {
    position: relative;
    min-width: 0;
    padding: 2.65rem 0.8rem 0.8rem;
    border: 1px solid var(--npgy-border);
    border-radius: 10px;
    background: #fff;
    counter-increment: welcome-step;
}

.npgy-welcome-step::before {
    position: absolute;
    top: 0.65rem;
    left: 0.75rem;
    display: grid;
    width: 1.55rem;
    height: 1.55rem;
    place-items: center;
    border-radius: 50%;
    background: var(--npgy-primary);
    color: #fff;
    content: counter(welcome-step);
    font-size: 0.82rem;
    font-weight: 800;
}

.npgy-welcome-step strong,
.npgy-welcome-step span {
    display: block;
}

.npgy-welcome-step span {
    margin-top: 0.25rem;
    color: var(--npgy-muted);
    font-size: 0.9rem;
}

.npgy-welcome-note {
    margin: 1rem 0 0;
    color: var(--npgy-muted);
}

.npgy-stepper {
    margin-bottom: 1rem;
}

.npgy-step-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.npgy-step {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--npgy-border);
    border-radius: 8px;
    background: #fff;
    color: var(--npgy-muted);
}

.npgy-step-number {
    display: grid;
    flex: 0 0 auto;
    width: 1.65rem;
    height: 1.65rem;
    place-items: center;
    border: 1px solid var(--npgy-border);
    border-radius: 50%;
    background: var(--npgy-softer);
    font-size: 0.82rem;
    font-weight: 800;
}

.npgy-step-title {
    overflow: hidden;
    font-size: 0.88rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.npgy-step.is-current {
    border-color: var(--npgy-primary);
    background: var(--npgy-soft);
    color: var(--npgy-primary-dark);
}

.npgy-step.is-current .npgy-step-number {
    border-color: var(--npgy-primary);
    background: var(--npgy-primary);
    color: #fff;
}

.npgy-step.is-complete {
    border-color: #96caae;
    background: var(--npgy-success-bg);
    color: var(--npgy-success);
}

.npgy-step.is-complete .npgy-step-number {
    border-color: var(--npgy-success);
    background: var(--npgy-success);
    color: #fff;
}

.npgy-task-card,
.npgy-result-card {
    overflow: hidden;
    border: 1px solid var(--npgy-border);
    border-radius: 12px;
    background: #fff;
}

.npgy-task-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    padding: 0.8rem clamp(1rem, 3vw, 1.5rem) 0;
}

.npgy-badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.7rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: var(--npgy-soft);
    color: var(--npgy-primary-dark);
    font-size: 0.78rem;
    font-weight: 750;
}

.npgy-badge--difficulty {
    background: #f3f3f3;
    color: #4f5962;
}

.npgy-badge--d2 {
    background: #fff4d6;
    color: #714a00;
}

.npgy-badge--d3 {
    background: #fbe8e8;
    color: #8d2323;
}

.npgy-task-code {
    margin-left: auto;
    color: var(--npgy-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.78rem;
}

.npgy-task-title {
    margin: 0;
    padding: 0.7rem clamp(1rem, 3vw, 1.5rem) 0;
    color: var(--npgy-primary-dark);
    font-size: clamp(1.25rem, 3vw, 1.55rem);
}

.npgy-question {
    margin: 0;
    padding: 0.65rem clamp(1rem, 3vw, 1.5rem);
    font-size: 1.05rem;
    font-weight: 600;
}

.npgy-givens {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0 clamp(1rem, 3vw, 1.5rem) 1rem;
}

.npgy-given {
    display: flex;
    flex: 1 1 180px;
    min-width: 0;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--npgy-border);
    border-radius: 7px;
    background: var(--npgy-softer);
}

.npgy-given dt {
    color: var(--npgy-muted);
    font-size: 0.8rem;
}

.npgy-given dd {
    margin: 0;
    overflow-wrap: anywhere;
    text-align: right;
    font-weight: 750;
}

.npgy-stage-panel {
    padding: 1.1rem clamp(1rem, 3vw, 1.5rem) 1.35rem;
    border-top: 1px solid var(--npgy-border);
    background: var(--npgy-softer);
}

.npgy-stage-heading {
    margin: 0;
    color: var(--npgy-primary-dark);
    font-size: 1.15rem;
}

.npgy-stage-instruction {
    margin: 0.35rem 0 1rem;
    color: var(--npgy-muted);
}

.npgy-answer-form {
    margin: 0;
}

.npgy-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
    margin: 0;
    padding: 0;
    border: 0;
}

.npgy-option {
    display: flex;
    min-width: 0;
    min-height: 52px;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.75rem;
    border: 1px solid #aebfcd;
    border-radius: 9px;
    background: #fff;
    cursor: pointer;
}

.npgy-option:hover {
    border-color: var(--npgy-accent);
    background: var(--npgy-soft);
}

.npgy-option.is-selected {
    border-color: var(--npgy-primary);
    background: var(--npgy-soft);
    box-shadow: inset 0 0 0 1px var(--npgy-primary);
}

.npgy-option.is-correct {
    border-color: var(--npgy-success);
    background: var(--npgy-success-bg);
    box-shadow: inset 0 0 0 1px var(--npgy-success);
}

.npgy-option.is-incorrect {
    border-color: var(--npgy-error);
    background: var(--npgy-error-bg);
}

.npgy-option input {
    flex: 0 0 auto;
    width: 1.1rem;
    height: 1.1rem;
    margin: 0.15rem 0 0;
    accent-color: var(--npgy-primary);
}

.npgy-option--formula {
    align-items: center;
}

.npgy-option-formula {
    overflow-wrap: anywhere;
    background: transparent;
    color: var(--npgy-primary-dark);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 0.92rem;
    font-weight: 700;
}

.npgy-number-answer {
    max-width: 560px;
}

.npgy-input-control {
    display: flex;
    align-items: stretch;
}

.npgy-input-control .npgy-input {
    border-radius: 8px 0 0 8px;
}

.npgy-input-control .npgy-input:only-child {
    border-radius: 8px;
}

.npgy-input-suffix {
    display: flex;
    min-width: 3.5rem;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.7rem;
    border: 1px solid #aebfcd;
    border-left: 0;
    border-radius: 0 8px 8px 0;
    background: var(--npgy-soft);
    color: var(--npgy-primary-dark);
    font-weight: 750;
}

.npgy-help {
    margin: 0.3rem 0 0;
    color: var(--npgy-muted);
    font-size: 0.84rem;
}

.npgy-help--rounding {
    padding-left: 0.65rem;
    border-left: 3px solid var(--npgy-primary);
    color: var(--npgy-primary-dark);
    font-weight: 650;
}

.npgy-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 1rem;
}

.npgy-message {
    margin-top: 0.85rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--npgy-border);
    border-radius: 8px;
    background: #fff;
}

.npgy-message--success {
    border-color: #a5d5b9;
    background: var(--npgy-success-bg);
    color: var(--npgy-success);
}

.npgy-message--error,
.npgy-notice--error,
.npgy-dependency-notice {
    border-color: #efb2b2;
    background: var(--npgy-error-bg);
    color: var(--npgy-error);
}

.npgy-message--warning {
    border-color: #e7bd70;
    background: var(--npgy-warning-bg);
    color: var(--npgy-warning);
}

.npgy-message--hint {
    border-color: #9fc7e2;
    background: var(--npgy-soft);
    color: var(--npgy-primary-dark);
}

.npgy-message--neutral {
    background: #f4f6f7;
    color: var(--npgy-muted);
}

.npgy-solution {
    margin-top: 1rem;
    overflow: hidden;
    border: 1px solid var(--npgy-border);
    border-radius: 9px;
    background: #fff;
}

.npgy-solution-summary {
    padding: 0.7rem 0.85rem;
    cursor: pointer;
    color: var(--npgy-primary-dark);
    font-weight: 750;
}

.npgy-solution[open] .npgy-solution-summary {
    border-bottom: 1px solid var(--npgy-border);
    background: var(--npgy-soft);
}

.npgy-solution-body {
    display: grid;
    gap: 0;
}

.npgy-solution-row {
    display: grid;
    grid-template-columns: minmax(125px, 0.28fr) minmax(0, 1fr);
    gap: 0.75rem;
    padding: 0.7rem 0.85rem;
    border-bottom: 1px solid #e4eaef;
}

.npgy-solution-row:last-child {
    border-bottom: 0;
}

.npgy-solution-label {
    color: var(--npgy-muted);
    font-size: 0.88rem;
}

.npgy-solution-code {
    overflow-wrap: anywhere;
    background: transparent;
    color: var(--npgy-primary-dark);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 0.92rem;
    font-weight: 650;
}

.npgy-result-card {
    padding: clamp(1rem, 3vw, 1.5rem);
}

.npgy-score {
    margin: 0;
    color: var(--npgy-primary);
    font-size: clamp(1.8rem, 5vw, 2.7rem);
    font-weight: 850;
    line-height: 1.1;
}

.npgy-result-summary {
    max-width: 760px;
    margin: 0.65rem 0 1rem;
    color: var(--npgy-muted);
}

.npgy-test-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem 1rem;
    margin-bottom: 0.8rem;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--npgy-border);
    border-radius: 9px;
    background: var(--npgy-softer);
}

.npgy-timer {
    margin-right: auto;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    background: var(--npgy-primary-dark);
    color: #fff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 750;
}

.npgy-test-overview {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.npgy-test-stat {
    padding: 0.75rem;
    border: 1px solid var(--npgy-border);
    border-radius: 9px;
    background: var(--npgy-softer);
    text-align: center;
}

.npgy-test-stat strong,
.npgy-test-stat span {
    display: block;
}

.npgy-test-stat strong {
    color: var(--npgy-primary-dark);
    font-size: 1.35rem;
}

.npgy-test-stat span {
    color: var(--npgy-muted);
    font-size: 0.85rem;
}

.npgy-test-solutions {
    display: grid;
    gap: 0.85rem;
    margin-top: 1rem;
}

.npgy-test-solution {
    padding: 0.85rem;
    border: 1px solid var(--npgy-border);
    border-radius: 9px;
    background: var(--npgy-softer);
}

.npgy-test-solution h4,
.npgy-test-solution p {
    margin-top: 0;
}

.npgy-disclaimer {
    padding: 1rem clamp(1rem, 3vw, 2rem);
    border-top: 1px solid var(--npgy-border);
    background: #f5f7f8;
    color: var(--npgy-muted);
    font-size: 0.86rem;
}

.npgy-notice,
.npgy-dependency-notice {
    margin: 1rem;
    padding: 0.85rem;
    border: 1px solid;
    border-radius: 8px;
}

.npgy-visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(1px, 1px, 1px, 1px) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
}

@media (max-width: 760px) {
    .npgy-filter-grid,
    .npgy-options {
        grid-template-columns: 1fr;
    }

    .npgy-welcome-steps {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .npgy-step-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .npgy-solution-row {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }
}

@media (max-width: 480px) {
    .npgy-app {
        margin: 0.8rem 0;
        border-right: 0;
        border-left: 0;
        border-radius: 0;
    }

    .npgy-mode-tabs,
    .npgy-mode-tab,
    .npgy-start-button {
        width: 100%;
    }

    .npgy-mode-tabs {
        display: grid;
    }

    .npgy-welcome-steps,
    .npgy-step-list,
    .npgy-test-overview {
        grid-template-columns: 1fr;
    }

    .npgy-step-title {
        white-space: normal;
    }

    .npgy-given {
        flex-basis: 100%;
    }

    .npgy-actions .npgy-button {
        width: 100%;
    }

    .npgy-local-progress {
        align-items: flex-start;
    }

    .npgy-progress-stats {
        display: grid;
        flex-basis: 100%;
        grid-template-columns: 1fr;
    }
}

@media (forced-colors: active) {
    .npgy-step.is-current,
    .npgy-step.is-complete,
    .npgy-option.is-selected,
    .npgy-option.is-correct,
    .npgy-option.is-incorrect {
        border: 2px solid CanvasText;
        forced-color-adjust: auto;
    }

    .npgy-step.is-current .npgy-step-number,
    .npgy-step.is-complete .npgy-step-number {
        border: 2px solid CanvasText;
    }
}

@media print {
    .npgy-setup,
    .npgy-local-progress,
    .npgy-actions,
    .npgy-text-button,
    .npgy-test-header .npgy-text-button {
        display: none !important;
    }

    .npgy-app {
        border: 0;
        box-shadow: none;
    }

    .npgy-workspace {
        padding: 0;
    }
}
