:root {
  --bg: #fafafa;
  --card: #ffffff;
  --raised: #f4f4f5;
  --field-fill: #e8e8ea;
  --field-line: #a7a8aa;
  --line: rgba(23, 23, 23, 0.08);
  --text: #171717;
  --secondary: #525252;
  --muted: #737373;
  --red: #9d1620;
  --red-fill: #e81c2d;
  --radius-control: 8px;
  --radius-card: 12px;
  --font: "Source Sans 3", "Helvetica Neue", Arial, sans-serif;
  --serif: "Source Serif 4", "Times New Roman", serif;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button,
input,
summary {
  font: inherit;
}

.topbar {
  height: 64px;
  width: 100%;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-height: 36px;
}

.wordmark {
  display: block;
  width: 108px;
  height: 32px;
  flex-shrink: 0;
}

.brand-sub {
  padding-left: 12px;
  border-left: 1px solid var(--line);
  font-size: 14px;
  font-weight: 600;
  color: var(--secondary);
  line-height: 1;
}

.top-actions {
  display: flex;
  align-items: center;
  margin-left: auto;
}

.header-btn {
  height: 36px;
  padding: 0 16px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a3a3a3;
}

.status[data-connected="true"] .status-dot {
  background: #16a34a;
}

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 32px 64px;
  flex: 1 0 auto;
  width: 100%;
}

.intro,
.search-card,
.summary,
.results {
  animation: enter 280ms var(--ease) both;
}

@keyframes enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.intro h1,
.search-head h1,
.results h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 32px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.results h2 {
  font-size: 20px;
  margin-bottom: 12px;
}

.intro p,
.search-head p {
  margin: 8px 0 0;
  max-width: 36rem;
  color: var(--secondary);
  font-size: 16px;
}

.intro {
  padding-top: 32px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 1.15fr);
  gap: 32px;
  align-items: center;
}

.why {
  margin: 16px 0 0;
  padding-left: 20px;
  color: var(--text);
  font-size: 16px;
}

.why li + li {
  margin-top: 8px;
}

.independence {
  margin-top: 16px;
  max-width: 36rem;
  font-size: 14px;
  color: var(--secondary);
}

.intro-photo {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
}

.search-card,
.summary {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}

.search-card {
  padding: 24px;
}

.search-head {
  margin-bottom: 20px;
}

.search-form {
  display: grid;
  grid-template-columns: 1.4fr 88px 1.4fr auto;
  gap: 12px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.field span {
  font-size: 14px;
  color: var(--secondary);
}

.field input {
  height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: var(--field-fill);
  color: var(--text);
  outline: none;
}

.field input::placeholder {
  color: var(--field-line);
}

.field input:hover {
  background: #dedee1;
}

.field input:focus {
  background: var(--field-fill);
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(157, 22, 32, 0.16);
}

.field input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--field-fill) inset;
  -webkit-text-fill-color: var(--text);
}

.btn {
  height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--red-fill);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 160ms var(--ease);
}

.btn:hover {
  background: var(--red);
}

.btn:focus-visible,
.text-btn:focus-visible,
.more summary:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.text-btn {
  height: 36px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--secondary);
  cursor: pointer;
}

.text-btn:hover {
  color: var(--text);
}

.doi-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.doi-btn {
  height: 44px;
}

.more {
  margin-top: 16px;
}

.more summary {
  cursor: pointer;
  color: var(--secondary);
  font-size: 14px;
}

.more .field {
  margin-top: 12px;
  max-width: 420px;
}

.note {
  margin: 16px 0 0;
  font-size: 14px;
  color: var(--secondary);
}

.note.error {
  color: #dc2626;
}

.alert {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-control);
  background: #fef2f2;
  color: #991b1b;
  max-width: 36rem;
}

.summary {
  margin-top: 16px;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.summary-label {
  margin: 0;
  font-size: 14px;
  color: var(--secondary);
}

.summary-value {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.summary-value.accent {
  color: var(--red);
}

.summary .text-btn {
  margin-left: auto;
}

.results {
  margin-top: 32px;
}

.paper-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.paper {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 16px;
  padding: 16px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}

.paper h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
}

.paper .meta,
.paper .ids {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--secondary);
}

.paper .ids {
  font-variant-numeric: tabular-nums;
}

.readers {
  text-align: right;
  align-self: start;
}

.readers .n {
  display: block;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--red);
  line-height: 1;
}

.readers .lbl {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

.breakdown {
  grid-column: 1 / -1;
  margin-top: 4px;
}

.breakdown summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--secondary);
}

.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.breakdown h4 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary);
}

.breakdown ul {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.breakdown li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 760px) {
  .topbar,
  main {
    padding-left: 16px;
    padding-right: 16px;
  }

  .search-form {
    grid-template-columns: 1fr 1fr;
  }

  .field-short {
    grid-column: 1;
  }

  .search-form .btn,
  .doi-form .doi-btn {
    grid-column: 1 / -1;
  }

  .paper,
  .breakdown-grid,
  .summary {
    grid-template-columns: 1fr;
    display: grid;
  }

  .summary {
    display: flex;
    flex-wrap: wrap;
  }

  .readers {
    text-align: left;
  }

  .intro {
    grid-template-columns: 1fr;
    padding-top: 16px;
  }

  .intro h1,
  .search-head h1 {
    font-size: 28px;
  }
}

.footnote {
  background: #e4e4e6;
  border-top: 1px solid #c8c8cc;
  padding: 16px 32px;
}

.footnote p {
  max-width: 1040px;
  margin: 0 auto;
  font-size: 14px;
  color: #525252;
}

.footnote a {
  color: #323232;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footnote a:hover {
  color: #9d1620;
}
