* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    -webkit-tap-highlight-color: transparent;
}
:root {
    --bg-color: #ffffff;
    --card-bg: rgba(255, 255, 255, 0.88);
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --primary: #4f46e5;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    --red-dot: #ef4444;
    --green-dot: #10b981;
}
body {
    min-height: 100vh;
    color: var(--text-color);
    background-color: #fff;
    background-image: linear-gradient(135deg, #ffffff 0%, #f5f7fb 100%);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    padding: 16px 16px calc(90px + env(safe-area-inset-bottom));
    transition: background 0.3s ease;
    overflow-x: hidden;
}
.app { max-width: 640px; margin: 0 auto; }
.header { text-align: center; margin-bottom: 20px; position: relative; }
.title { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.subtitle { color: var(--text-muted); font-size: 14px; }
/* 右上角信箱 */
.mail-btn{
    position:absolute; right:0; top:0; width:46px; height:46px;
    border-radius:13px; background:rgba(255,255,255,.95);
    border:1px solid var(--border-color);
    display:flex; align-items:center; justify-content:center;
    box-shadow:var(--shadow); color:var(--primary); cursor:pointer;
}
.mail-btn svg{ width:24px; height:24px; }
.mail-dot{
    position:absolute; top:7px; right:7px; width:11px; height:11px;
    border-radius:50%; background:var(--red-dot); display:none;
    box-shadow:0 0 0 2px #fff;
}
.mail-dot.show{ display:block; }
.panel {
    background: var(--card-bg); backdrop-filter: blur(10px);
    border: 1px solid var(--border-color); border-radius: 18px;
    padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
input[type="text"], input[type="number"], input[type="password"],
input[type="color"], select, textarea {
    border: 1px solid var(--border-color); border-radius: 12px;
    padding: 14px; font-size: 16px; outline: none; background: #fff;
    color: var(--text-color); transition: border-color 0.2s;
}
input[type="text"], input[type="number"], input[type="password"], select, textarea {
    flex: 1; min-width: 120px;
}
input[type="color"] { width: 54px; height: 44px; padding: 4px; vertical-align: middle; }
input[type="file"] { font-size: 14px; max-width: 100%; }
textarea { resize: vertical; min-height: 80px; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
button {
    border: none; border-radius: 12px; padding: 14px 16px; font-size: 15px;
    font-weight: 600; cursor: pointer; color: #fff; background: var(--primary);
    transition: background 0.2s; min-height: 48px;
}
button:active { opacity: 0.85; }
button.secondary { background: #e5e7eb; color: var(--text-color); }
button.success { background: var(--success); }
button.danger { background: var(--danger); }
button.warning { background: var(--warning); }
button.btn-sm { padding: 6px 10px; min-height: auto; font-size: 14px; }
button:disabled { opacity:0.45; cursor:not-allowed; }
.section-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.bg-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.bg-option {
    padding: 12px 6px; border-radius: 12px; text-align: center; font-size: 13px;
    border: 2px solid transparent; cursor: pointer; background: #f9fafb;
    color: var(--text-color); min-height: 44px;
}
.bg-option.active { border-color: var(--primary); }
.color-pickers { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.color-pickers label { font-size: 14px; color: var(--text-muted); }
.task-list { display: flex; flex-direction: column; gap: 12px; }
.task-item {
    display: flex; flex-direction: column; gap: 12px;
    background: var(--card-bg); backdrop-filter: blur(10px);
    border: 1px solid var(--border-color); border-radius: 16px;
    padding: 16px; box-shadow: var(--shadow);
}
.task-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.task-title { font-size: 17px; font-weight: 600; word-break: break-word; }
.task-content { font-size: 15px; color: #444; white-space: pre-wrap; word-break: break-word; }
.task-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.task-img-box { margin-top: 8px; }
.task-img { max-width: 100%; max-height: 240px; border-radius: 10px; object-fit: cover; cursor: pointer; }
.img-input-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.img-input-row input { flex: 1; min-width: 140px; }
.empty { text-align: center; color: var(--text-muted); padding: 30px 0; font-size: 14px; }
.attach-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 14px; color: #555; }
.attach-pill {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px;
    border-radius: 999px; background: #f1f5ff; color: #4f46e5; font-weight: 600; font-size: 13px;
}
.toy-pill { background: #fff7e6; color: #d97706; }
.summary-block { margin-top: 8px; padding: 10px; background: #f8fafc; border-radius: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.diaper-item, .toy-item {
    background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: 16px; padding: 14px; display: flex;
    justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap;
}
.diaper-info p, .toy-info p { line-height: 1.5; }
.diaper-info .size { font-weight: 600; }
.stock-img-box { width: 100%; margin-top: 8px; }
.stock-img { max-width: 160px; max-height: 160px; border-radius: 10px; object-fit: cover; cursor: pointer; }
.stock-count { font-size: 22px; font-weight: 800; color: var(--primary); }
.stock-count.zero { color: var(--danger); }
.log-item { padding: 10px; border-bottom: 1px solid var(--border-color); font-size: 14px; }
.log-item:last-child { border-bottom: none; }
.log-item .log-text { margin: 6px 0 2px; line-height: 1.5; }
.log-time { color: var(--text-muted); font-size: 12px; }
.role-tag {
    display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
    padding: 4px 8px; border-radius: 99px;
}
.role-master { background: #fee2e2; color: #dc2626; }
.role-puppy { background: #dbeafe; color: #2563eb; }
.status-tag {
    display: inline-flex; align-items: center; gap: 4px; font-size: 13px;
    padding: 3px 8px; border-radius: 99px; background: #f3f4f6; white-space: nowrap;
}
.dot-red { width: 8px; height: 8px; border-radius: 50%; background: var(--red-dot); display: inline-block; }
.dot-green { width: 8px; height: 8px; border-radius: 50%; background: var(--green-dot); display: inline-block; }
.dot-amber { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); display: inline-block; }
/* 时间信息行 */
.time-row {
    display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px;
    color: #6b7280; background: #f8fafc; border-radius: 10px;
    padding: 8px 10px; line-height: 1.6;
}
.time-row .dur { color: #4f46e5; font-weight: 700; }
/* 奖惩块 */
.fb-block {
    margin-top: 10px; padding: 12px; border-radius: 12px;
    background: #fafbff; border: 1px dashed #d8def0;
}
.fb-block.read { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fb-title { font-size: 14px; font-weight: 700; margin-bottom: 8px; color: #374151; }
.fb-type-row { display: flex; gap: 10px; margin-bottom: 10px; }
.fb-type-btn {
    flex: 1; background: #eef1fa; color: #4b5563; border: 2px solid transparent;
}
.fb-type-btn.active { background: #4f46e5; color: #fff; border-color: #4338ca; }
.fb-tag { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 99px; }
.fb-tag.reward { background: #dcfce7; color: #15803d; }
.fb-tag.punish { background: #fee2e2; color: #b91c1c; }
.fb-tag.skip { background: #e5e7eb; color: #4b5563; }
.fb-text { font-size: 14px; color: #374151; }
.fb-current { font-size: 13px; color: #6b7280; margin-top: 8px; }
/* 底部Tab栏 */
.tab-bar {
    position: fixed; left: 0; bottom: 0; width: 100%; display: flex;
    background: #fff; border-top: 1px solid var(--border-color); z-index: 99;
    padding-bottom: env(safe-area-inset-bottom);
}
.tab-item { flex: 1; text-align: center; padding: 10px 0; color: #888; transition: 0.2s; cursor: pointer; }
.tab-item.active { color: var(--primary); }
.tab-item svg { width: 28px; height: 28px; display: block; margin: 0 auto 4px; }
.tab-item span { font-size: 12px; }
/* 页面切换：左右平移过渡动画 */
.page { display: none; position: relative; }
.page.active { display: block; }
.page.slide-in-left { animation: slideInLeft 0.28s ease forwards; }
.page.slide-in-right { animation: slideInRight 0.28s ease forwards; }
@keyframes slideInLeft { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: translateX(0); } }
@media (max-width: 480px) {
    .task-head { flex-direction: column; align-items: flex-start; }
    .task-actions { width: 100%; justify-content: flex-end; }
    .header .title { padding: 0 52px; }
}
.role-select-card { display: flex; gap: 12px; margin-top: 12px; }
.role-option {
    flex: 1; text-align: center; padding: 16px 8px; border-radius: 16px;
    border: 2px solid var(--border-color); cursor: pointer; font-weight: 600;
}
.role-option.selected { border-color: var(--primary); background: #f0f4ff; }
.warn-text { margin-top: 8px; font-size: 13px; color: #b45309; }
/* 5级评分条 */
.score-bar-wrap { width: 100%; margin-top: 8px; }
.score-bar { display: flex; width: 100%; height: 32px; border-radius: 8px; overflow: hidden; }
.score-seg {
    flex: 1; display: flex; align-items: center; justify-content: center;
    color: white; font-size: 13px; font-weight: bold; opacity: .55;
}
.score-bar.editable .score-seg { cursor: pointer; }
.score-seg.on { box-shadow: inset 0 0 0 3px #fff; font-size: 15px; opacity: 1; }
.seg1 { background: #ef4444; }
.seg2 { background: #f59e0b; }
.seg3 { background: #f59e0b; }
.seg4 { background: #f59e0b; }
.seg5 { background: #10b981; }
.score-label-row { display: flex; justify-content: space-between; margin-top: 4px; font-size: 12px; }
.label-bad { color: #ef4444; }
.label-good { color: #10b981; }
/* 图片放大弹窗 */
.img-modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 9999;
    display: none; flex-direction: column; align-items: center; justify-content: center; padding: 16px;
}
.img-modal.show { display: flex; }
.img-modal img { max-width: 90%; max-height: 75vh; border-radius: 8px; }
.modal-btn-row { margin-top: 16px; display: flex; gap: 12px; }
/* 编辑弹窗 */
.edit-modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 9998;
    display: none; align-items: center; justify-content: center; padding: 16px;
}
.edit-modal.show { display: flex; }
.edit-box { width: 100%; max-width: 520px; background: #fff; border-radius: 18px; padding: 20px; max-height: 90vh; overflow-y: auto; }
.edit-box h3 { margin-bottom: 14px; }
.edit-row { margin-bottom: 12px; }
.edit-row label { display: block; margin-bottom: 6px; font-size: 14px; color: #444; }
/* 信箱弹窗 */
.mail-modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 9997;
    display: none; align-items: center; justify-content: center; padding: 16px;
}
.mail-modal.show { display: flex; }
.mail-box {
    width: 100%; max-width: 560px; max-height: 78vh; background: #fff;
    border-radius: 18px; display: flex; flex-direction: column; overflow: hidden;
}
.mail-box-head {
    display: flex; align-items: center; gap: 8px; padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
}
.mail-box-head h3 { flex: 1; font-size: 16px; }
.mail-body { padding: 8px 0; overflow-y: auto; }
.mail-item {
    display: flex; gap: 10px; padding: 12px 16px;
    border-bottom: 1px solid #f1f3f8; cursor: pointer; position: relative;
}
.mail-item.unread { background: #f8faff; }
.mail-item.unread .mail-item-title { font-weight: 700; }
.mail-item .n-dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--red-dot);
    flex: 0 0 8px; margin-top: 6px;
}
.mail-item .n-dot.hide { visibility: hidden; }
.mail-item-title { font-size: 14px; margin-bottom: 4px; }
.mail-item-text { font-size: 13px; color: #4b5563; line-height: 1.5; }
.mail-item-time { font-size: 11px; color: #9ca3af; margin-top: 4px; }
.mail-empty { text-align: center; color: var(--text-muted); padding: 30px 0; font-size: 14px; }
/* 同步状态 & 提示 */
.sync-state {
    position: absolute; left: 0; top: 12px; font-size: 12px; color: var(--text-muted);
    display: inline-flex; align-items: center; gap: 5px;
}
.sync-state.offline { color: var(--danger); }
.toast {
    position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
    background: rgba(31,41,55,.94); color: #fff; padding: 12px 18px; border-radius: 12px;
    font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 10000;
    max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: rgba(185,28,28,.95); }

/* ==================== 登录 / 注册 ==================== */
.auth-screen{position:fixed;inset:0;z-index:10000;display:none;align-items:center;justify-content:center;padding:20px;overflow-y:auto;
  background:linear-gradient(160deg,#eef2ff 0%,#ffffff 45%,#fdf2f8 100%)}
.auth-screen.show{display:flex}
.auth-box{width:100%;max-width:380px;background:#fff;border-radius:22px;padding:28px 22px 24px;
  box-shadow:0 18px 50px rgba(31,41,55,.14);border:1px solid var(--border-color,#e5e7eb)}
.auth-logo{text-align:center;font-size:44px;line-height:1;margin-bottom:6px}
.auth-title{text-align:center;font-size:23px;font-weight:800;letter-spacing:1px;margin:0}
.auth-sub{text-align:center;color:#6b7280;font-size:13px;margin:6px 0 18px}
.auth-tabs{display:flex;background:#f3f4f6;border-radius:12px;padding:4px;margin-bottom:16px}
.auth-tab{flex:1;text-align:center;padding:9px 0;border-radius:9px;font-size:14px;font-weight:600;color:#6b7280;cursor:pointer;transition:.15s}
.auth-tab.active{background:#fff;color:#4f46e5;box-shadow:0 2px 8px rgba(0,0,0,.08)}
.auth-field{margin-bottom:12px}
.auth-field label{display:block;font-size:13px;color:#4b5563;margin-bottom:6px;font-weight:600}
.auth-field input{width:100%;padding:13px 14px;font-size:16px;border:1px solid #e5e7eb;border-radius:12px;
  outline:none;background:#fafafa;transition:.2s;color:#1f2937;box-sizing:border-box}
.auth-field input:focus{border-color:#4f46e5;background:#fff}
.auth-roles{display:flex;gap:10px}
.auth-role{flex:1;text-align:center;padding:12px 6px;border:2px solid #e5e7eb;border-radius:12px;
  font-size:14px;font-weight:600;cursor:pointer;color:#4b5563}
.auth-role.active{border-color:#4f46e5;background:#f0f4ff;color:#4f46e5}
.auth-msg{min-height:20px;font-size:13px;color:#ef4444;margin:2px 0 10px;line-height:1.5;text-align:center}
.auth-msg.ok{color:#10b981}
.auth-btn{width:100%;padding:14px;font-size:16px;font-weight:700;border-radius:13px;background:#4f46e5;
  color:#fff;border:none;cursor:pointer}
.auth-btn:active{opacity:.88}
.auth-btn:disabled{opacity:.55;cursor:not-allowed}
.auth-tip{text-align:center;font-size:12px;color:#9ca3af;margin-top:14px;line-height:1.6}
.log-by{font-size:11px;color:#9ca3af;margin-left:6px}

/* 邀请码 */
.invite-hint{font-size:13px;color:#6b7280;line-height:1.6;margin:0}
.invite-tip{font-size:12px;color:#9ca3af;margin:8px 0 0;min-height:16px}
#inviteCodeBox{font-weight:700;letter-spacing:2px;font-size:18px;text-align:center;background:#f8fafc}
