:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --line: #d8e0ec;
  --text: #1d2939;
  --muted: #667085;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success-bg: #ecfdf3;
  --success-line: #abefc6;
  --success-text: #067647;
  --warn-bg: #fffaeb;
  --warn-line: #fedf89;
  --warn-text: #b54708;
  --shadow: 0 12px 30px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
}

.wrap {
  width: min(980px, calc(100% - 32px));
  margin: 32px auto;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.hero { margin-bottom: 18px; }
.hero h1 {
  margin: 0 0 8px;
  font-size: 32px;
  line-height: 1.15;
}

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

.form { margin-top: 18px; }
.label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.row {
  display: flex;
  gap: 12px;
}

.input {
  flex: 1 1 auto;
  min-width: 0;
  height: 50px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 16px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

.btn {
  flex: 0 0 auto;
  height: 50px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, transform .05s ease;
}

.btn:hover { background: var(--primary-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .65; cursor: default; }

.hint { margin: 10px 0 0; font-size: 14px; }
.result.is-hidden { display: none; }

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.success {
  background: var(--success-bg);
  border: 1px solid var(--success-line);
  color: var(--success-text);
}

.badge.warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  color: var(--warn-text);
}

.message {
  margin: 0 0 18px;
  color: var(--muted);
}

.winner {
  padding: 18px;
  border: 1px solid var(--success-line);
  background: var(--success-bg);
  border-radius: 14px;
}

.winner .category {
  font-size: 28px;
  font-weight: 800;
  margin: 0 0 6px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.list {
  display: grid;
  gap: 12px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

.item-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 10px;
}

.item-title {
  margin: 0;
  font-size: 20px;
}

.score {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e9eef6;
  overflow: hidden;
  margin-bottom: 10px;
}

.bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #60a5fa 0%, #2563eb 100%);
  border-radius: 999px;
}

.reasons {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.reasons li { margin: 4px 0; }

.pages {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.pages h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.pages ul {
  margin: 0;
  padding-left: 18px;
}

.pages li {
  margin: 8px 0;
  word-break: break-word;
}

.error-box {
  border: 1px solid #fecdca;
  background: #fef3f2;
  color: #b42318;
  border-radius: 14px;
  padding: 16px;
}

.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #c7d7fe;
  border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 720px) {
  .wrap {
    width: min(100% - 20px, 980px);
    margin: 18px auto;
  }

  .card { padding: 18px; }
  .hero h1 { font-size: 26px; }

  .row,
  .result-head,
  .item-top {
    flex-direction: column;
    align-items: stretch;
  }

  .btn,
  .input {
    width: 100%;
  }
}
