/* ===== Pinky 2.0 — style.css v4 ===== */
/* 粉色主題 + MoodBloom 架構 + 強制淺色 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
    color-scheme: light only;
    --pink:        #ff6b9d;
    --pink-bright: #e84d83;
    --pink-light:  #ffb8d4;
    --pink-pale:   #fff0f5;
    --pink-medium: #ffe0ed;
    --rose:        #d4607a;
    --bg:          #fff0f5;
    --bg-card:     #ffffff;
    --bg-bubble:   #fff5f8;
    --text-dark:   #3d2040;
    --text-mid:    #7a4f6d;
    --text-soft:   #b07898;
    --text-white:  #ffffff;
    --gold:        #ff6b9d;
    --shadow:      0 4px 20px rgba(255,107,157,0.15);
}

html, body {
    background: var(--bg) !important;
    color: var(--text-dark) !important;
    height: 100%; overflow: hidden;
    font-family: 'Noto Sans TC', 'Nunito', sans-serif;
    -webkit-font-smoothing: antialiased;
}

#root { height: 100%; background: var(--bg); }

/* ===== SPLASH SCREEN ===== */
.splash-screen {
    position: fixed; inset: 0;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    animation: splash-out 0.5s ease 2s forwards;
}

@keyframes splash-out {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(1.05); pointer-events: none; }
}

.splash-inner {
    display: flex; flex-direction: column; align-items: center; gap: 20px;
    animation: splash-in 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes splash-in {
    from { opacity: 0; transform: scale(0.7); }
    to   { opacity: 1; transform: scale(1); }
}

.splash-circle {
    width: 110px; height: 110px;
    background: var(--pink);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 52px;
    box-shadow: 0 0 0 0 rgba(255,107,157,0.4);
    animation: splash-pulse 1.5s ease-in-out infinite;
}

@keyframes splash-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(255,107,157,0.4); }
    70%  { box-shadow: 0 0 0 24px rgba(255,107,157,0); }
    100% { box-shadow: 0 0 0 0 rgba(255,107,157,0); }
}

.splash-title {
    font-family: 'Nunito', sans-serif;
    font-size: 38px; font-weight: 800;
    color: var(--pink-bright); letter-spacing: 3px;
}

.splash-sub {
    font-size: 14px; color: var(--text-mid); letter-spacing: 1px;
}

/* ===== ONBOARDING ===== */
.onboarding {
    position: fixed; inset: 0;
    background: var(--bg);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 32px; z-index: 900;
    animation: fade-in 0.4s ease;
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.onboarding-emoji { font-size: 56px; margin-bottom: 20px; }

.onboarding h2 {
    font-size: 26px; font-weight: 800;
    color: var(--text-dark); margin-bottom: 10px; text-align: center;
}

.onboarding p {
    font-size: 14px; color: var(--text-mid);
    text-align: center; line-height: 1.7; margin-bottom: 36px;
}

.onboarding-section { width: 100%; max-width: 340px; margin-bottom: 24px; }

.onboarding-label {
    font-size: 14px; font-weight: 700;
    color: var(--text-dark); margin-bottom: 10px;
}

.onboarding-options { display: flex; gap: 10px; flex-wrap: wrap; }

.option-btn {
    flex: 1; min-width: 90px;
    padding: 10px 8px;
    background: white;
    border: 2px solid var(--pink-medium);
    border-radius: 14px;
    font-size: 13px; font-weight: 600;
    color: var(--text-mid);
    cursor: pointer; text-align: center;
    transition: all 0.2s;
}

.option-btn.selected {
    background: var(--pink-pale);
    border-color: var(--pink);
    color: var(--pink-bright);
}

.onboarding-start {
    width: 100%; max-width: 340px;
    padding: 15px;
    background: linear-gradient(135deg, var(--pink), var(--pink-bright));
    border: none; border-radius: 24px;
    font-size: 16px; font-weight: 800;
    color: white; cursor: pointer;
    box-shadow: 0 6px 24px rgba(255,107,157,0.40);
    margin-top: 8px;
    transition: all 0.2s;
}

.onboarding-start:disabled {
    background: var(--pink-medium); box-shadow: none; cursor: not-allowed;
}

.onboarding-privacy {
    font-size: 11px; color: var(--text-soft);
    text-align: center; margin-top: 16px; max-width: 300px;
}

/* ===== MAIN APP ===== */
.app-container {
    width: 100%; max-width: 480px;
    margin: 0 auto;
    height: 100vh; height: 100svh;
    background: var(--bg) !important;
    display: flex; flex-direction: column;
    position: relative; overflow: hidden;
}

/* ===== HEADER ===== */
.header {
    padding: 12px 16px;
    background: white !important;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--pink-medium);
    box-shadow: 0 2px 12px rgba(255,107,157,0.08);
    flex-shrink: 0; z-index: 100;
}

.logo {
    font-family: 'Nunito', sans-serif;
    font-size: 22px; font-weight: 800;
    color: var(--pink-bright);
    display: flex; align-items: center; gap: 8px;
}

.logo-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #4ade80;
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.6; transform: scale(0.8); }
}

.status-bar {
    position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    background: rgba(61,32,64,0.85); color: white;
    padding: 4px 14px; border-radius: 0 0 12px 12px;
    font-size: 11px; font-weight: 600; white-space: nowrap;
    z-index: 200;
}

/* ===== TOOLBAR (右側垂直) ===== */
.toolbar {
    position: absolute; right: 12px; top: 72px;
    display: flex; flex-direction: column; gap: 6px; z-index: 50;
}

.tool-btn {
    width: 38px; height: 38px;
    background: white;
    border: 1.5px solid var(--pink-medium);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s;
    box-shadow: var(--shadow); position: relative;
}

.tool-btn:active, .tool-btn.active {
    background: var(--pink-pale);
    border-color: var(--pink);
    transform: scale(0.95);
}

.tool-btn svg { width: 18px; height: 18px; fill: var(--text-mid); }
.tool-btn.active svg { fill: var(--pink-bright); }
.tool-btn .emoji { font-size: 17px; }

.tooltip {
    position: absolute; right: 46px;
    background: var(--text-dark); color: white;
    padding: 4px 8px; border-radius: 6px;
    font-size: 11px; white-space: nowrap;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
}

.tool-btn:hover .tooltip { opacity: 1; }

/* ── 下拉選單 ── */
.dropdown-menu {
    position: absolute; right: 46px; top: 0;
    background: white; border: 1.5px solid var(--pink-medium);
    border-radius: 12px; overflow: hidden;
    display: none; box-shadow: var(--shadow); min-width: 140px; z-index: 200;
}

.dropdown-menu.show { display: block; }

.dropdown-item {
    padding: 9px 14px; font-size: 13px; font-weight: 600;
    color: var(--text-mid); cursor: pointer;
    border-bottom: 1px solid var(--pink-pale);
    transition: background 0.15s;
}

.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--pink-pale); }
.dropdown-item.active { background: var(--pink-pale); color: var(--pink-bright); }

.name-input-popup { padding: 10px; min-width: 160px; }
.name-input-popup label { display: block; color: var(--text-mid); font-size: 11px; margin-bottom: 5px; font-weight: 600; }
.name-input-popup input {
    width: 100%; padding: 7px 9px;
    border: 1.5px solid var(--pink-medium);
    background: var(--bg); color: var(--text-dark);
    border-radius: 8px; font-size: 13px; margin-bottom: 7px;
    outline: none;
}
.name-input-popup button {
    width: 100%; padding: 7px;
    background: linear-gradient(135deg, var(--pink), var(--pink-bright));
    border: none; border-radius: 8px;
    color: white; font-weight: 700; cursor: pointer; font-size: 13px;
}

/* ===== 小粉吉祥物 ===== */
.cat-mascot {
    position: absolute; left: 12px; top: 68px;
    width: 58px; height: 58px;
    border-radius: 50%;
    overflow: hidden;
    border: 2.5px solid var(--pink-light);
    background: var(--pink-pale);
    z-index: 50;
    box-shadow: var(--shadow);
}

.cat-mascot img { width: 100%; height: 100%; object-fit: cover; }
.cat-mascot .emoji-fallback {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 30px;
}

/* ===== CHAT AREA ===== */
.chat-area {
    flex: 1 1 0; min-height: 0;
    overflow-y: auto;
    padding: 76px 56px 12px 80px;
    display: flex; flex-direction: column; gap: 10px;
    background: var(--bg) !important;
    -webkit-overflow-scrolling: touch;
}

.chat-area::-webkit-scrollbar { width: 3px; }
.chat-area::-webkit-scrollbar-thumb { background: var(--pink-light); border-radius: 3px; }

/* ── 氣泡 ── */
.message {
    max-width: 82%; padding: 10px 14px;
    border-radius: 18px; font-size: 14px;
    line-height: 1.6; word-break: break-word; white-space: pre-wrap;
    animation: msg-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #ff8fb8, var(--pink)) !important;
    color: white !important;
    border-bottom-right-radius: 5px;
    box-shadow: 0 4px 16px rgba(255,107,157,0.30);
}

.message.ai {
    align-self: flex-start;
    background: white !important;
    color: var(--text-dark) !important;
    border-bottom-left-radius: 5px;
    border: 1px solid var(--pink-medium);
    box-shadow: var(--shadow);
}

.chat-image {
    max-width: 200px; border-radius: 10px;
    display: block; margin-bottom: 6px;
    border: 2px solid var(--pink-medium);
}

/* ── loading ── */
.loading { display: flex; align-items: center; gap: 5px; padding: 2px 0; }
.loading span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--pink); animation: bounce 1.2s infinite;
}
.loading span:nth-child(2) { animation-delay: 0.2s; }
.loading span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%            { transform: scale(1); opacity: 1; }
}

/* ── 日記按鈕 ── */
.diary-ready-btn {
    align-self: center;
    background: linear-gradient(135deg, #ff8fb8, var(--pink-bright));
    color: white; border: none; border-radius: 24px;
    padding: 12px 28px; font-size: 14px; font-weight: 700;
    font-family: 'Nunito', sans-serif;
    cursor: pointer; margin: 6px 0;
    box-shadow: 0 6px 24px rgba(255,107,157,0.40);
    animation: glow-pulse 2s infinite;
}

@keyframes glow-pulse {
    0%, 100% { box-shadow: 0 6px 24px rgba(255,107,157,0.40); }
    50%       { box-shadow: 0 8px 32px rgba(255,107,157,0.65); }
}

/* ── 朗讀按鈕 ── */
.read-aloud-btn {
    background: none; border: none; cursor: pointer;
    font-size: 14px; margin-left: 6px; opacity: 0.6;
    transition: opacity 0.2s; vertical-align: middle;
}
.read-aloud-btn:hover, .read-aloud-btn.reading { opacity: 1; }

/* ===== IMAGE PREVIEW ===== */
.image-preview-bar {
    background: white; border-top: 1px solid var(--pink-medium);
    padding: 8px 16px; display: flex; align-items: center; gap: 10px;
    flex-shrink: 0;
}

.image-preview-thumb {
    position: relative; width: 48px; height: 48px;
}

.image-preview-thumb img {
    width: 100%; height: 100%;
    object-fit: cover; border-radius: 8px;
    border: 1.5px solid var(--pink-light);
}

.image-preview-remove {
    position: absolute; top: -6px; right: -6px;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--text-dark); color: white;
    border: none; font-size: 11px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}

.image-preview-label { font-size: 12px; color: var(--text-soft); }

/* ===== INPUT AREA ===== */
.input-area {
    flex-shrink: 0;
    background: white !important;
    border-top: 1px solid var(--pink-medium);
    padding: 10px 12px;
    padding-bottom: max(14px, env(safe-area-inset-bottom, 14px));
    display: flex; align-items: flex-end; gap: 8px;
    z-index: 50;
}

.input-container {
    flex: 1;
    background: var(--bg) !important;
    border: 1.5px solid var(--pink-medium);
    border-radius: 22px;
    display: flex; align-items: center;
    padding: 0 10px; min-height: 44px;
    transition: border-color 0.2s;
}

.input-container:focus-within {
    border-color: var(--pink);
    background: white !important;
}

.input-container input {
    flex: 1; background: transparent; border: none; outline: none;
    font-size: 15px; color: var(--text-dark) !important;
    font-family: 'Noto Sans TC', sans-serif;
    padding: 10px 0;
}

.input-container input::placeholder { color: var(--text-soft); }

.camera-btn, .mic-btn {
    width: 38px; height: 38px; border-radius: 50%;
    background: transparent; border: none;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0; transition: all 0.2s;
}

.camera-btn svg, .mic-btn svg {
    width: 20px; height: 20px; fill: var(--text-soft);
}

.mic-btn.recording svg { fill: var(--pink); }
.mic-btn.recording { animation: mic-pulse 1s infinite; }

@keyframes mic-pulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.15); }
}

.send-btn {
    width: 44px; height: 44px; border-radius: 50%;
    background: linear-gradient(135deg, #ff8fb8, var(--pink));
    border: none; display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(255,107,157,0.35);
    transition: all 0.2s;
}

.send-btn:disabled {
    background: var(--pink-medium); box-shadow: none; cursor: not-allowed;
}

.send-btn svg { width: 18px; height: 18px; fill: white; }

/* ===== DIARY MODAL ===== */
.diary-modal {
    position: fixed; inset: 0;
    background: rgba(61,32,64,0.65);
    backdrop-filter: blur(4px);
    display: flex; justify-content: center; align-items: flex-start;
    z-index: 300; padding: 0;
    animation: overlay-in 0.2s ease;
}

@keyframes overlay-in {
    from { opacity: 0; } to { opacity: 1; }
}

.diary-book {
    background: #fffaf8 !important;
    border-radius: 0;
    width: 100%; max-width: 480px;
    height: 100vh; height: 100svh;
    max-height: 100vh;
    display: flex; flex-direction: column;
    animation: sheet-up 0.3s cubic-bezier(0.34, 1.30, 0.64, 1);
}

@keyframes sheet-up {
    from { transform: translateY(40px); opacity: 0.6; }
    to   { transform: translateY(0); opacity: 1; }
}

.diary-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--pink-medium);
    flex-shrink: 0;
}

.diary-header h2 {
    font-size: 15px; font-weight: 800;
    color: var(--text-dark); letter-spacing: 4px;
}

.diary-back-btn {
    background: none; border: none;
    color: var(--pink-bright); font-size: 13px;
    font-weight: 700; cursor: pointer;
}

.diary-close {
    background: var(--pink-pale);
    border: 1.5px solid var(--pink-medium);
    border-radius: 50%; width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 16px; color: var(--text-mid);
}

.diary-date {
    text-align: center; color: var(--text-soft);
    font-size: 12px; padding: 8px 0; font-style: italic;
    letter-spacing: 1px; flex-shrink: 0;
}

.diary-content {
    display: flex; flex: 1; overflow: hidden;
}

.diary-page {
    flex: 1; padding: 16px 18px;
    overflow-y: auto; position: relative;
    color: var(--text-dark) !important;
    font-size: 13px; line-height: 1.8;
    -webkit-overflow-scrolling: touch;
}

.diary-page::-webkit-scrollbar { display: none; }
.diary-page:first-child { border-right: 1px solid var(--pink-medium); }

.diary-page h3 {
    color: var(--text-mid); margin-bottom: 10px;
    font-size: 13px; font-weight: 700;
    display: flex; align-items: center; gap: 6px;
}

.diary-page h3.ai-title { color: var(--pink-bright); }
.diary-page p { white-space: pre-wrap; color: var(--text-dark) !important; }

/* 日記配圖 */
.diary-illustration {
    text-align: center; padding: 12px 16px;
    border-bottom: 1px solid var(--pink-medium);
    flex-shrink: 0;
}

.diary-illustration img {
    max-width: 100%; max-height: 200px;
    border-radius: 14px;
    border: 2px solid var(--pink-medium);
    box-shadow: var(--shadow);
}

.diary-img-loading {
    color: var(--text-soft); font-size: 13px; padding: 20px 0;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}

.copy-btn {
    position: absolute; top: 14px; right: 14px;
    background: none; border: none;
    font-size: 16px; cursor: pointer;
    opacity: 0.5; transition: opacity 0.2s;
}
.copy-btn:hover { opacity: 1; }

/* ===== DIARY HISTORY ===== */
.diary-history-panel {
    background: #fffaf8 !important;
    border-radius: 28px 28px 0 0;
    width: 100%; max-width: 480px;
    max-height: 88vh;
    display: flex; flex-direction: column;
    animation: sheet-up 0.3s cubic-bezier(0.34, 1.30, 0.64, 1);
}

.diary-history-count {
    padding: 8px 20px 4px;
    font-size: 12px; color: var(--text-soft);
    flex-shrink: 0;
}

.diary-history-list {
    overflow-y: auto; padding: 8px 16px 20px;
    flex: 1; -webkit-overflow-scrolling: touch;
}

.diary-history-list::-webkit-scrollbar { display: none; }

.diary-history-empty {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 48px 0; gap: 12px; color: var(--text-soft);
    font-size: 14px; text-align: center; line-height: 1.7;
}

.diary-history-item {
    background: white; border-radius: 14px;
    padding: 14px; margin-bottom: 10px;
    border: 1.5px solid var(--pink-pale);
    cursor: pointer; position: relative;
    transition: border-color 0.2s;
}

.diary-history-item:active { border-color: var(--pink-light); }

.diary-history-item-header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 6px;
}

.diary-history-item-date {
    font-size: 11px; color: var(--text-soft); font-weight: 600;
}

.diary-history-item-emotion { font-size: 16px; }

.diary-history-item-preview {
    font-size: 13px; color: var(--text-dark);
    line-height: 1.5;
    display: -webkit-box; -webkit-line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden;
}

.diary-history-item-delete {
    position: absolute; top: 10px; right: 10px;
    background: none; border: none;
    font-size: 15px; cursor: pointer; opacity: 0.4;
    transition: opacity 0.2s;
}

.diary-history-item-delete:hover { opacity: 1; }

/* 版本號 */
.version-tag {
    position: fixed; bottom: 6px; left: 10px;
    font-size: 10px; color: var(--text-soft);
    opacity: 0.4; pointer-events: none; z-index: 1;
}

/* 桌面版 */
@media (min-width: 481px) {
    .app-container {
        border-radius: 24px;
        margin: 20px auto;
        height: calc(100svh - 40px);
        box-shadow: 0 20px 60px rgba(61,32,64,0.20);
    }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* 小粉 Loading 動畫 */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.pinky-loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
}

.pinky-loading-bounce {
    width: 72px;
    height: 72px;
    object-fit: contain;
    animation: pinkyBounce 0.8s ease-in-out infinite alternate,
               pinkyWiggle 1.6s ease-in-out infinite;
}

@keyframes pinkyBounce {
    0%   { transform: translateY(0px) scale(1); }
    100% { transform: translateY(-10px) scale(1.05); }
}

@keyframes pinkyWiggle {
    0%   { transform: rotate(0deg); }
    25%  { transform: rotate(-8deg); }
    50%  { transform: rotate(0deg); }
    75%  { transform: rotate(8deg); }
    100% { transform: rotate(0deg); }
}

.pinky-loading-text {
    font-size: 14px;
    color: var(--pink-dark, #c06080);
    font-weight: 500;
    animation: fadeInOut 1.5s ease-in-out infinite;
    text-align: center;
}

@keyframes fadeInOut {
    0%   { opacity: 0.4; }
    50%  { opacity: 1; }
    100% { opacity: 0.4; }
}

.pinky-loading-msg {
    background: transparent !important;
    box-shadow: none !important;
}
