:root {
  --ink: #202124;
  --muted: #5f6368;
  --line: #d7dde5;
  --soft: #f7f9fc;
  --accent: #1557b0;
}

body {
  line-height: 1.4;
  --panel-border-color: var(--line);
  --panel-radius: 10px;
  --panel-padding: 12px;
  --panel-bg: var(--soft);
  --panel-margin: 12px 0;
  --summary-min: 170px;
  --summary-gap: 6px;
  --summary-margin: 12px 0;
  --stat-border-color: var(--line);
  --stat-radius: 8px;
  --stat-padding: 12px;
  --stat-bg: #fff;
  --stat-font-size: 12px;
  --stat-strong-size: 17px;
  --filters-min: 190px;
  --filters-gap: 6px;
  --filters-margin: 10px 0;
  --filter-label-color: var(--subtle-mute);
  --filter-label-size: 12px;
  --filter-label-margin-bottom: 4px;
  --filter-label-margin-left: 1rem;
  --actions-gap: 6px;
  --actions-margin-top: 10px;
  --action-border-color: var(--line);
  --action-radius: 7px;
  --action-padding: 6px 9px;
  --action-bg: #fff;
  --action-color: inherit;
  --action-font-weight: 400;
  --action-hover-bg: #eef2f7;
}

.note {
  max-width: 900px;
}

input[type="search"],
select {
  width: 100%;
  padding: 4px 10px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-height: var(--tap-target, 44px);
}

input[type="search"] {
  margin: 0;
}

.search-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
  margin: 6px 0 10px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.search-row input[type="search"] {
  width: 100%;
}

.search-row #searchButton {
  min-width: 112px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.search-row #searchButton:hover {
  background: #0f4691;
}

p#status {
  padding-top: 0.75rem;
}

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(32, 33, 36, 0.16);
  display: none;
}

.suggestions.open {
  display: block;
}

.suggestion-item {
  display: block;
  font-size: 80%;
  opacity: 80%;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
  padding: 7px 9px;
  cursor: pointer;
  min-height: 40px;
}

.suggestion-item:last-child {
  border-bottom: 0;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: #eef2f7;
  opacity: 100%;
}

.suggestion-term {
  display: block;
  font-weight: 700;
  line-height: 1.25;
}

.suggestion-meta {
  display: block;
  color: var(--subtle-mute);
  font-size: 12px;
  margin-top: 2px;
}

.options,
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 6px 0;
}

.filter-toggle {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}

.options label,
.presets label {
  display: inline-flex;
  gap: 0.45rem;
  align-items: flex-start;
}

.preset {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 4px 9px;
  cursor: pointer;
}

.preset:hover {
  background: #eef2f7;
}

.search-summary-card {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 0.5rem 0;
  font-size: 0.95rem;
  color: var(--subtle-mute);
}

.search-summary-card strong {
  color: var(--ink);
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 6px 7px;
  overflow-wrap: anywhere;
  border: none;
}

.answer-search-table th {
  background: var(--soft);
  text-align: left;
  vertical-align: middle;
}

.answer-search-table td {
  text-align: left;
  vertical-align: top;
}

td+td,
th+th {
  border-left-width: 0.2px;
  border-left-style: dashed;
  border-left-color: #ccc;
}

tr+tr td,
tr+tr th {
  border-top: 1px solid #ccc;

}

th[data-sort] {
  cursor: pointer;
  user-select: none;
}

th[data-sort]:hover,
th.sort-active {
  background: #eef2f7;
}

.sort-indicator {
  color: var(--subtle-mute);
  font-size: 11px;
  margin-left: 1px;
}

tr> :first-child {
  border-left: 0;
}

tr> :last-child {
  border-right: 0;
}

tbody tr.result-row {
  cursor: pointer;
}

tbody tr.result-row:hover {
  background: #f7f9fc;
}

tbody tr.result-row-selected-incorrect td {
  background: #fff4f1;
}

tbody tr.result-row-selected-incorrect:hover td {
  background: #ffe9e3;
}

.detail-row td {
  background: #fbfcfe;
  padding: 0;
  text-align: left;
}

.inline-detail {
  padding: 12px 14px 14px;
  border-top: 2px solid var(--accent);
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.inline-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.inline-detail-title {
  font-weight: 700;
  font-size: 15px;
  width: 30%;
  max-width: 100%;
}

.inline-detail-meta {
  color: var(--subtle-mute);
  font-size: 9px;
  text-align: left;
  line-height: 1.35;
  width: 70%;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: row;
  flex-wrap: nowrap;
}

.inline-detail-meta>div {
  text-align: left;
  width: stretch;
  display: contents;
}

.inline-detail .detail-section {
  margin: 8px 0;
}

.inline-detail .detail-section h3 {
  margin: 0 0 5px;
  font-size: 13px;
  color: var(--subtle-mute);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.inline-detail .detail-section p {
  margin: 0;
  text-align: left;
}

.inline-detail .detail-blocks {
  display: grid;
  gap: 8px;
}

.inline-detail .detail-table-scroll {
  overflow-x: auto;
}

.inline-detail .detail-table {
  min-width: 420px;
  width: auto;
  table-layout: auto;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.inline-detail .detail-table th,
.inline-detail .detail-table td {
  padding: 7px 9px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.inline-detail .detail-choice-table td:first-child,
.inline-detail .detail-choice-table th:first-child {
  white-space: nowrap;
  min-width: 96px;
}

.inline-detail .detail-table th {
  background: var(--soft);
  font-weight: 700;
}

.inline-detail .choice-list {
  display: grid;
  gap: 5px;
  margin-top: 5px;
}

.inline-detail .choice-item {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 8px;
  background: #fff;
  text-align: left;
}

.inline-detail .choice-item.correct {
  border-color: #8fbd99;
  background: #edf7ef;
  font-weight: 600;
}

.inline-detail .choice-badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-left: 8px;
  vertical-align: middle;
}

.inline-detail .choice-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 700;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--subtle-mute);
}

.inline-detail .choice-badge-correct {
  border-color: #8fbd99;
  background: #edf7ef;
  color: #146c43;
}

.inline-detail .choice-badge-selected {
  border-color: #bfd6f2;
  background: #e8f2fb;
  color: #1557b0;
}

.inline-detail .choice-meta {
  color: var(--subtle-mute);
  font-size: 11px;
  margin-top: 3px;
  font-weight: 400;
}

.label-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff7e6;
  color: #7a4b00;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.label-badge-selected-incorrect {
  background: #fde8e7;
  color: #8a1c1c;
  border-color: #f4c7c3;
}

.yes {
  font-weight: 700;
}

@media (max-width: 900px) {
  body {
    --panel-padding: 11px;
    --summary-min: 145px;
    --filters-min: 160px;
  }

  table {
    min-width: 780px;
    table-layout: auto;
  }

  table th:nth-child(3),
  table td:nth-child(3),
  table th:nth-child(8),
  table td:nth-child(8),
  table th:nth-child(10),
  table td:nth-child(10),
  table th:nth-child(11),
  table td:nth-child(11) {
    display: none;
  }

  .inline-detail {
    padding: 11px;
  }

  .inline-detail-header {
    flex-direction: column;
    gap: 8px;
  }

  .inline-detail-title,
  .inline-detail-meta {
    width: 100%;
  }

  .inline-detail-meta {
    text-align: left;
    flex-wrap: wrap;
    gap: 2px 6px;
  }

  .inline-detail-meta>div {
    display: block;
  }
}

@media (max-width: 560px) {
  body {
    --panel-padding: 12px;
    --filters-min: 100%;
  }

  .search-row {
    flex-direction: column;
  }

  .search-row #searchButton {
    width: 100%;
  }

  .options,
  .filters,
  .actions {
    gap: 6px;
  }

  .actions .action {
    width: 100%;
  }

  table {
    min-width: 540px;
  }

  table th:nth-child(2),
  table td:nth-child(2),
  table th:nth-child(9),
  table td:nth-child(9) {
    display: none;
  }

  .label-badge {
    margin-left: 4px;
    margin-top: 4px;
    white-space: normal;
  }
}
