:root {
  --bg: #f5f6f8;
  --card: #fff;
  --text: #1d2129;
  --sub: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-weak: #eff4ff;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #059669;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
.boot { padding: 80px 20px; text-align: center; color: var(--sub); }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 12px calc(40px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 10; background: rgba(245, 246, 248, .92);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
}
.topbar-inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 8px; }
.top-search { position: relative; max-width: 760px; margin: 0 auto 8px; }
.top-search-pill {
  display: flex; align-items: center; gap: 8px; width: 100%;
  height: 40px; padding: 0 14px; border-radius: 999px;
  background: #ececee; border: 1px solid #e3e3e6; cursor: text;
}
.top-search-ico { flex: none; width: 18px; height: 18px; color: #6b7280; }
.top-search-pill input[type=search] {
  flex: 1; min-width: 0; width: auto; height: 100%;
  border: 0 !important; background: transparent !important; border-radius: 0 !important;
  padding: 0 !important; outline: none; font-size: 16px; line-height: 1.25; box-shadow: none;
  -webkit-appearance: none; appearance: none;
  transform: translateZ(0);
}
.top-search-pill input[type=search]:focus { border: 0 !important; box-shadow: none; }
.top-search-pill input[type=search]::placeholder { color: #9ca3af; }
.top-search-pill input[type=search]::-webkit-search-decoration,
.top-search-pill input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30;
  background: #fff; border-radius: 14px; overflow: auto;
  max-height: min(70vh, 440px);
  box-shadow: 0 10px 32px rgba(0,0,0,.14), 0 0 0 1px rgba(0,0,0,.05);
}
.suggest-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border: 0; border-bottom: 1px solid #f1f2f4;
  background: #fff; text-align: left; cursor: pointer; font: inherit; color: inherit;
}
.suggest-row:last-child { border-bottom: 0; }
.suggest-row:hover, .suggest-row:active, .suggest-row.on { background: #f3f4f6; }
.suggest-more {
  display: block; padding: 12px 14px; border-top: 1px solid #f1f2f4;
  font-size: 13px; font-weight: 600; color: #cd4801; text-align: center;
}
.suggest-more:hover, .suggest-more:active { background: #fff7f2; }
.suggest-thumb {
  width: 44px; height: 44px; border-radius: 8px; object-fit: cover;
  background: #eef0f3; flex: none;
}
.suggest-thumb.ph { background: linear-gradient(135deg, #eef0f3, #e5e7eb); }
.suggest-body { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.suggest-title {
  font-size: 13.5px; font-weight: 600; line-height: 1.35;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.suggest-tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 600; line-height: 1.3; background: #1f2937; color: #fff;
}
.suggest-price { font-size: 12px; color: #cd4801; font-weight: 700; }
.suggest-chev { color: #c4c7ce; font-size: 20px; line-height: 1; flex: none; }
.suggest-empty { padding: 18px 14px; text-align: center; color: var(--sub); font-size: 13px; }
a.suggest-row { text-decoration: none; color: inherit; }
.brand { font-weight: 700; font-size: 18px; flex: 1; }
.nav { display: flex; gap: 4px; align-items: center; }
.nav button { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; color: var(--sub); cursor: pointer; }
.nav button.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.nav .nav-ext {
  display: inline-block; padding: 6px 12px; border-radius: 999px; color: #0f766e;
  background: #ecfdf5; font-weight: 600; font-size: 13px; white-space: nowrap;
}
.nav .nav-ext:active { transform: scale(.98); }

.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-top: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.muted { color: var(--sub); font-size: 13px; }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 14px;
  cursor: pointer; white-space: nowrap; line-height: 1.2;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--primary); padding: 6px 8px; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

textarea, input[type=text], input[type=search], input[type=number], input[type=date], input[type=datetime-local],
input[type=url], input[type=email], input[type=password], label.field select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: #fff; outline: none;
}
textarea:focus, input:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 64px; }
label.field { display: block; margin-top: 10px; }
label.field > span { display: block; font-size: 13px; color: var(--sub); margin-bottom: 4px; }

.jobs-bar { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; }
.jobs-bar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.job { display: flex; gap: 8px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.job:first-child { border-top: 0; }
.job .st { flex: none; width: 52px; font-size: 12px; }
.st.done { color: var(--ok); } .st.failed { color: var(--danger); } .st.pending, .st.running { color: var(--primary); } .st.canceled { color: var(--sub); }
.job .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px 3px; margin-top: 14px; }
.tabs button { border: 0; background: transparent; padding: 5px 8px; border-radius: 999px; color: var(--sub); cursor: pointer; white-space: nowrap; font-size: 12.5px; line-height: 1.3; }
.tabs button.on { background: var(--text); color: #fff; }
.tabs button.admin { color: #7c3aed; }
.tabs button.admin.on { background: #7c3aed; color: #fff; }
.tabs .n { font-size: 10px; opacity: .8; margin-left: 1px; }
.tabs button.reload { margin-left: auto; color: var(--text); border: 1px solid var(--line); background: var(--card); }
.tabs button.reload:disabled { opacity: .5; }
.tabs .n.hot { color: var(--ok); font-weight: 600; opacity: 1; }
.tabs button.on .n.hot { color: #bbf7d0; }

/* 监控（管理员） */
.mon-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 10px 0 8px; }
.mon { background: var(--card); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.04); touch-action: pan-y; }
.mon.paused { opacity: .6; }
.mon.dragging { opacity: .55; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.mon.drag-over { outline: 2px dashed var(--primary); outline-offset: 1px; }
.mon-head { display: flex; align-items: flex-start; gap: 8px; }
.mon-drag {
  flex: none; width: 22px; height: 22px; line-height: 22px; text-align: center;
  color: #9ca3af; cursor: grab; user-select: none; font-size: 14px; margin-top: 1px;
}
.mon-drag:active { cursor: grabbing; }
.mon-name { font-weight: 600; font-size: 14px; flex: 1; word-break: break-all; }
.mon-meta { font-size: 12px; color: var(--sub); margin-top: 4px; line-height: 1.6; word-break: break-all; }
.mon-meta a { color: var(--sub); text-decoration: underline; }
.funds { margin-top: 8px; border-top: 1px solid var(--line); }
.fund { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 12px; color: var(--text); }
.fund-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fund-state { flex: none; color: var(--sub); }
.fund-state.open { color: var(--ok); font-weight: 600; }
.mon-acts { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.mon-acts .btn { padding: 4px 10px; font-size: 12px; }
.mon-set .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mon-log { font-size: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); line-height: 1.5; word-break: break-all; }
.mon-log b { font-weight: 600; }
.field.inline { display: flex; align-items: center; gap: 8px; }
.field.inline input { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--primary); }
.field.inline > span { margin: 0; color: var(--text); font-size: 14px; }

.item { display: flex; gap: 12px; background: var(--card); border-radius: var(--radius); padding: 12px; margin-top: 10px; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.item:active { background: #fafafa; }
.thumb { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; background: #eef0f3; flex: none; }
.thumb.ph { display: flex; align-items: center; justify-content: center; color: #9ca3af; font-size: 12px; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 600; font-size: 15px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .meta { margin-top: 5px; font-size: 13px; color: var(--sub); line-height: 1.5; }
.item .meta b { font-weight: 600; color: var(--text); }
.badges .del { margin-left: auto; color: var(--danger); padding: 4px 12px; margin-right: -8px; font-size: 13px; }
.badges .del:hover { color: var(--danger); }
.urgent { color: var(--danger) !important; }
.soon { color: var(--warn) !important; }
.badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: #f1f2f4; color: var(--sub); }
.badge.blue { background: var(--primary-weak); color: var(--primary); }
.badge.green { background: #ecfdf5; color: var(--ok); }
.badge.red { background: #fef2f2; color: var(--danger); }
.badge.orange { background: #fff7ed; color: #c2410c; }
.list-note { margin: 4px 2px 8px; }
.btn.more { display: block; margin: 4px auto 12px; color: var(--sub); font-size: 13px; }
.prefs { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.pref-label { font-size: 13px; color: var(--sub); margin-top: 10px; }
.prefs .chks { margin-top: 6px; }
.prefs select { margin-top: 6px; width: auto; }
.empty { text-align: center; color: var(--sub); padding: 40px 10px; font-size: 14px; line-height: 1.7; }

.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; display: flex; align-items: stretch; justify-content: center; }
/* 手机上整页显示：vh 在 iPhone Safari 里包含工具栏后面的区域，底部弹层的顶端会被推出屏幕 */
.sheet {
  background: var(--card); width: 100%; height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
}
@media (min-width: 700px) {
  .modal-mask { align-items: center; }
  .sheet { max-width: 640px; height: auto; max-height: 90vh; max-height: 90dvh; border-radius: 16px; }
}
.sheet-head {
  display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 2; background: var(--card);
  margin: 0 -16px 10px; padding: calc(8px + env(safe-area-inset-top)) 16px 8px; border-bottom: 1px solid var(--line);
}
@media (min-width: 700px) { .sheet-head { padding-top: 10px; } }
.sheet-head h2 { flex: 1; margin: 0; font-size: 17px; }
.sheet-head .back { padding-left: 0; font-size: 15px; }
.sheet-title { margin: 0 0 10px; font-size: 17px; line-height: 1.4; }
.detail-top { display: flex; gap: 12px; align-items: flex-start; }
.detail-top .sheet-title { flex: 1; min-width: 0; }
.hero { width: 100%; max-height: 260px; object-fit: contain; background: #f3f4f6; border-radius: 12px; }
.kv { display: grid; grid-template-columns: 72px 1fr; gap: 8px 10px; margin-top: 12px; font-size: 14px; }
.kv .k { color: var(--sub); }
.kv .v { word-break: break-all; }
.howto { white-space: pre-wrap; line-height: 1.6; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.edited { font-size: 11px; color: var(--warn); margin-left: 4px; }

.token { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.token .links { flex-basis: 100%; }
.linkline { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.linkline .secret { flex: 1; margin-top: 0; min-width: 0; }
.linkline .tag { flex: none; font-size: 12px; color: var(--muted, #6b7280); width: 3.2em; }
.token:first-of-type { border-top: 0; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; background: #f3f4f6; border-radius: 8px; padding: 8px 10px; margin-top: 8px; user-select: all; -webkit-user-select: all; }
.notice { background: #fffbeb; border-radius: 10px; padding: 10px 12px; font-size: 13px; color: #92400e; margin-top: 10px; line-height: 1.6; }
.guide ol { padding-left: 20px; margin: 8px 0; line-height: 1.75; font-size: 14px; }
.guide li { margin-bottom: 4px; }
.guide code { background: #f3f4f6; border-radius: 4px; padding: 1px 5px; font-size: 12px; word-break: break-all; }
details summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 4px 0; }

.chks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chk { display: flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; cursor: pointer; }
.chk input { margin: 0; width: 16px; height: 16px; accent-color: var(--primary); }

.confirm-mask { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 20px; }
.confirm { background: var(--card); border-radius: 14px; width: min(340px, 100%); padding: 20px 18px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.confirm-msg { font-size: 15px; line-height: 1.6; word-break: break-all; }
.confirm-btns { display: flex; gap: 10px; margin-top: 18px; }
.confirm-btns .btn { flex: 1; padding: 10px 0; font-size: 15px; }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }

#toast {
  position: fixed; left: 50%; bottom: calc(30px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: rgba(17,24,39,.92); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 86vw;
  opacity: 0; transition: all .2s; pointer-events: none; z-index: 100; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.login { max-width: 420px; margin: 12vh auto 0; padding: 0 16px; text-align: center; }
.login h1 { font-size: 22px; }
