/* Retirement Date Calculator — scoped styles, light and dark */

.rd-grid-bg {
    background-size: 40px 40px;
    background-image:
        linear-gradient(to right, rgba(6, 182, 212, 0.04) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(6, 182, 212, 0.04) 1px, transparent 1px);
}
html.dark .rd-grid-bg {
    background-image:
        linear-gradient(to right, rgba(6, 182, 212, 0.03) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(6, 182, 212, 0.03) 1px, transparent 1px);
}

/* Cards */
#retirement-workspace .apple-glass,
#educational-content .apple-glass {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(228, 228, 231, 0.9);
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
}
html.dark #retirement-workspace .apple-glass,
html.dark #educational-content .apple-glass {
    background: rgba(10, 10, 14, 0.92);
    border-color: rgba(255, 255, 255, 0.07);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Inputs: 16px minimum so iOS does not zoom */
#retirement-workspace input[type="date"],
#retirement-workspace input[type="number"] {
    font-size: 16px !important;
    line-height: 1.5;
}
.rd-label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #3f3f46;
    cursor: pointer;
}
html.dark .rd-label { color: #d4d4d8; }

.rd-input {
    height: 44px;
    padding: 0 0.875rem;
    border-radius: 0.75rem;
    border: 1px solid #e4e4e7;
    background: #f4f4f5;
    color: #18181b;
    font-weight: 600;
    outline: none;
    transition: border-color 0.15s ease;
}
.rd-input:focus { border-color: rgba(6, 182, 212, 0.6); }
html.dark .rd-input {
    background: rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.1);
    color: #f4f4f5;
    color-scheme: dark;
}

.rd-stepper {
    height: 44px;
    border-radius: 0.75rem;
    border: 1px solid #e4e4e7;
    background: #f4f4f5;
    overflow: hidden;
}
.rd-stepper:focus-within { border-color: rgba(6, 182, 212, 0.6); }
html.dark .rd-stepper {
    background: rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.1);
}
.rd-step {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    font-weight: 700;
    color: #52525b;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
}
.rd-step:hover { background: #e4e4e7; color: #18181b; }
html.dark .rd-step { color: #a1a1aa; }
html.dark .rd-step:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

input[type="number"].no-spinners::-webkit-inner-spin-button,
input[type="number"].no-spinners::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"].no-spinners { -moz-appearance: textfield; appearance: textfield; }


.rd-age-input {
    width: 4.75rem;
    text-align: center;
    padding: 0 0.5rem;
}

/* Quick-pick age chips */
.rd-chip {
    min-width: 44px;
    min-height: 44px;
    padding: 0 0.75rem;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 700;
    background: #f4f4f5;
    border: 1px solid #e4e4e7;
    color: #27272a;
    cursor: pointer;
    touch-action: manipulation;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.rd-chip:hover { border-color: rgba(6, 182, 212, 0.5); }
html.dark .rd-chip { background: #18181b; border-color: rgba(255, 255, 255, 0.1); color: #e4e4e7; }
.rd-chip.rd-chip-active,
html.dark .rd-chip.rd-chip-active { background: #06b6d4; border-color: #0891b2; color: #000; }

/* Rule options (radio cards) */
.rd-option {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    min-height: 44px;
    padding: 0.625rem 0.75rem;
    border-radius: 0.875rem;
    border: 1px solid #e4e4e7;
    background: #fafafa;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
html.dark .rd-option { background: rgba(0, 0, 0, 0.35); border-color: rgba(255, 255, 255, 0.08); }
.rd-option:has(.rd-radio:checked) { border-color: #06b6d4; background: rgba(6, 182, 212, 0.08); }
html.dark .rd-option:has(.rd-radio:checked) { border-color: #22d3ee; background: rgba(6, 182, 212, 0.12); }
.rd-radio {
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.1rem;
    flex-shrink: 0;
    accent-color: #06b6d4;
    cursor: pointer;
}
.rd-option-title { display: block; font-size: 0.9rem; font-weight: 700; color: #18181b; }
html.dark .rd-option-title { color: #fff; }
.rd-option-help { display: block; font-size: 0.8rem; line-height: 1.35; color: #52525b; margin-top: 0.1rem; }
html.dark .rd-option-help { color: #a1a1aa; }

/* Buttons */
.rd-icon-btn {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f4f5;
    border: 1px solid #e4e4e7;
    color: #52525b;
    cursor: pointer;
}
.rd-icon-btn:hover { color: #e11d48; background: rgba(244, 63, 94, 0.08); }
html.dark .rd-icon-btn { background: #18181b; border-color: rgba(255, 255, 255, 0.1); color: #a1a1aa; }

.rd-btn-primary,
.rd-btn-secondary {
    min-height: 44px;
    min-width: 44px;
    padding: 0 0.875rem;
    border-radius: 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
}
.rd-btn-primary:active,
.rd-btn-secondary:active { transform: scale(0.97); }
.rd-btn-primary { background: #06b6d4; color: #000; }
.rd-btn-primary:hover { background: #22d3ee; }
.rd-btn-secondary { background: #f4f4f5; color: #27272a; border: 1px solid #e4e4e7; }
.rd-btn-secondary:hover { background: #e4e4e7; }
html.dark .rd-btn-secondary { background: #18181b; color: #e4e4e7; border-color: rgba(255, 255, 255, 0.1); }
html.dark .rd-btn-secondary:hover { background: #27272a; }

.rd-chip:focus-visible,
.rd-icon-btn:focus-visible,
.rd-btn-primary:focus-visible,
.rd-btn-secondary:focus-visible,
.rd-radio:focus-visible {
    outline: 2px solid #06b6d4;
    outline-offset: 2px;
}
#rdJoinDetails summary::-webkit-details-marker { display: none; }

/* Result */
.rd-output-error {
    font-size: 1.5rem !important;
    line-height: 2rem !important;
    color: #b45309 !important;
}
html.dark .rd-output-error { color: #fcd34d !important; }
.rd-details[hidden] { display: none; }
.rd-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.4rem 0;
    border-top: 1px solid rgba(228, 228, 231, 0.8);
    font-size: 0.875rem;
}
.rd-row:first-child { border-top: 0; }
html.dark .rd-row { border-top-color: rgba(255, 255, 255, 0.06); }
.rd-row dt { color: #52525b; font-weight: 500; }
html.dark .rd-row dt { color: #a1a1aa; }
.rd-row dd { color: #18181b; font-weight: 700; text-align: right; }
html.dark .rd-row dd { color: #fff; }
.rd-row[hidden] { display: none; }

/* Content */
.rd-h2 {
    font-size: 1.375rem;
    line-height: 1.25;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: #18181b;
}
html.dark .rd-h2 { color: #fff; }
@media (min-width: 640px) { .rd-h2 { font-size: 1.75rem; } }
.rd-link { color: #0891b2; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
html.dark .rd-link { color: #22d3ee; }
.rd-formula {
    padding: 0.75rem;
    border-radius: 0.75rem;
    background: rgba(244, 244, 245, 0.8);
    border: 1px solid rgba(228, 228, 231, 0.8);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    color: #0e7490;
}
html.dark .rd-formula { background: rgba(9, 9, 11, 0.4); border-color: rgba(255, 255, 255, 0.05); color: #67e8f9; }
.rd-example {
    padding: 1rem;
    border-radius: 0.875rem;
    background: rgba(244, 244, 245, 0.8);
    border: 1px solid rgba(228, 228, 231, 0.8);
    font-size: 0.875rem;
    line-height: 1.55;
    color: #52525b;
}
html.dark .rd-example { background: rgba(9, 9, 11, 0.4); border-color: rgba(255, 255, 255, 0.05); color: #a1a1aa; }
.rd-example strong { color: #18181b; }
html.dark .rd-example strong { color: #fff; }
.rd-example-title { font-weight: 700; color: #18181b; margin-bottom: 0.35rem; }
html.dark .rd-example-title { color: #fff; }

.rd-thead { background: #f4f4f5; }
html.dark .rd-thead { background: #111114; }
.rd-th {
    padding: 0.6rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #52525b;
}
html.dark .rd-th { color: #a1a1aa; }
.rd-td {
    padding: 0.55rem 0.75rem;
    border-top: 1px solid rgba(228, 228, 231, 0.7);
    color: #3f3f46;
}
html.dark .rd-td { border-top-color: rgba(255, 255, 255, 0.05); color: #d4d4d8; }

@media (min-width: 1024px) {
    .rd-results-column {
        grid-column: 8 / span 5 !important;
        grid-row: 1 / span 12 !important;
        align-self: start !important;
    }
}

@media (max-width: 767px) {
    #retirement-workspace .apple-glass { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
}

@media print {
    #btn-reset, #btn-copy, #btn-share, #btn-clear-join { display: none !important; }
}
