*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%;font-family:Georgia,"Palatino Linotype","Book Antiqua",Palatino,"PingFang SC","Microsoft YaHei","微软雅黑",serif;background:#f7f7f8;color:#111;overflow:hidden}
body{display:flex;flex-direction:column;height:100vh;max-width:720px;margin:0 auto;position:relative}

/* === 顶栏 === */
header{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;background:#fff;border-bottom:1px solid #e5e5e5;position:relative;z-index:20;min-height:48px}
header .left{display:flex;align-items:center;gap:8px}
header button{background:none;border:none;font-size:22px;cursor:pointer;padding:6px 10px;border-radius:8px;color:#333;line-height:1}
header button:hover{background:#f0f0f0}
#learn-status{font-size:12px;color:#999;padding:4px 8px;border-radius:6px}
#learn-status.ok{color:#0a7}
#learn-status.pending{color:#999}
#learn-status.running{color:#f39c12}
#learn-status.fail{color:#e74c3c}

/* === 聊天区（气泡 - ChatGPT 最新版）=== */
#log{flex:1;min-height:0;max-height:100%;overflow-y:auto;padding:16px 8px 80px 8px;line-height:1.6;word-wrap:break-word;position:relative;background:#f7f7f8}
.msg{margin:12px 0;max-width:80%;font-size:15px;white-space:pre-wrap}


.msg.sys{color:#999;font-size:12px;text-align:center;margin:16px 0;background:transparent;max-width:100%}

/* === 底部输入区 === */
footer{position:fixed;bottom:0;left:0;right:0;max-width:720px;margin:0 auto;background:#fff;border-top:1px solid #e5e5e5;padding:10px 12px;padding-bottom:calc(10px + env(safe-area-inset-bottom));z-index:30;box-sizing:border-box}
#input-row{display:flex;align-items:flex-end;gap:8px}
#btn-plus{background:none;border:none;font-size:24px;cursor:pointer;padding:4px 8px;color:#666;line-height:1;flex-shrink:0}
#btn-plus:hover{color:#0a7}
#inp{flex:1;padding:10px 14px;font-size:16px;border:1px solid #ddd;border-radius:22px;outline:none;resize:none;max-height:120px;font-family:inherit;background:#f7f7f8}
#inp:focus{border-color:#0a7;background:#fff}
#btn-send{padding:8px 16px;font-size:13px;background:#fff;color:#333;border:1px solid #e5e5e5;border-radius:20px;cursor:pointer;font-family:inherit;display:none;transition:all .15s;box-shadow:0 1px 3px rgba(0,0,0,.08),0 1px 2px rgba(0,0,0,.06)}
#btn-send.visible{display:block}
#btn-send:disabled{color:#999;cursor:not-allowed;box-shadow:0 1px 2px rgba(0,0,0,.05)}

/* === 抽屉（布局 D）=== */
#drawer-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,.4);z-index:40;opacity:0;transition:opacity .25s;pointer-events:none}
#drawer-backdrop.open{opacity:1;pointer-events:auto}

#conv-drawer{position:fixed;top:0;left:0;bottom:0;width:82%;max-width:360px;background:#fff;z-index:50;transform:translateX(-100%);transition:transform .25s;display:flex;flex-direction:column}
#conv-drawer.open{transform:translateX(0)}

/* 搜索 + 两个新建按钮 */
.drawer-top{padding:12px;border-bottom:1px solid #f0f0f0;display:flex;gap:8px;align-items:center}
#conv-search{flex:1;padding:8px 12px;border:1px solid #e5e5e5;border-radius:20px;font-size:14px;outline:none;background:#f7f7f8}
#conv-search:focus{border-color:#0a7;background:#fff}
.btn-new{padding:8px 10px;border:1px solid #e5e5e5;border-radius:20px;background:#fff;cursor:pointer;font-size:14px;color:#333;flex-shrink:0;display:flex;align-items:center;gap:2px}
.btn-new:hover{background:#f0f0f0;border-color:#0a7}
.btn-new:active{background:#e6f4ef}

/* 内容区 */
.drawer-body{flex:1;overflow-y:auto;padding:12px}

/* 卡片 */
.card{background:#fafafa;border-radius:12px;padding:4px 0;margin-bottom:12px;border:1px solid #f0f0f0}
.card .item{padding:12px 16px;cursor:pointer;font-size:14px;color:#333;display:flex;align-items:center;gap:8px;border-bottom:1px solid #f0f0f0}
.card .item:last-child{border-bottom:none}
.card .item:hover{background:#f0f0f0}

/* 历史对话卡片（工作 / 聊天） */
.hist-card{background:#fafafa;border-radius:12px;margin-bottom:12px;border:1px solid #f0f0f0;overflow:hidden;display:flex;flex-direction:column;height:calc(50vh - 140px);min-height:180px}
.hist-card .hist-head{padding:8px 14px;font-size:12px;color:#999;border-bottom:1px solid #f0f0f0;background:#fafafa;flex-shrink:0}
.hist-card .hist-list{flex:1;overflow-y:auto;padding:4px 0}
.hist-card .hist-item{padding:10px 14px;cursor:pointer;font-size:14px;display:flex;justify-content:space-between;align-items:center;gap:8px}
.hist-card .hist-item:hover{background:#f0f0f0}
.hist-card .hist-item.active{background:#e6f4ef;color:#0a7}
.hist-card .hist-item .title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#333}
.hist-card .hist-item .date{font-size:12px;color:#999;flex-shrink:0}
.hist-card .hist-empty{padding:20px;text-align:center;color:#999;font-size:13px}
.hist-card .hist-foot{padding:8px 12px;border-top:1px solid #f0f0f0;flex-shrink:0;display:flex;justify-content:center;align-items:center}

/* 通用操作按钮（iOS 扁平立体） */
.btn-action{padding:8px 16px;font-size:13px;background:#fff;color:#333;border:1px solid #e5e5e5;border-radius:20px;cursor:pointer;font-family:inherit;display:none;transition:all .15s;
box-shadow:0 1px 3px rgba(0,0,0,.08),0 1px 2px rgba(0,0,0,.06);
}
.btn-action.visible{display:inline-block}
.btn-action:hover{transform:translateY(-1px);
box-shadow:0 3px 8px rgba(0,0,0,.12),0 2px 4px rgba(0,0,0,.08);
background:#fafafa}
.btn-action:active{transform:translateY(0);
box-shadow:0 1px 2px rgba(0,0,0,.08);
background:#f5f5f5}
.btn-action:disabled{color:#999;cursor:not-allowed;box-shadow:0 1px 2px rgba(0,0,0,.05)}

/* 胶囊文字按钮（+ chat / + work）—— 同步立体 */
.btn-pill{padding:8px 16px;border:1px solid #e5e5e5;background:#fff;color:#333;font-size:13px;cursor:pointer;border-radius:20px;transition:all .15s;font-family:inherit;
box-shadow:0 1px 3px rgba(0,0,0,.08),0 1px 2px rgba(0,0,0,.06);
}
.btn-pill:hover{transform:translateY(-1px);
box-shadow:0 3px 8px rgba(0,0,0,.12),0 2px 4px rgba(0,0,0,.08);
background:#fafafa}
.btn-pill:active{transform:translateY(0);
box-shadow:0 1px 2px rgba(0,0,0,.08);
background:#f5f5f5}


/* === 全屏页（设置 / 学习日志）=== */
#fullpage{position:fixed;top:0;left:0;right:0;bottom:0;background:#f7f7f8;z-index:60;transform:translateX(100%);transition:transform .25s;display:flex;flex-direction:column;max-width:720px;margin:0 auto}
#fullpage.open{transform:translateX(0)}
#fullpage header{justify-content:flex-start;gap:8px;background:#fff}
/* #fullpage .back removed - see #fullpage-back */
#fullpage h2{font-size:17px;font-weight:600;flex:1}
#fullpage .page-body{flex:1;overflow-y:auto;padding:16px}

/* 设置页卡片 */
.set-card{background:#fff;border:1px solid #f0f0f0;border-radius:12px;padding:16px;margin-bottom:16px}
.set-card label{display:block;font-size:13px;color:#666;margin-bottom:10px}
.set-card .row{display:flex;justify-content:space-between;align-items:center;padding:12px 0;border-bottom:1px solid #f0f0f0}
.set-card .row:last-child{border-bottom:none}
.set-card .row .k{font-size:14px;color:#333}
.set-card .row .v{font-size:14px;color:#666}
.set-card input[type="range"]{width:100%;margin:10px 0}
.set-card .tier-btns{display:flex;gap:8px;margin-top:8px}
.set-card .tier-btns button{flex:1;padding:8px;border:1px solid #e5e5e5;border-radius:8px;background:#fff;font-size:13px;cursor:pointer}
.set-card .tier-btns button.active{background:#e6f4ef;border-color:#0a7;color:#0a7}
.set-card select{width:100%;padding:10px 12px;font-size:14px;border:1px solid #ddd;border-radius:8px;background:#fff;outline:none}
.set-card .hint{font-size:12px;color:#999;margin-top:8px;line-height:1.5}

/* 学习日志页 */
.log-item{background:#fff;border:1px solid #f0f0f0;border-radius:10px;padding:12px 14px;margin-bottom:10px;font-size:14px}
.log-item .row1{display:flex;justify-content:space-between;align-items:center;margin-bottom:6px}
.log-item .row1 .name{color:#333;font-weight:500}
.log-item .row1 .status{font-size:12px;padding:2px 8px;border-radius:6px}
.log-item .row1 .status.ok{background:#e6f4ef;color:#0a7}
.log-item .row1 .status.fail{background:#fee;color:#e74c3c}
.log-item .row1 .status.running{background:#fff4e6;color:#f39c12}
.log-item .row2{font-size:12px;color:#999}

.hidden{display:none !important}

/* 气泡宽度修正（覆盖前面的规则） */
#log 
#log 

/* 搜索按钮 */
#btn-search{padding:8px 16px;font-size:13px;background:#fff;color:#333;border:1px solid #e5e5e5;border-radius:20px;cursor:pointer;font-family:inherit;transition:all .15s;display:none;box-shadow:0 1px 3px rgba(0,0,0,.08),0 1px 2px rgba(0,0,0,.06)}
#btn-search.visible{display:inline-block}
#btn-search:hover{transform:translateY(-1px);box-shadow:0 3px 8px rgba(0,0,0,.12),0 2px 4px rgba(0,0,0,.08);background:#fafafa}
#btn-search:active{transform:translateY(0);box-shadow:0 1px 2px rgba(0,0,0,.08);background:#f5f5f5}

/* 上拉刷新提示 */
#pull-hint{position:absolute;top:8px;left:50%;transform:translateX(-50%);font-size:13px;color:#666;background:#fff;padding:6px 14px;border-radius:16px;box-shadow:0 2px 8px rgba(0,0,0,.08);transition:opacity .15s;pointer-events:none;z-index:5}
#pull-hint.hidden{opacity:0}
#pull-hint.show{opacity:1}

/* ===== iOS 风格 sheet ===== */
#sheet-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,.4);z-index:100;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .2s;pointer-events:none}
#sheet-overlay.show{opacity:1;pointer-events:auto}
#sheet-overlay.hidden{display:none !important}
.sheet{background:#fff;border-radius:13px;width:240px;max-width:80vw;overflow:hidden;box-shadow:0 10px 40px rgba(0,0,0,.2);transform:scale(.95);transition:transform .2s}
#sheet-overlay.show .sheet{transform:scale(1)}
.sheet-title{padding:14px 16px 12px;font-size:13px;font-weight:600;text-align:center;color:#8e8e93;line-height:1.4;word-break:break-word}
.sheet-input{margin:0 16px 16px;padding:8px 10px;font-size:15px;border:0.5px solid #d1d1d6;border-radius:8px;width:calc(100% - 32px);box-sizing:border-box;font-family:inherit;resize:none;outline:none;background:#fafafa}
.sheet-input:focus{border-color:#007aff;background:#fff}
.sheet-btn{display:flex;align-items:center;justify-content:center;width:100%;height:44px;padding:0 16px;font-size:17px;background:none;border:none;border-top:0.5px solid #d1d1d6;color:#007aff;cursor:pointer;font-family:inherit;font-weight:400;box-sizing:border-box;margin:0}
.sheet-btn:active{background:#f2f2f7}
.sheet-btn.destructive{color:#ff3b30}
.sheet-btn.cancel{font-weight:600}
.sheet-row{display:flex;border-top:0.5px solid #d1d1d6}
.sheet-row .sheet-btn{border-top:none;flex:1}
.sheet-row .sheet-btn:first-child{border-right:0.5px solid #d1d1d6}

/* ===== 登录页 ===== */
#login-page{position:fixed;top:0;left:0;right:0;bottom:0;background:#f7f7f8;z-index:200;display:none;align-items:center;justify-content:center}
#login-page.show{display:flex}
.login-card{background:#fff;border-radius:16px;padding:32px 24px;width:280px;max-width:80vw;text-align:center;box-shadow:0 4px 20px rgba(0,0,0,.08)}
.login-card h1{font-size:28px;font-weight:600;margin:0 0 6px;color:#111}
.login-sub{font-size:14px;color:#888;margin:0 0 20px}
#login-pwd{width:100%;box-sizing:border-box;padding:12px 14px;font-size:16px;border:1px solid #ddd;border-radius:10px;outline:none;margin-bottom:12px;background:#fafafa;font-family:inherit}
#login-pwd:focus{border-color:#007aff;background:#fff}
#login-btn{width:100%;padding:12px 14px;font-size:16px;background:#007aff;color:#fff;border:none;border-radius:10px;cursor:pointer;font-family:inherit;font-weight:500}
#login-btn:active{background:#0063cc}
#login-btn:disabled{background:#ccc;cursor:default}
.login-err{color:#e74c3c;font-size:13px;margin:10px 0 0;min-height:18px}

/* ===== 设备失效 / 邀请码 ===== */
#invite-page{position:fixed;top:0;left:0;right:0;bottom:0;background:#f7f7f8;z-index:200;display:none;align-items:center;justify-content:center}
#invite-page.show{display:flex}
#invite-code{width:100%;box-sizing:border-box;padding:12px 14px;font-size:16px;border:1px solid #ddd;border-radius:10px;outline:none;margin-bottom:12px;background:#fafafa;font-family:inherit}
#invite-code:focus{border-color:#007aff;background:#fff}
#invite-btn{width:100%;padding:12px 14px;font-size:16px;background:#007aff;color:#fff;border:none;border-radius:10px;cursor:pointer;font-family:inherit;font-weight:500}
#invite-btn:active{background:#0063cc}
#invite-btn:disabled{background:#ccc;cursor:default}
#disabled-page{position:fixed;top:0;left:0;right:0;bottom:0;background:#f7f7f8;z-index:300;display:none;align-items:center;justify-content:center}
#disabled-page.show{display:flex}
#disabled-page .disabled-inner{font-size:16px;color:#999}

/* ===== 聊天气泡字体（ChatGPT 风） ===== */
#log .msg {
  font-family: ui-sans-serif, -apple-system, system-ui, "Segoe UI", "PingFang SC", Helvetica, "Apple Color Emoji", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol", "Microsoft YaHei", "微软雅黑";
}

/* ===== 聊天气泡字体：强覆盖 ===== */
#log .msg.u,
#log .msg.a {
  font-family: ui-sans-serif, -apple-system, system-ui, "Segoe UI", "PingFang SC", Helvetica, Arial, "Microsoft YaHei", "微软雅黑", sans-serif !important;
}
#log .msg.u *,
#log .msg.a * {
  font-family: inherit !important;
}

/* ===== Back 按钮（手机端 fullpage） ===== */
#fullpage-back {
  display:inline-block;
  padding:6px 14px;
  font-size:14px;
  background:#f2f2f7;
  color:#1c1c1e;
  border:none;
  border-radius:8px;
  cursor:pointer;
  font-family:inherit;
  margin-right:12px;
}
#fullpage-back:hover { background:#e5e5ea; }
#fullpage-back:active { background:#d1d1d6; }


/* ===== Back 按钮（手机端，强制） ===== */
#fullpage-back,
#fullpage .back {
  display: inline-block !important;
  padding: 8px 18px !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  background: #fff !important;
  color: #1c1c1e !important;
  border: 1px solid #e5e5e5 !important;
  border-radius: 20px !important;
  cursor: pointer !important;
  font-family: inherit !important;
  margin-right: 12px !important;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.08),
    0 1px 2px rgba(0, 0, 0, 0.06) !important;
  transition: all 0.15s ease !important;
}
#fullpage-back:hover,
#fullpage .back:hover {
  transform: translateY(-1px) !important;
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.12),
    0 2px 4px rgba(0, 0, 0, 0.08) !important;
  background: #fafafa !important;
}



/* ===== 手机端设置小输入框 ===== */
.set-inp{padding:6px 10px;font-size:14px;border:1px solid #ddd;border-radius:8px;outline:none;font-family:inherit;background:#fafafa}
.set-inp:focus{border-color:#0a7;background:#fff}
.set-btn{padding:8px 16px;font-size:14px;background:#007aff;color:#fff;border:none;border-radius:8px;cursor:pointer;font-family:inherit}
.set-btn:hover{background:#0066cc}

/* ===== iMessage 风格聊天气泡 ===== */
#log .msg {
  font-family: ui-sans-serif, -apple-system, system-ui, "Segoe UI", "PingFang SC", Helvetica, Arial, "Microsoft YaHei", "微软雅黑", sans-serif !important;
}
#log .msg.u,
#log .msg.a {
  display: inline-block;
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 20px;
  font-size: 16px;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
  margin-bottom: 4px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.03);
}
#log .msg.u {
  align-self: flex-end;
  margin-left: auto;
  margin-right: 4px;
  background: #007aff;
  color: #fff;
  border-bottom-right-radius: 6px;
}
#log .msg.a {
  align-self: flex-start;
  margin-left: 4px;
  margin-right: auto;
  background: #e9e9eb;
  color: #111;
  border-bottom-left-radius: 6px;
}
/* 同一个人连发多条时的小间距 */
#log .msg.u + .msg.u,
#log .msg.a + .msg.a {
  margin-top: 2px;
}
/* 切换发送者时大一点 */
#log .msg.u + .msg.a,
#log .msg.a + .msg.u {
  margin-top: 8px;
}

/* ===== 修复 #messages 的 flex 布局 ===== */
#messages {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
}
#messages .msg {
  flex: 0 0 auto;
}


/* 数字外面框缩小 */
#ctx-val {
  width: 48px !important;
  padding: 6px 4px !important;
  text-align: center;
}

/* select 缩窄 */
#ctx-val {
  width: 52px !important;
  padding: 6px 2px !important;
  text-align: center !important;
}
/* 下拉选项也等宽 */
#ctx-val option {
  font-family: "SF Mono", "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
}

/* 隐藏时间控件自带的时钟图标 */
input[type="time"]::-webkit-calendar-picker-indicator {
  display: none;
  -webkit-appearance: none;
}
input[type="time"] {
  -webkit-appearance: none;
  -moz-appearance: textfield;
}

/* select 的自定义箭头 */
select.set-inp {
  padding-right: 20px !important;
  text-align: center !important;
  text-align-last: center !important;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%238e8e93' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 8px;
}

/* 各控件宽度 */
#ctx-val { width: 54px !important; }
#nudge-day-start, #nudge-night-start { width: 90px !important; }
#nudge-day-max, #nudge-night-max { width: 88px !important; }
#nudge-min-gap, #nudge-check { width: 70px !important; }

/* 时间：iOS 上点击弹系统滚轮；图标隐藏 */
input[type="time"]::-webkit-calendar-picker-indicator {
  display: none;
  -webkit-appearance: none;
}
input[type="time"] {
  -webkit-appearance: none;
  text-align: center !important;
}

/* option 高度控制 */
select.set-inp option {
  font-size: 14px;
  padding: 4px;
  text-align: center;
}

/* 输入框内数字居中 */
.set-inp[type="number"] {
  text-align: center !important;
}

/* ============================================
   设置页控件：iOS 风统一样式
   ============================================ */

/* 基础：所有 .set-inp 统一 */
.set-inp {
  font-family: Georgia, "Palatino Linotype", "Book Antiqua", Palatino, "PingFang SC", "Microsoft YaHei", serif !important;
  font-variant-numeric: lining-nums;
  font-feature-settings: "lnum" 1, "tnum" 1;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  border: 1px solid #d1d1d6;
  border-radius: 10px;
  background: #fff;
  color: #1c1c1e;
  padding: 6px 8px !important;
  box-sizing: border-box;
  text-align: center !important;
  font-size: 15px;
  line-height: 1.2;
  height: 34px;
  outline: none;
}
.set-inp:focus {
  border-color: #007aff;
}

/* select：自定义箭头 */
select.set-inp {
  padding-right: 24px !important;
  text-align-last: center !important;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%238e8e93' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 9px;
}

/* 宽度（按内容精调） */
#ctx-val { width: 56px !important; }
#nudge-day-start, #nudge-night-start { width: 92px !important; }
#nudge-day-max, #nudge-night-max { width: 92px !important; }
#nudge-min-gap, #nudge-check { width: 72px !important; }

/* 时间下拉：宽点，让 "09:00" 完整显示 */
.time-select { width: 92px !important; }

/* 数字输入框 */
.set-inp[type="number"] {
  text-align: center !important;
}

/* select option：iOS 列表风 */
select.set-inp option {
  font-family: Georgia, "Palatino Linotype", "Book Antiqua", Palatino, "PingFang SC", "Microsoft YaHei", serif;
  font-size: 15px;
  padding: 8px;
}

/* ============================================
   档位标签
   ============================================ */
#ctx-tokens {
  color: #8e8e93;
  font-size: 13px;
  font-weight: 400;
}

/* iOS Toggle Switch */
.ios-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.ios-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.ios-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #e9e9ea;
  transition: .3s;
  border-radius: 24px;
}
.ios-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.ios-switch input:checked + .ios-slider {
  background-color: #34c759; /* iOS 经典绿色 */
}
.ios-switch input:checked + .ios-slider:before {
  transform: translateX(20px);
}

/* 移除原生 select 箭头并居中文本 */
.clean-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: none !important;
  text-align: center;
  text-align-last: center;
  padding-right: 8px !important; /* 消除原生箭头的右侧占位 */
  cursor: pointer;
}
.clean-select::-ms-expand {
  display: none;
}

/* clean-select 数字绝对居中 */
select.clean-select {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background-image: none !important;
  text-align: center !important;
  text-align-last: center !important;
  padding: 4px 10px !important;
  border-radius: 6px;
  border: 1px solid #e5e5ea;
  background-color: #fff;
  cursor: pointer;
}
select.clean-select::-ms-expand {
  display: none;
}

/* Settings 顶部 Header 布局（Back, Settings 标题, Save） */
.set-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.set-header-btn {
  padding: 6px 14px;
  border-radius: 16px;
  border: 1px solid #e5e5ea;
  background: #ffffff;
  font-size: 14px;
  font-weight: 500;
  color: #007aff;
  cursor: pointer;
}
.set-header-btn:active {
  opacity: 0.7;
}

/* Save 按钮点击下沉反馈 */
#fullpage-save:active {
  transform: scale(0.96);
  box-shadow: 0 1px 4px rgba(0, 122, 255, 0.2) !important;
}

/* iOS Bottom Sheet 遮罩 */
.ios-sheet-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.ios-sheet-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* iOS Bottom Sheet 容器 */
.ios-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 75vh;
  background: #ffffff;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  z-index: 1001;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
}
.ios-sheet.show {
  transform: translateY(0);
}

/* Handle 顶部拖拽条 */
.ios-sheet-handle {
  width: 36px;
  height: 5px;
  background: #e0e0e0;
  border-radius: 3px;
  margin: 8px auto 4px auto;
}

.ios-sheet-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 0.5px solid #e5e5ea;
}
.ios-sheet-title {
  font-size: 17px;
  font-weight: 600;
  color: #000;
}
.ios-sheet-search {
  padding: 10px 16px;
}
.ios-sheet-search-inp {
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  border: none;
  background: #7676801f;
  font-size: 15px;
  outline: none;
}
.ios-sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
}
.ios-sheet-item {
  padding: 12px 8px;
  border-bottom: 0.5px solid #f2f2f7;
  font-size: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.ios-sheet-item:active {
  background: #f2f2f7;
  border-radius: 8px;
}

/* ====== Todo 详情 Modal（居中） ====== */
.todo-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 900;
}
.todo-modal-card {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px;
  max-width: 85vw;
  min-width: 280px;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 901;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  text-align: center;
  font-variant-numeric: lining-nums;
  font-feature-settings: "lnum" 1, "tnum" 1;
}
.todo-modal-card .t-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
}
.todo-modal-card .t-desc {
  font-size: 15px;
  color: #333;
  line-height: 1.5;
  margin-bottom: 20px;
  white-space: pre-wrap;
}
.todo-modal-card .t-line3 {
  font-size: 13px;
  color: #8e8e93;
  margin-bottom: 8px;
}
.todo-modal-card .t-freq {
  font-size: 13px;
  color: #8e8e93;
}

/* ====== Todo Form（编辑 / 频率 sheet） ====== */
.todo-form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #f2f2f7;
}
.todo-form-row:last-of-type {
  border-bottom: none;
}
.todo-form-label {
  font-size: 14px;
  color: #1c1c1e;
  flex: 1;
  min-width: 0;
  padding-right: 8px;
}
.todo-form-input {
  width: 72px;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid #d1d1d6;
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
  background: #fff;
  color: #1c1c1e;
  font-variant-numeric: lining-nums;
  font-feature-settings: "lnum" 1, "tnum" 1;
  appearance: none;
  -webkit-appearance: none;
}
.todo-form-input:focus {
  outline: none;
  border-color: #007aff;
}
.todo-form-block {
  padding: 14px 16px;
  border-bottom: 1px solid #f2f2f7;
}
.todo-form-block:last-of-type {
  border-bottom: none;
}
.todo-form-block .todo-form-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: #8e8e93;
}
.todo-form-block .todo-form-input {
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  padding: 8px 10px;
}

/* 让 text/number input 也全宽 */
.todo-form-block input.todo-form-input {
  width: 100%;
  text-align: left;
}

/* iOS 风格日期选择器（隐藏原生黑框） */
.todo-form-block input[type="datetime-local"].todo-form-input {
  appearance: none;
  -webkit-appearance: none;
  font-size: 15px;
  color: #1c1c1e;
  background: #f2f2f7;
  border: 1px solid #e5e5ea;
  border-radius: 10px;
  padding: 12px 14px;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-variant-numeric: lining-nums;
  font-feature-settings: "lnum" 1, "tnum" 1;
}
.todo-form-block input[type="datetime-local"].todo-form-input::-webkit-calendar-picker-indicator {
  filter: invert(0.5);
  cursor: pointer;
}
.todo-form-block textarea.todo-form-input {
  width: 100%;
  box-sizing: border-box;
  min-height: 64px;
  text-align: left;
  resize: vertical;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-variant-numeric: lining-nums;
  font-feature-settings: "lnum" 1, "tnum" 1;
}

/* ====== 引用条 ====== */
.quote-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f2f2f7;
  border-top: 1px solid #e5e5ea;
  font-size: 13px;
}
.quote-bar-inner {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.quote-bar-label {
  color: #007aff;
  font-weight: 500;
  flex-shrink: 0;
}
.quote-bar-text {
  color: #8e8e93;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.quote-bar-close {
  border: none;
  background: #d1d1d6;
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

/* ====== 消息 wrapper（引用块 + 气泡） ====== */
.msg-wrap {
  display: flex;
  flex-direction: column;
  margin: 6px 12px;
  max-width: calc(100% - 24px);
}
.msg-wrap.u {
  align-items: flex-end;
  align-self: flex-end;
  margin-left: auto;
}
.msg-wrap.a {
  align-items: flex-start;
  align-self: flex-start;
  margin-right: auto;
}

/* 引用块（气泡上方，独立灰条） */
.msg-quote {
  font-size: 12px;
  color: #8e8e93;
  padding: 4px 10px;
  border-left: 3px solid #c7c7cc;
  background: #f2f2f7;
  border-radius: 6px;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  box-sizing: border-box;
}

/* ====== C2 修复：气泡宽度自适应 ====== */
.msg {
  word-break: normal !important;          /* ← 元凶：break-all 会让短消息被断 */
  overflow-wrap: break-word !important;   /* ← 只在必要时断词 */
  white-space: pre-wrap !important;
  width: fit-content !important;          /* ← 自适应内容宽度 */
  max-width: 78% !important;              /* ← 最大 78% */
}
.msg-wrap {
  max-width: 78% !important;              /* ← 和 .msg 一致，不压缩 */
}

/* ====== iMessage 风格气泡（覆盖前面的） ====== */
.msg-wrap {
  display: flex !important;
  flex-direction: column !important;
  margin: 3px 12px !important;
  max-width: 100% !important;
  width: auto !important;
}
.msg-wrap.u {
  align-items: flex-end !important;
  margin-left: auto !important;
}
.msg-wrap.a {
  align-items: flex-start !important;
  margin-right: auto !important;
}

.msg {
  display: inline-block !important;
  width: fit-content !important;
  max-width: 75% !important;
  padding: 8px 14px !important;
  border-radius: 18px !important;
  font-size: 17px !important;
  line-height: 1.3 !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif !important;
  word-break: normal !important;
  overflow-wrap: break-word !important;
  white-space: pre-wrap !important;
  text-align: left !important;
  box-sizing: border-box !important;
}
.msg.u {
  background: #007aff !important;
  color: #ffffff !important;
  border-bottom-right-radius: 4px !important;
}
.msg.a {
  background: #e9e9eb !important;
  color: #000000 !important;
  border-bottom-left-radius: 4px !important;
}

/* 引用块（iMessage 里没有，但你要）—— 只在用户气泡上方，短条 */
.msg-quote {
  font-size: 13px !important;
  line-height: 1.3 !important;
  color: #8e8e93 !important;
  padding: 4px 10px !important;
  border-left: 3px solid #c7c7cc !important;
  background: #f2f2f7 !important;
  border-radius: 6px !important;
  margin-bottom: 4px !important;
  max-width: 75% !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  box-sizing: border-box !important;
}

/* ====== 气泡宽度精确修复：.msg 不应再用 max-width: 75%（那是相对 .msg-wrap 的） ====== */
.msg {
  max-width: 100% !important;      /* ← 关键：相对 .msg-wrap 撑满 */
}
.msg-wrap {
  max-width: 75% !important;       /* ← 让 .msg-wrap 控制"最大 75% 屏宽" */
}

/* ====== 字体精确对齐 iMessage ====== */
.msg {
  letter-spacing: -0.4px !important;      /* iMessage 有负字距 */
}
.msg-quote {
  font-family: ui-sans-serif, -apple-system, system-ui, "Segoe UI", "PingFang SC", Helvetica, Arial, "Microsoft YaHei", 微软雅黑, sans-serif !important;  /* ← 和气泡同字体栈（无衬线） */
  letter-spacing: -0.2px !important;
}

/* ============================================================
   字体纪律（2026-09-28 定）
   - 系统设定类（UI / 菜单 / 抽屉标题 / 数字）：Georgia + 数字对齐
   - 有具体内容（气泡 / 引用块 / Todos / 日记）：iMessage 无衬线
   ============================================================ */

/* 抽屉对话列表：标题 / 日期 / 数字 → Georgia + 强对齐 */
.hist-item,
.hist-item .date,
.hist-item .title,
#conv-drawer,
#conv-drawer * {
  font-family: Georgia, "Palatino Linotype", "Book Antiqua", Palatino, "PingFang SC", "Microsoft YaHei", serif !important;
  font-variant-numeric: lining-nums !important;
  font-feature-settings: "lnum" 1, "tnum" 1 !important;
}

/* 引用块：内容类 → iMessage 无衬线 */
.msg-quote {
  font-family: ui-sans-serif, -apple-system, system-ui, "Segoe UI", "PingFang SC", Helvetica, Arial, "Microsoft YaHei", "微软雅黑", sans-serif !important;
  font-variant-numeric: normal !important;
  font-feature-settings: normal !important;
}

/* 确保气泡数字也跟着无衬线（内容类） */
#log .msg,
#log .msg * {
  font-variant-numeric: normal !important;
  font-feature-settings: normal !important;
}

/* ============================================================
   输入框悬浮卡片（微信式）
   ============================================================ */
#footer {
  position: fixed;
  bottom: 12px;
  left: 12px;
  right: 12px;
  max-width: 720px;
  margin: 0 auto;
  background: transparent;
  border: none;
  padding: 0;
  z-index: 30;
  box-sizing: border-box;
}

#input-card {
  position: relative;
  background: #ffffff;
  border-radius: 22px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
  padding: 8px 10px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  transition: height 0.3s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.3s, border-radius 0.3s;
}

#input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

#inp {
  flex: 1;
  padding: 8px 14px;
  font-size: 17px;
  line-height: 1.3;
  letter-spacing: -0.4px;
  border: none;
  border-radius: 18px;
  outline: none;
  resize: none;
  max-height: 50vh;
  overflow-y: auto;
  font-family: ui-sans-serif, -apple-system, system-ui, "Segoe UI", "PingFang SC", Helvetica, Arial, "Microsoft YaHei", "微软雅黑", sans-serif;
  background: #f2f2f7;
  color: #1c1c1e;
  box-sizing: border-box;
}

#btn-fullscreen {
  position: absolute;
  top: 6px;
  right: 8px;
  background: rgba(0, 0, 0, 0.05);
  border: none;
  border-radius: 6px;
  font-size: 14px;
  padding: 2px 8px;
  cursor: pointer;
  color: #666;
  z-index: 2;
  line-height: 1.4;
}

/* ============ 全屏模式（保持悬浮卡片，只放大高度） ============ */
body.input-fullscreen #input-card {
  display: flex;
  flex-direction: column;
  /* 高度由 JS 精确控制，平滑过渡 */
}

body.input-fullscreen #inp {
  flex: 1;
  max-height: none;
  height: auto !important;
}

body.input-fullscreen #input-actions {
  flex-shrink: 0;
  margin-top: 8px;
}

body.input-fullscreen header,
body.input-fullscreen #log,
body.input-fullscreen #learn-status,
body.input-fullscreen #pull-hint {
  display: none !important;
}

/* ============================================================
   输入框布局修正（inp 全宽 + 按钮下一栏）
   ============================================================ */
#inp {
  width: 100% !important;
  box-sizing: border-box !important;
}
#input-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 0 4px;
}
#input-actions #btn-send {
  margin-left: auto;
}

/* 全屏模式：inp 铺满，按钮行在下 */
body.input-fullscreen #input-card {
  display: flex !important;
  flex-direction: column !important;
}
body.input-fullscreen #inp {
  flex: 1 !important;
  width: 100% !important;
  height: auto !important;
  max-height: none !important;
  margin-bottom: 6px;
}
body.input-fullscreen #input-actions {
  flex-shrink: 0;
  margin-top: auto;
}

/* 工具调用显示 */
.tool-call {
  font-size: 13px;
  color: #8e8e93;
  padding: 4px 10px;
  background: #f2f2f7;
  border-radius: 6px;
  margin: 4px 12px;
  align-self: flex-start;
  max-width: 78%;
  font-family: ui-sans-serif, -apple-system, sans-serif;
}
.tool-result {
  font-size: 12px;
  color: #8e8e93;
  padding: 2px 10px;
  margin: 0 12px 4px 12px;
  align-self: flex-start;
}

/* 工具调用显示 */
.tool-call {
  font-size: 13px;
  color: #8e8e93;
  padding: 4px 10px;
  background: #f2f2f7;
  border-radius: 6px;
  margin: 4px 12px;
  align-self: flex-start;
  max-width: 78%;
  font-family: ui-sans-serif, -apple-system, sans-serif;
}
.tool-result {
  font-size: 12px;
  color: #8e8e93;
  padding: 2px 10px;
  margin: 0 12px 4px 12px;
  align-self: flex-start;
}

/* 工具调用显示 */
.tool-call {
  font-size: 13px;
  color: #8e8e93;
  padding: 4px 10px;
  background: #f2f2f7;
  border-radius: 6px;
  margin: 4px 12px;
  align-self: flex-start;
  max-width: 78%;
  font-family: ui-sans-serif, -apple-system, sans-serif;
}
.tool-result {
  font-size: 12px;
  color: #8e8e93;
  padding: 2px 10px;
  margin: 0 12px 4px 12px;
  align-self: flex-start;
}

/* 菜单右对齐（Todos 长按） */
.sheet.sheet-right .sheet-btn {
  text-align: right !important;
  padding-right: 24px !important;
}

/* ============================================================
   Todos 菜单：居中 + 紧凑框
   ============================================================ */
.sheet.sheet-right .sheet-btn {
  text-align: center !important;
  padding-right: 16px !important;
  padding-left: 16px !important;
}

/* Todos 长按 sheet 紧凑（通过 :has 匹配含菜单项的 sheet） */
.sheet:has(.sheet-btn) .sheet-btn {
  padding: 12px 16px !important;
  font-size: 16px !important;
  text-align: center !important;
}

/* ============================================================
   Todos 菜单：窄框
   ============================================================ */
#sheet-overlay .sheet {
  max-width: 260px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}
#sheet-overlay .sheet .sheet-btn {
  padding: 12px 16px !important;
  font-size: 16px !important;
  text-align: center !important;
}

/* ====== Logs：按日期分组 ====== */
.log-day {
  margin: 16px 12px;
  background: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.log-day-title {
  font-size: 15px;
  font-weight: 600;
  color: #1c1c1e;
  padding-bottom: 8px;
  border-bottom: 0.5px solid #e5e5ea;
  margin-bottom: 8px;
  font-family: Georgia, "Palatino Linotype", "Book Antiqua", Palatino, "PingFang SC", "Microsoft YaHei", serif;
}
.log-day-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.log-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: #333;
}
.log-row .status {
  font-size: 13px;
  color: #34c759;
}
.log-row .status.fail {
  color: #ff3b30;
}

/* ============================================================
   【字体纪律 · 全局】2026-09-28 定
   - 系统文字：Georgia + 数字强对齐
   - 内容文字（气泡 / 引用块 / 工具调用）：iMessage 无衬线 + normal
   ============================================================ */

/* ① 全局默认：系统文字 = Georgia + 数字强对齐 */
html, body {
  font-family: Georgia, "Palatino Linotype", "Book Antiqua", Palatino, "PingFang SC", "Microsoft YaHei", 微软雅黑, serif !important;
  font-variant-numeric: lining-nums !important;
  font-feature-settings: "lnum" 1, "tnum" 1 !important;
}

/* 所有子元素继承数字对齐（除非内容类显式覆盖） */
* {
  font-variant-numeric: inherit;
  font-feature-settings: inherit;
}

/* ② 内容类反向覆盖：无衬线 + normal numbers */
#log .msg,
#log .msg *,
.msg-quote,
.msg-quote *,
.tool-call,
.tool-result,
.todo-card *,
.msg-wrap.u .msg,
.msg-wrap.a .msg {
  font-family: ui-sans-serif, -apple-system, system-ui, "Segoe UI", "PingFang SC", Helvetica, Arial, "Microsoft YaHei", 微软雅黑, sans-serif !important;
  font-variant-numeric: normal !important;
  font-feature-settings: normal !important;
}

/* ③ 明确系统类：Georgia + 数字对齐（防止被 :has / :is 误覆盖） */
#conv-drawer,
#conv-drawer *,
.hist-item,
.hist-item *,
.log-day,
.log-day *,
.log-row,
.log-row *,
.set-card,
.set-card *,
.sheet,
.sheet *,
nav,
nav *,
#settings-nav,
#settings-nav *,
#settings-content,
#settings-content *,
#admin-content,
#admin-content * {
  font-variant-numeric: lining-nums !important;
  font-feature-settings: "lnum" 1, "tnum" 1 !important;
}

/* Logs 状态标签：文字版 */
.log-status {
  font-size: 13px;
  font-weight: 500;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.log-status.ok      { color: #34c759; }
.log-status.fail    { color: #ff3b30; }
.log-status.running { color: #ff9500; }

/* Logs 行：状态左 + 文字右 */
.log-row {
  display: flex !important;
  justify-content: flex-start !important;
  align-items: center !important;
  gap: 10px !important;
}
.log-status {
  flex-shrink: 0;
  min-width: 96px;
}
.log-row > span:not(.log-status) {
  color: #1c1c1e;
}

.archived-tag {
  color: #34c759;
  font-weight: normal;
  margin-right: 2px;
}

/* 图片消息 */
.msg-image {
  max-width: 100%;
  max-height: 320px;
  border-radius: 10px;
  display: block;
  cursor: pointer;
}

/* 用户缩略图（气泡上方，右对齐） */
.msg-thumbs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin: 4px 12px 6px 0;
}
.msg-thumbs img {
  max-width: 100px;
  max-height: 100px;
  border-radius: 10px;
  cursor: pointer;
  object-fit: cover;
}

/* AI 大图（气泡下方） */
.msg-images {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 12px 6px 0;
  max-width: 80%;
}
.msg-images img {
  max-width: 100%;
  border-radius: 12px;
  cursor: pointer;
}

/* 联网搜索按钮 */
#btn-web {
  background: transparent;
  border: none;
  font-size: 20px;
  padding: 4px 8px;
  cursor: pointer;
  opacity: 0.35;
  filter: grayscale(1);
  transition: opacity 0.15s, filter 0.15s;
}
#btn-web.active {
  opacity: 1;
  filter: none;
}

/* 启动遮罩 */
#boot-loading {
  position: fixed;
  inset: 0;
  background: #f7f7f8;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  opacity: 1;
  transition: opacity 0.25s;
}
#boot-loading.hide {
  opacity: 0;
  pointer-events: none;
}
.boot-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #dcdce0;
  border-top-color: #007aff;
  border-radius: 50%;
  animation: boot-spin 0.8s linear infinite;
}
@keyframes boot-spin {
  to { transform: rotate(360deg); }
}
.boot-text {
  font-size: 13px;
  color: #8e8e93;
}
