:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #9aa3b2;
  --line: #eef0f4;
  --primary: #1a1f36;
  --accent: #5b6cff;
  --orange: #f59e0b;
  --green: #22c55e;
  --blue: #3b82f6;
  --tag-bg: #eef0ff;
  --tag-text: #5b6cff;
  --shadow: 0 8px 24px rgba(31, 41, 55, 0.06);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 14px 100px;
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}
.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}
.topbar .hint {
  color: var(--muted);
  font-size: 12px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.card-title .icon { font-size: 16px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.field input, .consume-item input, .tag-add-row input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  background: #fafbff;
  outline: none;
}
.field input:focus, .consume-item input:focus, .tag-add-row input:focus {
  border-color: #c7ceff;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(91, 108, 255, 0.12);
}

.with-unit {
  display: flex;
  align-items: center;
  gap: 6px;
}
.with-unit em {
  font-style: normal;
  color: var(--orange);
  font-weight: 700;
  font-size: 14px;
}
.with-unit input { flex: 1; }

/* 标签 */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 36px;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 999px;
  padding: 6px 10px 6px 12px;
  font-size: 13px;
  font-weight: 600;
}
.tag button {
  border: none;
  background: transparent;
  color: var(--tag-text);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  opacity: 0.7;
}
.tag button:hover { opacity: 1; }
.tag.suggested {
  background: #f0fdf4;
  color: #16a34a;
  cursor: pointer;
  border: 1px dashed #86efac;
}

.tag-add-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.tag-add-row input { flex: 1; }

/* 消费 */
.summary-banner {
  background: #eef0ff;
  color: var(--accent);
  text-align: center;
  border-radius: 12px;
  padding: 12px;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 12px;
}

.consume-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.consume-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fafbff;
  position: relative;
}
.consume-item .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.consume-item .row:last-child { margin-bottom: 0; }
.consume-item label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}
.consume-item .remove {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: transparent;
  color: #c0c6d2;
  cursor: pointer;
  font-size: 16px;
}
.consume-item .remove:hover { color: #ef4444; }
.amount-strong { color: var(--orange); font-weight: 700; }

/* 结果 */
.result-card { border: 1.5px solid #dbe1ff; }
.result-block {
  background: #fbfcff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  margin-bottom: 12px;
}
.result-block h2 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 800;
  outline: none;
}
.result-block p {
  margin: 0;
  color: #8b93a7;
  font-size: 13px;
  line-height: 1.6;
  outline: none;
}

.icebreaker {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  padding: 14px;
}
.ice-label {
  font-size: 13px;
  font-weight: 700;
  color: #16a34a;
  margin-bottom: 8px;
}
.ice-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  outline: none;
  min-height: 48px;
  margin-bottom: 12px;
}
.ice-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.suggested { margin-top: 14px; }
.suggested .ice-label { color: var(--muted); font-weight: 600; }

/* 按钮 */
.btn {
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px dashed #c7ceff;
}
.btn.block { width: 100%; padding: 10px; }
.btn.green { background: var(--green); color: #fff; }
.btn.blue { background: var(--blue); color: #fff; }
.btn.primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  padding: 14px 18px;
  font-size: 16px;
  box-shadow: 0 10px 24px rgba(26, 31, 54, 0.28);
}
.btn.primary:hover { filter: brightness(1.08); }

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(243,245,249,0.98), rgba(243,245,249,0.88));
  display: flex;
  justify-content: center;
}
.bottom-bar .btn.primary { max-width: 480px; }

.loading {
  text-align: center;
  color: var(--accent);
  font-size: 13px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #eef0ff;
  border-radius: 12px;
  font-weight: 600;
}
.error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
  margin-bottom: 12px;
  white-space: pre-wrap;
}

.payload-preview {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.5;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: #fff;
  border: 1px dashed #d1d5db;
  border-radius: 12px;
  word-break: break-all;
}

/* JSON 监视窗 */
.monitor-card {
  border: 1px solid #e5e7eb;
  background: #fcfcfd;
}
.monitor-card .card-title {
  justify-content: flex-start;
  gap: 8px;
}
.monitor-status {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  color: #6b7280;
  background: #f3f4f6;
  border-radius: 999px;
  padding: 4px 10px;
}
.monitor-status.pending {
  color: #b45309;
  background: #fffbeb;
}
.monitor-status.ok {
  color: #15803d;
  background: #f0fdf4;
}
.monitor-status.err {
  color: #b91c1c;
  background: #fef2f2;
}
.monitor-meta {
  font-size: 12px;
  color: var(--muted);
  margin: -4px 0 12px;
  line-height: 1.5;
}
.monitor-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.monitor-pane {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #0b1020;
}
.monitor-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: #151b2f;
  color: #dbe4ff;
  font-size: 12px;
}
.monitor-pane-head strong { font-weight: 700; }
.btn.tiny {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 8px;
  background: #2a3352;
  color: #e5e7eb;
}
.btn.tiny:hover { filter: brightness(1.1); }
.monitor-pre {
  margin: 0;
  padding: 12px;
  max-height: 280px;
  overflow: auto;
  color: #d1fae5;
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.result-meta {
  font-size: 12px;
  color: var(--muted);
  margin: -4px 0 12px;
}

.result-card.dimmed {
  opacity: 0.45;
  pointer-events: none;
}

.result-card.flash {
  animation: resultFlash 0.8s ease;
}

@keyframes resultFlash {
  0% { box-shadow: 0 0 0 0 rgba(91, 108, 255, 0.55); }
  100% { box-shadow: var(--shadow); }
}

[contenteditable="true"]:focus {
  outline: 2px dashed #c7ceff;
  outline-offset: 4px;
  border-radius: 6px;
}

@media (min-width: 520px) {
  .app { padding-top: 24px; }
}
