/* =========================================================
   디딤돌대출 금리·한도 계산기 — 페이지 전용 스타일 (?v=4)
   수당헬프 5계층 계산기 표준 (인라인 style 0줄)
   ========================================================= */

/* 모바일 줌·더블탭 줌 차단 (iOS 자동 줌은 input/select에만 발생하므로 button 전역 오버라이드 금지) */
html, body {
    touch-action: manipulation;
}
#didimdol-form input[type="text"],
#didimdol-form select {
    font-size: 16px;
}
.calculator-form {
    scroll-margin-top: 76px;
}

/* 접근성 스킵 링크 */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 2000;
    background: #0d6efd;
    color: #fff;
    padding: 0.625rem 1rem;
    font-weight: 700;
    text-decoration: none;
    border-radius: 0 0 8px 0;
}
.skip-link:focus {
    left: 0;
}

/* 타이틀 섹션 */
.main-title-section {
    padding: 1.25rem 0;
}
.main-title {
    font-size: 1.75rem;
    margin: 0 0 0.375rem;
}
.main-subtitle {
    font-size: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
}
.dd-date-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

/* 데스크탑 2단 레이아웃: 좌측 400px sticky + 내부 스크롤, 우측 flex:1 */
@media (min-width: 769px) {
    .calculator-wrapper {
        width: 400px;
        position: sticky;
        top: 72px;
        max-height: calc(100vh - 96px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    .calculator-card {
        height: auto;
        overflow: visible;
    }
}

.calculator-body {
    padding: 0.875rem 1rem 1rem;
}

/* 폼 섹션 */
.dd-form-section {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 10px;
    padding: 0.7rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}
.dd-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.625rem;
}
.dd-field {
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-bottom: 0;
}
.dd-field label,
.dd-group-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.25rem;
    display: block;
}
.dd-field input[type="text"],
.dd-field select {
    width: 100%;
    height: 40px;
    padding: 0 0.625rem;
    border: 1px solid var(--border-secondary);
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    background: #fff;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
}
.dd-field .input-with-unit input[type="text"] {
    text-align: right;
    padding-right: 2.75rem;
}
.dd-field input[type="text"]::placeholder {
    color: #9ca3af;
    font-weight: 400;
}
.dd-field .unit-inline {
    right: 0.625rem;
    font-size: 0.78rem;
}
.dd-field input.is-invalid,
.dd-field select.is-invalid {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.15);
}
.error-message {
    font-size: 0.72rem;
    color: #dc2626;
    margin: 0.2rem 0 0;
    min-height: 0;
    line-height: 1.35;
}

/* 2×2 세그먼트 라디오 */
.dd-segment-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.dd-seg-option {
    position: relative;
    margin: 0;
}
.dd-seg-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}
.dd-seg-label {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 0.5rem;
    border: 1px solid var(--border-secondary);
    border-radius: 8px;
    background: #fff;
    color: #374151;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    user-select: none;
}
.dd-seg-option input[type="radio"]:checked + .dd-seg-label {
    background: #eff6ff;
    border-color: #2563eb;
    color: #1d4ed8;
    font-weight: 700;
}
.dd-seg-option input[type="radio"]:focus-visible + .dd-seg-label {
    outline: 2px solid #2563eb;
    outline-offset: 1px;
}

/* 기본 접힘 상세 조건 (<details>) */
.dd-advanced {
    margin-top: 0.7rem;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    background: var(--bg-tertiary);
}
.dd-advanced summary {
    padding: 0.5625rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.dd-advanced summary::-webkit-details-marker {
    display: none;
}
.dd-advanced summary::after {
    content: "+";
    font-size: 1rem;
    font-weight: 700;
    color: #6b7280;
}
.dd-advanced[open] summary::after {
    content: "−";
}
.dd-advanced-body {
    padding: 0.55rem 0.75rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    border-top: 1px solid var(--border-primary);
}
.dd-checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
}
.dd-checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #2563eb;
    cursor: pointer;
}

/* 버튼 행: 계산하기(메인) + 초기화(보조) 2개 */
.button-grid.dd-button-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    grid-template-areas: "calc reset";
    gap: 8px;
    margin-top: 0.8rem;
}
.button-grid.dd-button-grid .calculate-btn {
    grid-area: calc;
    width: 100%;
    min-height: 44px;
    font-size: 0.9375rem;
}
.button-grid.dd-button-grid .reset-btn {
    grid-area: reset;
    min-height: 44px;
}
.button-grid.dd-button-grid .btn {
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.875rem;
}

.dd-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 2500;
    padding: 0.6rem 1.1rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.94);
    color: #fff;
    font-size: 0.825rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
    pointer-events: none;
}

/* 결과 영역 (#calculator-result-area) */
.dd-result-area {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-primary);
    scroll-margin-top: 76px;
}

/* 자격 초과 경고 카드 */
.dd-ineligible-card {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 0.9rem;
    color: #991b1b;
    margin-bottom: 0.875rem;
}
.dd-ineligible-title {
    font-size: 0.95rem;
    font-weight: 800;
    margin: 0 0 0.4rem;
    display: flex;
    align-items: center;
    gap: 6px;
}
.dd-ineligible-list {
    margin: 0.35rem 0 0.6rem;
    padding-left: 1.15rem;
    font-size: 0.82rem;
    line-height: 1.55;
}
.dd-ineligible-tip {
    font-size: 0.78rem;
    color: #7f1d1d;
    margin: 0;
    line-height: 1.5;
}

/* 1차 핵심 결론 카드 */
.dd-hero-card {
    background: #f8fafc;
    border: 1px solid #dbeafe;
    border-radius: 12px;
    padding: 0.95rem;
    margin-bottom: 0.75rem;
}
.dd-hero-eyebrow {
    font-size: 0.76rem;
    font-weight: 700;
    color: #2563eb;
    margin-bottom: 0.2rem;
}
.dd-hero-limit {
    font-size: 1.65rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.025em;
    line-height: 1.25;
    font-variant-numeric: tabular-nums;
    margin-bottom: 0.65rem;
}
.dd-kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 0.65rem;
}
.dd-kpi-box {
    background: #ffffff;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 0.55rem 0.65rem;
}
.dd-kpi-label {
    display: block;
    font-size: 0.72rem;
    color: #64748b;
    margin-bottom: 0.2rem;
}
.dd-kpi-value {
    display: block;
    font-size: 0.98rem;
    font-weight: 800;
    color: #111827;
    font-variant-numeric: tabular-nums;
}

/* 한도 병목 진단 배지 */
.dd-bottleneck-badge {
    padding: 0.5rem 0.65rem;
    border-radius: 8px;
    font-size: 0.77rem;
    font-weight: 600;
    line-height: 1.45;
    margin-bottom: 0.7rem;
    word-break: keep-all;
}
.dd-bottleneck-badge.is-roomDeduction {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}
.dd-bottleneck-badge.is-productCap {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}
.dd-bottleneck-badge.is-ltv {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}

/* CSS 비율 바 (대출금 vs 자기자금) */
.dd-ratio-bar {
    display: flex;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: #e2e8f0;
    margin-bottom: 0.4rem;
}
.dd-ratio-loan {
    background: #2563eb;
    transition: width 0.25s ease;
}
.dd-ratio-equity {
    background: #cbd5e1;
    transition: width 0.25s ease;
}
.dd-ratio-legend {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.73rem;
    color: #475569;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.dd-basis-line {
    margin-top: 0.55rem;
    padding-top: 0.5rem;
    border-top: 1px dashed #cbd5e1;
    font-size: 0.73rem;
    color: #475569;
    line-height: 1.45;
}

/* '더 자세히 알아볼까요?' 접힘 상세 3종 */
.dd-details-heading {
    font-size: 0.82rem;
    font-weight: 700;
    color: #334155;
    margin: 0.85rem 0 0.45rem;
}
.dd-details-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 0.85rem;
}
.dd-detail-item {
    border: 1px solid var(--border-primary);
    border-radius: 9px;
    background: #ffffff;
    overflow: hidden;
}
.dd-detail-item summary {
    padding: 0.62rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 700;
    color: #1e293b;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.dd-detail-item summary::-webkit-details-marker {
    display: none;
}
.dd-detail-item summary::after {
    content: "+";
    font-size: 1rem;
    font-weight: 600;
    color: #64748b;
    flex-shrink: 0;
}
.dd-detail-item[open] summary::after {
    content: "−";
}
.dd-detail-body {
    padding: 0.55rem 0.75rem 0.75rem;
    border-top: 1px solid var(--border-primary);
    font-size: 0.78rem;
    color: #334155;
    line-height: 1.55;
}
.dd-detail-note {
    margin: 0 0 0.5rem;
    word-break: keep-all;
}
.dd-mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}
.dd-mini-table th,
.dd-mini-table td {
    padding: 0.4rem 0.35rem;
    border-bottom: 1px solid #e2e8f0;
    text-align: right;
}
.dd-mini-table th:first-child,
.dd-mini-table td:first-child {
    text-align: left;
}
.dd-mini-table th {
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
}
.dd-mini-table tr.is-current-row td {
    background: #eff6ff;
    font-weight: 700;
    color: #1d4ed8;
}
.dd-handoff-note {
    margin: 0.6rem 0 0;
    padding: 0.5rem 0.6rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    font-size: 0.76rem;
    color: #334155;
    line-height: 1.45;
}
.dd-handoff-note a {
    color: #2563eb;
    font-weight: 700;
    text-decoration: underline;
}

/* 결과 액션 버튼: 이 조건 저장 + 이미지로 저장 (50:50 1줄) */
.dd-result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 0.85rem;
}
.dd-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 0.75rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.dd-save-btn {
    background: #eff6ff;
    border: 1px solid #93c5fd;
    color: #1d4ed8;
}
.dd-save-btn:hover {
    background: #dbeafe;
    border-color: #60a5fa;
}
.dd-image-btn {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #1e293b;
}
.dd-image-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

/* 저장한 조건 비교함 (최대 3개) */
.dd-saved-box {
    margin-top: 0.85rem;
    margin-bottom: 0.85rem;
    padding: 0.75rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}
.dd-saved-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 0.5rem;
}
.dd-saved-title {
    font-size: 0.82rem;
    font-weight: 800;
    color: #0f172a;
}
.dd-saved-clear {
    background: none;
    border: none;
    padding: 2px 4px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    text-decoration: underline;
}
.dd-saved-clear:hover {
    color: #dc2626;
}
.dd-saved-table-wrap {
    overflow-x: auto;
}
.dd-saved-table td {
    vertical-align: middle;
    line-height: 1.35;
}
.dd-saved-cond-main {
    display: block;
    font-weight: 700;
    color: #0f172a;
}
.dd-saved-cond-sub {
    display: block;
    font-size: 0.7rem;
    color: #64748b;
}
.dd-saved-del-btn {
    width: 24px;
    height: 24px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.dd-saved-del-btn:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

/* 결과 직후 연쇄 동선 카드 */
.dd-chain-card {
    margin: 0.85rem 0 0;
}

/* 가이드 영역 — 탈-AI × 가독성 4대 부품 */
.guide-title-main {
    font-size: 1.5rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 1rem;
    letter-spacing: -0.025em;
    line-height: 1.35;
    word-break: keep-all;
}
.guide-content > h2 {
    font-size: 1.2rem;
    font-weight: 800;
    color: #0f172a;
    margin: 2rem 0 0.75rem;
    letter-spacing: -0.02em;
    line-height: 1.4;
    word-break: keep-all;
}
.guide-content p {
    margin: 0 0 0.85rem;
    color: #334155;
    font-size: 0.9375rem;
    line-height: 1.75;
    word-break: keep-all;
}

/* 콜아웃 3종: intro-box(첫 결론), info-box(기준 정리), warning-box(실제 함정 경고) */
.dd-intro-box,
.dd-info-box,
.dd-warning-box {
    border-radius: 10px;
    padding: 0.95rem 1.05rem;
    margin: 0 0 1.25rem;
    font-size: 0.92rem;
    line-height: 1.7;
    word-break: keep-all;
}
.dd-intro-box {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-left: 4px solid #2563eb;
    color: #0f172a;
}
.dd-info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-left: 4px solid #2563eb;
    color: #1e3a8a;
}
.dd-warning-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 4px solid #d97706;
    color: #78350f;
}
.dd-callout-title {
    display: block;
    font-size: 0.86rem;
    font-weight: 800;
    margin-bottom: 0.45rem;
    letter-spacing: -0.01em;
}
.dd-intro-box p:last-child,
.dd-info-box p:last-child,
.dd-warning-box p:last-child,
.dd-intro-box ul:last-child,
.dd-info-box ul:last-child,
.dd-warning-box ul:last-child {
    margin-bottom: 0;
}
.dd-callout-list {
    margin: 0;
    padding-left: 1.15rem;
}
.dd-callout-list li {
    margin-bottom: 0.35rem;
}
.dd-callout-list li:last-child {
    margin-bottom: 0;
}

/* 계산기 시뮬레이션 사례 카드 3종 */
.dd-case-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 0.9rem 0 1.25rem;
}
.dd-case-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.9rem 1rem;
}
.dd-case-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 0.5rem;
}
.dd-case-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0;
}
.dd-case-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 0.76rem;
    font-weight: 700;
}
.dd-case-card p {
    margin: 0 0 0.45rem;
    font-size: 0.9rem;
    line-height: 1.68;
    color: #334155;
}
.dd-case-card p:last-child {
    margin-bottom: 0;
}
.dd-case-verdict {
    font-weight: 700;
    color: #0f172a;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1rem 0;
}
.guide-list {
    padding-left: 1.25rem;
    margin: 0.5rem 0 1rem;
    color: #374151;
    line-height: 1.75;
    word-break: keep-all;
}
.guide-list li {
    margin-bottom: 0.45rem;
}
.guide-caption {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: -0.45rem;
    margin-bottom: 1rem;
}

/* 가이드 공식 캡처·요약 도해 figure (CLS 0) */
.dd-figure {
    margin: 1.1rem 0 1.4rem;
    padding: 0.65rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}
.dd-figure img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
}
.dd-figure figcaption {
    margin-top: 0.55rem;
    font-size: 0.78rem;
    color: #64748b;
    text-align: center;
    line-height: 1.5;
    word-break: keep-all;
}
.dd-figure-portrait {
    max-width: 460px;
    margin-left: auto;
    margin-right: auto;
}

/* 가이드 FAQ 아코디언 */
.dd-faq-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 0.75rem;
}
.dd-faq-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 10px;
    overflow: hidden;
}
.dd-faq-item summary {
    padding: 0.9rem 1rem;
    font-size: 0.9375rem;
    font-weight: 700;
    color: #111827;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.dd-faq-item summary::-webkit-details-marker {
    display: none;
}
.dd-faq-item summary::after {
    content: "+";
    font-size: 1.15rem;
    font-weight: 500;
    color: #6b7280;
    flex-shrink: 0;
}
.dd-faq-item[open] summary::after {
    content: "−";
}
.dd-faq-answer {
    padding: 0 1rem 1rem;
    font-size: 0.9rem;
    color: #374151;
    line-height: 1.75;
    word-break: keep-all;
}

/* 푸터 */
.footer {
    margin-top: 2.5rem;
    padding: 1.75rem 1rem;
    background: #ffffff;
    border-top: 1px solid var(--border-primary);
    text-align: center;
    color: #6b7280;
    font-size: 0.8125rem;
}
.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.footer-brand {
    font-weight: 700;
    color: #111827;
}
.footer-contact a {
    color: #4b5563;
    text-decoration: none;
}
.footer-contact a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}
.footer-copy {
    font-size: 0.75rem;
    color: #9ca3af;
}

/* 모바일 최적화 (≤768px): 390×844 첫 화면에 계산 버튼 노출 + 가이드 숨김 금지 */
@media (max-width: 768px) {
    .main-title-section {
        padding: 0.65rem 0;
    }
    .main-title-container {
        padding: 0 1rem;
    }
    .main-title {
        font-size: 1.35rem;
        margin-bottom: 0.2rem;
    }
    .main-subtitle {
        font-size: 0.78rem;
    }
    .calculator-wrapper {
        width: 100%;
        position: relative;
        top: 0;
        max-height: none;
        overflow-y: visible;
        margin-bottom: 0;
    }
    .calculator-body {
        padding: 0.7rem 0.85rem 0.85rem;
    }
    .dd-form-section {
        padding: 0.6rem 0.65rem;
        gap: 0.55rem;
    }
    .dd-form-grid {
        gap: 0.5rem;
    }
    .dd-field label,
    .dd-group-label {
        font-size: 0.74rem;
        margin-bottom: 0.2rem;
    }
    .dd-field input[type="text"],
    .dd-field select {
        height: 38px;
        font-size: 16px;
    }
    .dd-seg-label {
        height: 34px;
        font-size: 0.78rem;
    }
    .dd-advanced {
        margin-top: 0.55rem;
    }
    .dd-advanced summary {
        padding: 0.48rem 0.65rem;
        font-size: 0.78rem;
    }
    .button-grid.dd-button-grid {
        margin-top: 0.65rem;
        gap: 6px;
    }
    .button-grid.dd-button-grid .btn {
        min-height: 36px;
    }
    .button-grid.dd-button-grid .calculate-btn {
        min-height: 42px;
    }
    .guide-wrapper {
        display: block;
        max-height: none;
        overflow: visible;
    }
}
