:root {
  color-scheme: light;
  --ink: #182019;
  --muted: #657064;
  --paper: #f3efe5;
  --panel: #fffaf0;
  --panel-2: #ebe6db;
  --line: rgba(24, 32, 25, 0.16);
  --green: #2f7d4f;
  --green-soft: #dcebdc;
  --red: #a83f36;
  --red-soft: #f1d9d5;
  --amber: #ad7426;
  --amber-soft: #f0e2c9;
  --blue: #276c86;
  --shadow: 0 12px 34px rgba(38, 38, 26, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(47, 125, 79, 0.07) 1px, transparent 1px),
    linear-gradient(180deg, rgba(47, 125, 79, 0.05) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: ui-sans-serif, "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
}

.shell {
  width: min(1500px, calc(100vw - 36px));
  margin: 0 auto;
  padding: 26px 0 44px;
}

.masthead {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

h1,
h2,
p,
dl {
  margin: 0;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(38px, 6vw, 86px);
  line-height: 0.92;
}

.eyebrow,
.metrics span,
.metrics small,
label span,
dt,
.panel-head p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.build-stamp,
.metrics article,
.toolbar,
.topic-panel,
.results-panel,
.history-panel {
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.92);
  box-shadow: var(--shadow);
}

.build-stamp {
  display: grid;
  gap: 5px;
  min-width: 250px;
  padding: 13px 15px;
}

.build-stamp span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.build-stamp strong {
  font-size: 14px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.metrics article {
  display: grid;
  gap: 8px;
  min-height: 112px;
  padding: 16px;
}

.metrics small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

.metrics strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 46px;
  line-height: 1;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) 170px 260px 170px 110px;
  gap: 12px;
  margin-bottom: 12px;
  padding: 14px;
}

label {
  display: grid;
  gap: 7px;
}

input,
select,
button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: var(--panel);
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 0 12px;
}

button,
a {
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

button:active,
a:active {
  transform: scale(0.97);
}

.content {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 12px;
}

.content-wide {
  grid-template-columns: 300px minmax(560px, 1fr) 280px;
}

.toolbar-button,
.clear-history {
  padding: 0 14px;
  font-weight: 900;
  background: var(--panel-2);
  cursor: pointer;
}

.topic-panel,
.results-panel,
.history-panel {
  min-height: 640px;
  min-width: 0;
  padding: 16px;
}

.panel-head,
.results-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head strong,
.results-head strong {
  display: block;
  margin-top: 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
}

.fulltext-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.pagination {
  display: grid;
  grid-template-columns: 96px 86px 118px minmax(160px, 1fr) 86px;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(235, 230, 219, 0.48);
}

.pagination label {
  gap: 5px;
}

.pagination input {
  min-height: 38px;
}

.pagination button {
  min-height: 38px;
  padding: 0 12px;
  font-weight: 900;
  background: var(--panel);
  cursor: pointer;
}

.pagination button:disabled {
  color: rgba(101, 112, 100, 0.55);
  cursor: not-allowed;
  background: rgba(255, 250, 240, 0.44);
}

.page-info {
  align-self: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

#resetButton {
  min-width: 76px;
  padding: 0 14px;
  font-weight: 800;
  background: var(--panel-2);
  cursor: pointer;
}

.result-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.result-tools button {
  min-width: 96px;
  padding: 0 12px;
  font-weight: 900;
  background: var(--panel-2);
  cursor: pointer;
}

.result-tools button.active,
.favorite-button.active {
  color: var(--panel);
  border-color: var(--green);
  background: var(--green);
}

.read-button.active {
  color: var(--panel);
  border-color: var(--blue);
  background: var(--blue);
}

.topic-list {
  display: grid;
  gap: 8px;
}

.topic-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 62px;
  padding: 10px;
  text-align: left;
  background: rgba(235, 230, 219, 0.72);
  cursor: pointer;
}

.topic-row:hover,
.distribution-row:hover,
#resetButton:hover,
.toolbar-button:hover,
.clear-history:hover,
.workspace-tools button:hover,
.history-item:hover,
.history-delete:hover,
.result-tools button:hover,
.pagination button:not(:disabled):hover {
  border-color: rgba(47, 125, 79, 0.45);
  background: var(--green-soft);
}

.result-tools button.active:hover,
.favorite-button.active:hover {
  color: var(--panel);
  background: #256a40;
}

.read-button.active:hover {
  color: var(--panel);
  background: #1f5a70;
}

.topic-row span {
  display: grid;
  gap: 4px;
}

.topic-row strong {
  font-size: 13px;
  line-height: 1.25;
}

.topic-row small {
  color: var(--muted);
  font-weight: 700;
}

.topic-row em {
  min-width: 48px;
  color: var(--green);
  font-style: normal;
  font-weight: 900;
  text-align: right;
}

.results {
  display: grid;
  gap: 10px;
}

.result-dashboard {
  display: grid;
  gap: 14px;
  margin: 0 0 12px;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.74);
  box-shadow: var(--shadow);
}

.dashboard-head {
  margin-bottom: 0;
}

.dashboard-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.dashboard-metrics article {
  display: grid;
  gap: 6px;
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(235, 230, 219, 0.62);
}

.dashboard-metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.dashboard-metrics strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  line-height: 1;
}

.topic-distribution {
  display: grid;
  gap: 9px;
  margin-top: 10px;
}

.distribution-row {
  display: grid;
  gap: 6px;
  width: 100%;
  min-height: auto;
  padding: 0;
  text-align: left;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.distribution-row div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.distribution-row strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.distribution-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.distribution-bar {
  height: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(24, 32, 25, 0.07);
}

.distribution-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 30px;
}

.active-filters button,
.filters-empty {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(235, 230, 219, 0.68);
  font-size: 12px;
  font-weight: 900;
}

.active-filters button {
  cursor: pointer;
}

.active-filters button span {
  margin-left: 8px;
  color: var(--muted);
}

.share-check {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(235, 230, 219, 0.48);
}

.share-check-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  font-size: 13px;
  line-height: 1.35;
}

.share-check-row strong {
  font-weight: 900;
}

.share-check-row.good strong {
  color: var(--green);
}

.share-check-row.warn strong {
  color: var(--amber);
}

.share-check-row.bad strong {
  color: var(--red);
}

.share-check-row a {
  color: var(--blue);
  font-weight: 900;
}

.result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 14px;
  padding: 15px;
  border: 1px solid rgba(24, 32, 25, 0.12);
  background: rgba(255, 250, 240, 0.78);
  box-shadow: 0 1px 0 rgba(24, 32, 25, 0.06);
}

.result:hover {
  border-color: rgba(47, 125, 79, 0.32);
  background: rgba(255, 250, 240, 0.96);
}

.result.compact {
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 10px;
  padding: 11px;
}

.result.compact h2 {
  font-size: 16px;
  line-height: 1.22;
}

.result.compact .result-meta,
.result.compact .snippets,
.result.compact .note-summary {
  display: none;
}

.result-main {
  min-width: 0;
}

.result h2,
dd,
.reason,
.topic-row strong {
  overflow-wrap: anywhere;
}

.result-kicker,
.result-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.result-kicker {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.result-kicker span,
.result-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 7px;
  background: rgba(235, 230, 219, 0.72);
}

.result-kicker .poster-code {
  color: var(--panel);
  background: var(--ink);
}

.result-kicker .hit-label {
  color: var(--green);
  background: var(--green-soft);
}

.result-title {
  margin-bottom: 9px;
}

.result h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  line-height: 1.16;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.badge.good {
  color: var(--green);
  background: var(--green-soft);
}

.badge.warn {
  color: var(--amber);
  background: var(--amber-soft);
}

.badge.bad {
  color: var(--red);
  background: var(--red-soft);
}

.badge.quiet {
  color: var(--muted);
  background: var(--panel);
}

.result-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

.reason {
  margin-top: 12px;
  padding: 10px;
  color: var(--red);
  background: rgba(168, 63, 54, 0.09);
  line-height: 1.35;
}

.text-state {
  display: inline-flex;
  width: fit-content;
  margin-top: 12px;
  min-height: 26px;
  align-items: center;
  padding: 0 8px;
  color: var(--blue);
  background: rgba(39, 108, 134, 0.1);
  font-size: 12px;
  font-weight: 900;
}

.snippets {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.snippets p {
  padding: 10px 12px;
  border-left: 3px solid var(--blue);
  background: rgba(255, 250, 240, 0.78);
  color: #334036;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.workspace-meta {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-list span,
.last-viewed {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  color: var(--blue);
  background: rgba(39, 108, 134, 0.1);
  font-size: 12px;
  font-weight: 900;
}

.note-summary {
  padding: 10px 12px;
  border-left: 3px solid var(--amber);
  background: rgba(173, 116, 38, 0.1);
  color: #3f382e;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

mark {
  padding: 0 2px;
  color: inherit;
  background: rgba(173, 116, 38, 0.26);
}

.actions {
  display: grid;
  align-content: start;
  gap: 8px;
}

.actions a,
.actions button,
.disabled {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--panel);
  font-weight: 900;
  text-decoration: none;
}

.actions a:hover,
.actions button:hover {
  border-color: rgba(39, 108, 134, 0.55);
  background: rgba(39, 108, 134, 0.12);
}

.actions button {
  width: 100%;
  cursor: pointer;
}

.disabled {
  color: var(--muted);
  background: rgba(255, 250, 240, 0.5);
}

.empty {
  padding: 18px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 250, 240, 0.72);
  font-weight: 800;
}

.history-list {
  display: grid;
  gap: 8px;
}

.workspace-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.workspace-tools button {
  min-height: 38px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 900;
  background: var(--panel-2);
  cursor: pointer;
}

.history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px;
  gap: 6px;
}

.history-item {
  display: grid;
  gap: 6px;
  width: 100%;
  min-height: 58px;
  padding: 10px;
  text-align: left;
  background: rgba(235, 230, 219, 0.72);
  cursor: pointer;
}

.history-delete {
  width: 54px;
  min-height: 58px;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  background: rgba(235, 230, 219, 0.46);
  cursor: pointer;
}

.history-item strong {
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.25;
}

.history-item span,
.history-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.history-empty {
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(235, 230, 219, 0.5);
}

.clear-history {
  width: 100%;
  margin-top: 12px;
}

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

  .masthead {
    display: grid;
    align-items: start;
  }

  .metrics,
  .toolbar,
  .pagination {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .content {
    display: grid;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100vw - 22px, 1500px);
    padding-top: 16px;
  }

  .metrics,
  .toolbar,
  .pagination {
    grid-template-columns: 1fr;
  }

  .metrics article {
    min-height: 86px;
  }

  .metrics strong {
    font-size: 36px;
  }

  .topic-panel,
  .results-panel {
    min-height: auto;
  }

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

  .result-title,
  dl {
    grid-template-columns: 1fr;
  }

  .actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .share-check-row {
    grid-template-columns: 1fr;
  }
}
