:root {
    --primary-color: #0046FF;
    /* Shinhan Blue */
    --primary-dark: #002896;
    --primary-light: #528BFF;
    --text-color: #1a1a1a;
    --text-secondary: #595959;
    --bg-color: #F4F6F8;
    --card-bg: #FFFFFF;
    --border-color: #E0E0E0;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --font-family: 'Noto Sans KR', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    max-width: 480px;
    /* Force mobile width on all devices */
    margin: 0 auto;
    padding: 0 16px;
}

/* Header */
.header {
    background-color: white;
    box-shadow: var(--shadow-sm);
    height: 70px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    display: flex;
    align-items: center;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary-color);
}

.logo-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4px 10px;
    /* Pill shape padding */
    background: var(--primary-color);
    color: white;
    border-radius: 12px;
    /* Rounded rectangle */
    margin-right: 10px;
    font-size: 0.8rem;
    white-space: nowrap;
    font-weight: 500;
}

.logo-text {
    letter-spacing: -0.5px;
}

.nav {
    display: flex;
    gap: 24px;
}

.nav-item {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.2s;
}

.nav-item:hover,
.nav-item.active {
    color: var(--primary-color);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 10px 0;
    /* Reduced from 40px */
}

.hero-section {
    text-align: center;
    margin-bottom: 15px;
    /* Reduced from 40px */
}

.hero-section h1 {
    font-size: 1.5rem;
    /* Reduced from 2.5rem */
    font-weight: 700;
    margin-bottom: 4px;
    /* Reduced */
    line-height: 1.2;
    color: #111;
}

.hero-section p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    /* Reduced */
    display: none;
    /* Hide on small screens to save space */
}

/* Removed Desktop overrides to keep mobile consistency */

.calculator-wrapper {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}

/* Removed Desktop overrides for grid to keep single column */

/* Cards */
.calculator-card,
.result-card {
    background: var(--card-bg);
    border-radius: 12px;
    /* Reduced radius */
    padding: 16px;
    /* Reduced from 32px */
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    /* Reduced */
    padding-bottom: 8px;
    /* Reduced */
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 1.1rem;
    /* Reduced from 1.5rem */
    font-weight: 700;
}

.badge {
    background-color: #E8F0FE;
    color: var(--primary-color);
    padding: 2px 8px;
    /* Reduced */
    border-radius: 20px;
    font-size: 0.75rem;
    /* Reduced */
    font-weight: 600;
}

/* Form Elements */
.form-group {
    margin-bottom: 12px;
    /* Reduced from 20px */
}

/* Force grid on mobile for compact view */
.form-group-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* For mobile specifically, ensure rows behave well */
@media (max-width: 400px) {
    .form-group-row {
        gap: 8px;
    }
}

.form-group-row .form-group {
    margin-bottom: 0;
}

label {
    display: block;
    margin-bottom: 4px;
    /* Reduced */
    font-weight: 500;
    color: #333;
    font-size: 0.8rem;
    /* Reduced */
    line-height: 1.3;
    /* Improve readability of wrapped lines */
}

/* Adjust labels on very small screens to prevent awkward wrapping */
@media (max-width: 360px) {
    label {
        font-size: 0.75rem;
        letter-spacing: -0.5px;
    }
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

input[type="number"],
input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    /* Reduced padding */
    padding-right: 40px;
    /* Default for short units like '세', '%' */
    border: 1px solid #CCC;
    border-radius: 6px;
    font-size: 0.9rem;
    /* Reduced */
    font-family: var(--font-family);
    transition: all 0.2s;
    text-align: right;
    height: 36px;
    /* Fixed height for consistency */
}

/* Specific padding for currency inputs with '만원' */
input[data-type="currency"] {
    padding-right: 52px;
}

input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 70, 255, 0.1);
}

.unit {
    position: absolute;
    right: 12px;
    /* Brought closer to edge for compact view */
    color: #888;
    font-size: 0.85rem;
    pointer-events: none;
    white-space: nowrap;
}

.help-text {
    margin-top: 6px;
    font-size: 0.85rem;
    color: #888;
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 12px;
    /* Reduced */
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    /* Reduced */
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    margin-top: 4px;
}

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

.btn-primary:active {
    transform: scale(0.98);
}

/* Results */
.result-summary {
    margin-bottom: 24px;
    background-color: #F8F9FA;
    border-radius: 12px;
    padding: 20px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px dashed #E0E0E0;
    flex-wrap: wrap;
    /* Allow wrapping for mobile */
}

.result-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.result-item.highlight .value {
    color: var(--primary-color);
    font-weight: 800;
}

.result-item .label {
    font-size: 1rem;
    color: #555;
    margin-bottom: 4px;
    /* Space if wrapped */
}

.result-item .value {
    font-size: 1.4rem;
    /* Slightly reduced */
    font-weight: 700;
    margin-right: 4px;
    word-break: keep-all;
    /* Keep text together */
}

/* Specific mobile adjustment for results */
@media (max-width: 400px) {
    .result-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .result-item .value {
        font-size: 1.5rem;
        align-self: flex-end;
    }

    .result-item .unit {
        position: static;
        font-size: 1rem;
    }

    /* Re-structure value container if unit is separate in HTML */
}

.message-box {
    margin-top: 20px;
    font-size: 0.95rem;
    color: #444;
    line-height: 1.5;
    padding: 12px;
    background: #E8F0FE;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    margin-bottom: 24px;
}

.action-buttons {
    display: flex;
    gap: 12px;
}

.btn-secondary,
.btn-outline {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    font-size: 1rem;
}

.btn-secondary {
    background-color: #333;
    color: white;
    border: none;
}

.btn-outline {
    background-color: white;
    border: 1px solid #CCC;
    color: #333;
}

/* Footer */
.footer {
    background-color: #F8F9FA;
    border-top: 1px solid #E0E0E0;
    padding: 30px 0;
    margin-top: auto;
    color: #888;
    font-size: 0.85rem;
    text-align: center;
}