:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e3e5ea;
  --text: #1c1f24;
  --muted: #6b7280;
  --brand: #7a1f2b;
  --brand-soft: #fdf3f4;
  --ok: #1f8a54;
  --warn: #b45309;
  --danger: #c0392b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 14px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.7;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
.wrap.wide { max-width: 1040px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

h1 { font-size: 19px; font-weight: 600; margin: 0 0 6px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 10px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; color: var(--muted); }
p { margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 13px; }
.tiny { color: var(--muted); font-size: 12px; }

label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }

input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); }
textarea { resize: vertical; min-height: 96px; }

button {
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 16px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost { background: #fff; color: var(--text); border-color: var(--line); }
button.soft { background: var(--brand-soft); color: var(--brand); border-color: #f2dadd; }
button.danger { background: #fff; color: var(--danger); border-color: #f0cfcb; }
button.sm { font-size: 13px; padding: 7px 11px; border-radius: 8px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.grow { flex: 1 1 160px; min-width: 0; }

.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eef0f4; color: var(--muted); }
.badge.open { background: #e8f6ee; color: var(--ok); }
.badge.closed { background: #f3f4f6; color: var(--muted); }

.q { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.q:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.q-title { font-weight: 500; margin-bottom: 8px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat {
  background: var(--brand-soft);
  border: 1px solid #f2dadd;
  border-radius: 10px;
  padding: 10px 12px;
}
.stat b { display: block; font-size: 22px; font-weight: 600; color: var(--brand); line-height: 1.3; }
.stat span { font-size: 12px; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; white-space: nowrap; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.code-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 26px;
  letter-spacing: 4px;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-soft);
  border: 1px dashed #e2c3c7;
  border-radius: 10px;
  padding: 10px 16px;
  text-align: center;
}

.link-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
  background: #f7f8fa;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #23272e;
  color: #fff;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 999px;
  max-width: 86vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s;
  z-index: 90;
}
.toast.show { opacity: 1; }

.err-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: #fdecea;
  color: #a3281c;
  border-bottom: 1px solid #f3c9c4;
  font-size: 12px;
  padding: 6px 12px;
  z-index: 99;
  display: none;
}

.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 26px 10px; }

.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 14px 0 4px; }

@media (min-width: 760px) {
  body { font-size: 15px; }
  .wrap { padding: 24px; }
  .card { padding: 22px; }
}
