/* =========================================================
   Lucky · 全局布局与通用组件
   ========================================================= */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: var(--fs-base);
  color: var(--c-text);
  background: var(--c-bg-grad);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}
::-webkit-scrollbar { width: 0; height: 0; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: var(--fs-base); color: var(--c-text); }
ul { margin: 0; padding: 0; list-style: none; }
h1,h2,h3,h4 { margin: 0; font-weight: 700; }

/* ---------- 顶部通栏 ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: 56px; display: flex; align-items: center; gap: 6px;
  padding: 0 10px;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--c-surface) 86%, transparent);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-soft);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.topbar-title { font-weight: 700; font-size: 16px; flex: 0 0 auto; max-width: 38vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 40px; height: 40px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 19px;
  border-radius: var(--radius-pill);
  background: var(--c-surface-2);
  box-shadow: var(--shadow-inset);
}
.icon-btn:active { animation: press .3s var(--ease); }
.topbar-search-trigger { margin-left: auto; }
.sync-btn { position: relative; }
.sync-dot { position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: #bbb; box-shadow: 0 0 0 2px var(--c-surface-2); }
.sync-dot.st-online { background: #57d98a; }
.sync-dot.st-syncing { background: #ffcf5c; animation: blink 1s infinite; }
.sync-dot.st-offline { background: #ff8a8a; }
.sync-dot.st-error { background: #ff6b6b; }
.sync-dot.st-local { background: #bbb; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.35} }
.sync-status { font-size: 12.5px; color: var(--c-text-2); background: var(--c-surface-2); border-radius: var(--radius); padding: 8px 10px; margin: 6px 0 2px; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 12.5px; color: var(--c-text-2); margin-bottom: 5px; }

/* ---------- 主内容区 ---------- */
.main {
  padding: calc(56px + env(safe-area-inset-top) + 14px) 14px calc(28px + env(safe-area-inset-bottom));
  max-width: 720px; margin: 0 auto; min-height: 100vh;
}
@media (min-width: 760px){ .main { padding-left: 14px; } }

/* ---------- 左侧抽屉 ---------- */
.drawer-mask { position: fixed; inset: 0; z-index: 49; background: rgba(40,30,40,.35); opacity: 0; pointer-events: none; transition: opacity var(--dur); }
.drawer-mask.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; width: 270px; max-width: 82vw;
  background: var(--c-surface); box-shadow: var(--shadow-pop);
  transform: translateX(-105%); transition: transform var(--dur) var(--ease-smooth);
  display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top) + 14px) 12px 14px;
  border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
}
.drawer.open { transform: translateX(0); }
.drawer-header { padding: 8px 10px 14px; }
.drawer-logo { font-size: 22px; font-weight: 800; color: var(--c-primary); }
.drawer-slogan { font-size: 11.5px; color: var(--c-text-soft); margin-top: 2px; }
.drawer-nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.drawer-nav li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-md);
  font-size: 15px; font-weight: 600; color: var(--c-text);
  min-height: var(--tap); transition: background var(--dur), transform .12s;
}
.drawer-nav li .nav-ico { font-size: 20px; width: 26px; text-align: center; }
.drawer-nav li.active { background: linear-gradient(120deg,var(--c-primary-soft),var(--c-accent-soft)); color: var(--c-primary); }
.drawer-nav li:active { transform: scale(.97); }
.drawer-footer { border-top: 1px solid var(--c-line); padding-top: 10px; margin-top: 6px; }
.drawer-foot-btn { width: 100%; text-align: left; padding: 12px 14px; border-radius: var(--radius-md); font-weight: 600; min-height: var(--tap); }
.drawer-foot-btn:active { background: var(--c-surface-2); }
.drawer-storage { text-align: center; font-size: 11px; color: var(--c-text-soft); margin-top: 8px; }

/* ---------- 卡片 / 区块 ---------- */
.card { background: var(--c-surface); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-soft); margin-bottom: 14px; }
.card-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-title .sub { font-size: 12px; color: var(--c-text-soft); font-weight: 500; margin-left: auto; }
.section { margin-bottom: 18px; }
.section-head { display: flex; align-items: center; margin-bottom: 10px; }
.section-head h3 { font-size: 16px; }
.section-head .action { margin-left: auto; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 10px 18px; border-radius: var(--radius-pill);
  font-weight: 700; font-size: 14px; background: var(--c-surface-2); color: var(--c-text);
  box-shadow: var(--shadow-inset);
}
.btn.primary { background: linear-gradient(120deg,var(--c-primary),var(--c-accent)); color: #fff; box-shadow: var(--shadow-soft); }
.btn.soft { background: var(--c-primary-soft); color: var(--c-primary); }
.btn.danger { background: var(--c-danger); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 7px 13px; font-size: 13px; }
.text-btn { color: var(--c-primary); font-weight: 600; padding: 8px 10px; min-height: var(--tap); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row .btn { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }

/* ---------- 表单控件 ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--c-text-soft); margin-bottom: 6px; }
.input, .textarea, .select {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-md);
  background: var(--c-surface-2); border: 2px solid transparent; outline: none;
  transition: border var(--dur);
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--c-primary); }
.textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.seg { display: flex; gap: 6px; background: var(--c-surface-2); padding: 4px; border-radius: var(--radius-pill); }
.seg button { flex: 1; min-height: 38px; border-radius: var(--radius-pill); font-weight: 600; color: var(--c-text-soft); }
.seg button.on { background: var(--c-surface); color: var(--c-primary); box-shadow: var(--shadow-soft); }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px;
  border-radius: var(--radius-pill); background: var(--c-surface-2); font-size: 13px; font-weight: 600;
  min-height: 34px;
}
.chip.on { background: var(--c-primary-soft); color: var(--c-primary); }
.switch { position: relative; width: 50px; height: 30px; border-radius: var(--radius-pill); background: var(--c-line); transition: background var(--dur); flex: 0 0 auto; }
.switch.on { background: var(--c-primary); }
.switch::after { content:""; position:absolute; top:3px; left:3px; width:24px; height:24px; border-radius:50%; background:#fff; box-shadow: var(--shadow-soft); transition: transform var(--dur) var(--ease); }
.switch.on::after { transform: translateX(20px); }
.setting-row { display: flex; align-items: center; gap: 10px; padding: 12px 2px; border-bottom: 1px solid var(--c-line); }
.setting-row:last-child { border-bottom: none; }
.setting-row .label { flex: 1; }
.setting-row .label .desc { font-size: 11.5px; color: var(--c-text-soft); margin-top: 2px; }

/* ---------- 浮层 / 弹窗 ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(40,30,40,.4); display: none; align-items: flex-end; justify-content: center; padding: 0; }
.overlay.open { display: flex; animation: fade-in .25s; }
.overlay-card {
  width: 100%; max-width: 720px; background: var(--c-surface); border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-pop);
  max-height: 90vh; overflow-y: auto; animation: slide-up .3s var(--ease);
}
.modal-mask { align-items: center; }
.modal-card { border-radius: var(--radius-xl); max-height: 84vh; width: 92%; animation: pop-in .3s var(--ease); }
@media (min-width: 760px){ .overlay-card { border-radius: var(--radius-xl); margin: auto; animation: pop-in .3s var(--ease); } }

/* ---------- 轻提示 toast ---------- */
.toast-wrap { position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: rgba(50,40,46,.92); color: #fff; padding: 10px 18px; border-radius: var(--radius-pill); font-size: 13.5px; box-shadow: var(--shadow-pop); animation: slide-up .3s var(--ease); max-width: 80vw; text-align: center; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 40px 16px; color: var(--c-text-soft); }
.empty .emo { font-size: 52px; display: block; margin-bottom: 10px; animation: bob 4s ease-in-out infinite; }
.empty p { margin: 4px 0; }

/* ---------- 高亮（搜索命中） ---------- */
mark { background: linear-gradient(120deg,var(--c-primary-soft),var(--c-accent-soft)); color: var(--c-primary); padding: 0 3px; border-radius: 6px; font-weight: 700; }
mark.m-title { background: var(--c-primary); color:#fff; }

/* ---------- 列表项 ---------- */
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: var(--radius-md); background: var(--c-surface-2); margin-bottom: 8px; min-height: var(--tap); }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .li-sub { font-size: 12px; color: var(--c-text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 统计条 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; }
.stat-box { background: var(--c-surface-2); border-radius: var(--radius-md); padding: 12px; }
.stat-box .v { font-size: 19px; font-weight: 800; color: var(--c-primary); }
.stat-box .v.b { color: var(--c-accent); }
.stat-box .k { font-size: 11.5px; color: var(--c-text-soft); margin-top: 2px; }

/* ---------- 通用工具类 ---------- */
.muted { color: var(--c-text-soft); }
.center { text-align: center; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.hide { display: none !important; }
.fade-in { animation: fade-in .3s; }
.scroll-x { overflow-x: auto; display: flex; gap: 8px; padding-bottom: 4px; }
.pill-tag { display:inline-block; padding:3px 10px; border-radius: var(--radius-pill); background: var(--c-primary-soft); color: var(--c-primary); font-size: 12px; font-weight:600; margin:2px; }
