:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --panel-soft: #f0f4f1;
  --line: #d7ded8;
  --line-strong: #a9b8af;
  --text: #17211c;
  --muted: #617066;
  --accent: #126250;
  --accent-weak: #e4f1ed;
  --warn: #9b3a2d;
  --mark: #fff0a6;
  --shadow: 0 16px 34px rgba(28, 43, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic", sans-serif;
}

a {
  color: inherit;
}

.app-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0 20px;
}

.brand {
  font-weight: 800;
  text-decoration: none;
}

.page-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.topbar .page-links {
  margin-top: 0;
  justify-content: flex-end;
}

.page-links a {
  color: var(--accent);
  text-decoration: none;
}

.page-links a:hover {
  text-decoration: underline;
}

.topnav {
  display: flex;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.topnav button,
.primary-button,
.pager button,
.result-link {
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.topnav button {
  padding: 0 14px;
}

.topnav button.is-active,
.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.search-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.filters,
.workspace,
.result-item,
.facet-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.filters {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 14px;
  padding: 16px;
}

.search-form,
.field,
.facet-list,
.results {
  display: grid;
  gap: 12px;
}

.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.inline-help-button,
.help-close-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}

.inline-help-button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
}

.inline-help-button:hover,
.help-close-button:hover {
  border-color: var(--accent);
  background: var(--accent-weak);
}

.field input,
.field select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font: inherit;
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--accent-weak);
  border-color: var(--accent);
}

.split-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary-button {
  width: 100%;
}

.facet-panel {
  padding: 14px;
  box-shadow: none;
}

.facet-panel h2 {
  margin: 0 0 10px;
  font-size: 14px;
}

.facet-list {
  gap: 8px;
}

.facet-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.workspace {
  min-height: 680px;
  padding: 20px;
}

.workspace-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.25;
}

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

.stat {
  min-width: 112px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

.message-area {
  margin: 16px 0;
}

.message {
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--muted);
}

.message.is-error {
  border-color: #e4b2a9;
  background: #fff5f3;
  color: var(--warn);
}

.result-item {
  display: grid;
  gap: 10px;
  padding: 16px;
  box-shadow: none;
}

.result-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.result-kind {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
}

.result-date {
  font-size: 12px;
  color: var(--muted);
}

.result-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.45;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.result-excerpt {
  margin: 0;
  color: #2c3931;
  font-size: 14px;
  line-height: 1.8;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.result-link {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  text-decoration: none;
}

mark {
  padding: 0 2px;
  background: var(--mark);
}

.has-help-modal {
  overflow: hidden;
}

.help-modal[hidden] {
  display: none;
}

.help-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
}

.help-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 33, 28, 0.44);
}

.help-modal-panel {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(23, 33, 28, 0.22);
}

.help-modal-panel:focus {
  outline: 2px solid var(--accent-weak);
}

.help-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.help-modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.help-close-button {
  min-width: 36px;
  min-height: 36px;
  font-size: 22px;
  line-height: 1;
}

.help-modal-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.query-help-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 10px 16px;
  margin: 0;
}

.query-help-list dt {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.query-help-list dd {
  display: grid;
  gap: 4px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.query-help-list code {
  width: fit-content;
  max-width: 100%;
  padding: 3px 6px;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  background: #f8faf8;
  color: var(--text);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
}

.help-modal-body p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.docs-shell {
  max-width: 960px;
}

.docs-page {
  display: grid;
  gap: 16px;
}

.docs-hero,
.docs-section {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.docs-hero {
  padding: 24px;
}

.docs-section {
  padding: 20px 24px;
}

.docs-hero p,
.docs-section p,
.docs-params {
  max-width: 780px;
  color: var(--muted);
  line-height: 1.8;
}

.docs-section h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.docs-page code {
  font-family: Consolas, "SFMono-Regular", monospace;
}

.docs-page pre {
  overflow-x: auto;
  margin: 12px 0;
  padding: 14px;
  border: 1px solid var(--line);
  background: #f8faf8;
  color: var(--text);
}

.docs-params {
  display: grid;
  grid-template-columns: minmax(130px, max-content) minmax(0, 1fr);
  gap: 8px 18px;
  margin: 0;
}

.docs-params dt {
  font-weight: 800;
  color: var(--text);
}

.docs-params dd {
  margin: 0;
}

.docs-params-wide {
  grid-template-columns: minmax(180px, max-content) minmax(0, 1fr);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-top: 18px;
}

.pager button {
  padding: 0 14px;
}

.pager button:disabled {
  opacity: 0.45;
  cursor: default;
}

.detail-page .app-shell {
  max-width: 1180px;
}

.detail-source-link {
  min-width: 92px;
  justify-content: center;
}

.detail-layout {
  display: grid;
  gap: 16px;
}

.detail-head,
.detail-search,
.detail-body {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.detail-head {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.detail-head h1 {
  font-size: 24px;
}

.detail-meta {
  gap: 10px;
}

.detail-search {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.detail-search-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-search-actions button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.detail-search-actions button:disabled {
  opacity: 0.45;
  cursor: default;
}

.detail-count {
  min-width: 76px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.detail-body {
  padding: 22px;
  font-family: "BIZ UDMincho", "Yu Mincho", serif;
  font-size: 16px;
  line-height: 2;
  overflow-wrap: anywhere;
}

.detail-body p {
  margin: 0 0 1.2em;
}

.detail-body p:last-child {
  margin-bottom: 0;
}

.detail-empty {
  color: var(--muted);
  font-family: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic", sans-serif;
}

.detail-hit {
  border-radius: 2px;
}

.detail-hit.is-active {
  background: #ffbf47;
  box-shadow: 0 0 0 2px rgba(255, 191, 71, 0.35);
}

@media (max-width: 900px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .workspace-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar .page-links {
    justify-content: flex-start;
  }

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

  .filters {
    position: static;
  }

  .topnav {
    width: 100%;
  }

  .topnav button {
    flex: 1;
  }

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

  .detail-search-actions {
    justify-content: space-between;
  }

  .detail-body {
    padding: 16px;
    font-size: 15px;
  }

  .query-help-list {
    grid-template-columns: 1fr;
  }

  .docs-params {
    grid-template-columns: 1fr;
  }
}
