:root {
  /* Dark theme in neutral greys, like macOS dark mode with the Graphite accent */
  color-scheme: dark;
  --ink: #e8e8ea; --muted: #98989d; --line: #3d3d3f; --bg: #1e1e1e; --card: #282828; --raised: #333335;
  --link: #BE5103; --link-hover: #E07A2E; --accent: #636366; --accent-ink: #fff; --warn: #e0b04a; --error: #ff6961;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 1.25rem; }
main.wrap { padding-top: 1.5rem; padding-bottom: 3rem; }
a { color: var(--link); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.break { word-break: break-all; }

.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.site-header .wrap { padding-top: .85rem; padding-bottom: .85rem; }
.site-title { font-weight: 650; color: var(--ink); text-decoration: none; letter-spacing: .01em; }

h1 { font-size: 1.75rem; margin: 0 0 .2rem; line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
.lede { color: var(--muted); margin: 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; color: var(--muted); margin: 0 0 .2rem; }
.crumb { margin: 0 0 1rem; font-size: .9rem; }

.page-head { display: flex; gap: 1rem; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1.25rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.btn { display: inline-block; font: inherit; font-size: .95rem; padding: .5rem .9rem; border-radius: 6px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn { background: var(--raised); }
.btn:hover { border-color: #8e8e93; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { font-size: .82rem; padding: .3rem .6rem; }
.icon-btn { border: 0; background: none; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); }

.filter { width: 100%; font: inherit; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 1rem; background: var(--card); }

table { width: 100%; border-collapse: collapse; background: var(--card); font-size: .95rem; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.table-scroll table { border: 0; }
.table-scroll tr:last-child td { border-bottom: 0; }
.mount-table td a { font-weight: 600; }
.count { margin-top: .75rem; font-size: .9rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.card .table-scroll { border-radius: 6px; }
.grid { display: grid; grid-template-columns: 1fr 260px; gap: 1rem; }
.grid .card { margin-bottom: 0; }
.grid + .card { margin-top: 1rem; }
@media (max-width: 720px) { .grid { grid-template-columns: 1fr; } }

.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .45rem 1.25rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.qr-card { text-align: center; }
.qr { background: #fff; border-radius: 6px; padding: .4rem; display: inline-block; width: 100%; max-width: 200px; }
.qr svg { width: 100%; max-width: 200px; height: auto; display: block; margin: 0 auto; }
.qr-card p { margin: .5rem 0; }

.gallery { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.gallery figure { margin: 0; }
.gallery img { width: 100%; height: auto; display: block; border: 1px solid var(--line); border-radius: 6px; background: var(--raised); }
.gallery figcaption { font-size: .85rem; margin-top: .35rem; }

.files { list-style: none; padding: 0; margin: 0; }
.files li { padding: .55rem 0; border-bottom: 1px solid var(--line); }
.files li:last-child { border-bottom: 0; }
.file-line { display: flex; align-items: center; gap: .75rem; justify-content: space-between; }
.preview { margin-top: .6rem; }
.preview pre { background: var(--bg); padding: .75rem; border-radius: 6px; overflow: auto; max-height: 400px; font-size: .85rem; margin: 0; }
.preview .table-scroll { max-height: 420px; overflow: auto; }
.preview table { font-size: .82rem; font-family: var(--mono); }
.preview th { text-transform: none; letter-spacing: 0; position: sticky; top: 0; background: var(--card); }

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

/* ---------- dialog ---------- */
.dialog { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(680px, 96vw); max-height: 92vh; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog form { display: flex; flex-direction: column; max-height: 92vh; }
.dialog-head, .dialog-foot { padding: .9rem 1.25rem; display: flex; align-items: center; gap: .5rem; }
.dialog-head { justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 1.2rem; }
.dialog-foot { justify-content: flex-end; border-top: 1px solid var(--line); }
.dialog-body { padding: 1rem 1.25rem; overflow-y: auto; }
fieldset { border: 0; padding: 0; margin: 0 0 1.25rem; }
legend { font-weight: 650; margin-bottom: .5rem; padding: 0; }
.dialog label { display: block; font-size: .88rem; color: var(--muted); margin-bottom: .7rem; }
.dialog input, .dialog textarea { display: block; width: 100%; font: inherit; font-size: .95rem; color: var(--ink);
  padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 6px; margin-top: .25rem; background: var(--bg); }
.dialog input:focus, .dialog textarea:focus { outline: 2px solid var(--link); outline-offset: -1px; border-color: transparent; }
.dialog .row { display: flex; gap: .75rem; flex-wrap: wrap; }
.dialog .row > label { flex: 0 0 140px; }
.dialog .row > label.grow { flex: 1 1 220px; }
.dialog label.narrow { max-width: 180px; }
.inline { display: flex; gap: .5rem; align-items: center; }
.inline input { flex: 1; }
.inline .btn { margin-top: .25rem; }
.hint { display: block; margin-top: .3rem; font-size: .8rem; color: var(--muted); }
.hint.error { color: var(--error); }
.warn { color: var(--warn); background: rgba(187, 128, 9, .15); padding: .6rem .8rem; border-radius: 6px; }
.sample-row { display: grid; grid-template-columns: 1.6rem 1fr 1.6fr auto 1.6rem; gap: .5rem; align-items: center; margin-bottom: .45rem; }
.sample-row .eb-btn { margin-top: 0; }
.eb-tag { grid-column: 2 / -1; font-size: .8rem; color: var(--muted); margin-top: -.15rem; }
.link-btn { border: 0; background: none; color: var(--link); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
.dialog select { display: block; width: 100%; font: inherit; font-size: .95rem; color: var(--ink); padding: .45rem .6rem;
  border: 1px solid var(--line); border-radius: 6px; margin-top: .25rem; background: var(--bg); }
.pick-results { max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 1rem; }
.pick-results:empty { display: none; }
.pick-item { display: flex !important; gap: .6rem; align-items: flex-start; padding: .45rem .65rem; margin: 0 !important;
  border-bottom: 1px solid var(--line); cursor: pointer; color: var(--ink) !important; }
.pick-item:last-child { border-bottom: 0; }
.pick-item:hover { background: var(--raised); }
.pick-item input { width: auto !important; display: inline !important; margin: .2rem 0 0 !important; }
.pick-item small { display: block; color: var(--muted); }
@media (max-width: 560px) { .sample-row { grid-template-columns: 1.6rem 1fr; } .sample-row input[data-k=position], .sample-row .eb-btn { grid-column: 2; } .sample-row .row-del { grid-column: 2; justify-self: end; } }
.sample-row input { margin-top: 0; }
.sample-row .num { color: var(--muted); font-size: .85rem; text-align: right; }
.steps { padding-left: 1.2rem; }
.steps li { margin-bottom: .4rem; }
details textarea { margin: .5rem 0; font-size: .8rem; }
summary { cursor: pointer; color: var(--link); }

/* Codes section */
.codes { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); }
.code { margin: 0; border: 1px solid var(--line); border-radius: 8px; padding: .9rem; display: flex; flex-direction: column; }
.code.wide { grid-column: 1 / -1; }
.code-img { background: #fff; border-radius: 6px; padding: .6rem; display: flex; align-items: center; justify-content: center; height: 170px; margin-bottom: .75rem; }
.code-img svg { max-width: 100%; max-height: 100%; width: auto; height: 100%; }
.code.wide .code-img { height: 90px; }
.code.wide .code-img svg { height: auto; width: 100%; max-width: 640px; }
.code-empty { background: none; border: 2px dashed var(--line); border-radius: 6px; color: var(--muted); font-size: .9rem; text-align: center; padding: 1rem; }
.code figcaption { font-size: .85rem; display: flex; flex-direction: column; flex: 1; }
.code figcaption ul { margin: .35rem 0 .75rem; padding-left: 1.1rem; color: var(--muted); }
.code figcaption li { margin: .15rem 0; }
.code-dl { display: flex; gap: .4rem; margin-top: auto; }

/* EarthBank section */
.eb-map { height: 340px; border-radius: 8px; border: 1px solid var(--line); margin-bottom: .4rem; background: var(--bg); }
.eb-samples { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); margin-top: 1rem; }
.eb-sample, .eb-pkg { border: 1px solid var(--line); border-radius: 8px; padding: .9rem 1rem; }
.eb-sample h3 { font-size: 1rem; margin: 0 0 .5rem; }
.eb-sample .facts { gap: .3rem 1rem; }
.eb-sub { margin: .8rem 0 .2rem; color: var(--muted); }
.eb-list { margin: 0; padding-left: 1.1rem; }
.eb-list li { margin: .2rem 0; }
.eb-h { font-size: 1rem; margin: 1.4rem 0 .6rem; }
.eb-pkg { margin-bottom: .75rem; }
.eb-pkg p { margin: 0 0 .5rem; }
.eb-pkg details p { margin: .5rem 0 0; }
.pre { white-space: pre-line; }
.orcid { display: inline-block; font-size: .7rem; font-weight: 700; line-height: 1; padding: .15rem .25rem; border-radius: 3px;
  background: #a6ce39; color: #fff !important; text-decoration: none; vertical-align: 1px; }
.eb-foot { margin: 1rem 0 0; }
.leaflet-container { font: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--card); color: var(--ink); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-control-attribution { background: rgba(30,30,30,.8) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--link); }
.leaflet-bar a { background: var(--raised); color: var(--ink); border-color: var(--line); }
.leaflet-control-layers, .leaflet-control-layers label { background: var(--card) !important; color: var(--ink) !important; border: 1px solid var(--line) !important; font-size: .8rem; }
a { text-decoration-color: rgba(190, 81, 3, .5); text-underline-offset: 2px; }
a:hover { color: var(--link-hover); text-decoration-color: currentColor; }
.btn.primary:hover { filter: none; background: #737377; border-color: #737377; }
a.btn:hover, .site-title:hover { color: var(--ink); }
a.btn.primary:hover { color: var(--accent-ink); }
.row-del { font-size: 1.3rem; padding: 0; }
.row-del:hover { color: var(--error); }
kbd { font-family: var(--mono); font-size: .8em; padding: .05rem .3rem; border: 1px solid var(--line); border-radius: 4px; background: var(--raised); }

/* Page actions menu */
.menu { position: relative; }
.menu > summary { list-style: none; letter-spacing: .1em; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; min-width: 240px; padding: .3rem;
  background: var(--raised); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.menu-list a, .menu-list button { display: block; width: 100%; text-align: left; padding: .45rem .6rem; border: 0; border-radius: 5px;
  background: none; color: var(--ink); font: inherit; font-size: .9rem; text-decoration: none; cursor: pointer; }
.menu-list a:hover, .menu-list button:hover { background: var(--card); color: var(--ink); }

/* History */
.card-head { display: flex; justify-content: flex-start; gap: .75rem; align-items: center; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 7.5rem 1fr auto; gap: .2rem 1rem; padding: .45rem 0;
  border-bottom: 1px solid var(--line); font-size: .9rem; }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-by { color: var(--muted); font-size: .82rem; }
.tl-note { grid-column: 2 / -1; margin: 0; color: var(--muted); font-size: .85rem; }
.tl-created .tl-text { color: var(--muted); }
#history-more { margin-top: .5rem; }
@media (max-width: 560px) { .timeline li { grid-template-columns: 1fr; } .tl-note { grid-column: 1; } }

/* History dialog */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chips label { margin: 0 !important; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips span { display: inline-block; padding: .35rem .75rem; border: 1px solid var(--line); border-radius: 999px;
  font-size: .85rem; color: var(--ink); cursor: pointer; background: var(--raised); }
.chips input:checked + span { background: var(--accent); border-color: #8e8e93; color: #fff; }
.chips input:focus-visible + span { outline: 2px solid var(--link); }
.dialog label.check { display: flex !important; gap: .5rem; align-items: center; color: var(--ink); }
.dialog label.check input { width: auto; margin: 0; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { margin: 0 0 .2rem; }
.notes-body > :first-child { margin-top: 0; }
.notes-body > :last-child { margin-bottom: 0; }
.note-list { list-style: none; margin: .75rem 0 0; padding: 0; }
.note-list li { padding: .6rem 0; border-top: 1px solid var(--line); }
.note-list p { margin: 0 0 .2rem; }
.eb-box { border: 1px solid var(--line); border-radius: 8px; padding: .75rem .9rem .1rem; margin-top: .25rem; }
.eb-box-head { margin: 0 0 .6rem; font-size: .9rem; }
#log-types { margin-bottom: 1.1rem; }
.dialog select { appearance: auto; }

/* Sign in */
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.gh-auth .menu-list { min-width: 260px; }
.gh-user { display: flex; align-items: center; gap: .45rem; cursor: pointer; list-style: none; font-size: .9rem; color: var(--ink); }
.gh-user::-webkit-details-marker { display: none; }
.gh-user img { width: 24px; height: 24px; border-radius: 50%; }
.menu-note { margin: .3rem .6rem .5rem; font-size: .82rem; color: var(--muted); }
.tag { font-size: .72rem; padding: .05rem .4rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.saved { display: flex; gap: .6rem; align-items: flex-start; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 8px; background: var(--raised); }
.saved strong { display: block; }
.spinner { display: inline-block; width: .9em; height: .9em; border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Upload dialog */
.drop { display: flex !important; flex-direction: column; align-items: center; gap: .3rem; text-align: center; padding: 2rem 1rem !important;
  border: 2px dashed var(--line); border-radius: 10px; cursor: pointer; color: var(--ink) !important; }
.drop.over { border-color: var(--link); background: var(--raised); }
.drop small { color: var(--muted); max-width: 32rem; }
.link-like { color: var(--link); text-decoration: underline; }
.upload-list { list-style: none; margin: 1rem 0 0; padding: 0; }
.upload-list li { display: grid; grid-template-columns: 1fr auto auto; gap: 0 .6rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.upload-list li small { grid-column: 1 / -1; }
.upload-list li.bad .mono { text-decoration: line-through; color: var(--muted); }
.upload-list .error { color: var(--error); }
.upload-list .icon-btn { font-size: 1.2rem; }

/* Hi-res download under each map */
.hires { display: flex; align-items: center; gap: .7rem; width: 100%; margin-top: .6rem; padding: .65rem .85rem;
  border: 1px solid var(--link); border-radius: 8px; background: rgba(190, 81, 3, .12); color: var(--ink);
  text-decoration: none; font: inherit; text-align: left; cursor: pointer; }
.hires:hover { background: rgba(190, 81, 3, .22); color: var(--ink); }
.hires strong { display: block; font-size: .95rem; }
.hires small { display: block; color: var(--muted); font-size: .8rem; word-break: break-all; }
.hires-icon { flex: none; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--link); color: #fff; font-size: 1.1rem; font-weight: 700; }
.hires-add { border-style: dashed; border-color: var(--line); background: none; }
.hires-add .hires-icon { background: var(--raised); color: var(--muted); }
.hires-add:hover { border-color: var(--link); background: none; }
.hires-edit { margin-top: .3rem; }
.warn-text { color: var(--warn) !important; }
