* {
    box-sizing: border-box;
}

.cpc-app {
    --cpc-bg: #f4f6fb;
    --cpc-surface: #ffffff;
    --cpc-text: #1a2234;
    --cpc-muted: #5d6a82;
    --cpc-border: #d8dee9;
    --cpc-primary: #34455d;
    --cpc-primary-contrast: #ffffff;
    --cpc-accent: #18884b;
    max-width: 100%;
    background: var(--cpc-bg);
    color: var(--cpc-text);
    border: 1px solid var(--cpc-border);
    border-radius: 22px;
    padding: 18px;
    box-shadow: 0 12px 30px rgba(17, 24, 39, 0.08);
    overflow-wrap: anywhere;
}

.cpc-app.cpc-dark {
    --cpc-bg: #111827;
    --cpc-surface: #1f2937;
    --cpc-text: #f3f4f6;
    --cpc-muted: #cbd5e1;
    --cpc-border: #334155;
    --cpc-primary: #475569;
    --cpc-primary-contrast: #ffffff;
    --cpc-accent: #4ade80;
}

.cpc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.cpc-title {
    margin: 0;
    font-size: clamp(1.5rem, 4.8vw, 2rem);
    line-height: 1.2;
}

.cpc-theme-toggle {
    border: 1px solid var(--cpc-border);
    background: var(--cpc-surface);
    color: var(--cpc-text);
    border-radius: 999px;
    padding: 10px 14px;
    cursor: pointer;
}

.cpc-form, .cpc-results {
    display: block;
    width: 100%;
}

.cpc-field {
    margin-bottom: 14px;
}

.cpc-field label {
    display: block;
    margin-bottom: 7px;
    font-weight: 700;
}

.cpc-field input {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    border: 1px solid var(--cpc-border);
    border-radius: 14px;
    padding: 14px 16px;
    background: var(--cpc-surface);
    color: var(--cpc-text);
    font-size: 16px;
}

.cpc-field input:focus,
.cpc-button:focus,
.cpc-theme-toggle:focus {
    outline: 3px solid rgba(59, 130, 246, 0.35);
    outline-offset: 2px;
}

.cpc-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 18px 0 22px;
}

.cpc-button {
    width: 100%;
    border: 0;
    border-radius: 18px;
    background: var(--cpc-primary);
    color: var(--cpc-primary-contrast);
    padding: 16px 18px;
    font-size: clamp(1rem, 4vw, 1.15rem);
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.cpc-button:hover,
.cpc-theme-toggle:hover {
    opacity: 0.95;
}

.cpc-button:active {
    transform: translateY(1px);
}

.cpc-button-primary {
    background: #1e3a5f;
}

.cpc-error {
    margin: 0 0 8px;
    color: #b91c1c;
    font-weight: 600;
}

.cpc-result-section {
    width: 100%;
    background: var(--cpc-surface);
    border: 1px solid var(--cpc-border);
    border-radius: 18px;
    padding: 18px;
    margin-bottom: 14px;
}

.cpc-result-section h3 {
    margin: 0 0 14px;
    font-size: clamp(1.2rem, 4.5vw, 1.5rem);
    line-height: 1.25;
}

.cpc-main-result {
    font-size: clamp(2rem, 9vw, 3rem);
    line-height: 1.1;
    font-weight: 800;
    color: var(--cpc-accent);
    white-space: nowrap;
}

.cpc-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--cpc-border);
}

.cpc-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.cpc-row span {
    color: var(--cpc-muted);
    font-weight: 600;
}

.cpc-row strong {
    color: var(--cpc-text);
    text-align: right;
    white-space: nowrap;
    font-size: clamp(1rem, 4vw, 1.2rem);
}

.cpc-disclaimer {
    margin: 0;
    color: var(--cpc-muted);
    line-height: 1.6;
}

@media (min-width: 768px) {
    .cpc-app {
        padding: 24px;
    }

    .cpc-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media print {
    .cpc-theme-toggle,
    .cpc-actions,
    .cpc-form {
        display: none !important;
    }

    .cpc-app {
        border: 0;
        box-shadow: none;
        padding: 0;
        background: #ffffff;
        color: #000000;
    }
}
