:root {
    --bg-color: #f4f1ea;
    --panel-bg: #ffffff;
    --text-main: #3e2723;
    --text-sub: #8d6e63;
    --border: #d7ccc8;
    
    --cafe-brown: #4E342E;
    --cafe-latte: #A1887F;
    --cafe-accent: #3E2723;
    
    --rel-friend: #42a5f5;
    --rel-lover: #ef5350;
    --rel-family: #66bb6a;
    --rel-coworker: #ffa726;
    --rel-crush: #ffee58;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Pretendard', sans-serif;
    background: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden; 
    display: flex; justify-content: center; align-items: center;
}

#app {
    width: 98vw; height: 96vh;
    background: var(--panel-bg);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(62, 39, 35, 0.2);
    display: flex; flex-direction: column;
}

.header {
    height: 60px; padding: 0 25px;
    background: var(--cafe-brown); color: #fff;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 4px solid var(--cafe-accent);
    flex-shrink: 0;
}
.logo { font-size: 18px; font-weight: 800; letter-spacing: 1px; color: #fff; }

.header-center { display: flex; gap: 15px; align-items: center; }
.date-box { 
    background: rgba(0,0,0,0.3); padding: 5px 15px; border-radius: 4px; 
    font-size: 14px; font-weight: 700; color: #fff;
}

#play-btn {
    padding: 6px 16px; border-radius: 4px; border: none;
    background: #fff; color: var(--cafe-brown); font-weight: 800; cursor: pointer;
    transition: 0.1s;
}
#play-btn:active { transform: scale(0.96); background: #ececec; }

.header-right { display: flex; align-items: center; }
.brown-btn {
    background: transparent; border: 1px solid rgba(255,255,255,0.5);
    color: #fff; padding: 5px 10px; font-size: 12px; border-radius: 4px;
    cursor: pointer; margin-left: 5px; text-decoration: none; display: inline-block;
}
.brown-btn:hover { background: rgba(255,255,255,0.2); }

.main-grid {
    flex: 1; display: grid;
    grid-template-columns: 260px 1fr 350px; 
    overflow: hidden; 
}
.panel {
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; padding: 15px;
    background: #fff;
    min-height: 0;
}
.panel:last-child { border-right: none; }
.panel-title {
    font-size: 11px; font-weight: 800; color: var(--cafe-latte);
    margin-bottom: 10px; border-bottom: 2px solid #f5f5f5; padding-bottom: 5px;
}

.scroll-content { flex: 1; overflow-y: auto; padding-right: 5px; }
.guest-card {
    background: #fff; border: 1px solid #efebe9;
    border-left: 4px solid var(--cafe-brown);
    padding: 10px; margin-bottom: 6px; border-radius: 4px;
}
.guest-card.active { background: #fff; border-color: var(--cafe-brown); }
.guest-card.inactive { background: #f5f5f5; opacity: 0.6; border-left-color: #bdbdbd; }

.g-name { font-weight: 700; font-size: 14px; }
.g-detail { font-size: 11px; color: var(--text-sub); margin-top: 2px; }
.status-tag { font-size: 10px; font-weight: bold; float: right; padding: 2px 5px; border-radius: 3px; color: white; background: var(--cafe-brown); }
.inactive .status-tag { background: #bdbdbd; }

.graph-wrapper {
    flex: 1; background: #fafafa; position: relative;
    border: 1px solid var(--border); border-radius: 6px; margin-bottom: 10px;
    overflow: hidden;
}
#graph-svg { width: 100%; height: 100%; position: absolute; pointer-events: none; }
.node {
    position: absolute; width: 44px; height: 44px;
    background: white; border: 2px solid var(--cafe-brown); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700; cursor: pointer;
    transform: translate(-50%, -50%); z-index: 10;
    box-shadow: 0 2px 5px rgba(62, 39, 35, 0.15);
    word-break: keep-all; text-align: center;
}
.node.selected { border-color: var(--rel-friend); box-shadow: 0 0 0 3px rgba(66, 165, 245, 0.3); }

.relation-controls { flex-shrink: 0; }
.tool-selector { display: flex; gap: 5px; flex-wrap: wrap; }
.tool-selector label {
    font-size: 11px; cursor: pointer; display: flex; align-items: center; gap: 4px;
    padding: 4px 8px; border: 1px solid #d7ccc8; border-radius: 4px; background: white;
}
.tool-selector input:checked + span { font-weight: bold; color: var(--cafe-brown); }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.friend { background: var(--rel-friend); } 
.dot.lover { background: var(--rel-lover); }
.dot.family { background: var(--rel-family); }
.dot.coworker { background: var(--rel-coworker); }
.dot.crush { background: var(--rel-crush); }

.log-wrapper {
    flex: 1;
    overflow-y: auto;
    background: #fdfdfd;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 10px;
    display: flex;
    flex-direction: column;
}

#log-list {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 8px;
}

.log-item {
    font-size: 13px; line-height: 1.5;
    padding-bottom: 6px; border-bottom: 1px solid #f0f0f0;
    animation: fadeIn 0.2s;
    color: #4e342e;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: translateY(0); } }

.log-time {
    color: #8d6e63; font-weight: 700; margin-right: 6px;
    font-family: monospace; font-size: 11px;
    display: inline-block; min-width: 35px;
}

.day-divider {
    text-align: center; margin: 20px 0; font-weight: bold; color: #a1887f; font-size: 12px;
    display: flex; align-items: center;
}
.day-divider::before, .day-divider::after {
    content: ""; flex: 1; height: 1px; background: #d7ccc8; margin: 0 10px;
}

.mbti-grid { display: flex; gap: 5px; }
.mbti-grid select { flex: 1; text-align: center; padding: 6px; }
dialog { border: none; padding: 20px; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,0.3); width: 320px; max-width: 90%; }
dialog::backdrop { background: rgba(0,0,0,0.4); }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 11px; font-weight: 700; margin-bottom: 4px; color: var(--cafe-brown); }
.form-group input, .form-group select { width: 100%; padding: 8px; border: 1px solid #d7ccc8; border-radius: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.primary-btn { background: var(--cafe-brown); color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; }
#cancel-btn { background: #efebe9; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; }
.empty-msg { color: #bdbdbd; text-align: center; margin-top: 40px; font-size: 12px; }

/* 📱 Mobile Optimization */
@media (max-width: 768px) {
    body {
        height: auto;
        overflow: auto;
        padding: 10px 0;
        display: block;
    }

    #app {
        width: 100%;
        height: auto;
        min-height: 100vh;
        border-radius: 0;
        box-shadow: none;
    }

    .header {
        height: auto;
        flex-direction: column;
        gap: 10px;
        padding: 15px;
        text-align: center;
    }
    
    .header-center { width: 100%; }
    
    #play-btn {
        width: 100%;
        padding: 10px;
        font-size: 14px;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
        gap: 5px;
    }
    
    .brown-btn { flex: 1; text-align: center; margin: 0; }

    .main-grid {
        display: flex;
        flex-direction: column;
        overflow: visible;
    }

    .panel {
        border-right: none;
        border-bottom: 8px solid #f4f1ea;
        padding: 15px;
        height: auto;
        overflow: visible;
    }

    .left-panel {
        order: 1;
        max-height: 300px;
    }
    #visitor-list {
        max-height: 250px;
    }

    .right-panel {
        order: 2; 
        flex: 1;
        min-height: 400px; 
    }
    .log-wrapper {
        min-height: 350px;
    }

    .center-panel {
        order: 3; 
        min-height: 400px;
    }
    .graph-wrapper {
        height: 300px;
    }
}
