:root {
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-code: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --code-font-size: 12px;
  --code-line-height: 1.12;
  --code-line-min-height: 14px;
  --code-line-number-width: 42px;
  --code-block-padding-x: 8px;
  --code-block-padding-y: 4px;
  color: #17202a;
  background: #f7f8fa;
  font-family: var(--font-ui);
}

body {
  margin: 0;
  font-family: var(--font-ui);
}

:where(button, input, select, textarea) {
  font: inherit;
}

:where(pre, code, kbd, samp) {
  font-family: var(--font-code);
}

:where(pre) {
  margin: 0;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 0 20px;
  border-bottom: 1px solid #d8dee6;
  background: #ffffff;
}

.brand {
  color: #17202a;
  font-family: var(--font-code);
  font-weight: 700;
  text-decoration: none;
}

.header-search {
  display: grid;
  flex: 1 1 0;
  grid-template-columns: 1fr auto;
  gap: 0;
  max-width: 760px;
  min-width: 0;
  width: auto;
}

.search-field {
  position: relative;
  min-width: 0;
}

.search-input,
.facet-search {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  height: 36px;
  padding: 0 10px;
  border: 1px solid #c7d0da;
  border-radius: 6px;
  background: #ffffff;
  color: #17202a;
  font: inherit;
}

.search-input {
  font-family: var(--font-code);
}

.search-submit,
.mode-toggle,
.sort-control,
.facet-option button,
.suggestion-row {
  appearance: none;
  -webkit-appearance: none;
  height: 36px;
  border: 1px solid #c7d0da;
  border-radius: 6px;
  background: #ffffff;
  color: #17202a;
  font: inherit;
}

.search-submit,
.mode-toggle,
.sort-control {
  padding: 0 12px;
  white-space: nowrap;
}

.search-input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.search-submit {
  display: grid;
  width: 40px;
  padding: 0;
  place-items: center;
  border-left: 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  color: #344256;
}

.mode-toggle {
  min-width: 78px;
  position: relative;
  padding-left: 26px;
  color: #536170;
}

.mode-toggle::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 12px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #98a2b3;
  transform: translateY(-50%);
}

.mode-toggle[aria-pressed="true"] {
  border-color: #2458d3;
  background: #edf3ff;
  color: #174ea6;
}

.mode-toggle[aria-pressed="true"]::before {
  background: #2458d3;
}

.sort-control {
  min-width: 94px;
  text-align: center;
  text-align-last: center;
}

.search-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 20px;
}

.facet-sidebar {
  display: grid;
  align-content: start;
  gap: 14px;
  font-size: 13px;
}

.facet-group {
  display: grid;
  gap: 8px;
}

.facet-heading {
  color: #536170;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.facet-values {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.facet-option button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  height: 32px;
  width: 100%;
  padding: 0 8px;
  text-align: left;
}

.facet-option.selected button {
  border-color: #2458d3;
  background: #edf3ff;
}

.facet-option.excluded button {
  color: #9a3412;
  background: #fff3ed;
}

.results-pane {
  position: relative;
  min-width: 0;
}

.results-toolbar {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 34px;
  color: #536170;
}

.query-chip {
  display: inline-flex;
  max-width: min(720px, 100%);
  overflow: hidden;
  padding: 2px 7px;
  border: 1px solid #d8dee6;
  border-radius: 999px;
  background: #ffffff;
  color: #344256;
  font-family: var(--font-code);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-error {
  border: 1px solid #f2b8b5;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff1f0;
  color: #b42318;
  font-size: 13px;
}

.loading-state,
.empty-state,
.fatal-state {
  border: 1px solid #d8dee6;
  border-radius: 8px;
  padding: 18px 20px;
  background: #ffffff;
  color: #536170;
  font-size: 14px;
}

.fatal-state {
  max-width: 720px;
  margin: 24px auto;
  color: #17202a;
}

.fatal-state strong {
  display: block;
  margin-bottom: 6px;
}

.fatal-state p {
  margin: 0 0 14px;
  color: #536170;
}

.fatal-state button {
  appearance: none;
  -webkit-appearance: none;
  height: 34px;
  padding: 0 12px;
  border: 1px solid #c7d0da;
  border-radius: 6px;
  background: #ffffff;
  color: #17202a;
  font: inherit;
}

.detail-error {
  margin-top: 4px;
  color: #b42318;
  font-size: 13px;
  font-weight: 400;
}

.suggestions-host {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
}

.header-search-error {
  position: absolute;
  z-index: 45;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  border: 1px solid #f2b8b5;
  border-radius: 6px;
  padding: 7px 9px;
  background: #fff1f0;
  color: #b42318;
  font-size: 12px;
  line-height: 1.3;
}

.suggestion-dropdown {
  width: 100%;
  overflow: hidden;
  border: 1px solid #c7d0da;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 12px 32px rgb(23 32 42 / 16%);
}

.suggestion-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  border-radius: 0;
  text-align: left;
}

.suggestion-row.active,
.suggestion-row:hover {
  background: #edf3ff;
}

.suggestion-value {
  min-width: 0;
  overflow: hidden;
  font-family: var(--font-code);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-detail {
  color: #536170;
  font-size: 12px;
  white-space: nowrap;
}

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

.result-item {
  position: relative;
  border: 1px solid #d8dee6;
  border-radius: 8px;
  background: #ffffff;
}

.result-main-link {
  position: absolute;
  z-index: 1;
  inset: 0;
  border-radius: inherit;
}

.result-main-link:focus-visible {
  outline: 2px solid #1a73e8;
  outline-offset: 2px;
}

.result-card-content {
  display: grid;
  gap: 8px;
  padding: 12px;
  color: inherit;
  text-decoration: none;
}

.result-meta,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.service-pill,
.tag,
.result-status {
  padding: 2px 7px;
  border-radius: 999px;
  background: #edf0f4;
  color: #536170;
  font-size: 12px;
}

.problem-id {
  color: inherit;
  font-size: 15px;
  font-weight: 700;
}

.submission-id,
.language,
.submitted-at {
  color: #536170;
  font-size: 13px;
}

.filter-link,
.external-submission-link {
  position: relative;
  z-index: 2;
  text-decoration: none;
}

.filter-link:hover {
  color: #2458d3;
  text-decoration: underline;
}

.external-submission-link:hover {
  color: #2458d3;
  text-decoration: underline;
}

.snippet-stack {
  display: grid;
  gap: 6px;
}

.snippet-state {
  border-radius: 6px;
  padding: 8px;
  background: #f1f4f8;
  color: #536170;
  font-family: var(--font-code);
  font-size: 12px;
  line-height: 1.2;
}

.snippet-error {
  color: #b42318;
}

.code-snippet {
  display: grid;
  gap: 0;
  overflow: hidden;
  margin: 0;
  padding: var(--code-block-padding-y) var(--code-block-padding-x);
  border-radius: 6px;
  background: #f1f4f8;
  font-family: var(--font-code);
  font-size: var(--code-font-size);
  line-height: var(--code-line-height);
}

mark {
  border-radius: 2px;
  padding: 0 1px;
  background: #fff08a;
  color: inherit;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  color: #536170;
  font-size: 13px;
}

.pagination-button {
  appearance: none;
  -webkit-appearance: none;
  height: 32px;
  padding: 0 10px;
  border: 1px solid #c7d0da;
  border-radius: 6px;
  background: #ffffff;
  color: #17202a;
  font: inherit;
}

.pagination-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.pagination-status {
  min-width: 92px;
  text-align: center;
}

.snippet-line {
  display: grid;
  grid-template-columns: var(--code-line-number-width) minmax(0, 1fr);
  min-height: var(--code-line-min-height);
  min-width: 0;
  line-height: var(--code-line-height);
}

.snippet-number {
  padding-right: 12px;
  color: #98a2b3;
  text-align: right;
  user-select: none;
}

.snippet-code {
  min-width: 0;
  overflow: hidden;
  border-left: 1px solid #d8dee6;
  padding-left: 12px;
  color: #243044;
  text-overflow: ellipsis;
  white-space: pre;
}

.detail-layout {
  display: grid;
  box-sizing: border-box;
  grid-template-columns: 280px minmax(0, 1fr);
  grid-template-areas:
    "title title"
    "inspector code";
  gap: 16px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 20px;
}

.detail-titlebar {
  grid-area: title;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  min-width: 0;
  min-height: 42px;
}

.back-link {
  color: #2458d3;
  font-size: 14px;
  text-decoration: none;
}

.submission-title,
.hit-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.submission-title {
  min-width: 0;
  flex-wrap: wrap;
}

.submission-title strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.copy-code,
.hit-buttons button {
  appearance: none;
  -webkit-appearance: none;
  height: 30px;
  padding: 0 10px;
  border: 1px solid #c7d0da;
  border-radius: 6px;
  background: #ffffff;
  color: #17202a;
  font: inherit;
  white-space: nowrap;
}

.detail-inspector {
  grid-area: inspector;
  display: grid;
  position: sticky;
  top: 16px;
  align-content: start;
  gap: 18px;
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.metadata-panel h2,
.hit-navigation h2 {
  margin: 0 0 8px;
  color: #536170;
  font-size: 12px;
  text-transform: uppercase;
}

.metadata-panel {
  font-size: 13px;
  line-height: 1.35;
}

.metadata-panel dl {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
}

.metadata-panel dt {
  color: #536170;
}

.metadata-panel dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.code-pane {
  grid-area: code;
  display: grid;
  position: relative;
  min-width: 0;
  max-width: 100%;
}

.code-pane .copy-code {
  grid-area: 1 / 1;
  justify-self: end;
  align-self: start;
  position: relative;
  z-index: 3;
  top: var(--code-block-padding-y);
  right: var(--code-block-padding-x);
  height: var(--code-line-min-height);
  padding: 0 5px;
  border-color: #d8dee6;
  border-radius: 5px;
  background: rgb(255 255 255 / 92%);
  color: #536170;
  font-size: 10px;
  line-height: 1;
}

.copy-code.is-copied {
  border-color: #0f766e;
  background: #ecfdf5;
  color: #0f766e;
}

.copy-code.is-failed {
  border-color: #b42318;
  background: #fff1f0;
  color: #b42318;
}

.code-viewer {
  grid-area: 1 / 1;
  min-width: 0;
  max-width: 100%;
  overflow: auto;
  margin: 0;
  padding: var(--code-block-padding-y) var(--code-block-padding-x);
  border: 0;
  border-radius: 6px;
  background: #f1f4f8;
  font-family: var(--font-code);
  font-size: var(--code-font-size);
  line-height: var(--code-line-height);
}

.code-line {
  display: grid;
  grid-template-columns: var(--code-line-number-width) max-content;
  min-height: var(--code-line-min-height);
  min-width: calc(100% + (var(--code-block-padding-x) * 2));
  margin-left: calc(-1 * var(--code-block-padding-x));
  padding-left: var(--code-block-padding-x);
  width: max-content;
}

.code-line.hit-line {
  background: #fff8d6;
}

.line-number {
  padding-right: 12px;
  color: #98a2b3;
  text-align: right;
  user-select: none;
}

.code-line code {
  font-family: inherit;
  min-width: 0;
  padding-right: 64px;
  padding-left: 12px;
  border-left: 1px solid #d8dee6;
  color: #243044;
  white-space: pre;
}

.syntax-keyword {
  color: #7c3aed;
  font-weight: 700;
}

.syntax-type {
  color: #0f766e;
}

.syntax-macro {
  color: #b45309;
}

.syntax-variable {
  color: #2563eb;
}

.syntax-string {
  color: #047857;
}

.syntax-number {
  color: #2563eb;
}

.syntax-comment {
  color: #7b8794;
  font-style: italic;
}

@media (max-width: 760px) {
  .app-header {
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
  }

  .brand {
    line-height: 36px;
  }

  .header-search {
    order: 2;
    flex-basis: 100%;
    max-width: none;
  }

  .mode-toggle,
  .sort-control {
    flex: 1 1 0;
    min-width: 0;
  }

  .search-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
  }

  .facet-sidebar {
    grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
    gap: 10px;
    font-size: 12px;
  }

  .facet-option button {
    height: 30px;
    padding: 0 7px;
  }

  .result-card-content {
    padding: 10px;
  }

  .result-meta,
  .tag-row {
    gap: 6px;
  }

  .detail-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "title"
      "inspector"
      "code";
    gap: 12px;
    padding: 14px 16px;
  }

  .detail-titlebar {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .detail-inspector {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .code-pane {
    width: 100%;
    overflow: hidden;
  }
}
