:root {
  --bg: #f5f7fa;
  --bg-elev: #ffffff;
  --bg-soft: #eef1f5;
  --border: #d0d7e0;
  --border-soft: #e3e8ef;
  --text: #1f2933;
  --text-secondary: #57606a;
  --text-faint: #8b949e;
  --accent: #0b7fc4;
  --accent-soft: rgba(11, 127, 196, 0.12);
  --ok: #1a7f37;
  --warn: #9a6700;
  --danger: #cf222e;
  --dup-bg: rgba(207, 34, 46, 0.12);
  --hit-bg: rgba(26, 127, 55, 0.11);
  --code-bg: #fbfcfe;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --radius: 12px;
  --ed-pad-x: 12px;
  --ed-pad-y: 8px;
  --ed-lh: 22px;
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    radial-gradient(1000px 500px at 15% -10%, rgba(11, 127, 196, 0.07), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(26, 127, 55, 0.04), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 54px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  position: relative;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
  color: var(--text);
  text-decoration: none;
}

.brand:hover {
  color: var(--accent);
}

.brand-icon {
  font-size: 19px;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 3px;
}

.page-nav {
  display: flex;
  gap: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 3px;
}

.page-nav a,
.page-nav .current {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
}

.page-nav .current {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.page-nav a:hover {
  color: var(--text);
  background: rgba(15, 30, 45, 0.05);
}

.tab {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.sites {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
}

.sites a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  border: 1px solid var(--border-soft);
  padding: 4px 9px;
  border-radius: 8px;
}

.sites a:hover {
  color: var(--text);
  border-color: var(--border);
}

.container {
  height: calc(100% - 54px);
  overflow-y: auto;
  padding: 20px 22px 36px;
}

/* ---------- 汇总页 ---------- */
.summary-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100% - 54px);
  padding-bottom: 74px;
}

.summary-hero {
  text-align: center;
  margin-bottom: 30px;
}

.summary-hero h1 {
  margin: 0 0 8px;
  font-size: 34px;
  background: linear-gradient(90deg, #0b7fc4, #1a7f37);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.summary-hero p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 15px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 520px));
  gap: 16px;
  justify-content: center;
  width: 100%;
  max-width: 1080px;
}

.tool-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}

.tool-card:hover {
  border-color: var(--accent);
  background: var(--bg-soft);
  transform: translateY(-2px);
}

.tool-card-icon {
  flex: 0 0 54px;
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 25px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
}

.tool-card-body {
  flex: 1;
  min-width: 0;
}

.tool-card-body h2 {
  margin: 0 0 6px;
  font-size: 19px;
}

.tool-card-body p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.55;
}

.tool-card-arrow {
  font-size: 20px;
  color: var(--text-faint);
  transition: transform 0.15s, color 0.15s;
}

.tool-card:hover .tool-card-arrow {
  color: var(--accent);
  transform: translateX(4px);
}

.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  color: var(--text-faint);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid var(--border-soft);
  z-index: 10;
}

.site-footer a {
  color: var(--text-secondary);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
}

.panel {
  display: none;
  max-width: 1500px;
  margin: 0 auto;
}

.panel.active {
  display: block;
}

.panel-head h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.panel-head .desc {
  margin: 0 0 16px;
  color: var(--text-secondary);
  max-width: 900px;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
}

.toolbar-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.mode-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mode-label {
  color: var(--text-secondary);
}

.seg {
  display: flex;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 7px;
  padding: 6px 14px;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.btn {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 9px;
  padding: 7px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--accent);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.btn.primary:disabled,
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

.btn.small {
  padding: 4px 9px;
  font-size: 12px;
  border-radius: 7px;
}

.text-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.editor-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.editor-card.output-card {
  grid-column: 1 / -1;
}

.ed-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  min-height: 28px;
}

.ed-name {
  font-weight: 650;
}

.ed-hint {
  color: var(--text-faint);
  font-size: 12px;
  flex: 1;
  min-width: 80px;
}

.readonly-tag {
  font-style: normal;
  font-size: 11px;
  color: var(--warn);
  border: 1px solid rgba(154, 103, 0, 0.35);
  border-radius: 6px;
  padding: 0 5px;
  margin-left: 5px;
  vertical-align: 1px;
}

.editor {
  flex: 1;
  min-height: 220px;
  height: clamp(220px, 44vh, 500px);
}

.editor.output {
  min-height: 220px;
  height: clamp(180px, 32vh, 330px);
}

.json-output-card .editor-card-body {
  flex: 1;
  min-height: 0;
}

.btn-group {
  display: flex;
  gap: 4px;
}

.btn-group .btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- 代码编辑器 ---------- */
.code-editor {
  height: 100%;
  min-height: 180px;
  display: flex;
  cursor: text;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--code-bg);
}

.ce-gutter {
  flex: 0 0 46px;
  width: 46px;
  background: #f2f4f7;
  border-right: 1px solid var(--border-soft);
  overflow: hidden;
  user-select: none;
  cursor: text;
}

.ce-gutter-inner {
  position: relative;
  will-change: transform;
}

.ce-line-no {
  height: var(--ed-lh);
  line-height: var(--ed-lh);
  color: #8b949e;
  text-align: right;
  padding-right: 9px;
  font-family: var(--mono);
  font-size: 11.5px;
  white-space: nowrap;
}

.ce-scroll {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: auto;
  cursor: text;
  scrollbar-color: #c8d1da transparent;
  scrollbar-width: thin;
}

.ce-marks {
  position: absolute;
  top: var(--ed-pad-y);
  left: var(--ed-pad-x);
  z-index: 0;
  pointer-events: none;
}

.ce-mark {
  position: absolute;
  left: 0;
  width: 100%;
  height: var(--ed-lh);
}

.ce-mark.dup {
  background: var(--dup-bg);
}

.ce-mark.hit {
  background: var(--hit-bg);
}

.ce-input {
  display: block;
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: var(--ed-pad-y) var(--ed-pad-x);
  border: 0;
  outline: none;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: var(--text);
  caret-color: var(--accent);
  font-family: var(--mono);
  font-size: 13px;
  line-height: var(--ed-lh);
  white-space: pre;
  tab-size: 4;
}

.ce-input.soft {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ce-input:read-only {
  cursor: default;
}

::selection {
  background: rgba(11, 127, 196, 0.22);
}

/* ---------- JSON 输出 ---------- */
.json-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.json-output-card {
  min-height: 0;
}

.json-output {
  flex: 1;
  min-height: 320px;
  height: calc(100vh - 230px);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--code-bg);
  overflow: auto;
  position: relative;
  padding: 0;
}

.json-empty {
  color: var(--text-faint);
  padding: 28px 20px;
  text-align: center;
}

.json-error {
  margin: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(207, 34, 46, 0.35);
  background: rgba(207, 34, 46, 0.06);
  color: #a40e26;
  border-radius: 9px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 12.5px;
}

.json-rows {
  font-family: var(--mono);
  font-size: 13px;
  line-height: var(--ed-lh);
  min-width: 100%;
}

.jrow {
  display: flex;
  min-height: var(--ed-lh);
  width: max-content;
  min-width: 100%;
}

.jrow:hover {
  background: rgba(15, 30, 45, 0.03);
}

.jrow-hidden {
  display: none;
}

.jln {
  flex: 0 0 46px;
  width: 46px;
  color: #8b949e;
  text-align: right;
  padding: 0 9px 0 0;
  user-select: none;
  border-right: 1px solid var(--border-soft);
  margin-right: 10px;
  background: #f2f4f7;
  position: sticky;
  left: 0;
  z-index: 1;
}

.jcontent {
  padding-right: 18px;
  white-space: pre;
}

.j-toggle {
  border: 0;
  background: transparent;
  cursor: pointer;
  width: 18px;
  padding: 0 3px 0 0;
  color: var(--text-faint);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s;
  vertical-align: 1px;
}

.j-toggle.collapsed {
  transform: rotate(-90deg);
}

.j-toggle-placeholder {
  display: inline-block;
  width: 18px;
}

.tk-key {
  color: #0550ae;
}

.tk-str {
  color: #0a6e2d;
}

.tk-num {
  color: #9a6700;
}

.tk-bool {
  color: #8250df;
}

.tk-null {
  color: #cf222e;
}

.tk-punc {
  color: #59636e;
}

.tk-dots {
  color: #bf8700;
  font-style: italic;
}

.tok-collapsed {
  color: var(--text-faint);
}

.compact-row {
  padding: 6px 0;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 20;
}

.toast.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #c8d1da;
  border-radius: 6px;
  border: 2px solid var(--code-bg);
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- 响应式 ---------- */
@media (max-width: 980px) {
  .text-grid,
  .json-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .editor-card.output-card {
    grid-column: auto;
  }

  .topbar {
    gap: 10px;
    padding: 0 12px;
    overflow-x: auto;
  }

  .sites {
    display: none;
  }

  .json-output {
    height: 60vh;
  }
}

@media (max-width: 620px) {
  .container {
    padding: 14px 10px 28px;
  }

  .toolbar-actions {
    margin-left: 0;
    width: 100%;
  }

  .editor {
    min-height: 190px;
  }

  .mode-group {
    flex-wrap: wrap;
  }
}
