/* ── reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── tokens ───────────────────────────────────────────────────────────────── */
:root {
  --ff: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
  --fs: 13px;
  --lh: 1.55;
  --fg: #111;
  --bg: #fff;
  --dim: #9a9a9a;
  --rule: #e6e6e6;   /* hairline row dividers */
  --rule-2: #111;    /* strong section dividers */
  --hover: #f6f6f6;
  --pad: 1.5rem;
}

/* ── base ─────────────────────────────────────────────────────────────────── */
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--ff);
  font-size: var(--fs);
  line-height: var(--lh);
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
mark { background: var(--fg); color: var(--bg); }

/* uppercase micro-labels — the backbone of the table aesthetic */
.field-label, .group-label, .t-head, .wiki-section-hd, .wiki-gloss-cat-hd, #nav a, .wiki-toc a, .logo, .entry-actions a, button {
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ── header ───────────────────────────────────────────────────────────────── */
#header {
  position: sticky; top: 0; z-index: 50; background: var(--bg);
  border-bottom: 1px solid var(--rule-2);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.7rem var(--pad);
}
.logo { font-weight: 700; letter-spacing: 0.16em; white-space: nowrap; }
.bg-status {
  color: var(--dim); font-size: 0.74rem; letter-spacing: 0.04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 38vw; flex: 0 1 auto; animation: pulse 1.4s ease-in-out infinite;
}
.bg-status:empty { animation: none; }
#nav { display: flex; gap: 1.4rem; flex-wrap: wrap; justify-content: flex-end; }
#nav a { font-size: 0.82rem; color: var(--dim); white-space: nowrap; }
#nav a:hover { color: var(--fg); text-decoration: none; }
#nav a.active { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }

#main { padding: var(--pad); }
#view { width: 100%; }

/* ── interactive ──────────────────────────────────────────────────────────── */
button, input, textarea, select {
  font-family: var(--ff); font-size: var(--fs); line-height: var(--lh);
  color: var(--fg); background: var(--bg); border: 1px solid var(--rule-2);
  -webkit-appearance: none; appearance: none; border-radius: 0; outline: none;
}
button {
  padding: 0.3rem 0.9rem; cursor: pointer; min-height: 2.1rem;
  background: var(--fg); color: var(--bg); border-color: var(--fg);
  font-size: 0.8rem; display: inline-flex; align-items: center;
}
button:hover { opacity: 0.72; }
button:disabled { opacity: 0.35; cursor: default; }
button.sec { background: var(--bg); color: var(--fg); }
input, textarea { padding: 0.4rem 0.55rem; width: 100%; }
textarea { resize: vertical; min-height: 8rem; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--fg); outline-offset: -2px; }
input[type="file"] { border: none; padding: 0; cursor: pointer; }
select { padding: 0.4rem 0.55rem; width: 100%; cursor: pointer; }

/* ── shared table header row ──────────────────────────────────────────────── */
.t-head {
  display: grid; gap: 1rem; padding: 0.45rem 0;
  border-bottom: 1px solid var(--rule-2);
  font-size: 0.74rem; color: var(--dim);
}
.t-head span { white-space: nowrap; }

/* ── entries table ────────────────────────────────────────────────────────── */
.entry, .t-head.t-entries {
  display: grid; grid-template-columns: 2.5rem 7rem 8.5rem 6.5rem 1fr; gap: 1rem;
}
.entry { padding: 0.85rem 0; border-bottom: 1px solid var(--rule); align-items: start; }
.entry:hover { background: var(--hover); }
.entry-idx { color: var(--dim); font-variant-numeric: tabular-nums; }
.entry-when, .entry-context, .entry-project { display: grid; gap: 0.15rem; min-width: 0; word-break: break-word; }
.entry-context, .entry-project { color: var(--dim); }
.entry-context .m-ctx { color: var(--fg); }
.m-date { font-variant-numeric: tabular-nums; }
.m-sub { color: var(--dim); font-size: 0.86rem; word-break: break-word; }
.entry-main { display: grid; gap: 0.45rem; min-width: 0; }
.entry-title { font-weight: 700; }
.entry-body { white-space: pre-wrap; word-break: break-word; }
.entry-imgs { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.entry-imgs img { width: 110px; height: 82px; object-fit: cover; border: 1px solid var(--rule-2); cursor: pointer; }
.entry-ai { color: var(--dim); }
.entry-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.tags { display: flex; flex-wrap: wrap; gap: 0.2rem 0.7rem; }
.tag { color: var(--dim); }
.tag::before { content: '#'; }
.entry-actions { display: flex; gap: 0.85rem; opacity: 0; transition: opacity 0.12s; }
.entry:hover .entry-actions { opacity: 1; }
.entry-actions a { color: var(--dim); font-size: 0.74rem; }
.entry-actions a:hover { color: var(--fg); }
@media (hover: none) { .entry-actions { opacity: 1; } }

/* ── forms ────────────────────────────────────────────────────────────────── */
.form { display: grid; gap: 1.2rem; max-width: 62rem; }
.field { display: grid; gap: 0.3rem; }
.field-label, .group-label { font-size: 0.74rem; color: var(--dim); }
.hint { color: var(--dim); font-size: 0.82rem; }
.row { display: flex; gap: 0.9rem; flex-wrap: wrap; }
.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
#rec-btn.live { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
#rec-status, #form-msg, #cfg-msg, #rebuild-msg { color: var(--dim); }
#imgs-preview { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.3rem; }
#imgs-preview img { width: 84px; height: 64px; object-fit: cover; border: 1px solid var(--rule-2); }

/* ── wiki ─────────────────────────────────────────────────────────────────── */
.wiki-hd {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap;
  padding-bottom: 0.7rem; border-bottom: 1px solid var(--rule-2); margin-bottom: 1rem;
}
.wiki-toc { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; }
.wiki-toc a { font-size: 0.82rem; color: var(--dim); }
.wiki-toc a:hover { color: var(--fg); text-decoration: none; }
.wiki-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
#wiki-msg { color: var(--dim); padding: 0.3rem 0; min-height: 1.4rem; }

.wiki-section { margin-bottom: 2rem; }
.wiki-section-hd { font-size: 0.74rem; color: var(--dim); padding-bottom: 0.4rem; border-bottom: 1px solid var(--rule-2); margin-bottom: 0.4rem; }

/* activity report — prose */
.wiki-article { padding: 0.6rem 0; }
.wiki-article p { margin-bottom: 0.6rem; max-width: 62rem; }
.wiki-head { font-weight: 700; }
.wiki-xref { color: var(--dim); }
.wiki-xref a { color: var(--dim); }
.wiki-xref a:hover { color: var(--fg); }

/* events — the prominent list (bigger than the rest) */
.wiki-event { padding: 1rem 0; border-bottom: 1px solid var(--rule); }
.wiki-event:hover { background: var(--hover); }
.wiki-event-top { display: flex; align-items: baseline; gap: 0.9rem; flex-wrap: wrap; }
.wiki-event-date { color: var(--dim); font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.wiki-event-name { font-size: 1.55rem; font-weight: 700; line-height: 1.2; }
.wiki-event-fmt {
  color: var(--dim); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
  border: 1px solid var(--rule); padding: 0.05rem 0.45rem; align-self: center;
}
.wiki-event-visitors { color: var(--dim); font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.wiki-event-sum { margin-top: 0.45rem; max-width: 60rem; }

/* reach · visitors */
.reach-total { margin-bottom: 0.6rem; }
.reach-row, .t-head.t-reach { display: grid; grid-template-columns: 1fr 9rem; gap: 1rem; align-items: baseline; }
.reach-row { padding: 0.4rem 0; border-bottom: 1px solid var(--rule); }
.reach-row:hover { background: var(--hover); }
.reach-name { font-weight: 700; }
.reach-num { text-align: right; font-variant-numeric: tabular-nums; }
.reach-missing { color: var(--dim); }
@media (max-width: 720px) { .reach-row, .t-head.t-reach { grid-template-columns: 1fr auto; } }
.wiki-event-rel { margin-top: 0.5rem; color: var(--dim); font-size: 0.85rem; }
.wiki-event-rel a { color: var(--dim); }
.wiki-event-rel a:hover { color: var(--fg); }
.wiki-event-feeds { margin-top: 0.25rem; color: var(--dim); font-size: 0.85rem; }
.wiki-event-feeds a { color: var(--dim); }
.wiki-event-feeds a:hover { color: var(--fg); }

/* projects table */
.wiki-prj-row, .t-head.t-prj {
  display: grid; grid-template-columns: minmax(9rem, 14rem) 1fr; gap: 1rem; align-items: baseline;
}
.wiki-prj-row { padding: 0.6rem 0; border-bottom: 1px solid var(--rule); }
.wiki-prj-row:hover { background: var(--hover); }
.wiki-prj-name { font-weight: 700; }
.wiki-prj-body p { max-width: 62rem; }

/* glossary table */
.wiki-gloss-cat { margin-top: 0.6rem; }
.wiki-gloss-cat-hd { font-size: 0.74rem; color: var(--dim); padding: 0.45rem 0 0.25rem; }
.wiki-gloss-row, .t-head.t-gloss {
  display: grid; grid-template-columns: minmax(9rem, 16rem) 1fr; gap: 1rem; align-items: baseline;
}
.wiki-gloss-row { padding: 0.45rem 0; border-bottom: 1px solid var(--rule); }
.wiki-gloss-row:hover { background: var(--hover); }
.wiki-gloss-term { font-weight: 700; }

/* ── search ───────────────────────────────────────────────────────────────── */
.search-bar { border-bottom: 1px solid var(--rule-2); padding-bottom: 0.5rem; margin-bottom: 1rem; }
.search-bar input { border: none; padding-left: 0; font-size: 1.15rem; }
.search-bar input:focus { outline: none; }
.s-row { padding: 0.7rem 0; border-bottom: 1px solid var(--rule); display: grid; gap: 0.3rem; }
.s-row:hover { background: var(--hover); }
.s-meta { color: var(--dim); font-variant-numeric: tabular-nums; }
.entry-snip { white-space: pre-wrap; word-break: break-word; }

/* ── settings ─────────────────────────────────────────────────────────────── */
.settings-group { margin-top: 1.2rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); display: grid; gap: 0.5rem; max-width: 42rem; }
.group-label { font-size: 0.74rem; color: var(--dim); }
.progress-bar { width: 100%; height: 2px; background: var(--rule); margin-top: 0.3rem; }
.progress-fill { height: 100%; background: var(--fg); width: 0; transition: width 0.3s ease; }

/* ── overlay ──────────────────────────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.92); display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 200; }
.overlay img { max-width: 95dvw; max-height: 95dvh; object-fit: contain; }

/* ── misc ─────────────────────────────────────────────────────────────────── */
.empty, .status-line { color: var(--dim); padding: 1.25rem 0; }

/* ── responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .t-head { display: none; }
  .entry { display: block; }
  .entry-idx { display: inline; margin-right: 0.6rem; }
  .entry-when { display: inline-block; }
  .entry-context, .entry-project { display: block; margin-top: 0.15rem; }
  .entry-main { margin-top: 0.4rem; }
  .wiki-prj-row, .wiki-gloss-row { grid-template-columns: 1fr; gap: 0.15rem; }
}
