:root {
  --bg: #f3eee4;
  --paper: #fffdf8;
  --ink: #1c1814;
  --muted: #6b6258;
  --line: #d8cfc0;
  --rust: #9a3412;
  --rust-2: #c2410c;
  --green: #3f6212;
  --red: #9f1239;
  --amber: #92400e;
  --blue: #1e3a5f;
  --shadow: 0 1px 0 rgba(28, 24, 20, 0.06), 0 8px 24px rgba(28, 24, 20, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  min-height: 100vh;
}
code, .num, .pill, .mode, button, input, .mark, nav a, .actions {
  font-family: ui-sans-serif, system-ui, "Segoe UI", sans-serif;
}

.top {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 10;
}
.mark {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  color: var(--rust);
  text-decoration: none;
  font-size: 1.15rem;
}
.top nav { display: flex; gap: 1rem; flex: 1; }
.top nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
}
.top nav a[aria-current="page"], .top nav a:hover { color: var(--ink); }
.mode {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

main { max-width: 960px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }

h1 { font-size: 2rem; font-weight: 600; margin: 0 0 0.3rem; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; margin: 0 0 0.4rem; }
.lede { margin: 0; color: var(--muted); max-width: 40rem; }
.muted { color: var(--muted); font-size: 0.92rem; }
.empty { color: var(--muted); font-style: italic; padding: 1.5rem 0; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.crumbs { font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.8rem; }
.crumbs a { color: var(--rust); text-decoration: none; }
.crumbs span { margin: 0 0.35rem; }

.btn, button, .create button {
  font-family: ui-sans-serif, system-ui, sans-serif;
  background: var(--ink);
  color: var(--paper);
  border: 0;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.88rem;
  display: inline-block;
}
.btn:hover, button:hover { background: var(--rust); }
button.danger, .danger { background: var(--red); color: #fff; }
.linkish { color: var(--rust); cursor: pointer; text-decoration: underline; }

.create, .danger-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: end;
  margin: 1rem 0 1.5rem;
  padding: 1rem;
  background: var(--paper);
  border: 1px solid var(--line);
}
.create label, .danger-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.8rem; color: var(--muted); }
.create input, .danger-form input, .search-form input[type="search"] {
  font: inherit;
  font-family: ui-sans-serif, system-ui, sans-serif;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  min-width: 16rem;
}

.cards { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.9rem; }
.card {
  display: block;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 1rem 1.1rem 0.9rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  min-height: 9rem;
}
.card:hover { border-color: var(--ink); }
.card h2 { margin-bottom: 0.25rem; }
.card dl {
  display: flex;
  gap: 1rem;
  margin: 0.9rem 0 0;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.78rem;
}
.card dt { color: var(--muted); font-weight: 400; }
.card dd { margin: 0; font-variant-numeric: tabular-nums; }

.panel { background: var(--paper); border: 1px solid var(--line); padding: 0.6rem 1rem 0.2rem; margin-bottom: 1.25rem; }
.panel summary { cursor: pointer; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.9rem; padding: 0.4rem 0; }

.drop {
  border: 1.5px dashed var(--line);
  background: var(--paper);
  padding: 1.4rem 1.2rem;
  text-align: center;
  margin-bottom: 1.25rem;
}
.drop.drag { border-color: var(--rust); background: #fff7ed; }
.queue { list-style: none; padding: 0; margin: 0.8rem 0 0; text-align: left; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.85rem; }
.queue li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.25rem 0; border-top: 1px solid var(--line); }

table.docs { width: 100%; border-collapse: collapse; background: var(--paper); font-size: 0.92rem; }
table.docs th, table.docs td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.docs th {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
table.docs a { color: var(--ink); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.err { color: var(--red); font-size: 0.8rem; margin-top: 0.2rem; max-width: 28rem; }
.actions { white-space: nowrap; }
.actions button { padding: 0.25rem 0.5rem; font-size: 0.75rem; margin-left: 0.25rem; }

.pill {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  background: #faf7f2;
}
.pill[data-status="indexed"] { color: var(--green); border-color: #a3b18a; }
.pill[data-status="failed"] { color: var(--red); border-color: #e11d48; }
.pill[data-status="extracting"],
.pill[data-status="indexing"],
.pill[data-status="uploading"] { color: var(--amber); }

.search-form { margin-bottom: 1.25rem; }
.search-form input[type="search"] {
  width: 100%;
  font-size: 1.15rem;
  padding: 0.65rem 0.75rem;
  min-width: 0;
}
.search-form.compact input[type="search"] { font-size: 1rem; }
.mode, .scope {
  border: 0;
  padding: 0.6rem 0 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.85rem;
}
.scope legend { padding: 0; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); width: 100%; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.results { display: flex; flex-direction: column; gap: 0.7rem; }
.hit {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
}
.hit header { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.hit h3 { margin: 0; font-size: 1.05rem; }
.hit .meta { font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.75rem; color: var(--muted); }
.hit .heading { color: var(--muted); font-size: 0.9rem; margin: 0.15rem 0 0.4rem; }
.hit .snippet { margin: 0; font-size: 0.95rem; }
.hit mark { background: #fde68a; color: inherit; padding: 0 0.1em; }
.hit a { color: var(--rust); }
.banner { padding: 0.7rem 0.9rem; border: 1px solid var(--red); color: var(--red); background: #fff; }
.home-search { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }

@media (max-width: 640px) {
  .page-head { flex-direction: column; }
  table.docs { font-size: 0.82rem; }
  .create input { min-width: 0; width: 100%; }
}
