/* ═══════════════════════════════════════════
   BestTRL 기본 스타일 (base.css)
   미니멀 디자인 - 최소 9px 글자
   마하님 레이아웃 정책:
   - 일반 페이지: 98%
   - 문서형: 85%
   - 메시지창: 350px
   - 글자 최소 9px
   ═══════════════════════════════════════════ */


/* === 1. 리셋 === */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
}


/* === 2. 색상 + 레이아웃 변수 === */
:root {
    /* 색상 */
    --color-main: #1e3a5f;
    --color-main-hover: #2a4a7f;
    --color-light: #4a6fa5;
    --color-bg: #ffffff;
    --color-text: #1e3a5f;
    --color-text-light: #1e3a5f;
    --color-border: #e8e8e8;
    --color-bg-light: #f8f9fb;
    
    --color-success: #2e7d32;
    --color-warning: #f57c00;
    --color-error: #c62828;
    --color-info: #1976d2;
    
    /* 마하님 레이아웃 정책 */
    --width-page: 98%;
    --width-document: 85%;
    --width-message: 350px;
    --max-page: 1400px;
    --max-document: 1100px;
    
    /* 글자 크기 (절대 9px 미만 X) */
    --font-min: max(9px, 0.5625rem);
    --font-small: max(10px, 0.625rem);
    --font-base: max(11px, 0.6875rem);
    --font-medium: max(13px, 0.8125rem);
    --font-large: max(16px, 1rem);
    --font-xl: max(20px, 1.25rem);
}


/* === 3. 본문 === */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI',
                 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: var(--font-base);
    line-height: 1.65;
    min-height: 100vh;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}


/* === 4. 레이아웃 (마하님 정책) === */
.container {
    width: var(--width-page);
    max-width: var(--max-page);
    height: auto;
    margin: 0 auto;
    padding: 10px 0;
}

.document-content,
.document-wrap {
    width: var(--width-document);
    max-width: var(--max-document);
    height: auto;
    margin: 10px auto;
}

.message-content,
.message-wrap {
    width: var(--width-message);
    max-width: 95vw;
    height: auto;
    margin: 30px auto;
}

.card {
    width: 100%;
    height: auto;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 18px;
    margin: 10px 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.section {
    width: 100%;
    height: auto;
    margin: 12px 0;
}


/* === 5. 글자 크기 === */
h1 {
    font-size: max(17px, 1.0625rem);
    color: var(--color-main);
    font-weight: 700;
    margin-bottom: 7px;
    letter-spacing: -0.02em;
}

h2 {
    font-size: max(14px, 0.875rem);
    color: var(--color-main);
    font-weight: 600;
    margin-bottom: 5px;
    letter-spacing: -0.01em;
}

h3 {
    font-size: max(12px, 0.75rem);
    color: var(--color-main);
    font-weight: 600;
    margin-bottom: 4px;
}

p, label, span {
    font-size: var(--font-base);
    line-height: 1.65;
}

.small {
    font-size: var(--font-min);
    color: var(--color-text-light);
}


/* === 6. 입력 칸 === */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
select,
textarea {
    width: 100%;
    height: auto;
    font-size: var(--font-base);
    padding: 7px 9px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: white;
    color: var(--color-text);
    transition: border-color 0.2s;
    margin: 3px 0;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-main);
}

input::placeholder {
    color: #999999;
    font-size: var(--font-small);
}

label {
    display: block;
    margin-bottom: 3px;
    font-weight: 500;
    color: var(--color-text);
    font-size: var(--font-base);
}


/* === 7. 버튼 === */
button,
.btn {
    width: 100%;
    height: auto;
    padding: 9px 13px;
    font-size: var(--font-base);
    font-weight: 600;
    background: var(--color-main);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
    letter-spacing: -0.01em;
}

button:hover,
.btn:hover {
    background: var(--color-main-hover);
}

button:disabled,
.btn:disabled {
    background: #d0d0d0;
    cursor: not-allowed;
}

.btn-secondary {
    background: white;
    color: var(--color-main);
    border: 1px solid var(--color-main);
}

.btn-secondary:hover {
    background: var(--color-bg-light);
}

.btn-small {
    width: auto;
    padding: 4px 8px;
    font-size: var(--font-min);
}


/* === 8. 메시지창 === */
.message,
.modal,
.alert,
.toast {
    width: var(--width-message);
    max-width: 95vw;
    height: auto;
    margin: 0 auto;
    padding: 14px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}


/* === 9. 알림 박스 === */
.notice {
    width: 100%;
    padding: 9px 11px;
    border-radius: 6px;
    margin: 7px 0;
    font-size: var(--font-small);
}

.notice-info {
    background: #e3f2fd;
    color: var(--color-info);
    border-left: 3px solid var(--color-info);
}

.notice-success {
    background: #e8f5e9;
    color: var(--color-success);
    border-left: 3px solid var(--color-success);
}

.notice-warning {
    background: #fff3e0;
    color: var(--color-warning);
    border-left: 3px solid var(--color-warning);
}

.notice-error {
    background: #ffebee;
    color: var(--color-error);
    border-left: 3px solid var(--color-error);
}


/* === 10. 헤더 === */
header {
    width: 100%;
    background: white;
    border-bottom: 1px solid var(--color-border);
    padding: 9px 0;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header .logo {
    font-size: max(14px, 0.875rem);
    font-weight: 700;
    color: var(--color-main);
    text-decoration: none;
    letter-spacing: -0.02em;
}

header nav {
    display: flex;
    gap: 10px;
    align-items: center;
}

header nav a {
    color: var(--color-text);
    text-decoration: none;
    font-size: var(--font-small);
    font-weight: 500;
}

header nav a:hover {
    color: var(--color-main);
}


/* === 11. 푸터 === */
footer {
    width: 100%;
    background: var(--color-bg-light);
    padding: 15px 0;
    margin-top: 22px;
    border-top: 1px solid var(--color-border);
}

footer .container {
    text-align: center;
}

footer p {
    color: var(--color-text-light);
    font-size: var(--font-min);
    margin: 2px 0;
}

footer .trust-badge {
    background: white;
    padding: 9px;
    border-radius: 8px;
    margin: 9px auto;
    display: inline-block;
    color: var(--color-main);
    font-weight: 500;
}


/* === 12. 도움말 === */
.hint {
    font-size: var(--font-min);
    color: var(--color-text-light);
    margin-top: 3px;
    line-height: 1.5;
}

.hint-box {
    background: var(--color-bg-light);
    border-radius: 6px;
    padding: 7px 9px;
    margin: 5px 0;
    font-size: var(--font-min);
    color: var(--color-text);
}


/* === 13. 한도 선택 옵션 === */
.option-group {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin: 9px 0;
}

.option {
    flex: 1;
    min-width: 55px;
    padding: 8px;
    text-align: center;
    border: 1.5px solid var(--color-border);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: var(--font-base);
    font-weight: 600;
    color: var(--color-text);
    transition: all 0.2s;
}

.option:hover {
    border-color: var(--color-main);
    background: var(--color-bg-light);
}

.option.selected {
    border-color: var(--color-main);
    background: var(--color-main);
    color: white;
}

.option .badge {
    display: block;
    font-size: var(--font-min);
    color: var(--color-warning);
    margin-top: 2px;
    font-weight: 500;
}


/* === 14. 잔액 표시 === */
.balance-display {
    text-align: center;
    padding: 20px 14px;
    background: var(--color-main);
    color: white;
    border-radius: 10px;
    margin: 13px auto;
}

.balance-display .amount {
    font-size: max(26px, 1.625rem);
    font-weight: 700;
    margin: 5px 0;
    letter-spacing: -0.02em;
}

.balance-display .label {
    font-size: var(--font-small);
    opacity: 0.85;
}


/* === 15. AI 도우미 === */
.ai-helper {
    position: fixed;
    bottom: 14px;
    right: 14px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--color-main);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-size: max(17px, 1.0625rem);
    transition: all 0.2s;
}

.ai-helper:hover {
    background: var(--color-main-hover);
    transform: scale(1.08);
}


/* === 16. 신뢰 메시지 === */
.trust-message {
    background: var(--color-bg-light);
    padding: 8px;
    text-align: center;
    border-radius: 6px;
    margin: 9px auto;
    font-size: var(--font-min);
    color: var(--color-main);
    width: 100%;
}

.trust-message strong {
    color: var(--color-success);
}


/* === 17. 로딩 === */
.loading {
    text-align: center;
    padding: 26px 14px;
    color: var(--color-text-light);
}

.spinner {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-main);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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


/* === 18. 가입 단계 === */
.steps {
    display: flex;
    justify-content: space-between;
    margin: 13px auto;
    width: 100%;
}

.step {
    flex: 1;
    text-align: center;
    padding: 5px;
    color: var(--color-text-light);
    font-size: var(--font-min);
    border-bottom: 2px solid var(--color-border);
}

.step.active {
    color: var(--color-main);
    border-bottom-color: var(--color-main);
    font-weight: 600;
}

.step.done {
    color: var(--color-success);
    border-bottom-color: var(--color-success);
}


/* === 19. 스마트폰 미세 조정 === */
@media (max-width: 480px) {
    .container {
        padding: 5px 0;
    }
    
    .document-content,
    .document-wrap {
        width: 95%;
    }
    
    .message-content,
    .message-wrap {
        width: 95%;
        margin: 15px auto;
    }
    
    .card {
        padding: 11px;
        margin: 7px 0;
    }
    
    .ai-helper {
        width: 40px;
        height: 40px;
        font-size: 15px;
        bottom: 9px;
        right: 9px;
    }
    
    .option {
        min-width: 50px;
        padding: 7px;
    }
    
    .balance-display .amount {
        font-size: max(22px, 1.375rem);
    }
}


/* === 19.5 영상 (마하님 정수: 가로 100%, 새로 자동) === */
video,
iframe,
.video,
.video-wrap {
    width: 100%;
    height: auto;
    max-width: 100%;
    display: block;
    margin: 10px auto;
}

.video-frame {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
}


/* === 19.7 그림 (마하님 정수: 가로 350px, 새로 자동) === */
img,
.image,
.photo {
    width: var(--width-message);
    max-width: 100%;
    height: auto;
    display: block;
    margin: 10px auto;
}

img.full,
.image.full {
    width: 100%;
}

img.thumb,
.image.thumb {
    width: 100px;
}


/* === 20. 유틸리티 === */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mt-30 { margin-top: 30px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }
.mb-30 { margin-bottom: 30px; }

.hidden { display: none; }
.flex { display: flex; }
.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}