/* ==========================================================================
   extra.css —— 高级模块样式（习惯 / 番茄 / 统计 / 搜索 / 账号同步 / 桌面版标题栏）
   与 styles.css 共用同一套 CSS 变量，自动跟随浅色与深色主题
   ========================================================================== */

:root{
  --bg-elev:      #ffffff;
  --chart-grid:   rgba(140,148,164,.18);
  --card-border:  #ececec;
  --ok:           #3ebf9c;
}
html[data-theme="dark"]{
  --bg-elev:      #232529;
  --chart-grid:   rgba(160,170,190,.16);
  --card-border:  #2c2f34;
  --brand-soft:   #1e3630;
}

/* ==========================================================================
   桌面版标题栏
   ========================================================================== */
.titlebar{
  height:40px; flex:0 0 40px;
  display:flex; align-items:center; gap:10px;
  padding:0 6px 0 12px;
  background: var(--bg-side);
  border-bottom:1px solid var(--border);
  -webkit-app-region: drag;
  user-select:none;
  position:relative; z-index:60;
}
.titlebar[hidden]{ display:none; }
body.desktop-mode{ display:flex; flex-direction:column; height:100vh; overflow:hidden; }
body.desktop-mode .app{ flex:1; min-height:0; height:auto; }
.tb-left{ display:flex; align-items:center; gap:8px; min-width:0; }
.tb-logo{
  width:18px; height:18px; border-radius:5px; flex:0 0 18px;
  background: linear-gradient(135deg, var(--brand), #4a90d9);
  position:relative;
}
.tb-logo::after{
  content:''; position:absolute; left:5px; top:4px; width:7px; height:4px;
  border-left:2px solid #fff; border-bottom:2px solid #fff; transform:rotate(-45deg);
}
.tb-name{ font-size:12.5px; font-weight:600; color:var(--text); white-space:nowrap; }
.tb-badge{
  font-size:11px; padding:1px 8px; border-radius:10px; white-space:nowrap;
  background:var(--bg-active); color:var(--text-2); max-width:280px; overflow:hidden; text-overflow:ellipsis;
}
.tb-badge.on{ background:var(--brand-soft); color:var(--brand); }
.tb-badge.off{ background:var(--bg-active); color:var(--text-3); }
.tb-center{ flex:1; min-width:0; display:flex; justify-content:center; align-items:center; gap:6px; }
.tb-right{ display:flex; align-items:center; gap:2px; -webkit-app-region:no-drag; }
.tb-btn, .tb-win{
  -webkit-app-region:no-drag;
  width:30px; height:26px; border:0; border-radius:5px; cursor:pointer;
  background:transparent; color:var(--text-2);
  display:inline-flex; align-items:center; justify-content:center;
}
.tb-btn:hover{ background:var(--bg-hover); color:var(--text); }
.tb-win{ width:38px; height:26px; }
.tb-win:hover{ background:var(--bg-active); color:var(--text); }
.tb-close:hover{ background:#e8384f; color:#fff; }
.tb-sep{ width:1px; height:16px; background:var(--border-2); margin:0 4px; }
.tb-center .chip-btn{ -webkit-app-region:no-drag; }

/* ==========================================================================
   侧栏同步状态胶囊
   ========================================================================== */
.sync-chip{
  display:flex; align-items:center; gap:6px; cursor:pointer;
  padding:6px 9px; margin-bottom:6px; border-radius:var(--radius-sm);
  background:var(--bg-input); color:var(--text-2); font-size:12px;
  transition:background .15s ease;
}
.sync-chip:hover{ background:var(--bg-active); }
.sync-chip .sc-sync-ic{ display:flex; color:var(--text-3); }
.sync-chip.on .sc-sync-ic{ color:var(--brand); }
.sync-chip.warn .sc-sync-ic, .sync-chip.err .sc-sync-ic{ color:var(--orange); }
.sync-chip.err{ color:var(--red); }
.sync-chip .sc-text{ flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sync-conflict{
  font-style:normal; font-size:10px; font-weight:600; min-width:15px; text-align:center;
  background:var(--orange); color:#fff; border-radius:8px; padding:0 4px;
}
@keyframes ttsync-spin{ to{ transform:rotate(360deg); } }
.sync-chip .sc-sync-ic.spin svg{ animation:ttsync-spin 1.1s linear infinite; }

/* ==========================================================================
   扩展页面通用
   ========================================================================== */
.page{ padding:16px 20px 60px; max-width:1180px; }
.head-sub{ font-size:12px; color:var(--text-3); margin-top:1px; }
.card{
  background:var(--bg-panel); border:1px solid var(--card-border); border-radius:12px;
  padding:14px 16px; margin-bottom:14px;
}
.card-head{
  display:flex; align-items:center; justify-content:space-between;
  font-size:13.5px; font-weight:600; color:var(--text); margin-bottom:10px;
}
.card-sub{ font-size:11.5px; font-weight:400; color:var(--text-3); }
.legend{ display:flex; align-items:center; gap:6px; font-size:11.5px; font-weight:400; color:var(--text-3); }
.legend i{ display:inline-block; width:9px; height:9px; border-radius:3px; margin-left:8px; }
.dot-sep{ color:var(--text-3); margin:0 5px; }
.hint-text{ font-size:12px; color:var(--text-3); line-height:1.6; }
.inline-row{ display:flex; align-items:center; gap:8px; }
.inline-row > span{ font-size:13px; color:var(--text-2); }
.inline-row input[type="number"]{ width:78px; }
.inline-row input[type="date"]{ width:150px; }
.empty-state{ display:flex; flex-direction:column; align-items:center; gap:10px; padding:56px 20px; color:var(--text-3); }
.empty-art{ color:var(--border-2); }
.empty-title{ font-size:15px; font-weight:600; color:var(--text-2); }
.empty-sub{ font-size:12.5px; color:var(--text-3); }

/* 按钮补充 */
.btn-ghost{ background:transparent; border:1px solid var(--border-2); }
.btn-ghost-on{ background:var(--brand-soft); color:var(--brand); border-color:var(--brand); }
.btn-danger-ghost{ background:transparent; border:1px solid var(--border-2); color:var(--red); }
.btn-danger-ghost:hover{ background:rgba(232,56,79,.08); }
.btn svg{ width:15px; height:15px; }

/* ==========================================================================
   习惯打卡
   ========================================================================== */
.habit-hero{
  display:flex; align-items:center; gap:18px;
  background:linear-gradient(135deg, var(--brand-soft), var(--bg-panel) 70%);
  border:1px solid var(--card-border); border-radius:14px;
  padding:18px 20px; margin-bottom:16px;
}
html[data-theme="dark"] .habit-hero{ background:linear-gradient(135deg, #1e3630, var(--bg-panel) 70%); }
.hero-ring{ position:relative; width:76px; height:76px; flex:0 0 76px; }
.hero-ring svg{ width:76px; height:76px; display:block; }
.hero-ring-text{ position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; }
.hero-ring-text b{ font-size:17px; color:var(--text); }
.hero-ring-text span{ font-size:10px; color:var(--text-3); }
.hero-info{ flex:1; min-width:0; }
.hero-title{ font-size:16px; font-weight:600; color:var(--text); }
.hero-sub{ font-size:12.5px; color:var(--text-2); margin-top:5px; display:flex; flex-wrap:wrap; align-items:center; }
.hero-sub b{ color:var(--brand); }
.habit-group-head{ font-size:12px; color:var(--text-3); margin:14px 2px 8px; }
.habit-list{ display:flex; flex-direction:column; gap:8px; }
.habit-row{
  display:flex; align-items:center; gap:12px;
  background:var(--bg-panel); border:1px solid var(--card-border); border-radius:11px;
  padding:10px 12px; transition:border-color .15s, box-shadow .15s;
}
.habit-row:hover{ border-color:var(--border-2); box-shadow:var(--shadow-1); }
.habit-check{
  width:30px; height:30px; flex:0 0 30px; border-radius:50%; cursor:pointer;
  border:1.6px solid var(--border-2); background:transparent; color:transparent;
  display:inline-flex; align-items:center; justify-content:center; transition:all .16s;
}
.habit-check:hover{ border-color:var(--brand); color:var(--brand); }
.habit-check.done{ background:var(--brand); border-color:var(--brand); color:#fff; }
.habit-main{ flex:1; min-width:0; cursor:pointer; }
.habit-name{ font-size:14px; color:var(--text); font-weight:500; }
.habit-sub{ font-size:11.5px; color:var(--text-3); margin-top:3px; display:flex; align-items:center; gap:4px; flex-wrap:wrap; }
.habit-sub span{ display:inline-flex; align-items:center; gap:3px; }
.habit-week{ display:flex; gap:4px; }
.wd-cell{
  width:22px; height:30px; border-radius:6px; cursor:pointer;
  background:var(--bg-input); display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px;
  border:1px solid transparent;
}
.wd-cell i{ font-style:normal; font-size:9px; color:var(--text-3); line-height:1; }
.wd-cell b{ width:8px; height:8px; border-radius:50%; background:var(--border-2); display:block; }
.wd-cell:hover{ border-color:var(--brand); }
.wd-cell.done{ background:var(--hc); border-color:var(--hc); }
.wd-cell.done b{ background:rgba(255,255,255,.9); }
.wd-cell.done i{ color:rgba(255,255,255,.85); }
.wd-cell.off{ opacity:.42; }
.wd-cell.today{ box-shadow:0 0 0 1.5px var(--brand); }
.habit-streak{ display:flex; align-items:center; gap:3px; font-size:12px; color:var(--orange); min-width:38px; justify-content:flex-end; }
.habit-menu{ opacity:0; }
.habit-row:hover .habit-menu{ opacity:1; }

/* 习惯详情 */
.habit-detail-head{ display:flex; align-items:center; gap:10px; margin-bottom:14px; }
.hd-ic{ width:38px; height:38px; border-radius:11px; display:inline-flex; align-items:center; justify-content:center; }
.hd-name{ font-size:17px; font-weight:600; color:var(--text); }
.hd-note{ font-size:12px; color:var(--text-3); font-weight:400; margin-top:2px; }
.habit-today-card{
  display:flex; align-items:center; justify-content:space-between; gap:16px;
  background:var(--bg-panel); border:1px solid var(--card-border); border-radius:12px;
  padding:16px 18px; margin-bottom:14px;
}
.htc-label{ font-size:12px; color:var(--text-3); }
.htc-value b{ font-size:26px; color:var(--text); margin-right:6px; }
.htc-value span{ font-size:13px; color:var(--text-3); }
.htc-ctrl{ display:flex; align-items:center; gap:10px; }
.icon-btn.round{ width:32px; height:32px; border-radius:50%; border:1px solid var(--border-2); }

.stat-cards{ display:grid; grid-template-columns:repeat(4, 1fr); gap:12px; margin-bottom:14px; }
.stat-card{
  background:var(--bg-panel); border:1px solid var(--card-border); border-radius:12px; padding:14px;
}
.sc-ic{ margin-bottom:6px; }
.sc-value{ font-size:20px; font-weight:600; color:var(--text); }
.sc-label{ font-size:11.5px; color:var(--text-3); margin-top:3px; }

/* 热力图 */
.heatmap-wrap{ overflow-x:auto; padding-bottom:4px; }
.heatmap{ display:grid; grid-auto-flow:column; grid-template-rows:repeat(7, 11px); gap:3px; }
.hm-cell{
  width:11px; height:11px; border-radius:3px; cursor:pointer;
  background:var(--bg-input); border:1px solid transparent;
}
.hm-cell:hover{ border-color:var(--brand); }
.hm-cell.off{ opacity:.4; }
.hm-cell.lv1{ background:color-mix(in srgb, var(--hc) 26%, transparent); }
.hm-cell.lv2{ background:color-mix(in srgb, var(--hc) 50%, transparent); }
.hm-cell.lv3{ background:color-mix(in srgb, var(--hc) 74%, transparent); }
.hm-cell.lv4{ background:var(--hc); }
.hm-legend{ display:flex; align-items:center; gap:4px; justify-content:flex-end; margin-top:8px; font-size:10.5px; color:var(--text-3); }
.hm-legend i{ width:11px; height:11px; border-radius:3px; background:var(--bg-input); display:inline-block; }
.hm-legend i.lv1{ background:color-mix(in srgb, var(--hc, var(--brand)) 26%, transparent); }
.hm-legend i.lv2{ background:color-mix(in srgb, var(--hc, var(--brand)) 50%, transparent); }
.hm-legend i.lv3{ background:color-mix(in srgb, var(--hc, var(--brand)) 74%, transparent); }
.hm-legend i.lv4{ background:var(--hc, var(--brand)); }

.log-list{ display:flex; flex-direction:column; }
.log-row{ display:flex; align-items:center; gap:10px; padding:7px 0; border-bottom:1px solid var(--border); font-size:12.5px; }
.log-row:last-child{ border-bottom:0; }
.log-date{ color:var(--text-3); width:96px; flex:0 0 96px; }
.log-title{ flex:1; min-width:0; color:var(--text-2); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.log-val{ color:var(--text-3); }
.log-val.done{ color:var(--brand); display:inline-flex; align-items:center; gap:3px; }

/* ==========================================================================
   番茄专注
   ========================================================================== */
.pomo-layout{ display:grid; grid-template-columns:minmax(360px, 1fr) minmax(300px, 380px); gap:18px; align-items:start; }
.pomo-main{ display:flex; flex-direction:column; align-items:center; }
.pomo-modes{ display:inline-flex; background:var(--bg-input); border-radius:9px; padding:3px; margin-bottom:22px; }
.pomo-modes button{
  border:0; background:transparent; cursor:pointer; font-size:13px; color:var(--text-2);
  padding:6px 18px; border-radius:7px;
}
.pomo-modes button.on{ background:var(--bg-panel); color:var(--text); box-shadow:var(--shadow-1); font-weight:600; }
.pomo-ring-wrap{ position:relative; width:240px; height:240px; }
.pomo-ring{ width:240px; height:240px; }
.pomo-center{ position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; }
.pomo-time{ font-size:44px; font-weight:300; letter-spacing:1px; color:var(--text); font-variant-numeric:tabular-nums; }
.pomo-state{ font-size:12.5px; color:var(--text-3); margin-top:4px; }
.pomo-round{ font-size:11px; color:var(--text-3); margin-top:8px; }
.pomo-task{ display:flex; align-items:center; gap:8px; margin:22px 0 14px; width:100%; max-width:360px; }
.pt-label{ font-size:12.5px; color:var(--text-3); display:inline-flex; align-items:center; gap:4px; white-space:nowrap; }
.pomo-task select{
  flex:1; min-width:0; height:32px; border:1px solid var(--border-2); border-radius:7px;
  background:var(--bg-panel); color:var(--text); font-size:12.5px; padding:0 8px;
}
.pomo-actions{ display:flex; gap:10px; }
.pomo-counts{ display:flex; gap:26px; margin-top:26px; padding-top:18px; border-top:1px solid var(--border); }
.pc-item{ text-align:center; }
.pc-item b{ display:block; font-size:19px; color:var(--text); }
.pc-item span{ font-size:11.5px; color:var(--text-3); }
.pomo-side .card{ margin-bottom:12px; }
.cfg-grid{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.cfg-item{ display:flex; flex-direction:column; gap:4px; font-size:12px; color:var(--text-2); }
.cfg-item input{
  height:30px; border:1px solid var(--border-2); border-radius:6px; background:var(--bg-panel);
  color:var(--text); padding:0 8px; font-size:12.5px;
}
.switch-row{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  font-size:12.5px; color:var(--text-2); padding:7px 0;
}
.switch-row input[type="checkbox"]{ width:15px; height:15px; accent-color:var(--brand); cursor:pointer; }

/* ==========================================================================
   统计报表
   ========================================================================== */
.range-switch{ display:inline-flex; background:var(--bg-input); border-radius:9px; padding:3px; margin-bottom:16px; }
.range-switch button{ border:0; background:transparent; cursor:pointer; font-size:12.5px; color:var(--text-2); padding:5px 14px; border-radius:7px; }
.range-switch button.on{ background:var(--bg-panel); color:var(--text); box-shadow:var(--shadow-1); font-weight:600; }
.kpi-row{ display:grid; grid-template-columns:repeat(6, 1fr); gap:12px; margin-bottom:16px; }
.kpi-card{
  position:relative; overflow:hidden;
  background:var(--bg-panel); border:1px solid var(--card-border); border-radius:12px; padding:13px 14px;
}
.kpi-card::before{ content:''; position:absolute; left:0; top:0; bottom:0; width:3px; background:var(--kc); }
.kpi-label{ font-size:11.5px; color:var(--text-3); }
.kpi-value{ font-size:21px; font-weight:600; color:var(--text); margin:5px 0 3px; }
.kpi-sub{ font-size:11px; color:var(--text-3); }
.chart-grid{ display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.chart-grid .span2{ grid-column:span 2; }
.chart-grid canvas{ display:block; width:100%; }
.legend-list{ display:flex; flex-wrap:wrap; gap:8px 14px; margin-top:10px; }
.lg-row{ display:inline-flex; align-items:center; gap:5px; font-size:11.5px; color:var(--text-2); }
.lg-row i{ width:9px; height:9px; border-radius:3px; display:inline-block; }
.lg-row b{ color:var(--text); margin-left:2px; }
.hbars{ display:flex; flex-direction:column; gap:9px; }
.hbar-row{ display:flex; align-items:center; gap:9px; font-size:12px; }
.hb-label{ width:88px; flex:0 0 88px; color:var(--text-2); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.hb-track{ flex:1; height:9px; border-radius:5px; background:var(--bg-input); overflow:hidden; }
.hb-track i{ display:block; height:100%; border-radius:5px; }
.hb-value{ width:28px; text-align:right; color:var(--text-3); }
.rate-list{ display:flex; flex-direction:column; gap:11px; }
.rate-row{ display:flex; align-items:center; gap:12px; font-size:12.5px; }
.rr-name{ width:150px; flex:0 0 150px; display:inline-flex; align-items:center; gap:6px; color:var(--text); }
.rr-bar{ flex:1; height:9px; border-radius:5px; background:var(--bg-input); overflow:hidden; }
.rr-bar i{ display:block; height:100%; border-radius:5px; }
.rr-val{ width:42px; text-align:right; font-weight:600; color:var(--text); }
.rr-sub{ width:150px; text-align:right; color:var(--text-3); font-size:11.5px; }

/* ==========================================================================
   全局搜索
   ========================================================================== */
.search-page-head{
  display:flex; align-items:center; gap:10px;
  background:var(--bg-panel); border:1px solid var(--border-2); border-radius:11px;
  padding:10px 14px; margin-bottom:16px;
}
.search-page-head:focus-within{ border-color:var(--brand); box-shadow:0 0 0 3px var(--brand-soft); }
.sp-ic{ color:var(--text-3); display:flex; }
#globalSearchInput{
  flex:1; border:0; background:transparent; outline:none;
  font-size:15px; color:var(--text); height:24px;
}
.search-sugg{ display:flex; flex-direction:column; gap:20px; }
.ss-title{ font-size:12px; color:var(--text-3); margin-bottom:8px; }
.ss-chips{ display:flex; flex-wrap:wrap; gap:8px; }
.ss-tips{ display:grid; grid-template-columns:repeat(auto-fit, minmax(200px, 1fr)); gap:8px; }
.ss-tips > div{ font-size:12.5px; color:var(--text-2); background:var(--bg-panel); border:1px solid var(--card-border); border-radius:9px; padding:10px 12px; }
.ss-tips b{ color:var(--text); font-family:ui-monospace, Menlo, Consolas, monospace; font-size:12px; }
.search-sum{ font-size:12.5px; color:var(--text-3); margin-bottom:14px; }
.search-sum b{ color:var(--text); }
.search-group{ margin-bottom:18px; }
.sg-head{
  display:flex; align-items:center; gap:6px; font-size:12.5px; font-weight:600; color:var(--text-2);
  margin-bottom:6px; padding-left:2px;
}
.sg-head span{ font-weight:400; color:var(--text-3); }
.search-row{
  display:flex; align-items:center; gap:10px; cursor:pointer;
  padding:9px 10px; border-radius:9px; border:1px solid transparent;
}
.search-row:hover{ background:var(--bg-hover); border-color:var(--border); }
.sr-prio{ display:flex; color:var(--text-3); }
.sr-prio.done{ color:var(--brand); }
.sr-title{ flex:1; min-width:0; font-size:13.5px; color:var(--text); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sr-title mark{ background:var(--brand-soft-2); color:var(--brand); border-radius:3px; padding:0 1px; }
.sr-meta{ display:flex; align-items:center; gap:8px; font-size:11.5px; color:var(--text-3); flex-shrink:0; }
.sr-meta .overdue{ color:var(--red); }
.mini-tag{ background:var(--bg-input); border-radius:5px; padding:1px 6px; }
.mini-list{ background:var(--bg-input); border-radius:5px; padding:1px 6px; }

/* ==========================================================================
   表单 / 对话框补充
   ========================================================================== */
.modal-wide{ width:min(720px, calc(100vw - 32px)); }
.modal-x{ position:absolute; right:10px; top:50%; transform:translateY(-50%); }
.modal-head{ position:relative; }
.modal-text{ font-size:13px; color:var(--text-2); line-height:1.7; margin-bottom:10px; }
.modal-body input[type="text"], .modal-body input[type="number"], .modal-body input[type="date"],
.modal-body select, .modal-body textarea{
  width:100%; height:34px; border:1px solid var(--border-2); border-radius:7px;
  background:var(--bg-panel); color:var(--text); font-size:13px; padding:0 10px; outline:none;
}
.modal-body input:focus, .modal-body select:focus{ border-color:var(--brand); box-shadow:0 0 0 3px var(--brand-soft); }
.form-row{ margin-bottom:13px; }
.form-row > label{ display:block; font-size:12.5px; color:var(--text-2); margin-bottom:6px; }
.form-row.two{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.form-row.two label{ display:block; font-size:12.5px; color:var(--text-2); margin-bottom:6px; }
.seg{ display:inline-flex; background:var(--bg-input); border-radius:8px; padding:3px; flex-wrap:wrap; }
.seg button{ border:0; background:transparent; cursor:pointer; font-size:12.5px; color:var(--text-2); padding:5px 14px; border-radius:6px; }
.seg button.on{ background:var(--bg-panel); color:var(--text); box-shadow:var(--shadow-1); font-weight:600; }
.chip-picker{ display:flex; flex-wrap:wrap; gap:7px; }
.chip-picker button{
  border:1px solid var(--border-2); background:transparent; cursor:pointer;
  font-size:12px; color:var(--text-2); padding:4px 11px; border-radius:14px;
}
.chip-picker button.on{ background:var(--brand-soft); border-color:var(--brand); color:var(--brand); font-weight:600; }
.color-picker{ display:flex; gap:8px; flex-wrap:wrap; }
.color-opt{ width:24px; height:24px; border-radius:50%; border:2px solid transparent; cursor:pointer; outline:none; }
.color-opt.on{ border-color:var(--text); box-shadow:0 0 0 2px var(--bg-panel) inset; }
.icon-picker{ display:flex; flex-wrap:wrap; gap:6px; }
.icon-opt{
  width:34px; height:34px; border-radius:8px; border:1px solid var(--border-2); cursor:pointer;
  background:transparent; color:var(--text-2); display:inline-flex; align-items:center; justify-content:center;
}
.icon-opt.on{ background:var(--brand-soft); border-color:var(--brand); color:var(--brand); }
.weekday-picker{ display:flex; gap:6px; flex-wrap:wrap; margin-top:6px; }
.weekday-picker button{
  border:1px solid var(--border-2); background:transparent; cursor:pointer;
  font-size:12px; color:var(--text-2); padding:4px 10px; border-radius:7px;
}
.weekday-picker button.on{ background:var(--brand-soft); border-color:var(--brand); color:var(--brand); font-weight:600; }
.menu-item.multi{ display:flex; align-items:center; gap:8px; }
.mi-check{
  width:15px; height:15px; border-radius:4px; border:1.5px solid var(--border-2);
  display:inline-flex; align-items:center; justify-content:center; color:transparent; flex:0 0 15px;
}
.mi-check.on{ background:var(--brand); border-color:var(--brand); color:#fff; }

/* ==========================================================================
   登录 / 注册浮层
   ========================================================================== */
#authRoot:empty{ display:none; }
.auth-mask{
  position:fixed; inset:0; z-index:300;
  background:rgba(16,24,40,.42); backdrop-filter:blur(3px);
  display:flex; align-items:center; justify-content:center; padding:20px;
}
.auth-card{
  width:min(400px, 100%); max-height:calc(100vh - 40px); overflow-y:auto;
  background:var(--bg-panel); border-radius:16px; box-shadow:var(--shadow-3); padding:24px;
}
.auth-brand{ display:flex; align-items:center; gap:12px; margin-bottom:18px; }
.auth-logo{
  width:42px; height:42px; border-radius:12px; flex:0 0 42px;
  background:linear-gradient(135deg, var(--brand), #4a90d9); color:#fff;
  display:inline-flex; align-items:center; justify-content:center;
}
.auth-name{ font-size:16px; font-weight:600; color:var(--text); }
.auth-slogan{ font-size:12px; color:var(--text-3); margin-top:2px; }
.auth-tabs{ display:flex; background:var(--bg-input); border-radius:9px; padding:3px; margin-bottom:18px; }
.auth-tabs button{
  flex:1; border:0; background:transparent; cursor:pointer; font-size:13px; color:var(--text-2);
  padding:7px 0; border-radius:7px;
}
.auth-tabs button.on{ background:var(--bg-panel); color:var(--text); box-shadow:var(--shadow-1); font-weight:600; }
.fld{ display:block; margin-bottom:12px; }
.fld > span{ display:block; font-size:12px; color:var(--text-2); margin-bottom:5px; }
.fld input{
  width:100%; height:36px; border:1px solid var(--border-2); border-radius:8px;
  background:var(--bg-panel); color:var(--text); font-size:13.5px; padding:0 11px; outline:none;
}
.fld input:focus{ border-color:var(--brand); box-shadow:0 0 0 3px var(--brand-soft); }
.fld-row{ display:flex; gap:8px; }
.fld-row input{ flex:1; }
.fld-row .btn{ white-space:nowrap; height:36px; }
.fld-hint{ display:block; font-size:11.5px; color:var(--text-3, var(--text-2)); margin-top:6px; line-height:1.5; }
.auth-msg{ font-size:12.5px; min-height:18px; margin:6px 0 10px; color:var(--text-3); line-height:1.5; }
.auth-msg.err{ color:var(--red); }
.auth-msg.ok{ color:var(--brand); }
.auth-msg.busy{ color:var(--text-2); }
.auth-submit{ width:100%; height:38px; justify-content:center; }
.auth-foot{ display:flex; flex-direction:column; gap:6px; align-items:center; margin-top:14px; }
.auth-hint{ font-size:11.5px; color:var(--text-3); text-align:center; line-height:1.6; }

/* ==========================================================================
   账号面板
   ========================================================================== */
.acct-tabs{ display:flex; gap:4px; border-bottom:1px solid var(--border); margin:-4px 0 16px; }
.acct-tabs button{
  border:0; background:transparent; cursor:pointer; font-size:13px; color:var(--text-2);
  padding:9px 14px; border-bottom:2px solid transparent; display:inline-flex; align-items:center; gap:6px;
}
.acct-tabs button.on{ color:var(--brand); border-bottom-color:var(--brand); font-weight:600; }
.acct-rows{ display:flex; flex-direction:column; }
.acct-row{
  display:flex; align-items:center; justify-content:space-between; gap:16px;
  padding:9px 2px; border-bottom:1px solid var(--border); font-size:12.8px;
}
.acct-row:last-child{ border-bottom:0; }
.acct-row span{ color:var(--text-3); flex:0 0 auto; }
.acct-row b{ color:var(--text); font-weight:500; text-align:right; word-break:break-all; }
.acct-actions{ display:flex; flex-wrap:wrap; gap:9px; margin-top:16px; }
.acct-empty{ display:flex; flex-direction:column; align-items:center; gap:10px; padding:28px 12px; text-align:center; color:var(--text-3); }
.acct-empty-title{ font-size:14.5px; font-weight:600; color:var(--text-2); }
.acct-empty-sub{ font-size:12.5px; line-height:1.75; max-width:460px; }
/* 远程访问状态块：账号面板里最需要"一眼看懂"的一块 */
.acct-net{
  border:1px solid var(--card-border); border-radius:12px; padding:12px 13px;
  margin-bottom:14px; background:var(--bg-input);
}
.acct-net.ok{ border-color:var(--brand); background:var(--brand-soft); }
.acct-net-hd{
  display:flex; align-items:center; gap:7px; font-size:13px; font-weight:600; color:var(--text-2);
}
.acct-net.ok .acct-net-hd{ color:var(--brand); }
.acct-net-badge{
  margin-left:auto; font-size:11px; font-weight:500; border-radius:6px;
  padding:2px 7px; background:rgba(255,255,255,.7); color:var(--text-2);
}
.acct-net-url{
  font-family:ui-monospace,Consolas,monospace; font-size:13px; font-weight:600;
  color:var(--text); margin:7px 0 5px; word-break:break-all; user-select:all;
}
.acct-net-sub{ font-size:12px; line-height:1.7; color:var(--text-3); }
.acct-net .acct-actions{ margin-top:9px; }
.dev-hint{ font-size:12px; color:var(--text-3); line-height:1.7; margin-bottom:12px; }
.dev-list{ display:flex; flex-direction:column; gap:9px; }
.dev-row{
  display:flex; align-items:center; gap:11px;
  border:1px solid var(--card-border); border-radius:10px; padding:10px 12px;
}
.dev-ic{ width:32px; height:32px; flex:0 0 32px; border-radius:9px; background:var(--bg-input); color:var(--text-3); display:inline-flex; align-items:center; justify-content:center; }
.dev-ic.on{ background:var(--brand-soft); color:var(--brand); }
.dev-main{ flex:1; min-width:0; }
.dev-name{ font-size:13px; color:var(--text); display:flex; align-items:center; gap:6px; }
.dev-sub{ font-size:11.5px; color:var(--text-3); margin-top:3px; }
.badge-cur, .badge-on{
  font-size:10px; padding:1px 6px; border-radius:8px; font-weight:500;
}
.badge-cur{ background:var(--bg-active); color:var(--text-2); }
.badge-on{ background:var(--brand-soft); color:var(--brand); }
.dev-cur-tip{ font-size:11.5px; color:var(--text-3); }
.cf-list{ display:flex; flex-direction:column; gap:9px; max-height:340px; overflow-y:auto; }
.cf-row{
  display:flex; align-items:flex-start; gap:12px;
  border:1px solid var(--card-border); border-radius:10px; padding:10px 12px;
}
.cf-main{ flex:1; min-width:0; }
.cf-title{ font-size:13px; color:var(--text); }
.cf-sub{ font-size:11.5px; color:var(--text-3); margin-top:4px; line-height:1.6; }
.cf-time{ font-size:11px; color:var(--text-3); white-space:nowrap; }

/* ==========================================================================
   响应式
   ========================================================================== */
@media (max-width: 1000px){
  .kpi-row{ grid-template-columns:repeat(3, 1fr); }
  .stat-cards{ grid-template-columns:repeat(2, 1fr); }
  .pomo-layout{ grid-template-columns:1fr; }
  .chart-grid{ grid-template-columns:1fr; }
  .chart-grid .span2{ grid-column:span 1; }
  .tb-center{ display:none; }
}
@media (max-width: 760px){
  .page{ padding:12px 12px 60px; }
  .kpi-row{ grid-template-columns:repeat(2, 1fr); }
  .habit-hero{ flex-wrap:wrap; gap:12px; padding:14px; }
  .habit-week{ display:none; }
  .habit-streak{ min-width:auto; }
  .habit-menu{ opacity:1; }
  .pomo-time{ font-size:36px; }
  .pomo-ring-wrap, .pomo-ring{ width:190px; height:190px; }
  .pomo-counts{ gap:15px; }
  .rr-name{ width:100px; flex:0 0 100px; }
  .rr-sub{ display:none; }
  .acct-tabs{ overflow-x:auto; }
  .titlebar{ display:none; }
  body.desktop-mode{ display:block; }
  body.desktop-mode .app{ height:100vh; }
}

/* 打印：隐藏交互外壳 */
@media print{
  .titlebar, .sidebar, .detail, .toasts{ display:none !important; }
}

/* ==========================================================================
   手机 / PWA 适配
   --------------------------------------------------------------------------
   · 安全区：iOS「添加到主屏幕」的独立模式下，内容会延伸到刘海与底部小横条下面，
     用 env(safe-area-inset-*) 让开。env() 在桌面端与不支持的浏览器里返回 0，
     所以这段对 Windows 桌面版零影响。
   · 安装提示条：pwa.js 在检测到"可以装成 App"时插入。
   ========================================================================== */
.app{
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  box-sizing: border-box;
}
@media (max-width: 1000px){
  /* 抽屉式侧边栏与全屏详情是 position:fixed，不受父级 padding 影响，要自己让 */
  .sidebar-inner{
    padding-top: calc(env(safe-area-inset-top) + 12px);
    padding-bottom: calc(env(safe-area-inset-bottom) + 12px);
  }
  .detail.open{
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    box-sizing: border-box;
  }
  .toasts{ bottom: calc(12px + env(safe-area-inset-bottom)); }
  .pwa-banner{ bottom: calc(12px + env(safe-area-inset-bottom)); }
}

.pwa-banner{
  position: fixed; left: 12px; right: 12px; z-index: 300;
  max-width: 520px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  background: var(--bg-panel); border: 1px solid var(--border);
  box-shadow: var(--shadow-3);
  animation: pwa-in .25s ease;
}
@keyframes pwa-in{ from{ transform: translateY(12px); opacity: 0; } to{ transform: none; opacity: 1; } }
.pwa-banner-text{ flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pwa-banner-text b{ font-size: 13px; color: var(--text); }
.pwa-banner-text span{ font-size: 12px; color: var(--text-2); line-height: 1.45; }
.pwa-banner-btn{
  flex: 0 0 auto; height: 30px; padding: 0 14px; border-radius: 8px; border: 0;
  background: var(--brand); color: #fff; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.pwa-banner-x{
  flex: 0 0 auto; width: 24px; height: 24px; border: 0; background: transparent;
  color: var(--text-3); font-size: 17px; line-height: 1; cursor: pointer; border-radius: 6px;
}
.pwa-banner-x:hover{ background: var(--bg-hover); color: var(--text); }
