/* Whitcomb workspace: a research database that reads like a well-set
   locomotive roster. White paper, ink text, one accent (US Army olive drab),
   Source Serif 4 for titles, Public Sans for everything you work with. The
   one bold element is the heavy rule under a table's heading row. */

@font-face {
    font-family: "Public Sans";
    src: url("../fonts/public-sans-latin-wght-normal.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Public Sans";
    src: url("../fonts/public-sans-latin-ext-wght-normal.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: "Source Serif 4";
    src: url("../fonts/source-serif-4-latin-wght-normal.woff2") format("woff2");
    font-weight: 200 900;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Source Serif 4";
    src: url("../fonts/source-serif-4-latin-ext-wght-normal.woff2") format("woff2");
    font-weight: 200 900;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: "Source Serif 4";
    src: url("../fonts/source-serif-4-latin-wght-italic.woff2") format("woff2");
    font-weight: 200 900;
    font-style: italic;
    font-display: swap;
}

/* № and the superscript figures (⁰⁴⁵…), missing from the subsets above. */
@font-face {
    font-family: "Public Sans";
    src: url("../fonts/public-sans-symbols.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
    unicode-range: U+2070-2079, U+2116;
}
@font-face {
    font-family: "Source Serif 4";
    src: url("../fonts/source-serif-4-symbols.woff2") format("woff2");
    font-weight: 200 900;
    font-style: normal;
    font-display: swap;
    unicode-range: U+2070-2079, U+2116;
}

:root {
    --paper: #fff;
    --header: #eaeaea;
    --ink: #1f2328;
    --quiet: #5e6670;
    --rule: #d5d8dc;
    --rule-faint: #eceef0;
    --olive: #4b5320;
    --olive-dark: #3a4019;
    --olive-wash: #eef0e3;
    --danger: #9b1c1c;
    --danger-wash: #fbeeee;
    --focus: rgba(75, 83, 32, .28);
    --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
    --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* Hidden stays hidden, whatever display a class sets. */
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 15px/1.5 var(--sans);
    font-variant-numeric: lining-nums;
    /* Public Sans has a narrow space; titles like "Name - № 12" need air. */
    word-spacing: .06em;
}

a { color: var(--olive); text-underline-offset: .15em; }
a:hover { color: var(--olive-dark); }

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

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header and menu */
.site-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .4rem 2rem;
    padding: .7rem 16px .6rem;
    background: var(--header);
    border-bottom: 1px solid #d9d9d9;
}

.site-title {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--ink);
    text-decoration: none;
}

.site-menu { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; flex: 1; }
.site-menu a { color: var(--ink); text-decoration: none; padding-bottom: .1rem; border-bottom: 2px solid transparent; }
.site-menu a:hover { border-bottom-color: var(--quiet); }
.site-menu a[aria-current="page"] { border-bottom-color: var(--olive); }
/* Right of the menu: who is logged in, the admin (when allowed), log out. */
.user-menu { display: flex; align-items: baseline; gap: 1.25rem; margin-left: auto; }
.user-name { color: var(--quiet); }
.site-menu .user-menu a { color: var(--quiet); }
.site-menu .user-menu a:hover { color: var(--ink); }

main { padding: 1.1rem 16px 2.5rem; }

/* Titles */
h1 {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 1.625rem;
    line-height: 1.2;
    letter-spacing: -.005em;
    margin: 0 0 .25rem;
}

h2 {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 1.125rem;
    line-height: 1.3;
    margin: 0 0 .55rem;
}

.placeholder { color: var(--quiet); }

.page-header,
.form-header { margin: 0 0 1.25rem; }
.page-subtitle,
.form-subtitle { margin: 0; color: var(--quiet); max-width: 42rem; }

.crumbs { font-size: .85rem; color: var(--quiet); margin-bottom: .2rem; }
.crumbs a { color: var(--quiet); }
.crumbs a:hover { color: var(--ink); }
.crumbs .back-link { text-decoration: none; }
.crumbs .back-link:hover { text-decoration: underline; }

/* Messages from Omeka */
ul.messages { list-style: none; padding: 0; margin: 0 auto 1.25rem; max-width: 50rem; }
ul.messages li { padding: .6rem .9rem; border-left: 3px solid var(--quiet); background: #f6f7f8; margin-bottom: .5rem; }
ul.messages li.success { border-left-color: var(--olive); background: var(--olive-wash); }
ul.messages li { transition: opacity .6s ease; }
ul.messages li.fading { opacity: 0; }
ul.messages li.error { border-left-color: var(--danger); background: var(--danger-wash); color: var(--danger); }

/* Inputs and buttons */
input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
select,
textarea {
    font: inherit;
    color: var(--ink);
    background: #fff;
    border: 1px solid #8c939c;
    border-radius: 3px;
    padding: 0 .55rem;
    height: 2.05rem;
}

textarea { height: auto; padding: .4rem .55rem; line-height: 1.55; resize: vertical; }
select { padding-right: .4rem; cursor: pointer; }

input:focus,
select:focus,
textarea:focus { outline: none; border-color: var(--olive); box-shadow: 0 0 0 3px var(--focus); }

.button,
input[type="submit"] {
    display: inline-block;
    padding: .38rem 1rem;
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--olive);
    border: 1px solid var(--olive);
    border-radius: 3px;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.button:hover,
input[type="submit"]:hover { background: var(--olive-dark); border-color: var(--olive-dark); color: #fff; }

.button-secondary {
    display: inline-block;
    padding: .38rem .9rem;
    font: inherit;
    color: var(--ink);
    background: #fff;
    border: 1px solid #b9bec5;
    border-radius: 3px;
    text-decoration: none;
    cursor: pointer;
}
.button-secondary:hover { border-color: var(--ink); color: var(--ink); }

.button.danger { background: var(--danger); border-color: var(--danger); }
.button.danger:hover { background: #7d1515; border-color: #7d1515; }

.danger-link { background: none; border: 0; color: var(--danger); cursor: pointer; font: inherit; padding: .38rem 0; }
.danger-link:hover { text-decoration: underline; }

.label {
    display: inline-block;
    padding: 0 .4rem;
    font-size: 12.5px;
    line-height: 19px;
    color: var(--olive-dark);
    background: var(--olive-wash);
    border-radius: 2px;
}

/* Login */
.login-box { max-width: 22rem; margin: 3rem auto; }
.login-box h1 { margin-bottom: 1.25rem; }
.login-box form .field { margin-bottom: 1rem; }
.login-box label { display: block; font-weight: 600; margin-bottom: .3rem; }
.login-box .field-meta { margin-bottom: .3rem; }
.login-box input[type="email"],
.login-box input[type="password"],
.login-box input[type="text"] { width: 100%; }
.forgot-password { font-size: .9rem; }

/* Lists: title, toolbar and table centred as one block, the table only
   as wide as its content. */
.list-page { width: fit-content; max-width: 100%; margin: 0 auto; }

.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem 1.5rem;
    margin-bottom: .9rem;
}

.list-search {
    flex: 0 1 16rem;
    min-width: 11rem;
    padding-left: 2rem;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235e6670' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat .6rem center / .95rem;
}

.list-filter { display: inline-flex; align-items: center; gap: .45rem; white-space: nowrap; cursor: pointer; }
.list-filter input { width: 1rem; height: 1rem; accent-color: var(--olive); cursor: pointer; }
.list-count { color: var(--quiet); font-size: .9rem; font-variant-numeric: tabular-nums; }
.toolbar-add { margin-left: auto; }
.list-empty { color: var(--quiet); margin: 1rem 0 0; }

.table-wrap { overflow-x: auto; }

.list-table {
    width: auto;
    border-collapse: collapse;
    font-size: 14px;
    font-variant-numeric: tabular-nums lining-nums;
}

.list-table th,
.list-table td {
    padding: 4px 12px;
    text-align: left;
    white-space: nowrap;
    vertical-align: middle;
}

.list-table th:first-child,
.list-table td:first-child { padding-left: 4px; }

.list-table td { border-bottom: 1px solid var(--rule-faint); }

/* The roster rule: a heavy ink line under the heading row. */
.list-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding-top: 6px;
    padding-bottom: 7px;
    background: var(--paper);
    font-weight: 600;
    color: var(--ink);
    box-shadow: inset 0 -2px 0 var(--ink);
    user-select: none;
}

.list-table .num { text-align: right; }
.list-table .center { text-align: center; }

.list-table th.sortable { cursor: pointer; }
.list-table th.sortable::after { content: "↕"; display: inline-block; width: 1em; margin-left: .2em; color: #b3b8bf; font-weight: 400; text-align: center; }
.list-table th.sortable:hover::after { color: var(--quiet); }
.list-table th[aria-sort="ascending"]::after { content: "↑"; color: var(--olive); }
.list-table th[aria-sort="descending"]::after { content: "↓"; color: var(--olive); }

/* Right-aligned (number) columns carry the sort mark in front, so the
   figures line up under the heading's last letter. */
.list-table th.num.sortable::after { content: none; }
.list-table th.num.sortable::before { content: "↕"; display: inline-block; width: 1em; margin-right: .2em; color: #b3b8bf; font-weight: 400; text-align: center; }
.list-table th.num.sortable:hover::before { color: var(--quiet); }
.list-table th.num[aria-sort="ascending"]::before { content: "↑"; color: var(--olive); }
.list-table th.num[aria-sort="descending"]::before { content: "↓"; color: var(--olive); }

.list-table tr.saved td { background: var(--olive-wash); }

.list-table .col-icon { text-align: center; }

/* Row icons and small buttons in a table */
.icon-button,
.link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 4px;
    color: var(--quiet);
    background: none;
    border: 0;
    border-radius: 3px;
    cursor: pointer;
    font: inherit;
}
.icon-button:hover { background: var(--olive-wash); color: var(--olive-dark); }
.icon-button .icon { width: 16px; height: 16px; display: block; }
.link-button { color: var(--olive); text-decoration: underline; text-underline-offset: .15em; padding: 0 2px; font-variant-numeric: tabular-nums; }

/* Photos column: very small thumbnails, at most 4 places. */
.photo-strip { display: flex; gap: 3px; }

.thumb-button { display: block; padding: 0; border: 0; background: none; cursor: pointer; }
.thumb-button img { display: block; width: 26px; height: 26px; object-fit: cover; border-radius: 2px; }
.thumb-button:hover img,
.thumb-button.current img { outline: 2px solid var(--olive); outline-offset: 1px; }

.thumb-more {
    width: 26px;
    height: 26px;
    padding: 0;
    font: 600 11px/24px var(--sans);
    color: var(--ink);
    background: #f1f2f3;
    border: 1px solid var(--rule);
    border-radius: 2px;
    cursor: pointer;
}
.thumb-more:hover { border-color: var(--olive); color: var(--olive-dark); }

/* Pop-ups: small, placed next to what was clicked (see workspace.js). */
.popup {
    position: fixed;
    margin: 0;
    right: auto;
    bottom: auto;
    padding: 0;
    width: max-content;
    max-width: min(92vw, 380px);
    color: var(--ink);
    background: var(--paper);
    border: 1px solid #b9bec5;
    border-radius: 3px;
    box-shadow: 0 6px 20px rgba(31, 35, 40, .16);
    z-index: 10;
}

.popup-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .75rem;
    padding: .5rem .5rem .4rem .8rem;
    border-bottom: 1px solid var(--rule);
}

.popup-title { font-family: var(--serif); font-size: 1rem; font-weight: 600; margin: 0; }
.popup-close { font-size: 1.2rem; line-height: 1; color: var(--quiet); background: none; border: 0; cursor: pointer; padding: 0 .3rem; }
.popup-close:hover { color: var(--ink); }

.popup-body { padding: .65rem .8rem .75rem; }
.popup-photos figure { margin: 0; }
.popup-photos img { max-width: 100%; max-height: 260px; display: block; margin: 0 auto; }
.popup-photos figcaption { margin-top: .45rem; color: var(--quiet); font-size: .875rem; }
.popup-strip { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: .6rem; }
.popup-railroads ol { list-style-type: upper-alpha; margin: 0; padding-left: 1.4rem; line-height: 1.8; }

/* Edit forms: one record sheet, sections divided by rules, labels in a
   fixed column, actions in a bar fixed at the bottom. */
body.page-form main { padding-bottom: 4.5rem; }

.edit-form { max-width: 50rem; margin: 0 auto; }

.form-header { padding-bottom: .85rem; margin-bottom: 0; border-bottom: 2px solid var(--ink); }

/* The catalogue entry: fixed works-list data, not inputs. */
.catalogue { display: flex; flex-wrap: wrap; gap: .2rem 2.25rem; margin: .55rem 0 .35rem; }
.catalogue div { display: flex; flex-direction: column; }
.catalogue dt { font-size: .8rem; color: var(--quiet); }
.catalogue dd { margin: 0; font-family: var(--serif); font-size: 1.125rem; font-weight: 600; font-variant-numeric: tabular-nums lining-nums; }

.sheet-section { padding: 1.05rem 0 .3rem; border-bottom: 1px solid var(--rule); }
.section-hint { margin: -.2rem 0 .65rem; color: var(--quiet); font-size: .85rem; max-width: 40rem; }

.form-row {
    display: grid;
    grid-template-columns: 10rem minmax(0, 1fr);
    gap: .2rem 1.25rem;
    align-items: start;
    margin-bottom: .5rem;
}

.form-label { font-weight: 600; padding-top: .3rem; }
.req { color: var(--danger); font-weight: 600; }
.hint { margin: .2rem 0 0; color: var(--quiet); font-size: .85rem; }

.edit-form input[type="text"],
.edit-form select { width: 100%; max-width: 30rem; }
.edit-form input.input-short { max-width: 12rem; }
.edit-form select.input-short { max-width: 14rem; }
.edit-form textarea { width: 100%; }

.fixed-value { display: inline-block; padding-top: .3rem; }

.date-input { display: flex; gap: .5rem; }
.edit-form .date-input .date-year { width: 5.5rem; }
.edit-form .date-input .date-month { width: 7rem; }
.edit-form .date-input .date-day { width: 4.5rem; }

.switch { display: inline-flex; align-items: center; gap: .55rem; padding-top: .45rem; cursor: pointer; }
.switch input { width: 1.05rem; height: 1.05rem; accent-color: var(--olive); cursor: pointer; }

.notes { display: flex; flex-direction: column; gap: .5rem; }
.notes-actions { display: flex; align-items: center; gap: 1rem; margin: .5rem 0 .75rem; }
.notes-actions .hint { margin: 0; }
.fixed-note { margin-bottom: .6rem; }

/* Research Notes: formatted text with a small toolbar. */
.note-editor { border: 1px solid #b9bec5; border-radius: 3px; background: #fff; }
.note-editor:focus-within { border-color: var(--olive); box-shadow: 0 0 0 3px var(--focus); }
.note-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem; padding: .25rem .3rem; border-bottom: 1px solid var(--rule); background: #fafafa; border-radius: 3px 3px 0 0; font-size: .85rem; }
.note-toolbar .tb-button { min-width: 28px; height: 28px; }
.note-toolbar .tb-sep { height: 18px; margin: 0 .2rem; }
.link-box-button { font: inherit; font-size: .8rem; height: 1.8rem; padding: 0 .6rem; color: var(--ink); background: #fff; border: 1px solid var(--rule); border-radius: 3px; cursor: pointer; }
.link-box-button:hover { border-color: #b9bec5; }
.link-box-button.primary { color: #fff; background: var(--olive); border-color: var(--olive); }
.link-box-button.primary:hover { background: var(--olive-dark); }
.link-box-button[hidden] { display: none; }
.note-link-box { display: inline-flex; align-items: center; gap: .3rem; margin-left: .4rem; }
.note-link-box[hidden] { display: none; }
.note-link-box input { height: 1.8rem; width: 18rem; max-width: 50vw; font-size: .85rem; padding: 0 .45rem; }
.note-link-box input:focus { box-shadow: none; }
.note-body { line-height: 1.55; overflow-wrap: anywhere; }
/* The Tiptap box inside: the whole area takes clicks. */
.note-text { min-height: 4rem; padding: .5rem .65rem; outline: none; white-space: pre-wrap; }
.note-text > :first-child { margin-top: 0; }
.note-text > :last-child { margin-bottom: 0; }
.note-body p { margin: 0 0 .7rem; }
.note-body li > p { margin: 0; }
.note-body ul, .note-body ol { margin: 0 0 .7rem; padding-left: 1.4rem; }
.note-body a { color: var(--olive); }

/* USATC Whitcomb: its Railroad Whitcombs in order (the locomotive's history). */
.railroad-order { list-style: none; counter-reset: railroad; margin: 0; padding: 0; max-width: 34rem; border-top: 1px solid var(--rule); }
.railroad-order li {
    counter-increment: railroad;
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .3rem .25rem;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    cursor: grab;
}
.railroad-order li::before { content: counter(railroad, upper-alpha) "."; order: 1; min-width: 1.4rem; text-align: right; color: var(--quiet); font-variant-numeric: tabular-nums; }
.railroad-order .drag-handle { order: 0; color: #9aa0a8; line-height: 1; }
.railroad-order .railroad-title { order: 2; flex: 1; }
.railroad-order .remove-button { order: 3; }
.railroad-order li.dragging { opacity: .4; }
.railroad-order li.just-added { background: var(--olive-wash); }
.remove-button { background: none; border: 0; color: var(--quiet); font-size: 1.15rem; line-height: 1; padding: .1rem .4rem; cursor: pointer; }
.remove-button:hover { color: var(--danger); }
.railroad-empty { color: var(--quiet); margin: 0; }
.railroad-add { margin: .9rem 0 1.1rem; }
.edit-form .railroad-add input { max-width: 34rem; }

.form-errors {
    margin: 1.25rem 0 0;
    padding: .7rem 1rem;
    border-left: 3px solid var(--danger);
    background: var(--danger-wash);
    color: var(--danger);
}
.form-errors ul { margin: .3rem 0 0; padding-left: 1.2rem; }

.form-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: .75rem;
    background: rgba(255, 255, 255, .96);
    border-top: 1px solid var(--rule);
    padding: .5rem 16px;
    z-index: 5;
}
.form-bar .danger-link { margin-left: auto; }
/* Line the buttons up with the form's edges. */
.form-bar {
    padding-left: max(16px, calc((100% - 50rem) / 2));
    padding-right: max(16px, calc((100% - 50rem) / 2));
}

.delete-confirm {
    margin: 1.25rem 0;
    padding: .9rem 1rem;
    border-left: 3px solid var(--danger);
    background: var(--danger-wash);
    scroll-margin-bottom: 6rem;
}
.delete-confirm p { margin: 0 0 .8rem; }
.delete-confirm .button-secondary { margin-left: .5rem; }

@media (max-width: 40rem) {
    .site-header { gap: .2rem 1rem; padding: .5rem 12px .45rem; }
    .site-menu { flex-wrap: nowrap; gap: 1rem; font-size: .9rem; white-space: nowrap; }
    .menu-long { display: none; }
    .user-name { display: none; }
    .user-menu { gap: 1rem; }
    h1 { font-size: 1.4rem; }
    .form-row { grid-template-columns: 1fr; }
    .form-label { padding-top: 0; }
    .toolbar-add { margin-left: 0; }
}

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

/* Railroad Whitcomb form: its place in the USATC Whitcomb's history */
.history-instruction { margin: .45rem 0 .7rem; max-width: 36rem; font-size: .925rem; }
.railroad-order li.self { background: var(--olive-wash); font-weight: 600; box-shadow: inset 3px 0 0 var(--olive); }
.railroad-order li.self .drag-handle { color: var(--olive); }

/* USATC Whitcomb form: confirm before moving a railroad from another history */
.move-confirm {
    max-width: 34rem;
    margin: 0 0 1rem;
    padding: .75rem 1rem;
    border-left: 3px solid var(--olive);
    background: var(--olive-wash);
}
.move-confirm p { margin: 0 0 .6rem; }
.move-confirm .button-secondary { margin-left: .5rem; }
.moved-note { font-size: .8rem; }

/* Photos page */
.photos-page .sheet-section h2 { margin-bottom: .7rem; }

.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .3rem;
    padding: 1.4rem 1rem;
    text-align: center;
    border: 1px dashed #9aa0a8;
    border-radius: 3px;
    background: #fafbfa;
    cursor: pointer;
}
.drop-zone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-zone:focus-within { outline: 2px solid var(--olive); outline-offset: 2px; }
.drop-zone.dragging-over { border-color: var(--olive); background: var(--olive-wash); }
.drop-link { color: var(--olive); text-decoration: underline; text-underline-offset: .15em; }
.upload-actions { margin: .75rem 0 1rem; }
.button:disabled { opacity: .45; cursor: default; }

.photo-remove { margin: 0 0 1rem; }

/* Photos page: the order of the photos, by dragging thumbnails. */
.photo-order { display: flex; flex-wrap: wrap; gap: .35rem; list-style: none; margin: 0 0 .6rem; padding: 0; }
.photo-order li { position: relative; width: 56px; height: 56px; cursor: grab; border: 1px solid var(--rule); border-radius: 2px; background: #f4f5f6; }
.photo-order li img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-order li.dragging { opacity: .35; }
.photo-order li:hover { border-color: var(--quiet); }
.photo-order li.active { border: 2px solid var(--olive); }
.photo-order li:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.photo-order-new {
    position: absolute;
    right: 3px;
    bottom: 3px;
    padding: 0 .3rem;
    font-size: .7rem;
    line-height: 1.1rem;
    color: #fff;
    background: var(--olive);
    border-radius: 2px;
}
.photo-editor .gallery-stage { height: 20rem; margin-bottom: .6rem; }
.photo-order-hint { margin: -.25rem 0 .75rem; }
.photo-fields { padding-top: .3rem; }
.photo-order-number {
    position: absolute;
    left: 3px;
    top: 3px;
    min-width: 1.2rem;
    padding: 0 .25rem;
    font-size: .75rem;
    line-height: 1.2rem;
    text-align: center;
    color: #fff;
    background: rgba(31, 35, 40, .75);
    border-radius: 2px;
    font-variant-numeric: tabular-nums;
}
.photo-order-changed { margin: -.3rem 0 1rem; color: var(--olive-dark); }


/* Record page: the same sheet as the forms, read-only. */
.record-page { max-width: 50rem; margin: 0 auto; }
.record-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem 1.5rem; }
.record-title h1 { margin-bottom: 0; }
/* Delete: a bin beside the title; the confirm box opens under the title. */
.record-title-main { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.record-delete-button { flex: none; width: 28px; height: 28px; padding: 0; color: var(--quiet); }
.record-delete-button:hover, .record-delete-button[aria-expanded="true"] { color: var(--danger); background: var(--danger-wash); }
.record-header .delete-confirm { margin: .75rem 0 .25rem; }
.record-kind { display: flex; gap: .4rem; margin: .4rem 0 0; }
.record-header .catalogue { margin-bottom: 0; }

/* A section edited in place: the pencil next to its heading opens its
   fields; while open, save and cancel icons take the pencil's place. */
.section-head { display: flex; align-items: center; gap: .4rem; margin: 0 0 .55rem; }
.section-head h2 { margin: 0; }
.section-actions { display: inline-flex; gap: .1rem; }
.section-actions .icon-button { width: 28px; height: 28px; padding: 0; }
.edit-section .js-section-save,
.edit-section .js-section-cancel,
.edit-section .section-fields { display: none; }
.edit-section.is-editing .js-section-edit,
.edit-section.is-editing .section-view { display: none; }
.edit-section.is-editing .js-section-save,
.edit-section.is-editing .js-section-cancel { display: inline-flex; }
.edit-section.is-editing .section-fields { display: block; }
.edit-section { position: relative; }
.edit-section.is-editing::before {
    content: "";
    position: absolute;
    left: -.9rem;
    top: .9rem;
    bottom: .6rem;
    width: 3px;
    border-radius: 2px;
    background: rgba(75, 83, 32, .35);
}
.icon-button.icon-save { color: var(--olive); }
.section-busy { margin: -.2rem 0 .6rem; color: var(--danger); font-size: .85rem; }
.facts { display: grid; grid-template-columns: 10rem minmax(0, 1fr); gap: .3rem 1.25rem; margin: 0 0 .75rem; }
.facts dt { font-weight: 600; }
.facts dd { margin: 0; font-variant-numeric: tabular-nums lining-nums; }
.empty { color: var(--quiet); }
.record-links { list-style-type: upper-alpha; margin: 0 0 .75rem; padding-left: 1.6rem; }
.record-links li { margin-bottom: .15rem; }
.record-link { margin: 0 0 .75rem; }
.record-note { line-height: 1.55; max-width: 42rem; margin-bottom: .75rem; }
/* Research Notes one by one: the note, then who added it and when, with its
   pencil and bin; "+ Add research note" below the notes. */
.notes-section .note-block { max-width: 42rem; padding: .55rem 0 .45rem; border-bottom: 1px solid var(--rule-faint); }
.notes-section .note-block:last-child { border-bottom: 0; }
.notes-section .note-block .record-note { margin-bottom: .2rem; }
.notes-section .note-block .record-note > :last-child { margin-bottom: 0; }
.notes-section .note-link .record-note { margin-bottom: 0; }
.note-foot { display: flex; align-items: center; gap: .6rem; min-height: 28px; }
.note-meta { color: var(--quiet); font-size: .8rem; }
.note-foot .section-actions { margin-left: auto; }
.note-block .js-note-delete { display: inline-flex; }
.note-block.is-editing .js-note-delete { display: none; }
.note-block .section-actions .icon-button { color: var(--quiet); }
.note-block .section-actions .icon-button:hover { color: var(--olive-dark); }
.note-block .section-actions .icon-delete:hover { color: var(--danger); background: var(--danger-wash); }
.note-block.is-editing .section-fields { margin: .1rem 0 .35rem; }
.note-confirm { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin: .35rem 0 .2rem; font-size: .875rem; }
.note-confirm[hidden] { display: none; }
.notes-section .note-new { border-bottom: 0; padding-top: .75rem; }
.add-note-button { display: inline-flex; align-items: center; gap: .35rem; }
.note-new .note-new-foot { display: none; }
.note-new.is-editing .note-new-foot { display: flex; }
.notes-empty { margin: 0; }
.record-note p { margin: 0 0 .6rem; }
.record-note li > p, .message-bubble li > p { margin: 0; }
.record-note ul, .record-note ol { margin: 0 0 .75rem; padding-left: 1.4rem; }
.record-note a, .record-links a, .record-link a { color: var(--olive); }
/* Photo gallery: one large photo in a fixed-height box, thumbnails to switch. */
.gallery-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 24rem;
    background: #f4f5f6;
    border-radius: 2px;
}
.gallery-stage img { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; }
.gallery-thumbs { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0 .6rem; }
.gallery-thumb {
    padding: 0;
    width: 56px;
    height: 56px;
    border: 2px solid transparent;
    border-radius: 2px;
    background: none;
    cursor: pointer;
    opacity: .7;
}
.gallery-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gallery-thumb:hover { opacity: 1; }
.gallery-thumb.active { border-color: var(--olive); opacity: 1; }
.gallery-thumb:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.gallery-info { max-width: 42rem; margin: .4rem 0 .75rem; }
.gallery-info p { margin: 0 0 .2rem; }
.photo-facts { gap: .3rem 1.25rem; margin: 0 0 .4rem; }
/* Original file names are long: smaller and quieter, so they do not dominate. */
.photo-file { overflow-wrap: anywhere; font-size: .8rem; line-height: 1.45; color: var(--quiet); }
.facts dd.photo-file { padding-top: .1rem; }
.fixed-value.photo-file { padding-top: .4rem; }
/* The file name is shown only on request. */
.file-reveal summary { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; margin: -2px 0 0 -4px; border-radius: 3px; cursor: pointer; color: var(--quiet); list-style: none; }
.file-reveal summary::-webkit-details-marker { display: none; }
.file-reveal summary:hover { color: var(--olive-dark); background: var(--olive-wash); }
.file-reveal .chevron { transition: transform .15s; }
.file-reveal[open] .chevron { transform: rotate(180deg); }
.file-reveal .file-name { display: block; margin-top: .1rem; }

@media (max-width: 40rem) {
    .gallery-stage,
    .photo-editor .gallery-stage { height: 18rem; }
    .facts { grid-template-columns: 1fr; gap: .1rem; }
    .facts dd { margin-bottom: .5rem; }
}

/* The upload tile after the thumbnails, and its pop-up. */
.photo-order li.photo-add { cursor: default; border: 1px dashed #9aa0a8; background: #fafbfa; }
.photo-order li.photo-add:hover { border-color: var(--olive); }
.photo-add button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 0;
    color: var(--quiet);
    background: none;
    border: 0;
    cursor: pointer;
}
.photo-add button:hover { color: var(--olive); }
.photo-add .icon { width: 20px; height: 20px; }
.upload-popup { width: min(92vw, 22rem); z-index: 20; }
.upload-popup .drop-zone { padding: 1rem; }
.upload-popup .upload-actions { margin: .6rem 0 0; }
.photo-editor-empty .photo-order { margin-bottom: .4rem; }

/* Links in the list tables: olive, underlined only on hover (calmer rows). */
.list-table td > a { text-decoration: none; }
.list-table td > a:hover { text-decoration: underline; }

/* Change log */
.changelog-page { width: min(100%, 62rem); }
.log-filters { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; margin-bottom: .9rem; }
.log-filters label { display: inline-flex; align-items: center; gap: .45rem; color: var(--quiet); font-size: .9rem; }
.log-filters select { max-width: 22rem; color: var(--ink); }
.log-clear { font-size: .9rem; }
.log-table { width: 100%; }
.log-table td { vertical-align: top; padding-top: 6px; padding-bottom: 6px; border-bottom: 0; border-top: 1px solid var(--rule-faint); }
.log-table .log-record, .log-table .log-what { white-space: normal; }
.log-table .log-record { min-width: 12rem; max-width: 18rem; }
.log-table .log-when { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--quiet); }
.log-table .log-who { white-space: nowrap; }
.log-table tr.log-same td { border-top-color: transparent; }
.log-table .log-what { max-width: 34rem; }
.log-value { white-space: pre-line; overflow-wrap: anywhere; }
.log-detail { color: var(--quiet); }
.log-arrow { color: var(--quiet); padding: 0 .2rem; }
.log-long { display: inline; }
.log-long summary { display: inline; cursor: pointer; color: var(--ink); }
.log-long summary::marker { content: ""; }
.log-long[open] summary { display: none; }
.log-more { margin: 1rem 0 0; }
.log-off { margin: 0 0 1rem; padding: .55rem .8rem; border-left: 3px solid var(--quiet); background: #f6f7f8; max-width: 42rem; }

/* Photo viewer: the photo over the page, as large as the window allows. */
.viewer {
    padding: 0;
    margin: auto;
    max-width: 100vw;
    max-height: 100vh;
    width: 100vw;
    height: 100vh;
    border: 0;
    background: transparent;
    overflow: hidden;
}
.viewer::backdrop { background: rgba(20, 22, 24, .9); }
.viewer[open] { display: flex; align-items: center; justify-content: center; }
.viewer-figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: .6rem; max-width: calc(100vw - 7rem); }
.viewer-image { display: block; max-width: calc(100vw - 7rem); max-height: calc(100vh - 6rem); width: auto; height: auto; background: #fff; }
.viewer-caption { color: #e8e9ea; font-size: .9rem; text-align: center; }
.viewer-close,
.viewer-prev,
.viewer-next {
    position: fixed;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    color: #fff;
    background: rgba(255, 255, 255, .08);
    border: 0;
    border-radius: 50%;
    font: 400 1.9rem/1 var(--sans);
    cursor: pointer;
}
.viewer-close:hover,
.viewer-prev:hover,
.viewer-next:hover { background: rgba(255, 255, 255, .2); }
.viewer-close { top: 1rem; right: 1rem; font-size: 1.6rem; }
.viewer-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.viewer-next { right: 1rem; top: 50%; transform: translateY(-50%); }
.viewer button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.js-gallery .gallery-stage { cursor: zoom-in; }

@media (max-width: 40rem) {
    .viewer-figure, .viewer-image { max-width: calc(100vw - 1.5rem); }
    .viewer-prev, .viewer-next { top: auto; bottom: 1rem; transform: none; }
}

/* Discussion: the button next to the record title, and the panel at the right. */
:root { --panel-w: 22rem; }
.discussion-button {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .3rem .75rem; font: inherit; font-size: .925rem; color: var(--ink);
    background: #fff; border: 1px solid #b9bec5; border-radius: 3px; cursor: pointer;
}
.discussion-button:hover, .discussion-button[aria-expanded="true"] { border-color: var(--olive); color: var(--olive-dark); }
.count-badge {
    display: inline-block; min-width: 1.25rem; padding: 0 .35rem; border-radius: 999px;
    background: var(--olive); color: #fff; font-size: .75rem; font-weight: 600; line-height: 1.25rem; text-align: center;
    font-variant-numeric: tabular-nums;
}
.count-badge[hidden] { display: none; }

.discussion-panel {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 20;
    width: var(--panel-w); max-width: 100vw;
    display: flex; flex-direction: column;
    background: var(--paper); border-left: 1px solid var(--rule);
}
.discussion-panel[hidden] { display: none; }
/* Wide screens: the page moves left, so the panel covers nothing. */
@media (min-width: 64rem) {
    body.discussion-open { padding-right: var(--panel-w); }
}
.discussion-head { display: flex; align-items: flex-start; gap: .5rem; padding: .7rem 12px .6rem 16px; background: var(--header); border-bottom: 1px solid #d9d9d9; }
.discussion-heading { flex: 1; min-width: 0; }
.discussion-head h2 { margin: 0; font-size: 1.05rem; }
.discussion-head h2.discussion-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Who takes part, under the title; a click shows the people list. */
.discussion-members {
    display: block; max-width: 100%; margin: .05rem 0 0; padding: 0;
    font: inherit; font-size: .85rem; color: var(--quiet); text-align: left;
    background: none; border: 0; cursor: pointer;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.discussion-members:hover, .discussion-members[aria-expanded="true"] { color: var(--ink); text-decoration: underline; }
.discussion-members[hidden], .discussion-people[hidden] { display: none; }
.discussion-head .icon-button { width: 28px; height: 28px; padding: 0; }
.discussion-back { display: none; }

.discussion-people { padding: .55rem 16px; border-bottom: 1px solid var(--rule); font-size: .875rem; }
.discussion-people:empty { display: none; }
.people-intro { margin: 0 0 .4rem; color: var(--quiet); }
.people-intro:last-child { margin-bottom: 0; }
.people-line { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.person-chip { display: inline-flex; align-items: center; gap: .1rem; padding: .05rem .2rem .05rem .5rem; border: 1px solid var(--rule); border-radius: 999px; background: #fff; }
.person-chip.is-me { color: var(--quiet); }
.person-chip:not(:has(.chip-remove)) { padding-right: .5rem; }
.chip-remove { border: 0; background: none; color: var(--quiet); cursor: pointer; font: inherit; line-height: 1; padding: .1rem .3rem; border-radius: 999px; }
.chip-remove:hover { background: var(--olive-wash); color: var(--ink); }
.add-person { color: var(--olive); font-size: .875rem; }
.person-finder { position: relative; flex: 1; min-width: 9rem; }
.person-finder input { width: 100%; height: 1.8rem; font-size: .875rem; padding: 0 .45rem; }
.finder-list { list-style: none; margin: .2rem 0 0; padding: .2rem 0; border: 1px solid var(--rule); border-radius: 3px; background: #fff; max-height: 11rem; overflow-y: auto; }
.finder-list li { padding: .25rem .55rem; cursor: pointer; }
.finder-list li:hover, .finder-list li:focus { background: var(--olive-wash); outline: none; }
.people-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .45rem; }

.button.small, .button-secondary.small { padding: .15rem .6rem; font-size: .825rem; }

.discussion-messages { flex: 1; overflow-y: auto; padding: .75rem 12px; display: flex; flex-direction: column; gap: .7rem; }
.discussion-note { color: var(--quiet); margin: auto 0; text-align: center; font-size: .9rem; }
.message { display: flex; flex-direction: column; max-width: 88%; align-self: flex-start; }
.message.mine { align-self: flex-end; align-items: flex-end; }
.message.is-editing { max-width: 100%; width: 100%; }
.message-meta { font-size: .75rem; color: var(--quiet); margin: 0 .2rem .15rem; }
.message-author { font-weight: 600; color: var(--ink); }
.message.mine .message-author { font-weight: 400; color: var(--quiet); }
.message-edited { font-style: italic; }
.message-bubble { padding: .45rem .7rem; border-radius: 8px; background: var(--rule-faint); line-height: 1.5; overflow-wrap: anywhere; }
.message.mine .message-bubble { background: var(--olive-wash); }
.message.deleted .message-bubble { background: none; border: 1px dashed var(--rule); color: var(--quiet); }
.message-bubble > :first-child { margin-top: 0; }
.message-bubble > :last-child { margin-bottom: 0; }
.message-bubble p { margin: 0 0 .5rem; }
.message-bubble ul, .message-bubble ol { margin: 0 0 .5rem; padding-left: 1.3rem; }
.message-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .2rem; font-size: .8rem; color: var(--quiet); }
.message-actions { gap: .15rem; }
.message-actions span { margin-right: .3rem; }
.message-icon { width: 24px; height: 24px; padding: 0; }
.message-icon .icon { width: 14px; height: 14px; }
.message-icon.icon-delete:hover, .message-icon.is-danger { color: var(--danger); }
.message-icon.icon-delete:hover, .message-icon.is-danger:hover { background: var(--danger-wash); }
.message .message-actions { visibility: hidden; }
.message:hover .message-actions, .message:focus-within .message-actions, .message.is-editing .message-actions, .message-actions:has(.js-delete-yes) { visibility: visible; }
@media (hover: none) { .message .message-actions { visibility: visible; } }
.message-editor { width: 100%; }
.message-editor .note-text { min-height: 2.5rem; }
.message-new { display: flex; align-items: center; gap: .5rem; color: var(--olive); font-size: .75rem; font-weight: 600; }
.message-new::before, .message-new::after { content: ""; flex: 1; border-top: 1px solid var(--olive); }

.discussion-error { margin: 0; padding: .45rem 16px; background: var(--danger-wash); color: var(--danger); font-size: .85rem; }
.discussion-error[hidden] { display: none; }
.discussion-compose { padding: .55rem 12px .7rem; border-top: 1px solid var(--rule); }
.discussion-compose[hidden] { display: none; }
.compose-editor .note-body { max-height: 12rem; overflow-y: auto; }
.compose-editor .note-text { min-height: 2.6rem; }
.compose-editor .note-link-box { margin: .2rem 0 0; flex-wrap: wrap; }
.compose-editor .note-link-box input { width: 100%; max-width: none; }
.compose-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .35rem; }
.compose-foot .hint { margin: 0; font-size: .75rem; color: var(--quiet); }
.send-button { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border: 0; border-radius: 3px; background: var(--olive); color: #fff; cursor: pointer; }
.send-button:hover { background: var(--olive-dark); }
.send-button .icon { width: 16px; height: 16px; }

/* Phones: the panel fills the screen, with a back arrow. */
@media (max-width: 40rem) {
    .discussion-panel { width: 100vw; border-left: 0; }
    .discussion-back { display: inline-flex; }
    .discussion-close { display: none; }
    .compose-foot .hint { display: none; }
}

/* New messages in the menu: an icon with a count, and a drop-down per record. */
.inbox { position: relative; align-self: center; }
.inbox-button {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 28px; padding: 0; color: var(--quiet); background: none; border: 0; border-radius: 3px; cursor: pointer;
}
.inbox-button:hover, .inbox-button[aria-expanded="true"] { color: var(--ink); background: rgba(0, 0, 0, .06); }
.inbox-button .icon { width: 18px; height: 18px; }
.inbox-button .count-badge { position: absolute; top: -5px; right: -7px; min-width: 1.1rem; line-height: 1.1rem; font-size: .7rem; padding: 0 .3rem; }
.inbox-menu {
    position: absolute; top: calc(100% + 6px); right: -4px; z-index: 30;
    width: 22rem; max-width: calc(100vw - 24px);
    background: #fff; border: 1px solid var(--rule); border-radius: 4px; box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
    font-size: .875rem;
}
.inbox-menu[hidden] { display: none; }
.inbox-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: .55rem .8rem; border-bottom: 1px solid var(--rule); }
.inbox-head strong { font-weight: 600; color: var(--ink); }
.site-menu .inbox-head .link-button { color: var(--olive); font-size: .825rem; padding: 0; }
.inbox-head .link-button:hover { background: none; text-decoration: underline; }
.inbox-list { max-height: 60vh; overflow-y: auto; }
/* The drop-down uses the rows of the Discussions page, a little smaller. */
.site-menu .inbox-list a.chat-row { padding: .55rem .8rem; gap: .65rem; border-bottom: 1px solid var(--rule-faint); color: var(--ink); }
.site-menu .inbox-list a.chat-row:last-child { border-bottom: 0; }
.site-menu .inbox-list a.chat-row:hover { background: var(--olive-wash); border-bottom-color: var(--rule-faint); }
.inbox-list .chat-picture { width: 38px; height: 38px; }
.inbox-list .chat-initial { font-size: 1rem; }
.inbox-list .chat-preview { font-size: .85rem; }
.inbox-empty { margin: 0; padding: .9rem .8rem; color: var(--quiet); }

/* Discussions page: a chat list, as in WhatsApp or Teams. */
.chat-list-page { max-width: 38rem; margin: 0 auto; }
.chat-list-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: .6rem; margin-bottom: 0; border-bottom: 1px solid var(--rule); }
.chat-list-header h1 { margin: 0; }
.chat-filters { display: flex; gap: .4rem; }
.chat-filters a {
    padding: .2rem .8rem; border: 1px solid var(--rule); border-radius: 999px;
    color: var(--quiet); font-size: .875rem; text-decoration: none;
}
.chat-filters a:hover { border-color: var(--quiet); color: var(--ink); }
.chat-filters a[aria-current="page"] { background: var(--olive-wash); border-color: var(--olive); color: var(--olive-dark); }
.chat-list { list-style: none; margin: 0; padding: 0; }
.chat-row {
    display: flex; align-items: center; gap: .8rem; padding: .65rem .5rem;
    color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule-faint);
}
.chat-row:hover { background: #f6f7f8; color: var(--ink); }
.chat-picture { flex: none; width: 46px; height: 46px; border-radius: 50%; object-fit: cover; background: var(--rule-faint); }
.chat-initial { display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-weight: 600; font-size: 1.15rem; color: var(--olive-dark); background: var(--olive-wash); }
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.chat-line { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.chat-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-time { flex: none; font-size: .8rem; color: var(--quiet); font-variant-numeric: tabular-nums; }
.chat-row.has-new .chat-time { color: var(--olive); font-weight: 600; }
.chat-preview { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--quiet); font-size: .9rem; }
.chat-row.has-new .chat-preview { color: var(--ink); }
.chat-line .count-badge { flex: none; align-self: center; }
.inbox-foot { display: block; padding: .5rem .8rem; border-top: 1px solid var(--rule); font-size: .825rem; }
.site-menu a.inbox-all { color: var(--olive); border-bottom: 0; padding: 0; }
.site-menu a.inbox-all:hover { text-decoration: underline; border-bottom: 0; }
/* The full width of the list, with the corners of the other search boxes. */
.chat-search { margin: .7rem 0 .2rem; }
.chat-search input { width: 100%; }
.chat-list mark { background: var(--olive-wash); color: var(--ink); font-weight: 600; padding: 0 .05em; border-radius: 2px; }
.chat-none { padding: .75rem .5rem; }

/* The area switch under the site title: Research or Book. */
.area-switch { position: relative; }
.area-button { display: inline-flex; align-items: center; gap: .3rem; padding: 0; background: none; border: 0; cursor: pointer; }
.area-caret { color: var(--quiet); transition: transform .15s; }
.area-button:hover .area-caret, .area-button[aria-expanded="true"] .area-caret { color: var(--ink); }
.area-button[aria-expanded="true"] .area-caret { transform: rotate(180deg); }
.area-menu {
    position: absolute; top: calc(100% + 8px); left: -8px; z-index: 30; min-width: 11rem; padding: .3rem 0;
    background: #fff; border: 1px solid var(--rule); border-radius: 4px; box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
}
.area-menu[hidden] { display: none; }
.area-menu a { display: flex; align-items: center; gap: .5rem; padding: .4rem .8rem .4rem 1.9rem; color: var(--ink); text-decoration: none; position: relative; }
.area-menu a:hover { background: var(--olive-wash); }
.area-menu a[aria-current="true"] { font-weight: 600; }
.area-menu a[aria-current="true"]::before { content: "✓"; position: absolute; left: .75rem; color: var(--olive); font-weight: 600; }

/* Writing pages */
.writing-page { max-width: 50rem; margin: 0 auto; }
.writing-name { margin: 0 0 .15rem; color: var(--quiet); font-size: .9rem; }
.writing-actions { display: flex; gap: .75rem; margin: 1rem 0; }
.choices { display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; padding-top: .3rem; }
.choice { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; }
.choice input { width: 1rem; height: 1rem; margin: 0; accent-color: var(--olive); cursor: pointer; }
.choices .js-label-text { margin-left: 1.5rem; max-width: 12rem; }
.choices .js-label-text:disabled { background: var(--rule-faint); color: var(--quiet); }
.choices .hint { margin-top: .1rem; }
.quiet { color: var(--quiet); }
.writing-list-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; padding-bottom: .7rem; margin-bottom: 0; border-bottom: 2px solid var(--ink); }
.writing-list-header h1 { margin: 0; }
.writing-new { display: flex; gap: .6rem; }
.writing-list { list-style: none; margin: 0; padding: 0; }
.writing-row { display: flex; align-items: baseline; gap: 1rem; padding: .7rem .4rem; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule-faint); }
.writing-row:hover { background: #f6f7f8; color: var(--ink); }
.writing-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.writing-title { font-family: var(--serif); font-weight: 600; font-size: 1.1rem; }
.writing-row:hover .writing-title { text-decoration: underline; }
.writing-subtitle { color: var(--quiet); font-size: .9rem; }
.writing-type { flex: none; font-size: .8rem; color: var(--quiet); border: 1px solid var(--rule); border-radius: 3px; padding: 0 .4rem; }
.writing-date { flex: none; width: 6.5rem; text-align: right; font-size: .85rem; color: var(--quiet); font-variant-numeric: tabular-nums; }

/* New book / New article pop-up */
.writing-dialog {
    width: min(40rem, calc(100vw - 24px)); max-height: calc(100vh - 48px); padding: 0;
    border: 1px solid var(--rule); border-radius: 6px; box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
    color: var(--ink); background: var(--paper);
}
.writing-dialog::backdrop { background: rgba(31, 35, 40, .45); }
.writing-dialog[open] { display: flex; }
.writing-dialog form { display: flex; flex-direction: column; width: 100%; max-width: none; margin: 0; max-height: calc(100vh - 50px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1.1rem .7rem; border-bottom: 2px solid var(--ink); }
.dialog-head h2 { margin: 0; font-size: 1.3rem; }
.dialog-head .icon-button { width: 28px; height: 28px; padding: 0; }
.dialog-body { overflow-y: auto; padding: 0 1.1rem .4rem; }
.dialog-body .sheet-section { padding-top: .8rem; }
.dialog-body .sheet-section:last-of-type { border-bottom: 0; }
.dialog-body .form-row { grid-template-columns: 8.5rem minmax(0, 1fr); }
.dialog-note { margin: .2rem 0 .6rem; }
.dialog-error { margin: .8rem 0 0; padding: .5rem .75rem; border-left: 3px solid var(--danger); background: var(--danger-wash); color: var(--danger); }
.dialog-error[hidden] { display: none; }
.dialog-foot { display: flex; gap: .75rem; padding: .7rem 1.1rem; border-top: 1px solid var(--rule); background: #fafafa; }
@media (max-width: 40rem) {
    .dialog-body .form-row { grid-template-columns: 1fr; }
}

/* A book or article, NEO-style in our colours: white sheets on light grey,
   a quiet bottom bar, the chapter panel sliding in from the left margin.
   Page measures after NEO 1.3.0 (Hugh Howey, MIT licence). */
:root { --bar-h: 40px; --panel-w: 17rem; }
body.book-view { background: #eceef0; }
body.book-view main { padding: 0 16px calc(var(--bar-h) + 2rem); }
body.book-view.chapters-pinned main { padding-left: calc(var(--panel-w) + 16px); }
.sheets { padding-top: 40px; }
.sheet {
    width: var(--page-w); max-width: 100%; margin: 0 auto 36px; padding: 70px 72px 90px;
    /* the page's own shape (Settings, Page size); a long chapter grows beyond it */
    aspect-ratio: var(--page-ratio, 8.27 / 11.69);
    background: #fff; color: var(--ink); border: 1px solid #dfe2e5; box-shadow: 0 2px 14px rgba(31, 35, 40, .07);
    font-family: var(--serif); font-size: 17px; line-height: 1.75;
}
.title-sheet { display: flex; flex-direction: column; justify-content: center; text-align: center; }
.tp-title { font-family: var(--serif); font-size: 34px; font-weight: 700; line-height: 1.2; margin: 0; }
.tp-subtitle { margin: 14px 0 0; font-size: 18px; font-style: italic; color: var(--quiet); }
.tp-authors { margin: 46px 0 0; font-family: var(--sans); font-size: 13px; letter-spacing: 3px; text-transform: uppercase; color: var(--quiet); }
.sheet-head, .chapter-head {
    margin: 0 0 44px; text-align: center; font-family: var(--serif); font-weight: 400;
    font-size: 15px; line-height: 1.5; letter-spacing: 4px; text-transform: uppercase; color: var(--quiet);
}
.chapter-head-empty { letter-spacing: 1px; text-transform: none; font-style: italic; color: #a7adb4; }
.sheet .ghost { margin: 0 0 1em; font-style: italic; color: #8c939c; }
.sheet-later { margin: 0; font-family: var(--sans); font-size: 14px; line-height: 1.6; color: #8c939c; }
.chapter-sheet { scroll-margin-top: calc(var(--header-h, 50px) + 16px); }

/* The bottom bar: quiet until the mouse comes near. */
.book-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; height: var(--bar-h);
    display: flex; align-items: center; gap: 1.25rem; padding: 0 16px;
    background: rgba(255, 255, 255, .96); border-top: 1px solid var(--rule);
    font-size: .85rem; opacity: .55; transition: opacity .15s ease;
}
.book-bar:hover, .book-bar:focus-within { opacity: 1; }
.book-back { color: var(--quiet); text-decoration: none; white-space: nowrap; }
.book-back:hover { color: var(--ink); }
.book-bar-button { padding: .2rem .55rem; font: inherit; color: var(--quiet); background: none; border: 1px solid transparent; border-radius: 3px; cursor: pointer; }
.book-bar-button:hover { color: var(--ink); border-color: var(--rule); }
.book-tabs { flex: 1; display: flex; justify-content: center; gap: .25rem; }
.book-tabs a { padding: .3rem .9rem; color: var(--quiet); text-decoration: none; border-radius: 3px; }
.book-tabs a:hover { color: var(--ink); background: var(--rule-faint); }
.book-tabs a[aria-current="page"] { color: var(--olive-dark); background: var(--olive-wash); font-weight: 600; }
.book-words { color: var(--quiet); font-variant-numeric: tabular-nums; white-space: nowrap; }
.book-gear { width: 28px; height: 28px; padding: 0; }

/* The chapter panel */
.chapter-hotzone { position: fixed; left: 0; top: var(--header-h, 50px); bottom: var(--bar-h); z-index: 20;
    width: clamp(16px, calc((100vw - var(--page-w, 760px)) / 2 - 40px), 96px); }
.chapter-panel {
    position: fixed; left: 0; top: var(--header-h, 50px); bottom: var(--bar-h); z-index: 24; width: var(--panel-w);
    display: flex; flex-direction: column; overflow-y: auto;
    background: #fff; border-right: 1px solid var(--rule); box-shadow: 4px 0 18px rgba(31, 35, 40, .06);
    transform: translateX(-100%); transition: transform .18s ease; font-size: .875rem;
}
.chapter-panel.open { transform: translateX(0); }
body.chapters-pinned .chapter-panel { box-shadow: none; }
.chapter-panel-head { display: flex; align-items: center; justify-content: space-between; padding: .8rem .75rem .5rem 1rem;
    font-size: .75rem; letter-spacing: 2px; text-transform: uppercase; color: var(--quiet); }
.chapter-panel-head .icon-button { width: 26px; height: 26px; padding: 0; }
.chapter-panel-head .icon-button[aria-pressed="true"] { color: var(--olive); background: var(--olive-wash); }
.chapter-list { list-style: none; margin: 0; padding: 0; }
.chapter-item { position: relative; padding: .5rem 2rem .55rem 1rem; border-left: 3px solid transparent; border-bottom: 1px solid var(--rule-faint); cursor: grab; }
.chapter-item:hover { background: #f6f7f8; border-left-color: var(--olive); }
.chapter-item.dragging { opacity: .4; }
.chapter-row { display: flex; align-items: baseline; gap: .5rem; }
.chapter-num { flex: none; min-width: 1.2rem; color: var(--quiet); font-variant-numeric: tabular-nums; cursor: pointer; }
.chapter-title { flex: 1; min-width: 0; font-weight: 600; color: var(--ink); }
input.chapter-title { height: auto; padding: 0; border: 0; border-bottom: 1px dashed transparent; border-radius: 0; background: none; font: inherit; font-weight: 600; }
input.chapter-title:focus { box-shadow: none; border-bottom-color: var(--rule); }
input.chapter-title::placeholder { font-weight: 400; font-style: italic; color: #a7adb4; }
.chapter-words { flex: none; font-size: .75rem; color: #a7adb4; font-variant-numeric: tabular-nums; }
.chapter-summary { display: block; width: 100%; margin: .15rem 0 0 1.7rem; width: calc(100% - 1.7rem); padding: 0; border: 0; resize: none; overflow: hidden;
    background: none; font: inherit; font-size: .8rem; line-height: 1.45; color: var(--quiet); min-height: 0; height: auto; }
textarea.chapter-summary:focus { box-shadow: none; outline: none; color: var(--ink); }
textarea.chapter-summary::placeholder { font-style: italic; color: #b9bec5; }
p.chapter-summary { margin-bottom: 0; }
.chapter-delete { position: absolute; top: .4rem; right: .5rem; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 3px;
    background: none; color: #a7adb4; font-size: 1rem; line-height: 1; cursor: pointer; opacity: 0; }
.chapter-item:hover .chapter-delete, .chapter-delete:focus { opacity: 1; }
.chapter-delete:hover { color: var(--danger); background: var(--danger-wash); }
.chapter-confirm { margin: .35rem 0 0 1.7rem; font-size: .8rem; color: var(--danger); }
.chapter-confirm .link-button { padding: 0 .2rem; font-size: .8rem; color: var(--quiet); text-decoration: underline; }
.chapter-confirm .link-button.danger { color: var(--danger); font-weight: 600; }
.chapter-none { padding: .8rem 1rem; color: var(--quiet); font-style: italic; }
.chapter-add { margin: .7rem 1rem; padding: .45rem; border: 1px dashed #b9bec5; border-radius: 4px; background: none; color: var(--quiet); font: inherit; cursor: pointer; }
.chapter-add:hover { color: var(--olive-dark); border-color: var(--olive); }
.chapter-error { margin: 0 1rem .7rem; padding: .4rem .6rem; border-left: 3px solid var(--danger); background: var(--danger-wash); color: var(--danger); font-size: .8rem; }
.chapter-error[hidden] { display: none; }
@media (max-width: 52rem) {
    .sheet { padding: 40px 28px 60px; }
    body.book-view.chapters-pinned main { padding-left: 16px; }
    .book-back span:last-child { display: none; }
}

/* The editor: a toolbar like a word processor's, at the top of the window. */
.editor-toolbar {
    position: sticky; top: 0; z-index: 22; display: flex; flex-wrap: wrap; align-items: center; gap: .15rem;
    margin: 0 -16px; padding: .35rem 16px; background: #fff; border-bottom: 1px solid var(--rule);
    font-size: .85rem;
}
body.book-view.chapters-pinned .editor-toolbar { margin-left: calc(-1 * var(--panel-w) - 16px); padding-left: calc(var(--panel-w) + 16px); }
.tb-button {
    display: inline-flex; align-items: center; justify-content: center; gap: .3rem; min-width: 30px; height: 30px; padding: 0 .4rem;
    color: var(--ink); background: none; border: 1px solid transparent; border-radius: 3px; font: inherit; cursor: pointer;
}
.tb-button:hover:not(:disabled) { background: var(--rule-faint); }
.tb-button.active { background: var(--olive-wash); color: var(--olive-dark); border-color: #c9cfb0; }
.tb-button:disabled { color: #b9bec5; cursor: default; }
.tb-letter { font-family: var(--serif); font-size: 1rem; }
.tb-wide { padding: 0 .6rem; }
.tb-sep { width: 1px; height: 20px; margin: 0 .3rem; background: var(--rule); }
.tb-style, .tb-size { height: 30px; width: auto; padding: 0 .4rem; font-size: .85rem; }
.tb-size { margin-left: .3rem; }
.tb-table-tools { display: inline-flex; align-items: center; gap: .1rem; margin-left: .2rem; padding-left: .3rem; border-left: 1px solid var(--rule); }
.tb-table-tools[hidden] { display: none; }
.tb-table-tools .tb-button[aria-pressed="true"] { background: var(--olive-wash); color: var(--olive-dark); border-color: #c9cfb0; }
.tb-table-tools .tb-button.danger:not(:disabled) { color: var(--danger); }
.tb-status { margin-left: auto; color: var(--quiet); font-size: .8rem; white-space: nowrap; }
.tb-status.ok { color: var(--olive); }
.tb-status.error { color: var(--danger); white-space: normal; }

/* The text on the sheet */
.chapter-body .tiptap { outline: none; min-height: 8em; }
.chapter-body .tiptap > :first-child { margin-top: 0; }
.chapter-body p { margin: 0; text-indent: 1.5em; }
.chapter-body p:first-child, .chapter-body h3 + p, .chapter-body h4 + p, .chapter-body hr + p, .chapter-body blockquote + p, .chapter-body ul + p, .chapter-body ol + p,
.chapter-body p[style*="text-align: center"], .chapter-body p[style*="text-align: right"] { text-indent: 0; }
.chapter-body h3 { margin: 1.4em 0 .5em; font-family: var(--serif); font-size: 1.25em; font-weight: 600; line-height: 1.3; }
.chapter-body h4 { margin: 1.2em 0 .4em; font-family: var(--serif); font-size: 1.05em; font-weight: 600; font-style: italic; line-height: 1.3; }
.chapter-body blockquote { margin: .8em 2em; font-size: .95em; }
.chapter-body blockquote p { text-indent: 0; }
.chapter-body ul, .chapter-body ol { margin: .5em 0; padding-left: 1.8em; }
.chapter-body li p { text-indent: 0; }
/* Figures: the photo, then "Figure 3.2 Caption (credit)". The number is a counter, so it follows every move. */
.book.figures-chapter .chapter-sheet { counter-reset: figure; }
.book.figures-book .js-chapter-sheets { counter-reset: figure; }
.chapter-body figure.figure { margin: 1.4em auto; counter-increment: figure; }
.chapter-body figure.figure[data-size="half"] { width: 50%; }
.chapter-body figure.figure[data-size="page"] { margin: 2em auto; padding: 1.2em 0; border-top: 1px dashed #c9cdd2; border-bottom: 1px dashed #c9cdd2; }
.chapter-body figure.figure[data-size="page"]::before { content: "On a page of its own"; display: block; margin-bottom: .6em; font-family: var(--sans); font-size: .7rem; letter-spacing: .05em; text-transform: uppercase; color: #8c939c; }
.chapter-body figure.figure img { display: block; width: 100%; height: auto; margin: 0 auto; cursor: pointer; background: #eef0f2; }
.chapter-body figure.figure[data-size="page"] img { max-height: 70vh; width: auto; max-width: 100%; }
.chapter-body .fig-line { margin-top: .5em; font-size: .85em; line-height: 1.45; text-indent: 0; }
.chapter-body .fig-label { font-weight: 600; margin-right: .35em; }
.book.figures-none .fig-label { display: none; }
.book:not(.figures-none) .chapter-body .fig-label::before { content: var(--fig-prefix) counter(figure); }
.chapter-body .fig-caption.is-empty::before { content: "Type a caption…"; color: #b9bec5; font-style: italic; pointer-events: none; }
.chapter-body .fig-credit { color: #5d636b; }
.chapter-body figure.figure.ProseMirror-selectednode { outline: 2px solid var(--focus); outline-offset: 4px; }
.chapter-body figure.figure + p { text-indent: 0; }

/* The photo picker */
.photo-picker { width: min(64rem, calc(100vw - 2rem)); max-height: calc(100vh - 3rem); padding: 0; }
.photo-picker[open] { display: flex; flex-direction: column; }
.photo-picker > * { flex: none; }
.picker-filters { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .75rem 1.25rem; border-bottom: 1px solid var(--rule); }
.picker-filters input[type="search"] { flex: 1 1 18rem; }
.photo-picker > .picker-grid { flex: 1 1 auto; min-height: 0; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); grid-auto-rows: max-content; align-items: start; gap: .75rem; padding: 1rem 1.25rem 1.25rem; overflow-y: auto; }
.picker-grid > p { grid-column: 1 / -1; }
.picker-photo { position: relative; display: flex; flex-direction: column; gap: .15rem; padding: 0 0 .4rem; text-align: left; font: inherit; color: var(--ink); background: none; border: 1px solid var(--rule); border-radius: 3px; cursor: pointer; overflow: hidden; }
.picker-photo:hover, .picker-photo:focus-visible { border-color: var(--olive); box-shadow: 0 0 0 2px var(--olive-wash); }
/* The photo keeps its square: never squeezed by the tile's flex layout. */
.picker-photo img { flex: none; display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; background: #eef0f2; }
.picker-record { padding: .2rem .45rem 0; font-size: .8rem; font-weight: 600; line-height: 1.3; }
.picker-link { padding: 0 .45rem; font-size: .75rem; line-height: 1.3; color: var(--olive-dark); }
.picker-title { padding: 0 .45rem; font-size: .75rem; line-height: 1.3; color: var(--quiet); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.picker-book { position: absolute; top: .35rem; left: .35rem; padding: .05rem .35rem; font-size: .68rem; color: #fff; background: var(--olive); border-radius: 2px; }

/* Tables: plain ruled tables for now; the book's table style is still to be decided. */
.chapter-body table { width: 100%; margin: 1em 0; border-collapse: collapse; table-layout: fixed; line-height: 1.45; }
.chapter-body th, .chapter-body td { position: relative; padding: .3em .5em; vertical-align: top; border: 1px solid #b9bec5; }
.chapter-body th { font-weight: 600; text-align: left; background: #f3f4f0; }
.chapter-body td p, .chapter-body th p { text-indent: 0; }
.chapter-body .selectedCell::after { content: ""; position: absolute; inset: 0; background: rgba(110, 120, 60, .15); pointer-events: none; }
.chapter-body table + p { text-indent: 0; }
/* A section break shows as *** (stored as a line). */
.chapter-body hr { border: 0; margin: 1.4em 0; text-align: center; height: auto; }
.chapter-body hr::after { content: "***"; letter-spacing: 8px; color: #8c939c; }
.chapter-body hr.ProseMirror-selectednode { outline: 2px solid var(--focus); }
.chapter-body .tiptap p.is-editor-empty:first-child::before {
    content: attr(data-placeholder); float: left; height: 0; pointer-events: none; color: #b9bec5; font-style: italic;
}
.book-use-warning { margin: .5rem 0; padding: .4rem .7rem; font-size: .9rem; line-height: 1.45; color: #6d5a1f; background: #fbf4dc; border-left: 3px solid #c9a227; }
/* A figure whose photo was deleted from the records. */
.chapter-body figure.figure .fig-missing { display: none; }
.chapter-body figure.figure.is-missing img { display: none; }
.chapter-body figure.figure.is-missing .fig-missing { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; min-height: 10rem; padding: 1.5rem; font-family: var(--sans); font-size: .9rem; text-align: center; color: #6d5a1f; background: #fbf4dc; border: 1px dashed #c9a227; }
.lock-banner { margin: -1.5em 0 1.5em; padding: .4rem .7rem; font-family: var(--sans); font-size: .85rem; line-height: 1.5;
    color: #6d5a1f; background: #fbf4dc; border-left: 3px solid #c9a227; }
.lock-banner[hidden] { display: none; }
.chapter-sheet.is-locked .chapter-body { color: #4a5058; }
.chapter-writer { margin: .1rem 0 0 1.7rem; font-size: .75rem; color: #8a6d16; }
