/* 薪动 · 上班鼓励器 V0.1.3 — LIMING LAB */
:root {
  --bg: #f3f7f1;
  --bg-2: #eaf3ec;
  --card: #ffffff;
  --ink: #1d2a22;
  --ink-2: #4d5c53;
  --ink-3: #64736a;   /* 说明文字：白底对比度 ≥ 4.5 */
  --ink-4: #8a978f;   /* 仅用于署名等次要信息 */
  --line: #e4ebe5;
  --green: #11a05a;
  --green-deep: #0b7a43;
  --green-soft: #e3f5ea;
  --amber: #e59a1a;
  --amber-soft: #fdf2dc;
  --gray-soft: #eef1ef;
  --blue: #3b7be0;
  --blue-soft: #e5eefc;
  --danger: #d64545;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(20, 50, 30, .04), 0 8px 28px rgba(20, 60, 35, .07);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Helvetica Neue", Arial, sans-serif;
  --num: "SF Pro Display", -apple-system, BlinkMacSystemFont, "DIN Alternate", "Roboto", "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
/* 禁止双击放大：iOS Safari 13+、微信、Chromium 均支持 */
*, *::before, *::after { touch-action: manipulation; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(120% 60% at 100% 0%, #e2f4e7 0%, rgba(226, 244, 231, 0) 60%),
    radial-gradient(90% 50% at 0% 100%, #fbf3df 0%, rgba(251, 243, 223, 0) 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.5;
}
body.lock { overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-appearance: none; appearance: none; }
[hidden] { display: none !important; }

.ico {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

.app {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(12px + var(--sat)) calc(16px + var(--sar)) calc(20px + var(--sab)) calc(16px + var(--sal));
  display: flex; flex-direction: column;
  min-height: 100vh; min-height: 100dvh;
}

/* ---------- 顶部 ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; height: 40px; }
.portal-pill {
  display: inline-flex; align-items: center;
  height: 32px; padding: 0 14px;
  border-radius: 999px;
  font-size: 13px; letter-spacing: .02em;
  color: var(--ink-2); text-decoration: none;
  background: rgba(255, 255, 255, .72);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: background .2s, color .2s;
}
.portal-pill:hover, .portal-pill:active { background: #fff; color: var(--ink); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: rgba(255, 255, 255, .72); border: 1px solid var(--line);
  color: var(--ink-2);
  transition: background .2s, transform .15s;
}
.icon-btn:hover { background: #fff; color: var(--ink); }
.icon-btn:active { transform: scale(.94); }

.brand { padding: 8px 4px 12px; }
.brand h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: .02em; line-height: 1.3; }
.brand .dot { color: var(--green); margin: 0 .18em; }
.brand p { margin: 2px 0 0; font-size: 13px; color: var(--ink-3); }

.stack { display: flex; flex-direction: column; gap: 12px; flex: 1; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(228, 235, 229, .7);
  padding: 20px;
  min-width: 0;
}
.card-label {
  font-size: 12px; font-weight: 600; letter-spacing: .08em;
  color: var(--ink-3);
}

/* ---------- 鼓励卡片 ---------- */
.quote-card { padding: 16px 18px 16px; }
/* 最小高度按实测：手机端主文案最多两行，短文案在此高度内垂直居中，切换时卡片不跳 */
.quote {
  margin: 8px 0 12px; min-height: var(--quote-h, 84px);
  display: flex; flex-direction: column; justify-content: center;
  transition: opacity .22s ease, transform .22s ease;
}
.quote.swap { opacity: 0; transform: translateY(6px); }
.quote-main { margin: 0; font-size: 20px; font-weight: 700; line-height: 1.4; word-break: break-word; text-wrap: pretty; }
.quote-sub { margin: 6px 0 0; font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px;
  flex: none; height: 34px; padding: 0 12px; border-radius: 999px;
  background: var(--green-soft); color: var(--green-deep);
  border: 0; font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: transform .15s, background .2s;
}
.ghost-btn .ico { width: 15px; height: 15px; transition: transform .45s ease; }
.ghost-btn:hover { background: #d6f0e0; }
.ghost-btn:active { transform: scale(.96); }
.ghost-btn.spin .ico { transform: rotate(180deg); }

/* ---------- 收入卡片 ---------- */
.money-card { padding: 16px 18px 14px; position: relative; overflow: hidden; }
.money-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  background: var(--gray-soft); color: var(--ink-2);
  white-space: nowrap;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }
.rate-chip { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }

.money-card[data-status="working"] .status-pill { background: var(--green-soft); color: var(--green-deep); }
.money-card[data-status="working"] .status-dot { animation: pulse 1.6s ease-in-out infinite; }
.money-card[data-status="break"] .status-pill { background: var(--amber-soft); color: #a8690a; }
.money-card[data-status="off"] .status-pill { background: var(--blue-soft); color: #2559a8; }

@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }

.money-label { margin-top: 12px; font-size: 13px; color: var(--ink-3); }
.money {
  margin-top: 2px;
  display: flex; align-items: baseline; flex-wrap: nowrap;
  color: var(--green);
  font-family: var(--num);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -.01em;
  white-space: nowrap;
  min-width: 0;
  --money-size: clamp(44px, 14vw, 58px);
}
.money .cur { font-size: calc(var(--money-size) * .5); margin-right: 4px; font-weight: 600; }
.money .int { font-size: var(--money-size); }
.money .dec { font-size: calc(var(--money-size) * .56); opacity: .78; }
.money.len-m { --money-size: clamp(36px, 11vw, 48px); }
.money.len-l { --money-size: clamp(28px, 8.4vw, 38px); }
.money-card:not([data-status="working"]) .money { color: #4e9b72; }
.money-card[data-status="before"] .money,
.money-card[data-status="rest"] .money,
.money-card[data-status="invalid"] .money { color: #9fb3a7; }

.per-sec {
  margin-top: 10px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--green-deep);
  font-variant-numeric: tabular-nums;
}
.per-sec .ico { width: 16px; height: 16px; }
.money-card:not([data-status="working"]) .per-sec { color: var(--ink-3); }

.progress { margin-top: 14px; height: 8px; border-radius: 99px; background: var(--gray-soft); overflow: hidden; }
.progress-bar {
  height: 100%; width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #5fd194, var(--green));
}
/* 首帧直接到位，之后才开启过渡，避免加载时进度条从 0 动画到实际位置 */
.ready .progress-bar { transition: width .5s linear; }
.money-card[data-status="break"] .progress-bar { background: linear-gradient(90deg, #f6c56d, var(--amber)); }
.progress-meta {
  display: flex; justify-content: space-between; margin-top: 6px;
  font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums;
}

.stats { margin-top: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: #f7faf7; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px 8px; min-width: 0; }
.stat-label { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.stat-label .ico { width: 15px; height: 15px; }
.stat-value {
  margin-top: 4px; font-family: var(--num); font-variant-numeric: tabular-nums;
  font-size: clamp(19px, 5.6vw, 22px); font-weight: 650; color: var(--ink); letter-spacing: .01em;
  white-space: nowrap;
}
.stat-value.long { font-size: clamp(16px, 4.6vw, 20px); }

.demo-tip {
  margin-top: 14px; width: 100%;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 2px 0; background: none; border: 0; border-top: 1px solid var(--line);
  text-align: left; font-size: 13px; line-height: 1.4; color: var(--ink-3);
}
.demo-tag {
  flex: none; padding: 1px 7px; border-radius: 6px;
  background: var(--amber-soft); color: #8a5a0b; font-size: 11px; font-weight: 600;
}
.demo-text { flex: 1; min-width: 0; }
.demo-link { flex: none; display: inline-flex; align-items: center; gap: 3px; color: var(--green-deep); font-weight: 600; }
.demo-link .ico { width: 14px; height: 14px; }
.demo-tip:hover .demo-link { text-decoration: underline; }

.disclaimer { margin: 0 6px; padding-bottom: 4px; font-size: 12px; color: var(--ink-3); text-align: center; line-height: 1.6; }

/* ---------- 设置面板 ---------- */
.sheet-mask {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(20, 35, 25, .32);
  opacity: 0; transition: opacity .25s ease;
}
.sheet-mask.show { opacity: 1; }
.sheet {
  position: fixed; z-index: 21;
  left: 0; right: 0; bottom: 0;
  margin: 0 auto; width: 100%; max-width: 520px;
  max-height: calc(92vh - var(--sat)); max-height: calc(92dvh - var(--sat));
  display: flex; flex-direction: column;
  background: #fbfdfb;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 40px rgba(20, 50, 30, .15);
  transform: translateY(100%); transition: transform .32s cubic-bezier(.2, .8, .2, 1);
}
.sheet.show { transform: translateY(0); }
.sheet-grip { width: 38px; height: 4px; border-radius: 4px; background: #d5ddd7; margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 16px 6px 20px; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.sheet-body {
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 4px 20px calc(18px + var(--sab));
}

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row[data-mode="hourly"] { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.row .field { margin-bottom: 12px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field-label.sub { font-weight: 500; color: var(--ink-3); font-size: 12px; }
.input {
  width: 100%; min-width: 0; height: 46px; padding: 0 14px;
  border-radius: 12px; border: 1px solid var(--line); background: #fff;
  font-size: 16px; /* 16px 防止 iOS 聚焦自动放大 */
  font-variant-numeric: tabular-nums;
  outline: none; -webkit-appearance: none; appearance: none;
  transition: border-color .2s, box-shadow .2s;
}
input[type="time"].input { display: flex; align-items: center; line-height: 46px; }
input[type="time"]::-webkit-date-and-time-value { text-align: left; }
.input:focus { border-color: #8fd3ad; box-shadow: 0 0 0 3px rgba(17, 160, 90, .12); }
.input.bad { border-color: #eaa; box-shadow: 0 0 0 3px rgba(214, 69, 69, .08); }
.input:disabled { background: var(--gray-soft); color: var(--ink-3); }
.field-err { font-size: 12px; color: var(--danger); min-height: 0; }
.field-err:empty { display: none; }
.hint { margin: -4px 0 14px; font-size: 12px; color: var(--ink-3); }
.hint.on { color: #2559a8; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 13px; background: var(--gray-soft); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block; text-align: center; height: 38px; line-height: 38px; border-radius: 10px;
  font-size: 15px; font-weight: 600; color: var(--ink-3); cursor: pointer; transition: all .2s;
}
.segmented input:checked + span { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.segmented input:focus-visible + span { outline: 2px solid #8fd3ad; }

.switch-row { display: flex; align-items: center; justify-content: space-between; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: #d8dfda; transition: background .2s; }
.switch span::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .2s;
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid #8fd3ad; outline-offset: 2px; }
#lunchRow { margin-top: 8px; }
#lunchRow .field { margin-bottom: 0; }

.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.weekdays button {
  height: 40px; border-radius: 11px; border: 1px solid var(--line); background: #fff;
  font-size: 14px; font-weight: 600; color: var(--ink-3); padding: 0; transition: all .15s;
}
.weekdays button[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }
.weekdays button:active { transform: scale(.94); }

.preview {
  margin: 4px 0 16px; padding: 12px 14px; border-radius: 12px;
  background: var(--green-soft); color: var(--green-deep);
  font-size: 13px; line-height: 1.6; font-variant-numeric: tabular-nums; white-space: pre-line;
}
.preview.bad { background: #fdecec; color: var(--danger); }

.sheet-actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; }
.btn { height: 48px; border-radius: 14px; border: 0; font-size: 16px; font-weight: 700; transition: transform .15s, background .2s; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-deep); }
.btn.secondary { background: var(--gray-soft); color: var(--ink-2); }
.privacy { margin: 12px 0 0; text-align: center; font-size: 12px; color: var(--ink-3); }
.sheet-sign { margin: 18px 0 0; text-align: center; font-size: 11px; color: var(--ink-4); letter-spacing: .04em; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 30; left: 50%; bottom: calc(28px + var(--sab));
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 40px);
  padding: 10px 18px; border-radius: 999px;
  background: rgba(29, 42, 34, .92); color: #fff; font-size: 14px;
  transition: opacity .25s, transform .25s; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 桌面 ---------- */
/* 平板：单列加宽 */
@media (min-width: 600px) {
  .app { max-width: 560px; padding-top: calc(24px + var(--sat)); }
  .brand { padding: 20px 4px 18px; }
  .brand h1 { font-size: 28px; }
  .card { padding: 24px; }
  .quote-card { padding: 22px 24px 24px; }
  .quote { --quote-h: 64px; margin: 14px 0 18px; }
  .quote-main { font-size: 22px; }
  .money-card { padding: 22px 24px 20px; }
  .money { --money-size: 60px; }
  .money.len-m { --money-size: 50px; }
  .money.len-l { --money-size: 40px; }
  .stat-value { font-size: 24px; }
  .stat-value.long { font-size: 21px; }
  .sheet { bottom: auto; top: 50%; border-radius: 24px; transform: translateY(-46%) scale(.98); opacity: 0; transition: transform .25s, opacity .25s; max-height: 88vh; }
  .sheet.show { transform: translateY(-50%) scale(1); opacity: 1; }
  .sheet-grip { display: none; }
  .sheet-head { padding-top: 14px; }
  .sheet-body { padding-bottom: 20px; }
}

/* 桌面：左右两栏 */
@media (min-width: 960px) {
  .app { max-width: 940px; padding-top: calc(32px + var(--sat)); justify-content: flex-start; }
  .brand { padding: 24px 4px 22px; }
  .brand h1 { font-size: 30px; }
  .stack { display: grid; grid-template-columns: 1fr 1.25fr; align-items: stretch; gap: 18px; flex: none; }
  .quote-card { display: flex; flex-direction: column; }
  .quote-card .ghost-btn { align-self: flex-start; }
  .quote-card .quote { flex: 1; display: flex; flex-direction: column; justify-content: center; }
  .quote-main { font-size: 27px; }
  .quote-sub { font-size: 15px; margin-top: 12px; }
  .disclaimer { grid-column: 1 / -1; }
  .money.len-l { --money-size: 34px; }
}

@media (max-width: 359px) {
  .app { padding-left: calc(12px + var(--sal)); padding-right: calc(12px + var(--sar)); }
  .card { padding: 16px; }
  .quote-main { font-size: 19px; }
  .quote { --quote-h: 80px; }
  .ghost-btn { padding: 0 10px; }
  .stat-value { font-size: 18px; }
  .stat-value.long { font-size: 15px; }
  .stat { padding: 11px 10px 9px; }
}

/* 矮屏紧凑模式：Safari 带工具栏、安卓常见机型等可视高度较小时，尽量一屏放下 */
@media (max-width: 599px) and (max-height: 760px) {
  .topbar { height: 38px; }
  .brand { padding: 4px 4px 8px; }
  .brand h1 { font-size: 20px; }
  .brand p { display: none; }
  .stack { gap: 10px; }
  .quote-card { padding: 12px 16px 14px; }
  .quote { margin: 6px 0 10px; }
  .money-card { padding: 14px 16px 12px; }
  .money-label { margin-top: 8px; }
  .money { --money-size: clamp(40px, 12vw, 50px); }
  .money.len-m { --money-size: clamp(32px, 9.6vw, 42px); }
  .per-sec { margin-top: 6px; }
  .progress { margin-top: 12px; }
  .stats { margin-top: 10px; gap: 8px; }
  .stat { padding: 8px 10px 7px; }
  .stat-value { font-size: 20px; margin-top: 2px; }
  .stat-value.long { font-size: 17px; }
  .demo-tip { margin-top: 10px; padding-top: 10px; }
}

/* 更矮的屏幕（如 iPhone SE 的 Safari）：进一步压缩数字区 */
@media (max-width: 599px) and (max-height: 620px) {
  .app { padding-top: calc(8px + var(--sat)); padding-bottom: calc(10px + var(--sab)); }
  .money { --money-size: clamp(36px, 10.5vw, 42px); }
  .money-label { margin-top: 6px; }
  .progress { height: 6px; }
  .disclaimer { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation: none !important; }
}
