/* Proper Cite. Library vernacular: buckram green, catalogue cards, date-stamp violet. */
:root {
  --paper: #f4f6f8;
  --card: #fffffe;
  --ink: #1b2230;
  --muted: #5d6673;
  --cloth: #1b2440;
  --cloth-deep: #131a31;
  --cloth-tint: #e7ebf3;
  --stamp: #4f46a8;
  --flag: #b8322a;
  --pencil: #f6e58d;
  --rule: #cfdbe4;
  --line: #dfe3dc;
  --serif: "Literata", "Iowan Old Style", Georgia, serif;
  --sans: "Figtree", system-ui, sans-serif;
  --step--1: 0.8125rem; --step-0: 0.9375rem; --step-1: 1.125rem; --step-2: 1.5rem;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 var(--step-0)/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--stamp); outline-offset: 2px; border-radius: 3px; }

.app { display: grid; grid-template-columns: 232px minmax(0, 1fr) 0; height: 100vh; }
.app.has-detail { grid-template-columns: 232px minmax(0, 1fr) minmax(380px, 30rem); }

/* Rail: the cloth spine */
.rail { background: var(--cloth); color: #eef3ef; display: flex; flex-direction: column; padding: 22px 14px 14px; overflow-y: auto;
  background-image: repeating-linear-gradient(0deg, rgba(255,255,255,.022) 0 1px, transparent 1px 3px), repeating-linear-gradient(90deg, rgba(0,0,0,.035) 0 1px, transparent 1px 3px); }
.wordmark { display: block; color: inherit; text-decoration: none; padding: 0 8px 20px; font: 500 1.3125rem/1.1 var(--serif); letter-spacing: -0.01em; }
.wordmark i { font-weight: 400; color: #d9c98a; padding: 0 1px; }
.specs { display: block; width: 46px; margin-bottom: 10px; fill: none; }
.shelves { list-style: none; margin: 0; padding: 0; flex: 1; }
.shelves li.head { display: flex; justify-content: space-between; align-items: baseline; padding: 18px 8px 4px; font-size: var(--step--1); color: #a9c0b5; }
.shelves li.head button { background: none; border: 0; color: #d9c98a; cursor: pointer; padding: 2px 4px; font-size: var(--step--1); }
.shelves button.shelf { display: flex; justify-content: space-between; gap: 8px; width: 100%; text-align: left; background: none; border: 0; color: inherit; padding: 6px 8px; border-radius: 5px; cursor: pointer; }
.shelves button.shelf:hover { background: rgba(255,255,255,.07); }
.shelves button.shelf[aria-current="true"] { background: var(--cloth-deep); box-shadow: inset 3px 0 0 #d9c98a; }
.shelves .n { color: #a9c0b5; font-variant-numeric: tabular-nums; font-size: var(--step--1); }
.shelves .none { padding: 2px 8px; color: #a9c0b5; font-size: var(--step--1); }
.rail-foot { display: grid; gap: 2px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.14); }
.rail .quiet { background: none; border: 0; color: #cfdcd5; text-align: left; padding: 5px 8px; border-radius: 5px; cursor: pointer; text-decoration: none; font-size: var(--step--1); }
.rail .quiet:hover { background: rgba(255,255,255,.07); color: #fff; }

/* Ledger */
.ledger { overflow-y: auto; padding: 26px 34px 60px; }
.add label { display: block; font: 500 var(--step-1)/1.3 var(--serif); margin-bottom: 8px; }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; }
.add-row input { flex: 1 1 320px; padding: 11px 14px; border: 1px solid #b9c2ba; border-radius: 6px; background: var(--card); }
.add-row input::placeholder { color: #7d8691; }
.add-msg { min-height: 1.4em; margin: 6px 2px 0; font-size: var(--step--1); color: var(--muted); }
.add-msg.bad { color: var(--flag); }
button.primary { background: var(--cloth); color: #fff; border: 1px solid var(--cloth-deep); border-radius: 6px; padding: 10px 18px; font-weight: 600; cursor: pointer; }
button.primary:hover { background: var(--cloth-deep); }
button.primary[disabled] { opacity: .6; cursor: progress; }
button.ghost { background: transparent; border: 1px solid #b9c2ba; border-radius: 6px; padding: 10px 14px; cursor: pointer; }
button.ghost:hover { border-color: var(--cloth); color: var(--cloth); }
button.small { padding: 5px 10px; font-size: var(--step--1); }
button.link { background: none; border: 0; padding: 0; color: var(--cloth); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font-size: inherit; }
button.link.danger { color: var(--flag); }

.toolbar { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 22px 0 6px; padding-bottom: 12px; border-bottom: 2px solid var(--ink); }
.toolbar h1 { font: 500 var(--step-2)/1.15 var(--serif); margin: 0; letter-spacing: -0.012em; }
.tools { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: var(--step--1); color: var(--muted); }
.tools input[type=search] { padding: 6px 10px; border: 1px solid #b9c2ba; border-radius: 6px; background: var(--card); width: 11rem; }
.tools select, .field select { padding: 6px 8px; border: 1px solid #b9c2ba; border-radius: 6px; background: var(--card); color: var(--ink); max-width: 15rem; }
.inline { display: inline-flex; gap: 6px; align-items: center; }

.rows { list-style: none; margin: 0; padding: 0; }
.row { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 12px; padding: 13px 10px 13px 6px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 4px; }
.row:hover { background: #eaeee8; }
.row[aria-selected="true"] { background: var(--cloth-tint); }
.row .cite { font: 400 1rem/1.5 var(--serif); max-width: 46rem; overflow-wrap: anywhere; }
.row .cite .csl-entry { display: block; }
.row .meta { margin-top: 3px; font-size: var(--step--1); color: var(--muted); }
.row .used { font-size: var(--step--1); color: var(--muted); white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.mark { width: 14px; height: 14px; border-radius: 50%; margin-top: 6px; border: 2px solid #a9b1a9; }
.mark.checked { border-color: var(--stamp); background: var(--stamp); box-shadow: inset 0 0 0 2px var(--paper); }
.mark.problems { border-color: var(--flag); background: var(--flag); }
.mark.incomplete { border-color: #b98a12; background: var(--pencil); }
.mark.unverifiable { border-style: dashed; }
.empty { padding: 48px 8px; max-width: 34rem; font: 400 var(--step-1)/1.55 var(--serif); color: var(--muted); }

/* Detail: the catalogue card */
.detail { background: #e7ebe4; border-left: 1px solid #cdd3ca; overflow-y: auto; padding: 22px 22px 60px; }
.detail-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: var(--step--1); color: var(--muted); }
.saved { transition: opacity .3s; }
.card { position: relative; background: var(--card); border: 1px solid #d5d9d0; border-radius: 3px; padding: 20px 22px 34px 44px; box-shadow: 0 1px 0 #c8cdc3, 0 8px 18px -12px rgba(27,34,48,.35);
  background-image: linear-gradient(90deg, transparent 31px, rgba(184,50,42,.5) 31px 32px, transparent 32px), repeating-linear-gradient(180deg, transparent 0 27px, var(--rule) 27px 28px); background-position: 0 0, 0 14px; }
.card::after { content: ""; position: absolute; left: 50%; bottom: 10px; width: 13px; height: 13px; margin-left: -6px; border-radius: 50%; background: #e7ebe4; box-shadow: inset 0 1px 2px rgba(0,0,0,.28); }
.card .cite { font: 400 1.0625rem/28px var(--serif); overflow-wrap: anywhere; min-height: 84px; padding-top: 6px; }
.card .cite .csl-entry { text-align: left; }
details.more { margin: 4px 0 12px; } details.more summary { cursor: pointer; color: var(--cloth); font-size: var(--step--1); padding: 4px 0 10px; }
.stamp { position: absolute; right: 14px; top: -11px; transform: rotate(-4deg); border: 2px solid currentColor; outline: 1px solid currentColor; outline-offset: 2px; color: var(--stamp); background: rgba(255,255,255,.86); border-radius: 3px; padding: 3px 9px 2px; font: 600 0.6875rem/1.25 var(--sans); letter-spacing: .09em; text-transform: uppercase; text-align: center; mix-blend-mode: multiply; }
.stamp.problems { color: var(--flag); } .stamp.incomplete { color: #8a6500; } .stamp.unverifiable { color: var(--muted); }
.stamp.fresh { animation: thunk .28s cubic-bezier(.2,1.4,.4,1); }
@keyframes thunk { from { transform: rotate(-9deg) scale(1.5); opacity: 0; } to { transform: rotate(-4deg) scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .stamp.fresh { animation: none; } }

.check { margin-top: 20px; }
.check h2, .fields h2 { font: 500 var(--step-1)/1.3 var(--serif); margin: 0 0 4px; }
.check .lede { margin: 0 0 10px; color: var(--muted); font-size: var(--step--1); }
.finding { background: var(--card); border: 1px solid #d5d9d0; border-left: 4px solid var(--muted); border-radius: 3px; padding: 9px 12px; margin-bottom: 7px; font-size: var(--step--1); }
.finding.differs { border-left-color: var(--flag); } .finding.missing { border-left-color: #c79a1d; } .finding.note { border-left-color: var(--stamp); } .finding.confirmed { border-left-color: var(--cloth); }
.finding b { font-weight: 600; font-size: var(--step-0); }
.finding .pair { display: grid; grid-template-columns: 4.6rem minmax(0,1fr); gap: 1px 8px; margin: 4px 0; }
.finding .pair span:nth-child(odd) { color: var(--muted); }
.finding .theirs { background: var(--pencil); padding: 0 3px; border-radius: 2px; overflow-wrap: anywhere; }
.finding .yours { overflow-wrap: anywhere; }
.finding .why { color: var(--muted); margin: 3px 0 0; }
.finding .acts { display: flex; gap: 12px; align-items: center; margin-top: 6px; }
.finding a { color: var(--cloth); }
details.ok { margin-top: 6px; font-size: var(--step--1); color: var(--muted); }
details.ok summary { cursor: pointer; padding: 4px 0; }

.fields { margin-top: 24px; }
.field { display: grid; gap: 3px; margin-bottom: 10px; }
.field label { font-size: var(--step--1); color: var(--muted); }
.field input, .field textarea { padding: 8px 10px; border: 1px solid #b9c2ba; border-radius: 5px; background: var(--card); width: 100%; font-family: var(--serif); font-size: 0.9375rem; }
.field textarea { resize: vertical; min-height: 2.6em; line-height: 1.45; }
.field .hint { font-size: 0.75rem; color: var(--muted); }
.field.flagged input, .field.flagged textarea { border-color: var(--flag); background: #fff8f6; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid #b9c2ba; border-radius: 999px; padding: 3px 10px; background: var(--card); font-size: var(--step--1); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--cloth); border-color: var(--cloth); color: #fff; }
.detail-foot { margin-top: 22px; display: flex; justify-content: space-between; font-size: var(--step--1); color: var(--muted); }

dialog { border: 0; border-radius: 6px; padding: 0; width: min(34rem, 92vw); box-shadow: 0 24px 60px -20px rgba(27,34,48,.5); color: var(--ink); }
dialog::backdrop { background: rgba(22,58,47,.42); }
.dlg { padding: 24px 26px; }
.dlg h2 { font: 500 var(--step-2)/1.2 var(--serif); margin: 0 0 6px; }
.dlg p { margin: 0 0 14px; color: var(--muted); }
.dlg textarea { width: 100%; min-height: 9rem; padding: 10px; border: 1px solid #b9c2ba; border-radius: 6px; font: 0.8125rem/1.45 ui-monospace, Menlo, monospace; }
.dlg input[type=text] { width: 100%; padding: 10px; border: 1px solid #b9c2ba; border-radius: 6px; }
.dlg .acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.typegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 6px; }
.typegrid button { text-align: left; }

@media (max-width: 1100px) {
  .app, .app.has-detail { grid-template-columns: 200px minmax(0, 1fr); }
  .detail { position: fixed; inset: 0 0 0 auto; width: min(30rem, 100vw); z-index: 5; box-shadow: -18px 0 40px -20px rgba(0,0,0,.4); }
}
@media (max-width: 720px) {
  .app, .app.has-detail { grid-template-columns: 1fr; height: auto; }
  .rail { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; padding: 12px; }
  .wordmark { padding: 0 8px 0 0; } .specs { display: none; }
  .shelves { display: flex; flex-wrap: wrap; gap: 2px; } .shelves li.head { padding: 6px 8px; }
  .rail-foot { grid-auto-flow: column; border: 0; padding: 0; }
  .ledger { padding: 18px 16px 60px; overflow: visible; }
  .row { grid-template-columns: 18px minmax(0,1fr); } .row .used { display: none; }
}

.stylelist { list-style: none; margin: 10px 0 0; padding: 0; max-height: 16rem; overflow-y: auto; } .stylelist li { padding: 5px 2px; border-bottom: 1px solid var(--line); text-transform: capitalize; }

.plans{display:grid;gap:10px;margin:14px 0 4px}.plans .plan{display:grid;grid-template-columns:1fr auto;gap:2px 12px;text-align:left;padding:12px 14px}.plans .plan b{font:500 1.0625rem/1.3 var(--serif)}.plans .plan span{font-weight:600;color:var(--cloth)}.plans .plan small{grid-column:1/-1;color:var(--muted);font-size:.875rem}

.dlg-sub{font:500 1.0625rem/1.3 var(--serif);margin:22px 0 4px}.docpick{list-style:none;padding:0;margin:10px 0;max-height:14rem;overflow:auto}.docpick li{padding:4px 0}.docpick small{color:var(--muted)}

body.dropping::after{content:'Drop the file to import it';position:fixed;inset:12px;border:2px dashed var(--cloth);border-radius:12px;background:rgba(243,245,241,.92);display:grid;place-items:center;font:500 1.5rem var(--serif);color:var(--cloth);z-index:50;pointer-events:none}
.cite dl{margin:10px 0 0;display:grid;grid-template-columns:auto 1fr;gap:12px 16px}.cite dt{font:600 .8125rem/1.6 var(--sans);color:var(--muted);text-align:right;padding-top:2px}.cite dd{margin:0;font:400 .9375rem/1.55 var(--serif)}.cite-ex{margin-top:18px;display:flex;gap:18px;flex-wrap:wrap;font-size:.9375rem}.cite-ex a{color:var(--cloth)}.dlg.cite{max-width:42rem}
.dlg.cite p.cite-ex{margin:22px 0 0;padding-top:14px;border-top:1px solid #d5dbd4}
