:root {
  --paper: #f4efe6;
  --paper-2: #ece4d6;
  --ink: #211d17;
  --ink-soft: #6a6053;
  --line: #d8cdba;
  --line-soft: #e4dccd;
  --accent: #7a2e26;
  --accent-ink: #fbf6ee;
  --green: #3c5a3a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 3rem 1.25rem 5rem;
  font-family: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
}

main { max-width: 720px; margin: 0 auto; }

header { border-bottom: 2px solid var(--ink); padding-bottom: 1rem; margin-bottom: 2rem; }
header h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.sub { margin: .35rem 0 0; color: var(--ink-soft); font-style: italic; }
.muted { color: var(--ink-soft); font-weight: 400; }
.small { font-size: .85rem; }

.error {
  background: #f6e4df;
  border-left: 3px solid var(--accent);
  color: #5e221c;
  padding: .7rem .95rem;
  margin-bottom: 1.25rem;
}

textarea {
  width: 100%;
  padding: .95rem 1rem;
  border: 1px solid var(--line);
  background: #fbf8f2;
  color: var(--ink);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: .88rem;
  line-height: 1.6;
  resize: vertical;
}
textarea:focus { outline: none; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.row { display: flex; align-items: center; gap: 1.25rem; margin-top: 1rem; }
.file { color: var(--ink-soft); font-size: .88rem; cursor: pointer; }
.file input { display: block; margin-top: .35rem; font-family: inherit; }

button {
  font-family: inherit;
  background: var(--ink);
  color: var(--paper);
  border: 0;
  padding: .65rem 1.4rem;
  font-size: .95rem;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  transition: background .12s ease;
}
button:hover { background: var(--accent); }
.row button { margin-left: auto; }

.results { margin-top: 3rem; }
.results h2 {
  font-size: 1.3rem;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  padding-bottom: .5rem;
}

table.tokens { width: 100%; border-collapse: collapse; margin: 1.25rem 0; }
.tokens th, .tokens td {
  text-align: left;
  padding: .55rem .65rem;
  border-bottom: 1px solid var(--line-soft);
}
.tokens th {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.tokens tbody tr:hover { background: var(--paper-2); }
.tokens .tok { font-weight: 600; }
.tokens .src { color: var(--ink-soft); font-size: .85rem; }
.src .cnt { color: var(--ink-soft); font-size: .78rem; margin-left: 2px; font-weight: 700; }
.qty {
  width: 54px; padding: .35rem .45rem;
  border: 1px solid var(--line); background: #fbf8f2; color: var(--ink);
  font-family: ui-monospace, Menlo, monospace;
}
.qty:disabled { opacity: .35; }

.pdf-btn { margin-top: .75rem; background: var(--green); }
.pdf-btn:hover { background: #4a6e47; }

.unmatched { margin-top: 1.75rem; }
.unmatched summary { cursor: pointer; color: var(--ink-soft); }

.card-hover { cursor: help; border-bottom: 1px dotted var(--accent); }
.card-hover:hover { color: var(--accent); }

.card-preview {
  position: fixed; width: 240px; border-radius: 4.75% / 3.5%;
  pointer-events: none; z-index: 1000; opacity: 0;
  box-shadow: 0 12px 30px rgba(40, 30, 15, .4);
  transition: opacity .12s ease;
}
.card-preview.visible.ready { opacity: 1; }

.gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 1.4rem; margin-top: 2.25rem;
}
.token-card { margin: 0; text-align: center; }
.token-card img {
  width: 100%; display: block; border-radius: 4.75% / 3.5%;
  box-shadow: 0 6px 16px rgba(40, 30, 15, .28);
}
.token-card figcaption { margin-top: .5rem; font-size: .84rem; }
.token-card.noart {
  border: 1px dashed var(--line); min-height: 205px;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; background: var(--paper-2);
}
.token-card.noart figcaption { margin: 0; color: var(--ink-soft); }
