/* ============================================================
   기본
============================================================ */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;

    width: 100%;
    min-height: 100%;

    font-family:
        "Pretendard",
        "Noto Sans KR",
        Arial,
        sans-serif;

    background:
        #eee9dd;

    color:
        #27231f;
}

body {
    min-height: 100vh;
}

button,
input {
    font: inherit;
}

button {
    -webkit-tap-highlight-color:
        transparent;
}


button:focus-visible,
input:focus-visible {
    outline:
        3px solid #8b725e;

    outline-offset:
        3px;
}


/* ============================================================
   전체 앱
============================================================ */

.app {
    width: 100%;
    max-width: 1000px;

    min-height: 100dvh;

    margin: 0 auto;

    background:
        #faf8f2;

    display: flex;
    flex-direction: column;

    box-shadow:
        0 0 45px
        rgba(57, 45, 33, 0.08);
}


/* ============================================================
   헤더
============================================================ */

.header {
    padding:
        28px 34px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    border-bottom:
        1px solid #ddd6c8;

    background:
        rgba(250, 248, 242, 0.96);
}


.brand {
    display: flex;
    align-items: center;

    gap: 15px;
}


.brand-mark {
    width: 54px;
    height: 54px;

    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 16px;

    background:
        #fffaf0;

    color:
        #fffaf0;

    font-family:
        serif;

    font-size: 27px;

    box-shadow:
        0 7px 20px
        rgba(70, 49, 32, 0.15);
}


/* 로고 비율을 보존해 작은 휴대폰 화면에서도 잘리지 않게 함 */
.brand-mark img {
    display: block;
    width: 88%;
    height: 88%;
    object-fit: contain;
}

.header h1 {
    margin:
        0 0 5px;

    font-size:
        27px;

    font-weight:
        750;

    letter-spacing:
        -0.04em;
}


.header p {
    margin: 0;

    color:
        #766f65;

    font-size:
        14px;

    line-height:
        1.5;
}


.status {
    flex-shrink: 0;

    padding:
        8px 14px;

    border-radius:
        999px;

    font-size:
        13px;

    font-weight:
        650;

    transition:
        0.2s;
}


.status.ready {
    background:
        #e5ede1;

    color:
        #486144;
}


.status.busy {
    background:
        #eee4ce;

    color:
        #795e31;
}


.status.speaking {
    background:
        #e6dfef;

    color:
        #5c4970;
}


.status.error {
    background:
        #f2dfdc;

    color:
        #8d4137;
}


/* ============================================================
   음성 질문 메인
============================================================ */

.voice-hero {
    padding:
        42px 30px 34px;

    text-align: center;

    background:
        linear-gradient(
            180deg,
            #f3eee3 0%,
            #faf8f2 100%
        );
}


.voice-title {
    margin-bottom:
        8px;

    font-size:
        27px;

    font-weight:
        750;

    letter-spacing:
        -0.04em;
}


.voice-description {
    margin-bottom:
        26px;

    color:
        #777065;

    font-size:
        15px;

    line-height:
        1.6;
}


/* ------------------------------------------------------------
   음성 버튼
------------------------------------------------------------- */

.voice-button {
    width:
        min(520px, 100%);

    min-height:
        112px;

    margin:
        0 auto;

    padding:
        20px 26px;

    border:
        1px solid #d4cbbc;

    border-radius:
        28px;

    background:
        white;

    display:
        flex;

    align-items:
        center;

    justify-content:
        center;

    gap:
        22px;

    cursor:
        pointer;

    color:
        #423930;

    box-shadow:
        0 12px 32px
        rgba(71, 55, 39, 0.09);

    transition:
        transform 0.12s,
        box-shadow 0.15s,
        background 0.15s;

    user-select:
        none;

    -webkit-user-select:
        none;

    touch-action:
        manipulation;
}


.voice-button:hover {
    box-shadow:
        0 15px 36px
        rgba(71, 55, 39, 0.13);
}


.voice-button:active {
    transform:
        scale(0.985);
}


.voice-circle {
    width:
        72px;

    height:
        72px;

    flex-shrink:
        0;

    position:
        relative;

    display:
        flex;

    align-items:
        center;

    justify-content:
        center;

    border-radius:
        50%;

    background:
        #675142;

    color:
        white;

    transition:
        background 0.2s,
        transform 0.2s;
}


.mic-icon {
    position:
        relative;

    z-index:
        2;

    width:
        31px;

    height:
        31px;

    display:
        flex;
}


.mic-icon svg {
    width:
        100%;

    height:
        100%;
}


.voice-button-label {
    text-align:
        left;

    display:
        flex;

    flex-direction:
        column;

    gap:
        5px;
}


.voice-button-label strong {
    font-size:
        20px;

    font-weight:
        750;
}


.voice-button-label span {
    color:
        #8a8278;

    font-size:
        13px;
}


/* ------------------------------------------------------------
   녹음 상태
------------------------------------------------------------- */

.voice-button.recording {
    background:
        #fff8f5;

    border-color:
        #b97a6d;
}


.voice-button.recording
.voice-circle {
    background:
        #99584d;

    transform:
        scale(1.06);
}


.voice-button.recording
.voice-button-label strong {
    color:
        #8d493f;
}


/* ------------------------------------------------------------
   녹음 파형
------------------------------------------------------------- */

.voice-wave {
    position:
        absolute;

    left:
        50%;

    bottom:
        -17px;

    transform:
        translateX(-50%);

    display:
        none;

    gap:
        3px;

    align-items:
        center;
}


.voice-button.recording
.voice-wave {
    display:
        flex;
}


.voice-wave span {
    width:
        3px;

    height:
        8px;

    border-radius:
        4px;

    background:
        #99584d;

    animation:
        voiceWave
        0.65s
        infinite alternate;
}


.voice-wave span:nth-child(2) {
    animation-delay:
        0.1s;
}

.voice-wave span:nth-child(3) {
    animation-delay:
        0.2s;
}

.voice-wave span:nth-child(4) {
    animation-delay:
        0.3s;
}


@keyframes voiceWave {
    from {
        height:
            5px;
    }

    to {
        height:
            18px;
    }
}


.voice-status {
    min-height:
        27px;

    margin-top:
        18px;

    font-size:
        14px;

    font-weight:
        600;

    color:
        #88584e;
}


/* ============================================================
   공통 섹션
============================================================ */

.section-title {
    margin-bottom:
        14px;

    font-size:
        15px;

    font-weight:
        750;

    color:
        #544d45;
}


/* ============================================================
   추천 질문
============================================================ */

.recommend-section {
    padding:
        26px 30px;

    border-top:
        1px solid #eee9df;

    border-bottom:
        1px solid #e5dfd3;
}


.recommendations {
    display:
        grid;

    grid-template-columns:
        repeat(4, 1fr);

    gap:
        10px;
}


.recommend-button {
    min-height:
        82px;

    padding:
        14px 10px;

    display:
        flex;

    flex-direction:
        column;

    align-items:
        center;

    justify-content:
        center;

    gap:
        7px;

    border:
        1px solid #dad2c5;

    border-radius:
        18px;

    background:
        white;

    color:
        #514941;

    cursor:
        pointer;

    transition:
        0.15s;
}


.recommend-button:hover {
    background:
        #f3efe7;

    border-color:
        #c8bdac;

    transform:
        translateY(-2px);
}


.recommend-icon {
    font-size:
        22px;
}


/* ============================================================
   대화 영역
============================================================ */

.conversation-section {
    flex:
        1;

    padding:
        26px 30px 12px;
}


.chat {
    min-height:
        240px;

    max-height:
        460px;

    padding:
        8px 2px 20px;

    overflow-y:
        auto;

    scroll-behavior:
        smooth;
}


.message {
    display:
        flex;

    flex-direction:
        column;

    margin-bottom:
        23px;
}


.message.user {
    align-items:
        flex-end;
}


.message.ai {
    align-items:
        flex-start;
}


.message-name {
    margin:
        0 7px 6px;

    color:
        #827a70;

    font-size:
        12px;
}


.bubble {
    max-width:
        78%;

    padding:
        15px 18px;

    border-radius:
        19px;

    font-size:
        16px;

    line-height:
        1.7;

    word-break:
        keep-all;

    white-space:
        pre-wrap;
}


.message.ai
.bubble {
    background:
        #eee8dc;

    border-bottom-left-radius:
        5px;
}


.message.user
.bubble {
    background:
        #594638;

    color:
        white;

    border-bottom-right-radius:
        5px;
}


/* ------------------------------------------------------------
   답변 하단 기능 버튼
------------------------------------------------------------- */

.message-actions {
    margin-top:
        8px;

    display:
        flex;

    gap:
        7px;
}


.replay-button {
    padding:
        7px 12px;

    border:
        1px solid #d1c8ba;

    border-radius:
        999px;

    background:
        #fff;

    color:
        #62584f;

    font-size:
        13px;

    cursor:
        pointer;
}


.replay-button:hover {
    background:
        #f2ede5;
}


/* ------------------------------------------------------------
   답변 생성 중
------------------------------------------------------------- */

.typing {
    opacity:
        0.65;
}


/* ============================================================
   입력
============================================================ */

.input-area {
    padding:
        18px 30px 26px;

    border-top:
        1px solid #e0d9cd;

    background:
        #faf8f2;
}


.input-label {
    margin-bottom:
        9px;

    color:
        #7b746b;

    font-size:
        13px;

    font-weight:
        600;
}


.text-input-row {
    display:
        flex;

    gap:
        8px;
}


#questionInput {
    flex:
        1;

    min-width:
        0;

    height:
        52px;

    padding:
        0 19px;

    border:
        1px solid #d3cbbc;

    border-radius:
        26px;

    background:
        white;

    outline:
        none;

    font-size:
        15px;
}


#questionInput:focus {
    border-color:
        #756050;

    box-shadow:
        0 0 0 3px
        rgba(102, 80, 63, 0.07);
}


.send-button {
    width:
        52px;

    height:
        52px;

    flex-shrink:
        0;

    border:
        none;

    border-radius:
        50%;

    background:
        #594638;

    color:
        white;

    font-size:
        24px;

    cursor:
        pointer;
}


.send-button:hover {
    background:
        #44352b;
}


/* ============================================================
   비활성화
============================================================ */

button:disabled,
input:disabled {
    cursor:
        not-allowed;

    opacity:
        0.55;
}


/* ============================================================
   모바일
============================================================ */

@media (max-width: 700px) {

    .header {
        padding:
            19px 17px;
    }


    .brand-mark {
        width:
            46px;

        height:
            46px;

        border-radius:
            13px;

        font-size:
            23px;
    }


    .header h1 {
        font-size:
            21px;
    }


    .header p {
        font-size:
            12px;
    }


    .status {
        display:
            none;
    }


    .voice-hero {
        padding:
            32px 17px 25px;
    }


    .voice-title {
        font-size:
            23px;
    }


    .voice-button {
        min-height:
            100px;

        padding:
            16px 19px;

        border-radius:
            23px;

        justify-content:
            flex-start;
    }


    .voice-circle {
        width:
            62px;

        height:
            62px;
    }


    .voice-button-label strong {
        font-size:
            18px;
    }


    .recommend-section {
        padding:
            20px 15px;
    }


    .recommendations {
        grid-template-columns:
            repeat(2, 1fr);
    }


    .recommend-button {
        min-height:
            76px;
    }


    .conversation-section {
        padding:
            22px 15px 8px;
    }


    .bubble {
        max-width:
            89%;

        font-size:
            15px;
    }


    .input-area {
        padding:
            15px 15px 22px;
    }
}


/* ============================================================
   키오스크 / 큰 화면
============================================================ */

@media (min-width: 1100px) {

    .voice-hero {
        padding-top:
            50px;

        padding-bottom:
            42px;
    }


    .voice-title {
        font-size:
            31px;
    }


    .voice-button {
        min-height:
            125px;
    }


    .bubble {
        font-size:
            18px;
    }

}


/* 입력창 옆에서 음성 질문을 시작하는 버튼임 */
.input-area .voice-button {
    width:
        52px;

    min-height:
        52px;

    height:
        52px;

    margin:
        0;

    padding:
        0;

    flex:
        0 0 52px;

    border-radius:
        50%;

    border:
        none;

    background:
        #e8dfd1;

    display:
        flex;

    align-items:
        center;

    justify-content:
        center;

    color:
        #594638;

    box-shadow:
        none;
}


.input-area .voice-button:hover {
    background:
        #dcd0bf;

    box-shadow:
        none;
}


.input-area .voice-button.recording {
    background:
        #99584d;

    color:
        white;

    border:
        none;
}


.input-area .voice-button .mic-icon {
    width:
        23px;

    height:
        23px;
}


.input-area .voice-wave {
    display:
        none !important;
}


.input-area .voice-status {
    min-height:
        0;

    margin:
        8px 4px 0;

    color:
        #88584e;

    font-size:
        13px;

    line-height:
        1.4;
}


.screen-reader-only {
    position:
        absolute;

    width:
        1px;

    height:
        1px;

    padding:
        0;

    margin:
        -1px;

    overflow:
        hidden;

    clip:
        rect(0, 0, 0, 0);

    white-space:
        nowrap;

    border:
        0;
}


/* ============================================================
   휴대폰 우선 조정
============================================================ */

@media (max-width: 700px) {

    html {
        background:
            #faf8f2;

        overscroll-behavior-y:
            none;
    }


    body {
        min-height:
            100dvh;
    }


    .app {
        min-height:
            100dvh;

        box-shadow:
            none;
    }


    .header {
        position:
            sticky;

        top:
            0;

        z-index:
            10;

        min-height:
            72px;

        padding:
            calc(12px + env(safe-area-inset-top)) 16px 12px;

        gap:
            10px;

        background:
            rgba(250, 248, 242, 0.94);

        backdrop-filter:
            blur(14px);
    }


    .brand {
        min-width:
            0;

        gap:
            10px;
    }


    .brand-mark {
        width:
            42px;

        height:
            42px;

        border-radius:
            12px;

        font-size:
            21px;
    }


    .header h1 {
        margin:
            0;

        font-size:
            18px;

        white-space:
            nowrap;
    }


    .header p {
        display:
            none;
    }


    .status {
        display:
            block;

        padding:
            7px 10px;

        font-size:
            12px;

        white-space:
            nowrap;
    }


    .voice-hero {
        padding:
            25px 16px 18px;
    }


    .voice-title {
        margin-bottom:
            6px;

        font-size:
            24px;
    }


    .voice-description {
        max-width:
            290px;

        margin:
            0 auto 19px;

        font-size:
            14px;
    }


    .recommend-section {
        padding:
            18px 16px;
    }


    .section-title {
        margin-bottom:
            11px;
    }


    .recommendations {
        display:
            flex;

        gap:
            9px;

        margin:
            0 -16px;

        padding:
            0 16px 4px;

        overflow-x:
            auto;

        scroll-snap-type:
            x mandatory;

        scrollbar-width:
            none;
    }


    .recommendations::-webkit-scrollbar {
        display:
            none;
    }


    .recommend-button {
        min-width:
            130px;

        min-height:
            76px;

        flex:
            0 0 130px;

        scroll-snap-align:
            start;

        font-size:
            14px;
    }


    .conversation-section {
        padding:
            21px 16px 12px;
    }


    .chat {
        min-height:
            200px;

        max-height:
            none;

        padding-bottom:
            10px;
    }


    .message {
        margin-bottom:
            18px;
    }


    .bubble {
        max-width:
            92%;

        padding:
            14px 16px;

        font-size:
            16px;

        line-height:
            1.65;
    }


    .replay-button {
        min-height:
            42px;

        padding:
            8px 14px;

        font-size:
            14px;
    }


    .input-area {
        position:
            sticky;

        bottom:
            0;

        z-index:
            10;

        padding:
            12px 16px calc(12px + env(safe-area-inset-bottom));

        background:
            rgba(250, 248, 242, 0.96);

        backdrop-filter:
            blur(14px);

        box-shadow:
            0 -8px 20px rgba(63, 47, 31, 0.06);
    }


    .input-label {
        display:
            none;
    }


    .text-input-row {
        gap:
            10px;
    }


    #questionInput {
        height:
            54px;

        padding:
            0 18px;

        font-size:
            16px;
    }


    .send-button {
        width:
            54px;

        height:
            54px;

        font-size:
            25px;
    }


    .input-area .voice-button {
        width:
            54px;

        min-height:
            54px;

        height:
            54px;

        flex-basis:
            54px;
    }
}


@media (max-width: 360px) {

    .header h1 {
        font-size:
            16px;
    }


    .status {
        padding:
            6px 8px;

        font-size:
            11px;
    }


    .voice-button {
        min-height:
            130px;
    }
}

/* 대화와 입력줄을 한 화면에 유지하는 모바일 앱형 배치임 */
.input-hint { margin: 9px 4px 0; font-size: 12px; color: #756b60; }
button:disabled { opacity: .5; cursor: wait; }
.bubble { overflow-wrap: anywhere; white-space: pre-wrap; }
.conversation-section { flex: 1; min-height: 0; }
/* PC도 입력줄이 처음부터 보이도록 대화 부분만 스크롤함 */
@media (min-width: 701px) {
    .app { height: 100dvh; min-height: 620px; overflow: hidden; }
    .header { flex: 0 0 auto; padding: 18px 30px; }
    .voice-hero { flex: 0 0 auto; padding: 22px 30px 16px; }
    .voice-description { margin-bottom: 0; }
    .recommend-section { flex: 0 0 auto; padding: 14px 30px; }
    .recommend-button { min-height: 62px; }
    .conversation-section { display: flex; flex-direction: column; overflow: hidden; padding: 16px 30px 0; }
    .chat { flex: 1; min-height: 0; max-height: none; }
    .input-area { flex: 0 0 auto; padding: 12px 30px 16px; }
}
@media (max-width: 700px) {
    html, body { height: 100%; overflow: hidden; }
    .app { height: var(--app-height, 100dvh); min-height: 0; overflow: hidden; }
    .header { position: relative; flex: 0 0 auto; min-height: 62px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; }
    .header h1 { font-size: clamp(15px, 4.3vw, 18px); }
    .status { max-width: 104px; overflow: hidden; text-overflow: ellipsis; }
    .voice-hero { flex: 0 0 auto; text-align: left; padding: 17px 16px 8px; }
    .voice-title { font-size: 20px; }
    .voice-description { max-width: none; margin: 0; font-size: 13px; }
    .recommend-section { flex: 0 0 auto; padding: 9px 16px 12px; }
    .recommend-section .section-title, .conversation-section > .section-title { display: none; }
    .recommendations { gap: 7px; }
    .recommend-button { flex: 0 0 auto; min-width: 0; min-height: 44px; padding: 10px 13px; border-radius: 24px; flex-direction: row; gap: 7px; }
    .recommend-icon { font-size: 16px; }
    .conversation-section { display: flex; flex-direction: column; padding: 8px 14px 0; overflow: hidden; }
    .chat { flex: 1; min-height: 0; max-height: none; overflow-y: auto; overscroll-behavior: contain; }
    .bubble { max-width: 94%; font-size: 16px; padding: 13px 15px; }
    .input-area { position: relative; flex: 0 0 auto; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
    .text-input-row { gap: 7px; }
    #questionInput { padding: 0 13px; height: 50px; }
    .input-area .voice-button, .send-button { width: 50px; height: 50px; min-height: 50px; flex: 0 0 50px; }
    .input-area .voice-status:empty { display: none; }
    .input-area .voice-status { max-height: 72px; overflow-y: auto; }
}
/* 가로 화면·키보드 사용 중에는 소개를 접어 실제 대화 공간을 확보함 */
@media (max-width: 700px) and (max-height: 540px) {
    .voice-hero { display: none; }
    .recommend-section { padding-top: 5px; padding-bottom: 5px; }
    .input-hint { display: none; }
}

/* 여섯 안내 분야를 모바일에서 고르고 대화 중에는 접을 수 있도록 구성함 */
.guide-menu > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; min-height: 40px; font-size: 15px; font-weight: 600; color: #594638; }
.guide-menu > summary span { font-size: 12px; font-weight: 400; }
.guide-menu > summary span::after { content: ' +'; }
.guide-menu[open] > summary span::after { content: ' −'; }
.guide-categories { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-height: min(32dvh, 320px); overflow-y: auto; overscroll-behavior: contain; padding: 3px 2px 6px; }
.guide-category { border: 1px solid #ded5c7; border-radius: 12px; background: #fffdf8; min-width: 0; }
.guide-category > summary { padding: 13px 12px; min-height: 46px; box-sizing: border-box; color: #594638; cursor: pointer; font-size: 14px; }
.guide-category[open] { grid-column: 1 / -1; }
.guide-category[open] > summary { background: #eee7db; border-radius: 12px 12px 0 0; }
.guide-questions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; padding: 10px; }
.guide-questions .recommend-button, .guide-questions a { display: flex; align-items: center; justify-content: flex-start; min-width: 0; min-height: 44px; margin: 0; padding: 10px; border: 1px solid #e5dfd5; border-radius: 9px; white-space: normal; font-size: 13px; line-height: 1.4; text-align: left; text-decoration: none; color: #594638; background: #fff; box-sizing: border-box; }
.guide-about.recommend-button { display: block; min-height: 36px; margin: 5px 0 0; padding: 5px 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; font-size: 12px; text-align: left; }
.guide-menu summary:focus-visible, .guide-questions button:focus-visible, .guide-questions a:focus-visible { outline: 2px solid #00695c; outline-offset: 2px; }
@media (max-width: 700px) {
    .guide-categories { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; max-height: 27dvh; }
    .guide-menu > summary { min-height: 34px; font-size: 13px; }
    .guide-category > summary { font-size: 12px; padding: 12px 8px; }
    .guide-questions { gap: 6px; padding: 8px; }
    .guide-questions .recommend-button, .guide-questions a { font-size: 12px; }
}
@media (max-height: 540px) {
    .guide-categories { max-height: 100px; }
    .guide-about.recommend-button { display: none; }
}
