/* Base Styles */
:root {
    --color-bg: #FFF8EF;
    /* クリーム */
    --color-primary: #F4A261;
    /* 猫オレンジ */
    --color-primary-dark: #D68C53;
    /* 濃いオレンジ */
    --color-accent: #E76F51;
    /* エラーなど */
    --color-text: #333333;
    --color-text-light: #666666;
    --color-white: #FFFFFF;
    --color-bubble-cat: #FFFFFF;
    --color-bubble-user: #E9F5DB;
    /* 薄い緑 */

    --font-base: "M PLUS Rounded 1c", sans-serif;
    --font-heading: "Kiwi Maru", serif;

    --radius-bubble: 20px;
    --radius-btn: 50px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-base);
    color: var(--color-text);
    background-color: var(--color-bg);
    line-height: 1.6;
    height: 100dvh;
}

/* Screen Management */
.screen {
    display: none;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.screen.active {
    opacity: 1;
}

.full-screen.active {
    display: flex;
    flex-direction: column;
}

.split-screen.active {
    display: flex;
    flex-direction: row;
    /* 左右分割 */
}

/* --- Split Layout --- */
.chat-section {
    width: 40%;
    /* チャットエリア幅 */
    height: 100%;
    display: flex;
    flex-direction: column;
    border-right: 2px solid #ddd;
    background-color: #fff;
    z-index: 10;
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.05);
}

.preview-section {
    width: 60%;
    /* プレビューエリア幅 */
    height: 100%;
    background-color: #eee;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
}

/* Chat Section Details */
.chat-header {
    height: 80px;
    background-color: var(--color-white);
    padding: 0 20px;
    display: flex;
    align-items: center;
    border-bottom: 2px solid rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.header-cat {
    margin-right: 15px;
    background: var(--color-bg);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid var(--color-primary);
}

.header-cat img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.header-info h2 {
    font-size: 1.2rem;
    color: var(--color-text);
}

.status {
    font-size: 0.8rem;
    color: #4CAF50;
    /* Online Green */
    font-weight: 700;
}

.status::before {
    content: "●";
    margin-right: 4px;
}

.reset-btn {
    margin-left: auto;
    font-size: 0.9rem;
    padding: 8px 16px;
    background-color: #ddd;
    color: #555;
    box-shadow: none;
    border-radius: 50px;
    /* Force Rounded */
}

.chat-history {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 80px;
    /* Ensure last message is not hidden */
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
    background-color: var(--color-bg);
    /* チャットっぽく色付け */
}

.message {
    display: flex;
    align-items: flex-end;
    max-width: 90%;
    animation: popIn 0.3s ease-out forwards;
    opacity: 0;
    transform: scale(0.9);
}

.message.cat {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-icon {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
    border: 2px solid #eee;
}

.message-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    /* 顔中心に */
}

.message.user .message-icon {
    margin-right: 0;
    margin-left: 10px;
    background: #ccc;
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    /* ユーザーアイコンは絵文字のままかもしくは画像か要検討だが一旦これ */
    font-weight: bold;
}

.message-text {
    padding: 15px 20px;
    border-radius: var(--radius-bubble);
    font-size: 1rem;
    line-height: 1.6;
    position: relative;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.message.cat .message-text {
    background-color: var(--color-bubble-cat);
    border-bottom-left-radius: 5px;
}

.message.user .message-text {
    background-color: var(--color-bubble-user);
    border-bottom-right-radius: 5px;
}

.chat-input-area {
    padding: 20px;
    background-color: var(--color-white);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.input-container {
    display: flex;
    gap: 10px;
    width: 100%;
}

#user-input {
    flex-grow: 1;
}

#send-btn {
    min-width: 80px;
    padding: 0 15px;
    font-size: 1rem;
    height: 50px;
    /* Match single line input height approx */
    align-self: flex-end;
    /* Align bottom for textarea */
    margin-bottom: 2px;
    /* Slight adjustment */
    border-radius: 50px;
    /* Force Rounded */
}

#user-input,
#user-textarea {
    flex-grow: 1;
    padding: 12px 15px;
    font-size: 16px;
    /* Prevent iOS Zoom */
    border: 2px solid #ddd;
    border-radius: 15px;
    outline: none;
    transition: border-color 0.3s;
    font-family: inherit;
    width: 100%;
    min-height: 44px;
    /* Touch friendly */
}

#user-input:focus,
#user-textarea:focus {
    border-color: var(--color-primary);
}

#user-textarea {
    resize: vertical;
    /* Allow resize on PC */
    line-height: 1.5;
    min-height: 80px;
    /* Better default for textarea */
}

.hidden {
    display: none !important;
}


/* --- Preview Section Details --- */
.device-switcher {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.device-btn {
    padding: 8px 20px;
    font-size: 0.9rem;
    border-radius: 20px;
    background: #ddd;
    color: #666;
    box-shadow: none;
}

.device-btn.active {
    background: var(--color-primary);
    color: #fff;
}

.preview-wrapper {
    /* Adjust for browser bar */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 8px;
    background: #fff;
    /* fallback */
    /* コンテンツはみ出し防止 */
    transition: width 0.3s ease;
    border: 1px solid #ccc;
    height: 100%;
    width: 100%;
}

.preview-wrapper.pc-view {
    width: 100%;
    /* 親に合わせて最大幅 */
    max-width: 1200px;
}

.preview-wrapper.mobile-view {
    width: 375px;
    /* スマホサイズ */
    border: 10px solid #333;
    /* スマホフレーム風 */
    border-radius: 40px;
    box-sizing: border-box;
}

.preview-wrapper.mobile-view iframe {
    width: 100%;
    height: 100%;
    display: block;
}

/* --- Preview Styles Removed (See preview.css) --- */


/* Chat Options */
.message-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: flex-end;
    /* Align with user */
    padding-right: 20px;
}

.option-btn {
    background-color: var(--color-white);
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.option-btn:hover {
    background-color: var(--color-primary);
    color: var(--color-white);
    transform: translateY(-2px);
}

.option-btn.selected {
    background-color: var(--color-primary-dark);
    color: var(--color-white);
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.option-btn.upload-btn {
    background-color: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
    width: 100%;
    max-width: 300px;
    margin: 10px auto;
    display: block;
    font-size: 1.1rem;
    padding: 12px;
}

.option-btn.upload-btn:hover {
    background-color: #d94e33;
    /* Darker accent */
    border-color: #d94e33;
}

/* Ensure images cover the area */
img.p-hero-img,
img.p-card-img {
    object-fit: cover;
}

.confirm-btn {
    background-color: #4CAF50;
    /* Green for confirm */
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 0 #388E3C;
    transition: all 0.2s;
}

.confirm-btn:hover {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #388E3C;
}

.confirm-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

.confirm-btn:disabled {
    background-color: #ccc;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* Update Animation */
@keyframes flash {
    0% {
        background-color: rgba(255, 235, 59, 0.4);
        transform: scale(1.02);
    }

    100% {
        background-color: transparent;
        transform: scale(1);
    }
}

.highlight-flash {
    animation: flash 1s ease-out;
}

/* Answer Card */
.answer-card {
    background-color: #fff;
    border: 2px solid #eee;
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 20px;
    margin-left: auto;
    width: 90%;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    position: relative;
    animation: popIn 0.3s ease-out forwards;
}

.answer-card-content {
    font-size: 1rem;
    color: var(--color-text);
    margin-bottom: 10px;
    word-break: break-all;
}

.answer-card-img {
    width: 100%;
    max-width: 200px;
    border-radius: 10px;
    display: block;
    margin-bottom: 10px;
}

.edit-btn {
    background-color: #f0f0f0;
    color: #666;
    border: none;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background-color 0.2s;
    margin-left: auto;
    /* Right align */
}

.edit-btn:hover {
    background-color: #e0e0e0;
}

.edit-btn::before {
    content: "✏️";
    font-size: 0.9rem;
}

/* Finalize Button */
.finalize-area {
    text-align: center;
    margin: 30px 0;
    animation: popIn 0.5s ease-out;
}

.finalize-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    font-size: 1.3rem;
    padding: 20px 40px;
    border: none;
    border-radius: 50px;
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
    cursor: pointer;
    font-weight: bold;
    transform: scale(1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.finalize-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 20px rgba(76, 175, 80, 0.6);
}

.finalize-btn:active {
    transform: scale(0.98);
}

/* Enhanced Highlight */
@keyframes flash-strong {
    0% {
        background-color: rgba(255, 193, 7, 0.8);
        transform: scale(1.05);
        box-shadow: 0 0 15px rgba(255, 193, 7, 0.5);
    }

    100% {
        background-color: transparent;
        transform: scale(1);
        box-shadow: none;
    }
}

.highlight-flash {
    animation: flash-strong 1.5s ease-out;
}

/* Animations */
@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes popIn {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive */
@media (max-width: 900px) {
    .split-screen.active {
        flex-direction: column-reverse;
        /* スマホではチャットが下、プレビューが上 */
    }

    .chat-section {
        width: 100%;
        height: 70%;
        /* Mobile optimized height */
        border-right: none;
        border-bottom: 1px solid #ddd;
    }

    .preview-section {
        width: 100%;
        height: 30%;
        /* Mini preview */
        padding: 10px;
        position: relative;
        /* For full screen toggle */
        transition: all 0.3s ease;
    }

    /* Full Screen Preview Mode */
    .preview-section.mobile-fullscreen {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 1000;
        padding: 0;
    }

    .preview-section.mobile-fullscreen .device-switcher {
        display: flex;
        /* Show in full screen */
        position: absolute;
        top: 10px;
        right: 10px;
        z-index: 10;
        background: rgba(255, 255, 255, 0.8);
        border-radius: 20px;
        padding: 5px;
    }

    .preview-section.mobile-fullscreen .preview-wrapper {
        width: 100% !important;
        height: 100% !important;
        border: none;
        border-radius: 0;
    }

    .preview-close-btn {
        display: none;
        /* Hidden by default */
        position: absolute;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.7);
        color: #fff;
        padding: 10px 30px;
        border-radius: 30px;
        border: none;
        font-weight: bold;
        z-index: 1001;
        cursor: pointer;
        font-size: 1rem;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    }

    .preview-section.mobile-fullscreen .preview-close-btn {
        display: block;
    }

    .device-switcher {
        display: none;
        /* スマホでは不要 */
    }

    .preview-wrapper.mobile-view {
        width: 375px;
        border: 10px solid #333;
        border-radius: 40px;
        box-sizing: border-box;
    }

    .p-hero-img {
        height: 150px;
    }

    .p-service-grid {
        grid-template-columns: 1fr;
        gap: 24px;
        max-width: 100%;
        margin: 0 auto;
    }
}

/* Template Button Colors */
.option-btn.btn-blue {
    border-color: #2F5FA7;
    color: #2F5FA7;
}

.option-btn.btn-blue:hover,
.option-btn.btn-blue.selected {
    background-color: #2F5FA7;
    color: #fff;
}

.option-btn.btn-monotone {
    border-color: #444;
    /* Consistently Dark Gray */
    color: #444;
}

.option-btn.btn-monotone:hover,
.option-btn.btn-monotone.selected {
    background-color: #444;
    color: #fff;
}

.option-btn.btn-cream:hover,
.option-btn.btn-cream.selected {
    background-color: #F4A261;
    color: #fff;
}

/* --- Edit List Popup (Modal) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 248, 239, 0.85);
    /* 半透明クリーム背景 */
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: none;
    /* 初期非表示 */
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.open {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: #fff;
    width: 90%;
    max-width: 600px;
    height: 80%;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(244, 162, 97, 0.2);
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
    border: 3px solid var(--color-primary);
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 2px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--color-bg);
    border-top-left-radius: 17px;
    border-top-right-radius: 17px;
}

.modal-header h3 {
    color: var(--color-accent);
    font-size: 1.2rem;
    font-family: var(--font-heading);
}

.modal-close-icon {
    background: none;
    border: none;
    font-size: 2rem;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    text-align: center;
    border-top: 2px solid #eee;
    background-color: #fff;
    border-bottom-left-radius: 17px;
    border-bottom-right-radius: 17px;
}

/* Edit Items */
.edit-row {
    margin-bottom: 24px;
    border-bottom: 1px dashed #eee;
    padding-bottom: 16px;
}

.edit-row:last-child {
    border-bottom: none;
}

.edit-label {
    display: block;
    font-weight: bold;
    color: var(--color-primary-dark);
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.edit-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.edit-input:focus {
    border-color: var(--color-primary);
    outline: none;
}

textarea.edit-input {
    resize: vertical;
    min-height: 80px;
}

.edit-img-preview {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 10px;
    border: 2px solid #eee;
    margin-right: 15px;
}

.edit-img-container {
    display: flex;
    align-items: center;
}

.btn-file-change {
    background: #eee;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #555;
}

.btn-file-change:hover {
    background: #ddd;
}

/* Perfect Button */
.btn-check {
    background-color: var(--color-accent);
    color: #fff;
    font-size: 1.2rem;
    padding: 15px 50px;
    border: none;
    border-radius: 50px;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(231, 111, 81, 0.3);
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-check:hover {
    transform: scale(1.05);
    background-color: #d65d3f;
}
.map-link {
  display: inline-block;
  padding: 12px 16px;
  border-radius: 8px;
  background: #f5f5f5;
  color: #333;
  text-decoration: none;
  font-weight: 500;
}

.map-link:hover {
  background: #eee;
}
@media (max-width: 768px) {
  .nav ul {
    justify-content: center;
  }

  .service-grid {
    justify-items: center;
  }
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }
  /* ナビ中央寄せ */
  .nav ul {
    justify-content: center;
    width: 100%;
  }
  /* Serviceカード中央 & 幅拡張 */
  .service-grid {
    justify-items: center;
  }
  .service-card {
    width: 100%;
    max-width: none;
  }
}
