*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, sans-serif;
  font-size: 0.95rem;
  background: #f4f6f9;
  color: #1a1a2e;
  padding: 2rem;
}

h1 {
  font-size: 1.4rem;
  margin-bottom: 1.5rem;
  color: #1a1a2e;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

thead {
  background: #1a1a2e;
  color: #fff;
}

thead th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}

thead th:not(:first-child) {
  text-align: center;
}

tbody tr {
  border-bottom: 1px solid #e8ecf0;
  transition: background 0.1s;
}

tbody tr:last-child {
  border-bottom: none;
}
tbody tr:hover {
  background: #f8fafc;
}

td {
  padding: 0.65rem 1rem;
  vertical-align: middle;
}

td:not(:first-child) {
  text-align: center;
  white-space: nowrap;
}

.tag {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.tag-K {
  background: #dbeafe;
  color: #1e40af;
}
.tag-S {
  background: #dcfce7;
  color: #166534;
}
.tag-B {
  background: #fef3c7;
  color: #92400e;
}

input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  cursor: pointer;
  accent-color: #1a1a2e;
}

/* row states */
tr.state-achieved {
  background: #f0fdf4;
}
tr.state-partial {
  background: #fffbeb;
}
tr.state-claimed {
  background: #eff6ff;
}
tr.state-prev-achieved {
  background: #faf5ff;
}

.ksb-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 1.5rem;
}

.ksb-summary {
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.ksb-summary h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.6rem;
}

.ksb-summary.prev-achieved {
  --badge: #6b21a8;
}
.ksb-summary.claimed {
  --badge: #1e40af;
}
.ksb-summary.achieved {
  --badge: #166534;
}
.ksb-summary.partial {
  --badge: #92400e;
}

.ksb-summary h2 {
  color: var(--badge);
}

.count {
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--badge);
  color: #fff;
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
}

.ksb-summary p {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #374151;
  min-height: 1.5em;
}

.ksb-summary p em {
  color: #9ca3af;
  font-style: normal;
}

#btn-clear,
#btn-home {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.3rem 0.9rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  color: #374151;
  text-decoration: none;
  display: inline-block;
}

#btn-clear:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}
#btn-home:hover {
  background: #f3f4f6;
}

#console-output {
  margin-top: 1.5rem;
  background: #1a1a2e;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

#console-output-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

#console-output h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
}

#btn-copy {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.25rem 0.8rem;
  border: 1px solid #374151;
  border-radius: 6px;
  background: #374151;
  cursor: pointer;
  color: #d1d5db;
}

#btn-copy:hover {
  background: #4b5563;
  border-color: #6b7280;
}
#btn-copy.copied {
  background: #166534;
  border-color: #166534;
  color: #fff;
}

:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}

#console-snippet {
  width: 100%;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  background: #0f0f1a;
  color: #a5f3fc;
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  resize: vertical;
  min-height: 10rem;
  white-space: pre;
  overflow-x: auto;
}

/* ── Bookmarklet output section ─────────────────────────────────────────── */

#bookmarklet-output {
  margin-top: 1.5rem;
  background: #1a1a2e;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

#bookmarklet-output-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

#bookmarklet-output h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
}

#btn-copy-bookmarklet {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.25rem 0.8rem;
  border: 1px solid #374151;
  border-radius: 6px;
  background: #374151;
  cursor: pointer;
  color: #d1d5db;
}

#btn-copy-bookmarklet:hover {
  background: #4b5563;
  border-color: #6b7280;
}

#btn-copy-bookmarklet.copied {
  background: #166534;
  border-color: #166534;
  color: #fff;
}

#bookmarklet-codes {
  width: 100%;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  background: #0f0f1a;
  color: #a5f3fc;
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  resize: none;
  white-space: pre;
  overflow-x: auto;
}

/* ── Distinction Criteria section ──────────────────────────────────────── */

.distinction-section {
  margin-top: 1.5rem;
}

.distinction-heading {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #92400e;
  background: #fef3c7;
  border-left: 4px solid #f59e0b;
  padding: 0.6rem 1rem;
  border-radius: 8px 8px 0 0;
}

.distinction-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.distinction-table thead {
  background: #78350f;
  color: #fff;
}

.distinction-table thead th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
}

.distinction-table thead th:last-child {
  text-align: center;
}

.distinction-table tbody tr {
  border-bottom: 1px solid #fef3c7;
  transition: background 0.1s;
}

.distinction-table tbody tr:last-child {
  border-bottom: none;
}

.distinction-table tbody tr:hover {
  background: #fffbeb;
}

.distinction-table td {
  padding: 0.65rem 1rem;
  vertical-align: middle;
}

.distinction-table td:last-child {
  text-align: center;
}

tr.state-distinction-attained {
  background: #fef9c3;
}
