/* === 品牌色板 === */
:root {
    --primary: #6366f1;       /* 主色：靛蓝紫 */
    --primary-dark: #4f46e5;
    --primary-light: #a5b4fc;
    --secondary: #f0f4ff;     /* 辅色1：浅蓝背景 */
    --secondary-2: #eef2ff;   /* 辅色2：极浅紫 */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --bg: #ffffff;
    --bg-card: #ffffff;
    --danger: #ef4444;
    --success: #10b981;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --radius: 16px;
    --radius-sm: 10px;
    --nav-height: 64px;
    --bottom-nav-height: 64px;
    --max-width: 450px;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* === 全局重置 === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: var(--font-family);
    background: #f1f5f9;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 0;
    background: #e2e8f0;
}

/* === APP容器（模拟手机屏幕） === */
.app-container {
    width: 100%;
    max-width: var(--max-width);
    min-height: 100vh;
    background: var(--bg);
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 40px rgba(0,0,0,0.1);
}

/* === 顶部导航栏 === */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
}

.logo-text {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.icon-btn:active {
    background: var(--secondary);
}

/* === 主内容区 === */
.main-content {
    flex: 1;
    padding: 1rem 1rem calc(var(--bottom-nav-height) + 1rem);
    overflow-y: auto;
}

/* === Hero区 === */
.hero-section {
    text-align: center;
    padding: 1.5rem 0 1rem;
}

.hero-logo {
    width: 120px;
    height: auto;
    margin-bottom: 0.75rem;
}

.hero-slogan {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.hero-desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* === 计算器 === */
.calculator-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.calc-display {
    background: var(--text-primary);
    color: #fff;
    padding: 1.25rem 1rem;
    text-align: right;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.calc-expression {
    font-size: 1rem;
    color: rgba(255,255,255,0.6);
    min-height: 1.5rem;
    word-break: break-all;
}

.calc-result {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -1px;
    transition: font-size 0.2s;
}

.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
    background: var(--border);
}

.calc-btn {
    border: none;
    font-size: 1.4rem;
    font-weight: 500;
    padding: 1rem 0;
    cursor: pointer;
    transition: all 0.15s;
    background: var(--bg);
    color: var(--text-primary);
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.calc-btn:active {
    transform: scale(0.95);
    opacity: 0.8;
}

.calc-btn.num {
    background: #f8fafc;
}

.calc-btn.num:active {
    background: #e2e8f0;
}

.calc-btn.func {
    background: #eef2ff;
    color: var(--primary);
    font-size: 1.1rem;
}

.calc-btn.func:active {
    background: #c7d2fe;
}

.calc-btn.op {
    background: var(--primary);
    color: #fff;
    font-size: 1.5rem;
}

.calc-btn.op:active {
    background: var(--primary-dark);
}

.calc-btn.eq {
    background: var(--primary-dark);
    color: #fff;
    font-size: 1.6rem;
}

.calc-btn.eq:active {
    background: #3730a3;
}

.calc-btn.zero {
    grid-column: span 2;
}

/* === 工具网格 === */
.section-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

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

.tool-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    color: inherit;
}

.tool-card:active {
    transform: scale(0.96);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.tool-card .tool-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    background: var(--secondary);
    color: var(--primary);
}

.tool-card .tool-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.tool-card .tool-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.3;
}

/* === 页面标题 === */
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* === 历史列表 === */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-item {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item .expr {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.history-item .result {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
}

/* === 个人中心 === */
.profile-card {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--secondary), var(--secondary-2));
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem;
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

.profile-avatar img {
    width: 40px;
    height: 40px;
    filter: brightness(0) invert(1);
}

.profile-name {
    font-size: 1.3rem;
    font-weight: 700;
}

.profile-bio {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.profile-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text-primary);
    font-size: 1rem;
    transition: background 0.2s;
}

.menu-item:active {
    background: var(--secondary);
}

.menu-item .arrow {
    color: var(--text-muted);
    font-weight: 600;
}

/* === 底部导航栏 === */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: var(--max-width);
    margin: 0 auto;
    height: var(--bottom-nav-height);
    background: var(--bg);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    gap: 2px;
    min-width: 60px;
    min-height: 44px;
    transition: color 0.2s;
}

.nav-item svg {
    width: 24px;
    height: 24px;
    stroke-width: 1.8;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active svg {
    stroke-width: 2.5;
}

/* === 按钮 === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
    min-width: 44px;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:active {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--primary);
    border: 1px solid var(--border);
}

.btn-secondary:active {
    background: var(--primary-light);
    color: #fff;
}

/* === 输入框 === */
.input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: var(--bg);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
    margin-bottom: 0.75rem;
    min-height: 44px;
}

.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

/* === 后台管理 === */
.admin-login {
    padding: 2rem 1rem;
    max-width: 320px;
    margin: 0 auto;
}

.admin-login h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--primary);
}

.admin-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.admin-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.admin-tool-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.admin-tool-item .info {
    flex: 1;
}

.admin-tool-item .info .name {
    font-weight: 600;
}

.admin-tool-item .info .desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.admin-tool-item .actions {
    display: flex;
    gap: 0.5rem;
}

.admin-tool-item .actions button {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    min-height: 36px;
}

.btn-edit {
    background: var(--secondary);
    color: var(--primary);
}

.btn-delete {
    background: #fee2e2;
    color: var(--danger);
}

/* === 模态框 === */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 1rem;
}

.modal-content {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-content h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* === 页脚 === */
.app-footer {
    text-align: center;
    padding: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* === 暗色主题 === */
body.dark {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border: #334155;
    --secondary: #1e293b;
    --secondary-2: #1e293b;
    --shadow: 0 2px 12px rgba(0,0,0,0.4);
}

body.dark .calc-btn.num {
    background: #1e293b;
    color: #f1f5f9;
}

body.dark .calc-btn.num:active {
    background: #334155;
}

body.dark .calc-btn.func {
    background: #1e293b;
}

body.dark .calc-btn.func:active {
    background: #334155;
}

body.dark .calc-display {
    background: #0f172a;
}

body.dark .profile-card {
    background: linear-gradient(135deg, #1e293b, #0f172a);
}

/* === 响应式 === */
@media (min-width: 768px) {
    .app-container {
        border-radius: 0;
        box-shadow: none;
    }
}

@media (min-width: 1024px) {
    .app-container {
        max-width: 450px;
        border-radius: 24px;
        margin: 2rem auto;
        min-height: 90vh;
        box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    }
    body {
        background: #e2e8f0;
        padding: 1rem;
    }
    body.dark {
        background: #0f172a;
    }
}

/* === 工具提示 === */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    z-index: 1000;
    animation: toastIn 0.3s ease;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* === 工具卡片图标自适应 === */
.tool-icon-img {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    object-fit: contain;
    margin-bottom: 0.5rem;
}