:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --line: #d7dde2;
  --text: #172026;
  --muted: #66737f;
  --primary: #146c75;
  --primary-hover: #0e5860;
  --accent: #8a5a12;
  --danger: #a83232;
  --shadow: 0 8px 24px rgba(20, 35, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: #a8b4bd;
}

button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

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

button.danger {
  color: var(--danger);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  min-height: 240px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 600;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

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

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px 24px 32px;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  border-bottom-color: var(--accent);
  color: var(--text);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.querybar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 92px auto;
  gap: 10px;
  margin-bottom: 16px;
}

.split,
.toolGrid,
.tokenGrid,
.statusGrid {
  display: grid;
  gap: 16px;
}

.split {
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.1fr);
}

.toolGrid,
.tokenGrid,
.statusGrid {
  grid-template-columns: minmax(320px, 420px) minmax(420px, 1fr);
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 16px;
}

.panelTitle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.resultList,
.tokenList,
.sourceList {
  display: grid;
  gap: 10px;
}

.result,
.token,
.source {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.resultHeader,
.tokenHeader,
.sourceHeader {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.resultTitle,
.tokenName,
.sourceName {
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #edf3f4;
  color: var(--primary-hover);
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
}

.snippet {
  margin: 8px 0 0;
  color: #3f4b55;
}

.documentPreview,
.jsonOutput {
  min-height: 420px;
  max-height: 68vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 12px;
}

.tokenGrid form,
.toolGrid form {
  display: grid;
  gap: 12px;
  align-content: start;
}

.tokenMeta {
  display: grid;
  gap: 3px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  border: 1px solid #26323a;
  border-radius: 8px;
  background: #26323a;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .shell {
    padding: 16px;
  }

  .querybar,
  .split,
  .toolGrid,
  .tokenGrid,
  .statusGrid {
    grid-template-columns: 1fr;
  }

  .tabs {
    overflow-x: auto;
  }
}
