/* Commonplace 1.3: private library, archive, literary journal */
:root {
  --ivory: #f6f1e6;
  --page: #fcfaf5;
  --ivory-deep: #ede5d3;
  --parchment: #e6dcc6;
  --ink: #262320;
  --ink-soft: #4a443c;
  --muted: #7d746a;
  --rule: #d8cdb7;
  --rule-soft: #e6dcc9;
  --gold: #a4803f;
  --gold-deep: #85652c;
  --gold-soft: #f0e6d0;
  --bronze: #7a5b32;
  --brown: #5d4a35;
  --danger: #8c3e2f;
  --danger-soft: #f1e2dc;
  /* aliases kept for pages that reference the older token names */
  --paper: var(--ivory);
  --paper-2: var(--ivory-deep);
  --accent: var(--gold);
  --accent-ink: var(--gold-deep);
  --accent-soft: var(--gold-soft);
  --mark: var(--gold);
  --display: "Cormorant Garamond", "Cormorant", Garamond, "Times New Roman", serif;
  --text: "EB Garamond", Garamond, "Iowan Old Style", Georgia, serif;
  --script: "Allura", "Brush Script MT", cursive;
  --serif: var(--display);
  --sans: var(--text);
  --maxw: 72rem;
  --radius: 2px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ivory);
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.1rem;
  line-height: 1.6;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: calc(env(safe-area-inset-bottom, 0) + 4.75rem);
  -webkit-font-smoothing: antialiased;
}
@media (min-width: 820px) { body { padding-bottom: 4rem; } }
a { color: var(--gold-deep); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: var(--rule); }
a:hover { color: var(--bronze); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--ivory); padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 1rem; top: 1rem; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Small capitals for labels and metadata */
.label, .kind, .tone, .entry-margin, .table th, .cite-box .label, .outline .section, .count, .field label, .field .label, .change-head .type, .hist th, .stat-list .n, .entry-meta .tag, .top-right a, .small-caps {
  font-family: var(--text);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .72rem;
  font-weight: 500;
}

/* Header: a masthead, not an app bar */
.top {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.6rem 1.5rem 0;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "brand right" "nav nav";
  align-items: end;
  column-gap: 2rem;
}
.brand {
  grid-area: brand;
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: .02em;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: .75rem;
  line-height: 1;
}
.brand-mark { width: .55rem; height: 1.25rem; border: 1.5px solid var(--gold); border-left: 4px solid var(--gold); border-radius: 1px 3px 3px 1px; display: inline-block; transform: translateY(.1rem); }
.brand .tagline { font-family: var(--script); font-size: 1.35rem; color: var(--gold-deep); font-weight: 400; letter-spacing: 0; text-transform: none; }
.nav {
  grid-area: nav;
  display: flex;
  gap: 2.25rem;
  margin-top: 1.1rem;
  border-top: 1px solid var(--rule);
  padding: .8rem 0 0;
}
.nav a {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--ink-soft);
  text-decoration: none;
  position: relative;
  padding-bottom: .1rem;
}
.nav a[aria-current="page"] { color: var(--ink); }
.nav a[aria-current="page"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -.35rem; height: 2px; background: var(--gold); }
.nav a:hover { color: var(--gold-deep); }
.count { display: inline-block; min-width: 1.4rem; text-align: center; line-height: 1.4rem; background: var(--gold); color: var(--ivory); border-radius: 1rem; padding: 0 .4rem; margin-left: .25rem; letter-spacing: .04em; font-size: .7rem; vertical-align: .15rem; }
.top-right { grid-area: right; display: flex; gap: 1.5rem; padding-bottom: .15rem; }
.top-right a { color: var(--muted); text-decoration: none; }
.top-right a:hover, .top-right a[aria-current="page"] { color: var(--ink); }
@media (max-width: 819px) {
  .top { padding: 1.2rem 1.25rem 0; grid-template-areas: "brand right"; }
  .brand { font-size: 1.6rem; }
  .brand .tagline { display: none; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; margin: 0;
    background: var(--ivory-deep); border-top: 1px solid var(--rule); border-bottom: 0;
    justify-content: space-around; gap: 0;
    padding: .55rem 0 calc(.5rem + env(safe-area-inset-bottom, 0));
  }
  .nav a { font-size: .95rem; padding: .3rem .35rem; }
  .nav a[aria-current="page"]::after { bottom: -.1rem; }
}

/* Main column */
.main {
  max-width: var(--maxw);
  margin: 2rem auto 3rem;
  padding: 2.5rem 3rem 3.25rem;
  background: var(--page);
  border: 1px solid var(--rule);
  box-shadow: 0 1px 0 rgba(93, 74, 53, .06), 0 12px 30px -24px rgba(93, 74, 53, .35);
}
@media (max-width: 819px) { .main { margin: 1.25rem .75rem 2rem; padding: 1.75rem 1.25rem 2.25rem; } }
.auth-page .main { background: transparent; border: 0; box-shadow: none; }
h1 {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2.1rem, 3.4vw, 3rem);
  line-height: 1.1;
  letter-spacing: -.005em;
  margin: 0 0 1rem;
  color: var(--ink);
}
h1 small { display: block; margin: .5rem 0 0; }
h1 small, .page-head small { font-family: var(--text); font-size: .74rem; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-left: 0; }
h2 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.6rem;
  line-height: 1.2;
  margin: 2.75rem 0 1rem;
  padding-bottom: .45rem;
  border-bottom: 1px solid var(--rule);
}
h2 small { font-family: var(--text) !important; font-size: .72rem !important; letter-spacing: .14em; text-transform: uppercase; font-weight: 500 !important; color: var(--muted); margin-left: .75rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.lede { color: var(--ink-soft); max-width: 42rem; margin: 0 0 2rem; font-size: 1.15rem; line-height: 1.55; font-style: italic; }
.script { font-family: var(--script); font-size: 1.6rem; color: var(--gold-deep); font-style: normal; }
.flash { padding: .8rem 1.1rem; border-left: 2px solid var(--gold); background: var(--ivory); margin-bottom: 1.5rem; color: var(--ink-soft); }
.flash-error { border-left-color: var(--danger); background: var(--danger-soft); }

/* Filters: a quiet toolbar */
.filters { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: end; margin: 1.5rem 0 2rem; padding: 1.25rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.filters .field { margin: 0; flex: 1 1 9rem; }
.filters .field.grow { flex: 3 1 14rem; }
.filters .btn { align-self: end; }

/* Inbox: entry plus its filing form as one block */
.file-form { border-top: 0; margin: 0 0 1.25rem; padding: .25rem 0 1.75rem; border-bottom: 1px solid var(--rule); }
.file-form .field label { margin-bottom: .2rem; }
.inbox-item .entry { border-bottom: 0; padding-bottom: .5rem; }

/* Entries: a reading list with a marginal index */
.entries { list-style: none; margin: 0; padding: 0; }
.entry { display: grid; grid-template-columns: 8rem 1fr; gap: 1.5rem; padding: 2rem 0; border-bottom: 1px solid var(--rule-soft); }
.entry:first-child { padding-top: .75rem; }
.entry-margin { color: var(--muted); padding-top: .55rem; line-height: 1.6; }
.kind { color: var(--bronze); display: block; }
.kind::before { content: none; }
.fav { color: var(--gold); font-size: .9rem; display: block; margin-top: .35rem; letter-spacing: 0; }
.entry-body { margin: 0 0 .75rem; font-family: var(--display); font-size: 1.55rem; font-weight: 500; line-height: 1.4; color: var(--ink); max-width: 46rem; }
.entry-body.is-quote::before { content: "\201C"; margin-left: -.45em; color: var(--gold); }
.entry-body.is-quote::after { content: "\201D"; color: var(--gold); }
.entry-source { margin: 0 0 .4rem; color: var(--ink-soft); font-size: 1.02rem; }
.entry-source::before { content: ""; display: inline-block; width: 1.5rem; height: 1px; background: var(--gold); margin-right: .6rem; vertical-align: middle; }
.entry-source cite { font-style: italic; }
.entry-note { margin: .5rem 0 .6rem; color: var(--muted); font-size: 1rem; max-width: 46rem; font-style: italic; padding-left: .9rem; border-left: 1px solid var(--rule); }
.entry-meta { margin: .6rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; align-items: baseline; font-size: .95rem; }
.entry-meta > a:first-child { font-family: var(--text); text-transform: uppercase; letter-spacing: .14em; font-size: .72rem; font-weight: 500; text-decoration: none; color: var(--bronze); }
.entry-meta .tag { color: var(--muted); text-decoration: none; }
.entry-meta .tag::before { content: "#"; opacity: .6; }
.entry-meta .tag:hover { color: var(--gold-deep); }
.tone { color: var(--muted); }
.entry-open { margin-left: auto; font-family: var(--display); font-size: 1.05rem; font-weight: 500; text-decoration: none; letter-spacing: .03em; }
.entry-open:hover { text-decoration: underline; }
@media (max-width: 640px) {
  .entry { grid-template-columns: 1fr; gap: .5rem; padding: 1.6rem 0; }
  .entry-margin { display: flex; gap: 1rem; align-items: baseline; padding-top: 0; }
  .fav { margin: 0; }
  .entry-body { font-size: 1.35rem; }
}
.empty { padding: 3.5rem 1.5rem; text-align: center; color: var(--muted); border: 1px solid var(--rule); font-style: italic; font-size: 1.1rem; }
.empty a { font-style: normal; }

/* Forms: paper and ink */
form { margin: 0; }
.field { margin-bottom: 1.15rem; }
.field label, .field .label { display: block; margin-bottom: .4rem; color: var(--muted); }
.field .hint { font-size: .95rem; color: var(--muted); margin: .35rem 0 0; font-style: italic; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 1.05rem; color: var(--ink); background: transparent;
  border: 0; border-bottom: 1px solid var(--rule); border-radius: 0; padding: .5rem .1rem;
  transition: border-color .15s ease;
}
select { background: transparent; appearance: none; -webkit-appearance: none; padding-right: 1.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%237d746a' stroke-width='1.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .2rem center; }
textarea { min-height: 7rem; resize: vertical; line-height: 1.55; border: 1px solid var(--rule); padding: .75rem .9rem; background: #fff; }
textarea.big { min-height: 11rem; font-family: var(--display); font-size: 1.4rem; font-weight: 500; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 1px 0 0 var(--gold); }
textarea:focus { box-shadow: 0 0 0 1px var(--gold); }
::placeholder { color: #a79d90; font-style: italic; }
.row { display: grid; gap: 0 1.5rem; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }
.actions { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; margin-top: .75rem; }
.btn {
  font-family: var(--text); font-size: .78rem; font-weight: 500; letter-spacing: .14em; text-transform: uppercase;
  cursor: pointer; border-radius: 0; padding: .75rem 1.4rem; border: 1px solid var(--ink); background: var(--ink); color: var(--ivory);
  text-decoration: none; display: inline-block; line-height: 1.2; transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--bronze); border-color: var(--bronze); color: var(--ivory); }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-secondary:hover { background: var(--ink); color: var(--ivory); border-color: var(--ink); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: var(--ivory); border-color: var(--danger); }
.btn-small { padding: .5rem .95rem; font-size: .7rem; }
.btn[disabled] { opacity: .35; cursor: default; }
.btn-link { background: none; border: 0; color: var(--gold-deep); padding: 0; cursor: pointer; font: inherit; font-size: .95rem; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rule); }
.btn-link:hover { color: var(--bronze); text-decoration-color: currentColor; }
.check { display: flex; align-items: center; gap: .6rem; color: var(--ink-soft); }
.check input { width: 1rem; height: 1rem; accent-color: var(--gold-deep); margin: 0; }

/* Capture screen */
.capture { max-width: 46rem; }
.capture .kinds { display: flex; flex-wrap: wrap; gap: .35rem .5rem; margin-bottom: 1.5rem; }
.capture .kinds label {
  font-family: var(--text); text-transform: uppercase; letter-spacing: .14em; font-size: .72rem; font-weight: 500;
  border: 1px solid var(--rule); padding: .5rem .95rem; cursor: pointer; color: var(--ink-soft); background: transparent; transition: all .15s ease;
}
.capture .kinds input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.capture .kinds label:has(input:checked) { background: var(--ink); color: var(--ivory); border-color: var(--ink); }
.capture .kinds label:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 3px; }
.voice-btn { margin-top: .6rem; }
.voice-btn[aria-pressed="true"] { background: var(--danger); border-color: var(--danger); color: var(--ivory); }
details.more { margin: .75rem 0 1.5rem; }
details.more summary { cursor: pointer; font-family: var(--display); font-size: 1.15rem; font-weight: 500; color: var(--gold-deep); list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "+"; display: inline-block; width: 1.2rem; color: var(--gold); }
details.more[open] summary::before { content: "\2013"; }
details.more > div { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--rule-soft); }

/* Tables and side column */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .8rem .6rem; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
.table th { color: var(--muted); border-bottom: 1px solid var(--rule); }
.table td cite { font-family: var(--display); font-size: 1.15rem; font-weight: 500; }
.table-wrap { overflow-x: auto; }
.two-col { display: grid; gap: 3rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .two-col { grid-template-columns: minmax(0, 2.1fr) minmax(16rem, 1fr); } }
.side { border-left: 1px solid var(--rule); padding-left: 2rem; }
@media (max-width: 899px) { .side { border-left: 0; padding-left: 0; border-top: 1px solid var(--rule); padding-top: 2rem; } }
.side h2 { margin-top: 0; font-size: 1.3rem; }
.side h2 ~ h2 { margin-top: 2.5rem; }
.stat-list { list-style: none; margin: 0; padding: 0; }
.stat-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--rule-soft); }
.stat-list li a { text-decoration: none; color: var(--ink); font-family: var(--display); font-size: 1.15rem; font-weight: 500; }
.stat-list li a:hover { color: var(--gold-deep); }
.stat-list .n { color: var(--muted); letter-spacing: .05em; }

/* Citations */
.cite-box { background: var(--ivory); padding: 1.1rem 1.3rem; margin: .75rem 0 1.5rem; border-left: 2px solid var(--gold); }
.cite-box p { margin: .3rem 0; }
.cite-box .label { display: block; margin-bottom: .1rem; color: var(--muted); }
.cite-box code { font-family: var(--text); font-size: 1.05rem; color: var(--ink); word-break: break-all; }
.cite-box em { font-style: italic; }

/* Speech outline */
.outline { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.outline li { padding: 1.4rem 0; border-bottom: 1px solid var(--rule-soft); display: grid; grid-template-columns: 2.5rem 1fr auto; gap: 1.25rem; align-items: start; }
.outline .pos { counter-increment: step; color: var(--gold); font-family: var(--display); font-size: 1.9rem; font-weight: 500; line-height: 1; }
.outline .pos::before { content: counter(step, upper-roman); }
.outline .section { color: var(--bronze); }
.outline .body { font-family: var(--display); font-size: 1.3rem; font-weight: 500; line-height: 1.4; margin: .35rem 0; }
.outline .attrib { font-size: .98rem; color: var(--muted); }
.outline form { display: flex; gap: .4rem; }
.outline input[type=text] { font-size: .95rem; }
@media (max-width: 640px) { .outline li { grid-template-columns: 2rem 1fr; } .outline li > div:last-child { grid-column: 2; } }

/* Approvals */
.change { border-top: 1px solid var(--rule); padding: 1.5rem 0 1.5rem 1.25rem; margin: 0; background: transparent; border-left: 2px solid var(--gold); }
.change + .change { margin-top: 1rem; }
.change.is-delete { border-left-color: var(--danger); }
.change .summary { font-family: var(--display); font-size: 1.3rem; font-weight: 500; line-height: 1.35; }
.change-head .when { color: var(--muted); font-size: .95rem; margin-left: auto; font-style: italic; }
.kv { font-size: 1rem; }
.kv dt { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .14em; font-weight: 500; padding-top: .15rem; }
.change details summary { font-family: var(--display); font-size: 1.05rem; font-weight: 500; color: var(--gold-deep); }

/* Sign-in and consent */
.auth { max-width: 26rem; margin: 4rem auto; text-align: left; }
.auth .brand { font-size: 2.4rem; margin-bottom: 2rem; }
.auth .brand .tagline { display: inline; }
.auth h1 { font-size: 2.2rem; }
.auth p { color: var(--ink-soft); }

/* Library sidebar heading flourish */
.side h2:first-of-type::before, .capture h1::before { content: none; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .top, .nav, .actions, .filters, .entry-open, .btn { display: none !important; }
  body { padding: 0; background: #fff; color: #000; }
  .entry-body.is-quote::before, .entry-body.is-quote::after { color: #000; }
}
