/* ==============================
   基本設定
============================== */

:root {
    --color-background: #fafaf7;
    --color-white: #ffffff;
    --color-input: #fafafa;
    --color-ai-message: #f0f1f2;
    --color-border: #e3e5e7;

    --color-text: #333333;
    --color-subtext: #777777;
    --color-placeholder: #a8adb3;

    --color-accent: #71879b;
    --color-disabled: #c9cdd1;

    --header-height: 64px;
    --input-area-min-height: 125px;

    /* Peco専用領域 */
    --peco-dock-height: 140px;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    max-width: 100%;
    height: 100%;
    margin: 0;
    
    overflow-x: hidden;
}

body {
    background-color: #eeeeec;
    color: var(--color-text);

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Hiragino Kaku Gothic ProN",
        "Yu Gothic",
        sans-serif;
}


/* ==============================
   アプリ全体
============================== */

.app {
    position: relative;

    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;

    overflow-x: clip;
    overflow-y: hidden;

    background-color: var(--color-background);
}


/* ==============================
   ヘッダー
============================== */

.header {
    position: absolute;
    z-index: 20;
    top: 0;
    left: 0;

    width: 100%;
    min-height: var(--header-height);
    padding: 9px 12px 8px;

    text-align: center;

    background-color: var(--color-white);
    border-bottom: 1px solid var(--color-border);
}

.service-title {
    margin: 0;

    font-size: 17px;
    font-weight: 600;
    line-height: 1.4;
}

.search-area-label {
    margin: 3px 0 0;

    color: var(--color-subtext);

    font-size: 12px;
    line-height: 1.4;
}


/* ==============================
   初回画面
============================== */

.initial-screen {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;

    padding:
        calc(var(--header-height) + 20px)
        8px
        calc(var(--input-area-min-height) + 100px);
}

.area-selector {
    width: 100%;
}

.area-selector-title {
    margin: 0 0 10px;

    color: var(--color-subtext);

    font-size: 13px;
    font-weight: 500;
}

.radio-group {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: nowrap;

    width: 100%;
    gap: 8px;
}

.radio-label {
    display: inline-flex;
    align-items: center;

    min-height: 44px;

    cursor: pointer;

    font-size: 14px;
    white-space: nowrap;
}

.radio-label input {
    width: 17px;
    height: 17px;
    margin: 0 4px 0 0;

    accent-color: var(--color-accent);
}


/* ==============================
   会話エリア
============================== */

.chat-area {
    position: absolute;
    top: var(--header-height);

    bottom: calc(
        var(--input-area-min-height)
        + var(--peco-dock-height)
    );
    
    left: 0;

    width: 100%;
    padding: 12px 8px 16px;

    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-behavior: smooth;

    background-color: var(--color-background);
}

.conversation-group {
    width: 100%;
    margin-bottom: 16px;
}

.message-row {
    display: flex;
    width: 100%;
}

.user-row {
    justify-content: flex-end;
}

.ai-row {
    justify-content: flex-start;
    margin-top: 8px;
}

.message {
    max-width: 88%;

    color: var(--color-text);

    font-size: 15px;
    overflow-wrap: anywhere;
}

.user-message {
    padding: 10px 12px;

    line-height: 1.6;

    background-color: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 16px 16px 4px 16px;
}

.ai-message {
    padding: 12px;

    line-height: 1.7;

    background-color: var(--color-ai-message);
    border-radius: 16px 16px 16px 4px;
}

.thinking-message {
    color: var(--color-subtext);
}

.ai-message p {
    margin: 0 0 10px;
}

.ai-message p:last-child {
    margin-bottom: 0;
}

.answer-item {
    display: flex;
    flex-direction: column;
    gap: 2px;

    margin-top: 12px;
}

.answer-item strong {
    font-size: 15px;
}

.answer-item span {
    font-size: 14px;
}


/* ==============================
   入力エリア
============================== */

.input-area {
    position: absolute;
    z-index: 30;
    right: 0;
    bottom: 0;
    left: 0;

    min-height: var(--input-area-min-height);
    padding:
        8px
        8px
        calc(8px + env(safe-area-inset-bottom));

    background-color: var(--color-white);
    border-top: 1px solid var(--color-border);
}

.input-box {
    position: relative;

    display: flex;
    align-items: flex-end;

    width: 100%;
    min-height: 44px;

    background-color: var(--color-input);
    border: 1px solid var(--color-border);
    border-radius: 18px;
}

.question-input {
    display: block;

    width: 100%;
    min-height: 42px;
    max-height: 120px;
    padding: 10px 50px 10px 14px;

    resize: none;
    overflow-y: auto;

    color: var(--color-text);

    font-family: inherit;
    font-size: 16px;
    line-height: 1.5;

    background: transparent;
    border: none;
    outline: none;
}

.question-input::placeholder {
    color: var(--color-placeholder);
}

.send-button {
    position: absolute;
    right: 0;
    bottom: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 44px;
    height: 44px;
    padding: 11px;

    cursor: default;

    color: var(--color-disabled);

    background: transparent;
    border: none;
    border-radius: 50%;
}

.send-button svg {
    width: 22px;
    height: 22px;

    fill: currentColor;
}

.send-button.active {
    cursor: pointer;
    color: var(--color-accent);
}

.send-button.active:active {
    transform: scale(0.92);
}


/* ==============================
   ぺこちゃん
============================== */

.peco-area {
    position: absolute;
    z-index: 25;
    right: 8px;
    bottom: calc(
        var(--input-area-min-height)
        + env(safe-area-inset-bottom)
        + 8px
    );

    width: 140px;
    height: 140px;

    pointer-events: none;
}

.peco-image {
    position: absolute;
    right: 0;
    bottom: 0;

    display: block;

    width: 140px;
    max-width: none;
    height: auto;
}

.peco-placeholder {
    position: absolute;
    right: 0;
    bottom: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 64px;
    height: 64px;

    font-size: 46px;
    line-height: 1;
}

.status-mark {
    position: absolute;
    z-index: 2;

    top: -8px;
    right: 8px;

    min-width: 28px;

    color: var(--color-accent);

    font-size: 26px;
    font-weight: 700;
    line-height: 1;

    text-align: center;

    filter:
        drop-shadow(1px 0 0 #ffffff)
        drop-shadow(-1px 0 0 #ffffff)
        drop-shadow(0 1px 0 #ffffff)
        drop-shadow(0 -1px 0 #ffffff);
}

.idea-mark {
    font-size: 28px;
}




/* ==============================
   画面幅が狭い端末
============================== */

@media (max-width: 350px) {
    .radio-group {
        gap: 4px;
    }

    .radio-label {
        font-size: 13px;
    }

    .radio-label input {
        margin-right: 2px;
    }
}

/* ==============================
   高さが低いスマートフォン向け
============================== */

@media (max-height: 700px) {
     :root {
        --peco-dock-height: 108px;
    }

    .peco-area {
        width: 96px;
        height: 100px;

        right: 8px;
        bottom: calc(
            var(--input-area-min-height)
            + env(safe-area-inset-bottom)
            + 4px
        );
    }

    .peco-image {
        width: 96px;
    }

    .status-mark {
        top: -6px;
        right: 2px;

        font-size: 22px;
    }

    
}

/* ==========================
   AI Peco 共通注意書き
========================== */

.peco-disclaimer {
    margin: 6px 8px 0;
    font-size: 12px;
    line-height: 1.5;
    color: #777777;
    text-align: center;
}

/* ==============================
   プライバシーポリシー
============================== */

.privacy-area {
    margin-top: 8px;
    text-align: center;
}

.privacy-area a {
    color: var(--color-subtext);
    font-size: 11px;
    line-height: 1.5;
    text-decoration: underline;
}

.privacy-area a:hover {
    color: var(--color-accent);
}

/* ==========================
   プライバシーポリシー
========================== */

.peco-privacy {
    margin: 4px 8px 0;
    font-size: 11px;
    line-height: 1.4;
    text-align: center;
}

.peco-privacy a {
    color: var(--color-subtext);
    text-decoration: underline;
}