:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --ink: #17212f;
  --muted: #637083;
  --line: #dce3ec;
  --accent: #16736a;
  --accent-2: #b63d55;
  --accent-3: #3169b8;
  --warn: #9c6b12;
  --shadow: 0 10px 28px rgba(23, 33, 47, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: max-content minmax(220px, 680px) max-content max-content;
  gap: 18px;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 190px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 16px;
}

.brand div span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.search {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px;
  align-items: center;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.language-switch {
  display: grid;
  grid-template-columns: max-content max-content;
  gap: 8px;
  align-items: center;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
}

.language-switch span {
  font-size: 13px;
  font-weight: 700;
}

.language-switch select {
  width: auto;
  min-width: 122px;
  height: 30px;
  border: 0;
  background: transparent;
  color: var(--ink);
  outline: 0;
}

.ghost-btn,
.action-btn,
.category {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.ghost-btn {
  padding: 0 14px;
}

.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

.sidebar {
  position: sticky;
  top: 88px;
  align-self: start;
  display: grid;
  gap: 8px;
}

.category {
  padding: 10px 12px;
  text-align: left;
}

.category.active {
  border-color: rgba(22, 115, 106, 0.35);
  background: #e4f4f1;
  color: #0d5c55;
  font-weight: 700;
}

.workspace {
  min-width: 0;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
}

.section-head p {
  max-width: 760px;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.6;
}

.stats {
  min-width: 88px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.stats span,
.stats small {
  display: block;
}

.stats span {
  font-size: 26px;
  font-weight: 800;
}

.stats small {
  color: var(--muted);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
}

.tool-card {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tool-title {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.tool-title h2 {
  font-size: 18px;
}

.tool-title p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.tag {
  flex: 0 0 auto;
  height: 25px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.tool-body {
  display: grid;
  gap: 10px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

textarea,
input,
select,
.output {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--ink);
}

textarea {
  min-height: 160px;
  padding: 10px;
  resize: vertical;
  line-height: 1.45;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

input,
select {
  height: 38px;
  padding: 0 10px;
}

.output {
  min-height: 40px;
  padding: 10px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

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

.action-btn {
  padding: 0 12px;
}

.action-btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.action-btn.danger {
  border-color: rgba(182, 61, 85, 0.4);
  color: var(--accent-2);
}

.notice {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
}

.notice.ok {
  color: var(--accent);
}

.notice.bad {
  color: var(--accent-2);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.tree-view {
  max-height: 360px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.tree-view details {
  margin: 3px 0;
}

.tree-view summary {
  cursor: pointer;
  color: var(--accent-3);
  font-weight: 700;
}

.tree-children {
  margin-left: 16px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.tree-leaf {
  margin: 4px 0;
  cursor: copy;
  overflow-wrap: anywhere;
}

.markdown-preview {
  min-height: 160px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  line-height: 1.6;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
  margin: 0 0 10px;
  font-size: 20px;
}

.markdown-preview p,
.markdown-preview ul {
  margin: 0 0 12px;
}

.markdown-preview code {
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--surface-2);
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 88px;
  padding: 14px;
  border: 1px dashed var(--accent-3);
  border-radius: 8px;
  background: #f3f7fc;
  color: var(--muted);
  text-align: center;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: #e4f4f1;
  color: var(--accent);
}

.tool-canvas {
  width: 100%;
  max-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
}

.json-key {
  color: #3169b8;
  font-weight: 700;
}

.json-string {
  color: #16736a;
}

.json-number {
  color: #9c6b12;
}

.json-literal {
  color: #b63d55;
  font-weight: 700;
}

@media (max-width: 860px) {
  .topbar,
  .layout,
  .section-head,
  .two-col {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-head {
    display: grid;
    align-items: stretch;
  }

  .layout {
    padding: 16px;
  }

  .sidebar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tool-grid {
    grid-template-columns: 1fr;
  }
}
