/* ===== JSON 工具箱 · 样式 ===== */
:root {
  --bg: #f4f5fa;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-hover: #eef0f7;
  --text: #1e2233;
  --text-sub: #6b7280;
  --border: #e3e6ef;
  --accent: #6366f1;
  --accent-strong: #4f46e5;
  --accent-soft: #eef0ff;
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --err: #dc2626;
  --err-bg: #fef2f2;
  --warn: #b45309;
  --code-bg: #f8f9fc;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 12px;
}

html[data-theme="dark"] {
  --bg: #101322;
  --bg-card: #181c2e;
  --bg-input: #141827;
  --bg-hover: #232842;
  --text: #e6e9f5;
  --text-sub: #98a0b8;
  --border: #2a3049;
  --accent: #818cf8;
  --accent-strong: #a5b4fc;
  --accent-soft: #262c4a;
  --ok: #34d399;
  --ok-bg: #10312a;
  --err: #f87171;
  --err-bg: #3a1d20;
  --warn: #fbbf24;
  --code-bg: #131726;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

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

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== 顶栏 ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { border-radius: 9px; box-shadow: var(--shadow); }
.brand-text h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand-sub { font-size: 12px; color: var(--text-sub); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.offline-badge {
  font-size: 12px;
  color: var(--warn);
  background: var(--ok-bg);
  border: 1px solid var(--warn);
  padding: 2px 10px;
  border-radius: 999px;
}
html[data-theme="dark"] .offline-badge { background: transparent; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-sub);
  cursor: pointer;
  transition: all .15s ease;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.icon-sun { display: none; }
html[data-theme="dark"] .icon-sun { display: block; }
html[data-theme="dark"] .icon-moon { display: none; }

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-sub);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s ease;
}
.tab:hover { background: var(--bg-hover); color: var(--text); }
.tab[aria-selected="true"] {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, .35);
}

/* ===== 内容区 ===== */
.content { flex: 1; padding: 20px 0; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.panel-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.head-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.live-clock {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 4px 12px;
  border-radius: 8px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 760px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ===== 输入控件 ===== */
.textarea, .input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Cascadia Code", monospace;
  font-size: 13.5px;
  line-height: 1.65;
  padding: 12px 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.textarea { min-height: 220px; resize: vertical; }
.textarea:focus, .input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}

.field-row { display: flex; gap: 8px; margin-bottom: 12px; }
.field-row .input { flex: 1; }

.select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-sub);
}
.select-wrap select {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.check-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-sub);
  cursor: pointer;
  user-select: none;
}
.check-wrap input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* ===== 按钮 ===== */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s ease;
}
.btn:hover { background: var(--bg-hover); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, .3);
}
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--bg-hover); }

/* ===== 状态栏 ===== */
.status-bar {
  margin-top: 12px;
  padding: 9px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--code-bg);
  border: 1px solid var(--border);
  color: var(--text-sub);
  word-break: break-all;
}
.status-bar.small { margin-top: 10px; }
.status-bar.ok { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.status-bar.err { background: var(--err-bg); border-color: var(--err); color: var(--err); }

/* ===== 统计 chips ===== */
.stats-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 3px 10px;
  border-radius: 999px;
}

/* ===== 结果列表 ===== */
.result-list { display: flex; flex-direction: column; gap: 6px; }
.result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 9px;
}
.result-item .k {
  flex: 0 0 128px;
  font-size: 12px;
  color: var(--text-sub);
}
.result-item .v {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
  font-style: normal;
}
.result-item .v.hash { font-size: 11.5px; }

.mini-copy {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--text-sub);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 6px;
  transition: all .12s ease;
}
.mini-copy:hover { background: var(--bg-hover); color: var(--accent-strong); }

.hint { font-size: 12px; color: var(--text-sub); margin: 10px 0 0; }
.hint-inline { font-size: 12px; color: var(--text-sub); }

/* ===== UUID ===== */
.uuid-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.uuid-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 14px;
  box-shadow: var(--shadow);
}
.uuid-item code {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
}
.uuid-item .uuid-v {
  font-size: 11px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 1px 8px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 20px);
  background: var(--text);
  color: var(--bg);
  padding: 9px 20px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all .25s ease;
  z-index: 99;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== Footer ===== */
.footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-sub);
  padding-top: 8px;
}

/* 编辑器轻微增强 */
.editor-wrap textarea { tab-size: 2; }

@media (max-width: 560px) {
  .brand-sub { display: none; }
  .result-item { flex-wrap: wrap; }
  .result-item .k { flex-basis: 100%; }
}
