:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #5f6b7a;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --border: #e3e8ee;
  --danger: #b42318;
  --shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.site-header nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

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

#tool-switcher {
  max-width: 190px;
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

h1 { margin: 0 0 8px; font-size: 28px; }

.lead { margin-top: 0; color: var(--muted); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.card h2 { margin: 0; font-size: 18px; }

.card p { margin: 0; color: var(--muted); font-size: 14px; }

.card .tag { margin-top: auto; color: var(--accent); font-size: 13px; font-weight: 600; }

.panel {
  margin-top: 24px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }

label { font-size: 14px; font-weight: 600; }

input, select, button { font: inherit; }

input[type="number"],
input[type="text"],
select {
  width: 100%;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

input[type="color"] {
  width: 100%;
  height: 42px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.row { display: flex; gap: 12px; flex-wrap: wrap; }

.row > .field { flex: 1 1 160px; }

button.primary {
  padding: 12px 20px;
  color: #fff;
  font-weight: 600;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

button.primary:hover { background: var(--accent-strong); }

button.primary:disabled { opacity: 0.6; cursor: progress; }

.hint { margin: 12px 0 0; color: var(--muted); font-size: 13px; }

.status { min-height: 1.5em; margin: 16px 0 0; font-size: 14px; white-space: pre-wrap; }

.status.error { color: var(--danger); }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.metric {
  padding: 16px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.metric span { display: block; color: var(--muted); font-size: 13px; }

.metric strong { font-size: 26px; font-variant-numeric: tabular-nums; }

.metric small { color: var(--muted); font-size: 13px; margin-left: 4px; }

.preview { margin-top: 20px; }

.preview img {
  display: block;
  max-width: 100%;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.download-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--accent);
  font-weight: 600;
}

.section-title {
  margin: 36px 0 12px;
  font-size: 18px;
}

details.panel > summary {
  cursor: pointer;
}

details.panel > summary h2 {
  display: inline;
  margin: 0;
  font-size: 18px;
}

details.panel[open] > summary {
  margin-bottom: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 20px;
  align-items: start;
  margin-top: 24px;
}

.workspace-main {
  min-width: 0;
}

.workspace-main > .panel:first-child {
  margin-top: 0;
}

.workspace-side {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 104px);
  overflow: auto;
}

.workspace-side .panel {
  margin-top: 0;
  padding: 18px;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .workspace-side {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .workspace-side.reference {
    order: -1;
  }
}

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

textarea {
  width: 100%;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
}

textarea.output {
  background: #f9fafb;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.actions select,
.actions input {
  width: auto;
}

.actions label {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  font-weight: 400;
}

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

.chip {
  padding: 6px 10px;
  font-size: 13px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}

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

mark {
  padding: 0 1px;
  background: #fef08a;
  border-radius: 3px;
}

.highlight {
  min-height: 60px;
  padding: 12px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.kv {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 6px 12px;
  font-size: 14px;
}

.kv dt { color: var(--muted); }

.kv dd {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

.copy-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.diff {
  max-height: 520px;
  padding: 8px 0;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.diff div { padding: 0 10px; }

.diff .add { background: #e6ffec; }

.diff .del { background: #ffebe9; }

.diff .hunk {
  color: #57606a;
  background: #eef1f4;
}

.diff .meta {
  font-weight: 600;
  color: #57606a;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.swatch {
  padding: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}

.swatch-color {
  height: 64px;
  margin-bottom: 8px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.swatch code {
  display: block;
  font-size: 13px;
}

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

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table.plain {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.plain th,
table.plain td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.plain th {
  color: var(--muted);
  font-weight: 600;
  background: #f9fafb;
}

table.plain tr:last-child td { border-bottom: none; }

table.plain tr.ok { background: #f0fdf4; }

.requests { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

.request {
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.request summary {
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.request pre {
  max-height: 260px;
  padding: 10px;
  overflow: auto;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.bin-url {
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
  background: #f9fafb;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

footer {
  padding: 24px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

@media (max-width: 560px) {
  .site-header { align-items: flex-start; flex-direction: column; }
  .site-header nav a { margin: 0; }
  main { padding: 24px 16px 48px; }
}
