/* 打工工具箱 —— 照搬「买个der」(https://maigede.awen.me) 的贴纸设计系统：
   奶油纸底 + 深棕粗描边 + 硬偏移阴影。线上那套没有深色模式，这里也强制浅色，
   所以整个文件不写 prefers-color-scheme，index.html 里另加了 color-scheme=light。 */
:root {
  --paper: #fff7e6; --card: #ffffff; --card2: #fffdf8;
  --ink: #33261f; --ink2: #5c4a3f; --line: #33261f;
  --dim: #8a7669; --dim2: #b09c8e; --dot: #e2d3c1;
  --peach: #ff9a6c; --mint: #4ecdc4; --sky: #63b3ff; --butter: #ffd166;
  --ok: #31b867; --ok-bg: #d8f6e2; --bad: #ff5d5d; --bad-bg: #ffe1de;
  --warn: #f5a623; --warn-bg: #fff0cf;
  --topbar: #ffd166;
  --r: 22px; --pad: 14px;
  --sh: 5px 5px 0 var(--line); --sh-sm: 3px 3px 0 var(--line); --sh-xs: 2px 2px 0 var(--line);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Yuanti SC", "YouYuan", "Microsoft YaHei", -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 400;
}
.page { padding: 0 0 calc(86px + env(safe-area-inset-bottom)); min-height: 100vh; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 9px;
  padding: calc(13px + env(safe-area-inset-top)) var(--pad) 12px;
  background: var(--topbar); border-bottom: 3px solid var(--line);
}
.logo {
  width: 32px; height: 32px; flex: none; border-radius: 12px; background: var(--peach);
  border: 2.5px solid var(--line); display: grid; place-items: center; font-size: 17px;
  box-shadow: var(--sh-xs); animation: wig 3.2s ease-in-out infinite;
}
@keyframes wig { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(8deg); } }
.topbar h1 { margin: 0; font-size: 20px; font-weight: 400; letter-spacing: 1px; }
.topbar .spacer { flex: 1; }
.iconbtn {
  background: var(--card); border: 2.5px solid var(--line); color: var(--ink); border-radius: 12px;
  padding: 4px 10px; font-size: 14px; box-shadow: var(--sh-sm); font-family: inherit; cursor: pointer;
}
.iconbtn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--line); }
#backBtn { display: none; }
#backBtn.show { display: block; }

/* ---------- 工具标题 ---------- */
.toolhead { padding: 16px var(--pad) 2px; }
.toolhead .t { font-size: 20px; letter-spacing: 1px; margin-bottom: 8px; }
.tag {
  display: inline-block; font-size: 11px; line-height: 1.7; padding: 3px 10px;
  border: 2px solid var(--line); border-radius: 20px; background: var(--card2); color: var(--ink2);
}

/* ---------- 卡片 ---------- */
.content-area { padding: 0 var(--pad); }
.tab-panel { display: none; margin-top: 12px; }
.tab-panel.on { display: block; }
.section {
  background: var(--card); border: 2.5px solid var(--line); border-radius: var(--r);
  padding: var(--pad); margin-bottom: 15px; box-shadow: var(--sh);
}
.info-card, .white-card { background: var(--card); border-radius: var(--r); padding: var(--pad); }
.card-title { font-size: 16px; font-weight: 400; letter-spacing: .5px; margin: 0 0 12px; }
.sub-title { font-size: 13px; text-align: center; color: var(--ink2); margin: -6px 0 10px; }
.card-content { font-size: 13px; color: var(--ink2); line-height: 1.85; }
.formula-item { margin-bottom: 4px; }
.bold { color: var(--ink); }
.note { font-size: 12px; color: var(--dim); line-height: 1.75; margin-top: 10px; border-top: 2px dashed var(--dot); padding-top: 8px; }
.tips {
  font-size: 12px; color: var(--ink2); line-height: 1.75; background: var(--card2);
  border: 2px dashed var(--dim2); border-radius: 12px; padding: 7px 10px; margin-top: 8px;
}
.disclaimer { font-size: 11px; color: var(--dim); text-align: center; margin-top: 10px; line-height: 1.6; }

/* ---------- 表单 ---------- */
input[type=text], input[type=number], input[type=date], select {
  width: 100%; background: var(--card2); border: 2.5px solid var(--line); color: var(--ink);
  border-radius: 14px; padding: 11px 12px; font-size: 15px; font-family: inherit; outline: none;
  box-shadow: inset 2px 2px 0 rgba(51, 38, 31, .06); appearance: none; -webkit-appearance: none;
}
input::placeholder { color: var(--dim2); }
input:focus, select:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(99, 179, 255, .35), inset 2px 2px 0 rgba(51, 38, 31, .06); }
.option-block { padding: 6px 0 4px; }
.option-title { font-size: 12px; color: var(--ink2); margin: 4px 0 6px 3px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.option-title .fold {
  font-size: 11px; color: var(--ink); background: var(--card2); border: 2px solid var(--line);
  border-radius: 20px; padding: 1px 9px; cursor: pointer;
}
.option-grid { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-start; }
.repay-type-box {
  flex: 0 0 calc((100% - 16px) / 3); text-align: center; padding: 9px 8px; min-height: 40px;
  background: var(--card2); border: 2.5px solid var(--line); border-radius: 15px; color: var(--ink);
  font-size: 13px; display: flex; align-items: center; justify-content: center;
  white-space: normal; word-break: break-word; box-shadow: var(--sh-xs);
  transition: transform .08s, box-shadow .08s, background-color .12s;
}
.repay-type-box:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--line); }
.repay-type-box.active { background: var(--sky); color: #fff; }
.option-grid.two-col .repay-type-box { flex: 0 0 calc((100% - 8px) / 2); }
.option-grid.wide .repay-type-box { flex: 1 1 100%; justify-content: flex-start; text-align: left; padding-left: 14px; }
input[type=range] { width: 100%; accent-color: var(--peach); background: none; border: 0; padding: 6px 0; box-shadow: none; }
.slider-hint { font-size: 11px; color: var(--dim); margin-top: 2px; }

/* ---------- 行 ---------- */
.cell {
  display: flex; align-items: center; gap: 11px; padding: 10px 2px;
  border-bottom: 2px dotted var(--dot); font-size: 14px;
}
.cell:last-child { border-bottom: 0; }
.cell .cell-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.cell .cell-title .ico {
  width: 38px; height: 38px; flex: none; border-radius: 13px; background: var(--card2);
  border: 2px solid var(--line); display: grid; place-items: center; font-size: 18px; box-shadow: var(--sh-xs);
}
.cell .cell-note { color: var(--ink2); font-size: 14px; display: flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.cell .chev { color: var(--dim); font-size: 17px; flex: none; }
.cell.tap { cursor: pointer; }
.cell.tap:active { transform: translateY(1px); }
.group-title { font-size: 13px; color: var(--dim); padding: 2px 2px 8px; letter-spacing: .5px; }

/* ---------- 结果 ---------- */
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-item {
  display: flex; flex-direction: column; align-items: center; padding: 10px 8px;
  background: var(--card2); border: 2.5px solid var(--line); border-radius: 15px; box-shadow: var(--sh-xs);
}
.grid-item.full-width { grid-column: span 2; }
.grid-item .label { font-size: 11px; color: var(--dim); margin-bottom: 4px; text-align: center; }
.grid-item .value { font-size: 18px; font-variant-numeric: tabular-nums; }
.grid-item span:not(.label):not(.value) { font-size: 11px; color: var(--dim); margin-left: 2px; }
.grid-item .note-line { font-size: 12px; color: #8a5a00; text-align: left; line-height: 1.75; margin-top: 2px; }

.table-header, .table-footer .tr { display: flex; background: var(--butter); }
.table-header .th { border-radius: 12px 12px 0 0; }
.total-row { border-radius: 0 0 12px 12px; }
.table-body .tr { display: flex; border-bottom: 2px dotted var(--dot); }
.th, .td { flex: 1; text-align: center; padding: 9px 4px; font-size: 13px; font-variant-numeric: tabular-nums; }
.table-header .th, .table-footer .tr { font-size: 13px; }
.total-row { background: var(--warn-bg); }
.tax-table { border: 2.5px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--card2); }
.tax-table .thead { display: flex; background: var(--butter); }
.tax-table .tbody .tr { display: flex; border-top: 2px dotted var(--dot); }
.tax-table .th, .tax-table .td { font-size: 12px; padding: 8px 4px; }
.flex-2 { flex: 2; }

.switch {
  width: 52px; height: 29px; border-radius: 20px; background: #e6d9c8; position: relative; flex: none;
  border: 2.5px solid var(--line); transition: .18s; cursor: pointer;
}
.switch.on { background: var(--ok); }
.switch::after {
  content: ""; position: absolute; top: 1.5px; left: 2px; width: 21px; height: 21px; border-radius: 50%;
  background: #fff; border: 2px solid var(--line); transition: .18s;
}
.switch.on::after { left: 23px; }

/* ---------- 价值评估 ---------- */
.level-value { font-size: 27px; letter-spacing: 2px; text-align: center; margin-bottom: 8px; }
.level-comment { font-size: 13px; color: var(--ink2); line-height: 1.85; text-align: center; padding: 0 4px; }
.formula-lines {
  font-size: 11px; color: var(--dim); line-height: 1.75; margin-top: 12px; background: var(--card2);
  border: 2px dashed var(--dim2); border-radius: 12px; padding: 8px 10px;
}
.center-block { text-align: center; margin-top: 14px; padding-top: 12px; border-top: 2px dashed var(--dot); }
.center-block .lv-label { font-size: 11px; color: var(--dim); margin-bottom: 6px; }

/* ---------- 底部标签栏 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex;
  height: calc(72px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 3px solid var(--line);
}
.tabbar .tb {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; color: var(--dim); cursor: pointer;
}
.tabbar .tb b { font-size: 21px; font-weight: 400; transition: transform .16s; }
.tabbar .tb.active { color: var(--ink); }
.tabbar .tb.active b {
  width: 34px; height: 33px; border-radius: 13px; background: var(--peach); border: 2.5px solid var(--line);
  box-shadow: var(--sh-xs); display: grid; place-items: center; transform: translateY(-1px);
}

/* ---------- PC：≥980px 换成桌面壳 ----------
   左侧导航 + 两列内容，照「买个der」线上那套 @media(min-width:980px) 的做法：
   桌面版是另一套壳，不是把手机页拉长。手机 WebView 的 CSS 宽度到不了 980，所以这段只在线上生效。 */
.rail { display: none; }
@media (min-width: 980px) {
  :root { --pad: 18px; }
  .page { min-height: 100vh; padding: 0 0 44px 236px; }
  .tabbar { display: none; }
  .rail {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 30; width: 236px;
    display: flex; flex-direction: column; gap: 4px; padding: 18px 0 0;
    background: var(--butter); border-right: 3px solid var(--line);
  }
  .rail .rbrand { display: flex; align-items: center; gap: 10px; padding: 0 22px 16px; font-size: 19px; letter-spacing: 1px; }
  .rail .rb {
    display: flex; align-items: center; gap: 13px; width: 100%; padding: 11px 22px; text-align: left;
    background: none; border: 0; border-left: 4px solid transparent; color: var(--dim);
    font-family: inherit; font-size: 15px; cursor: pointer;
  }
  .rail .rb b {
    width: 32px; height: 31px; flex: none; border-radius: 12px; background: var(--card2);
    border: 2.5px solid var(--line); box-shadow: var(--sh-xs); display: grid; place-items: center;
    font-size: 16px; font-weight: 400;
  }
  .rail .rb.active { background: var(--paper); color: var(--ink); border-left-color: var(--line); }
  .rail .rb.active b { background: var(--peach); }
  .topbar { padding: 14px 34px 12px; }
  .topbar h1 { font-size: 22px; }
  #backBtn, #backBtn.show { display: none; }     /* 返回键是手机导航用的，桌面有侧栏 */
  .toolhead { padding: 20px 34px 2px; }
  .content-area { max-width: 1240px; margin: 0 auto; padding: 0 34px; }

  .tab-panel.on { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
  .tab-panel.on > .section { margin-bottom: 0; }
  /* 长表单独占整行、内部按多列流排：栅格会把两列的行高对齐，「子女教育」那种五颗标签的长项
     一撑，短项下面就是一大片空洞；多列流才贴得紧（和买个der桌面版同一个结论）。 */
  #panel-0 > .section:first-child, #panel-3 > .section:first-child {
    grid-column: 1 / -1; column-width: 290px; column-gap: 34px;
  }
  #panel-0 > .section:first-child .option-block, #panel-3 > .section:first-child .option-block,
  #panel-0 > .section:first-child .tips, #panel-3 > .section:first-child .tips { break-inside: avoid; }
  #block-social, #block-house, #block-special { display: contents; }  /* 折叠壳让位，里面的表单项直接进栅格 */
  #mortgage-section, #panel-3 > .section:last-child { grid-column: 1 / -1; }
  /* 月供表能到几百行，桌面给个自己的滚动区，别让整页拖不到头 */
  #yearly-section, #mortgage-section { max-height: 66vh; overflow: auto; scrollbar-width: thin; }
  #yearly-section .table-header, #mortgage-section .table-header { position: sticky; top: 0; z-index: 2; }
  /* 专项扣除那些「一个孩子，夫妻各扣除1000元」的长标签，桌面上按内容宽排，别三等分挤成三行 */
  .option-grid .repay-type-box { flex: 0 1 auto; padding: 9px 14px; }
  .option-grid.two-col .repay-type-box, .option-grid.wide .repay-type-box { flex: 0 0 calc((100% - 8px) / 2); }
  .option-grid.wide .repay-type-box { flex: 1 1 100%; justify-content: flex-start; }
  .result-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}
/* 有鼠标才有 hover：触屏上这条不生效，免得 :active 的位移手感被盖掉 */
@media (hover: hover) {
  .repay-type-box, .cell.tap, .switch, .fold { cursor: pointer; }
  .iconbtn:hover, .btn:hover, .repay-type-box:hover { filter: brightness(1.05); }
  .rail .rb:hover { color: var(--ink); }
  .repay-type-box:hover { border-color: var(--sky); }
}
