:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #667085;
  --border: #e3e6eb;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --ok: #1a7f4b;
  --err: #c0362c;
  --code-bg: #f0f2f5;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft JhengHei", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1b1f27;
    --text: #e6e8ec;
    --muted: #98a2b3;
    --border: #2c323d;
    --accent: #5b8cff;
    --code-bg: #232833;
    --ok: #4cc38a;
    --err: #ff7b72;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); white-space: nowrap; }
#search { flex: 1; max-width: 420px; }
.topbar nav a { color: var(--muted); white-space: nowrap; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }

/* 首頁 */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 4px 12px; border-radius: 999px; cursor: pointer; font-size: 14px;
}
.chip.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.card {
  display: block; padding: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card .icon { font-size: 26px; }
.card h3 { margin: 8px 0 4px; font-size: 16px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.badge {
  display: inline-block; margin-top: 10px; padding: 1px 8px; border-radius: 6px;
  font-size: 12px; background: var(--code-bg); color: var(--muted);
}
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* 工具頁 */
.tool-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.tool-head h1 { margin: 0; font-size: 22px; }
.tool-desc { color: var(--muted); margin: 0 0 20px; }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0; }
.stack > * + * { margin-top: 12px; }
label { font-size: 14px; color: var(--muted); }

input, textarea, select, button { font: inherit; color: inherit; }
input[type=text], input[type=search], input[type=password], input[type=url], input[type=number], textarea, select {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg);
}
textarea { min-height: 160px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; resize: vertical; }
button {
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }

pre.output {
  background: var(--code-bg); padding: 12px; border-radius: 8px; overflow: auto;
  max-height: 480px; font-size: 13px; white-space: pre-wrap; word-break: break-word; margin: 0;
}
.status { font-size: 14px; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }

table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th, table.data td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; }
table.data th { background: var(--code-bg); position: sticky; top: 0; }
.table-wrap { overflow: auto; max-height: 480px; }

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 24px; text-align: center; color: var(--muted); cursor: pointer;
}
.dropzone.over { border-color: var(--accent); color: var(--accent); }

@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
  #search { order: 3; max-width: none; flex-basis: 100%; }
  main { padding: 16px; }
}
