:root {
    --bg: #f5f7fb;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --blue: #1d4ed8;
    --blue-light: #dbeafe;
    --blue-dark: #0f3ea8;
    --operator: #60a5fa;
    --operator-text: #0f172a;
    --accent: #0f172a;
    --success: #10b981;
    --danger: #ef4444;
    --memory: #0ea5e9;
    --font-display: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft Yahei', sans-serif;
}

body {
    background: var(--bg);
    font-family: var(--font-display);
    color: var(--text-primary);
}

body.modal-open {
    overflow: hidden;
}

.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0rem 1.5rem 4rem;
}

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

.hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.hero p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 720px;
    margin: 0 auto;
}

.calculator-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 2.5rem;
}

.scientific-calculator {
    width: 100%;
    background: #f1f5f9;
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 25px 65px rgba(15, 23, 42, 0.12);
    border: 1px solid #e2e8f0;
}

.history-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding: 0 0.5rem;
}

.latest-history {
    font-size: 0.9rem;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-more {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 0.8rem;
    cursor: pointer;
    visibility: hidden;
}

.history-more:hover {
    color: var(--blue);
}

.calc-display {
    background: white;
    border-radius: 16px;
    padding: 1rem 1.5rem;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 0.5rem;
    border: 1px solid #e2e8f0;
}

.calc-input {
    width: 100%;
    border: none;
    font-size: 1.4rem;
    color: var(--text-primary);
    background: transparent;
    outline: none;
    padding: 0.25rem 0;
}

.calc-status {
    padding: 0 0.5rem;
    min-height: 2rem;
    display: flex;
    align-items: center;
}

.result-label {
    font-size: 1.5rem;
    color: var(--blue);
    font-weight: 700;
    cursor: pointer;
    position: relative;
    padding: 2px 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.result-label:hover {
    background: #f1f5f9;
}

.copy-tooltip {
    position: absolute;
    bottom: 105%;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    color: #94a3b8;
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 400;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 4px;
    animation: tooltipFadeInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes tooltipFadeInUp {
    from { opacity: 0; transform: translate(-50%, 6px) scale(0.98); }
    to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.copy-icon {
    color: #10b981;
    opacity: 0.7;
    display: flex;
    align-items: center;
}

/* 按钮布局核心 */
.calc-main-grid {
    margin-top: 1.25rem;
    display: grid;
    grid-template-columns: 1fr 1fr; /* 桌面端：左右两块 */
    gap: 0.6rem;
}

.calc-group {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* 内部始终是 5 列 */
    gap: 0.6rem;
}

.calc-btn {
    height: 58px;
    border-radius: 12px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    background: #e2e8f0;
    box-shadow: 0 4px 0 #cbd5e1;
    margin-bottom: 4px;
}

.calc-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 0 #cbd5e1;
}

.calc-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #cbd5e1;
}

.btn-num {
    background: #ffffff;
    box-shadow: 0 4px 0 #d1d5db;
    border: 1px solid #e5e7eb;
}
.btn-num:hover { box-shadow: 0 5px 0 #d1d5db; }
.btn-num:active { box-shadow: 0 1px 0 #d1d5db; }

.btn-func { background: #e0f2fe; color: #0369a1; box-shadow: 0 4px 0 #bae6fd; }
.btn-func:hover { box-shadow: 0 5px 0 #bae6fd; }
.btn-func:active { box-shadow: 0 1px 0 #bae6fd; }

.btn-operator { background: #c7d2fe; color: #3730a3; box-shadow: 0 4px 0 #a5b4fc; }
.btn-operator:hover { box-shadow: 0 5px 0 #a5b4fc; }
.btn-operator:active { box-shadow: 0 1px 0 #a5b4fc; }

.btn-accent { background: #3b82f6; color: white; box-shadow: 0 4px 0 #2563eb; }
.btn-accent:hover { box-shadow: 0 5px 0 #2563eb; }
.btn-accent:active { box-shadow: 0 1px 0 #2563eb; }

.btn-equals { background: linear-gradient(135deg, #10b981, #059669); color: white; box-shadow: 0 4px 0 #047857; }
.btn-equals:hover { box-shadow: 0 5px 0 #047857; }
.btn-equals:active { box-shadow: 0 1px 0 #047857; }

.btn-danger { background: #fee2e2; color: #b91c1c; box-shadow: 0 4px 0 #fecaca; }
.btn-danger:hover { box-shadow: 0 5px 0 #fecaca; }
.btn-danger:active { box-shadow: 0 1px 0 #fecaca; }

.btn-mode { background: #f1f5f9; color: var(--text-secondary); font-size: 0.8rem; box-shadow: 0 4px 0 #e2e8f0; }
.btn-mode:hover { box-shadow: 0 5px 0 #e2e8f0; }
.btn-mode:active { box-shadow: 0 1px 0 #e2e8f0; }

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: none; /* JS will change to flex */
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px rgba(0,0,0,0.2);
    animation: modalSlideUp 0.3s ease-out;
}

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

.modal-header {
    padding: 1.5rem;
    font-size: 1.2rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-history-list { padding: 1rem; overflow-y: auto; }
.history-item { padding: 1rem; border-radius: 12px; background: #f8fafc; margin-bottom: 0.5rem; cursor: pointer; }
.history-item:hover { background: #f1f5f9; }
.history-expr { font-size: 0.85rem; color: var(--text-secondary); }
.history-res { font-size: 1.1rem; font-weight: 700; color: var(--blue); }
.modal-footer { padding: 1rem; text-align: right; border-top: 1px solid var(--border); }
.btn-clear-all { background: #fee2e2; color: #b91c1c; border: none; padding: 0.6rem 1.2rem; border-radius: 12px; font-weight: 600; cursor: pointer; }

.features-card, .shortcuts-card {
    background: white;
    border-radius: 24px;
    padding: 2rem;
    margin-top: 2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}

.shortcuts-card h2, .features-card h2 { text-align: center; margin-bottom: 1.5rem; font-size: 1.8rem; color: var(--text-primary); }
.shortcuts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.25rem; }
.shortcut-item { display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1rem; background: #f8fafc; border-radius: 12px; border: 1px solid #e2e8f0; }
kbd { display: inline-block; padding: 3px 6px; font-family: monospace; font-size: 0.85rem; background: #f1f5f9; border: 1px solid #cbd5e1; border-bottom-width: 2px; border-radius: 6px; }

.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; margin-top: 1rem; }
.feature-item { padding: 1.5rem; border-radius: 16px; background: #f8fafc; display: flex; flex-direction: column; align-items: center; text-align: center; border: 1px solid #e2e8f0; transition: all 0.2s; }
.feature-item:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.05); border-color: var(--blue-light); }
.feature-icon { width: 48px; height: 48px; background: var(--blue-light); color: var(--blue); border-radius: 12px; display: flex; align-items: center; justify-content: center; margin-bottom: 1rem; }

@media (max-width: 768px) {
    .page { padding: 0 0.75rem 3rem; }
    .hero { margin-bottom: 1.5rem; }
    .hero h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
    .hero p { font-size: 0.8rem; padding: 0 0.5rem; }
    
    .scientific-calculator { padding: 0.75rem; border-radius: 16px; }
    .calc-display { padding: 0.75rem 1rem; border-radius: 12px; }
    .calc-input { font-size: 1.2rem; }
    .result-label { font-size: 1.3rem; }

    .calc-main-grid {
        grid-template-columns: 1fr; /* 移动端改为上下排列 */
        gap: 0.5rem;
    }
    .calc-btn { height: 50px; font-size: 0.9rem; border-radius: 10px; }
    .shortcuts-grid { grid-template-columns: 1fr; }
    
    .features-card, .shortcuts-card { padding: 1.5rem 1rem; }
    .features-card h2, .shortcuts-card h2 { font-size: 1.4rem; }
}

@media (max-width: 480px) {
    .page { padding: 0 0.5rem 2rem; }
    .calc-group { gap: 0.35rem; }
    .calc-btn { height: 46px; }
}

.aw-footer-wrap { margin-top: 4rem; }
.aw-footer { padding: 30px 0; font-size: 12px; text-align: center; color: #666; border-top: 1px solid #ddd; }
.footer-text-copyright a { color: #666; text-decoration: none; }
.footer-text-copyright a:hover { color: var(--blue); }
