/* ── 기본 설정 (Fortune 톤 + 손금 골드 액센트) ── */
:root {
    --accent: #b8860b;
    --accent-dark: #8b6508;
    --accent-soft: #fff8e7;
    --bg: #f5f5f7;
    --card-bg: #fff;
    --text: #1c1c1e;
    --text-muted: #8e8e93;
    --border: rgba(0, 0, 0, 0.08);
    --radius: 12px;
    --shadow: 0 1px 4px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.06);
    --palm-accent: #d4a05c;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    flex: 1;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    padding: 0 16px 40px;
}

/* ── 헤더 ────────────────────────────────────── */
header {
    background: #fff;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.1);
    text-align: center;
    padding: 28px 20px 22px;
    margin-bottom: 24px;
}

header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text);
    margin-bottom: 6px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.88rem;
}

/* ── 전역 포커스 인디케이터 (WCAG 2.4.11) ── */
*:focus-visible {
    outline: 2px solid var(--palm-accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ── 면책 띠 (영구 노출) ───────────────────── */
.disclaimer-band {
    background: #fff4dc;
    border-top: 1px solid #f0d9a0;
    border-bottom: 1px solid #f0d9a0;
    color: #8b6508;
    text-align: center;
    font-size: 0.9rem;
    padding: 10px 16px;
    line-height: 1.5;
    margin-bottom: 16px;
}

.disclaimer-band.compact {
    font-size: 0.82rem;
    padding: 7px 16px;
    margin-bottom: 12px;
}

.disclaimer-band.slim {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.78rem;
    padding: 6px 16px 2px;
    margin-bottom: 8px;
}

/* ── 동의 체크박스 (터치 타겟 확장) ─────── */
.consent-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #fff8e7;
    border: 1px solid #f0d9a0;
    border-radius: 8px;
    padding: 14px 16px;
    cursor: pointer;
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--text);
    min-height: 44px;
}

.consent-box input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
    cursor: pointer;
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
}

.consent-box strong {
    color: var(--accent-dark);
}

/* ── 데이터 안심 띠 ────────────────────────── */
.privacy-note {
    background: #f0f7ff;
    border: 1px solid #d0e3f7;
    border-radius: 8px;
    padding: 10px 14px;
    color: #2b5b8b;
    font-size: 0.85rem;
    line-height: 1.5;
}

.privacy-note strong {
    color: #1a4670;
}

/* ── 사진 섹션 헤더 ────────────────────────── */
.hand-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: -4px;
}

.hand-section-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.ok-badge {
    background: var(--palm-accent);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 16px;
    letter-spacing: -0.02em;
}

/* ── 촬영 팁 일러스트 ──────────────────────── */
.tip-illustrations {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
    margin-bottom: 12px;
}

.tip-step {
    text-align: center;
}

.tip-step svg {
    width: 56px;
    height: 56px;
    margin-bottom: 4px;
}

.tip-step p {
    font-size: 0.78rem;
    color: var(--text);
    line-height: 1.4;
    margin: 0;
}

.tip-step strong {
    color: var(--accent-dark);
}

/* ── 액션 버튼 ─────────────────────────────── */
#action-card {
    padding: 16px;
}

.action-helper {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 10px;
    margin-bottom: 0;
}

.action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.action-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: inherit;
}

.action-btn:hover:not(:disabled) {
    background: var(--accent-dark);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-btn.secondary {
    background: #fff;
    color: var(--accent-dark);
    border: 1.5px solid var(--palm-accent);
}

.action-btn.secondary:hover {
    background: var(--accent-soft);
}

.action-btn.tertiary {
    background: transparent;
    color: var(--text-muted);
    width: 100%;
    border: 1px solid var(--border);
    font-weight: 500;
}

.action-btn.tertiary:hover {
    background: #fafafa;
    color: var(--text);
}

/* ── 카드 ────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 20px;
}

.card h2 {
    color: var(--text);
    font-size: 1rem;
    font-weight: 700;
    padding: 14px 20px;
    margin: 0;
    border-bottom: 1px solid var(--border);
    border-left: 4px solid var(--palm-accent);
}

/* ── 스트리밍 인디케이터 (카드 본문 상단 띠) ── */
.streaming-banner {
    align-items: center;
    gap: 10px;
    background: linear-gradient(90deg, var(--accent-soft) 0%, #fff8e7 100%);
    border-bottom: 1px solid #f0d9a0;
    color: var(--accent-dark);
    font-size: 0.88rem;
    font-weight: 500;
    padding: 10px 20px;
}

.streaming-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--palm-accent);
    box-shadow: 0 0 0 0 rgba(212, 160, 92, 0.6);
    animation: streamPulse 1.2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes streamPulse {
    0% { box-shadow: 0 0 0 0 rgba(212, 160, 92, 0.55); transform: scale(1); }
    70% { box-shadow: 0 0 0 8px rgba(212, 160, 92, 0); transform: scale(1.15); }
    100% { box-shadow: 0 0 0 0 rgba(212, 160, 92, 0); transform: scale(1); }
}

#interpretation.streaming::after {
    content: '▍';
    color: var(--palm-accent);
    animation: caretBlink 0.9s steps(2) infinite;
    margin-left: 2px;
    font-weight: bold;
}

@keyframes caretBlink {
    50% { opacity: 0; }
}

#input-section form {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-intro {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

.form-intro strong {
    color: var(--accent-dark);
    font-weight: 600;
}

/* ── 옵션 (성별·우세손) ──────────────────────── */
.form-options {
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: #fafafa;
    border-radius: 10px;
    padding: 14px 16px;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.radio-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.radio-pill {
    position: relative;
    cursor: pointer;
}

.radio-pill input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.radio-pill span {
    display: inline-block;
    padding: 9px 16px;
    border: 1px solid #d1d1d6;
    border-radius: 22px;
    background: #fff;
    font-size: 0.9rem;
    color: #5a5a5e;
    transition: all 0.15s;
    min-height: 38px;
    line-height: 1.4;
}

.radio-pill input[type="radio"]:checked + span {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.radio-pill:hover span {
    border-color: var(--palm-accent);
}

/* ── 손 슬롯 ──────────────────────────────────── */
.hand-slots {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 480px) {
    .hand-slots {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .hand-preview {
        aspect-ratio: auto;
        min-height: 140px;
    }
    .hand-icon {
        font-size: 1.6rem;
    }
    .hand-title {
        font-size: 0.85rem;
    }
    .hand-hint {
        font-size: 0.72rem;
    }
    header {
        padding: 20px 16px 16px;
        margin-bottom: 12px;
    }
    header h1 {
        font-size: 1.35rem;
    }
    .subtitle {
        font-size: 0.82rem;
    }
}

.hand-slot {
    position: relative;
}

.hand-label {
    display: block;
    cursor: pointer;
}

.hand-preview {
    aspect-ratio: 1;
    background: var(--accent-soft);
    border: 2px dashed var(--palm-accent);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.hand-preview:hover {
    background: #fff3d1;
    border-color: var(--accent-dark);
}

.hand-preview.dragover {
    background: #ffe9a0;
    border-style: solid;
    border-color: var(--accent-dark);
    transform: scale(1.01);
}

.hand-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hand-placeholder {
    text-align: center;
    padding: 16px;
}

.hand-icon {
    font-size: 2.2rem;
    margin-bottom: 8px;
}

.hand-title {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.hand-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.hand-hint-mobile { display: none; }
@media (hover: none) and (pointer: coarse) {
    .hand-hint-pc { display: none; }
    .hand-hint-mobile { display: block; }
}

.hand-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    border-radius: 16px;
    padding: 4px 10px;
    font-size: 0.78rem;
    cursor: pointer;
}

.hand-remove:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* ── 고급 설정 ────────────────────────────────── */
.advanced-settings {
    background: #fafafa;
    border-radius: 8px;
    padding: 12px 16px;
}

.advanced-settings summary {
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-muted);
}

.tip-list {
    margin-top: 10px;
    padding-left: 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.tip-list li {
    margin-bottom: 4px;
}

/* ── 버튼 ─────────────────────────────────────── */
#submit-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
    min-height: 48px;
}

#submit-btn:hover:not(:disabled) {
    background: var(--accent-dark);
}

#submit-btn:disabled {
    background: #d1d1d6;
    cursor: not-allowed;
}

#submit-btn small {
    font-weight: 400;
    opacity: 0.85;
    font-size: 0.85em;
    margin-left: 4px;
}

.submit-helper {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: -4px;
    margin-bottom: 4px;
}

.submit-helper.hidden { display: none; }

/* ── 토스트 ──────────────────────────────── */
.toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    transform: translateX(-50%) translateY(20px);
    background: rgba(28, 28, 30, 0.92);
    color: #fff;
    padding: 12px 20px;
    border-radius: 24px;
    font-size: 0.9rem;
    opacity: 0;
    transition: all 0.25s;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── 화면에선 숨김, 인쇄 시에만 표시 ──────── */
.print-only {
    display: none;
}

.action-tip {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 6px;
    margin-bottom: 0;
}

/* ── @media print: 인쇄·PDF 저장 전용 ──── */
@media print {
    /* 화면 전용 요소 모두 숨김 */
    header, footer, #input-section, #loading-section,
    #action-card, .disclaimer-band, .streaming-banner,
    #toast {
        display: none !important;
    }

    body {
        background: #fff !important;
        color: #000 !important;
        font-family: 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
        line-height: 1.6;
        padding: 0 8mm !important;
        margin: 0 !important;
    }

    .container, #result-section {
        max-width: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    #interpretation-card {
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    #interpretation-card h2 {
        border-left: none !important;
        border-bottom: 2px solid #b8860b;
        font-size: 16pt;
        padding: 0 0 8px 0;
        margin-bottom: 14px;
    }

    #interpretation {
        padding: 0 !important;
        color: #000;
    }

    #interpretation h3,
    #interpretation h4 {
        page-break-after: avoid;
        color: #8b6508 !important;
        margin-top: 14pt;
        margin-bottom: 6pt;
    }

    #interpretation h3 { font-size: 13pt; }
    #interpretation h4 { font-size: 11.5pt; }
    #interpretation p,
    #interpretation li {
        font-size: 10.5pt;
        page-break-inside: avoid;
    }

    #interpretation blockquote,
    #interpretation table {
        page-break-inside: avoid;
    }

    #interpretation table {
        display: table !important;
        width: 100% !important;
        white-space: normal !important;
        overflow: visible !important;
        font-size: 10pt;
    }

    #interpretation th,
    #interpretation td {
        border: 1px solid #999;
        padding: 6pt 8pt;
    }

    #interpretation th {
        background: #fff4dc !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* 표지 페이지 */
    .print-only.print-cover {
        display: block !important;
        page-break-after: always;
        break-after: page;
        padding: 20mm 4mm 0;
    }

    .print-cover h1 {
        font-size: 22pt;
        text-align: center;
        margin-bottom: 8mm;
    }

    .print-cover .print-date {
        text-align: center;
        color: #555;
        font-size: 10pt;
        margin-bottom: 12mm;
    }

    .print-cover hr {
        border: none;
        border-top: 1px solid #b8860b;
        margin: 8mm 0;
    }

    .print-cover h2 {
        font-size: 13pt;
        color: #8b6508;
        margin: 4mm 0;
    }

    .print-cover p, .print-cover li {
        font-size: 10.5pt;
        margin-bottom: 3mm;
    }

    .print-cover ul {
        padding-left: 6mm;
    }

    /* 페이지 여백 */
    @page {
        size: A4;
        margin: 18mm 14mm;
    }
}

.btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── 로딩 ─────────────────────────────────────── */
.loading-container {
    padding: 40px 20px;
    text-align: center;
}

.palm-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--accent-soft);
    border-top-color: var(--palm-accent);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1.2s linear infinite;
}

.loading-container p {
    color: var(--text);
    font-weight: 500;
}

.loading-steps {
    list-style: none;
    padding: 0;
    margin: 16px auto 0;
    max-width: 280px;
    text-align: left;
}

.loading-steps li {
    color: var(--text-muted);
    font-size: 0.88rem;
    padding: 6px 0 6px 28px;
    position: relative;
    transition: color 0.3s;
}

.loading-steps li::before {
    content: '○';
    position: absolute;
    left: 8px;
    top: 5px;
    color: #d1d1d6;
    font-size: 1rem;
    transition: all 0.3s;
}

.loading-steps li.active {
    color: var(--accent-dark);
    font-weight: 600;
}

.loading-steps li.active::before {
    content: '●';
    color: var(--palm-accent);
    animation: stepPulse 1.2s ease-in-out infinite;
}

@keyframes stepPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.loading-steps li.active::after {
    content: '';
    display: inline-block;
    width: 12px;
    margin-left: 4px;
    overflow: hidden;
    vertical-align: bottom;
    animation: stepDots 1.4s steps(4) infinite;
}

@keyframes stepDots {
    0%   { content: ''; }
    25%  { content: '·'; }
    50%  { content: '··'; }
    75%  { content: '···'; }
    100% { content: ''; }
}

.loading-steps li.done {
    color: var(--text);
}

.loading-steps li.done::before {
    content: '✓';
    color: var(--palm-accent);
}

/* ── 해석 결과 (마크다운) ───────────────────────── */
#interpretation {
    padding: 20px;
    color: var(--text);
}

#interpretation h2,
#interpretation h3,
#interpretation h4 {
    margin-top: 22px;
    margin-bottom: 10px;
    font-weight: 700;
}

#interpretation h2 {
    font-size: 1.1rem;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--palm-accent);
}

#interpretation h3 {
    font-size: 1rem;
    color: var(--accent-dark);
}

#interpretation h4 {
    font-size: 0.95rem;
    color: var(--text);
}

/* 헤딩(항목명) 뒤 신뢰도 라벨 — 작은 회색 글씨 */
#interpretation h3 .conf-label,
#interpretation h4 .conf-label,
#interpretation .conf-label {
    font-size: 0.68rem;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: 0;
    margin-left: 5px;
}

/* 라벨이 별도 문단으로 온 경우 */
#interpretation .conf-label-block {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: -6px;
    margin-bottom: 12px;
}

#interpretation p {
    margin-bottom: 12px;
}

#interpretation ul,
#interpretation ol {
    margin: 10px 0 14px 20px;
}

#interpretation li {
    margin-bottom: 4px;
}

#interpretation strong {
    color: var(--accent-dark);
}

#interpretation blockquote {
    border-left: 3px solid var(--palm-accent);
    background: var(--accent-soft);
    padding: 10px 14px;
    margin: 12px 0;
    color: var(--text);
    font-style: italic;
}

#interpretation table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
    font-size: 0.9rem;
    table-layout: fixed;
}

#interpretation th,
#interpretation td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
    vertical-align: top;
    word-break: keep-all;
    overflow-wrap: anywhere;
}

/* 첫 칸(영역 등)은 짧으니 좁게 고정, 둘째 칸이 남는 폭을 채우며 줄바꿈 → 오른쪽 잘림 방지 */
#interpretation th:first-child,
#interpretation td:first-child {
    width: 5.5em;
    font-weight: 600;
}

#interpretation th {
    background: var(--accent-soft);
    font-weight: 600;
}

#interpretation hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}


/* ── 푸터 ─────────────────────────────────────── */
footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 20px 16px 0;
    line-height: 1.7;
}

footer a {
    color: var(--accent-dark);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

.deploy-date {
    font-size: 0.72rem;
    opacity: 0.6;
    margin-top: 4px;
}
