/* showme — "Galley" review interface.
   The document is a typeset proof sheet on an editor's desk: serif body on a
   white sheet, gray-green desk behind it, proofreader's red pencil for every
   annotation affordance. Chrome and meta are letterspaced uppercase mono.
   Notes sit in the sheet's right margin on wide screens (grid; see .md-block)
   and inline under their block on narrow ones. */

:root {
  --desk: #e7e8e1;
  --sheet: #ffffff;
  --ink: #26251f;
  --ink-soft: #3d3c34;
  --muted: #6e6c61;
  --faded: #8b8a7c;
  --pencil: #b3372e;
  --pencil-press: #96291f;
  --rule: #e3e2d9;        /* hairlines on the sheet */
  --desk-rule: #c9cabf;   /* hairlines on the desk */
  --paper-code: #f4f3ee;
  --paper-inline: #f2f1ea;
  --serif: Charter, "Iowan Old Style", "Palatino", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sheet-shadow: 0 1px 2px rgba(38, 37, 31, 0.1), 0 12px 32px rgba(38, 37, 31, 0.1);
  --margin-w: 232px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--serif);
  font-size: 15.5px;
  line-height: 1.68;
  color: var(--ink);
  background: var(--desk);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--pencil); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Chrome and meta share one voice: small letterspaced uppercase mono. */
.crumbs, .page-sub, .project-meta, .filehead, .note-meta,
.btn, .btn-primary, .stale-badge {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.13em;
}

.wrap { max-width: 1048px; margin: 0 auto; padding: 0 20px; }

/* ---- top bar: sits directly on the desk ---- */

.topbar .wrap {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding-top: 18px;
  padding-bottom: 10px;
}
.brand {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
}
.brand::after { content: "·"; color: var(--pencil); margin-left: 9px; font-style: normal; }
.brand:hover { text-decoration: none; color: var(--pencil); }
.crumbs { font-size: 11px; color: var(--faded); min-width: 0; text-transform: none; }
.crumbs a { color: var(--muted); border-bottom: 1px solid var(--desk-rule); }
.crumbs a:hover { color: var(--pencil); border-bottom-color: var(--pencil); text-decoration: none; }
.crumbs .sep { margin: 0 5px; color: var(--desk-rule); }

main.wrap { padding-top: 16px; padding-bottom: 72px; }

.page-title { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 2px; }
.page-sub { color: var(--faded); font-size: 11px; margin: 0 0 22px; }
.page-sub code { font-family: var(--mono); font-size: inherit; }

/* ---- sheets: home / project tree / notices lie on the desk as pages ---- */

.sheet {
  background: var(--sheet);
  box-shadow: var(--sheet-shadow);
  max-width: 760px;
  margin: 8px auto 0;
  padding: 44px 52px 48px;
}
.sheet > .empty { margin-top: 0; }

/* ---- home: project list ---- */

.project-list { list-style: none; margin: 0; padding: 0; }
.project-list li { padding: 14px 0 15px; border-top: 1px solid var(--rule); }
.project-name { font-size: 18px; font-weight: 700; color: var(--ink); }
.project-name:hover { color: var(--pencil); text-decoration: none; }
.project-meta {
  display: block;
  margin-top: 3px;
  color: var(--faded);
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}
.project-meta code { font-family: var(--mono); font-size: inherit; }

.empty {
  margin-top: 32px;
  padding: 44px 24px;
  text-align: center;
  font-style: italic;
  color: var(--muted);
  border: 1px dashed var(--desk-rule);
}
.empty code {
  font-family: var(--mono);
  font-style: normal;
  background: var(--paper-inline);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 13px;
}

/* ---- project tree: the snapshot manifest ----
   Filenames speak in the chrome's mono voice; each directory's children hang
   off a hairline guide, markdown files carry the red asterisk. */

.tree {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  border-top: 1px solid var(--rule);
  padding-top: 14px;
}
.tree details > details, .tree details > .tree-file {
  margin-left: 13px;
  border-left: 1px solid var(--rule);
}
.tree details > details { padding-left: 12px; }
/* Files indent 12px (guide) + 21px (marker width) so their names line up
   with sibling directory names, not with the carets. */
.tree details > .tree-file { padding-left: 33px; }
.tree summary {
  cursor: pointer;
  padding: 3px 8px 3px 6px;
  font-weight: 700;
  color: var(--ink);
  list-style: none;
}
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before {
  content: "\25B8";
  display: inline-block;
  width: 15px;
  color: var(--pencil);
  transition: transform 0.12s;
}
.tree details[open] > summary::before { transform: rotate(90deg); }
.tree summary:hover { background: var(--paper-code); }
.tree-file { display: block; padding: 3px 8px 3px 21px; color: var(--muted); }
.tree-file:hover { background: var(--paper-code); color: var(--pencil); text-decoration: none; }
.tree-file.is-md { color: var(--ink); }
.tree-file.is-md::after { content: " *"; color: var(--pencil); }

/* ---- file box: the proof sheet ---- */

.filebox {
  background: var(--sheet);
  box-shadow: var(--sheet-shadow);
  margin-top: 8px;
}
.filehead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 30px 48px 12px 56px;
  border-bottom: 1px solid var(--rule);
  font-size: 10.5px;
  color: var(--faded);
}
.filename { font-weight: 400; word-break: break-all; }
.filehead-actions { white-space: nowrap; }
.filehead-actions a { margin-left: 16px; color: var(--pencil); }
.filehead-actions a:hover { color: var(--pencil-press); }
.filebody { padding: 34px 48px 56px 56px; overflow-x: auto; }
.filebody.codebody, .filebody.framebody { padding: 0; }

/* ---- code view: a typeset listing ---- */

pre.code {
  margin: 0;
  padding: 18px 0;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  overflow-x: auto;
}
pre.code .line { display: block; padding: 0 24px 0 16px; }
pre.code .ln {
  display: inline-block;
  width: 2.8em;
  margin-right: 14px;
  padding-right: 10px;
  text-align: right;
  color: #b0afa2;
  border-right: 1px solid var(--rule);
  user-select: none;
}

/* ---- html frame / image / binary ---- */

.htmlframe { display: block; width: 100%; height: 80vh; border: 0; background: #fff; }
.preview { max-width: 100%; display: block; margin: 0 auto; }
.binary { padding: 48px 24px; text-align: center; font-style: italic; color: var(--muted); }

/* ---- markdown body: the typeset document ---- */

.markdown-body { max-width: 100%; }
.markdown-body > .md-block:first-child .md-content > :first-child { margin-top: 0; }

.md-content > :last-child { margin-bottom: 0; }

.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  margin: 22px 0 12px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.markdown-body h1 { font-size: 27px; }
.markdown-body h2 { font-size: 20px; }
/* Section air lives on the block wrapper, not inside it, so the hover rule
   and the + button hug the heading text instead of its top margin. */
.md-content > h1:first-child, .md-content > h2:first-child,
.md-content > h3:first-child, .md-content > h4:first-child,
.md-content > h5:first-child, .md-content > h6:first-child { margin-top: 0; }
.md-block + .md-block:has(> .md-content > h1:first-child) { margin-top: 14px; }
.md-block + .md-block:has(> .md-content > h2:first-child) { margin-top: 26px; }
.md-block + .md-block:has(> .md-content > h3:first-child),
.md-block + .md-block:has(> .md-content > h4:first-child),
.md-block + .md-block:has(> .md-content > h5:first-child),
.md-block + .md-block:has(> .md-content > h6:first-child) { margin-top: 18px; }
.markdown-body h3 { font-size: 16.5px; }
.markdown-body h4 { font-size: 15.5px; font-style: italic; }
.markdown-body p { margin: 0 0 10px; }
.markdown-body ul, .markdown-body ol { margin: 0 0 10px; padding-left: 2em; }
.markdown-body li + li { margin-top: 4px; }
.markdown-body li.task-list-item { list-style: none; margin-left: -1.4em; }
.markdown-body input[type="checkbox"] { margin: 0 8px 2px 0; vertical-align: middle; accent-color: var(--pencil); }
.markdown-body blockquote {
  margin: 0 0 10px;
  padding: 0 1em;
  font-style: italic;
  color: var(--muted);
  border-left: 2px solid var(--desk-rule);
}
.markdown-body code {
  font-family: var(--mono);
  font-size: 80%;
  background: var(--paper-inline);
  padding: 2px 5px;
  border-radius: 3px;
}
.markdown-body pre {
  background: var(--paper-code);
  border: 1px solid var(--rule);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 6px 0 12px;
}
.markdown-body pre code { background: none; padding: 0; font-size: 12.5px; line-height: 1.55; border-radius: 0; }
.markdown-body table { border-collapse: collapse; margin: 6px 0 12px; display: block; overflow-x: auto; font-size: 14.5px; }
.markdown-body th, .markdown-body td { border: 1px solid var(--rule); padding: 6px 13px; }
.markdown-body th { font-weight: 700; }
.markdown-body tr:nth-child(2n) { background: #fafaf6; }
.markdown-body img { max-width: 100%; }
.markdown-body hr { border: 0; border-top: 1px solid var(--rule); margin: 20px 0; }

/* ---- annotation blocks: the review interaction ----
   The sheet keeps a 56px inner left gutter (padding on .filebody) so the
   note-add pencil button never gets clipped by the overflow-x container. */

.md-block { position: relative; padding: 4px 0; }
/* The hover rule lives in the gutter, never over the text. */
.md-block::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 5px;
  bottom: 5px;
  width: 3px;
  background: var(--pencil);
  opacity: 0;
  transition: opacity 0.12s;
}
.md-block:hover::before { opacity: 1; }

/* Wide screens: content column + true page margin for the notes. */
@media (min-width: 1100px) {
  .md-block { display: grid; grid-template-columns: minmax(0, 1fr) var(--margin-w); column-gap: 32px; }
  .md-content { grid-column: 1; min-width: 0; }
  .block-notes { grid-column: 2; grid-row: 1; }
  .stale-notes { max-width: calc(100% - var(--margin-w) - 32px); }
}

.note-add {
  position: absolute;
  left: -44px;
  top: 4px;
  z-index: 2;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1.5px solid var(--pencil);
  border-radius: 50%;
  background: var(--sheet);
  color: var(--pencil);
  font-family: var(--serif);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.12s, transform 0.12s;
  /* Center the glyph geometrically — font metrics drift across platforms. */
  display: grid;
  place-items: center;
  font-size: 16px;
  line-height: 0;
}
.md-block:hover .note-add, .note-add:focus-visible { opacity: 1; transform: scale(1); }
.note-add:hover { background: var(--pencil); color: var(--sheet); }
@media (pointer: coarse) {
  .note-add { opacity: 0.35; transform: scale(1); }
}

/* A block that carries notes gets the proofreader's asterisk. */
.md-block:has(.block-notes .note) .md-content > :last-child::after {
  content: " *";
  color: var(--pencil);
  font-style: italic;
  font-size: 0.85em;
  vertical-align: super;
}

.block-notes { margin: 4px 0; }
.note {
  position: relative;
  border-left: 2px solid var(--pencil);
  padding: 2px 26px 2px 12px;
  margin: 0 0 18px;
  font-size: 13.5px;
  line-height: 1.55;
  transition: background-color 0.12s;
}
.note:hover { background: var(--paper-code); }
.block-notes .note:first-child { margin-top: 0; }
.note-del {
  position: absolute;
  top: 0;
  right: 0;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--faded);
  font-size: 15px;
  line-height: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s;
}
.note:hover .note-del, .note-del:focus-visible { opacity: 1; }
@media (pointer: coarse) {
  .note-del { opacity: 0.55; }
}
.note-del:hover { color: var(--pencil); }
.note-meta { color: var(--faded); font-size: 10px; margin-bottom: 3px; }
.block-notes .note .note-meta::before { content: "* "; color: var(--pencil); font-style: italic; }
.note-text { white-space: pre-wrap; font-style: italic; color: var(--ink-soft); }

.note-stale { border-left: 2px dashed var(--desk-rule); }
.note-stale .note-quote {
  font-family: var(--mono);
  font-size: 11px;
  font-style: normal;
  color: var(--faded);
  border-left: 2px solid var(--rule);
  padding-left: 10px;
  margin: 4px 0 8px;
  white-space: pre-wrap;
}
.stale-badge {
  display: inline-block;
  font-size: 10px;
  color: var(--pencil);
  border: 1px solid var(--pencil);
  border-radius: 9px;
  padding: 0 8px;
  margin-left: 8px;
  vertical-align: 2px;
}

.stale-notes { margin-top: 48px; border-top: 1px solid var(--rule); padding-top: 18px; }
.stale-notes h2 { font-size: 16px; font-weight: 700; margin: 0 0 2px; }
.stale-notes .page-sub { margin-bottom: 14px; }

/* ---- composer: writes in the margin ---- */

.composer {
  margin: 0 0 18px;
  border-left: 2px solid var(--pencil);
  padding: 2px 0 2px 12px;
}
.composer textarea {
  width: 100%;
  min-height: 68px;
  border: 0;
  border-bottom: 1px solid var(--desk-rule);
  background: transparent;
  padding: 2px 0 6px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-soft);
  resize: vertical;
}
.composer textarea::placeholder { color: var(--faded); }
.composer textarea:focus { outline: none; border-bottom-color: var(--pencil); }
.composer-actions { display: flex; gap: 18px; margin-top: 8px; }
.composer .btn, .composer .btn-primary {
  border: 0;
  background: none;
  padding: 0;
}
.composer .btn { color: var(--faded); }
.composer .btn:hover { color: var(--muted); background: none; }
.composer .btn-primary { color: var(--pencil); }
.composer .btn-primary:hover { color: var(--pencil-press); background: none; }

/* ---- buttons (generic; the login uses these filled) ---- */

.btn, .btn-primary {
  font-size: 10.5px;
  font-weight: 700;
  padding: 8px 16px;
  cursor: pointer;
}
.btn { border: 1px solid var(--desk-rule); background: none; color: var(--muted); }
.btn:hover { background: var(--paper-code); }
.btn-primary { border: 1.5px solid var(--pencil); background: var(--pencil); color: #fff; }
.btn-primary:hover { background: var(--pencil-press); border-color: var(--pencil-press); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

/* ---- login: a single card on the desk ---- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--desk);
  padding: 20px;
}
.login {
  background: var(--sheet);
  box-shadow: var(--sheet-shadow);
  padding: 44px 40px;
  width: min(360px, 100%);
  text-align: center;
}
.login h1 { font-family: var(--serif); font-style: italic; font-size: 26px; margin: 0 0 6px; }
.login h1::after { content: "·"; color: var(--pencil); margin-left: 8px; font-style: normal; }
.login p { font-style: italic; color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.login input {
  width: 100%;
  padding: 6px 2px 8px;
  font-size: 13px;
  text-align: center;
  border: 0;
  border-bottom: 1px solid var(--desk-rule);
  background: transparent;
  margin-bottom: 22px;
  font-family: var(--mono);
  color: var(--ink);
}
.login input:focus { outline: none; border-bottom-color: var(--pencil); }
.login button { width: 100%; }
.login-error { font-style: italic; color: var(--pencil); font-size: 13px; margin: 14px 0 0; }

/* ---- responsive ---- */

@media (max-width: 720px) {
  .wrap { padding: 0 12px; }
  .sheet { padding: 28px 22px 36px; }
  .filehead { padding: 22px 18px 10px 44px; }
  .filebody { padding: 20px 18px 40px 44px; }
  .note-add { left: -36px; }
  .md-block::before { left: -8px; }
  pre.code .line { padding: 0 16px 0 8px; }
}

:focus-visible { outline: 2px solid var(--pencil); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
