/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    backdrop-filter: blur(10px);
}

/* 头部样式 */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    padding: 40px 20px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

/* 计算区域样式 */
.calculation-section {
    padding: 30px;
    border-bottom: 1px solid #e0e0e0;
    transition: all 0.3s ease;
}

.calculation-section:hover {
    background: rgba(102, 126, 234, 0.02);
}

.calculation-section h2 {
    color: #5a67d8;
    font-size: 1.8rem;
    margin-bottom: 25px;
    padding-bottom: 10px;
    border-bottom: 3px solid #5a67d8;
    display: inline-block;
}

/* 公式显示样式 */
.formula-display {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.formula-display h3 {
    color: #2d3748;
    font-size: 1.2rem;
    margin-bottom: 15px;
    font-weight: 600;
}

.formula-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    font-size: 1.3rem;
    flex-wrap: wrap;
    padding: 10px 0;
}

.formula-variable {
    font-style: italic;
    font-weight: bold;
    color: #4a5568;
    font-size: 1.4rem;
}

.operator {
    font-weight: bold;
    color: #2b6cb0;
    font-size: 1.3rem;
    margin: 0 10px;
}

.fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    margin: 0 8px;
    position: relative;
}

.numerator, .denominator {
    padding: 5px 10px;
    text-align: center;
    font-weight: 500;
}

.numerator {
    border-bottom: 2px solid #2d3748;
}

.denominator {
    margin-top: 2px;
}

/* 平方根样式 */
.sqrt-container {
    display: flex;
    align-items: flex-start;
    margin: 0 8px;
}

.sqrt-symbol {
    font-size: 2rem;
    color: #2b6cb0;
    font-weight: bold;
    margin-right: 5px;
    position: relative;
}

.sqrt-symbol::after {
    content: '';
    position: absolute;
    top: 5px;
    right: -5px;
    width: 100%;
    height: 2px;
    background: #2b6cb0;
}

.sqrt-content-wrapper {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-top: 2px solid #2b6cb0;
    min-height: 40px;
}

.term {
    white-space: nowrap;
    font-weight: 500;
}

.operator-inline {
    color: #2b6cb0;
    font-weight: bold;
    margin: 0 5px;
}

/* 输入区域样式 */
.input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin: 25px 0;
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.input-group input[type="number"] {
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

.input-group input[type="number"]:focus {
    outline: none;
    border-color: #5a67d8;
    box-shadow: 0 0 0 3px rgba(90, 103, 216, 0.1);
    transform: translateY(-2px);
}

/* 按钮样式 */
button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 10px 5px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

button:active {
    transform: translateY(-1px);
}

.calculate-all-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    font-size: 1.2rem;
    padding: 18px 40px;
    margin: 30px auto;
    display: block;
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.3);
}

.calculation-controls {
    text-align: center;
    padding: 30px;
}

/* 结果显示样式 */
.results-group {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.results-group h3 {
    color: #2d3748;
    font-size: 1.3rem;
    margin-bottom: 15px;
    font-weight: 700;
}

.results-group p {
    font-size: 1.1rem;
    margin: 8px 0;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

.results-group p:last-child {
    border-bottom: none;
}

.results-group span {
    font-weight: 700;
    color: #2b6cb0;
    font-size: 1.15rem;
}

/* 子区域样式 */
.sub-section {
    background: rgba(245, 247, 250, 0.5);
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    border: 1px solid #e2e8f0;
}

.sub-section h3 {
    color: #4a5568;
    font-size: 1.3rem;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #cbd5e0;
}

.sub-section h4 {
    color: #2d3748;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

/* 紧凑格式样式 */
.sub-section.compact {
    padding: 15px;
    margin: 15px 0;
    background: rgba(237, 242, 247, 0.6);
}

.sub-section.compact h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    border-bottom: 1px solid #cbd5e0;
    padding-bottom: 5px;
}

.input-grid-compact {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 15px 0;
}

.input-grid-compact .input-group {
    display: flex;
    flex-direction: column;
}

.input-grid-compact .input-group label {
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.input-grid-compact .input-group input[type="number"] {
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    background: white;
}

.input-grid-compact .input-group input[type="number"]:focus {
    outline: none;
    border-color: #5a67d8;
    box-shadow: 0 0 0 2px rgba(90, 103, 216, 0.1);
}

.compact-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    margin: 8px 0;
    background: linear-gradient(135deg, #4fd1c7 0%, #81e6d9 100%);
    box-shadow: 0 2px 8px rgba(79, 209, 199, 0.3);
}

.compact-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 209, 199, 0.4);
}

.results-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.results-compact span {
    font-size: 0.9rem;
    color: #4a5568;
    font-weight: 500;
}

.results-compact span span {
    color: #2b6cb0;
    font-weight: 700;
}

/* 页脚样式 */
footer {
    background: #2d3748;
    color: white;
    text-align: center;
    padding: 25px;
    font-size: 0.95rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        border-radius: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .calculation-section {
        padding: 20px;
    }
    
    .input-grid {
        grid-template-columns: 1fr;
    }
    
    .formula-line {
        flex-direction: column;
        gap: 10px;
    }
    
    .sqrt-content-wrapper {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .sub-section {
        padding: 15px;
        margin: 15px 0;
    }
    
    .sub-section.compact {
        padding: 12px;
        margin: 12px 0;
    }
    
    .input-grid-compact {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .results-compact {
        flex-direction: column;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    header {
        padding: 25px 15px;
    }
    
    header h1 {
        font-size: 1.6rem;
    }
    
    .calculation-section {
        padding: 15px;
    }
    
    .formula-display {
        padding: 15px;
    }
    
    button {
        width: 100%;
        margin: 5px 0;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.calculation-section {
    animation: fadeIn 0.6s ease-out;
}

/* 输入验证样式 */
.input-group input[type="number"].error {
    border-color: #e53e3e;
    background: #fed7d7;
}

.input-group input[type="number"].success {
    border-color: #38a169;
    background: #c6f6d5;
}

/* 工具提示样式 */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: #2d3748;
    color: white;
    text-align: center;
    border-radius: 8px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.85rem;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
} 