:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #d8dee9;
  --text: #202634;
  --muted: #667085;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --soft: #edf7f5;
  --danger: #b42318;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  min-height: 100vh;
}

.search-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: #eef2f7;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 760;
  letter-spacing: 0;
}

.topbar p,
.reader-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px 20px 16px;
}

.search-form input {
  min-width: 0;
  height: 44px;
  border: 1px solid #c9d2df;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--panel);
  color: var(--text);
  outline: none;
}

.search-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.search-form button,
.raw-link {
  height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 650;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.search-form button:hover,
.raw-link:hover {
  background: var(--accent-strong);
}

.results {
  list-style: none;
  margin: 0;
  padding: 0 12px 18px;
  overflow: auto;
}

.result {
  width: 100%;
  margin: 0 0 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
}

.result button {
  width: 100%;
  min-height: 92px;
  border: 0;
  border-radius: 8px;
  padding: 12px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.result button:hover,
.result.is-active button {
  background: var(--panel);
}

.result.is-active {
  border-color: var(--accent);
}

.result-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.result-title {
  font-size: 17px;
  line-height: 1.2;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.score {
  color: #344054;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}

.result-path,
.reason,
.snippet {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.reason {
  color: var(--accent-strong);
  font-size: 12px;
}

.snippet {
  color: #303846;
}

.reader-pane {
  min-width: 0;
  background: var(--panel);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 100vh;
  color: var(--muted);
}

.empty-state h2 {
  font-size: 18px;
  font-weight: 650;
}

.reader {
  min-height: 100vh;
}

.reader-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
}

.reader-header h2 {
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.raw-link {
  flex: 0 0 auto;
}

.preview {
  max-width: 980px;
  padding: 24px;
}

.markdown-body {
  max-width: 880px;
  font-size: 16px;
  line-height: 1.62;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 22px 0 10px;
  line-height: 1.25;
  letter-spacing: 0;
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child {
  margin-top: 0;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body table,
.markdown-body pre {
  margin: 0 0 16px;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 24px;
}

.markdown-body li + li {
  margin-top: 4px;
}

.markdown-body a {
  color: var(--accent-strong);
}

.markdown-body code,
.preview pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.markdown-body code {
  border-radius: 4px;
  padding: 2px 5px;
  background: #eef2f7;
  font-size: 0.92em;
}

.markdown-body pre {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #111827;
  color: #f8fafc;
}

.markdown-body pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.markdown-body blockquote {
  border-left: 4px solid var(--line);
  padding-left: 14px;
  color: var(--muted);
}

.markdown-body table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 14px;
}

.markdown-body th,
.markdown-body td {
  min-width: 120px;
  border: 1px solid var(--line);
  padding: 8px 10px;
  vertical-align: top;
}

.markdown-body th {
  background: #eef2f7;
  text-align: left;
  font-weight: 700;
}

.wikilink {
  color: var(--accent-strong);
  font-weight: 650;
}

.preview pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.58;
}

.preview img,
.preview iframe,
.preview video {
  display: block;
  width: 100%;
  max-height: calc(100vh - 130px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.preview iframe {
  height: calc(100vh - 130px);
}

.notice {
  margin: 16px 20px;
  padding: 12px 14px;
  border: 1px solid #fecdca;
  border-radius: 8px;
  background: #fffbfa;
  color: var(--danger);
  font-size: 14px;
  line-height: 1.4;
}

@media (max-width: 760px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .search-pane {
    min-height: 48vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .results {
    max-height: 52vh;
  }

  .empty-state {
    min-height: 34vh;
  }

  .reader {
    min-height: 50vh;
  }

  .reader-header {
    padding: 14px 16px;
  }

  .preview {
    padding: 16px;
  }
}
