:root {
    --primary-color: #2196F3;
    --primary-dark: #1976D2;
    --secondary-color: #90CAF9;
    --background-color: #F5F5F5;
    --card-background: #FFFFFF;
    --text-color: #333333;
    --border-color: #E0E0E0;
    --success-color: #4CAF50;
    --danger-color: #F44336;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

.calculator-container {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1rem;
    width: 100%;
}

.calculator-card {
    background: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    padding: 1.5rem;
    width: 100%;
}

h1 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 2rem;
    text-align: center;
}

h3 {
    font-size: 1rem;
    margin-bottom: 0.8rem;
    color: var(--text-color);
}

.toggle-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.toggle-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.grade-inputs {
    margin: 2rem 0;
}

.input-headers {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.input-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

input {
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.add-row-btn {
    width: 100%;
    padding: 0.8rem;
    background: var(--secondary-color);
    color: var(--text-color);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin: 1rem 0;
    transition: background 0.3s ease;
}

.target-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 200px;
}

.unit {
    font-size: 1rem;
    color: var(--text-color);
}

.action-buttons {
    display: flex;
    gap: 1rem;
    margin: 2rem 0;
}

.calculate-btn, .reset-btn {
    padding: 0.8rem 2rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.calculate-btn {
    background: var(--success-color);
    color: white;
    flex: 2;
}

.reset-btn {
    background: var(--danger-color);
    color: white;
    flex: 1;
}

.results-section {
    margin-top: 2rem;
}

.result-row {
    margin-bottom: 1.5rem;
}

.result-display {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.result-box {
    background: var(--background-color);
    padding: 0.8rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calculation-box {
    height: 100px;
    width: 100%;
}

/* Hover effects */
.add-row-btn:hover {
    background: #81D4FA;
}

.calculate-btn:hover {
    background: #43A047;
}

.reset-btn:hover {
    background: #E53935;
}

/* Responsive design */
@media (max-width: 600px) {
    .calculator-card {
        padding: 1rem;
    }

    .input-row {
        grid-template-columns: 1fr;
    }

    .input-headers {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        flex-direction: column;
    }
}

/* 在现有CSS���尾添加 */

.invalid {
    border-color: var(--danger-color) !important;
    background-color: rgba(244, 67, 54, 0.1);
}

.error-message {
    color: var(--danger-color);
    font-size: 0.8rem;
    margin-top: 0.25rem;
    position: absolute;
    transform: translateY(100%);
}

.input-row {
    position: relative;
    margin-bottom: 1.5rem;
}

.target-input {
    position: relative;
}

/* 添加新的样式 */
.grade-input-wrapper {
    position: relative;
    width: 100%;
}

.grade-input-wrapper select,
.grade-input-wrapper input {
    width: 100%;
    height: 100%;
}

.letter-input {
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    background-color: white;
    cursor: pointer;
}

/* 修改结果显示区域样式 */
.results-section[data-grade-type="letters"] .result-row:not(.gpa-row) {
    display: none;
}

.gpa-row {
    display: none;
}

.results-section[data-grade-type="letters"] .gpa-row {
    display: block;
}

/* 添加总计行样式 */
.total-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
    padding: 0.5rem 0;
    font-weight: bold;
}

.total-row > div {
    background: var(--background-color);
    padding: 0.8rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    text-align: center;
}

/* 添加 Points 模式下的显示控制 */
.results-section[data-grade-type="points"] .result-row:not(.points-row) {
    display: none;
}

.results-section[data-grade-type="points"] .points-row {
    display: block;
}

.points-row {
    display: none;
}

/* 修改现有的容器样式 */
.calculator-container {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1rem;
    width: 100%;
}

.calculator-card {
    background: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    padding: 1.5rem;
    width: 100%;
}

/* 修改输入区域的响应式布局 */
.input-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* 添加媒体查询，优化移动端布局 */
@media screen and (max-width: 768px) {
    .calculator-card {
        padding: 1rem;
        border-radius: 8px;
    }

    h1 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }

    /* 调整按钮组布局 */
    .toggle-group {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
        width: 100%;
    }

    .toggle-btn {
        width: 100%;
        padding: 0.5rem;
        font-size: 0.9rem;
    }

    /* 调整输入区域布局 */
    .input-headers span,
    .input-row input,
    .input-row select {
        font-size: 0.9rem;
        padding: 0.6rem;
    }

    /* 调整结果显示区域 */
    .result-display {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .result-box {
        padding: 0.6rem;
        font-size: 0.9rem;
        min-height: 36px;
    }

    /* 调整操作按钮 */
    .action-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .calculate-btn,
    .reset-btn {
        padding: 0.8rem;
        font-size: 0.9rem;
    }

    /* 调整目标成绩输入框 */
    .target-input {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .target-input input {
        flex: 1;
    }

    /* 保持总计行的布局一致 */
    .total-row {
        grid-template-columns: 2fr 1fr 1fr;
        gap: 0.5rem;
        margin-top: 0.8rem;
    }

    /* 调整间距 */
    .grade-inputs,
    .decimal-places,
    .target-grade-section {
        margin-bottom: 1.5rem;
    }

    /* 确保添加行按钮样式一致 */
    .add-row-btn {
        width: 100%;
        padding: 0.8rem;
        font-size: 0.9rem;
        margin: 1rem 0;
    }
}

/* 更小屏幕的优化 */
@media screen and (max-width: 480px) {
    .calculator-container {
        margin: 1rem auto;
    }

    .input-row {
        gap: 0.5rem;
    }

    .toggle-btn,
    .input-headers span,
    .input-row input,
    .input-row select,
    .result-box {
        font-size: 0.85rem;
    }
}

/* 添加到现有的 CSS 文件末尾 */

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.site-header {
    background: var(--navy-blue, #14213D);
    padding: 1rem 0;
}

.site-header .logo {
    font-size: 2rem;
    font-weight: bold;
    color: white;
    text-decoration: none;
    font-family: Arial, sans-serif;
}

.site-header .domain-suffix {
    color: var(--accent-green, #9FE870);
}

/* 移动端适配 */
@media screen and (max-width: 480px) {
    .site-header .logo {
        font-size: 1.5rem;
    }
}

/* Breadcrumb */
.breadcrumb {
    background: #f5f5f5;
    padding: 0.5rem 0;
    margin-bottom: 2rem;
}

.breadcrumb a {
    color: var(--primary-color);
    text-decoration: none;
}

/* Main Content Layout */
.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    margin-bottom: 3rem;
}

.tools-card {
    background: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 1.5rem;
}

.tools-card h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.tools-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.tools-column a {
    display: inline-block;  /* 改为 inline-block */
    color: var(--text-color);
    text-decoration: none;
    padding: 0.5rem 0;
    transition: color 0.3s;
    white-space: nowrap;    /* 防止文字换行 */
    width: 100%;            /* 保持宽度占满容器 */
}

.tools-column a:hover {
    color: var(--primary-color);
}

.tools-categories {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.tools-categories a {
    color: var(--primary-color);
    text-decoration: none;
    padding: 0.5rem 1rem;
    background: #f5f5f5;
    border-radius: 20px;
    font-size: 0.9rem;
}

/* Footer */
.site-footer {
    background: #f5f5f5;
    padding: 2rem 0;
    margin-top: 3rem;
}

/* Responsive Design */
@media screen and (max-width: 968px) {
    .content-wrapper {
        grid-template-columns: 1fr;
    }

    .tools-card {
        margin-top: 2rem;
    }
}

@media screen and (max-width: 480px) {
    .tools-grid {
        grid-template-columns: 1fr;
    }

    .tools-categories {
        justify-content: center;
    }
}

/* SEO Content Styles */
.seo-content {
    margin-top: 4rem;
    padding: 2rem;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

/* Headings */
.seo-content h2 {
    color: var(--primary-color);
    font-size: 1.8rem;
    margin: 2.5rem 0 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #f0f0f0;
}

.seo-content h2:first-child {
    margin-top: 0;
}

.seo-content h3 {
    color: #2c3e50;
    font-size: 1.4rem;
    margin: 2rem 0 1rem;
}

/* Paragraphs */
.seo-content p {
    color: #4a5568;
    line-height: 1.7;
    margin-bottom: 1.2rem;
    font-size: 1.1rem;
}

/* Lists */
.seo-content ul {
    padding-left: 1.5rem;
    margin: 1rem 0 1.5rem;
}

.seo-content li {
    color: #4a5568;
    line-height: 1.6;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

/* Example Boxes */
.seo-content .example-box {
    background: #f8fafc;
    border-left: 4px solid var(--primary-color);
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: 0 8px 8px 0;
}

/* Responsive Design */
@media screen and (max-width: 768px) {
    .seo-content {
        padding: 1.5rem;
        margin-top: 3rem;
    }

    .seo-content h2 {
        font-size: 1.6rem;
    }

    .seo-content h3 {
        font-size: 1.3rem;
    }

    .seo-content p,
    .seo-content li {
        font-size: 1rem;
    }
}

@media screen and (max-width: 480px) {
    .seo-content {
        padding: 1rem;
        margin-top: 2rem;
    }

    .seo-content h2 {
        font-size: 1.4rem;
    }

    .seo-content h3 {
        font-size: 1.2rem;
    }
}

/* Grade Scale Table Styles */
.grade-scale-section {
    margin: 3rem 0;
    padding: 2rem;
    background: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.grade-scale-intro {
    font-size: 1.1rem;
    color: var(--text-color);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.grade-table-wrapper {
    overflow-x: auto;
}

.grade-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 1rem;
}

.grade-table th {
    background: var(--primary-color);
    color: white;
    padding: 1rem;
    text-align: center;
    font-weight: 500;
}

.grade-table td {
    padding: 0.8rem 1rem;
    text-align: center;
    border: 1px solid var(--border-color);
}

.grade-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

/* Responsive adjustments */
@media screen and (max-width: 768px) {
    .grade-scale-section {
        padding: 1.5rem;
        margin: 2rem 0;
    }

    .grade-scale-intro {
        font-size: 1rem;
    }

    .grade-table {
        font-size: 0.9rem;
    }

    .grade-table th,
    .grade-table td {
        padding: 0.6rem;
    }
}

@media screen and (max-width: 480px) {
    .grade-scale-section {
        padding: 1rem;
        margin: 1.5rem 0;
    }

    .grade-table {
        font-size: 0.8rem;
    }
}

/* GPA Calculator Specific Styles */
.gpa-input-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
    position: relative;
}

.gpa-input-row select {
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
    width: 100%;
}

.gpa-input-row select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.cumulative-gpa-section {
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 8px;
    margin: 2rem 0;
    border: 1px solid var(--border-color);
}

.cumulative-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}

.cumulative-inputs .input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cumulative-inputs label {
    font-size: 0.9rem;
    color: var(--text-color);
    font-weight: 500;
}

.cumulative-inputs input {
    width: 100%;
}

.grade-scale-section {
    margin-top: 2rem;
    background: var(--card-background);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.grade-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.grade-table th {
    background: var(--primary-color);
    color: white;
    padding: 0.8rem;
    text-align: center;
    font-weight: 500;
}

.grade-table td {
    padding: 0.8rem;
    text-align: center;
    border: 1px solid var(--border-color);
}

.grade-table tr:nth-child(even) {
    background: #f8fafc;
}

.grade-scale-intro {
    color: var(--text-color);
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

/* Responsive Design for GPA Calculator */
@media screen and (max-width: 768px) {
    .gpa-input-row {
        grid-template-columns: 1fr 1fr;
        gap: 0.8rem;
    }

    .cumulative-inputs {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .grade-table {
        font-size: 0.9rem;
    }

    .grade-table th,
    .grade-table td {
        padding: 0.6rem;
    }
}

@media screen and (max-width: 480px) {
    .gpa-input-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .grade-scale-section {
        padding: 1rem;
        margin-top: 1.5rem;
    }

    .grade-table {
        font-size: 0.8rem;
    }

    .grade-table th,
    .grade-table td {
        padding: 0.5rem;
    }

    .grade-scale-intro {
        font-size: 1rem;
    }
}

/* Hover Effects */
.gpa-input-row select:hover {
    border-color: var(--primary-color);
}

/* Focus States */
.gpa-input-row input:focus,
.gpa-input-row select:focus,
.cumulative-inputs input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

/* Animation for New Rows */
.gpa-input-row {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Table Scroll for Mobile */
.grade-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
    padding: 0 1rem;
}
/* Calculator Controls */
.calculator-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.grade-type-selector {
    display: flex;
    gap: 0.5rem;
}

.weighted-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.toggle-label {
    font-size: 0.9rem;
    color: var(--text-color);
}

/* Percentage Input Styles */
.percentage-input {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
}

/* 移动端优化样式 */
@media screen and (max-width: 768px) {
    /* 基础布局调整 */
    .calculator-container {
        padding: 1rem;
    }

    /* 输入行布局优化 */
    .gpa-input-row {
        grid-template-columns: 1fr;  /* 改为单列布局 */
        gap: 0.5rem;
        margin-bottom: 1.5rem;
        padding: 1rem;
        background: #fff;
        border-radius: 8px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }

    /* 输入框样式调整 */
    .gpa-input-row input,
    .gpa-input-row select {
        width: 100%;
        padding: 0.8rem;
        margin-bottom: 0.5rem;
    }

    /* 标题和标签调整 */
    .input-headers {
        display: none;  /* 在移动端隐藏表头 */
    }

    /* 添加输入框标签 */
    .gpa-input-row input::placeholder,
    .gpa-input-row select::placeholder {
        font-size: 0.9rem;
    }

    /* 控制按钮样式 */
    .calculator-controls {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .grade-type-selector {
        width: 100%;
        justify-content: center;
    }

    .toggle-btn {
        flex: 1;
        padding: 0.8rem;
    }

    /* 计算和重置按钮 */
    .button-group {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        margin-top: 1rem;
    }

    /* 结果显示区域 */
    .results-container {
        margin-top: 1.5rem;
        padding: 1rem;
    }

    #calculation-process {
        font-size: 0.9rem;
        word-break: break-word;  /* 允许长公式换行 */
        white-space: pre-wrap;
    }

    /* Previous GPA 输入区域 */
    .previous-gpa-container {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.5rem;
        margin: 1rem 0;
    }

    /* 添加和删除按钮 */
    .add-row-btn {
        width: 100%;
        margin: 1rem 0;
    }

    /* 权重切换开关 */
    #weightedToggleContainer {
        justify-content: center;
        margin: 1rem 0;
    }
}

/* 超小屏幕设备的额外优化 */
@media screen and (max-width: 320px) {
    .calculator-container {
        padding: 0.5rem;
    }

    .gpa-input-row {
        padding: 0.8rem;
    }

    input, select, button {
        font-size: 0.9rem;
    }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
    .gpa-input-row {
        background: #2a2a2a;
    }

    input, select {
        background: #333;
        color: #fff;
        border-color: #444;
    }
}

