:root {
  --bg: #ebe7df;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #d6d3d1;
  --panel: #fffdf8;
  --accent: #ea580c;
  --accent-deep: #c2410c;
  --editor: #1c1917;
  --editor-fg: #f5f5f4;
  /* QQ / 国内 WebView 优先系统字体 */
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "SF Mono", "Menlo", "Consolas", "Courier New", monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --dock-h: 74px;
  --app-h: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

.is-hidden {
  display: none !important;
}

.file-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.app {
  position: relative;
  width: 100%;
  height: var(--app-h);
  max-width: 920px;
  margin: 0 auto;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  padding-bottom: calc(var(--dock-h) + var(--safe-b) + 8px);
  overflow: hidden;
}

.top {
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  display: -webkit-flex;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px 8px;
}

.brand {
  display: -webkit-flex;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: -webkit-flex;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ea580c;
  color: #fff;
  font-weight: 800;
}

.brand strong {
  font-size: 1.15rem;
  font-weight: 800;
}

.help-btn {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: 700 0.86rem/1 var(--font);
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
}

.stage {
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0 12px 8px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
  position: relative;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
}

.pane {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  min-height: 0;
  -webkit-flex: 1;
  flex: 1;
  height: 100%;
}

.edit-bar {
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  display: -webkit-flex;
  display: flex;
  gap: 8px;
  padding: 10px;
  background: #f5f0e8;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.import-btn,
.chip {
  -webkit-appearance: none;
  appearance: none;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 40px;
  padding: 0 14px;
  font: 700 0.86rem/1 var(--font);
  display: -webkit-inline-flex;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}

.import-btn {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.chip {
  background: #fff;
  color: var(--ink);
}

#code {
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  width: 100%;
  min-height: 120px;
  border: 0;
  resize: none;
  outline: none;
  padding: 14px;
  background: var(--editor);
  color: var(--editor-fg);
  font: 400 13px/1.55 var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: -webkit-flex;
  display: flex;
  gap: 10px;
  padding: 10px 12px calc(10px + var(--safe-b));
  background: #fffdf8;
  border-top: 1px solid var(--line);
}

body.is-qq .dock {
  padding-bottom: calc(14px + var(--safe-b));
}

.dock-btn {
  -webkit-appearance: none;
  appearance: none;
  -webkit-flex: 1;
  flex: 1;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 14px;
  min-height: 48px;
  font: 800 0.92rem/1 var(--font);
}

.dock-main {
  -webkit-flex: 1.35;
  flex: 1.35;
  background: #ea580c;
  border-color: #ea580c;
  color: #fff;
}

.modal {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.help-modal {
  z-index: 55;
}

.modal-bg {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: rgba(28, 25, 23, 0.5);
}

.modal-card,
.help-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  max-height: 75%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
  border-radius: 18px;
  padding: 18px 14px 14px;
  margin: 0;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.modal-card h2,
.help-card h2 {
  margin: 0 0 12px;
  font-size: 1.25rem;
}

.modal-desc {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.9rem;
}

.field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}

#shareUrl {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  font: 400 0.8rem/1.35 var(--mono);
  background: #f5f5f4;
  margin-bottom: 12px;
  box-sizing: border-box;
}

.modal-actions {
  display: -webkit-flex;
  display: flex;
  gap: 8px;
}

.modal-actions .btn {
  -webkit-flex: 1;
  flex: 1;
}

.btn {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 44px;
  font: 700 0.88rem/1 var(--font);
  display: -webkit-inline-flex;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--ink);
  background: #fff;
}

.btn.solid {
  background: #ea580c;
  border-color: #ea580c;
  color: #fff;
}

.btn.ghost {
  background: #f5f5f4;
}

.modal-note {
  margin: 12px 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.4;
}

.help-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.help-steps li {
  padding: 12px;
  border-radius: 14px;
  background: #f5f5f4;
  border: 1px solid var(--line);
  counter-increment: step;
  margin-bottom: 10px;
}

.help-steps li strong {
  display: -webkit-flex;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}

.help-steps li strong::before {
  content: counter(step);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ea580c;
  color: #fff;
  font-size: 0.75rem;
  display: -webkit-flex;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
}

.help-figure {
  margin: 10px 0 8px;
}

.fig-phone {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
}

.fig-bar {
  display: -webkit-flex;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.fig-logo {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: #ea580c;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  display: -webkit-flex;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fig-title {
  font-size: 0.78rem;
  font-weight: 800;
}

.fig-row,
.fig-dock {
  display: -webkit-flex;
  display: flex;
  gap: 6px;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
}

.fig-dock {
  margin-top: 8px;
}

.fig-pill,
.fig-chip {
  display: -webkit-inline-flex;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  min-height: 28px;
  padding: 0 10px;
}

.fig-pill-dark {
  background: #1c1917;
  color: #fff;
  outline: 2px solid #ea580c;
  outline-offset: 2px;
}

.fig-pill-light {
  background: #fff;
  color: #1c1917;
  border: 1px solid var(--line);
  outline: 2px solid #ea580c;
  outline-offset: 2px;
}

.fig-pill-orange {
  background: #ea580c;
  color: #fff;
  -webkit-flex: 1;
  flex: 1;
}

.fig-chip {
  background: #f5f5f4;
  border: 1px solid var(--line);
  color: var(--muted);
}

.fig-editor {
  margin-top: 8px;
  background: #1c1917;
  color: #a8a29e;
  border-radius: 8px;
  padding: 10px;
  font: 400 0.7rem/1.4 var(--mono);
  min-height: 36px;
}

.fig-editor-tall {
  min-height: 52px;
}

.fig-tip {
  margin-top: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-deep);
  text-align: center;
}

.help-steps p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
  font-weight: 500;
}

.help-steps code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: #ebe7df;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  color: var(--ink);
}

.help-ok {
  width: 100%;
  margin-top: 4px;
  min-height: 48px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-h) + var(--safe-b) + 14px);
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  max-width: calc(100% - 28px);
  background: var(--ink);
  color: #fff;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  font: 700 0.86rem/1.3 var(--font);
  z-index: 60;
}

.site-view {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  background: #fff;
}

.site-banner {
  padding: 10px 14px;
  font-size: 0.82rem;
  background: var(--ink);
  color: #e7e5e4;
}

.site-banner a {
  color: #fdba74;
}

.site-view iframe {
  -webkit-flex: 1;
  flex: 1;
  width: 100%;
  border: 0;
}

.site-error {
  margin: auto;
  max-width: 340px;
  padding: 24px 16px;
  text-align: center;
}

.site-error h1 {
  margin: 0 0 8px;
  font-size: 1.3rem;
}

.site-error p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}
