:root {
    --bg-color: #ffffff;
    --primary-color: #1a1a1a;
    --accent-color: #000000;
    --dim-text: #888888;
    --border-color: #eeeeee;
    --nav-height: 70px;
    --header-height: 60px;
}

* {
    box-sizing: border-box;
    margin: 0; padding: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    /* 텍스트 선택 및 아이폰 시스템 팝업 방지 */
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    user-select: none;
}

/* 입력창은 편집이 가능해야 하므로 예외 처리 */
input, textarea {
    -webkit-user-select: text;
    user-select: text;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--primary-color);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    max-width: 500px;
    margin: 0 auto;
    height: 100vh;
    background: #fff;
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

.app-header {
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.app-header h1 { font-size: 1.1rem; font-weight: 600; }
.btn-mini { background: #f5f5f5; border: none; padding: 6px 12px; border-radius: 4px; font-size: 0.8rem; }
.btn-settings-icon { background: none; border: none; font-size: 1.3rem; color: #555; }

/* 메인 영역 */
.app-main { flex-grow: 1; overflow-y: auto; padding: 0 15px; }
.view { padding: 20px 0; animation: fadeIn 0.2s; }
.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* 주문 화면 */
.category-bar { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 15px; scrollbar-width: none; }
.cat-btn { padding: 8px 18px; background: #f9f9f9; border: 1px solid #eee; border-radius: 20px; font-size: 0.85rem; white-space: nowrap; }
.cat-btn.active { background: #000; color: #fff; }
.add-cat-btn { border: 1px dashed #bbb; color: #888; background: #fff; }
.add-cat-btn:active { background: #eee; }

.menu-list { list-style: none; overflow: hidden; }
.menu-item {
    display: flex; align-items: center; padding: 18px 0; border-bottom: 1px solid var(--border-color); gap: 15px;
    background: #fff; position: relative;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.3s;
}

/* 스와이프 준비 상태 강조 */
.menu-item.swipe-ready {
    background: #fdf2f2;
}

.swipe-indicator {
    position: absolute; right: -80px; top: 0; width: 80px; height: 100%;
    background: #000; color: #fff; display: flex; align-items: center;
    justify-content: center; font-weight: 800; font-size: 1.2rem;
}

.item-info { flex-grow: 1; cursor: pointer; }
.item-name { font-size: 1.1rem; font-weight: 500; margin-bottom: 2px; }
.item-price { font-size: 0.85rem; color: var(--dim-text); }

.qty-controls { display: flex; align-items: center; gap: 10px; }
.qty-btn { width: 44px; height: 44px; border: 1px solid #ddd; border-radius: 12px; background: #fff; font-size: 1.3rem; }
.qty-display { font-size: 1.2rem; font-weight: 600; min-width: 25px; text-align: center; }

/* 피드백 레이어 */
.feedback-layer {
    position: fixed; pointer-events: none; top: 0; left: 0; width: 100%; height: 100%; z-index: 2000;
}
.floating-text {
    position: absolute; color: #000; font-weight: 800; font-size: 1.6rem;
    animation: floatUp 0.6s ease-out forwards; text-shadow: 0 2px 10px rgba(255,255,255,0.8);
    pointer-events: none;
}

@keyframes floatUp {
    0% { transform: translate(-50%, 0); opacity: 1; }
    100% { transform: translate(-50%, -100px); opacity: 0; }
}

/* 확인 및 히스토리 */
.btn-finish { width: 100%; padding: 18px; background: #000; color: #fff; border: none; border-radius: 12px; font-weight: 600; font-size: 1rem; margin-top: 30px; }
.btn-finish:active { transform: scale(0.98); opacity: 0.9; }

.final-total { margin-top: 20px; padding: 20px; background: #f9f9f9; border-radius: 12px; font-size: 1.1rem; line-height: 1.8; }

.history-item {
    background: #fdfdfd; padding: 15px; border-radius: 12px; margin-bottom: 10px; border: 1px solid #eee;
}
.history-date { font-size: 0.8rem; color: #999; margin-bottom: 8px; border-bottom: 1px solid #f0f0f0; padding-bottom: 5px; }
.history-content { font-size: 0.95rem; line-height: 1.5; }
.history-total { font-weight: 700; text-align: right; margin-top: 8px; color: #000; }

/* 설정 */
.settings-item { background: #fafafa; padding: 15px; border-radius: 12px; margin-bottom: 12px; border: 1px solid #eee; display: flex; flex-direction: column; }
.btn-add { width: 100%; padding: 15px; background: #000; color: #fff; border: none; border-radius: 12px; font-weight: 600; margin-bottom: 15px; }
.settings-actions { display: flex; gap: 10px; margin-top: 20px; }
.btn-cancel { flex: 1; padding: 15px; background: #eee; color: #333; border: none; border-radius: 12px; font-weight: 600; cursor: pointer; }
.btn-save { flex: 2; padding: 15px; background: #000; color: #fff; border: none; border-radius: 12px; font-weight: 600; cursor: pointer; }
.btn-cancel:active, .btn-save:active { transform: scale(0.98); opacity: 0.9; }
.settings-row { display: flex; gap: 10px; align-items: center; width: 100%; }
/* 드래그 선택 시 스타일 */
.settings-item.sortable-chosen { 
    background: #fff !important; 
    box-shadow: 0 10px 20px rgba(0,0,0,0.15); 
    transform: scale(1.03); 
    z-index: 10;
    border-color: #000;
}
.drag-handle { color: #ccc; font-size: 1.2rem; cursor: grab; padding: 0 5px; user-select: none; flex-shrink: 0; }
.settings-item.sortable-ghost { opacity: 0.4; background: #e0e0e0; border: 2px dashed #999; }
.settings-row input[type="text"] { flex: 1.5; min-width: 0; padding: 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 0.95rem; }
.settings-row input[type="number"] { width: 80px; flex-shrink: 0; padding: 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 0.95rem; }
.btn-del { width: 50px; height: 40px; flex-shrink: 0; background: #ff4d4d; color: #fff; border: none; border-radius: 8px; font-size: 0.8rem; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* 내비게이션 */
.app-nav { height: var(--nav-height); border-top: 1px solid var(--border-color); display: flex; background: #fff; }
.nav-btn { flex: 1; border: none; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #bbb; }
.nav-btn.active { color: #000; font-weight: 700; }
.nav-btn .icon { font-size: 1.5rem; line-height: 10px; margin-bottom: 5px; }
.nav-btn .label { font-size: 0.8rem; }
