/* ============================================================
   hwj-workapp 样式
   单文件，无外部依赖（不引 CDN，离线也能用）
   ============================================================ */

:root {
  --bg:            #0f1115;
  --bg-elev:       #161a21;
  --bg-elev-2:     #1c212a;
  --bg-hover:      #222834;
  --border:        #262c38;
  --border-soft:   #1f242e;
  --text:          #e6e9ef;
  --text-dim:      #9aa3b2;
  --text-faint:    #6b7382;
  --accent:        #5b8def;
  --accent-soft:   rgba(91, 141, 239, .14);
  --green:         #2fb344;
  --green-soft:    rgba(47, 179, 68, .14);
  --amber:         #f59f00;
  --amber-soft:    rgba(245, 159, 0, .14);
  --red:           #e03131;
  --red-soft:      rgba(224, 49, 49, .14);
  --purple:        #9775fa;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 8px 28px rgba(0, 0, 0, .42);
  --sidebar-w:     232px;
}

[data-theme="light"] {
  --bg:            #f5f6f8;
  --bg-elev:       #ffffff;
  --bg-elev-2:     #f0f2f5;
  --bg-hover:      #e9ecf1;
  --border:        #e2e5ea;
  --border-soft:   #edeff3;
  --text:          #1a1d23;
  --text-dim:      #5c6472;
  --text-faint:    #8b93a1;
  --accent:        #3b6fd4;
  --accent-soft:   rgba(59, 111, 212, .10);
  --green:         #2b9e3c;
  --green-soft:    rgba(43, 158, 60, .12);
  --amber:         #d98a00;
  --amber-soft:    rgba(217, 138, 0, .12);
  --red:           #d32f2f;
  --red-soft:      rgba(211, 47, 47, .10);
  --shadow:        0 6px 22px rgba(16, 24, 40, .10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button { cursor: pointer; border: none; background: none; }

a { color: var(--accent); text-decoration: none; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ============================================================ 布局 */

/* 视口单位：先写 vh 兼容老浏览器，再用 dvh 覆盖。手机浏览器地址栏收放时
   dvh 才是「真正可见的高度」，否则底部内容会一直被地址栏盖住。 */
.layout { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  /* 刘海屏：抽屉顶部让开状态栏，底部让开 home 指示条 */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
}

.brand {
  padding: 20px 18px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: grid; place-items: center;
  font-size: 16px;
  flex: 0 0 32px;
}

.brand-name { font-weight: 650; font-size: 15px; letter-spacing: .2px; }
.brand-sub  { font-size: 11px; color: var(--text-faint); }

.nav { padding: 4px 10px; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13.5px;
  transition: background .14s, color .14s;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text); }

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-item .icon { width: 17px; height: 17px; flex: 0 0 17px; }
.nav-badge {
  margin-left: auto;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 20px;
  background: var(--bg-elev-2);
  color: var(--text-faint);
  font-weight: 500;
}

.nav-item.active .nav-badge { background: var(--accent); color: #fff; }

.sidebar-foot {
  margin-top: auto;
  padding: 12px 14px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.side-btn {
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
  width: 100%;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 12.5px;
  transition: background .14s, color .14s;
}
.side-btn:hover { background: var(--bg-hover); color: var(--text); }
.side-btn .icon { width: 15px; height: 15px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 16px 26px;
  /* 刘海屏：顶栏要让开状态栏，横屏时再让开左右缺口 */
  padding-top: calc(16px + env(safe-area-inset-top));
  padding-left: calc(26px + env(safe-area-inset-left));
  padding-right: calc(26px + env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar h1 { font-size: 19px; font-weight: 650; letter-spacing: .2px; }
.topbar .sub { font-size: 12.5px; color: var(--text-faint); margin-top: 1px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.content {
  padding: 22px 26px 64px;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  padding-left: calc(26px + env(safe-area-inset-left));
  padding-right: calc(26px + env(safe-area-inset-right));
  flex: 1;
}

/* ============================================================ 通用组件 */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  transition: background .14s, border-color .14s, opacity .14s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 550; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 86%, #fff); }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-wrap: anywhere;
}

.card-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px;
}
.card-head h2 { font-size: 14px; font-weight: 620; }
.card-head .count { font-size: 12px; color: var(--text-faint); }
.card-head .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }

/* 默认单列：必须写 minmax(0,1fr)。只写 display:grid 时隐式列按 auto 撑到
   max-content，卡片会被内容顶宽，导致整页横向滚动。 */
.grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-dash { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }
/* 网格子项允许收缩，长文本才不会顶破布局 */
.grid > *, .grid-dash > * { min-width: 0; }

/* 纵向堆叠容器。同样必须显式给 minmax(0,1fr)，否则隐式列会被内容撑宽 */
.stack { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.stack > * { min-width: 0; }
.stack-sm { gap: 10px; }

.input, .textarea, .select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .14s, box-shadow .14s;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.select { cursor: pointer; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; }
.field label { font-size: 12px; color: var(--text-dim); font-weight: 550; }
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  white-space: nowrap;
}
.chip-dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 6px; }
.chip-red   { background: var(--red-soft);   color: var(--red); }
.chip-amber { background: var(--amber-soft); color: var(--amber); }
.chip-green { background: var(--green-soft); color: var(--green); }
.chip-accent{ background: var(--accent-soft);color: var(--accent); }

.icon { display: block; width: 16px; height: 16px; flex: 0 0 auto; }
.icon-btn {
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 6px;
  color: var(--text-faint);
  transition: background .14s, color .14s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn .icon { width: 15px; height: 15px; }

/* 侧边栏图标 */

.empty {
  text-align: center;
  padding: 34px 16px;
  color: var(--text-faint);
  font-size: 13px;
}
.empty .big { font-size: 26px; display: block; margin-bottom: 8px; opacity: .7; }

/* ============================================================ 统计卡 */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }

.stat {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent); opacity: .85;
}
.stat.s-green::after { background: var(--green); }
.stat.s-amber::after { background: var(--amber); }
.stat.s-red::after   { background: var(--red); }
.stat-label { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 5px; }
.stat-value { font-size: 26px; font-weight: 660; margin-top: 5px; letter-spacing: -.5px; line-height: 1.15; }
.stat-foot { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; }

/* ============================================================ 趋势图 */

.chart { display: flex; align-items: flex-end; gap: 4px; height: 116px; padding-top: 6px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.chart-bars { display: flex; gap: 2px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.chart-bar {
  width: 42%; max-width: 11px;
  border-radius: 3px 3px 1px 1px;
  min-height: 2px;
  transition: opacity .14s;
}
.chart-bar.created { background: var(--accent); opacity: .55; }
.chart-bar.done    { background: var(--green); }
.chart-col:hover .chart-bar { opacity: 1; }
.chart-x { font-size: 9.5px; color: var(--text-faint); white-space: nowrap; }
.chart-legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--text-dim); margin-top: 10px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 5px; }

/* ============================================================ 待办列表 */

.task-list { display: flex; flex-direction: column; }

.task {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--border-soft);
  transition: background .12s;
  cursor: pointer;
}
.task:last-child { border-bottom: none; }
.task:hover { background: var(--bg-hover); }

.task-check {
  flex: 0 0 17px;
  width: 17px; height: 17px;
  margin-top: 2px;
  border: 1.6px solid var(--text-faint);
  border-radius: 5px;
  display: grid; place-items: center;
  transition: background .14s, border-color .14s;
}
.task-check:hover { border-color: var(--green); }
.task-check svg { width: 11px; height: 11px; color: #fff; opacity: 0; transition: opacity .14s; }
.task.done .task-check { background: var(--green); border-color: var(--green); }
.task.done .task-check svg { opacity: 1; }
.task.doing .task-check { border-color: var(--amber); }

.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 13.5px; word-break: break-word; }
.task.done .task-title { color: var(--text-faint); text-decoration: line-through; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 5px; }
.task-notes { font-size: 12px; color: var(--text-faint); margin-top: 3px; white-space: pre-wrap; word-break: break-word; }
.task-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .14s; }
.task:hover .task-actions { opacity: 1; }
.task-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.prio { width: 3px; align-self: stretch; border-radius: 2px; flex: 0 0 3px; min-height: 18px; }
.prio-1 { background: var(--red); }
.prio-2 { background: transparent; }
.prio-3 { background: transparent; }

.quick-add { display: flex; gap: 9px; margin-bottom: 14px; }
.quick-add .input { flex: 1; }

.toolbar {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 14px; flex-wrap: wrap;
}
.tabs { display: flex; gap: 3px; background: var(--bg-elev); border: 1px solid var(--border); padding: 3px; border-radius: 9px; }
.tab {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
  transition: background .14s, color .14s;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--bg-hover); color: var(--text); font-weight: 600; }
.tab .n { font-size: 11px; color: var(--text-faint); margin-left: 4px; }
.toolbar .spacer { flex: 1; }
.search-wrap { position: relative; }
.search-wrap .icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-faint); }
.search-wrap .input { padding-left: 29px; width: 190px; }

/* ============================================================ 习惯 */

.habit-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 10px;
  border-bottom: 1px solid var(--border-soft);
}
.habit-row:last-child { border-bottom: none; }
.habit-icon {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 17px;
  background: var(--bg-elev-2);
}
.habit-info { flex: 1; min-width: 0; }
.habit-name { font-size: 13.5px; font-weight: 550; }
.habit-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }
.habit-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .14s; }
.habit-row:hover .habit-actions { opacity: 1; }

.check-btn {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1.8px solid var(--border);
  display: grid; place-items: center;
  color: var(--text-faint);
  transition: all .16s;
}
.check-btn:hover { border-color: var(--green); color: var(--green); transform: scale(1.06); }
.check-btn svg { width: 16px; height: 16px; }
.check-btn.on { background: var(--green); border-color: var(--green); color: #fff; }

.streak-flame { font-size: 11.5px; color: var(--amber); font-weight: 600; }

/* 热力图 */
.heat { overflow-x: auto; padding-bottom: 4px; }
.heat-grid { display: inline-block; min-width: 100%; }
.heat-labels { display: flex; gap: 3px; margin-bottom: 6px; padding-left: 122px; }
.heat-labels span { width: 15px; flex: 0 0 15px; font-size: 9.5px; color: var(--text-faint); text-align: center; }
.heat-row { display: flex; align-items: center; gap: 3px; margin-bottom: 4px; }
.heat-name {
  width: 116px; flex: 0 0 116px;
  font-size: 12px; color: var(--text-dim);
  display: flex; align-items: center; gap: 5px;
  padding-right: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.heat-cell {
  width: 15px; height: 15px; flex: 0 0 15px;
  border-radius: 3.5px;
  background: var(--bg-elev-2);
  border: 1px solid transparent;
  transition: transform .1s, background .14s;
}
.heat-cell:hover { transform: scale(1.22); border-color: var(--text-faint); }
.heat-cell.on { background: var(--green); }
.heat-cell.today { box-shadow: 0 0 0 1.5px var(--accent); }
.heat-cell.future { opacity: .38; cursor: default; }
.heat-cell.future:hover { transform: none; border-color: transparent; }

/* ============================================================ 笔记 */

.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 14px; }

.note {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 15px;
  cursor: pointer;
  display: flex; flex-direction: column;
  transition: border-color .14s, transform .14s, box-shadow .14s;
  min-height: 118px;
  position: relative;
}
.note:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.note-title { font-size: 13.5px; font-weight: 600; margin-bottom: 6px; padding-right: 22px; word-break: break-word; }
.note-excerpt {
  font-size: 12.5px; color: var(--text-dim);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
}
.note-foot { margin-top: auto; padding-top: 10px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.note-editor { min-height: 230px; }
.note-date { font-size: 11px; color: var(--text-faint); margin-left: auto; }
.note-pin { position: absolute; top: 11px; right: 11px; color: var(--amber); }
.note-pin svg { width: 14px; height: 14px; }
.note-actions { position: absolute; top: 9px; right: 9px; display: flex; gap: 2px; opacity: 0; transition: opacity .14s; background: var(--bg-elev); border-radius: 6px; }
.note:hover .note-actions { opacity: 1; }

/* ============================================================ 项目 */

.proj {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 17px;
  transition: border-color .14s;
}
.proj:hover { border-color: var(--text-faint); }
.proj-head { display: flex; align-items: flex-start; gap: 9px; }
.proj-name { font-size: 14px; font-weight: 620; flex: 1; word-break: break-word; }
.proj-desc { font-size: 12.5px; color: var(--text-dim); margin-top: 6px; min-height: 19px; white-space: pre-wrap; word-break: break-word; }
.proj-bar { height: 5px; background: var(--bg-elev-2); border-radius: 3px; overflow: hidden; margin-top: 13px; }
.proj-bar > i { display: block; height: 100%; border-radius: 3px; transition: width .3s; }
.proj-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 11.5px; color: var(--text-faint); }
.proj-foot .right { margin-left: auto; display: flex; gap: 2px; opacity: 0; transition: opacity .14s; }
.proj:hover .proj-foot .right { opacity: 1; }

/* ============================================================ 弹窗 */

.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 20px;
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } }

.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  animation: pop .18s ease;
}
.modal.modal-wide { max-width: 700px; }
.modal-head {
  padding: 16px 20px 12px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border-soft);
  flex: 0 0 auto;
}
.modal-head h3 { font-size: 15px; font-weight: 620; flex: 1; }
.modal-body { padding: 18px 20px; overflow-y: auto; min-height: 0; }
.modal-foot {
  padding: 13px 20px;
  border-top: 1px solid var(--border-soft);
  display: flex; gap: 9px; align-items: center;
  flex: 0 0 auto;
}
.modal-foot .spacer { flex: 1; }
/* 填满型表单（笔记等长文本）：标题固定、正文占满剩余空间。
   整条 flex 链必须每一环都是 flex 子项 + min-height:0，否则高度塌回内容高度。 */
.modal-fill { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.modal-fill .field-fill { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

/* AI 整理按钮：只有 langchain 装了、密钥配了、开关没关时才渲染。
   尺寸照抄 .icon-btn 系列，视觉上不跳。
   busy 时图标换成转圈，不改按钮宽度，footer 不会跳。 */
.ai-tidy-btn {
  display: grid; place-items: center;
  width: 30px; height: 30px; flex: 0 0 auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--accent);
  transition: background .14s, color .14s;
}
.ai-tidy-btn:hover { background: var(--bg-hover); }
.ai-tidy-btn:active { transform: scale(.94); }
.ai-tidy-btn .icon { width: 15px; height: 15px; }
.ai-tidy-btn:disabled { opacity: .55; cursor: default; }
.ai-tidy-btn:disabled:hover { background: var(--bg-elev-2); }
.ai-tidy-btn.busy { color: var(--green); }
.ai-tidy-btn.busy .icon { display: none; }
.ai-tidy-btn.busy::before {
  content: "";
  width: 13px; height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: ai-spin .7s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }

/* 复选行（设置页的开关项） */
.opt-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-dim);
  margin: 4px 0 13px; cursor: pointer;
}
.opt-row input[type="checkbox"] { width: 15px; height: 15px; flex: 0 0 auto; accent-color: var(--accent); cursor: pointer; }

/* ============================================================ AI 设置 */

.ai-tabs { margin-bottom: 16px; }
.ai-tab-pages { min-height: 260px; }

.ai-banner {
  font-size: 12.5px;
  color: var(--text-dim);
  background: var(--bg-elev-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  margin-bottom: 14px;
}

.ai-key-row { display: flex; gap: 8px; align-items: center; }
.ai-key-row .input { flex: 1; min-width: 0; }

.btn-link {
  flex: 0 0 auto;
  font-size: 12.5px;
  color: var(--red);
  background: none;
  border: none;
  padding: 4px 6px;
  border-radius: 6px;
  white-space: nowrap;
  transition: background .14s;
}
.btn-link:hover { background: var(--red-soft); }

.ai-hint-inline { font-size: 12px; color: var(--text-faint); display: block; margin: -8px 0 13px; }
.ai-hint-warn { color: var(--amber); }

.ai-key-actions { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; flex-wrap: wrap; }
.ai-test-result { font-size: 12.5px; color: var(--text-faint); }
.ai-test-result.ai-ok  { color: var(--green); }
.ai-test-result.ai-bad { color: var(--red); }

.ai-hint {
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.8;
  margin-top: 4px;
}

/* ============================================================ 邮件 */

/* 三栏：文件夹 | 列表 | 读信。窄屏逐级降级，见文末 @media。
   mail-wrap 用 grid 而不是 flex，是为了让"文件夹栏"能自己撑满高度，
   而列表/读信两块各自独立滚动（内部 overflow:auto + max-height）。 */
.mail-wrap {
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.mail-wrap > * { min-width: 0; }

.mail-side {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  position: sticky;
  top: 14px;
}
.mail-side .field { margin-bottom: 12px; }
.mail-side .field label { font-size: 11.5px; }

.mail-account {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 8px 11px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px;
  color: var(--text-dim);
  min-width: 0;
}
.mail-account span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); flex: 0 0 7px; }
.mail-dot.on { background: var(--green); }

.mail-folders { display: flex; flex-direction: column; gap: 2px; }
.mail-folder {
  display: flex; align-items: center; gap: 6px;
  width: 100%;
  padding: 7px 9px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  text-align: left;
  transition: background .14s, color .14s;
}
.mail-folder:hover { background: var(--bg-hover); color: var(--text); }
.mail-folder.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.mail-folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-badge {
  flex: 0 0 auto;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.mail-main {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.mail-main > * { min-width: 0; }

.mail-pane {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.mail-pane-list { display: flex; flex-direction: column; max-height: calc(100vh - 190px); }

.mail-list-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-elev);
  position: sticky; top: 0; z-index: 2;
}
.mail-list-title {
  flex: 1; min-width: 0;
  font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.select-sm { padding: 4px 8px; font-size: 12px; width: auto; }

.mail-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background .12s;
  min-width: 0;
}
.mail-item:last-child { border-bottom: none; }
.mail-item:hover { background: var(--bg-hover); }
.mail-item.active { background: var(--accent-soft); }
.mail-item-line1 { display: flex; align-items: baseline; gap: 8px; }
.mail-from {
  flex: 1; min-width: 0;
  font-size: 12.5px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mail-item.unread .mail-from { color: var(--text); font-weight: 650; }
.mail-item-line2 { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.mail-subject {
  flex: 1; min-width: 0;
  font-size: 13.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mail-item.unread .mail-subject { font-weight: 700; }
.mail-clip { display: inline-flex; color: var(--text-faint); }
.mail-clip .icon { width: 13px; height: 13px; }
.mail-item-line3 {
  margin-top: 2px;
  font-size: 11px; color: var(--text-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.mail-pager {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--border-soft);
  font-size: 12px; color: var(--text-faint);
  flex-wrap: wrap;
}
.mail-pager .btn[disabled] { opacity: .4; cursor: not-allowed; }

.mail-reader-head { padding: 13px 15px; border-bottom: 1px solid var(--border-soft); }
.mail-reader-title { font-size: 15px; font-weight: 650; word-break: break-word; margin-bottom: 9px; }
.mail-reader-row { display: flex; gap: 9px; font-size: 12px; line-height: 1.8; }
.mail-k { flex: 0 0 44px; color: var(--text-faint); }
.mail-v { flex: 1; min-width: 0; color: var(--text-dim); word-break: break-word; }
.mail-reader-actions { display: flex; gap: 6px; margin-top: 11px; flex-wrap: wrap; }

/* 邮件正文两种形态：HTML 走 sandbox iframe（不可信内容，绝不进主文档），
   纯文本走 pre-wrap。iframe 给固定高度 + 白色底，因为邮件样式是按浅色设计的，
   套在深色主题里会看不清。 */
.mail-reader-body { padding: 0; background: #fff; }
.mail-frame { display: block; width: 100%; height: 440px; border: 0; background: #fff; }
.mail-text {
  margin: 0;
  padding: 15px;
  min-height: 180px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.mail-attachments { padding: 11px 15px 14px; border-top: 1px solid var(--border-soft); }
.mail-attachments-title { font-size: 12px; color: var(--text-faint); margin-bottom: 8px; }
.mail-att {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: 12.5px;
  transition: border-color .14s, background .14s;
}
.mail-att:hover { border-color: var(--accent); background: var(--bg-hover); }
.mail-att .icon { width: 14px; height: 14px; color: var(--text-faint); flex: 0 0 14px; }
.mail-att-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-att-size { flex: 0 0 auto; font-size: 11px; color: var(--text-faint); }

.mail-editor { min-height: 240px; }

/* 返回按钮只在单栏（窄屏读信态）下出现，桌面双栏时它是多余的 */
.mobile-only { display: none; }

/* ============================================================ 提示 */

.toasts {
  position: fixed; bottom: 22px; right: 22px; z-index: 200;
  display: flex; flex-direction: column; gap: 9px;
  align-items: flex-end;
  /* 手机上要避开 home 指示条 */
  bottom: calc(22px + env(safe-area-inset-bottom));
  right: calc(22px + env(safe-area-inset-right));
}
.toast {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 15px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: pop .18s ease;
  max-width: 340px;
}
.toast.ok    { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }

/* 悬浮新建按钮（仅移动端显示，桌面端 display:none） */
.fab {
  display: none;
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 60;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
  place-items: center;
  transition: transform .14s, background .14s;
}
.fab:active { transform: scale(.93); }
.fab .icon { width: 26px; height: 26px; }

/* ============================================================ AI 助手 */

/* 对话视图要吃满 .content 的剩余高度，所以先把 .content 通用 padding 收掉：
   上下留白会让输入区浮在半空、离屏幕底还差一截。左右 padding 保留在 .chat 上，
   这样窄屏那档还能把输入区做成真正的贴边通栏。
   .content 是 flex:1 的弹性项，高度由 flex 布局定下来，
   .chat 的 height:100% 因此能解析成确定值（不是 auto）。 */
.content:has(.chat) { padding-bottom: 0; }

.chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

/* 顶部工具条：新对话 + 消息条数 */
.chat-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
}
.chat-count { font-size: 12px; color: var(--text-faint); }

/* 消息区：吃掉剩余高度并自己滚。min-height:0 是关键，
   否则长回复会把 flex 子项撑到内容高度，输入区被顶出屏幕外。 */
.chat-msgs {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 2px 2px 10px;
}

.chat-row { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.chat-row.me { align-items: flex-end; }

.chat-bubble {
  max-width: 74%;
  min-width: 0;
  padding: 9px 13px;
  border-radius: 13px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.62;
  /* AI 回复里的换行要留着，但不能被长串（比如一整段 URL）顶破气泡 */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.chat-row.me .chat-bubble {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-row.ai .chat-bubble { border-bottom-left-radius: 4px; }

.chat-meta { font-size: 11px; color: var(--text-faint); padding: 0 3px; }

/* 工具轨迹：默认折成一行，点了才铺开明细 */
.chat-trace { max-width: 100%; display: flex; flex-direction: column; gap: 6px; }
.chat-trace-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  align-self: flex-start;
  padding: 2px 9px;
  border-radius: 20px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-soft);
  color: var(--text-faint);
  font-size: 11.5px;
  transition: background .14s, color .14s;
}
.chat-trace-toggle:hover { background: var(--bg-hover); color: var(--text-dim); }
.chat-trace-caret { font-style: normal; font-size: 10px; transition: transform .16s; display: inline-block; }
.chat-trace-toggle.open .chat-trace-caret { transform: rotate(90deg); }

/* hidden 属性要显式压住 display:flex —— 作者样式优先级高于 UA 的 [hidden]{display:none} */
.chat-trace-list { display: flex; flex-direction: column; gap: 6px; }
.chat-trace-list[hidden] { display: none; }

.chat-trace-item {
  padding-left: 8px;
  border-left: 2px solid var(--border);
  font-size: 11.5px;
  color: var(--text-faint);
  min-width: 0;
}
.chat-trace-line { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.chat-trace-gear { flex: 0 0 auto; font-size: 10px; }
.chat-trace-name { color: var(--accent); font-weight: 600; }
.chat-trace-sum { color: var(--text-dim); overflow-wrap: anywhere; }
.chat-trace-args {
  margin-top: 1px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  opacity: .8;
  overflow-wrap: anywhere;
}

.chat-retry {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 11.5px;
}
.chat-retry:hover { background: color-mix(in srgb, var(--red) 24%, transparent); }
.chat-retry .icon { width: 12px; height: 12px; }

/* 首次进入的引导 + 示例 chip */
.chat-hello {
  margin: auto;                    /* flex 列里上下居中 */
  padding: 26px 12px;
  text-align: center;
  max-width: 460px;
}
.chat-hello-title { font-size: 15px; font-weight: 620; }
.chat-hello-sub { font-size: 12.5px; color: var(--text-faint); line-height: 1.7; margin-top: 6px; }
.chat-samples { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.chat-sample {
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12.5px;
  transition: border-color .14s, color .14s, background .14s;
}
.chat-sample:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* 请求在飞时的"思考中… Ns" */
.chat-think {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: flex-start;
  padding: 8px 13px;
  border-radius: 13px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
}
.chat-think[hidden] { display: none; }
.chat-think-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  animation: chat-pulse 1s ease-in-out infinite;
}
.chat-think-sec { font-variant-numeric: tabular-nums; color: var(--text-faint); }
@keyframes chat-pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

/* 输入区：钉在底部，安全区由这一块自己让（.content 的 padding-bottom 已被去掉） */
.chat-input-bar {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 0;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  background: var(--bg);
  border-top: 1px solid var(--border-soft);
}
.chat-input {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  padding: 9px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  /* 16px 起步：iOS 聚焦小于这个字号会自动放大整页 */
  font-size: 16px;
  line-height: 1.5;
  resize: none;
  transition: border-color .14s, box-shadow .14s;
}
.chat-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-input:disabled { opacity: .6; }
.chat-input::placeholder { color: var(--text-faint); font-size: 14px; }

.chat-send {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  transition: opacity .14s, transform .14s;
}
.chat-send .icon { width: 17px; height: 17px; }
.chat-send:active { transform: scale(.94); }
.chat-send:disabled { opacity: .4; cursor: not-allowed; }

/* ============================================================ 移动端 */

.menu-btn { display: none; }

@media (max-width: 1080px) {
  .grid-dash { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* 邮件三栏挤不下了：文件夹收窄，读信改到列表下方，单栏时再切成"列表/读信"二选一 */
  .mail-wrap { grid-template-columns: 150px minmax(0, 1fr); }
  .mail-main { grid-template-columns: minmax(0, 1fr); }
  .mail-pane-list { max-height: none; }
}

@media (max-width: 760px) {
  .sidebar {
    position: fixed; z-index: 90; left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: grid; }
  .content {
    padding: 16px 15px 70px;
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
    padding-left: calc(15px + env(safe-area-inset-left));
    padding-right: calc(15px + env(safe-area-inset-right));
  }
  .topbar {
    padding: 13px 15px;
    padding-top: calc(13px + env(safe-area-inset-top));
    padding-left: calc(15px + env(safe-area-inset-left));
    padding-right: calc(15px + env(safe-area-inset-right));
  }
  .topbar h1 { font-size: 16.5px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .stats { gap: 10px; }
  .stat-value { font-size: 22px; }
  .search-wrap .input { width: 100%; }
  .toolbar { gap: 6px; }
  .notes-grid { grid-template-columns: minmax(0, 1fr); }
  .task-actions, .habit-actions { opacity: 1; }

  /* 邮件：单栏。文件夹横向排、列表和读信二选一，靠 .show-read 切换；
     没有它的话手机上点开一封信会被顶到列表下面，用户以为没反应。 */
  .mail-wrap { grid-template-columns: minmax(0, 1fr); }
  .mail-side { position: static; padding: 10px 8px; }
  .mail-folders {
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .mail-folder { width: auto; flex: 0 0 auto; }
  .mail-folder-name { max-width: 130px; }
  .mail-pane-read { display: none; }
  .mail-main.show-read .mail-pane-list { display: none; }
  .mail-main.show-read .mail-pane-read { display: block; }
  .mobile-only { display: inline-flex; }
  .mail-frame { height: 58vh; height: 58dvh; }
  /* 状态标签在窄屏放不下时自己横向滚，不要把整页撑出横向滚动条 */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* 有悬浮新建按钮的视图（笔记）底部要多留一点，别让卡片压在按钮下面 */
  .content:has(.fab) { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .toasts {
    left: 15px; right: 15px; bottom: 15px; align-items: stretch;
    bottom: calc(15px + env(safe-area-inset-bottom));
    right: calc(15px + env(safe-area-inset-right));
  }

  /* 弹窗全屏：手机上再是居中小卡片就只剩一条缝，笔记没法写 */
  .modal-mask { padding: 0; }
  .modal {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: none;
    border: none;
    border-radius: 0;
  }
  .modal-head {
    padding: 14px 15px 12px;
    padding-top: calc(14px + env(safe-area-inset-top));
  }
  /* 内容区吃掉剩余高度并成为 flex 容器，填满型表单才能真正把正文撑开 */
  .modal-body {
    padding: 16px 15px;
    flex: 1 1 auto;
    min-height: 0;
    display: flex; flex-direction: column;
  }
  .modal-foot {
    padding: 12px 15px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    /* 窄屏上"删除 + 自动保存提示 + 语音 + 取消 + 保存"放不下时换行，
       总比整行被挤出屏幕强 */
    flex-wrap: wrap;
    row-gap: 8px;
  }
  /* 正文输入框吃掉剩余高度；16px 起步，防止 iOS 聚焦时页面自动放大 */
  .modal-fill .field-fill .textarea {
    flex: 1;
    min-height: 40vh;
    min-height: 40dvh;
    font-size: 16px;
    resize: none;
  }
  /* 确认类小弹窗仍然保持卡片形态，不然一句话要划半屏 */
  .modal-compact {
    height: auto;
    max-height: 88vh;
    max-height: 88dvh;
    border: 1px solid var(--border);
    border-radius: 14px;
  }

  .fab { display: grid; }

  /* AI 助手：全高通栏。手机上再留一圈页边距，输入区会离拇指和键盘太远，
     消息区也只能剩两三行，所以整块贴边、只靠内部留白呼吸。 */
  .content:has(.chat) { padding: 0; }
  .chat-bar {
    padding: 10px 15px;
    padding-top: calc(10px + env(safe-area-inset-top));
    padding-left: calc(15px + env(safe-area-inset-left));
    padding-right: calc(15px + env(safe-area-inset-right));
    border-bottom: 1px solid var(--border-soft);
  }
  .chat-msgs { padding: 12px 15px; gap: 10px; }
  .chat-bubble { max-width: 85%; }
  .chat-hello { padding: 20px 18px; }
  .chat-input-bar {
    padding: 9px 15px;
    padding-bottom: calc(9px + env(safe-area-inset-bottom));
    padding-left: calc(15px + env(safe-area-inset-left));
    padding-right: calc(15px + env(safe-area-inset-right));
  }
}

@media (max-width: 420px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
}

/* 没有 hover 的设备（手机/平板触屏）：靠 hover 显形的按钮一律常驻，
   否则在手机上根本点不到。项目卡、笔记卡上的操作区同理。 */
@media (hover: none) {
  .task-actions,
  .habit-actions,
  .note-actions,
  .proj-foot .right { opacity: 1; }
}

/* 触摸设备：保证可点区域够大。图标按钮用透明伪元素把命中区撑到 44px，
   不改变盒子尺寸，所以不会挤坏现有排版。 */
@media (pointer: coarse) {
  .icon-btn { position: relative; }
  .icon-btn::after,
  .ai-tidy-btn::after {
    content: "";
    position: absolute;
    left: 50%; top: 50%;
    width: max(100%, 44px);
    height: max(100%, 44px);
    transform: translate(-50%, -50%);
    border-radius: 8px;
  }
  .ai-tidy-btn { position: relative; }
  .nav-item { min-height: 44px; }
  .side-btn { min-height: 44px; }
  .tab { padding: 8px 11px; }
  .check-btn { width: 42px; height: 42px; }
  .task-check { width: 22px; height: 22px; flex-basis: 22px; }
  .x-btn { padding: 6px 8px; }
}

/* ============================================================
   工具箱
   ============================================================ */

.tool-group-title { margin: 18px 2px 10px; font-size: 13px; font-weight: 600; color: var(--text-dim); }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.tool-card { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; transition: transform .12s, border-color .12s; }
.tool-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.tool-card.disabled { opacity: .55; cursor: not-allowed; }
.tool-card-icon { font-size: 26px; line-height: 1; padding-top: 2px; }
.tool-card-body { flex: 1; min-width: 0; }
.tool-card-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.tool-card-desc { font-size: 12px; color: var(--text-dim); line-height: 1.5; }

.tool-intro { padding: 13px 16px; margin-bottom: 14px; }
.tool-intro-text { font-size: 12.8px; color: var(--text-dim); line-height: 1.7; }

/* 上传区 */
.dz { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 16px;
      border: 1.5px dashed var(--border); border-radius: var(--radius-sm); cursor: pointer;
      color: var(--text-dim); transition: border-color .15s, background .15s; font-size: 13px; }
.dz:hover, .dz.drag { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon { font-size: 20px; }
.dz-hint { font-size: 11.5px; color: var(--text-faint); }
.dz-files { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; width: 100%; }
.dz-file { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--text);
           background: var(--bg-elev-2); border-radius: 6px; padding: 4px 10px; }
.dz-size { color: var(--text-faint); flex: 0 0 auto; }

/* 任务面板 */
.job-panel { margin-top: 14px; display: none; }
.job-panel:has(.job-bar-fill) { display: block; }
.job-bar { height: 6px; border-radius: 4px; background: var(--bg-elev-2); overflow: hidden; }
.job-bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .35s; }
.job-bar-fill.done { background: var(--green); }
.job-bar-fill.error { background: var(--red); }
.job-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.job-msg { font-size: 12.5px; color: var(--text-dim); }
.job-logs { display: none; max-height: 200px; overflow: auto; margin: 10px 0 0;
            font-size: 11.5px; line-height: 1.6; color: var(--text-dim);
            background: var(--bg); border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
            padding: 8px 12px; white-space: pre-wrap; }
.job-panel.has-logs .job-logs { display: block; }

.file-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.file-label { font-size: 12.5px; color: var(--text-faint); }

.result-card { margin-bottom: 14px; }
.result-summary { font-size: 13.5px; font-weight: 550; }
.ok-text { color: var(--green); font-weight: 550; }
.warn-text { color: var(--amber); }

/* 表格 */
.table-wrap { overflow-x: auto; margin-top: 10px; }
.rtable { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.rtable th, .rtable td { border: 1px solid var(--border-soft); padding: 6px 9px; text-align: left;
                          white-space: nowrap; }
.rtable th { background: var(--bg-elev-2); color: var(--text-dim); font-weight: 600; position: sticky; top: 0; }
.rtable tbody tr:hover td { background: var(--bg-hover); }

/* 评分 */
.score-layout { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .score-layout { grid-template-columns: 1fr; } }
.score-table td, .score-table th { text-align: center; }
.score-table .company-cell { text-align: left; font-weight: 550; }
.score-input { width: 74px; text-align: center; background: var(--bg-elev-2); color: var(--text);
               border: 1px solid var(--border-soft); border-radius: 6px; padding: 5px 6px; font-size: 12.5px; }
.score-input:focus { outline: none; border-color: var(--accent); }
.score-final { font-weight: 700; color: var(--accent); }
.x-btn { border: none; background: transparent; color: var(--text-faint); cursor: pointer;
         font-size: 13px; padding: 0 3px; margin-left: 4px; border-radius: 4px; }
.x-btn:hover { color: var(--red); background: var(--red-soft); }
.judge-name, .company-name { cursor: pointer; }
.rank-panel { background: var(--bg-elev-2); border-radius: var(--radius-sm); padding: 12px; }
.rank-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.rank-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; font-size: 13px; }
.rank-row.top1 { background: var(--amber-soft); }
.rank-row.top2 { background: var(--accent-soft); }
.rank-row.top3 { background: var(--green-soft); }
.rank-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-score { font-weight: 700; }
.rank-chip { font-size: 11.5px; color: var(--text-dim); }
.rank-chip.top1 { color: var(--amber); font-weight: 700; }
.rank-chip.top2 { color: var(--accent); font-weight: 700; }
.rank-chip.top3 { color: var(--green); font-weight: 700; }

/* 财务 */
.fin-upper { font-size: 15px; font-weight: 600; color: var(--accent); cursor: pointer; line-height: 1.6; }
.fin-tax { font-size: 13.5px; }
.fin-tax-upper { font-size: 12.5px; color: var(--text-dim); }

/* PDF 预览 */
.hf-preview { margin-top: 12px; }
.hf-img { max-width: 100%; max-height: 380px; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); }

/* 扫描 */
.scan-live .table-wrap { margin-top: 0; }
.dept-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dept-chip { display: inline-flex; align-items: center; gap: 4px; }
.issue-title { font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
.issue-item { font-size: 12px; color: var(--text-dim); padding: 2px 0 2px 14px; }
.stat-mini { font-size: 12px; color: var(--text-dim); line-height: 1.7; }
.ocr-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim);
           margin: 8px 0; cursor: pointer; }
.split-info { font-size: 12.5px; color: var(--text-dim); margin-top: 8px; }

@media (max-width: 640px) {
  .tool-grid { grid-template-columns: 1fr; }
}

/* ============================================================ 访问口令 */

/* 全屏遮罩，比 .modal-mask 层级更高（200 > 100）：登录层出现时任何弹窗都该被压住。
   刻意不给关闭入口 —— 没登录就什么都干不了，留一屏空壳没有意义。 */
.auth-gate {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: grid; place-items: center;
  padding: 24px;
  animation: fade .16s ease;
}
.auth-card {
  width: 100%;
  max-width: 372px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 26px 26px 22px;
  animation: pop .18s ease;
}
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.auth-brand-name { font-size: 16px; font-weight: 650; letter-spacing: .2px; }
.auth-brand-sub  { font-size: 12px; color: var(--text-faint); }

.auth-card .field { margin-bottom: 12px; }
.auth-submit { width: 100%; margin-top: 4px; padding: 9px 13px; }

.auth-err {
  font-size: 12.5px;
  color: var(--red);
  min-height: 18px;
  margin: 0 0 6px;
  line-height: 1.5;
}
.auth-err:empty { display: none; }
.auth-tip { font-size: 12px; color: var(--text-faint); line-height: 1.7; margin-top: 2px; }

/* 设置页里"修改访问口令"那一行 */
.auth-set-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.auth-set-hint { font-size: 12px; color: var(--text-faint); }
