/* CrowdPublishing — prototype styles.
   Sans for the machinery, serif for anything that is manuscript. */

:root {
  --ink: #1a1816;
  --ink-2: #5c564f;
  --ink-3: #8b847b;
  --paper: #fbf9f6;
  --card: #ffffff;
  --line: #e2ddd5;
  --line-2: #cfc8bd;
  --accent: #8a3324;
  --accent-soft: #f6ece9;
  --good: #2f6b45;
  --warn: #9a6a12;
  --bad: #9c2d2d;
  --radius: 6px;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: Iowan Old Style, "Palatino Linotype", Palatino, Georgia, serif;
  --shadow: 0 1px 2px rgba(26,24,22,.06), 0 4px 12px rgba(26,24,22,.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ece7e0; --ink-2: #b4aba0; --ink-3: #8a8178;
    --paper: #16151a; --card: #1e1d23; --line: #322f38; --line-2: #45414c;
    --accent: #e0775f; --accent-soft: #2b211f;
    --good: #6fbd8c; --warn: #d7a74a; --bad: #e07b7b;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper); color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5rem; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; background: var(--accent-soft); padding: .1em .3em; border-radius: 3px; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1.25rem;
  padding: .7rem 1.25rem; background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { font-weight: 700; letter-spacing: -.02em; color: var(--ink); font-size: 1.05rem; }
.topbar .brand span { color: var(--accent); }
.topbar nav { display: flex; gap: 1rem; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: var(--ink-2); font-weight: 500; }
.topbar nav a.on { color: var(--ink); border-bottom: 2px solid var(--accent); }
.topbar .who { color: var(--ink-3); font-size: .85rem; display: flex; align-items: center; gap: .6rem; }

.wrap { max-width: 1060px; margin: 0 auto; padding: 1.5rem 1.25rem 5rem; }
.wrap.narrow { max-width: 760px; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.cols { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 820px) { .cols { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card.tight { padding: .75rem .9rem; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.error { color: var(--bad); }
.ok { color: var(--good); }

/* ---------- controls ---------- */
.btn {
  display: inline-block; font: inherit; font-weight: 500;
  padding: .45rem .85rem; border-radius: var(--radius);
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn.sm { padding: .25rem .55rem; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
input, textarea, select {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: .45rem .6rem; width: 100%;
}
textarea { min-height: 9rem; resize: vertical; }
textarea.manuscript { font: 16px/1.7 var(--serif); min-height: 22rem; }
label { display: block; margin-bottom: .7rem; font-size: .85rem; color: var(--ink-2); font-weight: 500; }
label input, label textarea, label select { margin-top: .25rem; }
label.inline { display: flex; align-items: center; gap: .5rem; }
label.inline input { width: auto; margin: 0; }
.field-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.field-row > label { flex: 1; min-width: 12rem; }

/* ---------- bits ---------- */
.tag {
  display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .02em;
  text-transform: uppercase; padding: .15rem .4rem; border-radius: 3px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid transparent;
}
.tag.grey { background: transparent; color: var(--ink-3); border-color: var(--line); }
.tag.good { background: transparent; color: var(--good); border-color: currentColor; }
.tag.warn { background: transparent; color: var(--warn); border-color: currentColor; }
.tag.bad { background: transparent; color: var(--bad); border-color: currentColor; }

.bar { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }

.stats { display: flex; gap: 1.5rem; flex-wrap: wrap; margin: .5rem 0 0; }
.stats div { min-width: 5rem; }
.stats b { display: block; font-size: 1.35rem; font-weight: 600; letter-spacing: -.02em; }
.stats span { font-size: .78rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .03em; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list .meta { font-size: .82rem; color: var(--ink-3); }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.1rem; flex-wrap: wrap; }
.tabs a {
  padding: .5rem .8rem; color: var(--ink-2); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- outline ---------- */
.outline { list-style: none; margin: 0; padding: 0; }
.outline li {
  display: flex; align-items: baseline; gap: .6rem;
  padding: .5rem .25rem; border-bottom: 1px solid var(--line);
}
.outline li.d1 { padding-left: 1.5rem; }
.outline li.d2 { padding-left: 3rem; }
.outline .t { flex: 1; font-weight: 500; }
.outline .t small { display: block; font-weight: 400; color: var(--ink-3); }
.outline li.part { background: transparent; }
.outline li.part .t { font-weight: 600; letter-spacing: -.01em; }

/* ---------- manuscript and diff ---------- */
.prose { font: 17px/1.7 var(--serif); }
.prose h1, .prose h2, .prose h3 { font-family: var(--sans); margin-top: 1.5rem; }
.prose blockquote { margin: 0 0 1rem; padding-left: 1rem; border-left: 3px solid var(--line-2); color: var(--ink-2); }

.diff { font: 15px/1.7 var(--serif); white-space: pre-wrap; word-wrap: break-word; }
.d-ins { background: rgba(47,107,69,.16); text-decoration: none; }
.d-del { background: rgba(156,45,45,.16); text-decoration: line-through; opacity: .75; }

/* ---------- findings ---------- */
.finding { border-left: 3px solid var(--line-2); padding: .5rem 0 .5rem .75rem; margin-bottom: .75rem; }
.finding.blocker, .finding.major { border-left-color: var(--bad); }
.finding.minor { border-left-color: var(--warn); }
.finding.info { border-left-color: var(--line-2); }
.finding .anchor { font-family: var(--serif); font-style: italic; color: var(--ink-2); }

/* ---------- installer and auth ---------- */
body.install { display: grid; place-items: start center; padding: 3rem 1rem; }
body.install .card { max-width: 32rem; width: 100%; }
.checks { list-style: none; padding: 0; margin: 0 0 1rem; }
.checks li { padding: .3rem 0; border-bottom: 1px solid var(--line); }
.checks li::before { content: "✓ "; color: var(--good); font-weight: 700; }
.checks li.bad::before { content: "✗ "; color: var(--bad); }

.auth { max-width: 24rem; margin: 3rem auto; }
.notice { padding: .6rem .8rem; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); margin-bottom: 1rem; font-size: .9rem; }
.spinner { color: var(--ink-3); padding: 3rem 0; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: .6rem 1rem;
  border-radius: var(--radius); z-index: 50; box-shadow: var(--shadow); font-size: .9rem;
}
