:root {
    --primary: #a82a2a;
    --primary-hover: #8a2020;
    --ink: #2f2a22;
    --ink-hover: #1d1a15;
    --link: #245a8a;
    --tab: #efe9da;
    --serif: "EB Garamond", Georgia, "Times New Roman", serif;
    --bg: #fdfbf7;
    --panel-bg: #ffffff;
    --surface: #faf8f5;
    --border: #e0dacb;
    --text: #3c352a;
    --text-muted: #6b6252;   /* at least 5:1 on every background, for reading outdoors */
    --hover-scale: 2.2;
    --cell-max: 112px;
    --ok: #2e7d32;
    --warn: #b26a00;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    padding: 20px;
    line-height: 1.4;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); }
code { background: #f1ece0; padding: 1px 5px; border-radius: 3px; font-size: .92em; }
h2 { font-family: var(--serif); font-weight: 600; font-size: 23px; line-height: 1.2; color: var(--ink); margin: 22px 0 8px; }
.muted { color: var(--text-muted); font-size: 15px; }
.small { font-size: 14px; margin-top: 10px; }

/* ── header ── */
.site-header { margin-bottom: 20px; border-bottom: 3px double #8f846f; padding-bottom: 15px; }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
h1 { font-family: var(--serif); font-weight: 600; color: var(--ink); font-size: 32px; line-height: 1.15; margin-bottom: 4px; }
.subtitle { font-size: 15px; color: var(--text-muted); }
.userbox { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 15px; }
.userbox .who { font-weight: 600; }
.role-badge { font-size: 13px; text-transform: uppercase; letter-spacing: .4px; background: #eae3d2; border-radius: 10px; padding: 1px 8px; }

.nav { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; align-items: center; }
.nav-btn {
    background: transparent; border: 1px solid transparent; border-radius: 4px;
    padding: 7px 12px; font-weight: 600; font-size: 15px; cursor: pointer;
}
.nav-btn:hover { background: var(--tab); }
.nav-btn[aria-current="page"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.nav-btn .count { background: #fff; color: var(--ink); border-radius: 10px; padding: 0 7px; margin-left: 4px; font-size: 13px; }
.nav-add { margin-left: auto; }

/* ── buttons & forms ── */
.btn {
    background: var(--primary); color: #fff; border: none; padding: 8px 16px; border-radius: 4px;
    cursor: pointer; font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-secondary { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 1px #8f846f; }
.btn-secondary:hover { background: var(--tab); }
.btn-danger { background: #dc3545; }
.btn-danger:hover { background: #bd2130; }
.btn-ok { background: var(--ok); }
.btn-ok:hover { background: #1f5c23; }
.btn-small { padding: 4px 10px; font-size: 14px; }
.link { background: none; border: none; color: var(--link); text-decoration: underline; cursor: pointer; font-size: inherit; }

.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 14px; font-weight: bold; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .3px; }
.form-group label .muted { text-transform: none; font-weight: normal; letter-spacing: 0; font-size: 13px; }
.form-control { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 15px; background: var(--surface); }
.form-control:focus { outline: none; border-color: var(--ink); background: #fff; }
textarea.form-control { resize: vertical; min-height: 90px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; margin: 10px 0; }
.check input { margin-top: 3px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row .grow { flex: 1; min-width: 120px; }
.form-error { color: #b00020; font-size: 15px; min-height: 1em; margin: 6px 0; }
.form-info { color: var(--text-muted); font-size: 15px; margin: 6px 0; }

.search-bar { display: flex; gap: 8px; margin-top: 12px; max-width: 640px; }
.search-bar input { flex: 1; min-width: 0; }
.search-results {
    margin-top: 10px; max-width: 760px; max-height: 260px; overflow-y: auto;
    background: var(--panel-bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px; font-size: 15px;
}
.search-summary { color: var(--text-muted); font-size: 14px; margin: 0 2px 6px; }
.search-hit {
    display: block; width: 100%; text-align: left; background: var(--surface);
    border: 1px solid var(--border); border-radius: 4px; padding: 6px 10px; margin-bottom: 5px; cursor: pointer;
}
.search-hit:hover { border-color: var(--ink); background: var(--tab); }
.search-hit .where { font-weight: bold; color: var(--ink); margin-right: 6px; }
.search-hit .flaw { font-weight: 600; }
.search-hit .die { color: var(--text-muted); font-size: 13px; margin-left: 6px; }
.search-hit .snippet { display: block; color: var(--text-muted); font-size: 14px; margin-top: 2px; }
.search-hit mark { background: #ffd166; color: inherit; border-radius: 2px; padding: 0 1px; }

.notice { border-radius: 6px; padding: 10px 14px; margin-bottom: 16px; font-size: 15px; }
.notice-warn { background: #fff4d6; border: 1px solid #f0d28a; }

/* ── browse ── */
.issue-bar { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.issue-bar[hidden], .list-row[hidden], .issue-tab[hidden] { display: none; }
.value-row, .list-row { display: flex; flex-wrap: wrap; gap: 6px; }
.value-tab {
    font-family: var(--serif); font-weight: 600; font-size: 17px; line-height: 1.2; padding: 6px 14px; min-width: 52px; cursor: pointer;
    background: var(--tab); border: 1px solid var(--border); border-radius: 4px; color: inherit;
}
.issue-tab {
    font: inherit; font-size: 14px; font-weight: 600; line-height: 1.2; padding: 6px 14px; cursor: pointer;
    background: #fff; border: 1px solid var(--border); border-radius: 999px; color: inherit;
}
.value-tab:hover, .issue-tab:hover { border-color: var(--ink); }
.value-tab[aria-selected="true"], .issue-tab[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.print-name { display: none; }

/* The sheet map picks the pane. On a phone, compact tabs take over. */
.electro-tabs { display: none; grid-template-columns: repeat(var(--tabs, 4), 1fr); gap: 4px; margin-bottom: 14px; }
.tab-btn {
    background: var(--tab); border: 1px solid var(--border); padding: 10px 5px; font-weight: bold; font-size: 14px;
    cursor: pointer; border-radius: 4px 4px 0 0; transition: background-color .2s, color .2s;
}
.tab-btn[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.tab-btn small { display: block; font-weight: normal; font-size: 12px; opacity: .85; margin-top: 1px; }

.main-layout { display: grid; grid-template-columns: 1fr 380px; gap: 20px; }
.panes-container { display: flex; flex-direction: column; gap: 25px; }
.pane-section { background: var(--panel-bg); border: 1px solid var(--border); border-radius: 6px; padding: 15px; box-shadow: 0 2px 4px rgba(0,0,0,.02); }
.pane-title {
    font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: 1.25; margin-bottom: 12px;
    color: var(--ink); border-bottom: 1px solid var(--border); padding-bottom: 6px;
}

.sheet-map { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 480px; }
.sheet-map.many { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); max-width: none; }
.sheet-map.crowded { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.plate { border: 1px solid var(--border); border-radius: 6px; padding: 6px; background: var(--surface); }
.plate-label { font-size: 14px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.plate-panes { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.map-pane {
    background: #fff; border: 1px solid var(--border); border-radius: 4px; padding: 6px 4px; cursor: pointer;
    font-weight: bold; font-size: 14px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.map-pane:hover { border-color: var(--text-muted); }
.map-pane[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.map-pane small { font-weight: normal; font-size: 12px; opacity: .8; }

.grid-tools { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; margin-bottom: 10px; }
.grid-switch { margin: 0; font-weight: 600; align-items: center; }
.grid-switch input { margin-top: 0; }
.grid-key { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; color: var(--text-muted); }
.grid-key li { display: inline-flex; align-items: center; gap: 5px; }
.key-swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); background: var(--surface); }
.key-data { border-color: #3f8f45; background: #e9f3e4; }
.key-pending { border: 1px dashed var(--warn); }
.key-rejected { border: 2px dotted #5c5447; background: #eeeae3; }
.key-count { font-size: 11px; font-weight: bold; background: var(--ink); color: #fff; border-radius: 9px; padding: 0 6px; }
#grid-empty { margin-top: 8px; }

.plating-grid { display: grid; grid-template-columns: repeat(var(--cols, 6), minmax(0, var(--cell-max))); justify-content: start; gap: 5px; }
.plating-grid.only-flaws .grid-cell:not(.filled):not(.active):not(.search-match) { display: none; }
.grid-cell {
    min-height: 40px; border: 1px solid var(--border); background: var(--surface); position: relative; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px; min-width: 0;
    font-size: 13px; font-weight: bold; border-radius: 4px; user-select: none; transition: background-color .2s, border-color .2s;
    scroll-margin-top: 10px;
}
.grid-cell.filled { background: #fff; justify-content: flex-start; min-height: 74px; }
.grid-cell.has-photo { aspect-ratio: 4/5; }
.grid-cell:hover { background: #f0ebd9; border-color: var(--text-muted); z-index: 50; }
.grid-cell:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.grid-cell.active { background: var(--tab); border: 2px solid var(--ink); padding: 3px; }
.grid-cell.has-data { background: #e9f3e4; border-color: #3f8f45; }
.grid-cell.has-data:hover { background: #dcecd5; }
.grid-cell.has-data.active { border-color: var(--ink); background: #dcecd5; }
.grid-cell.has-data::after, .grid-cell.has-pending::after {
    content: ""; position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: #3f8f45;
}
.grid-cell.has-pending:not(.has-data) { border-style: dashed; border-color: var(--warn); }
.grid-cell.has-pending:not(.has-data)::after { background: var(--warn); }
.grid-cell.search-match { box-shadow: 0 0 0 3px #ffd166; }
.cell-name {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; width: 100%;
    font-size: 13px; font-weight: 400; line-height: 1.2; text-align: center; color: var(--text); overflow-wrap: anywhere;
}
.grid-cell.has-photo .cell-name { -webkit-line-clamp: 2; }
.grid-cell.has-rejected .cell-name { color: var(--text-muted); font-style: italic; }
.grid-cell:not(.filled) .cell-name { display: none; }
.cell-count {
    position: absolute; bottom: 3px; left: 3px; font-size: 11px; background: var(--ink); color: #fff;
    border-radius: 8px; padding: 0 5px; z-index: 3;
}
.cell-thumb-container { display: none; width: 100%; flex-grow: 1; min-height: 0; align-items: center; justify-content: center; position: relative; margin-top: 2px; }
.grid-cell.has-photo .cell-thumb-container { display: flex; }
.cell-thumb { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; transition: transform .15s ease-out; }
.grid-cell:hover .cell-thumb {
    transform: scale(var(--hover-scale)); box-shadow: 0 4px 12px rgba(0,0,0,.3); outline: 1px solid var(--ink);
    border-radius: 2px; position: relative; z-index: 100; background: #fff;
}
.cell-number { color: var(--text-muted); }

.details-panel {
    background: var(--panel-bg); border: 1px solid var(--border); border-radius: 6px; padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,.04); position: sticky; top: 20px; align-self: start; max-height: calc(100vh - 40px); overflow-y: auto;
}
.details-close { display: none; position: absolute; top: 8px; right: 10px; background: none; border: none; font-size: 28px; line-height: 1; padding: 4px 8px; cursor: pointer; color: var(--text-muted); }
.panel-heading { font-family: var(--serif); font-size: 23px; font-weight: 600; line-height: 1.2; color: var(--ink); margin-bottom: 6px; border-bottom: 2px solid var(--border); padding-bottom: 8px; }
.place-line { font-size: 14px; color: var(--text-muted); margin-bottom: 12px; }

/* ── entry cards ── */
.card-list { display: flex; flex-direction: column; gap: 12px; }
.entry-card { border: 1px solid var(--border); border-radius: 6px; padding: 12px; background: var(--surface); display: flex; flex-direction: column; gap: 6px; }
.entry-card.is-pending { border-color: var(--warn); }
.entry-card.is-rejected { border-color: #b00020; }
.entry-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.entry-flaw { font-family: var(--serif); font-weight: 600; font-size: 18px; line-height: 1.2; }
.entry-die { font-size: 13px; color: var(--text-muted); }
.badge { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; border-radius: 10px; padding: 1px 8px; color: #fff; background: var(--ok); }
.badge.pending { background: var(--warn); }
.badge.rejected { background: #b00020; }
.entry-thumb { align-self: flex-start; background: #fff; border: 1px solid var(--border); border-radius: 4px; padding: 3px; cursor: zoom-in; }
.entry-thumb img { display: block; max-width: 100%; max-height: 220px; object-fit: contain; }
.entry-desc { white-space: pre-wrap; font-size: 15px; overflow-wrap: anywhere; }
.entry-credit { font-size: 14px; color: var(--text-muted); }
.entry-note { font-size: 14px; background: #fdecea; border-radius: 4px; padding: 6px 8px; }
.entry-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.entry-where { font-weight: 700; color: var(--ink); font-size: 14px; }

.table-wrap { overflow-x: auto; }
.table { border-collapse: collapse; width: 100%; font-size: 15px; background: var(--panel-bg); }
.table th, .table td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; }
.table th { background: #eae3d2; }

/* ── dialogs ── */
.dialog { border: 1px solid var(--border); border-radius: 8px; padding: 22px; width: min(440px, 94vw); background: var(--panel-bg); color: var(--text); margin: auto; }
.dialog-wide { width: min(560px, 94vw); max-height: 92vh; overflow-y: auto; }
.dialog::backdrop { background: rgba(0,0,0,.45); }
.dialog h2 { margin-top: 0; }
.dialog-actions { display: flex; gap: 8px; margin-top: 12px; }
.tabs-inline { display: flex; gap: 4px; margin-bottom: 14px; }
.tabs-inline button { flex: 1; background: #eae3d2; border: 1px solid var(--border); padding: 7px; cursor: pointer; font-weight: 600; font-size: 15px; border-radius: 4px; }
.tabs-inline button[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.ent-preview { display: block; max-width: 160px; max-height: 160px; object-fit: contain; margin-top: 8px; border: 1px solid var(--border); border-radius: 4px; }

.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 1000; display: flex; flex-direction: column;
    justify-content: center; align-items: center; gap: 14px; cursor: zoom-out;
}
.modal-content { max-width: 90%; max-height: 76%; min-height: 0; object-fit: contain; box-shadow: 0 4px 20px rgba(0,0,0,.5); border: 2px solid #fff; border-radius: 4px; }
.modal-caption {
    max-width: min(90%, 720px); max-height: 18vh; overflow-y: auto; color: #fff; background: rgba(255,255,255,.12);
    padding: 10px 16px; border-radius: 6px; font-size: 15px; line-height: 1.5; white-space: pre-wrap; text-align: center;
}
.modal-credit { margin-top: 6px; font-size: 14px; color: #ddd; }
.modal-credit a { color: #ffd166; }
.modal-close { position: absolute; top: 20px; right: 30px; color: #fff; font-size: 40px; font-weight: bold; background: none; border: none; cursor: pointer; }

.toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #2b2620; color: #fff;
    padding: 10px 18px; border-radius: 6px; font-size: 15px; z-index: 2000; box-shadow: 0 4px 12px rgba(0,0,0,.3); max-width: 90vw;
}

.site-footer { margin-top: 40px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 14px; color: var(--text-muted); display: flex; gap: 16px; flex-wrap: wrap; }

@media (max-width: 1024px) {
    .main-layout { grid-template-columns: 1fr; }
    /* The details slide up from the bottom when a position is chosen. */
    .details-panel {
        display: none; position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 500; max-height: 58vh;
        border-radius: 12px 12px 0 0; box-shadow: 0 -4px 18px rgba(0,0,0,.2); padding: 16px;
    }
    body.details-open .details-panel { display: block; }
    body.details-open { padding-bottom: 60vh; }
    .details-close { display: block; }
    .panel-heading { padding-right: 34px; }
}
@media (max-width: 640px) {
    .value-tab { font-size: 16px; padding: 6px 10px; min-width: 44px; min-height: 40px; }
    .issue-tab { min-height: 36px; }
    body { padding: 10px; }
    h1 { font-size: 26px; }
    .electro-tabs { display: grid; }
    .tab-btn { padding: 7px 2px; font-size: 13px; }
    .tab-btn small { display: none; }
    .sheet-map-section { display: none; }
    .plating-grid { grid-template-columns: repeat(var(--cols-phone, 6), minmax(0, 1fr)); gap: 3px; }
    .grid-cell { min-height: 40px; padding: 2px; }
    .grid-cell.filled { min-height: 44px; justify-content: center; }
    .cell-name { display: none !important; }
    .nav-add { margin-left: auto; }
    .nav:not(.open) .nav-btn { display: none; }
    .nav.open .nav-btn { flex: 1 1 100%; text-align: left; }
    .nav.open .nav-add { order: -1; }
    .plan-filter-title { cursor: pointer; width: 100%; text-align: left; padding: 2px 0; }
    .plan-filter-title::after { content: " ▾"; }
    .plan-filter.open .plan-filter-title::after { content: " ▴"; }
    .plan-filter:not(.open) > :not(.plan-filter-title) { display: none; }
    .id-options-watermark, .id-results { grid-template-columns: 1fr; }
}

/* ── Evidence ── */
.evidence-badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 13px; font-weight: bold; border: 1px solid transparent; white-space: nowrap; }
.ev-candidate { background: #fff4d6; color: #7a5200; border-color: #f0d28a; }
.ev-listed { background: #e3f2e4; color: #1f5f23; border-color: #a9d3ac; }
.ev-published { background: #e3edf8; color: #1d4f85; border-color: #a9c5e4; }
.ev-referred { background: #efe9f8; color: #553a85; border-color: #c9b8e4; }
.ev-rejected { background: #eeeae3; color: #5c5447; border-color: #c9c1b2; }
.entry-evidence { font-size: 14px; color: var(--text); margin: 6px 0; padding: 6px 8px; background: var(--surface); border-left: 3px solid var(--border); border-radius: 2px; overflow-wrap: anywhere; }
.entry-reason { font-weight: bold; margin-top: 2px; }
.entry-refs { margin: 4px 0 0; padding-left: 18px; }
.grid-cell.has-rejected { border-style: dotted; border-width: 2px; border-color: #5c5447; background: #eeeae3; }
.evidence-key { margin-top: 16px; background: var(--panel-bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px 14px; font-size: 15px; }
.evidence-key summary { cursor: pointer; font-weight: bold; }
.evidence-key p { margin: 8px 0; }
.evidence-key dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 0; align-items: baseline; }
.evidence-key dd { margin: 0; }
.evidence-fields { border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px 4px; margin: 0 0 12px; min-width: 0; }
.evidence-fields legend { font-weight: bold; font-size: 15px; padding: 0 6px; }
.field-label { display: block; font-weight: bold; font-size: 15px; margin-bottom: 4px; }
.citation-row { display: grid; grid-template-columns: 2fr 70px 2fr auto; gap: 6px; margin-bottom: 6px; align-items: center; }
@media (max-width: 600px) {
    .citation-row { grid-template-columns: 1fr 70px; }
    .citation-row .cit-url { grid-column: 1 / -1; }
    .evidence-key dl { grid-template-columns: 1fr; }
    .evidence-key dd { margin-bottom: 6px; }
}

/* ── Plate states and comparison ── */
.entry-state { font-size: 14px; margin: 6px 0; padding: 6px 8px; background: var(--surface); border-left: 3px solid var(--ink); border-radius: 2px; }
.entry-state-name { font-weight: bold; }
.group-checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 12px; }
.group-checks .check { display: flex; align-items: flex-start; gap: 6px; margin: 2px 0; font-size: 14px; font-weight: normal; text-transform: none; letter-spacing: normal; }
.group-checks .check input { flex: none; width: auto; margin-top: 2px; }
.compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.compare-side { min-width: 0; }
.compare-side > label { display: block; font-weight: bold; font-size: 15px; margin-bottom: 4px; }
.compare-photo { display: block; width: 100%; margin: 8px 0; padding: 0; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); cursor: zoom-in; }
.compare-photo img { display: block; width: 100%; height: 280px; object-fit: contain; }
.compare-nophoto { display: flex; align-items: center; justify-content: center; height: 120px; margin: 8px 0; border: 1px dashed var(--border); border-radius: 4px; color: var(--text-muted); font-size: 15px; }
@media (max-width: 600px) {
    .group-checks, .compare-grid { grid-template-columns: 1fr; }
    .compare-photo img { height: 220px; }
}

/* ── Plate history ── */
.plan-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; padding: 10px 12px; background: var(--panel-bg); border: 1px solid var(--border); border-radius: 6px; font-size: 15px; }
.plan-filter-title { font-weight: bold; color: var(--ink); margin-right: 6px; background: none; border: none; cursor: default; }
.plan-filter label { font-weight: bold; }
.plan-filter .form-control { width: auto; max-width: 100%; }
#filter-group { max-width: 240px; }
.filter-field { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.filter-note { margin: -8px 0 16px; font-size: 15px; }
.tab-btn.not-possible, .map-pane.not-possible { opacity: .45; border-style: dashed; }
.plating-grid.pane-not-possible { opacity: .45; }
.entry-check { font-size: 14px; margin: 6px 0; padding: 6px 8px; background: #fff4d6; border-left: 3px solid var(--warn); border-radius: 2px; color: #5e4100; }
.form-warning { font-size: 15px; margin: 6px 0; padding: 8px 10px; background: #fff4d6; border-left: 3px solid var(--warn); border-radius: 2px; color: #5e4100; }
#ent-colours { margin-bottom: 6px; }
@media (max-width: 600px) {
    .plan-filter .form-control, #filter-group { width: 100%; max-width: none; }
    .plan-filter-title { width: 100%; }
    .filter-field { display: block; width: 100%; }
    .filter-field label { display: block; margin-bottom: 3px; }
}

/* ── Unlocated varieties and sheet markings ── */
.unlocated-section { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--border); }
.unlocated-section .pane-title { border-bottom: none; padding-bottom: 0; margin-bottom: 6px; }
.unlocated-section .card-list { margin-top: 12px; }
.unlocated-section .muted { margin: 0 0 10px; }
#markings-table td { vertical-align: top; }

/* ── History and archive ── */
.badge.archived { background: #eeeae3; color: #5c5447; }
.history-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 15px; overflow-wrap: anywhere; }
.history-item:last-child { border-bottom: none; }
.history-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.history-changes { margin: 4px 0 0; padding-left: 18px; font-size: 14px; }

/* ── Phone menu button ── */
@media (min-width: 641px) { .nav-menu { display: none; } }

/* ── Identify my stamp ── */
.id-trail { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.id-trail:empty { display: none; }
.id-chip { background: var(--tab); border: 1px solid var(--border); border-radius: 12px; padding: 2px 10px; font-size: 14px; }
.id-question { background: var(--panel-bg); border: 1px solid var(--border); border-radius: 6px; padding: 18px; margin-top: 12px; }
.id-title { font-family: var(--serif); font-weight: 600; font-size: 23px; line-height: 1.2; color: var(--ink); margin-bottom: 8px; }
.id-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 12px; }
.id-options-watermark { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.id-option {
    display: flex; gap: 12px; align-items: center; text-align: left; background: var(--surface); padding: 12px 14px; cursor: pointer;
    border: 1px solid var(--border); border-radius: 6px; font-size: 15px; min-height: 52px;
}
.id-option:hover, .id-option:focus-visible { border-color: var(--ink); background: #fff; }
.id-option strong { display: block; font-size: 15px; }
.id-option-text .muted { display: block; margin-top: 2px; }
.id-art { flex: none; display: block; width: 100px; height: 122px; object-fit: contain; background: #fff; border: 1px solid var(--border); }
.id-swatch { flex: none; width: 22px; height: 28px; border-radius: 2px; }
.id-red { background: #b3312b; }
.id-green { background: #3f7d3f; }
.id-violet { background: #6b3f87; }
.id-orange { background: #d9802e; }
.id-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 12px; }
.id-result { border: 1px solid var(--border); border-radius: 6px; padding: 14px; background: var(--surface); }
.id-bw { font-family: var(--serif); font-weight: 600; font-size: 28px; line-height: 1.1; color: var(--ink); }
.id-result-name { font-weight: 600; margin: 2px 0 4px; }
.id-tell { font-size: 15px; margin: 8px 0 10px; }
.id-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ── Entry form steps ── */
.ent-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 6px; }
.ent-step-btn { background: var(--tab); border: 1px solid var(--border); border-radius: 4px; padding: 6px 4px; font-size: 14px; font-weight: 600; cursor: pointer; }
.ent-step-btn[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.ent-step-help { font-size: 14px; margin-bottom: 12px; }
.ent-step.step-off { display: none; }
.dialog-actions { flex-wrap: wrap; }
@media (max-width: 600px) { .ent-steps { grid-template-columns: repeat(2, 1fr); } }

/* Member guide page */
.guide { max-width: 820px; }
.guide p, .guide li { font-size: 15px; line-height: 1.5; margin: 8px 0; }
.guide ol, .guide ul { padding-left: 24px; margin: 8px 0; }
.guide h3 { font-family: var(--serif); font-weight: 600; font-size: 21px; color: var(--ink); margin: 30px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border); scroll-margin-top: 12px; }
.guide h3:focus { outline: none; }
.guide h4 { font-size: 15px; color: var(--ink); margin: 18px 0 6px; }
.guide .table-wrap { margin: 10px 0 14px; }
.guide td, .guide th { vertical-align: top; }
.guide code { font-size: 15px; }
.guide-quick { background: var(--panel-bg); border: 1px solid var(--border); border-radius: 6px; padding: 14px 18px; margin: 14px 0; }
.guide-quick h3 { margin: 0 0 6px; padding: 0; border: 0; font-size: 19px; }
.guide-toc { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; margin: 14px 0 0; }
.guide-toc .link { font-size: 15px; padding: 4px 0; }
.guide-fields td[rowspan] { font-weight: 600; min-width: 90px; }

/* Your own entry that wasn't published */
.key-unpublished { border: 1px dashed #7c7261; }
.grid-cell.has-unpublished { border-style: dashed; border-color: #7c7261; }

/* A search result from another list */
.search-hit .list { font-size: 13px; color: var(--text-muted); margin-right: 6px; }

/* When the catalogue can't load, hide what depends on it */
.no-data .main-layout, .no-data .unlocated-section, .no-data .evidence-key,
.no-data #search-form, .no-data .nav-btn[data-view="markings"] { display: none; }

/* Which list an entry belongs to, on pages that mix lists */
.entry-list { font-size: 13px; font-weight: 600; background: var(--tab); border: 1px solid var(--border); border-radius: 10px; padding: 0 8px; white-space: nowrap; }

/* ── Printing: the content, without the controls ── */
@media print {
    body, body.details-open { background: #fff; color: #000; padding: 0; }
    a { color: #000; }
    .muted, .subtitle, .cell-number, .place-line, .entry-die, .entry-credit, .site-footer { color: #333; }
    h1 { font-size: 22px; }
    .site-header { margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid #000; }
    .subtitle, .userbox, .nav, .search-bar, .search-results, .plan-filter, .filter-note, .electro-tabs, .sheet-map-section,
    .grid-tools, .details-close, .entry-actions, .evidence-key, .guide-toc, .id-actions, .toast, .modal, #btn-add-unlocated, .site-footer,
    .unlocated-section:has(.card-list > p.muted) { display: none !important; }
    .issue-bar { margin-top: 4px; }
    .value-row, .list-row { display: none !important; }
    .print-name { display: block; font-family: var(--serif); font-weight: 600; font-size: 18px; }
    .main-layout { display: block; }
    .pane-section, .details-panel, .entry-card, .guide-quick, .id-question, .id-result { box-shadow: none; background: #fff; border-color: #888; }
    .details-panel { position: static; max-height: none; overflow: visible; margin-top: 14px; border-radius: 0; padding: 10px; }
    body:not(.details-open) .details-panel { display: none; }
    body.details-open .details-panel { display: block; }
    .plating-grid { grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr)); gap: 3px; }
    .grid-cell { background: #fff; border-color: #888; min-height: 34px; break-inside: avoid; }
    .cell-name { display: -webkit-box !important; color: #000; }
    .grid-cell:not(.filled) .cell-name { display: none !important; }
    .entry-card, .id-result, tr, .guide-quick { break-inside: avoid; }
    h2, h3, h4, .pane-title, .panel-heading { break-after: avoid; }
    .table-wrap { overflow: visible; }
    .table { font-size: 12px; }
    .table th { background: #eee; }
    .guide { max-width: none; }
}

/* Identify my stamp: the 1½d colours */
.id-black-brown { background: #35281f; }
.id-brown { background: #7a4b2e; }
.id-bright-red-brown { background: #a34a2b; }
.id-red-brown { background: #8c3b2a; }

/* A watermark picture with the perforation beside it */
.wm-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; line-height: 1.2; vertical-align: middle; }
.wm-chip img, img.wm-guide { display: block; flex: none; width: 41px; height: 50px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 2px; }
.recorded-on { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 2px; }
.group-checks .check { align-items: center; }
.id-violet-blue { background: #4a4e9a; }
.id-blue { background: #2f5d9e; }
.id-olive { background: #6b6b2e; }
.id-chestnut { background: #8a3f22; }
.id-orange-brown { background: #b0602c; }
.id-turquoise { background: #2f8a8f; }

/* ── first-visit welcome ── */
.welcome { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 16px 18px; margin: 4px 0 18px; }
.welcome h2 { margin: 0 0 6px; }
.welcome p { margin: 0 0 12px; max-width: 760px; }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.welcome-hint { font-size: 14px; }
@media print { .welcome { display: none !important; } }

/* ── one card for the sheet map and the grid ── */
.sheet-section .sheet-map-section { margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.map-label { font-size: 14px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
