:root {
  --bg: #16191c; --card: #1f2427; --card2: #272d31; --fg: #e9e6dd; --muted: #a5adaf; --line: #343b40;
  --blaze: #e8b53d; --blaze-ink: #1b1f22; --real: #4f9d69; --story: #8a6fd1; --danger: #d0574b; --radius: 10px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f6f4ee; --card: #fff; --card2: #f0ede4; --fg: #1d2124; --muted: #5d6669; --line: #ddd8cc; --blaze: #c8931c; color-scheme: light; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--blaze); text-decoration: none; } a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
h1 { font-size: 1.6rem; margin: .4em 0 .6em; } h2 { font-size: 1.15rem; margin: 1.4em 0 .6em; }
small, .hint { color: var(--muted); } .hint { font-size: .9em; }
.error { color: var(--danger); } .box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.error.box { border-color: var(--danger); }

.top { display: flex; align-items: center; gap: 16px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--fg); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.blaze { width: 6px; height: 20px; background: var(--blaze); border-radius: 2px; }
.search { flex: 1; min-width: 200px; } .search input { width: 100%; }
.top nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.top nav form { margin: 0; } .who { display: flex; align-items: center; gap: 6px; color: var(--fg); } .who img { border-radius: 50%; }
.langs a { margin-left: 6px; color: var(--muted); text-transform: uppercase; font-size: .8em; } .langs a[aria-current] { color: var(--fg); font-weight: 700; }

input, select, textarea { background: var(--card2); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font: inherit; }
textarea { width: 100%; resize: vertical; }
.btn, button.btn { display: inline-block; background: var(--card2); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px; cursor: pointer; font: inherit; }
.btn:hover { text-decoration: none; border-color: var(--blaze); }
.btn.primary { background: var(--blaze); color: var(--blaze-ink); border-color: var(--blaze); font-weight: 600; }
.btn.big { padding: 11px 20px; font-size: 1.05em; } .btn.small { padding: 3px 9px; font-size: .85em; } .btn.danger:hover { border-color: var(--danger); color: var(--danger); }
button.link { background: none; border: 0; color: var(--blaze); cursor: pointer; padding: 0; font: inherit; } .small { font-size: .85em; }

.layout { display: grid; grid-template-columns: 180px minmax(0, 1fr) 180px; gap: 24px; max-width: 1560px; margin: 0 auto; padding: 18px 20px; }
.rail { position: sticky; top: 76px; align-self: start; }
@media (max-width: 1180px) { .layout { grid-template-columns: minmax(0, 1fr); } .rail { display: none; } }
.ad { min-height: 250px; } .ad.placeholder { border: 2px dashed var(--line); border-radius: var(--radius); display: grid; place-items: center; color: var(--muted); min-height: 600px; }
.ad-label { display: block; font-size: .7em; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.grid-ad { grid-column: 1 / -1; } .grid-ad .ad.placeholder { min-height: 120px; }
footer { border-top: 1px solid var(--line); padding: 18px 20px; color: var(--muted); text-align: center; font-size: .9em; }

.tagline { font-size: 1.25rem; font-weight: 600; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: .85em; color: var(--muted); }
.filters label.check { flex-direction: row; align-items: center; gap: 6px; }
.filters .tags { border: 0; padding: 0; margin: 0; width: 100%; display: flex; flex-wrap: wrap; gap: 6px; }
.filters .tags legend { font-size: .85em; color: var(--muted); margin-bottom: 4px; }
.tag { flex-direction: row !important; align-items: center; gap: 4px !important; background: var(--card2); border-radius: 999px; padding: 2px 10px; color: var(--fg) !important; cursor: pointer; }
.tag input { display: none; } .tag:has(input:checked) { background: var(--blaze); color: var(--blaze-ink) !important; }
.reset { font-size: .9em; } .count { color: var(--muted); margin: 0 0 10px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card .cover { position: relative; display: block; aspect-ratio: 16 / 9; background: var(--card2); }
.card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge { font-size: .75em; font-weight: 600; padding: 2px 8px; border-radius: 999px; color: #fff; background: var(--real); }
.badge.story { background: var(--story); } .card .badge { position: absolute; left: 10px; top: 10px; }
.card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card h2 { margin: 0; font-size: 1.05rem; } .card h2 a { color: var(--fg); }
.card p { margin: 0; } .by { color: var(--muted); font-size: .88em; } .by a { color: var(--muted); }
.desc { color: var(--muted); font-size: .92em; flex: 1; }
.facts { font-size: .9em; } .pill { display: inline-block; font-size: .75em; padding: 1px 7px; border: 1px solid var(--line); border-radius: 999px; margin-left: 4px; color: var(--muted); }
.meta { display: flex; gap: 12px; font-size: .88em; color: var(--muted); align-items: baseline; } .meta .langs { margin-left: auto; text-transform: uppercase; font-size: .85em; }
.stars { color: var(--blaze); } .tags a { margin-right: 8px; font-size: .88em; }
.pages { display: flex; gap: 16px; justify-content: center; align-items: center; margin: 22px 0; }
.empty { color: var(--muted); padding: 30px 0; text-align: center; }

.route header .by img { border-radius: 50%; vertical-align: middle; margin-right: 4px; }
.hero { width: 100%; max-height: 460px; object-fit: cover; border-radius: var(--radius); }
.route-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; margin-top: 18px; }
@media (max-width: 900px) { .route-grid { grid-template-columns: 1fr; } }
.facts-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; align-self: start; }
.facts-box dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 14px 0; } .facts-box dt { color: var(--muted); }
.facts-box dd { margin: 0; text-align: right; } .facts-box .btn.big { width: 100%; text-align: center; }
.prose { line-height: 1.65; } .prose img { border-radius: 8px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 16px 0; }
.gallery img { border-radius: 8px; aspect-ratio: 4 / 3; object-fit: cover; width: 100%; }
.gallery.edit figure { margin: 0; } .gallery.edit figcaption { font-size: .85em; text-align: center; }
.rating { margin: 12px 0; } .stars-big { font-size: 1.3em; color: var(--blaze); margin: 0 0 6px; }
.rate { display: flex; align-items: center; gap: 2px; } .rate span { margin-right: 6px; color: var(--muted); font-size: .9em; }
.star { background: none; border: 0; font-size: 1.5em; color: var(--line); cursor: pointer; padding: 0 1px; }
.star.on, .rate:hover .star { color: var(--blaze); } .rate .star:hover ~ .star { color: var(--line); }
.owner-actions { display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--line); padding-top: 12px; }
.owner-actions form { display: contents; } form.inline { display: inline; }
.status-box { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; border: 1px solid var(--line); background: var(--card); }
.status-box.failed { border-color: var(--danger); } .status-box.published { border-color: var(--real); } .status-box.checking { border-color: var(--blaze); }
.status { font-size: .85em; } .status.invalid, .status.failed, .status.rejected { color: var(--danger); } .status.published, .status.valid, .status.approved { color: var(--real); }
.comment { border-bottom: 1px solid var(--line); padding: 10px 0; } .comment .who { margin: 0; font-size: .9em; } .comment .text { margin: 4px 0 0; white-space: pre-wrap; }
.comment-form { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.versions { padding-left: 18px; } .translation { margin: 6px 0; }
.stack { display: flex; flex-direction: column; gap: 14px; max-width: 720px; }
.stack label { display: flex; flex-direction: column; gap: 4px; } .stack label.check { flex-direction: row; align-items: center; gap: 8px; }
.stack fieldset { border: 1px solid var(--line); border-radius: 8px; } .row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
table.mine { width: 100%; border-collapse: collapse; } table.mine td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.mine img { border-radius: 6px; }
.login { max-width: 460px; margin: 40px auto; text-align: center; } .provider { min-width: 260px; }
.avatar { border-radius: 50%; vertical-align: middle; margin-right: 10px; }

/* ---------------------------------------------------------------- the route editor */
main.wide { padding: 0; }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 440px; height: calc(100vh - 57px); }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; height: auto; } .ed-map { height: 60vh; } }
.ed-map-wrap { position: relative; display: flex; flex-direction: column; min-height: 0; }
.ed-map { flex: 1; min-height: 300px; background: #e9e2cf; }
.ed-tools { display: flex; gap: 4px; padding: 8px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ed-tools button { background: var(--card2); color: var(--fg); border: 1px solid var(--line); border-radius: 7px; padding: 5px 10px; cursor: pointer; font: inherit; font-size: .9em; }
.ed-tools button[aria-pressed="true"] { background: var(--blaze); color: var(--blaze-ink); border-color: var(--blaze); font-weight: 600; }
.ed-help { margin: 0; padding: 6px 10px; font-size: .85em; color: var(--muted); background: var(--card); border-top: 1px solid var(--line); }
.ed-panel { border-left: 1px solid var(--line); background: var(--card); display: flex; flex-direction: column; min-height: 0; }
.ed-title { font-size: 1.1rem; margin: 12px 14px 6px; }
.ed-langs { display: flex; gap: 4px; align-items: center; padding: 0 14px 8px; flex-wrap: wrap; font-size: .85em; color: var(--muted); }
.ed-langs button { background: var(--card2); border: 1px solid var(--line); color: var(--fg); border-radius: 999px; padding: 1px 9px; cursor: pointer; font: inherit; }
.ed-langs button[aria-pressed="true"] { border-color: var(--blaze); color: var(--blaze); font-weight: 700; }
.ed-langs .x { border: 0; background: none; color: var(--muted); padding: 0 2px; }
.ed-tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 8px; }
.ed-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 8px 9px; cursor: pointer; font: inherit; font-size: .92em; }
.ed-tabs button[aria-selected="true"] { color: var(--fg); border-color: var(--blaze); }
.ed-tabs .n { font-size: .8em; color: var(--muted); margin-left: 3px; }
.ed-body { flex: 1; overflow: auto; padding: 12px 14px 20px; display: flex; flex-direction: column; gap: 12px; }
.ed-body label { display: flex; flex-direction: column; gap: 3px; font-size: .88em; color: var(--muted); }
.ed-body label.check { flex-direction: row; align-items: center; gap: 6px; }
.ed-body input, .ed-body select, .ed-body textarea { color: var(--fg); }
.ed-item { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; background: var(--card2); }
.ed-item.sel { border-color: var(--blaze); box-shadow: 0 0 0 1px var(--blaze); }
.ed-item .head { display: flex; gap: 6px; align-items: center; }
.ed-item .head b { flex: 1; }
.ed-item .row2 { display: grid; grid-template-columns: 1fr 110px; gap: 8px; }
.ed-result { border-radius: 8px; padding: 8px 10px; font-size: .9em; }
.ed-result.ok { border: 1px solid var(--real); } .ed-result.wait { border: 1px dashed var(--line); color: var(--muted); } .ed-result.bad { border: 1px solid var(--danger); color: var(--danger); }
.ed-saved { margin: 0; padding: 6px 14px; font-size: .78em; color: var(--muted); border-top: 1px solid var(--line); }
.ed-pin { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700;
  color: #1b1f22; background: #e8b53d; border: 2px solid #1b1f22; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.ed-pin.fact { background: #5aa9e6; } .ed-pin.story { background: #b9a3ef; } .ed-pin.biome { background: #7fbf7f; border-radius: 6px; }
.ed-pin.sel { outline: 3px solid #fff; }
.ed-vertex { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid #c8931c; }

/* the tag filter: chips, a search box with suggestions, popular tags */
.tagfilter { border: 0; padding: 0; margin: 0; width: 100%; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tagfilter legend { font-size: .85em; color: var(--muted); margin-bottom: 4px; }
.tagfilter .selected { display: contents; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--blaze); color: var(--blaze-ink); border-radius: 999px; padding: 2px 4px 2px 10px; font-weight: 600; font-size: .9em; }
.chip .x { background: none; border: 0; color: inherit; cursor: pointer; font-size: 1.1em; line-height: 1; padding: 0 4px; border-radius: 50%; }
.chip .x:hover { background: rgba(0,0,0,.15); }
.tag-find { position: relative; }
.tag-find input { width: 190px; }
.suggest { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 220px; max-height: 260px; overflow: auto; margin: 0; padding: 4px;
  list-style: none; background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.suggest li { padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.suggest li[aria-selected="true"], .suggest li[data-tag]:hover { background: var(--card2); color: var(--blaze); }
.suggest li.none { color: var(--muted); cursor: default; }
.tagfilter .popular { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.tagfilter .tag { background: var(--card2); color: var(--fg); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; cursor: pointer; font: inherit; font-size: .9em; }
.tagfilter .tag:hover { border-color: var(--blaze); }

/* moderation */
.admin { max-width: 1200px; margin: 0 auto; padding: 18px 20px 40px; }
.admin-nav { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.admin-nav a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; }
.admin-nav a[aria-current] { color: var(--fg); border-color: var(--blaze); }
.admin-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.admin-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; color: var(--fg); }
.admin-card b { font-size: 1.6em; } .admin-card span { color: var(--muted); font-size: .88em; } .admin-card.warn { border-color: var(--danger); }
a.admin-card:hover { border-color: var(--blaze); text-decoration: none; }
.admin-search { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.admin-search input[type=search] { flex: 1; min-width: 260px; } .admin-search .check { display: flex; gap: 6px; align-items: center; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .93em; }
.admin-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.admin-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table .avatar { border-radius: 50%; vertical-align: middle; margin-right: 6px; }
.admin-table .actions { white-space: nowrap; text-align: right; } .admin-table .actions form { display: inline; }
.admin-table details summary { list-style: none; cursor: pointer; display: inline-block; }
.admin-table details summary::-webkit-details-marker { display: none; }
.admin-table details[open] .reason { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; min-width: 260px; text-align: left; }
.status.blocked { color: var(--danger); font-weight: 600; }
