/* 将所有样式从HTML中提取到这个文件中 */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #1A66A0;
    /* 改为蓝紫色 */
    --light-color: #ecf0f1;
    --dark-color: #2c3e50;
    --success-color: #2ecc71;
    --border-radius: 8px;
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f9f9f9;
    color: var(--dark-color);
    line-height: 1.6;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 主行布局容器 */
.main-row-container {
    width: 100%;
    background-color: #f9f9f9;
    padding: 0 0 2rem 0;
    position: relative;
    z-index: 1;
}

/* 更宽的容器，用于容纳三个并排的部分 */
.wide-container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 主行布局 */
.main-row {
    display: flex;
    gap: 2rem;
}

.left-sidebar,
.right-sidebar {
    flex: 0 0 250px;
    background-color: #f0f2f5;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 1.5rem;
    position: relative;
    z-index: 1;
}

.calculator-main {
    flex: 1;
    position: relative;
    z-index: 1;
}

.placeholder-content {
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
    padding: 2rem;
}

/* 左侧导航栏样式 */
.nav-title {
    color: var(--primary-color);
    margin-bottom: 1rem;
    padding: 0 0 0.7rem 0;
    border-bottom: 3px solid #d9dee3;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
}

.nav-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.nav-button {
    background: #fdfefe;
    color: var(--primary-color);
    border: 1.5px solid #3a97e8;
    padding: 0.72rem 0.9rem;
    font-size: 0.96rem;
    line-height: 1.45;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    text-align: center;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 66px;
    font-weight: 600;
    box-shadow: none;
}

.nav-button:hover {
    background: #f3f8ff;
    color: var(--primary-color);
    border-color: #2f8fe4;
    box-shadow: 0 4px 10px rgba(25, 45, 76, 0.08);
    transform: translateY(-1px);
}

.nav-button:active {
    background: #eef5ff;
    transform: translateY(0);
    box-shadow: none;
}

/* 为外部链接按钮添加外链标志 */
.nav-button.external {
    position: relative;
    padding-right: 2.5rem;
    background-color: var(--light-color);
    color: var(--primary-color);
    border: 2px solid var(--secondary-color);
}

.nav-button.external::after {
    content: "↗";
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    font-weight: bold;
    transition: transform 0.2s ease;
}

.nav-button.external:hover {
    background-color: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

.nav-button.external:hover::after {
    transform: translateY(-50%) translateX(2px) translateY(-2px);
}

/* 头部样式 */
header {
    background: linear-gradient(135deg, #00447F 0%, #0066AA 100%);
    color: white;
    padding: 0.25rem 0;
    text-align: center;
    margin-bottom: 0.5rem;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    box-shadow: var(--box-shadow);
    position: relative;
    overflow: visible;
    display: flex;
    align-items: center;
    min-height: 70px;
    z-index: 1000;
}

/* 添加微妙的纹理效果 */
header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><path d="M0,0 L100,0 L100,100 Z" fill="rgba(255,255,255,0.1)"/></svg>');
    background-size: cover;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
}

footer {
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 0.5rem 0;
    margin-top: 3rem;
}


/* 多语言选择器样式 - 修改：确保在桌面端和移动端都在右边 */
.language-selector {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    z-index: 1001;
}

.language-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.language-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

.language-toggle::after {
    content: "▼";
    margin-left: 5px;
    font-size: 0.7rem;
}

.language-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: 107px;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    z-index: 1002;
}

.language-dropdown.active {
    display: block;
}

.language-option {
    display: block;
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s, color 0.2s;
    font-size: 0.85rem;
    color: #333;
    text-decoration: none;
}

.language-option:hover {
    background: #f5f8ff;
    color: #1f5fbf;
}

.language-option.active {
    background: #eef4ff;
    color: #1f5fbf;
    font-weight: 600;
}

.language-option:last-child {
    border-bottom: none;
}

.language-option:hover {
    background: #f5f5f5;
}

.language-option:last-child {
    border-bottom: none;
}

.language-option.active {
    background: #e6f2ff;
    color: #0066cc;
    font-weight: 500;
}

.globe-icon {
    margin-right: 5px;
    font-size: 0.9rem;
}

/* 矩阵计算器样式 */
.matrix-calculator {
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 5px;
    background-color: #f4f4f9;
    width: 100%;
}

.matrix-calculator .main-calculator-container {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 0px;
}

.matrix-calculator .matrix-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 400px;
}

.matrix-calculator .controls {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px;
    margin-bottom: 10px;
    padding: 0 4px;
    width: 100%;
    box-sizing: border-box;
}

.matrix-calculator .matrix-label {
    font-size: 1.5em;
    font-weight: bold;
    color: #333;
    margin-right: 8px;
}

.matrix-calculator .matrix-dimension {
    font-size: 0.7em;
    color: #666;
    margin-left: 5px;
    font-weight: normal;
}

.matrix-calculator .size-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 6px;
    background-color: #f8f9fa;
    border-radius: 4px;
}

.matrix-calculator .size-controls .control-label {
    font-size: 0.85em;
    color: #666;
    margin-right: 3px;
}

.matrix-calculator .random-controls {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 10px;
    background-color: #f8f9fa;
    border-radius: 4px;
}

.matrix-calculator .random-options {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 45px;
    left: 0;
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 5px;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.matrix-calculator .operation-buttons {
    display: flex;
    flex-direction: column;
    margin-top: 250px;
    gap: 5px;
    justify-content: center;
}

.matrix-calculator .operation-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.2em;
    width: 100px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    transition: background-color 0.2s;
}

.matrix-calculator .operation-btn:hover {
    background-color: #5a6268;
}

.matrix-calculator .operation-btn:active {
    background-color: #545b62;
    transform: translateY(1px);
}

.matrix-calculator .op-input {
    width: 40px;
    padding: 5px;
    text-align: center;
    border: 1px solid #aaa;
    border-radius: 3px;
    font-size: 0.9em;
    height: 35px;
    box-sizing: border-box;
}

.matrix-calculator .matrix-container {
    border: 2px solid #333;
    border-radius: 5px;
    padding: 10px;
    background-color: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    min-width: 150px;
    min-height: 150px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 380px;
}

.matrix-calculator .matrix {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    /* 假设是3x3矩阵，每列等宽 */
    gap: 2px;
    /* 缩小单元格间隙 */

}

.matrix-calculator .matrix input {
    width: 45px;
    height: 45px;
    text-align: center;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    transition: border-color 0.3s;
}

/* Hide number input spinners */
.matrix-calculator .matrix input[type=number]::-webkit-inner-spin-button,
.matrix-calculator .matrix input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}



/* 错误消息样式 */
.error-message {
    background-color: #ffeaea;
    border-left: 4px solid #ff4b4b;
    padding: 12px;
    margin: 10px 0;
    border-radius: 4px;
    color: #d32f2f;
    font-weight: 500;
}

.error-message i {
    margin-right: 8px;
    color: #ff4b4b;
}

/* 维度帮助样式 */
.dimension-help {
    background-color: #fff8e1;
    border: 1px solid #ffd54f;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.dimension-help .help-header {
    display: flex;
    align-items: center;
    font-weight: bold;
    color: #ff8f00;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.dimension-help .help-header i {
    margin-right: 8px;
    font-size: 1.2em;
}

.dimension-help .help-content {
    color: #5d4037;
    line-height: 1.5;
}

.dimension-help .help-content p {
    margin-bottom: 8px;
}

.dimension-help .help-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.dimension-help .fix-btn,
.dimension-help .help-btn {
    padding: 8px 15px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.dimension-help .fix-btn {
    background-color: #4caf50;
    color: white;
}

.dimension-help .fix-btn:hover {
    background-color: #3d8b40;
}

.dimension-help .help-btn {
    background-color: #2196f3;
    color: white;
}

.dimension-help .help-btn:hover {
    background-color: #0b7dda;
}

/* --- 您提供的结果输出样式 --- */
#result-container {
    margin-top: 0px;
    width: 90%;
    max-width: 1200px;
    background-color: white;
    border: 2px solid #aaa;
    border-radius: 8px;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #f8f9fa;
}

.result-header h3 {
    margin: 0;
    color: var(--primary-color);
}

.clear-all-btn {
    background-color: var(--accent-color);  /* 使用蓝紫色 */
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s;
}

.clear-all-btn:hover {
    background-color: #55AFCB; /* 深一点的蓝紫色 */
}

.result-history {
    max-height: 600px;
    overflow-y: auto;
}

.result-block {
    padding: 15px 10px;
    border-bottom: 1px solid #e0e0e0;
    position: relative;
}

.result-block:last-child {
    border-bottom: none;
}

.result-expression-row {
    display: flex;
    flex-wrap: wrap;
    /* 关键修改：允许换行 */
    align-items: center;
    justify-content: flex-start;
    gap: 15px;
    padding: 10px 0;
    overflow-x: visible;
    /* 移除横向滚动 */
}

.result-op,
.result-eq {
    font-size: 2em;
    font-weight: 500;
    color: #333;
}

/* Result Matrix Styling */
.result-matrix-grid {
    display: grid;
    gap: 5px;
    padding: 5px 0;
    border: none;
    border-left: 3px solid #333;
    border-right: 3px solid #333;
    border-radius: 0;
    box-sizing: content-box;
    position: relative;
}

.result-matrix-grid .matrix-dimension {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7em;
    color: #666;
    background-color: #f8f9fa;
    padding: 0 5px;
    border-radius: 3px;
    white-space: nowrap;
}

.result-cell {
    min-width: 45px;
    height: 45px;
    text-align: center;
    font-size: 14px;
    line-height: 45px;
    border: 1px solid #ddd;
    background-color: #f0f8ff;
    border-radius: 3px;
    overflow: hidden;
    white-space: nowrap;
    box-sizing: border-box;
    font-weight: bold;
}

.process-matrix {
    border-left: 3px solid orange;
    border-right: 3px solid orange;
}

.process-matrix .result-cell {
    background-color: #fff3e0;
    font-size: 12px;
    line-height: normal;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: auto;
    height: auto;
    padding: 5px;
    white-space: normal;
}

.action-buttons {
    position: absolute;
    top: 5px;
    right: 10px;
    display: flex;
    gap: 10px;
    z-index: 10;
}

.action-buttons button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    color: #6c757d;
    transition: color 0.2s;
}

.action-buttons button:hover {
    color: #000;
}

.error-message {
    color: red;
    font-size: 1em;
    margin: 10px 0;
    padding: 10px;
    background-color: #ffeaea;
    border-radius: 4px;
}

/* 分享下拉菜单样式 */
.share-dropdown {
    position: relative;
    display: inline-block;
}

.share-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 1000;
    min-width: 150px;
}

.share-menu.active {
    display: block;
}

.share-option {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 0.9em;
}

.share-option:hover {
    background: #f5f5f5;
}

/* 桌面端隐藏移动导航按钮 */
.mobile-nav-toggle {
    display: none;
}

/* --- 移动端响应式设计 --- */
@media (max-width: 1200px) {
    .matrix-calculator .main-calculator-container {
        gap: 20px;
    }

    .matrix-calculator .matrix-area {
        width: 100%;
        padding: 0;
    }

    .matrix-calculator .matrix-container {
        width: 100%;
        max-width: none;
        /* 移除固定最大宽度，让容器填满 */
        padding: 5px;
    }

    .matrix-calculator .matrix input {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 992px) {
    .matrix-calculator .main-calculator-container {
        flex-direction: column;
        align-items: center;
        gap: 30px;
    }

    .matrix-calculator .operation-buttons {
        flex-direction: row;
        margin-top: 20px;
        margin-bottom: 20px;
        order: 3;
    }

    .matrix-calculator .operation-btn {
        width: 80px;
        height: 45px;
        font-size: 1em;
    }

    .matrix-calculator .matrix-area {
        width: 100%;
        max-width: 500px;
    }

    .matrix-calculator .matrix-container {
        width: 100%;
        max-width: none;
        /* 移除固定最大宽度，让容器填满 */
        padding: 5px;
    }

    .matrix-calculator .controls {
        justify-content: center;
    }

    .matrix-calculator .op-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

/* 主要修改：移动端响应式设计 (max-width: 768px) */
@media (max-width: 768px) {

    /* 移动端空隙优化 - 新增 */
    .wide-container {
        padding: 0 8px;
        /* 从20px减少到8px，释放24px宽度 */
        margin-left: auto;
        margin-right: auto;
        width: calc(100% - 1px);
        /* 16px = 左右内边距之和，保证内容区域占满 */
    }

    .matrix-calculator {
        padding: 0;
        background-color: transparent;
    }

    .matrix-calculator .main-calculator-container {
        gap: 8px;
        /* 减少矩阵A和B之间的间距 */
    }

    .matrix-calculator .matrix-container {
        box-shadow: none;
        border: 1px solid #bbb;
        padding: 3px;
        max-width: 100%;
        /* 改为100%宽度 */
    }

    #result-container {
        width: 100%;
        margin-top: 10px;
        border: 1px solid #ccc;
        box-shadow: none;
        padding: 5px;
    }

    .matrix-calculator .matrix-area {
        width: 100%;
        padding: 0;

    }

    /* 修改多语言栏位置到右边 */
    .language-selector {
        position: absolute;
        top: 50%;
        right: 20px;
        transform: translateY(-50%);
        left: auto;
        margin-top: 0;
        text-align: right;
    }

    .language-dropdown {
        right: 0;
        left: auto;
        width: 120px;
    }

    /* 调整header布局以适应移动端 */
    header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 0.25rem 15px;
        min-height: 50px;
    }

    h1 {
        font-size: 1.3rem;
        margin: 0;
        flex: 1;
        text-align: left;
    }

    /* 移动端导航下拉框样式 */
    .mobile-nav-toggle {
        display: block;
        width: 100%;
        background-color: var(--secondary-color);
        color: white;
        border: none;
        padding: 0.5rem 0.8rem;
        /* 原为 0.8rem 1rem，适当减小 */
        border-radius: var(--border-radius);
        cursor: pointer;
        font-size: 0.95rem;
        /* 可稍减小字号 */
        font-weight: 500;
        text-align: center;
        margin: 0;
        transition: all 0.3s ease;
    }

    .mobile-nav-toggle:hover {
        background-color: #2980b9;
    }

    .mobile-nav-toggle::after {
        content: "▼";
        margin-left: 8px;
        font-size: 0.8rem;
    }

    .mobile-nav-toggle.active::after {
        content: "▲";
    }

    /* 隐藏原有的导航栏，显示下拉框 */
    .left-sidebar {
        padding: 0.25rem 0.25rem;
        /* 原为 1rem，改为 0.5rem */
        background: transparent;
        box-shadow: none;
        margin-bottom: 0.5rem;
    }

    .nav-title {
        display: none;
    }

    .nav-buttons {
        display: none;
        position: relative;
        top: 0;
        left: 0;
        width: 100%;
        background: white;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        z-index: 1000;
        padding: 0.5rem;
        flex-direction: column;
        margin-top: 0.5rem;
    }

    .nav-buttons.active {
        display: flex;
    }

    .nav-button {
        width: 100%;
        text-align: left;
        border: 1px solid #e0e0e0;
        margin: 0;
        border-radius: 4px;
    }

    /* 其他原有样式 */
    .matrix-calculator body {
        padding: 5px 10px;
    }

    .matrix-calculator .matrix-label {
        font-size: 2em;
    }

    .matrix-calculator .controls {
        flex-wrap: wrap;
        gap: 10px;
        justify-content: center;
    }

    .matrix-calculator .size-controls,
    .matrix-calculator .random-controls {
        border-right: none;
        padding-right: 0;
    }


    .matrix-calculator .matrix input {
        width: 35px;
        height: 35px;
        font-size: 12px;
    }

    .result-expression-row {
        flex-direction: column;
        gap: 10px;
        overflow-x: visible;
    }

    .result-op,
    .result-eq {
        font-size: 1.5em;
    }

    .result-cell {
        min-width: 35px;
        height: 35px;
        font-size: 12px;
        line-height: 35px;
    }

    .process-matrix .result-cell {
        min-width: 100px;
        font-size: 10px;
    }

    #result-container {
        width: 100%;
    }

    .main-row {
        flex-direction: column;
    }

    .left-sidebar,
    .right-sidebar {
        flex: 1;
        width: 100%;
    }

    .result-header {
        flex-direction: row;
        justify-content: space-between;
        gap: 10px;
        align-items: center;
    }

    .action-buttons {
        position: absolute;
        top: 5px;
        right: 10px;
        justify-content: flex-end;
        margin-bottom: 0;
        display: flex;
        gap: 10px;
        z-index: 10;
    }

    /* 移动端显示简化结果 */
    .mobile-result-view {
        display: block;
    }

    /* 1. 缩小矩阵容器宽度，让它更适配屏幕 */
    .matrix-calculator .matrix-container {
        width: 100%;
        max-width: none;
        /* 移除固定最大宽度，让容器填满 */
        padding: 5px;
        /* 保留一点内边距，避免单元格贴边 */
    }

    /* 2. 缩小矩阵单元格（结果矩阵 & 输入矩阵通用） */
    .result-cell,
    .matrix-cell,
    .input-matrix .matrix-cell input {
        min-width: 26px !important;
        height: 26px !important;
        padding: 2px !important;
        font-size: 12px !important;
        line-height: 1.1 !important;
    }

    /* 3. 缩小过程矩阵（你的过程矩阵本来特别大，所以单独缩小） */
    .process-matrix .result-cell {
        min-width: 24px !important;
        height: 24px !important;
        font-size: 11px !important;
        padding: 1px !important;
    }

    /* 4. 缩小符号，例如加号、乘号、等号 */
    .matrix-operator {
        font-size: 20px !important;
        margin: 0 4px !important;
    }

    /* 5. 缩小矩阵块与块之间的间距 */
    .matrix-wrapper {
        margin: 4px 0 !important;
    }

    

    .main-row {
        gap: 0rem;
        /* 调整为你想要的垂直间距，0 表示无间距 */
    }

}

@media (max-width: 480px) {

    /* 在小屏幕设备上进一步调整 */
    .wide-container {
        padding: 0 5px;
        /* 在更小的屏幕上进一步减少 */
    }

    .matrix-calculator .main-calculator-container {
        gap: 10px;
    }

    .language-selector {
        right: 10px;
    }

    .language-toggle {
        padding: 5px 10px;
        font-size: 0.8rem;
    }

    .mobile-nav-toggle {
        padding: 0.6rem 0.8rem;
        font-size: 1rem;
    }

    h1 {
        font-size: 1.2rem;
        margin-right: 10px;
    }

    /* 其他原有样式 */
    .matrix-calculator .matrix input {
        width: 30px;
        height: 30px;
        font-size: 11px;
    }

    .matrix-calculator .matrix-container {
        padding: 0px;
    }

    .matrix-calculator .operation-btn {
        width: 70px;
        height: 40px;
        font-size: 0.9em;
        padding: 5px 10px;
    }

    .matrix-calculator .op-input {
        width: 35px;
        height: 30px;
        font-size: 0.8em;
    }

    .result-cell {
        min-width: 30px;
        height: 30px;
        font-size: 11px;
        line-height: 30px;
    }

    .simplified-matrix {
        font-size: 0.9em;
        padding: 8px;
    }
}

/* ===== layout fix: force ops + result under A/B when parent is flex ===== */
.main-calculator-container {
    flex-wrap: wrap;
}

/* ===== Swap Icon in the middle of A/B controls ===== */
.main-2m-with-swap {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    column-gap: 14px;
    align-items: stretch;
    /* 关键：让中间列从顶部开始对齐 */
}

/* 中间列：只负责把按钮顶到上边，并与 controls 行对齐 */
.swap-mid-col {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /* 顶部对齐 */
    padding-top: 8px;
    /* 微调：让它跟 A/B controls 高度对齐 */
}

/* 图标按钮本体 */
.swap-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.swap-icon-btn:hover {
    transform: translateY(-1px);
}

.swap-icon-btn i {
    font-size: 16px;
}

/* Minimal input hint (no box, no effect) */
.input-hint {
    margin: 6px 0 6px;
    /* 上下留一点点气口 */
    padding: 0;
    /* 不要内边距 */
    background: none;
    /* 无背景 */
    border: none;
    /* 无边框 */
    border-radius: 0;
    /* 无圆角 */
    color: #64748b;
    /* 低存在感灰 */
    font-size: 13px;
    /* 小一点 */
    line-height: 1.35;
    text-align: left;
    /* 左对齐 */
}

/* Mobile one-dropdown op bar */
.mobile-op-onebar {
    display: none;
}

@media (max-width: 980px) {
    .mobile-op-onebar {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        gap: 10px;
        margin: 10px 0 12px;
        align-items: center;
    }

    .mobile-op-select {
        grid-column: 1 / 3;
        height: 44px;
        border-radius: 10px;
        border: 1px solid rgba(15, 23, 42, .14);
        background: #fff;
        padding: 0 10px;
        font-weight: 600;
    }

    .mobile-op-display {
        min-height: 44px;
        border-radius: 10px;
        border: 1px solid rgba(15, 23, 42, .10);
        background: #fff;
        display: flex;
        align-items: center;
        padding: 0 10px;
        color: #334155;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-op-eq {
        width: 56px;
        height: 44px;
        border-radius: 10px;
        border: 1px solid rgba(15, 23, 42, .14);
        background: #fff;
        font-weight: 800;
        cursor: pointer;
    }

    /* 移动端隐藏桌面 ops-v2（仅对非首页生效） */
    body:not(.page-index) .ops.ops-v2 {
        display: none !important;
    }
}

/* =========================================================
   FINAL — Mobile Onebar (Select fixed label + display/param/=)
   Put this block at the VERY END of calculator.css
   ========================================================= */
@media (max-width: 980px) {

    /* onebar overall layout: 2 rows
     row1: select (full width)
     row2: display + param + eq
  */
    .mobile-op-onebar {
        display: grid !important;
        grid-template-columns: 1fr auto auto !important;
        grid-template-rows: auto auto !important;
        gap: 10px !important;
        margin: 10px 0 12px !important;
        align-items: center !important;
    }

    /* ---------- Select wrapper (fixed face) ---------- */
    .mobile-op-selectwrap {
        grid-column: 1 / 4 !important;
        /* occupy full row1 */
        position: relative !important;
        height: 44px !important;
    }

    /* real select: clickable but invisible */
    .mobile-op-selectwrap .mobile-op-select {
        width: 100% !important;
        height: 44px !important;
        opacity: 0 !important;
        position: relative !important;
        z-index: 2 !important;
    }

    /* fixed face shown to user */
    .mobile-op-selectface {
        position: absolute !important;
        inset: 0 !important;
        z-index: 1 !important;
        height: 44px !important;
        border-radius: 10px !important;
        border: 1px solid rgba(15, 23, 42, .14) !important;
        background: #fff !important;
        padding: 0 10px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        font-weight: 600 !important;
        color: #334155 !important;
        pointer-events: none !important;
        /* click passes through */
        box-sizing: border-box !important;
        width: 100% !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .mobile-op-selectface .chev {
        opacity: .75 !important;
    }

    /* ---------- display (chosen operation text) ---------- */
    .mobile-op-display {
        min-height: 44px !important;
        border-radius: 10px !important;
        border: 1px solid rgba(15, 23, 42, .10) !important;
        background: #fff !important;
        display: flex !important;
        align-items: center !important;
        padding: 0 10px !important;
        color: #334155 !important;
        font-weight: 600 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        box-sizing: border-box !important;
    }

    /* ---------- param input (k / n) ---------- */
    .mobile-op-param {
        height: 44px !important;
        width: 88px !important;
        border-radius: 10px !important;
        border: 1px solid rgba(15, 23, 42, .14) !important;
        background: #fff !important;
        padding: 0 10px !important;
        font-weight: 700 !important;
        box-sizing: border-box !important;
    }

    /* ---------- equals button ---------- */
    .mobile-op-eq {
        width: 56px !important;
        height: 44px !important;
        border-radius: 10px !important;
        border: 1px solid rgba(15, 23, 42, .14) !important;
        background: #fff !important;
        font-weight: 800 !important;
        cursor: pointer !important;
    }
}

/* ---新增右边栏的样式---*/
.poster-card {
    width: 100%;
    max-width: 290px;
    background: #f0f2f5;
    border-radius: 22px;
    padding: 18px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 10px 10px 20px rgba(163, 177, 198, 0.55),
        -10px -10px 20px rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.promo-text {
    font-size: 0.88rem;
    color: #374151;
    line-height: 1.42;
    margin: 0;
    padding: 0 2px;
    font-weight: 500;
}

.promo-text span {
    color: #1d4ed8;
    font-weight: 700;
}

.image-container {
    position: relative;
    display: block;
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    background: #e6e8eb;
    box-shadow: inset 5px 5px 10px rgba(163, 177, 198, 0.55),
        inset -5px -5px 10px rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
}

.image-container:hover {
    transform: translateY(-2px) scale(1.008);
}

.image-container:active {
    transform: translateY(1px) scale(0.985);
}

.game-image {
    width: 100%;
    height: auto;
    display: block;
    opacity: 0.92;
    transition: opacity 0.3s;
}

.image-container:hover .game-image {
    opacity: 1;
}

.play-icon-overlay {
    width: 46px;
    height: 46px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.1),
        -3px -3px 8px rgba(255, 255, 255, 0.8);
    transition: all 0.2s ease;
    pointer-events: none;
}

.image-container:hover .play-icon-overlay {
    transform: translate(-50%, -50%) scale(1.08);
}

.play-triangle {
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 0 8px 13px;
    border-color: transparent transparent transparent #1d4ed8;
    margin-left: 3px;
}
/* ===== OPS FLAT (calm)冷静版按钮布局和颜色 ===== */
.ops-v2.ops-flat {
    display: grid;
    grid-template-columns: 1fr 4fr;  /* 左 1/5，右 4/5 */
    gap: 12px;
    align-items: start;
    margin: 22px 0;
}

.ops-v2.ops-flat .btn {
    appearance: none;
    -webkit-appearance: none;
    height: 38px;
    border-radius: 0;
    border: 0;
    background: #cfe8f1;
    color: #0f172a;
    font-weight: 500;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    cursor: pointer;
    white-space: nowrap;
    text-overflow: clip;  /* ✅ 直接裁切，不要省略号 */
    min-width: 0;  /* ✅ 很关键：允许在 grid 里被压缩 */
    transition: background-color .12s ease;
    max-width: 100%;
    overflow: hidden;
}
/* 右侧网格：左对齐 + 截断从右边裁 */
.ops-v2.ops-flat .ops-grid .btn {
    justify-content: flex-start;
    text-align: left;
    padding-left: 14px; /* 给左边一点呼吸 */
}

/* 左列 core：继续居中（保持你想要的感觉） */
.ops-v2.ops-flat .ops-core .btn {
    justify-content: center;
    text-align: center;
}

.ops-v2.ops-flat .btn:hover {
    background: #bfe0ec;
}
.ops-v2.ops-flat .ops-core .btn.core-main:hover {
    background: #4aa6c2;
    /* 比 #55AFCB 略深 */
}

.ops-v2.ops-flat .ops-core .btn.core-sub:hover,
.ops-v2.ops-flat .ops-grid .btn.func-mid:hover {
    background: #9fcfe0;
    /* 比 #ADD8E6 略深 */
}
.ops-v2.ops-flat .ops-grid .btn[data-goto$="matrix-logarithm-calculator.html"]:hover,
.ops-v2.ops-flat .ops-grid .btn[data-goto$="matrix-sine-calculator.html"]:hover,
.ops-v2.ops-flat .ops-grid .btn[data-goto$="matrix-cosine-calculator.html"]:hover,
.ops-v2.ops-flat .ops-grid .btn[data-goto$="matrix-tangent-calculator.html"]:hover,
.ops-v2.ops-flat .ops-grid .btn[data-goto$="matrix-exponential-calculator.html"]:hover,
.ops-v2.ops-flat .ops-grid .btn[data-goto$="matrix-arcsine-calculator.html"]:hover,
.ops-v2.ops-flat .ops-grid .btn[data-goto$="matrix-arccosine-calculator.html"]:hover,
.ops-v2.ops-flat .ops-grid .btn[data-goto$="matrix-arctangent-calculator.html"]:hover {
    background: #9fcfe0;
}

.ops-v2.ops-flat .ops-core {
    display: grid;
    gap: 8px;
}

.ops-v2.ops-flat .ops-core .btn.core-main {
    background: #55b2c8;
    font-weight: 700;
}

.ops-v2.ops-flat .ops-core .btn.core-sub {
    background: #cfe8f1;
    font-weight: 600;
}
.ops-v2.ops-flat .ops-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px 12px;
    min-width: 0;
}

.ops-v2.ops-flat .btn.span2 {
    grid-column: span 2;
}


@media (max-width: 980px) {
    .ops-v2.ops-flat {
        grid-template-columns: 1fr;
    }

    .ops-v2.ops-flat .ops-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ops-v2.ops-flat .btn {
        font-size: 20px;
    }
}
/* 全部按钮默认最浅 */
.ops-v2.ops-flat .btn {
    background: #CCE7F0;
    color: #0f172a;
}

/* 左列三大主按钮：最深 */
.ops-v2.ops-flat .ops-core .btn.core-main {
    background: #55AFCB;
    color: #0f172a;
    font-weight: 700;
}

/* 左列下面四个：中深 */
.ops-v2.ops-flat .ops-core .btn.core-sub {
    background: #ADD8E6;
    color: #0f172a;
    font-weight: 600;
}

/* 右侧函数那 8 个：中深（用 data-goto 精准点名，不用加 class） */
.ops-v2.ops-flat .ops-grid .btn[data-goto$="matrix-logarithm-calculator.html"],
.ops-v2.ops-flat .ops-grid .btn[data-goto$="matrix-sine-calculator.html"],
.ops-v2.ops-flat .ops-grid .btn[data-goto$="matrix-cosine-calculator.html"],
.ops-v2.ops-flat .ops-grid .btn[data-goto$="matrix-tangent-calculator.html"],
.ops-v2.ops-flat .ops-grid .btn[data-goto$="matrix-exponential-calculator.html"],
.ops-v2.ops-flat .ops-grid .btn[data-goto$="matrix-arcsine-calculator.html"],
.ops-v2.ops-flat .ops-grid .btn[data-goto$="matrix-arccosine-calculator.html"],
.ops-v2.ops-flat .ops-grid .btn[data-goto$="matrix-arctangent-calculator.html"] {
    background: #ADD8E6;
}
/* ===== minimal stable core-inline (Multiply by / Power) ===== */
.ops-v2.ops-flat .ops-core .core-inline {
    display: grid;
    grid-template-columns: 1fr 42px; /* 按钮 + 小框 */
    align-items: center;
    gap: 0; /* 你要贴紧就 0；想留缝改成 6px */
    min-width: 0;
}

.ops-v2.ops-flat .ops-core .core-inline .btn {
    justify-content: center; /* 文案居中 */
    text-align: center;
    min-width: 0;
}

.ops-v2.ops-flat .ops-core .core-inline input {
    width: 42px;
    height: 38px;
    box-sizing: border-box;
    border: 1px solid #7fbfd0;
    background: #fff;
    border-radius: 0;
    padding: 0;
    /* 先别玩左对齐，稳定第一 */
    text-align: center;
    /* 稳定且不挤爆 */
    font-size: 15px;
    font-weight: 600;
    outline: none;
}

/*--乘法按钮的特殊效果--*/
#calculate-multiplication-btn {
    font-size: 22px;
    font-weight: 600;
}
/*--约束首页图片的显示--*/
.matrix-image {
    display: block;
    width: 100%;
    max-width: 720px;
    height: auto;
    margin: 0 auto;
}
.seo-articles-container {
    max-width: 900px;
    margin: 0 auto 2rem;
    padding: 24px 20px;
    line-height: 1.7;
    color: #111;
}

.seo-articles-container h1 {
    font-size: 1.8rem;
    margin-bottom: 12px;
}

.seo-articles-container h2 {
    font-size: 1.4rem;
    margin: 24px 0 12px;
}

.seo-articles-container h3 {
    font-size: 1.15rem;
    margin: 18px 0 8px;
}

.seo-articles-container p {
    margin-bottom: 12px;
}

.seo-articles-container ul {
    padding-left: 20px;
    margin-bottom: 12px;
}

.seo-articles-container li {
    margin-bottom: 6px;
}
/*--右边栏的内链内容的样式--*/
.related-tools {
    margin-top: 14px;
    padding: 14px 14px 16px;
    background: #e3e9f6;
    border: 1px solid #cfd7e7;
    border-radius: 24px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.related-tools h3 {
    margin: 2px 0 14px;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
    color: #2c4667;
}

.related-tools ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.related-tools li+li {
    margin-top: 12px;
}

.related-tools a {
    display: block;
    padding: 13px 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border: 1px solid #d5ddeb;
    border-radius: 20px;
    text-align: center;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.25;
    color: #3b5a7a;
    box-shadow:
        0 2px 6px rgba(95, 120, 160, 0.045),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.related-tools a:hover {
    transform: translateY(-1px);
    border-color: #c2cfe4;
    box-shadow:
        0 5px 12px rgba(95, 120, 160, 0.07),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
    color: #284663;
}
/*--底部内链的样式--*/
.internal-links-note {
    margin-top: 18px;
    font-size: 1.08rem;
    line-height: 1.75;
    color: #24384f;
}

.internal-links-note a {
    font-weight: 600;
}
/*--how-to页面的样式--*/
.howto-page {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.howto-hero-card,
.howto-section-card,
.howto-faq-card {
    background: #f5f8fc;
    border: 1px solid #dbe5ef;
    border-radius: 24px;
    padding: 24px 22px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.howto-kicker {
    display: inline-block;
    margin-bottom: 10px;
    padding: 6px 12px;
    border-radius: 999px;
    background: #e7eef7;
    color: #47617d;
    font-size: 0.9rem;
    font-weight: 600;
}

.howto-hero-card h1 {
    margin: 0 0 14px;
    font-size: 2rem;
    line-height: 1.2;
    color: #20364f;
}

.howto-hero-card .lead {
    margin: 0 0 18px;
    font-size: 1.08rem;
    line-height: 1.75;
    color: #314960;
}

.howto-quick-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.howto-pill {
    display: inline-block;
    padding: 11px 16px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid #d9e3ee;
    color: #3b5876;
    text-decoration: none;
    font-weight: 600;
}

.howto-pill-primary {
    background: #eaf1f9;
}

.howto-section-card h2,
.howto-learning-paths h2,
.howto-faq-card h2 {
    margin-top: 0;
    margin-bottom: 14px;
    color: #233d59;
}

.howto-note {
    margin-top: 16px;
    padding: 14px 16px;
    background: #eef3f9;
    border-left: 4px solid #8da9c4;
    border-radius: 14px;
    color: #314960;
}

.howto-example-box {
    margin-top: 14px;
    padding: 16px 18px;
    background: #ffffff;
    border: 1px solid #dde6ef;
    border-radius: 18px;
}

.howto-learning-paths {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.howto-path-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.howto-path-card {
    background: #f5f8fc;
    border: 1px solid #dbe5ef;
    border-radius: 22px;
    padding: 22px 20px;
}

.howto-path-card h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #27425f;
}

.howto-card-link,
.howto-main-cta {
    display: inline-block;
    margin-top: 12px;
    padding: 12px 18px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid #d9e3ee;
    text-decoration: none;
    font-weight: 600;
    color: #365472;
}

.howto-button-row {
    margin-top: 16px;
}

.howto-mistakes-list,
.howto-related-list {
    margin: 0;
    padding-left: 20px;
}

.howto-faq-card h3 {
    margin-top: 18px;
    margin-bottom: 8px;
    color: #29435f;
}

@media (max-width: 768px) {
    .howto-path-grid {
        grid-template-columns: 1fr;
    }

    .howto-hero-card,
    .howto-section-card,
    .howto-faq-card,
    .howto-path-card {
        padding: 20px 16px;
    }

    .howto-hero-card h1 {
        font-size: 1.7rem;
    }
}
/*--乘法页面新增部分样式--*/
.learn-matrix-section {
    margin: 24px 0;
    padding: 18px;
    border-radius: 18px;
    background: #f4f8fc;
    border: 1px solid #dbe5ef;
}

.learn-matrix-section h2 {
    margin-bottom: 6px;
}

.learn-subtext {
    font-size: 0.95rem;
    color: #5a718c;
    margin-bottom: 16px;
}

.learn-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.learn-card {
    display: block;
    padding: 14px;
    border-radius: 14px;
    background: #ffffff;
    border: 1px solid #dbe5ef;
    text-decoration: none;
    transition: all 0.2s ease;
}

.learn-card:hover {
    border-color: #9fb7d1;
    transform: translateY(-2px);
}

.learn-card h3 {
    font-size: 1rem;
    margin-bottom: 6px;
    color: #2c4667;
}

.learn-card p {
    font-size: 0.9rem;
    color: #5a718c;
}

@media (max-width: 768px) {
    .learn-grid {
        grid-template-columns: 1fr;
    }
}
/*--how-to、2*2、3*3页面的右边栏样式--*/
.calculator-card {
    margin-top: 16px;
    text-align: center;
    padding: 16px;
    border-radius: 16px;
    background: #eaf2f9;
    border: 1px solid #dbe5ef;
}

/* 上面那条提示 */
.calculator-card .promo-text {
    font-size: 0.95rem;
    margin-bottom: 12px;
}

.calculator-card .promo-text span {
    color: #2f6fa3;
    font-weight: 600;
}

/* 按钮 */
.calculator-btn {
    display: inline-block;
    padding: 10px 16px;
    border-radius: 12px;
    background: #2f6fa3;
    color: #ffffff;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.calculator-btn:hover {
    background: #3d82bd;
}
/*--首页新换的seo结构--*/
.seo-block {
    margin-top: 28px;
    padding: 18px;
    border-radius: 14px;
    background: #f8fbff;
    border: 1px solid #e3ecf5;
}

.seo-block h2 {
    margin-bottom: 10px;
}

.seo-block p {
    margin-bottom: 10px;
    color: #4f647d;
}

.seo-block ul {
    padding-left: 18px;
}

.faq-block .faq-item {
    margin-bottom: 14px;
}
/*--首页截图的样式--*/
.seo-image {
    margin-top: 12px;
    text-align: center;
}

.seo-image img {
    max-width: 100%;
    border-radius: 10px;
    border: 1px solid #e3ecf5;
}