@import url(https://fonts.googleapis.com/css?family=Righteous);

/* =========================================
   1. 全局重置与基础样式
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background:
        radial-gradient(at 50% 0, transparent, #080808),
        repeating-conic-gradient(
            hsla(0, 0%, 0%, .235) 0% 25%,
            transparent 0% 50%
        ) 0 0 / 0.375em 0.375em,
        #3b3b3b;
    min-height: 100vh;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#background-wrapper {
    display: none;
}

.page-container {
    max-width: 90rem;
    margin: 0 auto;
    width: 100%;
    position: relative;
    z-index: 2;
    flex: 1;
    padding: 20px 1rem;
}

/* Navbar (aligned with CCFDDL) */
.navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    align-self: stretch;
    background-color: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px) saturate(1.2);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
}

.nav-content {
    max-width: 80rem;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.logo-icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    object-fit: cover;
}

.logo-text-desktop {
    font-weight: 900;
    color: hsl(0 0% 95%);
    letter-spacing: 0.05em;
    font-size: 1.125rem;
    font-family: 'Righteous', 'Microsoft YaHei', sans-serif;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    justify-content: flex-end;
}

.nav-btn {
    -webkit-tap-highlight-color: #0000;
    cursor: pointer;
    border-radius: 12px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    background: #0000;
    border: 1px solid #0000;
    position: relative;
    color: white;
    transition: translate 0.1s ease-out, scale 0.1s ease-out;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
    text-decoration: none;
}

.nav-btn::before,
.nav-btn::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    pointer-events: none;
}

.nav-btn::before {
    z-index: -1;
    background: linear-gradient(
        hsl(0 0% 100% / 0.18),
        hsl(0 0% 4% / 0.7)
    );
    backdrop-filter: saturate(2) contrast(1) blur(10px);
}

.nav-btn::after {
    box-shadow: 0 0 1px 0.8px hsl(0 0% 100% / 0.8) inset;
    mask: linear-gradient(-35deg, #ffffff80, #ffffff30 30% 60%, #fff);
}

.nav-btn:active:not(:disabled) {
    scale: 0.98;
    translate: 0 1px;
}

.nav-btn:hover:not(:disabled) {
    scale: 1.02;
}

/* =========================================
   2. 头部与导航样式
   ========================================= */
.nav-sub-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.nav-sub-actions .nav-btn {
    padding: 0.5rem 0.9rem;
}

.header {
    text-align: center;
    margin-bottom: 2rem;
}

.header h1 {
    display: inline-block;
    color: hsl(0 0% 90%);
    font-family: 'Righteous', 'Microsoft YaHei', serif;
    font-size: 3.5em;
    text-shadow: .03em .03em 0 hsla(230,40%,50%,1);
    position: relative;
    line-height: 1.2;
    margin-bottom: 1rem;
}

/* h1 特有的 data-shadow 动画效果 */
.header h1::after {
    content: attr(data-shadow);
    position: absolute;
    top: .06em;
    left: .06em;
    width: 100%;
    height: 100%;
    z-index: -1;
    text-shadow: none;
    background-image: linear-gradient(
        45deg,
        transparent 45%,
        hsla(48,20%,90%,1) 45%,
        hsla(48,20%,90%,1) 55%,
        transparent 0
    );
    background-size: .05em .05em;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    white-space: nowrap;
    animation: shad-anim 60s linear infinite;
}

@keyframes shad-anim {
    0% { background-position: 0 0; }
    100% { background-position: 100% -100%; }
}

.subtitle {
    font-size: 1rem;
    color: hsl(0 0% 75%);
    margin-top: 0.5rem;
}

/* =========================================
   3. 通用容器与视图控制
   ========================================= */
.container {
    background: transparent;
    border-radius: 16px;
    overflow: visible;
}

/* 视图切换动画 */
.view-section {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.view-section.active {
    display: block;
}

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

/* =========================================
   4. 基础计算器组件 (Index页)
   ========================================= */
.calc-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    align-items: start;
}

.calculator {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px) saturate(1.2);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    padding: 25px;
}

.display {
    background: rgba(0, 0, 0, 0.3);
    color: hsl(0 0% 95%);
    padding: 16px;
    border-radius: 12px;
    font-family: 'Courier New', monospace;
    font-size: 1.4rem;
    min-height: 90px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    margin-bottom: 15px;
    transition: border-color 0.3s;
    width: 100%;
    resize: vertical;
    line-height: 1.4;
}

.display:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.4);
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.buttons {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.function-section {
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.function-section summary {
    cursor: pointer;
    list-style: none;
}

.function-section summary::-webkit-details-marker {
    display: none;
}

.function-section summary::marker {
    content: '';
}

.section-heading {
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    gap: 12px;
    color: hsl(0 0% 85%);
    margin-bottom: 10px;
    font-weight: 600;
}

.section-heading small {
    font-size: 0.8rem;
    color: hsl(0 0% 65%);
    margin-left: auto;
}

.section-heading::after {
    content: '>';
    font-size: 0.9rem;
    opacity: 0.7;
}

.function-section[open] .section-heading::after {
    content: '>';
}

.function-section:not([open]) .section-heading {
    margin-bottom: 0;
}

.trig-title {
    color: hsl(0 0% 95%);
    font-weight: 600;
}

.function-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 10px;
    padding-top: 8px;
}

.function-grid.const-grid {
    margin-top: 6px;
}

/* 侧边面板与历史记录 */
.side-panel {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px) saturate(1.2);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    padding: 20px;
}

.field {
    margin-bottom: 20px;
    padding: 16px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.25);
}

.field:last-child {
    margin-bottom: 0;
}

.field label {
    display: block;
    font-weight: 600;
    margin-bottom: 12px;
    color: hsl(0 0% 90%);
    font-size: 1rem;
}

.settings-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.settings-row {
    display: flex;
    gap: 12px;
    flex-wrap: nowrap;
}

.setting-item {
    flex: 1 1 50%;
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-item label {
    font-weight: 600;
    color: hsl(0 0% 85%);
    font-size: 0.85rem;
    margin: 0;
    white-space: nowrap;
}

.setting-item .input-field {
    flex: 1;
}

.setting-item.setting-spacer {
    visibility: hidden;
}

.history {
    max-height: 180px;
    height: 180px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: hsl(0 0% 85%);
    line-height: 1.6;
}

.history-item {
    padding: 6px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: background 0.2s ease;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.history-expression {
    font-weight: 600;
    color: hsl(0 0% 95%);
    word-break: break-all;
}

.history-result {
    color: hsl(210 20% 80%);
    font-size: 0.9rem;
    word-break: break-all;
}

/* =========================================
   5. 高级功能组件 (More 页)
   ========================================= */

/* 特性选择网格 (Feature Grid) */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

.feature-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px) saturate(1.2);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    padding: 30px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    cursor: pointer;
    display: block;
    text-align: left;
}

.feature-card:hover:not(.disabled) {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.feature-card h3 {
    color: hsl(0 0% 95%);
    font-size: 1.3rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.feature-card p {
    color: hsl(0 0% 80%);
    font-size: 1rem;
    line-height: 1.6;
    margin: 0;
}

.feature-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 矩阵与算法通用面板 */
.matrix-panel, .simplex-panel {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px) saturate(1.2);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    padding: 25px;
    margin-bottom: 20px;
}

.matrix-panel p, .simplex-panel > p {
    color: hsl(0 0% 85%);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 20px;
}

.matrix-panel label, .input-group label {
    display: block;
    color: hsl(0 0% 90%);
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 1rem;
}

/* 矩阵输入框 */
.matrix-input, .input-group textarea {
    width: 100%;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
    color: hsl(0 0% 95%);
    transition: all 0.3s;
    resize: vertical;
}

.matrix-input { min-height: 140px; }
.input-group textarea { min-height: 80px; padding: 12px; }

.matrix-input:focus, .input-group textarea:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.4);
}

.button-group {
    display: flex;
    gap: 12px;
    margin: 20px 0;
    flex-wrap: wrap;
}

/* 结果展示区 */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 25px;
}

.result-section h3 {
    color: hsl(0 0% 95%);
    font-size: 1.2rem;
    margin-bottom: 12px;
    font-weight: 600;
}

.result-output {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: auto;
    color: hsl(0 0% 90%);
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    min-height: 60px;
    margin-bottom: 20px;
}

.small-label {
    color: hsl(0 0% 80%);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

/* 单纯形法特定样式 */
.input-group { margin-bottom: 18px; }
.small-text { color: hsl(0 0% 75%); font-size: 0.85rem; margin-top: 6px; }

.radio-group { display: flex; gap: 20px; margin-top: 10px; }
.radio-group label { display: flex; align-items: center; gap: 8px; cursor: pointer; color: hsl(0 0% 85%); }
.radio-group input[type="radio"] { width: 18px; height: 18px; accent-color: hsl(0 0% 80%); }

.step-section {
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    border-left: 4px solid rgba(102, 126, 234, 0.7);
    color: hsl(0 0% 90%);
}

.step-title { font-size: 1.2rem; font-weight: 700; color: hsl(0 0% 95%); margin-bottom: 15px; }

.tableau {
    overflow-x: auto; margin: 15px 0;
    background: rgba(0, 0, 0, 0.3);
    padding: 15px; border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.tableau table { border-collapse: collapse; margin: 0 auto; font-size: 0.9rem; color: hsl(0 0% 90%); }
.tableau th, .tableau td {
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center; min-width: 60px;
}
.tableau th { background: rgba(255, 255, 255, 0.1); font-weight: 600; color: hsl(0 0% 95%); }

.pivot-cell { background: rgba(255, 193, 7, 0.3); font-weight: 700; color: hsl(45 100% 80%); }
.pivot-row, .pivot-col { background: rgba(255, 193, 7, 0.1); }

.result-box {
    background: rgba(102, 126, 234, 0.15);
    padding: 18px; border-radius: 12px;
    border: 2px solid rgba(102, 126, 234, 0.5);
    margin-top: 15px; color: hsl(0 0% 90%);
}

/* =========================================
   6. 通用 UI 组件 (按钮、输入框、转换器)
   ========================================= */

/* 按钮通用 */
.btn {
    -webkit-tap-highlight-color: #0000;
    cursor: pointer;
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 1rem;
    background: #0000;
    border: 1px solid #0000;
    position: relative;
    color: white;
    transition-property: translate, scale;
    transition-duration: 0.1s;
    transition-timing-function: ease-out;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn:active:not(:disabled) {
    scale: 0.98;
    translate: 0 1px;
}

.btn::before,
.btn::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    pointer-events: none;
}

.btn::before {
    z-index: -1;
    background: linear-gradient(
        hsl(0 0% 100% / 0.18),
        hsl(0 0% 4% / 0.7)
    );
    backdrop-filter: saturate(2) contrast(1) blur(10px);
}

.btn::after {
    box-shadow: 0 0 1px 0.8px hsl(0 0% 100% / 0.8) inset;
    mask: linear-gradient(-35deg, #ffffff80, #ffffff30 30% 60%, #fff);
}

.btn:hover:not(:disabled) {
    scale: 1.02;
}

/* 计算器专用按钮 */
.btn-calc {
    padding: 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: hsl(0 0% 90%);
    font-weight: 700;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
}

.btn-calc:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.btn-calc:active {
    transform: translateY(0);
}

.btn-calc.btn-op {
    background: rgba(102, 126, 234, 0.3);
    color: hsl(0 0% 95%);
    border-color: rgba(102, 126, 234, 0.5);
}

.btn-calc.btn-op:hover {
    background: rgba(102, 126, 234, 0.5);
    border-color: rgba(102, 126, 234, 0.7);
}

/* 输入框通用 */
.input-field {
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: hsl(0 0% 95%);
    font-size: 0.95rem;
    transition: all 0.3s;
}

.input-field:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.08);
}

.input-field.small {
    width: 80px;
    padding: 8px;
}

.input-field::placeholder {
    color: hsl(0 0% 60%);
}

select.input-field option {
    background: #2a2a2a;
    color: white;
}

body:not(.day-mode) input[type="date"].input-field,
body:not(.day-mode) input[type="datetime-local"].input-field {
    color-scheme: dark;
}

body:not(.day-mode) input[type="date"].input-field::-webkit-calendar-picker-indicator,
body:not(.day-mode) input[type="datetime-local"].input-field::-webkit-calendar-picker-indicator {
    filter: invert(1) brightness(1.15);
    opacity: 0.9;
    cursor: pointer;
}

body:not(.day-mode) input[type="date"].input-field::-webkit-calendar-picker-indicator:hover,
body:not(.day-mode) input[type="datetime-local"].input-field::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* 转换器组件 */
.converter-grid {
    margin-top: 30px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

@media (max-width: 1200px) {
    .converter-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

.converter-panel {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 20px;
    backdrop-filter: blur(18px);
}

.converter-panel h2 {
    font-size: 1.2rem;
    color: hsl(0 0% 92%);
    margin-bottom: 6px;
}

.panel-desc {
    color: hsl(0 0% 70%);
    font-size: 0.9rem;
    margin-bottom: 14px;
}

.date-tool {
    margin-top: 16px;
    padding: 14px;
    border-radius: 12px;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.2);
}

.date-tool-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.date-tool-grid .date-tool {
    margin-top: 0;
}

.date-tool:first-of-type {
    margin-top: 0;
}

.date-tool-header {
    color: hsl(0 0% 90%);
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 12px;
}

.calendar-fields {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.unit-row.three-cols .input-field {
    flex: 1 1 120px;
    min-width: 110px;
}

.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    color: hsl(0 0% 78%);
    font-size: 0.9rem;
}

.inline-check input {
    accent-color: hsl(122 40% 70%);
}

.converter-panel .input-field {
    width: 100%;
}

.converter-actions {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.unit-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.converter-panel .unit-row {
    gap: 18px;
    margin-bottom: 18px;
}

.converter-panel .unit-row:last-child {
    margin-bottom: 0;
}

.unit-row .input-field {
    flex: 1 1 120px;
}

.converter-panel .unit-row .input-field {
    flex: 1 1 50%;
    min-width: 180px;
}

.converter-panel .unit-row .base-select {
    flex: 1 1 45%;
    min-width: 150px;
}

.unit-row.two-cols,
.converter-panel .unit-row.two-cols {
    flex-wrap: nowrap;
    gap: 20px;
}

.unit-row.two-cols .input-field,
.unit-row.two-cols select,
.converter-panel .unit-row.two-cols .input-field,
.converter-panel .unit-row.two-cols select {
    min-width: 0;
    flex: 1 1 0;
}

.unit-row.two-cols .unit-arrow {
    flex: 0 0 auto;
    margin: 0 6px;
}

.unit-row.single-input,
.converter-panel .unit-row.single-input {
    flex-wrap: nowrap;
    margin-bottom: 20px;
}

.unit-row.single-input .input-field {
    flex: 1 1 100%;
}

.unit-row.select-pair,
.converter-panel .unit-row.select-pair {
    flex-wrap: nowrap;
    gap: 12px;
}

.unit-row.select-pair .input-field,
.converter-panel .unit-row.select-pair .input-field {
    flex: 1 1 45%;
}

.unit-row.select-pair .unit-arrow,
.converter-panel .unit-row.select-pair .unit-arrow {
    flex: 0 0 auto;
}

.unit-arrow {
    color: hsl(0 0% 70%);
    font-weight: 700;
}

/* 高级控制容器 */
.advanced-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* 文本样式 */
.result-text {
    margin-top: 10px;
    color: hsl(122 40% 70%);
    font-weight: 600;
    font-size: 0.95rem;
    min-height: 20px;
}

.info-text {
    color: hsl(0 0% 80%);
    font-size: 0.95rem;
    line-height: 1.6;
}

.info-text code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: hsl(122 40% 70%);
}

.color-output-row {
    display: flex;
    align-items: center; /* 垂直居中 */
    gap: 12px;           /* 预览块和文字的间距 */
    margin-top: 15px;    /* 整体与按钮的间距 */
    min-height: 32px;    /* 最小高度，防止未显示时塌陷严重 */
}

/* 修改：.color-preview 变小，去掉原来的 margin-top */
.color-preview {
    width: 32px;         /* 宽度改小 */
    height: 32px;        /* 高度改小 */
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    /* margin-top: 15px;  <-- 删除或覆盖这行 */
    margin-top: 0;       /* 设为 0，由容器控制间距 */
    flex-shrink: 0;      /* 防止被压缩 */
}

.color-output-row .result-text {
    margin-top: 0;
    padding-top: 2px;    /* 微调文字垂直位置 */
}

/* =========================================
   7. 响应式设计
   ========================================= */
@media screen and (max-width: 1024px) {
    .calc-grid {
        grid-template-columns: 1fr;
    }

    .header h1 {
        font-size: 3em;
    }
}

@media screen and (max-width: 768px) {
    .page-container {
        padding: 10px 1rem;
    }

    .header h1 {
        font-size: 2.5em;
    }

    .calculator,
    .side-panel {
        padding: 20px;
    }

    .buttons {
        gap: 8px;
    }

    .btn-calc {
        padding: 12px;
        font-size: 0.9rem;
    }

    .advanced-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .input-field.small {
        width: 100%;
    }

    .function-grid {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    }

    /* 合并自 more.html 的响应式 */
    .features-grid { grid-template-columns: 1fr; }
    .results-grid { grid-template-columns: 1fr; }
    .date-tool-grid { grid-template-columns: 1fr; }
    .button-group { flex-direction: column; }
    .tableau th, .tableau td { padding: 6px 8px; min-width: 50px; }
}

@media screen and (max-width: 480px) {
    .header h1 {
        font-size: 2em;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .calculator,
    .side-panel {
        padding: 15px;
    }

    .display {
        font-size: 1.3rem;
        padding: 12px;
    }

    .buttons {
        grid-template-columns: repeat(4, 1fr);
    }

    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }

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

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* =========================================
   8. 日间模式样式
   ========================================= */
body.day-mode {
    background: #f0f4f8;
    background-image: url(../../../../assets/image/day-background.png);
    background-size: auto;
    background-repeat: repeat;
    font-family: 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body.day-mode #background-wrapper {
    background-color: transparent;
}

/* 通用日间面板 */
body.day-mode .calculator,
body.day-mode .side-panel,
body.day-mode .feature-card, 
body.day-mode .matrix-panel, 
body.day-mode .simplex-panel {
    background: rgba(255, 255, 255, 0.4);
    border: none;
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 5px 3px 30px rgba(0, 0, 0, 0.1);
    color: #2d3748;
}

/* 日间 H1 标题 (保留投影效果) */
body.day-mode .header h1 {
    color: #2d3748;
    text-shadow: .03em .03em 0 hsla(200, 60%, 60%, 1);
}

/* 日间其他标题 (移除投影，保留颜色) */
body.day-mode .feature-card h3,
body.day-mode .result-section h3,
body.day-mode .matrix-panel label,
body.day-mode .simplex-panel label,
body.day-mode .step-title {
    color: #2d3748;
    text-shadow: none;
}

body.day-mode .subtitle,
body.day-mode .section-heading small,
body.day-mode .panel-desc,
body.day-mode .feature-card p,
body.day-mode .matrix-panel p,
body.day-mode .simplex-panel p,
body.day-mode .small-label,
body.day-mode .radio-group label,
body.day-mode .step-section p {
    color: #4a5568;
}

body.day-mode .small-text {
    color: #4a5568;
}

/* 日间输入框与显示区 */
body.day-mode .display,
body.day-mode .input-field,
body.day-mode select,
body.day-mode .matrix-input,
body.day-mode .result-output,
body.day-mode .input-group textarea {
    background: rgba(255, 255, 255, 0.7);
    color: #1a202c;
    border-color: rgba(0, 0, 0, 0.15);
}

body.day-mode .display:focus,
body.day-mode .input-field:focus,
body.day-mode select:focus,
body.day-mode .matrix-input:focus,
body.day-mode .input-group textarea:focus {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.25);
}

body.day-mode input[type="date"].input-field,
body.day-mode input[type="datetime-local"].input-field {
    color-scheme: light;
}

/* 日间按钮 */
body.day-mode .btn-calc {
    background: rgba(255, 255, 255, 0.7);
    color: #1a202c;
    border-color: rgba(0, 0, 0, 0.15);
}

body.day-mode .btn-calc:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.25);
}

body.day-mode .btn-calc.btn-op {
    background: rgba(59, 130, 246, 0.2);
    color: #1e40af;
    border-color: rgba(59, 130, 246, 0.4);
}

body.day-mode .btn-calc.btn-op:hover {
    background: rgba(59, 130, 246, 0.3);
    border-color: rgba(59, 130, 246, 0.6);
}

body.day-mode .btn {
    background: #ffffff;
    color: #1a202c;
    border: 2px solid #cbd5e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

body.day-mode .btn::before {
    background: none;
    backdrop-filter: none;
}

body.day-mode .btn-primary,
body.day-mode .btn-success,
body.day-mode .btn-secondary {
    background: #ffffff;
    color: #1a202c;
}

body.day-mode .btn:hover:not(:disabled),
body.day-mode .btn-primary:hover:not(:disabled),
body.day-mode .btn-success:hover:not(:disabled),
body.day-mode .btn-secondary:hover:not(:disabled) {
    background: #f7fafc;
    border-color: #a0aec0;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* 日间其他组件 */
body.day-mode .advanced-controls {
    background: rgba(255, 255, 255, 0.5);
    border-color: rgba(0, 0, 0, 0.1);
}

body.day-mode .field {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.08);
}

body.day-mode .field label {
    color: #1a202c;
}

body.day-mode .setting-item label {
    color: #1a202c;
}

body.day-mode .section-heading,
body.day-mode .trig-title {
    color: #1a202c;
}

body.day-mode .function-section {
    border-top: 1px solid rgba(26, 32, 44, 0.35);
}

body.day-mode .converter-panel {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.08);
}

body.day-mode .converter-panel h2 {
    color: #1a202c;
}

body.day-mode .date-tool {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 0, 0, 0.08);
}

body.day-mode .date-tool-header,
body.day-mode .inline-check {
    color: #2d3748;
}

body.day-mode .result-text {
    color: #15803d;
}

body.day-mode .info-text {
    color: #2d3748;
}

body.day-mode .info-text code {
    background: rgba(0, 0, 0, 0.1);
    color: #1e40af;
}

body.day-mode .history {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(0, 0, 0, 0.1);
}

body.day-mode .history-item {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(0, 0, 0, 0.1);
    color: #2d3748;
}

body.day-mode .history-item:hover {
    background: rgba(255, 255, 255, 0.9);
}

body.day-mode .history-expression {
    color: #1a202c;
}

body.day-mode .history-result {
    color: #2d3748;
}

/* 日间模式：单纯形法表格 */
body.day-mode .tableau { background: rgba(255, 255, 255, 0.8); }
body.day-mode .tableau table { color: #1a202c; }
body.day-mode .tableau th { background: rgba(59, 130, 246, 0.25); color: #1e40af; }
body.day-mode .pivot-cell { background: rgba(251, 191, 36, 0.5); color: #92400e; }
body.day-mode .step-section {
    background: rgba(255, 255, 255, 0.85); /* 提高不透明度，使卡片更明显 */
    border: 1px solid rgba(0, 0, 0, 0.08); /* 增加微弱边框界定范围 */
    border-left: 4px solid rgba(59, 130, 246, 0.8); /* 保持左侧强调色，但调整为适合日间的蓝色 */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); /* 添加轻微阴影增加层次感 */
    color: #2d3748;
    margin-bottom: 20px;
}

body.day-mode .tableau {
    background: rgba(0, 0, 50, 0.05); /* 使用微带蓝色的浅灰背景，与白色面板形成对比 */
    border: 1px solid rgba(0, 0, 0, 0.15); /* 加深边框颜色 */
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.03); /* 添加轻微内阴影，增加层次感 */
    margin: 15px 0;
}

/* 确保表头在深色背景上依然清晰 */
body.day-mode .tableau th {
    background: rgba(59, 130, 246, 0.2);
    color: #1e3a8a;
    border-color: rgba(0, 0, 0, 0.15);
}

/* 确保单元格边框清晰 */
body.day-mode .tableau td {
    border-color: rgba(0, 0, 0, 0.1);
}

body.day-mode .result-box { background: rgba(59, 130, 246, 0.2); color: #1e40af; }

body.day-mode ::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

body.day-mode ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
}

body.day-mode ::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* =========================================
   9. 主题切换器 (Theme Toggle)
   ========================================= */
.theme-toggle {
  --theme-toggle-scale: 0.52;
  position: fixed;
  top: clamp(12px, 2vw, 20px);
  right: clamp(12px, 2vw, 20px);
  z-index: 1000;
  user-select: none;
  transform: scale(var(--theme-toggle-scale));
  transform-origin: top right;
}

.theme-toggle__checkbox {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.theme-toggle__btn {
  display: block;
  position: relative;
  width: 125px;
  height: 70px;
  border-radius: 70px;
  border: 5px solid #1c1c1c;
  background-color: #3c4145;
  cursor: pointer;
  transition: all 350ms ease-in;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle__checkbox:focus-visible + .theme-toggle__btn {
  outline: 3px solid rgba(255, 255, 255, 0.8);
  outline-offset: 4px;
}

body.day-mode .theme-toggle__checkbox:focus-visible + .theme-toggle__btn {
  outline-color: rgba(0, 0, 0, 0.55);
}

/* 禁用初始加载时的动画 */
.theme-toggle__btn.no-transition,
.theme-toggle__btn.no-transition::before,
.theme-toggle__btn.no-transition::after,
.theme-toggle__btn.no-transition .theme-toggle__feature,
.theme-toggle__btn.no-transition .theme-toggle__feature::before {
  transition: none !important;
  animation: none !important;
}

.theme-toggle__btn::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background-color: #fff;
  border: 5px solid #e3e3c7;
  transition: all 250ms ease-in;
}

.theme-toggle__btn::after {
  content: '';
  position: absolute;
  top: 62%;
  left: 39px;
  z-index: 10;
  width: 9.2px;
  height: 9.2px;
  opacity: 0;
  background-color: #fff;
  border-radius: 50%;
  box-shadow:
    #fff 0 0,
    #fff 2.5px 0,
    #fff 5px 0,
    #fff 7.5px 0,
    #fff 9px 0,
    #fff 11.5px 0,
    #fff 13px 0,
    #fff 17px -1px 0 1px,
    #fff 13px -6px 0 -2px,
    #fff 6px -6px 0 1px,
    #d3d3d3 0 0 0 3.5px,
    #d3d3d3 5px 0 0 3.5px,
    #d3d3d3 9px 0 0 3.5px,
    #d3d3d3 13px 0 0 3.5px,
    #d3d3d3 17px -1px 0 4.5px,
    #d3d3d3 13px -6px 0 1px,
    #d3d3d3 6px -6px 0 4.5px;
  transition: opacity 100ms ease-in;
}

.theme-toggle__feature {
  display: block;
  position: absolute;
  top: 9px;
  left: 52.5%;
  z-index: 20;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: #fff;
  box-shadow:
    rgba(255,255,255,0.1) 30px -3px 0 0,
    rgba(255,255,255,0.1) 12px 10px 0 -1px,
    #fff 38px 18px 0 1px,
    rgba(255,255,255,0.1) 32px 34px 0 0,
    #fff 20px 24px 0 -1.5px,
    rgba(255,255,255,0.1) 5px 38px 0 1px;
  animation: starry_star 5s ease-in-out infinite;
}

.theme-toggle__feature::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -25px;
  width: 15px;
  height: 15px;
  background-color: #fff;
  border-radius: 50%;
  border: 4px solid #e3e3c7;
  box-shadow:
    #e3e3c7 -28px 0 0 -3px,
    #e3e3c7 -8px 24px 0 -2px;
  transform-origin: -6px 130%;
  transition: all 250ms ease-in;
}

body.day-mode .theme-toggle__btn {
  background-color: #9ee3fb;
  border: 5px solid #86c3d7;
}

body.day-mode .theme-toggle__btn::before {
  left: 57px;
  background-color: #ffdf6d;
  border: 5px solid #e1c348;
}

body.day-mode .theme-toggle__btn::after {
  opacity: 1;
  animation: none;
}

body.day-mode .theme-toggle__btn .theme-toggle__feature {
  opacity: 0;
  box-shadow:
    rgba(255,255,255,0.1) 30px -3px 0 -4px,
    rgba(255,255,255,0.1) 12px 10px 0 -5px,
    #fff 38px 18px 0 -3px,
    rgba(255,255,255,0.1) 32px 34px 0 -4px,
    #fff 20px 24px 0 -5.5px,
    rgba(255,255,255,0.1) 5px 38px 0 -3px;
  animation: none;
}

body.day-mode .theme-toggle__btn .theme-toggle__feature::before {
  left: 25px;
  transform: rotate(70deg);
}

@keyframes starry_star {
  50% {
    background-color: rgba(255,255,255,0.1);
    box-shadow:
      #fff 30px -3px 0 0,
      #fff 12px 10px 0 -1px,
      rgba(255,255,255,0.1) 38px 18px 0 1px,
      #fff 32px 34px 0 0,
      rgba(255,255,255,0.1) 20px 24px 0 -1.5px,
      #fff 5px 38px 0 1px;
  }
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.1);
  }
  55% {
    transform: scale(1.1);
  }
  75% {
    transform: scale(.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.theme-toggle__checkbox:checked + .theme-toggle__btn {
  background-color: #9ee3fb;
  border: 5px solid #86c3d7;
}

.theme-toggle__checkbox:checked + .theme-toggle__btn::before {
  left: 57px;
  background-color: #ffdf6d;
  border: 5px solid #e1c348;
}

.theme-toggle__checkbox:checked + .theme-toggle__btn::after {
  opacity: 1;
  animation-name: bounceIn;
  animation-duration: 0.60s;
  animation-delay: 0.10s;
  animation-fill-mode: backwards;
  animation-timing-function: ease-in-out;
}

.theme-toggle__checkbox:checked + .theme-toggle__btn .theme-toggle__feature {
  opacity: 0;
  box-shadow:
    rgba(255,255,255,0.1) 30px -3px 0 -4px,
    rgba(255,255,255,0.1) 12px 10px 0 -5px,
    #fff 38px 18px 0 -3px,
    rgba(255,255,255,0.1) 32px 34px 0 -4px,
    #fff 20px 24px 0 -5.5px,
    rgba(255,255,255,0.1) 5px 38px 0 -3px;
  animation: none;
}

.theme-toggle__checkbox:checked + .theme-toggle__btn .theme-toggle__feature::before {
  left: 25px;
  transform: rotate(70deg);
}

@media (min-width: 769px) and (max-width: 1024px) {
  .theme-toggle {
    --theme-toggle-scale: 0.47;
  }
}

@media (max-width: 768px) {
  .theme-toggle {
    --theme-toggle-scale: 0.42;
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 10px);
    right: 10px;
    z-index: 2;
  }
}

/* =========================================
   10. 页脚样式
   ========================================= */
.footer {
    position: relative;
    z-index: 1;
    width: 100%;
    padding: 2rem 1rem;
    text-align: center;
    margin-top: 3rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer p {
    margin: 0;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.4);
    transition: color 300ms ease-out;
    line-height: 1.8;
}

body.day-mode .footer p {
    color: rgba(0, 0, 0, 0.5);
}

body.day-mode .footer {
    border-top-color: rgba(0,0,0,0.1);
}

body.day-mode .navbar {
    background-color: rgba(255, 255, 255, 0.7);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

body.day-mode .logo-text-desktop {
    color: #1a202c;
    font-weight: bold;
    text-shadow: none;
}

body.day-mode .nav-btn {
    background: #ffffff;
    color: #1a202c;
    border: 2px solid #cbd5e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

body.day-mode .nav-btn::before {
    background: none;
    backdrop-filter: none;
}

body.day-mode .nav-btn::after {
    display: none;
}

body.day-mode .nav-btn:hover:not(:disabled) {
    background: #f7fafc;
    border-color: #a0aec0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.navbar .theme-toggle-container {
    width: 60px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.navbar .theme-toggle {
    position: relative;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    z-index: 1000;
    user-select: none;
    transform: scale(0.45);
    transform-origin: center;
}

@media (max-width: 639px) {
    .nav-content {
        flex-direction: column;
        gap: 0.75rem;
        align-items: center;
        padding: 0.75rem 1rem;
    }

    .logo-wrapper {
        justify-content: center;
        width: 100%;
    }

    .nav-actions {
        justify-content: center;
        width: 100%;
        gap: 0.75rem;
        flex-wrap: wrap;
    }
}

@media (min-width: 640px) {
    .nav-content {
        flex-direction: row;
        padding: 0.75rem 1.5rem;
    }
}

@media (max-width: 768px) {
    .footer {
        padding: 1.5rem 1rem;
    }

    .footer p {
        font-size: 0.75rem;
    }
}
