* { box-sizing: border-box; }
:root {
  --green: #07c160;
  --green-d: #06ad56;
  --red: #fa5151;
  --border: #e5e6eb;
  --text: #1f2329;
  --muted: #8a8f99;
  --bg: #f5f6f8;
}
body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}
.hidden { display: none !important; }
code { background: #f0f1f3; padding: 1px 4px; border-radius: 3px; }

/* 顶部栏整合凭证输入，紧凑且清晰 */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left { display: flex; align-items: baseline; gap: 10px; }
.topbar-left h1 { margin: 0; font-size: 16px; white-space: nowrap; }
.topbar-left .sub { color: var(--muted); font-size: 12px; white-space: nowrap; }

.topbar-cred {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.cred-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.cred-item label { color: #4e5969; font-weight: 500; white-space: nowrap; }
.cred-item input {
  padding: 5px 8px;
  width: 170px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
}
.cred-item .input-group input { width: 140px; }

.layout {
  display: flex;
  gap: 24px;
  padding: 16px 24px;
  max-width: 1260px;
  margin: 0 auto;
  align-items: flex-start;
}
.col-left {
  width: 320px;
  flex-shrink: 0;
  position: sticky;
  top: 72px; /* 保证左侧手机模拟器固定在屏幕视口上方，无需向下滚动 */
}
.col-right { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }

.card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 18px; }
.card h2 { margin: 0 0 12px; font-size: 15px; }
.tip { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: #4e5969; margin-bottom: 4px; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 3px; }
.field .hint.err { color: var(--red); }
input[type=text], input:not([type]), input[type=password], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  font: inherit; color: inherit; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 2px rgba(7,193,96,.12); }
.input-group { display: flex; gap: 6px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #4e5969; white-space: nowrap; cursor: pointer; }
textarea#jsonText { height: 420px; font: 12.5px/1.5 Menlo, Consolas, monospace; resize: vertical; margin: 10px 0; }
.row { display: flex; gap: 8px; }

.btn { border: 1px solid var(--border); background: #fff; padding: 7px 14px; border-radius: 6px; cursor: pointer; font: inherit; color: inherit; white-space: nowrap; }
.btn:hover { border-color: #c9cdd4; background: #fafafa; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-d); }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.dirty { color: #ff8800; font-size: 12px; }

.status { border-radius: 8px; padding: 10px 14px; font-size: 13px; white-space: pre-wrap; }
.status.ok { background: #e8f8ef; color: #0a7a3f; border: 1px solid #b7ebcc; }
.status.err { background: #fff1f0; color: #c4302b; border: 1px solid #ffccc7; }
.status.warn { background: #fff7e6; color: #ad6800; border: 1px solid #ffe2a8; }
.status ul { margin: 6px 0 0; padding-left: 18px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab { border: none; background: none; padding: 8px 14px; cursor: pointer; font: inherit; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--green); border-bottom-color: var(--green); font-weight: 600; }

/* 手机预览：紧凑高度，完全适配常规浏览器视口 */
.phone {
  width: 320px;
  height: 500px;
  border: 1px solid #d9d9d9;
  border-radius: 20px;
  background: #ededed;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0,0,0,.06);
}
.phone-header { background: #ededed; text-align: center; padding: 12px 0 8px; font-weight: 600; border-bottom: 1px solid #ddd; font-size: 13px; }
.phone-body { flex: 1; padding: 14px; }
.bubble { display: inline-block; background: #fff; padding: 8px 12px; border-radius: 6px; color: var(--muted); font-size: 12px; }
.menubar { display: flex; height: 50px; background: #f7f7f7; border-top: 1px solid #d6d6d6; position: relative; }
.menubar .kbd { width: 40px; display: flex; align-items: center; justify-content: center; color: #777; border-right: 1px solid #d6d6d6; font-size: 16px; }
.mb-item { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; cursor: pointer; border-left: 1px solid #d6d6d6; font-size: 13px; padding: 0 4px; min-width: 0; }
.mb-item:first-of-type { border-left: none; }
.mb-item > .label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mb-item:hover { background: #ececec; }
.mb-item.selected { color: var(--green); box-shadow: inset 0 0 0 2px var(--green); }
.mb-item.add, .sub-item.add { color: #999; font-size: 20px; }
.mb-item.has-err > .label::after, .sub-item.has-err::after { content: " !"; color: var(--red); font-weight: 700; }
.submenu { position: absolute; bottom: 58px; left: 4px; right: 4px; background: #fff; border: 1px solid #d6d6d6; border-radius: 6px; box-shadow: 0 2px 10px rgba(0,0,0,.08); cursor: default; }
.submenu::after { content: ""; position: absolute; bottom: -6px; left: 50%; margin-left: -6px; width: 10px; height: 10px; background: #fff; border-right: 1px solid #d6d6d6; border-bottom: 1px solid #d6d6d6; transform: rotate(45deg); }
.sub-item { padding: 9px 6px; text-align: center; border-top: 1px solid #eee; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text); font-size: 13px; }
.sub-item:first-child { border-top: none; }
.sub-item:hover { background: #f5f5f5; }
.sub-item.selected { color: var(--green); box-shadow: inset 0 0 0 2px var(--green); border-radius: 4px; }
.mb-item .sub-icon { color: #999; margin-right: 3px; font-size: 12px; }

/* 编辑器 */
.editor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.editor-head h3 { margin: 0; font-size: 15px; }
.editor-head .ops { display: flex; gap: 6px; }
.empty { color: var(--muted); text-align: center; padding: 60px 0; }
.note { background: #f7f8fa; border-radius: 6px; padding: 10px 12px; color: #4e5969; font-size: 13px; }
.sublist { margin-top: 8px; }
.sublist .item { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 6px; cursor: pointer; }
.sublist .item:hover { border-color: var(--green); }
.sublist .item small { color: var(--muted); }

.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.78); color: #fff; padding: 9px 18px; border-radius: 6px; z-index: 99; font-size: 13px; }

@media (max-width: 860px) {
  .layout { flex-direction: column; padding: 16px; }
  .col-left { width: 100%; position: static; align-items: center; }
}
