* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-main: #FDFBF9;
    --bg-card: #FFFFFF;
    --bg-input: #F8F6F4;
    --text-dark: #2D2A26;
    --text-body: #4A4540;
    --text-muted: #8A8279;
    --border: #E8E4DF;
    --primary: #E85A3C;
    --primary-soft: #F4A261;
    --accent: #D4A853;
    --success: #5B9A6E;
    --danger: #C45B47;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Pretendard', sans-serif;
    background: var(--bg-main);
    color: var(--text-body);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 520px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 90px;
}

/* 헤더 */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.back-btn, .settings-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-body);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
}

.back-btn:hover, .settings-btn:hover {
    border-color: var(--text-muted);
}

.back-btn svg, .settings-btn svg {
    width: 20px;
    height: 20px;
}

header h1 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-dark);
    letter-spacing: -0.01em;
}

header h1::before {
    content: none;
}

/* 입력 섹션 */
.input-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border);
    margin-bottom: 12px;
}

.main-input {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-weight: 500;
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: var(--text-dark);
}

.input-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    border: 1px solid transparent;
    transition: all 0.15s;
}

.input-wrap:focus-within {
    border-color: var(--primary);
    background: var(--bg-card);
}

.input-wrap input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 14px 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-dark);
    outline: none;
}

.input-wrap input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.input-wrap .unit {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.input-wrap.small {
    padding: 0 12px;
}

.input-wrap.small input {
    padding: 10px 0;
    font-size: 0.95rem;
}

.recommend-btn {
    width: 100%;
    padding: 14px;
    background: var(--text-dark);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.15s;
}

.recommend-btn:hover {
    background: var(--primary);
}

.recommend-btn:active {
    transform: scale(0.99);
}

.recommend-btn span {
    font-size: 1.1rem;
}

/* 프리셋 섹션 */
.presets-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 16px;
    border: 1px solid var(--border);
    margin-bottom: 12px;
}

.preset-group {
    margin-bottom: 12px;
}

.preset-group:last-child {
    margin-bottom: 0;
}

.preset-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.preset-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.preset-btn {
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-body);
    cursor: pointer;
    transition: all 0.15s;
}

.preset-btn:hover {
    border-color: var(--text-muted);
}

.preset-btn.active {
    background: var(--text-dark);
    border-color: var(--text-dark);
    color: white;
}

/* 결과 섹션 */
.results-section {
    margin-bottom: 12px;
}

.results-section.hidden {
    display: none;
}

.result-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 16px;
    border: 1px solid var(--border);
    margin-bottom: 10px;
}

.result-card.main-result {
    background: var(--text-dark);
    color: white;
    text-align: center;
    padding: 24px 20px;
    border: none;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}

.card-icon {
    font-size: 1rem;
}

.card-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-dark);
}

.main-result .card-header {
    justify-content: center;
    margin-bottom: 10px;
}

.main-result .card-title {
    color: rgba(255,255,255,0.8);
}

.main-price {
    margin-bottom: 14px;
}

.main-price .price {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.main-price .margin {
    display: block;
    font-size: 0.9rem;
    opacity: 0.7;
}

.copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: white;
    cursor: pointer;
    transition: all 0.15s;
}

.copy-btn:hover {
    background: rgba(255,255,255,0.25);
}

.copy-btn svg {
    width: 16px;
    height: 16px;
}

.copy-btn.full-width {
    width: 100%;
    background: var(--bg-input);
    color: var(--text-body);
    margin-top: 10px;
}

.copy-btn.full-width:hover {
    background: var(--text-dark);
    color: white;
}

.copy-all-btn {
    margin-left: auto;
    padding: 5px 10px;
    background: var(--bg-input);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-body);
    cursor: pointer;
    transition: all 0.15s;
}

.copy-all-btn:hover {
    background: var(--text-dark);
    color: white;
}

/* 플랫폼 리스트 */
.platform-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.platform-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

.platform-item:hover {
    background: var(--bg-main);
}

.platform-item.favorite {
    background: rgba(232, 90, 60, 0.06);
}

.platform-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.platform-price {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.95rem;
}

.platform-copy {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.platform-copy:hover {
    background: var(--text-dark);
    color: white;
}

.platform-copy svg {
    width: 16px;
    height: 16px;
}

/* 전략 탭 */
.strategy-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    background: var(--bg-input);
    padding: 3px;
    border-radius: var(--radius-sm);
}

.strategy-tab {
    flex: 1;
    padding: 8px 6px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.strategy-tab.active {
    background: var(--bg-card);
    color: var(--text-dark);
    box-shadow: var(--shadow-sm);
}

.strategy-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.strategy-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.strategy-item.selected {
    background: rgba(232, 90, 60, 0.06);
}

.strategy-item .name {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.strategy-item .price {
    font-weight: 600;
    color: var(--primary);
}

.strategy-item .margin-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 6px;
}

.strategy-item .check {
    color: var(--primary);
    font-size: 1rem;
}

/* 할인 세트 */
.discount-set {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.discount-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.discount-item.highlight {
    background: rgba(232, 90, 60, 0.06);
}

.discount-item .label {
    font-size: 0.85rem;
    color: var(--text-muted);
    min-width: 45px;
}

.discount-item .value {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-dark);
}

.discount-item.highlight .value {
    color: var(--primary);
}

.badge {
    margin-left: auto;
    padding: 3px 8px;
    background: var(--primary);
    color: white;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* 묶음가 */
.bundle-list, .coupon-list, .season-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bundle-item, .coupon-item, .season-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.bundle-item .qty, .coupon-item .coupon, .season-item .season {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-body);
}

.bundle-item .price, .coupon-item .price, .season-item .price {
    font-weight: 600;
    color: var(--primary);
}

.bundle-item .per-unit, .coupon-item .margin-info {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.margin-good { color: var(--success) !important; }
.margin-warning { color: var(--accent) !important; }
.margin-danger { color: var(--danger) !important; }

/* 액션 버튼 */
.action-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    max-width: 520px;
    margin: 0 auto;
}

.action-buttons.hidden {
    display: none;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 10px 6px;
    background: var(--bg-input);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-body);
    cursor: pointer;
    transition: all 0.15s;
}

.action-btn:hover {
    background: var(--text-dark);
    color: white;
}

.action-btn svg {
    width: 18px;
    height: 18px;
}

/* 모달 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%;
    max-width: 520px;
    max-height: 80vh;
    overflow-y: auto;
}

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

.modal-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
}

.close-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
}

.close-btn svg {
    width: 18px;
    height: 18px;
}

.modal-body {
    padding: 20px;
}

.setting-group {
    margin-bottom: 16px;
}

.setting-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-body);
    margin-bottom: 8px;
}

.tax-toggle {
    display: flex;
    gap: 6px;
}

.tax-btn {
    flex: 1;
    padding: 10px;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-body);
    cursor: pointer;
    transition: all 0.15s;
}

.tax-btn.active {
    background: var(--text-dark);
    color: white;
}

.favorite-platforms {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.fav-platform-btn {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-body);
    cursor: pointer;
    transition: all 0.15s;
}

.fav-platform-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(232, 90, 60, 0.06);
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.toggle-track {
    display: block;
    width: 44px;
    height: 24px;
    background: var(--bg-input);
    border-radius: 12px;
    position: relative;
    transition: all 0.2s;
}

.toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--text-dark);
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-footer {
    padding: 12px 20px 20px;
}

.save-settings-btn {
    width: 100%;
    padding: 14px;
    background: var(--text-dark);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.15s;
}

.save-settings-btn:hover {
    background: var(--primary);
}

/* 토스트 */
.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    padding: 12px 20px;
    background: var(--text-dark);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease;
    z-index: 1001;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* 반응형 */
@media (max-width: 480px) {
    .container {
        padding: 16px;
    }

    .main-price .price {
        font-size: 1.75rem;
    }

    .preset-buttons {
        gap: 5px;
    }

    .preset-btn {
        padding: 7px 10px;
        font-size: 0.75rem;
    }
}

/* Footer */
.site-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 32px 20px;
    margin-top: 40px;
    text-align: center;
}

.footer-brand {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.footer-contact {
    font-size: 13px;
    color: var(--text-muted);
}
