/* =========================================================
   零克算数 · Design System
   配色参考零克官网首页：浅玫瑰背景 / 白卡 / 品牌红粉强调 / 轻阴影 / 中等圆角
   ========================================================= */
:root {
    --primary: #FF2442;
    --primary-hover: #E01E3A;
    --primary-active: #C01A32;
    --primary-light: #FFE5E9;
    --primary-lighter: #FFF5F7;

    --bg: #FFF8F8;
    --surface: #FFFFFF;
    --surface-2: #FDF2F4;

    --text-1: #1A1A1A;
    --text-2: #595959;
    --text-3: #999999;

    --border: #F0E6E8;
    --border-strong: #E5D8DA;

    --success: #0E9B7E;
    --warning: #B26A00;
    --warning-bg: #FDF4E3;
    --error: #D92D20;
    --error-bg: #FDECEA;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 2px rgba(16,32,28,.05), 0 1px 3px rgba(16,32,28,.06);
    --shadow: 0 4px 16px rgba(16,32,28,.06);
    --shadow-lg: 0 14px 36px rgba(16,32,28,.10);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

    --maxw: 1200px;
    --header-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-1);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; color: var(--text-1); }
p { margin: 0; }
code { font-family: var(--mono); }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

.skip-link {
    position: absolute; left: -999px; top: 0; background: var(--primary); color: #fff;
    padding: 10px 16px; border-radius: 0 0 8px 0; z-index: 1000;
}
.skip-link:focus { left: 0; }

/* ----------------------- 顶部导航 ----------------------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: rgba(255,255,255,.86);
    backdrop-filter: saturate(160%) blur(8px);
    border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 20px; height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; }
.brand-mark {
    display: block;
    width: auto; height: 30px;
    object-fit: contain;
    vertical-align: middle;
}
.brand-text { font-size: 17px; letter-spacing: .2px; line-height: 1; }
.primary-nav { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.primary-nav a {
    padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text-2);
    font-size: 14.5px; font-weight: 500; transition: background .15s, color .15s;
}
.primary-nav a:hover { background: var(--surface-2); color: var(--text-1); }
.primary-nav a.active { color: var(--primary); background: var(--primary-light); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.brand-link {
    padding: 8px 14px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
    color: var(--primary); background: var(--primary-light); transition: background .15s;
}
.brand-link:hover { background: var(--primary-light); }
.brand-link-soft { color: var(--text-2); background: transparent; border: 1px solid var(--border); }
.brand-link-soft:hover { background: var(--surface-2); color: var(--text-1); }
.nav-toggle { display: none; flex-direction: column; gap: 4px; width: 40px; height: 40px;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; cursor: pointer; padding: 9px; }
.nav-toggle span { height: 2px; background: var(--text-1); border-radius: 2px; transition: .2s; }
.mobile-menu { display: none; flex-direction: column; padding: 8px 24px 16px; border-bottom: 1px solid var(--border); background: #fff; }
.mobile-menu a { padding: 12px 4px; border-bottom: 1px solid var(--border); color: var(--text-1); font-weight: 500; }
.mobile-menu a:last-child { border-bottom: none; }
.mobile-menu.open { display: flex; }

/* ----------------------- Hero ----------------------- */
.hero { padding: 64px 0 40px; text-align: center; }
.hero-eyebrow { color: var(--primary); font-weight: 600; font-size: 14px; letter-spacing: .4px; margin-bottom: 12px; }
.hero-title { font-size: 38px; font-weight: 800; letter-spacing: -.5px; }
.hero-sub { margin-top: 12px; color: var(--text-2); font-size: 16px; }
.hero-search {
    margin: 28px auto 0; max-width: 560px; position: relative; display: flex; align-items: center;
    background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
    padding: 0 16px; box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s;
}
.hero-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.search-icon { color: var(--text-3); flex: none; }
.hero-search-input { flex: 1; border: none; outline: none; background: transparent;
    padding: 14px 12px; font-size: 16px; color: var(--text-1); }
.hero-chips { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
    border: 1px solid var(--border); background: #fff; color: var(--text-2);
    padding: 6px 14px; border-radius: 999px; font-size: 13.5px; cursor: pointer; transition: .15s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.hero-empty { margin-top: 24px; color: var(--text-3); }

/* ----------------------- 区块标题 / 分类筛选 ----------------------- */
.calc-section { padding: 24px 24px 56px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.section-title { font-size: 22px; font-weight: 700; }
.sub-title { font-size: 16px; font-weight: 700; color: var(--text-1); margin: 24px 0 14px; }
.cat-filter { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-btn {
    border: 1px solid var(--border); background: #fff; color: var(--text-2);
    padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 500; cursor: pointer; transition: .15s;
}
.cat-btn:hover { border-color: var(--primary); color: var(--primary); }
.cat-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ----------------------- 卡片网格 ----------------------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 16px; }
.calc-card {
    position: relative; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px; display: flex; flex-direction: column; gap: 8px;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
    animation: cardIn .4s ease both;
}
.calc-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.calc-card-top { display: flex; align-items: center; justify-content: space-between; }
.calc-badge {
    display: inline-flex; align-items: center; justify-content: center; min-width: 46px;
    padding: 4px 10px; border-radius: var(--radius-sm); background: var(--primary-light);
    color: var(--primary); font-weight: 700; font-size: 14px; letter-spacing: .3px;
}
.calc-card-name { font-size: 16px; font-weight: 700; margin-top: 4px; }
.calc-card-desc { font-size: 13.5px; color: var(--text-2); flex: 1; }
.calc-card-link { margin-top: 8px; color: var(--primary); font-weight: 600; font-size: 14px; }
.calc-card-link:hover { text-decoration: underline; }
.fav-star {
    border: none; background: transparent; cursor: pointer; font-size: 20px; line-height: 1;
    color: var(--text-3); transition: .15s; padding: 4px; border-radius: 8px;
}
.fav-star:hover { color: var(--primary); background: var(--primary-light); }
.fav-star[aria-pressed="true"] { color: #F5A623; }

.fav-section { margin: 0 0 32px; }
.all-calc-section { margin-top: 8px; }
.fav-section .sub-title { margin-top: 0; }

@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
    .calc-card { animation: none; } .calc-card:hover { transform: none; }
}

/* ----------------------- 计算器页 ----------------------- */
.calc-page { padding: 24px 24px 56px; }
.breadcrumb { font-size: 13px; color: var(--text-3); margin-bottom: 20px; }
.breadcrumb a { color: var(--text-2); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { margin: 0 8px; }
.breadcrumb .current { color: var(--text-1); }

.calc-layout { display: grid; grid-template-columns: 1.25fr 1fr; gap: 28px; align-items: start; }
.calc-form-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 28px; }
.calc-header { display: flex; gap: 16px; align-items: flex-start; }
.calc-badge-lg { font-size: 16px; min-width: 56px; height: 56px; padding: 0 14px; border-radius: var(--radius); }
.calc-title { font-size: 24px; font-weight: 800; }
.calc-lead { margin-top: 6px; color: var(--text-2); font-size: 14.5px; }

.formula-card {
    margin: 20px 0; background: var(--primary-lighter); border: 1px solid var(--primary-light);
    border-radius: var(--radius); padding: 14px 16px; display: flex; align-items: center; gap: 12px;
}
.formula-tag { font-size: 12px; font-weight: 700; color: var(--primary); background: #fff; border: 1px solid var(--primary-light); padding: 3px 9px; border-radius: 6px; }
.formula-text { font-size: 15px; color: var(--primary-active); font-weight: 600; }

/* 口径切换 */
.modes { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.mode-btn {
    border: 1px solid var(--border); background: #fff; color: var(--text-2);
    padding: 8px 14px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500; cursor: pointer; transition: .15s;
}
.mode-btn:hover { border-color: var(--primary); color: var(--primary); }
.mode-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 表单 */
.calc-form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field[data-show] { } /* 默认显示，JS 控制隐藏 */
/* 关键：.field 设了 display:flex，会盖过浏览器默认的 [hidden]{display:none}。
   必须显式提升 [hidden] 优先级，否则带 hidden 的字段（多口径互斥）仍会显示。 */
[hidden] { display: none !important; }
.field-label { font-size: 14px; font-weight: 600; color: var(--text-1); }
.input-wrap { position: relative; display: flex; align-items: center; background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s; }
.input-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.field-input {
    flex: 1; border: none; outline: none; background: transparent; width: 100%;
    padding: 0 14px; height: 46px; font-size: 16px; color: var(--text-1); font-family: var(--font);
}
.input-affix { color: var(--text-3); font-size: 15px; padding: 0 2px; }
.input-prefix { padding-left: 14px; }
.input-suffix { padding-right: 14px; }
.field-help { font-size: 12.5px; color: var(--text-3); margin: -2px 0 0; }
.field-error .input-wrap { border-color: var(--error); box-shadow: 0 0 0 3px var(--error-bg); }

.form-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

/* 按钮 */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 46px; padding: 0 20px; border-radius: var(--radius-sm); font-size: 15px; font-weight: 600;
    cursor: pointer; border: 1px solid transparent; transition: background .15s, border-color .15s, color .15s, transform .05s;
    font-family: var(--font);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-soft { background: var(--primary-light); color: var(--primary-active); }
.btn-soft:hover { background: var(--primary-light); }
.btn-ghost { background: #fff; color: var(--text-2); border-color: var(--border-strong); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-text { background: transparent; color: var(--text-3); padding: 0 12px; }
.btn-text:hover { color: var(--text-1); }

/* 结果卡 */
.calc-result-col { position: sticky; top: calc(var(--header-h) + 16px); }
.result-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 26px; box-shadow: var(--shadow-sm); }
.result-head { display: flex; align-items: center; justify-content: space-between; }
.result-label { font-size: 14px; font-weight: 700; color: var(--text-2); letter-spacing: .3px; }
.fav-star-lg { font-size: 22px; }
.result-value {
    font-size: 44px; font-weight: 800; color: var(--primary-active); margin: 10px 0 4px;
    letter-spacing: -.5px; line-height: 1.1; word-break: break-all; transition: color .2s;
}
.result-value.is-pulse { animation: lk-pulse .5s ease; }
@keyframes lk-pulse {
    0% { transform: scale(1); }
    40% { transform: scale(1.04); }
    100% { transform: scale(1); }
}
.result-status { display: inline-block; font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; margin-bottom: 6px; }
.result-status.above { background: var(--primary-light); color: var(--success); }
.result-status.below { background: var(--error-bg); color: var(--error); }
.result-status.equal { background: var(--surface-2); color: var(--text-2); }
.result-status.profit { background: var(--primary-light); color: var(--success); }
.result-status.loss { background: var(--error-bg); color: var(--error); }
.result-details { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.result-details li { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; border-bottom: 1px dashed var(--border); padding-bottom: 8px; }
.result-details li:last-child { border-bottom: none; }
.result-details .rd-label { color: var(--text-2); }
.result-details .rd-value { font-weight: 700; color: var(--text-1); font-variant-numeric: tabular-nums; }
.result-explanation { margin-top: 16px; font-size: 14.5px; color: var(--text-1); background: var(--surface-2); border-radius: var(--radius); padding: 12px 14px; }
.result-explanation.is-error { background: var(--error-bg); color: var(--error); }
.result-caution { margin-top: 10px; font-size: 13px; color: var(--warning); background: var(--warning-bg); border-radius: var(--radius); padding: 10px 14px; }
.result-actions { margin-top: 18px; display: flex; gap: 10px; }
.result-privacy { margin-top: 12px; font-size: 12px; color: var(--text-3); text-align: center; }

/* 自定义计算器结果列表 */
.result-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.result-list li { display: flex; justify-content: space-between; align-items: baseline; background: var(--surface-2); border-radius: var(--radius); padding: 10px 14px; }
.result-list .rl-name { font-size: 14px; color: var(--text-1); font-weight: 600; }
.result-list .rl-note { font-size: 12px; color: var(--text-3); }
.result-list .rl-value { font-weight: 800; color: var(--primary-active); font-variant-numeric: tabular-nums; }

/* ----------------------- 知识区 / 关联 / FAQ ----------------------- */
.knowledge { margin-top: 40px; }
.knowledge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 16px; }
.knowledge-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; }
.knowledge-block h3 { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.knowledge-block p { font-size: 14px; color: var(--text-2); }
.knowledge-formula { background: var(--primary-lighter); border-radius: var(--radius-sm); padding: 10px 12px; }
.knowledge-formula code { color: var(--primary-active); font-weight: 600; font-size: 14px; }

.related { margin-top: 40px; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 16px; }
.related-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; transition: .15s; }
.related-card:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.related-short { font-size: 13px; font-weight: 700; color: var(--primary); }
.related-name { font-size: 15px; font-weight: 700; }
.related-desc { font-size: 13px; color: var(--text-2); }

.faq { margin-top: 40px; }
.faq-list { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.faq-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 18px; }
.faq-item summary { cursor: pointer; padding: 15px 0; font-weight: 600; font-size: 15px; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; color: var(--primary); font-size: 20px; font-weight: 700; }
.faq-item[open] summary::after { content: "−"; }
.faq-answer { padding: 0 0 16px; font-size: 14px; color: var(--text-2); }

/* ----------------------- 页脚 ----------------------- */
.site-footer { margin-top: 64px; border-top: 1px solid var(--border); background: #fff; padding: 36px 0 28px; }
.footer-inner { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; align-items: center; }
.footer-brand { display: flex; gap: 12px; align-items: center; }
.footer-name { font-weight: 700; font-size: 16px; }
.footer-tag { font-size: 13px; color: var(--text-3); }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-links a { font-size: 14px; color: var(--text-2); }
.footer-links a:hover { color: var(--primary); }
.footer-bottom { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-3); }

/* ----------------------- Toast ----------------------- */
.toast {
    position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(10px);
    background: var(--text-1); color: #fff; padding: 11px 20px; border-radius: 999px; font-size: 14px;
    box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .2s, transform .2s; z-index: 200; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ----------------------- 404 / 关于 / 法律 ----------------------- */
.notfound { padding: 80px 24px; text-align: center; }
.notfound-inner { max-width: 480px; margin: 0 auto; }
.notfound-mark { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 14px; background: var(--primary-light); color: var(--primary); font-size: 28px; font-weight: 700; margin-bottom: 18px; }
.notfound-title { font-size: 26px; font-weight: 800; }
.notfound-sub { margin-top: 10px; color: var(--text-2); }
.notfound-actions { margin-top: 24px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.about-page { padding: 24px 24px 56px; }
.about-head { margin-bottom: 28px; }
.about-eyebrow { color: var(--primary); font-weight: 600; font-size: 14px; letter-spacing: .4px; margin-bottom: 8px; }
.about-title { font-size: 30px; font-weight: 800; }
.about-sub { margin-top: 8px; color: var(--text-2); }
.about-group { margin-bottom: 32px; }
.about-group-title { font-size: 20px; font-weight: 700; display: flex; align-items: baseline; gap: 10px; }
.about-group-en { font-size: 13px; color: var(--text-3); font-weight: 500; }
.about-group-desc { font-size: 14px; color: var(--text-2); margin: 6px 0 14px; }
.about-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.about-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; transition: .15s; }
.about-item:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.about-item-short { font-size: 13px; font-weight: 700; color: var(--primary); }
.about-item-name { font-size: 15px; font-weight: 700; }
.about-item-desc { font-size: 13px; color: var(--text-2); }
.about-item-formula { font-size: 12.5px; color: var(--text-3); background: var(--surface-2); border-radius: 6px; padding: 6px 8px; }
.about-note { margin-top: 16px; }
.about-note ul { margin: 12px 0 0; padding-left: 20px; color: var(--text-2); font-size: 14px; }
.about-note li { margin-bottom: 8px; }

.legal-page { padding: 24px 24px 56px; max-width: 820px; }
.legal-title { font-size: 28px; font-weight: 800; }
.legal-updated { color: var(--text-3); font-size: 13px; margin-top: 6px; }
.legal-body h2 { font-size: 18px; font-weight: 700; margin: 24px 0 8px; }
.legal-body p { color: var(--text-2); font-size: 15px; }

/* =========================================================
   响应式
   ========================================================= */
@media (max-width: 1024px) {
    .calc-layout { grid-template-columns: 1fr; }
    .calc-result-col { position: static; }
    .knowledge-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .primary-nav, .header-actions .brand-link { display: none; }
    .nav-toggle { display: flex; }
    .hero { padding: 44px 0 28px; }
    .hero-title { font-size: 28px; }
    .hero-sub { font-size: 15px; }
    .section-title { font-size: 20px; }
    .calc-form-col { padding: 20px; border-radius: var(--radius-lg); }
    .calc-form { grid-template-columns: 1fr; }
    .result-value { font-size: 38px; }
}
@media (max-width: 430px) {
    .container { padding: 0 16px; }
    .calc-page, .calc-section, .about-page, .legal-page { padding-left: 16px; padding-right: 16px; }
    .hero-title { font-size: 25px; }
    .field-input { height: 48px; font-size: 16px; }
    .btn { height: 48px; width: 100%; }
    .form-actions .btn { flex: 1; }
    .result-actions { flex-direction: column; }
    .result-actions .btn { width: 100%; }
    .footer-inner { flex-direction: column; align-items: flex-start; }
    .result-value { font-size: 34px; }
}
@media (max-width: 375px) {
    .hero-title { font-size: 23px; }
    .card-grid { grid-template-columns: 1fr; }
}
