:root {
    --primary-gradient: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
    --insta-gradient: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-color: #262626;
    --secondary-text: #8e8e8e;
    --accent-color: #0095f6;
    --btn-purple: #a18cd1;
    --header-text: #4A148C; /* Light mode header text */
    --header-btn-bg: rgba(74, 20, 140, 0.08); /* Light mode button bg */
    --border-radius: 12px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --header-bg: rgba(255, 255, 255, 0.95);
    --footer-link: rgba(255, 255, 255, 0.8);
    --neon-glow: transparent;
}

/* New Deep Lavender Dark Mode Overrides */
body.dark-theme {
    --bg-color: #1A1625;
    --primary-gradient: linear-gradient(135deg, #1A1625 0%, #2D243F 100%);
    --card-bg: #3B3355;
    --text-color: #F0E6FF; 
    --secondary-text: #B0A8C3;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    --header-bg: rgba(26, 22, 37, 0.95);
    --header-text: #F0E6FF; /* Dark mode header text */
    --header-btn-bg: rgba(255, 255, 255, 0.15); /* Dark mode button bg */
    --btn-purple: #D4BFFF;
    --footer-link: rgba(240, 230, 255, 0.5);
    --neon-glow: 0 0 15px rgba(187, 134, 252, 0.3);
}

@media (prefers-color-scheme: dark) {
    body:not(.light-theme) {
        --bg-color: #1A1625;
        --primary-gradient: linear-gradient(135deg, #1A1625 0%, #2D243F 100%);
        --card-bg: #3B3355;
        --text-color: #F0E6FF;
        --secondary-text: #B0A8C3;
        --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
        --header-bg: rgba(26, 22, 37, 0.95);
        --header-text: #F0E6FF;
        --header-btn-bg: rgba(255, 255, 255, 0.15);
        --btn-purple: #D4BFFF;
        --footer-link: rgba(240, 230, 255, 0.5);
        --neon-glow: 0 0 15px rgba(187, 134, 252, 0.3);
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

body {
    background: var(--primary-gradient);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-color);
    overflow-y: auto;
}

#app {
    width: 100%;
    max-width: 500px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    position: relative;
}

/* Header - Sticky Fixed */
.app-header {
    width: 100%;
    background: var(--header-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 15px;
    flex-shrink: 0;
    z-index: 1000;
    position: sticky;
    top: 0;
}

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

.logo-link { text-decoration: none; }
.logo { font-weight: 800; color: var(--header-text); font-size: 1.1rem; display: block; }

.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { background: var(--header-btn-bg); border: none; font-size: 1.1rem; cursor: pointer; padding: 6px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.lang-selector {
    display: flex;
    align-items: center;
    background: var(--header-btn-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 4px 22px 4px 10px;
    gap: 6px;
    position: relative;
    height: 32px;
}

.globe-icon {
    font-size: 14px;
    display: flex;
    align-items: center;
    opacity: 0.8;
}

.lang-dropdown {
    background: transparent;
    border: none;
    color: var(--header-text);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding: 0;
    margin: 0;
    width: 100%;
}

.lang-selector::after {
    content: "▼";
    font-size: 8px;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--header-text);
    opacity: 0.6;
}

.lang-dropdown option {
    background: var(--card-bg);
    color: var(--text-color);
    font-weight: 500;
}

/* Story Tabs */
.story-container {
    width: 100%;
    padding: 12px 10px;
    display: flex;
    gap: 12px;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.story-item { display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; flex-shrink: 0; }
.story-circle {
    width: 50px; height: 50px; border-radius: 50%; padding: 2.5px;
    background: #dbdbdb; display: flex; justify-content: center; align-items: center; position: relative;
}
.story-item.active .story-circle { background: var(--insta-gradient); }
.story-circle::after { content: ''; position: absolute; width: 45px; height: 45px; background: var(--card-bg); border-radius: 50%; z-index: 1; }
.story-icon { font-size: 20px; position: relative; z-index: 2; }
.story-label { font-size: 9px; color: var(--text-color); font-weight: 500; }

/* Main Content */
.centered-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px 10px;
}

/* Home screen vertically centered */
#home-screen {
    align-items: center;
}

/* Intro Card */
.intro-card { padding: 20px 20px; text-align: center; width: 100%; }
.main-title { font-size: 1.7rem; margin-bottom: 8px; color: white; text-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.subtitle { color: white; margin-bottom: 20px; font-size: 0.95rem; opacity: 0.9; }

/* Input Group */
.input-group { 
    margin-bottom: 25px; width: 100%; 
    display: flex; gap: 10px; align-items: center;
}
#user-name {
    flex: 1;
    padding: 12px 15px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.9rem;
    outline: none;
    text-align: center;
    transition: all 0.3s ease;
}
#user-name::placeholder { color: rgba(255, 255, 255, 0.6); }
#user-name:focus { background: rgba(255, 255, 255, 0.2); border-color: white; }

.random-btn {
    width: 45px; height: 45px; border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white; font-size: 1.2rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease;
}
.random-btn:active { transform: scale(0.9); background: rgba(255, 255, 255, 0.2); }

/* Insta Post */
.insta-post {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    width: 100%;
    box-shadow: var(--shadow), var(--neon-glow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: fade-in-up 0.6s cubic-bezier(0.23, 1, 0.32, 1) both;
}

.post-header { padding: 8px 12px; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.user-avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--insta-gradient); display: flex; justify-content: center; align-items: center; font-size: 12px; }
.user-info { flex: 1; }
.username { font-size: 12px; font-weight: 600; }
.location { font-size: 10px; color: var(--secondary-text); }

.post-media {
    width: 100%;
    height: 30vh;
    background: #fdf2f8;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.soft-circle { position: absolute; width: 160px; height: 160px; background: rgba(255, 255, 255, 0.4); border-radius: 50%; z-index: 1; }
#menu-emoji { font-size: 100px; filter: drop-shadow(0 10px 20px rgba(0,0,0,0.12)); z-index: 2; }
.food-img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }

/* 칼로리 & 어울리는 상황 배지 */
.food-meta-section { display: flex; flex-direction: column; gap: 8px; }
.food-meta-row { display: flex; align-items: flex-start; }
.food-meta-badge { font-size: 12.5px; line-height: 1.5; color: var(--text-color); display: flex; gap: 6px; align-items: flex-start; }
.food-meta-badge strong { white-space: nowrap; color: var(--accent-color); }

.menu-title-section { padding: 15px 12px 15px; text-align: center; flex-shrink: 0; border-bottom: 1px solid rgba(0,0,0,0.05); }
.recommended-text { font-size: 10px; color: var(--accent-color); font-weight: 700; text-transform: uppercase; margin-bottom: 5px; display: block; letter-spacing: 0.05em; }
#menu-name { font-size: 1.7rem; font-weight: 800; color: var(--text-color); }

.post-actions { padding: 6px 12px; display: flex; justify-content: space-between; font-size: 20px; flex-shrink: 0; }
.main-actions { display: flex; gap: 14px; }

.post-content { padding: 0 12px 10px 12px; flex-shrink: 0; }
.likes-count { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.caption { font-size: 13px; line-height: 1.6; letter-spacing: -0.01em; }
.caption-user { font-weight: 600; margin-right: 6px; }
.post-tag { color: #00376b; }

/* Result Sections & Readability */
.result-section {
    padding: 15px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}
.result-section:last-child { border-bottom: none; }

.section-title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-color);
}

.post-description { 
    margin: 0; 
    word-break: keep-all; 
    line-height: 1.6; 
    font-size: 13px;
    color: var(--text-color);
}

.highlight {
    background: linear-gradient(120deg, rgba(161, 140, 209, 0.2) 0%, rgba(161, 140, 209, 0.2) 100%);
    padding: 0 2px;
    border-radius: 4px;
    font-weight: 600;
}

body.dark-theme .highlight {
    background: linear-gradient(120deg, rgba(212, 191, 255, 0.2) 0%, rgba(212, 191, 255, 0.2) 100%);
}

.sender-info { 
    margin-top: 10px; 
    font-size: 12px; 
    font-weight: 600; 
    color: var(--secondary-text);
    text-align: right;
    font-style: italic;
}

.post-lucky-tip { 
    font-size: 11.5px; color: var(--secondary-text); padding: 12px; 
    background: rgba(161, 140, 209, 0.06); border-radius: 8px; border-left: 3px solid var(--btn-purple); 
    line-height: 1.6; margin-top: 0; word-break: keep-all;
}

/* 맛집 검색 섹션 스타일 */
.search-section {
    padding: 20px 0 !important;
    display: flex;
    flex-direction: column;
    gap: 15px; /* Unified gap */
}

.search-btn-group, .manual-search-btn-group {
    display: flex;
    gap: 12px;
    width: 100%;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}

.nearby-btn {
    flex: 1;
    min-width: 140px; /* Ensure buttons don't get too small */
    padding: 14px 10px;
    background: var(--btn-purple);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(161, 140, 209, 0.3);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    white-space: normal; /* Allow text to wrap if needed */
    text-align: center;
    line-height: 1.2;
}

.naver-btn {
    background: #03C75A !important;
    box-shadow: 0 4px 15px rgba(3, 199, 90, 0.3) !important;
}

/* Global button click animation */
.primary-btn:active, 
.secondary-btn:active, 
.compact-btn:active, 
.nearby-btn:active,
.heart-btn:active,
.story-item:active,
.circle-btn:active {
    transform: scale(0.95);
}

.search-or-divider {
    text-align: center;
    margin: 15px 0 5px 0; /* Extra top margin for breathing room */
    font-size: 12px;
    font-weight: 600;
    color: var(--secondary-text);
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-or-divider::before, .search-or-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: rgba(0, 0, 0, 0.05);
}

body.dark-theme .search-or-divider::before, body.dark-theme .search-or-divider::after {
    background: rgba(255, 255, 255, 0.05);
}

.search-input-group {
    display: flex;
    gap: 10px;
    height: 52px;
    margin-bottom: 5px;
}
#region-input {
    flex: 1; /* More flexible width */
    height: 100%;
    padding: 0 15px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(0, 0, 0, 0.03);
    color: var(--text-color);
    font-size: 14px;
    outline: none;
    line-height: normal;
}

body.dark-theme #region-input {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

.compact-btn {
    padding: 0 20px;
    background: var(--card-bg);
    color: var(--btn-purple);
    border: 1.5px solid var(--btn-purple);
    border-radius: 12px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

/* Loading State for Buttons */
.nearby-btn.loading {
    opacity: 0.8;
    pointer-events: none;
    position: relative;
    padding-left: 40px; /* Space for spinner */
}

.nearby-btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 20px; /* Positioned to the left of text */
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

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

.compact-btn:active { background: rgba(161, 140, 209, 0.1); }

@media (prefers-color-scheme: dark) {
    body:not(.light-theme) #region-input {
        border-color: rgba(255, 255, 255, 0.1);
        background: rgba(255, 255, 255, 0.05);
    }
}

.post-time { font-size: 9px; color: var(--secondary-text); text-transform: uppercase; margin-top: 6px; }
.post-footer-btn { padding: 12px 12px; border-top: 1px solid rgba(0,0,0,0.05); flex-shrink: 0; display: flex; gap: 10px; align-items: center; }

/* Buttons */
.primary-btn { width: 100%; padding: 18px; border: none; border-radius: 12px; font-size: 1.5rem; font-weight: 700; cursor: pointer; background: #F3E5F5; color: #4A148C; box-shadow: 0 4px 15px rgba(74, 20, 140, 0.15); }
.primary-btn.mini { padding: 12px; font-size: 1rem; }
.secondary-btn { flex: 1; padding: 18px 16px; border: 1px solid #dbdbdb; border-radius: 12px; font-size: 1.3rem; font-weight: 700; cursor: pointer; background: transparent; color: var(--text-color); }

.icon-save-btn {
    width: 60px;
    height: 60px;
    border: 1px solid #dbdbdb;
    border-radius: 12px;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.icon-save-btn:hover, .icon-save-btn:active {
    transform: scale(1.1);
    background-color: rgba(161, 140, 209, 0.1);
}

body.dark-theme .secondary-btn, body.dark-theme .icon-save-btn { border-color: rgba(255,255,255,0.1); }
@media (prefers-color-scheme: dark) {
    body:not(.light-theme) .secondary-btn, body:not(.light-theme) .icon-save-btn { border-color: rgba(255,255,255,0.1); }
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: relative;
    background: var(--card-bg);
    width: 100%;
    max-width: 400px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    animation: slideUpFade 0.4s ease-out;
}

.modal-header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.modal-header h3 { font-size: 1.1rem; color: var(--text-color); }

.close-btn {
    background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--secondary-text);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#preview-container {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

#preview-container img {
    width: 100%;
    display: block;
}

.guide-text {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent-color);
    text-align: center;
    line-height: 1.4;
    word-break: keep-all;
}

body.dark-theme .guide-text { color: #80d8ff; }

.animate-glow {
    animation: textGlow 1.5s ease-in-out infinite alternate;
}

@keyframes textGlow {
    from { opacity: 0.8; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); text-shadow: 0 0 10px rgba(0, 149, 246, 0.3); }
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(0,0,0,0.05);
}

body.dark-theme .modal-header, body.dark-theme .modal-footer { border-color: rgba(255,255,255,0.1); }

/* Footer */
footer { width: 100%; padding: 20px 10px 40px; text-align: center; color: var(--secondary-text); font-size: 0.75rem; flex-shrink: 0; background: rgba(0,0,0,0.02); }
.footer-links { margin-bottom: 8px; }
.footer-links a { color: var(--secondary-text); text-decoration: none; margin: 0 6px; font-weight: 500; }
.footer-links a:hover { text-decoration: underline; color: var(--accent-color); }
.copyright { margin-bottom: 4px; }
.powered-by { font-size: 0.7rem; opacity: 0.8; }
.powered-by a { color: var(--secondary-text); text-decoration: none; font-weight: 600; }
.powered-by a:hover { color: var(--accent-color); text-decoration: underline; }

.hidden { display: none !important; }

/* Animations */
@keyframes fade-in-up {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}
@keyframes popScale { 0% { transform: scale(0.8); } 70% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes storyPop { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }

.animate-slide-up { animation: fade-in-up 0.6s cubic-bezier(0.23, 1, 0.32, 1) both; }
.animate-pop { animation: popScale 0.3s ease-out both; }

/* Mobile Optimizations (max-width: 768px) */
@media (max-width: 768px) {
    .centered-content {
        align-items: flex-start;
        padding: 12px 8px;
    }

    .insta-post {
        max-height: none;
    }

    .post-media {
        width: 100%;
        height: 56vw;
        border-radius: 0;
        margin: 0;
    }

    #menu-emoji { font-size: 80px; }
    .soft-circle { width: 140px; height: 140px; }
    #menu-name { font-size: 1.5rem; }
    .post-content { padding: 0 12px 8px 12px; }
    .caption { font-size: 12.5px; }
    .post-lucky-tip { font-size: 11px; padding: 10px; }

    .primary-btn { padding: 16px; font-size: 1.3rem; }
    .secondary-btn { padding: 16px; font-size: 1.3rem; }

    footer { padding: 20px 10px 50px; font-size: 0.7rem; }
}

/* Mobile Optimizations (max-width: 600px) */
@media (max-width: 600px) {
    .centered-content {
        padding: 10px 0;
    }

    .insta-post {
        max-height: none;
        border-radius: 12px;
        margin: 0 4px;
    }

    .post-media {
        width: 100%;
        height: 56vw;
        border-radius: 0;
    }

    #menu-emoji { font-size: 60px; }
    .soft-circle { width: 110px; height: 110px; }

    .menu-title-section { padding: 10px 12px; }
    #menu-name { font-size: 1.3rem; }

    .post-content { padding: 0 12px 8px 12px; }
    .post-description { font-size: 12px; line-height: 1.5; }
    .post-lucky-tip { padding: 10px; font-size: 11px; }

    .post-footer-btn { padding: 10px 12px; }
    .primary-btn { padding: 14px; font-size: 1.1rem; }
    .secondary-btn { padding: 14px; font-size: 1.1rem; }
    .icon-save-btn { width: 48px; height: 48px; font-size: 1.3rem; }
}

/* RTL Mode Support (Arabic) */
.rtl-mode {
    text-align: right;
}

.rtl-mode .header-actions {
    flex-direction: row-reverse;
}

.rtl-mode .lang-selector {
    padding: 2px 10px 2px 22px;
}

.rtl-mode .lang-selector::after {
    right: auto;
    left: 10px;
}

.rtl-mode .section-title,
.rtl-mode .post-description,
.rtl-mode .likes-count,
.rtl-mode .caption,
.rtl-mode .sender-info,
.rtl-mode .post-time {
    text-align: right;
}

.rtl-mode .section-title {
    flex-direction: row-reverse;
}

.rtl-mode .post-lucky-tip {
    border-left: none;
    border-right: 3px solid var(--btn-purple);
}

.rtl-mode .food-meta-badge {
    flex-direction: row-reverse;
}

/* Mobile Adjustments for Language Selector */
@media (max-width: 400px) {
    .lang-selector {
        padding-left: 8px;
        padding-right: 18px;
    }
    .lang-dropdown {
        font-size: 10px;
        max-width: 80px;
    }
    .globe-icon {
        font-size: 12px;
    }
    .logo {
        font-size: 0.9rem;
    }
}

/* SEO Content Section */
.seo-content-section {
    margin: 40px auto;
    padding: 40px;
    max-width: 1000px;
}

.seo-container {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.seo-article {
    text-align: left;
}

.seo-title {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 20px;
    border-left: 4px solid var(--accent-color);
    padding-left: 15px;
}

.seo-article p {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-color);
    margin-bottom: 15px;
    text-align: justify;
    word-break: keep-all;
}

@media (max-width: 600px) {
    .seo-content-section {
        padding: 20px;
        margin: 20px 10px;
    }
    .seo-title {
        font-size: 1.3rem;
    }
}
