* {
    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;
}

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

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

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

.back-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;
}

.theme-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);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-body);
}

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

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

.sun-icon { display: block; }
.moon-icon { display: none; }

/* 기본 모드 */
.basic-mode {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border);
    margin-bottom: 12px;
}

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

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

.input-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    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: 12px 0;
    font-size: 1rem;
    font-weight: 500;
    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.9rem;
}

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

.input-wrap.small input {
    padding: 8px 0;
    font-size: 0.9rem;
}

/* 플랫폼 버튼 */
.platform-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

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

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

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

.platform-btn.more-btn {
    border-style: dashed;
    color: var(--text-muted);
}

.more-platforms {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}

.more-platforms.hidden {
    display: none;
}

/* 결과 박스 */
.result-box {
    background: var(--text-dark);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-top: 20px;
    color: white;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.result-item.main {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
}

.result-item .label {
    font-size: 0.85rem;
    opacity: 0.7;
}

.result-item .value {
    font-size: 1.25rem;
    font-weight: 600;
}

.result-item.main .value {
    font-size: 1.5rem;
}

.result-item .status {
    margin-left: auto;
    font-size: 1.25rem;
}

/* 고급 모드 토글 */
.advanced-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-body);
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 12px;
}

.advanced-toggle:hover {
    border-color: var(--text-muted);
}

.advanced-toggle.active {
    background: var(--bg-input);
}

.toggle-icon {
    width: 16px;
    height: 16px;
    transition: transform 0.2s;
}

.advanced-toggle.active .toggle-icon {
    transform: rotate(180deg);
}

.advanced-toggle.active .toggle-text::before {
    content: '';
}

.advanced-toggle.active .toggle-text {
    font-size: 0;
}

.advanced-toggle.active .toggle-text::after {
    content: '상세 설정 접기';
    font-size: 0.875rem;
}

/* 고급 모드 */
.advanced-mode {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border);
    margin-bottom: 12px;
}

.advanced-mode.hidden {
    display: none;
}

.advanced-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.advanced-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.advanced-section h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 12px;
}

/* 비용 그리드 */
.cost-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.cost-item label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

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

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

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

/* 리스크 그리드 */
.risk-grid {
    display: grid;
    gap: 12px;
}

.risk-item label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.risk-item input[type="range"] {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--bg-input);
    appearance: none;
    outline: none;
}

.risk-item input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-dark);
    cursor: pointer;
}

/* 시뮬레이션 테이블 */
.simulation-table, .platform-table {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.sim-header, .platform-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    padding: 10px 12px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}

.platform-header {
    grid-template-columns: 1.5fr 1fr 1fr 0.8fr;
}

.sim-row, .platform-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    padding: 10px 12px;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.platform-row {
    grid-template-columns: 1.5fr 1fr 1fr 0.8fr;
}

.sim-row:last-child, .platform-row:last-child {
    border-bottom: none;
}

.sim-row span:first-child, .platform-row span:first-child {
    color: var(--text-body);
}

.sim-row span:nth-child(2), .platform-row span:nth-child(3) {
    font-weight: 600;
    color: var(--primary);
}

.platform-row span:nth-child(2) {
    color: var(--text-muted);
}

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

/* 역계산 */
.reverse-calc, .breakeven-calc {
    display: grid;
    gap: 12px;
}

.reverse-item label, .breakeven-item label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.reverse-input, .breakeven-input {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.arrow {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.reverse-result, .breakeven-result {
    font-size: 0.85rem;
    color: var(--text-body);
}

.reverse-result strong, .breakeven-result strong {
    color: var(--primary);
    font-weight: 600;
}

/* 액션 버튼 */
.action-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-body);
    cursor: pointer;
    transition: all 0.15s;
}

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

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

/* 히스토리 & 비교 섹션 */
.history-section, .compare-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border);
    margin-bottom: 12px;
}

.history-section.hidden, .compare-section.hidden {
    display: none;
}

.history-section h3, .compare-section h3 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-dark);
}

.history-item, .compare-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.history-item:last-child, .compare-item:last-child {
    margin-bottom: 0;
}

.history-info, .compare-info {
    flex: 1;
}

.history-info .name, .compare-info .name {
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 2px;
    color: var(--text-dark);
}

.history-info .details, .compare-info .details {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.history-margin, .compare-margin {
    text-align: right;
}

.history-margin .value, .compare-margin .value {
    font-weight: 600;
    color: var(--primary);
}

.history-margin .rate, .compare-margin .rate {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.delete-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    margin-left: 10px;
    transition: all 0.15s;
}

.delete-btn:hover {
    background: var(--danger);
    color: white;
}

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

/* 토스트 */
.toast {
    position: fixed;
    bottom: 24px;
    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: 1000;
}

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

.toast.hidden {
    display: block;
}

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

    .basic-mode, .advanced-mode {
        padding: 16px;
    }

    .cost-grid {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .reverse-input, .breakeven-input {
        flex-direction: column;
        align-items: stretch;
    }

    .arrow {
        text-align: center;
    }
}

.status {
    animation: none;
}

/* 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);
}
