/* BITech 暖纸 · 墨 · 朱印 — the token layer the page is built on.
   Values mirror the product skin so this standalone page and the in-app plugin
   render as the same surface. */
:root {
  --bt-paper: #fbf8f1;
  --bt-paper-2: #f2ebdc;
  --bt-ink: #16140f;
  --bt-ink-2: #403b31;
  --bt-ink-3: #6a6355;
  --bt-ink-4: #a89f8c;
  --bt-rule: rgba(22, 20, 15, 0.16);
  --bt-rule-strong: rgba(22, 20, 15, 0.46);
  --bt-rule-faint: rgba(22, 20, 15, 0.06);
  --bt-seal: #b23a2b;
  --bt-seal-soft: rgba(178, 58, 43, 0.12);
  --bt-seal-veil: rgba(178, 58, 43, 0.06);
  --bt-hairline: 1px;
  --bt-radius-sm: 0px;
  --bt-radius-panel: 3px;
  --bt-warn: #7d5f2b;
  --bt-fs-meta: 11px;
  --bt-fs-ui: 12.5px;
  --bt-fs-body: 14px;
  --bt-fs-hero: clamp(26px, 2.4vw, 34px);
  --bt-ls-hero: 0.1em;
  --bt-font-serif: "Noto Serif SC", "Songti SC", "Source Han Serif SC", SimSun, serif;
  --bt-font-sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --bt-font-mono: "Source Code Pro", "Cascadia Mono", Consolas, monospace;
  --bt-shadow-prominent: 0 8px 24px rgba(22, 20, 15, 0.12);
  --bt-hover: rgba(22, 20, 15, 0.045);
  --bt-layer-2: rgba(22, 20, 15, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bt-paper: #1d1a14;
    --bt-paper-2: #14110c;
    --bt-ink: #ece5d6;
    --bt-ink-2: #c6bfad;
    --bt-ink-3: #a79f8d;
    --bt-ink-4: #625b4e;
    --bt-rule: rgba(236, 229, 214, 0.16);
    --bt-rule-strong: rgba(236, 229, 214, 0.46);
    --bt-rule-faint: rgba(236, 229, 214, 0.06);
    --bt-seal: #d9533f;
    --bt-seal-soft: rgba(217, 83, 63, 0.16);
    --bt-seal-veil: rgba(217, 83, 63, 0.08);
    --bt-warn: #c9a45f;
    --bt-shadow-prominent: 0 8px 24px rgba(0, 0, 0, 0.5);
    --bt-hover: rgba(236, 229, 214, 0.05);
    --bt-layer-2: rgba(236, 229, 214, 0.07);
  }
}

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

/* A `hidden` attribute must win over any class that sets a display mode; without
   this, a popover styled `display: flex` stays visible while marked hidden. */
[hidden] {
  display: none !important;
}

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

body {
  background: var(--bt-paper);
  color: var(--bt-ink);
  font-family: var(--bt-font-sans);
  font-size: var(--bt-fs-body);
  line-height: 1.6;
  overflow: hidden;
}

/* --------------------------------------------------------------- page shell */

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.view {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.view[hidden] {
  display: none;
}

/* -------------------------------------------------------------------- hero */

.hero {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0 24px;
}

.hero-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 640px;
  padding-bottom: 48px;
}

.hero-headline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  column-gap: 10px;
  row-gap: 12px;
  color: var(--bt-ink);
  font-family: var(--bt-font-serif);
  font-size: var(--bt-fs-hero);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: var(--bt-ls-hero);
  padding-left: var(--bt-ls-hero);
}

.hero-mark {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--bt-ink);
}

.hero-mark svg {
  display: block;
  overflow: visible;
}

/* The seal's heart is its only colour; the frame inherits the ink. */
.seal-heart {
  fill: var(--bt-seal);
}

.hero-title {
  display: inline-block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.hint {
  margin: -2px 0 0;
  color: var(--bt-ink-3);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

/* ------------------------------------------------------------- search card */

.card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 8px 0 6px;
  border: var(--bt-hairline) solid var(--bt-rule-strong);
  border-radius: var(--bt-radius-sm);
  background: var(--bt-paper);
  color: var(--bt-ink-2);
  font-size: var(--bt-fs-body);
  transition: border-color 0.15s ease;
}

.card:focus-within {
  border-color: var(--bt-seal);
}

.card textarea {
  width: 100%;
  height: 96px;
  min-height: 96px;
  max-height: 96px;
  padding: 0 12px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--bt-ink);
  font: inherit;
  line-height: 24px;
  resize: none;
  overflow-y: auto;
  display: block;
  field-sizing: fixed;
}

.card textarea::placeholder {
  color: var(--bt-ink-3);
}

.card textarea:focus-visible {
  outline: none;
}

.card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 2px 8px;
}

.card-foot .options {
  flex: 1 1 auto;
  min-width: 0;
}

/* ------------------------------------------------- in-line search toolbar */

.head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 0.5px solid var(--bt-rule);
}

.bar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 4px 0 8px;
  border: 0.5px solid var(--bt-rule);
  border-radius: var(--bt-radius-panel);
  color: var(--bt-ink-2);
}

.bar:focus-within {
  align-items: flex-start;
  height: auto;
  min-height: 32px;
  padding-top: 6px;
  padding-bottom: 6px;
  border-color: var(--bt-seal);
}

.bar > svg {
  flex: none;
}

.bar:focus-within > svg {
  margin-top: 4px;
}

.bar textarea {
  flex: 1;
  min-width: 0;
  height: 22px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--bt-ink);
  font: inherit;
  line-height: 22px;
  resize: none;
  overflow-y: auto;
}

.bar textarea::placeholder {
  color: var(--bt-ink-3);
}

.bar textarea:focus {
  field-sizing: fixed;
  height: 66px;
  min-height: 66px;
  max-height: 66px;
}

.bar textarea:focus-visible {
  outline: none;
}

/* ---------------------------------------------------------------- controls */

.options {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--bt-ink-2);
  font-size: 13px;
}

.count {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.count ~ .syntax {
  margin-left: auto;
}

.count-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 8px;
  border: 0.5px solid var(--bt-rule-strong);
  border-radius: var(--bt-radius-sm);
  background: transparent;
  color: var(--bt-ink);
  font: inherit;
  font-size: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.count-trigger:hover,
.count-trigger[aria-expanded="true"] {
  border-color: var(--bt-seal);
}

.count-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 88px;
  padding: 4px;
  border: var(--bt-hairline) solid var(--bt-rule);
  border-radius: var(--bt-radius-panel);
  background: var(--bt-paper);
  box-shadow: var(--bt-shadow-prominent);
}

.count-option {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--bt-radius-sm);
  background: transparent;
  color: var(--bt-ink);
  font: inherit;
  font-size: inherit;
  text-align: left;
  cursor: pointer;
}

@media (hover: hover) {
  .count-option:hover {
    background: var(--bt-hover);
  }
}

.count-option[aria-selected="true"] {
  background: var(--bt-seal-veil);
  color: var(--bt-seal);
  font-weight: 500;
  box-shadow: inset 2px 0 0 var(--bt-seal);
}

.syntax {
  position: relative;
  display: flex;
}

.syntax-trigger {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--bt-ink-2);
  font: inherit;
  font-size: inherit;
  cursor: pointer;
}

.syntax-trigger:hover {
  color: var(--bt-seal);
}

.syntax-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: min(288px, calc(100vw - 48px));
  padding: 4px;
  border: var(--bt-hairline) solid var(--bt-rule);
  border-radius: var(--bt-radius-panel);
  background: var(--bt-paper);
  box-shadow: var(--bt-shadow-prominent);
}

.syntax-panel p {
  margin: 0;
  padding: 6px 8px;
  border-radius: var(--bt-radius-panel);
  color: var(--bt-ink-2);
  font-size: 13px;
  line-height: 1.5;
}

.submit {
  flex: none;
  height: 28px;
  padding: 0 14px;
  border: var(--bt-hairline) solid var(--bt-seal);
  border-radius: var(--bt-radius-sm);
  background: var(--bt-seal);
  color: #fbf8f1;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.submit:hover:not(:disabled) {
  opacity: 0.88;
}

.submit:disabled {
  border-color: var(--bt-rule);
  background: transparent;
  color: var(--bt-ink-3);
  cursor: default;
}

:where(button, a, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--bt-seal);
  outline-offset: 2px;
}

.card textarea:focus-visible,
.bar textarea:focus-visible {
  outline: none;
}

/* ------------------------------------------------------------- result list */

.body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
}

.status {
  margin: 0;
  padding: 8px 12px 4px;
  color: var(--bt-ink-3);
  font-size: 13px;
}

.results {
  flex: none;
  margin: 0;
  padding: 0 0 12px;
  list-style: none;
}

.result {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
}

.result + .result {
  border-top: 0.5px solid var(--bt-rule-faint);
}

@media (hover: hover) {
  .result:hover {
    background: var(--bt-hover);
  }
}

.result-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--bt-ink-3);
  font-size: 13px;
}

.result-favicon {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 2px;
  object-fit: cover;
}

.result-favicon-empty {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 2px;
  background: var(--bt-layer-2);
  color: var(--bt-ink-3);
  font-size: 10px;
  line-height: 1;
}

.result-site {
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-date {
  flex: none;
}

.result-tag {
  flex: none;
  padding: 0 6px;
  border: 0.5px solid var(--bt-rule);
  border-radius: 2px;
  color: var(--bt-ink-2);
  font-size: var(--bt-fs-meta);
  line-height: 16px;
}

.result-title {
  display: -webkit-box;
  overflow: hidden;
  color: var(--bt-seal);
  font-weight: 500;
  line-height: 1.45;
  text-decoration: none;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

@media (hover: hover) {
  .result-title:hover {
    text-decoration: underline dotted;
    text-underline-offset: 3px;
  }
}

/* The snippet is never clipped: two lines is the floor, and a longer summary
   grows the row instead of hiding its tail behind an ellipsis. */
.result-snippet {
  margin: 0;
  min-height: 3.2em;
  color: var(--bt-ink-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.result-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.link-button {
  height: 26px;
  padding: 0 10px;
  border: 0.5px solid var(--bt-rule-strong);
  border-radius: var(--bt-radius-sm);
  background: transparent;
  color: var(--bt-ink-2);
  font: inherit;
  font-size: 13px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.link-button:hover {
  border-color: var(--bt-seal);
  color: var(--bt-seal);
}

/* ------------------------------------------------------------------- pager */

/* The pager sits outside the scrolling list, so the scrollbar covers only the
   results and the pager never moves when the list is scrolled. */
.pager {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px 16px;
  border-top: var(--bt-hairline) solid var(--bt-rule);
  background: var(--bt-paper);
  color: var(--bt-ink-2);
  font-size: 13px;
}

.pager[hidden] {
  display: none;
}

.pager-step {
  height: 28px;
  padding: 0 12px;
  border: var(--bt-hairline) solid var(--bt-rule-strong);
  border-radius: var(--bt-radius-sm);
  background: transparent;
  color: var(--bt-ink);
  font: inherit;
  font-size: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

@media (hover: hover) {
  .pager-step:hover:not(:disabled) {
    border-color: var(--bt-seal);
    color: var(--bt-seal);
  }
}

.pager-step:disabled {
  border-color: var(--bt-rule-faint);
  color: var(--bt-ink-3);
  cursor: default;
}

.pager-info {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  justify-content: center;
  text-align: center;
}

.pager-page {
  color: var(--bt-ink);
}

.pager-range {
  color: var(--bt-ink-3);
  font-size: var(--bt-fs-meta);
}

/* ------------------------------------------------------- empty / error / load */

.placeholder {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 32px 24px;
  text-align: center;
  color: var(--bt-ink-3);
}

.placeholder-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0.5px solid var(--bt-rule-faint);
  border-radius: 4px;
  color: var(--bt-ink-3);
}

.placeholder-title {
  margin: 0;
  color: var(--bt-ink);
  font-weight: 500;
}

.placeholder-hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.notice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin: 12px;
  padding: 10px 12px;
  border: 0.5px solid var(--bt-rule);
  border-radius: 4px;
}

.notice-text {
  margin: 0;
  color: var(--bt-seal);
  font-size: 13px;
  line-height: 1.5;
}

.notice-detail {
  margin: 0;
  color: var(--bt-ink-3);
  font-size: var(--bt-fs-meta);
  word-break: break-all;
}

.skeleton {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 12px;
}

.skeleton-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.skeleton-line {
  height: 10px;
  border-radius: 2px;
  background: var(--bt-layer-2);
  animation: pulse 1.4s ease-in-out infinite;
}

.skeleton-meta {
  width: 38%;
}

.skeleton-title {
  width: 78%;
  height: 14px;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-line {
    animation: none;
  }
}

/* ----------------------------------------------------------------- doc view */

.doc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 0.5px solid var(--bt-rule);
  color: var(--bt-ink-3);
  font-size: 13px;
}

.doc-url {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 14px 24px;
}

.doc-hint {
  padding: 6px 12px;
  color: var(--bt-warn);
  font-size: 13px;
}

/* --------------------------------------------------------------- markdown */

.md {
  max-width: 72ch;
  color: var(--bt-ink);
  word-break: break-word;
}

.md h1,
.md h2,
.md h3,
.md h4,
.md h5,
.md h6 {
  margin: 18px 0 8px;
  font-family: var(--bt-font-serif);
  font-weight: 700;
  line-height: 1.35;
}

.md h1 {
  font-size: 24px;
}

.md h2 {
  font-size: 20px;
}

.md h3 {
  font-size: 17px;
}

.md h4,
.md h5,
.md h6 {
  font-size: 15px;
}

.md p {
  margin: 0 0 10px;
}

.md a {
  color: var(--bt-seal);
  text-underline-offset: 2px;
}

.md code {
  padding: 1px 4px;
  border-radius: 2px;
  background: var(--bt-layer-2);
  font-family: var(--bt-font-mono);
  font-size: 0.92em;
}

.md pre {
  margin: 0 0 12px;
  padding: 10px 12px;
  overflow-x: auto;
  border: 0.5px solid var(--bt-rule);
  border-radius: var(--bt-radius-panel);
  background: var(--bt-layer-2);
}

.md pre code {
  padding: 0;
  background: transparent;
  font-size: 12.5px;
  line-height: 1.55;
}

.md ul,
.md ol {
  margin: 0 0 10px;
  padding-left: 22px;
}

.md li {
  margin: 0 0 4px;
}

.md blockquote {
  margin: 0 0 12px;
  padding: 2px 0 2px 12px;
  border-left: 2px solid var(--bt-rule-strong);
  color: var(--bt-ink-2);
}

.md hr {
  height: 1px;
  margin: 16px 0;
  border: 0;
  background: var(--bt-rule);
}

.md img {
  max-width: 100%;
  height: auto;
}

.md table {
  width: 100%;
  margin: 0 0 12px;
  border-collapse: collapse;
  font-size: 13px;
}

.md th,
.md td {
  padding: 6px 8px;
  border: 0.5px solid var(--bt-rule);
  text-align: left;
}

.md th {
  background: var(--bt-layer-2);
  font-weight: 600;
}

/* ------------------------------------------------------------------ narrow */

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

  .hero-stack {
    padding-bottom: 24px;
  }

  .card textarea {
    height: 80px;
    min-height: 80px;
    max-height: 80px;
  }
}
