/* --- 全局和基础样式 --- */
:root {
    --primary-color: #007bff;
    --border-color: #e0e0e0;
    --background-color: #f8f9fa;
    --text-color: #333;
    --label-color: #555;
    --container-bg: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.08);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
}

/* --- 主容器样式 --- */
.converter-container {
    width: 100%;
    max-width: 700px;
    background-color: var(--container-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px var(--shadow-color);
    padding: 24px 32px;
    box-sizing: border-box;
}

/* --- 头部样式 --- */
.converter-header {
    text-align: center;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
}

.converter-header .icon {
    margin-bottom: 12px;
}

.converter-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-color);
    margin: 0;
}

/* --- 表单和输入行样式 --- */
.converter-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.unit-row {
    display: grid;
    grid-template-columns: 140px 1fr auto;
    gap: 16px;
    align-items: center;
}

.unit-label {
    font-size: 16px;
    font-weight: 500;
    color: var(--label-color);
    text-align: right;
}

.input-group {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.input-group:focus-within {
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
    border-color: var(--primary-color);
}

.unit-input {
    flex-grow: 1;
    border: none;
    padding: 12px 16px;
    font-size: 16px;
    outline: none;
    background: transparent;
    min-width: 80px;
}

/* 隐藏数字输入框的上下箭头 */
.unit-input::-webkit-outer-spin-button,
.unit-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.unit-input[type=number] {
    -moz-appearance: textfield;
}

.unit-result {
    padding: 12px 16px;
    background-color: #f1f3f5;
    color: var(--text-color);
    font-weight: 500;
    white-space: nowrap;
    border-left: 1px solid var(--border-color);
}

.convert-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.convert-button:hover {
    background-color: #0056b3;
}

.convert-button:active {
    transform: scale(0.98);
}

/* --- 尾部样式 --- */
.converter-footer {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 14px;
    color: #6c757d;
    text-align: center;
}

.converter-footer p {
    margin: 4px 0;
}

/* --- 移动端响应式设计 --- */
@media (max-width: 640px) {
    body {
        padding: 10px;
    }

    .converter-container {
        padding: 16px;
    }

    .converter-header h1 {
        font-size: 22px;
    }

    .unit-row {
        grid-template-columns: 1fr; /* 堆叠布局 */
        gap: 8px;
    }

    .unit-label {
        text-align: left;
        margin-bottom: 4px;
        grid-column: 1 / -1; /* 标签占满整行 */
    }
    
    .input-group {
        grid-column: 1 / -1; /* 输入框组占满整行 */
    }

    .convert-button {
        grid-column: 1 / -1; /* 按钮占满整行 */
        width: 100%;
    }
}
