:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --text: #222222;
  --muted: #6b6b6b;
  --line: #deded8;
  --ok: #f1f8f0;
  --warn: #fef8ef;
  --error: #fff3f3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, #fbfbfa 0%, var(--bg) 70%);
  color: var(--text);
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
}

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.card {
  width: 100%;
  max-width: 760px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
}

h1 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 30px;
}

.subtitle {
  margin-top: 0;
  color: var(--muted);
}

.search-form {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

label {
  font-weight: 600;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 16px;
  font-family: inherit;
}

textarea {
  resize: vertical;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

textarea.is-flashing {
  border-color: #9bb7d8;
  box-shadow: 0 0 0 3px rgba(126, 158, 199, 0.2);
}

textarea.is-invalid {
  border-color: #d92d20;
  box-shadow: 0 0 0 3px rgba(217, 45, 32, 0.08);
}

.field-error {
  margin: 8px 0 0;
  font-size: 14px;
  color: #b42318;
}

button {
  width: fit-content;
  border: none;
  border-radius: 10px;
  background: #111111;
  color: #ffffff;
  padding: 10px 18px;
}

button[type="submit"] {
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

button[type="submit"]:hover {
  background-color: #1f1f1f;
}

button[type="submit"]:active {
  transform: translateY(1px);
}

button[type="submit"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.14);
}

button[type="submit"]:disabled {
  background-color: #bfc3c7;
  color: #f5f5f5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button[type="submit"]:disabled:hover,
button[type="submit"]:disabled:active {
  background-color: #bfc3c7;
  transform: none;
}

.examples {
  color: var(--muted);
  margin-top: 16px;
}

.examples span {
  color: var(--text);
}

.example-item {
  cursor: pointer;
  text-decoration: underline;
  transition: opacity 0.15s ease;
}

.example-item:hover {
  opacity: 0.7;
}

.result {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}

#result-block {
  scroll-margin-top: 24px;
}

.result.found {
  background: var(--ok);
}

.result.not_found {
  background: var(--warn);
}

.result.error {
  background: var(--error);
}

.result.phrase {
  background: #f8fbff;
}

.result.result-unified {
  background: #f8fbff;
  padding: 14px;
}

.result.result--found {
  background: #edf8ee;
  border-color: #cde6cf;
}

.result.result--review {
  background: #fff8eb;
  border-color: #ecd8ad;
}

.result.result--not-found {
  background: #fff0f0;
  border-color: #f0c7c7;
}

.result-title {
  margin: 0;
  font-size: 22px;
}

.result-main-text {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  word-break: break-word;
}

.result-title + .result-main-text {
  margin-top: 12px;
}

.result-chip {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 600;
  background-color: #e9ecef;
  color: #111111;
  border: 1px solid #d1d5db;
  margin-top: 12px;
  margin-bottom: 8px;
  transition: all 0.15s ease;
}

.result-chip:hover {
  transform: translateY(-1px);
}

.result--found .result-chip {
  background-color: #d7efe2;
  border-color: #9ecfb5;
  color: #0f5132;
}

.result-meta {
  margin: 8px 0 0;
  color: var(--muted);
}

.result h2 {
  margin-top: 0;
}

.result ul {
  margin: 0;
  padding-left: 20px;
}

.excerpt {
  color: var(--muted);
  margin-top: 4px;
}

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

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
  font-size: 14px;
}

.summary-top {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}

.summary-top.summary-low {
  background: #edf8ee;
  border-color: #cde6cf;
}

.summary-top.summary-review {
  background: #fff8eb;
  border-color: #ecd8ad;
}

.summary-top.summary-high {
  background: #fff0f0;
  border-color: #f0c7c7;
}

.summary-label {
  margin: 0 0 8px;
  font-size: 22px;
}

.summary-message {
  margin: 0;
}

.summary-insight {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.summary-note {
  margin-top: 8px;
  color: #7a5f22;
}

.copy-btn {
  margin-top: 10px;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
  font-size: 14px;
}

.groups {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.highlights {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.group {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #ffffff;
}

.group.compact {
  padding: 8px 10px;
}

.result-dictionaries {
  margin-top: 12px;
}

.single-result-item + .single-result-item {
  margin-top: 8px;
}

.highlight-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.group-title {
  margin: 0 0 8px;
  font-weight: 600;
}

.tag {
  display: inline-block;
  margin-right: 6px;
  margin-bottom: 6px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
}

.tag-found {
  background: #dff3db;
}

.tag-not-found {
  background: #fce9c8;
}

.tag-unsupported {
  background: #ececec;
}

.suggestion-inline {
  color: #7a5f22;
  font-size: 13px;
}

.suggestion {
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-weight: 700;
  color: #2158a8;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.suggestion:hover {
  color: #163b72;
}

.suggestion:focus-visible {
  outline: 2px solid #7aa2d8;
  outline-offset: 2px;
  border-radius: 3px;
}

.tokens-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.tokens-table th,
.tokens-table td {
  border-top: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
}

.status-found {
  background: #dff3db;
}

.status-not-found {
  background: #fce9c8;
}

.status-unsupported {
  background: #ececec;
  font-size: 12px;
}

.suggestion-hint {
  margin-top: 6px;
  color: #7a5f22;
  font-size: 12px;
  line-height: 1.35;
}

.details-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  padding: 8px 10px;
}

.details-block summary {
  cursor: pointer;
  font-weight: 600;
  user-select: none;
}

.details-block[open] {
  padding-bottom: 12px;
}

.details-block .summary-stats {
  margin-top: 10px;
}

.disclaimer {
  margin-top: 24px;
  font-size: 14px;
  color: var(--muted);
}

@media (max-width: 640px) {
  .card {
    padding: 18px;
  }

  h1 {
    font-size: 24px;
  }

  .tokens-table {
    font-size: 13px;
  }
}
