:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d8dee7;
  --text: #1c2430;
  --muted: #667085;
  --blue: #1f5fbf;
  --blue-dark: #174b98;
  --amber: #9a5b00;
  --green: #0f7b55;
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--text);
  font-weight: 750;
  letter-spacing: 0;
}

.nav {
  display: flex;
  gap: 18px;
  font-size: 14px;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto 56px;
}

.search-band {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.query-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input[type="text"],
input[name="q"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  color: var(--text);
  font-size: 16px;
  outline: none;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 95, 191, 0.12);
}

button,
.ghost-button,
.pager a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #ffffff;
  padding: 0 16px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.pager a:hover {
  background: var(--blue-dark);
  text-decoration: none;
}

button:disabled {
  border-color: rgba(15, 123, 85, 0.3);
  background: rgba(15, 123, 85, 0.1);
  color: var(--green);
  cursor: default;
}

.ghost-button {
  background: #ffffff;
  color: var(--blue);
}

.ghost-button:hover {
  background: #eef4ff;
  text-decoration: none;
}

.source-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.source-tab input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.source-tab span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  padding: 0 12px;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

.source-tab.active span {
  border-color: rgba(31, 95, 191, 0.3);
  background: #eef4ff;
  color: var(--blue);
}

.alert {
  margin-top: 16px;
  border: 1px solid rgba(154, 91, 0, 0.3);
  background: rgba(154, 91, 0, 0.08);
  color: var(--amber);
  border-radius: 8px;
  padding: 14px 16px;
}

.result-head,
.document-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 26px 0 14px;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: 0;
}

.result-head p,
.document-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.page-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 14px;
}

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

.result-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.result-title {
  font-weight: 720;
  color: var(--text);
}

.result-court {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.snippet {
  margin: 10px 0 0;
  color: #364152;
  font-size: 14px;
}

.save-form {
  margin: 0;
}

.pager {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.empty {
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 22px;
  color: var(--muted);
}

.document {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.document-head {
  margin-top: 0;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.document-text {
  margin: 18px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.65;
}

@media (max-width: 720px) {
  .topbar {
    padding: 0 16px;
  }

  .query-row,
  .result-item,
  .result-head,
  .document-head {
    grid-template-columns: 1fr;
    display: grid;
  }

  button,
  .ghost-button {
    width: 100%;
  }

  .pager {
    justify-content: stretch;
  }

  .pager a {
    flex: 1;
  }
}
