:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --text: #111111;
  --muted: #626260;
  --faint: #7b7b78;
  --border: #dedbd6;
  --accent: #ff5600;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 24px;
  background: color-mix(in srgb, var(--bg) 94%, white);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 18px;
  font-weight: 700;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

nav a,
button,
select {
  border: 1px solid var(--text);
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font: inherit;
}

nav a {
  padding: 8px 10px;
  font-size: 14px;
}

button {
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, color 140ms ease;
}

button:hover,
nav a:hover {
  transform: scale(1.04);
  background: var(--text);
  color: #ffffff;
}

main {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 40px 24px 64px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 40px;
  align-items: end;
  padding: 36px 0 32px;
}

.eyebrow,
.label {
  margin: 0 0 8px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 900px;
  margin-bottom: 0;
  font-size: clamp(42px, 7vw, 84px);
  font-weight: 500;
  letter-spacing: 0;
  line-height: 0.98;
}

h2 {
  margin-bottom: 4px;
  font-size: 28px;
  line-height: 1.05;
}

.summary {
  margin-bottom: 0;
  color: var(--muted);
}

.note {
  margin-bottom: 24px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.note p {
  max-width: 980px;
  margin-bottom: 0;
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 84px;
  display: grid;
  gap: 16px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

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

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  background: var(--bg);
}

.style-box {
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.style-box p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.content {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.badge-card,
.empty {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.badge-card {
  overflow: hidden;
}

.image-wrap {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  background: #f0eee9;
  border-bottom: 1px solid var(--border);
}

.image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.badge-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.badge-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.badge-label {
  margin-bottom: 4px;
  color: var(--faint);
  font-size: 12px;
}

.badge-top h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.05;
}

.index-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  min-width: 42px;
  min-height: 28px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.meta-grid div {
  min-width: 0;
}

.meta-grid dt {
  color: var(--faint);
  font-weight: 700;
  text-transform: uppercase;
}

.meta-grid dd {
  overflow: hidden;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-links,
.vote-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge-links a {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 12px;
}

.badge-links a:hover {
  border-color: var(--text);
  color: var(--text);
}

.case-panel {
  display: grid;
  gap: 10px;
}

.case-toggle {
  width: fit-content;
  min-height: 34px;
  padding: 0 10px;
  background: #ffffff;
  border-color: var(--border);
  color: var(--muted);
  font-size: 13px;
}

.case-details {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}

.case-detail-grid {
  display: grid;
  gap: 10px;
}

.detail-block {
  min-width: 0;
}

.detail-block + .detail-block {
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.detail-block h4 {
  margin: 0 0 8px;
  color: var(--faint);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.input-sections {
  display: grid;
  gap: 14px;
}

.input-sections section {
  display: grid;
  gap: 8px;
}

.input-sections h5 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
}

.input-sections dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.input-field {
  display: grid;
  gap: 4px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.input-field dt {
  color: var(--faint);
  font-size: 12px;
  font-weight: 700;
}

.input-field dd {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.empty-value {
  color: var(--faint);
}

.detail-block pre {
  overflow: auto;
  max-height: 280px;
  margin: 0;
  color: var(--text);
  font: 12px/1.45 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.vote-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  background: #ffffff;
  border-color: var(--border);
  color: var(--muted);
}

.vote-icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 20px;
  font-size: 17px;
  line-height: 1;
}

.vote-count {
  min-width: 16px;
  color: var(--text);
  font-weight: 700;
}

.vote-button.selected {
  border-color: var(--text);
  background: var(--text);
  color: #ffffff;
}

.vote-button.selected .vote-icon {
  filter: saturate(1.1);
}

.vote-button.selected .vote-count {
  color: #ffffff;
}

.vote-button:disabled {
  cursor: default;
  opacity: 0.62;
}

.empty {
  padding: 24px;
  color: var(--muted);
}

@media (max-width: 980px) {
  .hero,
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }
}

@media (max-width: 560px) {
  .topbar,
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  main {
    padding-inline: 16px;
  }
}
