:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f9fbfc;
  --text: #172033;
  --muted: #5f6b7a;
  --line: #dce2ea;
  --accent: #006ad4;
  --accent-dark: #004f9e;
  --danger: #b42318;
  --warning: #9a6700;
  --success: #067647;
  --shadow: 0 12px 36px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

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

.app-shell {
  width: min(90%, calc(100vw - 40px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  padding: 8px 0 22px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.2;
  font-weight: 700;
}

h2 {
  font-size: 17px;
  line-height: 1.3;
}

.hero p {
  margin-top: 8px;
  max-width: 760px;
  color: var(--muted);
  line-height: 1.7;
}

.hero-links {
  display: flex;
  gap: 16px;
  white-space: nowrap;
}

.hero-links a {
  color: var(--accent);
  font-size: 14px;
}

.workspace {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  gap: 18px;
}

.input-panel,
.result-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-panel {
  padding: 14px;
}

.result-panel {
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
}

.result-panel .panel-head {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.status {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #f7f9fb;
}

.filters input,
.filters select {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  font-size: 13px;
  color: var(--text);
  background: #fff;
}

.filters input {
  flex: 1 1 160px;
  min-width: 0;
}

.filters select {
  flex: 0 0 auto;
}

.filters input:focus,
.filters select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 106, 212, 0.14);
}

textarea {
  width: min(100%, 36ch);
  min-height: 180px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  color: var(--text);
  background: var(--panel-soft);
  font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  outline: none;
}

textarea:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 106, 212, 0.14);
}

.file-button,
button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.file-button input {
  display: none;
}

button:hover,
.file-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

#run-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

#run-button:hover {
  background: var(--accent-dark);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.controls label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.controls input {
  width: 72px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
}

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

.mode-group .mode-label {
  color: var(--muted);
  font-size: 13px;
}

.mode-group .radio {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  white-space: nowrap;
}

.mode-group input[type="radio"] {
  width: auto;
  height: auto;
  border: none;
  accent-color: var(--accent);
  margin: 0;
}

.invalid-list {
  min-height: 38px;
  margin: 10px 0 0;
  white-space: pre-wrap;
  color: var(--warning);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 182px);
}

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f9fb;
  color: var(--muted);
  font-weight: 600;
}

td {
  line-height: 1.55;
}

td:nth-child(1) {
  color: var(--muted);
  width: 48px;
}

/* 混合查询时按类别区分行背景：正式浅蓝、测试浅紫、混合浅橙 */
#results-body tr.row-formal td {
  background: #f2f8ff;
}

#results-body tr.row-test td {
  background: #f8f1ff;
}

#results-body tr.row-mixed td {
  background: #fff7e8;
}

/* 悬停产生选中效果（覆盖上面的类别底色） */
#results-body tr:hover td {
  background: #eef4ff;
  cursor: pointer;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-width: 58px;
  justify-content: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
}

.badge.found {
  color: var(--success);
  background: #e9f8f1;
}

.badge.not_found {
  color: var(--warning);
  background: #fff6df;
}

.badge.api_error,
.badge.network_error {
  color: var(--danger);
  background: #fff0ee;
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100% - 24px, 720px);
    padding-top: 18px;
  }

  .hero {
    display: block;
  }

  .hero-links {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-top: 14px;
  }

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

  textarea {
    min-height: 260px;
  }

  .table-wrap {
    max-height: none;
  }
}
