:root {
  --bg: #f4f5f2; --panel: #fff; --ink: #1b1b1a; --muted: #6b6b66;
  --line: #ddded9; --accent: #2f6f4f; --accent-ink: #fff; --warn: #8a5a00;
  --band-a: #d94b3f; --band-b: #e8a13a; --band-c: #3f7fd9; --band-d: #7a4fd9;
  --pattern: rgba(20, 40, 30, .045);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a; --panel: #1e2126; --ink: #e9e9e6; --muted: #9a9a95;
    --line: #2e323a; --accent: #4f9d74; --accent-ink: #0b0f0d; --warn: #d9a441;
    --band-a: #e0655a; --band-b: #eab45c; --band-c: #5e95e0; --band-d: #9a74e0;
    --pattern: rgba(180, 220, 200, .05);
  }
}
* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  background-color: var(--bg);
  /* A card-back lattice: two diagonal grids offset from each other, drawn in a
     single tint so it reads as texture rather than decoration. */
  background-image:
    repeating-linear-gradient(60deg, var(--pattern) 0 1px, transparent 1px 22px),
    repeating-linear-gradient(-60deg, var(--pattern) 0 1px, transparent 1px 22px);
  background-attachment: fixed;
}

.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px 72px; }
a { color: var(--accent); }
h1 { font-size: 21px; margin: 0 0 4px; }
p.lede { margin: 0 0 26px; color: var(--muted); }

/* Banner ------------------------------------------------------------------ */

.banner {
  position: relative;
  margin: 0 0 26px;
  padding: 26px 22px 24px;
  border-radius: 14px;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(115deg, #17332a 0%, #22513c 45%, #2f6f4f 100%);
  border: 1px solid rgba(255, 255, 255, .08);
}
.banner::after {
  /* Type-colour ribbon along the bottom edge. */
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: linear-gradient(90deg,
    var(--band-a) 0 25%, var(--band-b) 25% 50%,
    var(--band-c) 50% 75%, var(--band-d) 75% 100%);
}
.banner .orb {
  position: absolute; right: -46px; top: -46px;
  width: 190px; height: 190px; opacity: .5; pointer-events: none;
}
.banner h1, .banner p { position: relative; margin: 0; }
.banner h1 { font-size: 24px; letter-spacing: -.01em; }
.banner p { margin-top: 6px; color: rgba(255, 255, 255, .78); font-size: 14px; max-width: 46ch; }
.banner .crumb {
  position: relative; display: inline-block; margin-bottom: 10px;
  font-size: 12px; color: rgba(255, 255, 255, .72); text-decoration: none;
}
.banner .crumb:hover { color: #fff; }

/* Panels ------------------------------------------------------------------ */

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px; margin-bottom: 16px;
}
h2 { font-size: 14px; margin: 0 0 8px; }
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
textarea, input[type=number] {
  width: 100%; background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; padding: 10px;
  font: 13px/1.6 ui-monospace, "SF Mono", Consolas, monospace;
}
textarea { min-height: 86px; resize: vertical; }
.opts {
  display: flex; flex-wrap: wrap; gap: 14px 22px; margin-top: 14px;
  font-size: 13px; align-items: center;
}
.opts label { font-weight: 400; margin: 0; display: flex; align-items: center; gap: 6px; }
.opts input[type=number] { width: 68px; padding: 4px 6px; }
.row { display: flex; gap: 10px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
button {
  background: var(--accent); color: var(--accent-ink); border: 0;
  border-radius: 6px; padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
}
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button[disabled] { opacity: .55; cursor: default; }
.status { font-size: 13px; color: var(--muted); }
.status.err { color: #c0392b; }
.note { font-size: 13px; color: var(--warn); margin-top: 10px; }
.stats, .sources { font-size: 13px; color: var(--muted); margin-top: 9px; }
.sources a { color: inherit; }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.hint code {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 4px; font-size: 11px;
}

/* Want list chunks -------------------------------------------------------- */

.chunk { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; overflow: hidden; }
.chunk > header {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.chunk h3 { margin: 0; font-size: 13px; }
.chunk .meta { font-size: 12px; color: var(--muted); flex: 1; }
.chunk textarea { border: 0; border-radius: 0; min-height: 260px; background: var(--panel); }
.chunk .acts { display: flex; gap: 8px; padding: 10px 12px; background: var(--panel); }
.chunk button { padding: 6px 12px; font-size: 13px; }

/* Earlier queries --------------------------------------------------------- */

.hist {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 9px 0; border-top: 1px solid var(--line);
}
.hist:first-child { border-top: 0; }
.hist-label { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 1px; }
.hist-label strong { font-size: 13px; font-weight: 600; }
.hist-label .meta { font-size: 12px; color: var(--muted); }
.hist-label .meta.stale { color: var(--warn); }
.hist-acts { display: flex; gap: 6px; }
.hist-acts button { padding: 5px 10px; font-size: 12px; }

/* Tiles ------------------------------------------------------------------- */

.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.tile {
  display: block; text-decoration: none; color: inherit;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px; transition: border-color .15s, transform .15s;
}
.tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.tile img { width: 34px; height: 34px; display: block; margin-bottom: 12px; }
.tile h2 { font-size: 15px; margin: 0 0 4px; }
.tile p { margin: 0; font-size: 13px; color: var(--muted); }
footer { margin-top: 36px; font-size: 12px; color: var(--muted); }

@media (max-width: 520px) {
  .banner { padding: 20px 16px 18px; }
  .banner h1 { font-size: 20px; }
  .banner .orb { display: none; }
}
