:root {
  --ink: #171717;
  --muted: #68645d;
  --line: #ded8cc;
  --paper: #f6f1e8;
  --panel: #fffaf1;
  --panel-strong: #f0e5d2;
  --green: #17745a;
  --red: #b34538;
  --blue: #245d86;
  --yellow: #d79b22;
  --shadow: 0 18px 60px rgba(49, 43, 33, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(23, 23, 23, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(23, 23, 23, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: Georgia, "Times New Roman", serif;
}

button,
input,
select {
  font: inherit;
}

.public-mark {
  display: grid;
  place-items: center;
  min-height: 48px;
  border: 1px solid var(--ink);
  background: var(--green);
  color: #fffdf8;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
}

.shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: end;
  padding: 20px 0 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.1rem, 6vw, 5.8rem);
  line-height: 0.92;
  letter-spacing: 0;
  max-width: 760px;
}

h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.stats {
  display: grid;
  place-items: center;
  min-width: 104px;
  aspect-ratio: 1;
  border: 1px solid var(--ink);
  background: var(--panel);
  box-shadow: 7px 7px 0 var(--ink);
}

.stats span {
  font-size: 2rem;
  font-weight: 700;
}

.stats small {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.search-panel {
  border: 1px solid var(--ink);
  background: rgba(255, 250, 241, 0.94);
  box-shadow: var(--shadow);
  padding: 14px;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr minmax(140px, 180px);
  gap: 10px;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  background: #fffdf8;
  padding: 0 14px;
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(215, 155, 34, 0.38);
  outline-offset: 2px;
}

.category-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  min-height: 34px;
  border: 1px solid var(--ink);
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  background: var(--ink);
  color: var(--panel);
}

.workspace {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  margin-top: 18px;
}

.rail {
  display: grid;
  gap: 14px;
  align-content: start;
}

.rail-block {
  border: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.72);
  padding: 16px;
}

.stacked-bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 72px 1fr 28px;
  gap: 8px;
  align-items: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
}

.bar-track {
  height: 10px;
  border: 1px solid var(--ink);
  background: #fffdf8;
}

.bar-fill {
  height: 100%;
  background: var(--green);
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tag {
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--muted);
  padding: 5px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.74rem;
}

.result-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
}

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

.item-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  border: 1px solid var(--ink);
  background: var(--panel);
  padding: 18px;
  box-shadow: 4px 4px 0 rgba(23, 23, 23, 0.88);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.item-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 rgba(23, 23, 23, 0.88);
}

.item-card h3 {
  margin: 0 0 8px;
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  line-height: 1.12;
}

.item-card p {
  margin: 0 0 12px;
  color: #35312b;
  line-height: 1.58;
}

.item-side {
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 8px;
  min-width: 92px;
}

.badge {
  border: 1px solid var(--ink);
  background: var(--panel-strong);
  padding: 5px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
}

.score {
  color: var(--red);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
}

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--ink);
  padding: 0;
  background: var(--panel);
  box-shadow: 12px 12px 0 var(--ink);
}

dialog::backdrop {
  background: rgba(23, 23, 23, 0.42);
}

.detail {
  position: relative;
  padding: 28px;
}

.detail h2 {
  margin: 0 42px 12px 0;
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  line-height: 1;
}

.detail p,
.detail li {
  line-height: 1.62;
}

.detail a {
  display: inline-block;
  margin-top: 18px;
  color: var(--blue);
}

.icon-button {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--ink);
  background: #fffdf8;
  cursor: pointer;
}

.empty {
  border: 1px dashed var(--muted);
  background: rgba(255, 250, 241, 0.7);
  padding: 26px;
  color: var(--muted);
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .stats {
    width: 90px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .search-row,
  .item-card {
    grid-template-columns: 1fr;
  }

  .item-side {
    justify-items: start;
    grid-auto-flow: column;
    justify-content: start;
  }
}
