:root {
  color: #1d232a;
  background: #f4f5f6;
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-synthesis: none;
  --surface: #ffffff;
  --line: #d9dde2;
  --line-strong: #bcc3ca;
  --muted: #65707c;
  --accent: #a5272d;
  --accent-hover: #841e23;
  --success: #20734a;
  --warning: #8a5a00;
  --focus: #1769aa;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #f4f5f6;
}

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

button, a, input, select, textarea { outline-offset: 3px; }

:focus-visible { outline: 2px solid var(--focus); }

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  width: min(1180px, calc(100% - 32px));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  border-radius: 4px;
  color: #fff;
  background: var(--accent);
  font-family: "SimSun", serif;
  font-size: 23px;
  font-weight: 700;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; line-height: 1.4; }
.brand small { color: var(--muted); font-size: 11px; line-height: 1.3; }

.header-links {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 13px;
}

.header-links a { color: #34424f; text-decoration: none; }
.header-links a:hover { color: var(--accent); text-decoration: underline; }

.health-pill {
  min-width: 68px;
  min-height: 26px;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  background: #fafbfc;
  text-align: center;
  line-height: 16px;
}

.health-pill.online { color: var(--success); border-color: #9bc9b2; background: #eef8f2; }
.health-pill.offline { color: var(--accent); border-color: #d7a4a7; background: #fff3f3; }

.workspace {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto;
  display: grid;
  grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.query-panel, .result-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.panel-heading {
  min-height: 76px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.section-label {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
}

h1, h2 { margin: 0; font-size: 19px; line-height: 1.3; }

form { padding: 20px; }

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  min-width: 0;
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field > span { color: #424d58; font-size: 12px; font-weight: 600; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: #17202a;
  background: #fff;
}

input, select { height: 40px; padding: 0 10px; }
textarea { min-height: 86px; padding: 10px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #98a1aa; }
input:hover, select:hover, textarea:hover { border-color: #8f9aa5; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); }

.api-key-field { margin-top: 2px; }

.primary-button {
  width: 100%;
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

.primary-button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.primary-button:disabled { opacity: .6; cursor: wait; }

.text-button {
  min-height: 34px;
  padding: 5px 8px;
  border: 0;
  color: #394753;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
}

.text-button:hover:not(:disabled) { color: var(--accent); text-decoration: underline; }
.text-button:disabled { color: #a4abb2; cursor: default; }

.result-panel { min-height: 610px; }
.result-heading { position: sticky; top: 0; z-index: 1; background: var(--surface); border-radius: 6px 6px 0 0; }

.result-state {
  min-height: 500px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  color: var(--muted);
}

.result-state p { margin: 0; font-size: 13px; }
.empty-mark { color: #c3c9cf; font-family: Georgia, serif; font-size: 52px; }

.result-content { padding: 20px; }

.status-line {
  margin: 0 0 18px;
  padding: 10px 12px;
  border-left: 3px solid var(--warning);
  background: #fff8e8;
  color: #65430a;
  font-size: 13px;
}

.status-line.ok { border-color: var(--success); background: #eef8f2; color: #18583a; }

.result-section { margin-top: 22px; }
.result-section h3 { margin: 0 0 10px; font-size: 14px; }
.result-section ul { margin: 0; padding-left: 20px; color: #3d4853; font-size: 13px; line-height: 1.7; }

.case-table-wrap { overflow-x: auto; border: 1px solid var(--line); }
.case-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.case-table th, .case-table td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.case-table th { background: #f7f8f9; color: #46515c; white-space: nowrap; }
.case-table tr:last-child td { border-bottom: 0; }
.case-table a { color: #165f97; }

.provider-hit-list { display: grid; gap: 10px; }

.provider-hit {
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: #fbfbfa;
}

.provider-hit h4 { margin: 0 0 6px; font-size: 13px; }
.provider-hit p { margin: 6px 0; color: #3d4853; font-size: 12px; line-height: 1.65; }
.provider-hit .provider-hit-meta { color: var(--muted); font-family: Consolas, monospace; }
.provider-hit a { color: #165f97; font-size: 12px; }

.json-block {
  max-height: 260px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  background: #171b20;
  color: #d9e0e6;
  font: 12px/1.55 Consolas, "Courier New", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.app-footer {
  width: min(1180px, calc(100% - 32px));
  min-height: 64px;
  margin: 0 auto;
  padding: 18px 0 28px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 880px) {
  .workspace { grid-template-columns: 1fr; }
  .result-panel { min-height: 480px; }
  .result-state { min-height: 370px; }
  .result-heading { position: static; }
}

@media (max-width: 620px) {
  .header-inner { min-height: 64px; }
  .brand small, .header-links a { display: none; }
  .header-links { gap: 8px; }
  .workspace { width: min(100% - 20px, 1180px); margin-top: 14px; gap: 14px; }
  .field-grid { grid-template-columns: 1fr; gap: 0; }
  .panel-heading { padding: 16px; }
  form, .result-content { padding: 16px; }
  .app-footer { width: calc(100% - 20px); display: grid; }
}
