/* Base layout and components. All colours come from tokens. */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 var(--font-body); -webkit-font-smoothing: antialiased; }
#ktf { min-height: 100vh; display: flex; flex-direction: column; overflow-x: clip; }
#app { flex: 1; display: flex; flex-direction: column; }
.wrap { width: 100%; max-width: 1180px; margin-inline: auto; padding-inline: 16px; }
@media (min-width: 720px) { .wrap { padding-inline: 28px; } }
main.wrap { flex: 1; padding-block: 28px 56px; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
img { max-width: 100%; }
h1, h2, h3, .h2, .h3 { font-family: var(--font-display); text-transform: var(--display-case); letter-spacing: var(--display-track);
  line-height: 1.15; font-weight: 400; text-wrap: balance; margin: 0 0 .4em; }
h1 { font-size: clamp(30px, 5vw, 46px); }
h2, .h2 { font-size: clamp(22px, 3vw, 28px); }
h3, .h3 { font-size: 19px; }
[data-ktf-dir="v2"] h1, [data-ktf-dir="v2"] h2, [data-ktf-dir="v2"] h3, [data-ktf-dir="v2"] .h2, [data-ktf-dir="v2"] .h3 { font-weight: 500; }
p { margin: 0 0 .8em; }
.label { font-family: var(--font-label); text-transform: var(--label-case); letter-spacing: var(--label-track); font-size: 12px; color: var(--muted); font-weight: 400; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ph { display: block; width: 100%; height: 100%; object-fit: cover; filter: var(--photo-filter); background: var(--surface-2); }
.prose { max-width: 68ch; font-size: 17px; }
.block { margin-block: 36px; }
.pagehead { margin-bottom: 20px; }
.pagehead p { max-width: 68ch; }
.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.empty, .callout { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.mocknote { font-size: 13px; color: var(--muted); border-left: 2px solid var(--line); padding-left: 10px; margin-top: 16px; }

/* header */
header.site { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
header.site .bar { display: flex; align-items: center; gap: 16px; padding-block: 10px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; flex-shrink: 0; }
.brand .mark svg { height: 44px; width: auto; display: block; color: var(--text); }
.brand .word { font-family: var(--font-display); font-size: 26px; letter-spacing: .06em; }
.search { position: relative; flex: 1; max-width: 460px; margin-left: auto; }
.search input, .input { width: 100%; font: inherit; font-size: 15px; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 9px 12px; }
.input-s { width: auto; min-width: 150px; }
textarea.input { resize: vertical; }
.qres { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.18); z-index: 30; padding: 6px; }
.qres a { display: block; padding: 8px 10px; color: var(--text); text-decoration: none; }
.qres a:hover, .qres a:focus-visible { background: var(--surface-2); }
.qres .label { display: block; }
.qres p { padding: 8px 10px; margin: 0; }
nav.nav { display: flex; flex-direction: column; gap: 4px; padding-bottom: 8px; }
.navrow, .adminnav { display: flex; gap: 4px 18px; overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
.navrow a, .adminnav a { color: var(--muted); text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; font-size: 15px; }
.navrow a[aria-current="page"], .adminnav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.navrow a:hover, .adminnav a:hover { color: var(--text); }
.navrow .forum-link { margin-inline-start: auto; flex-shrink: 0; }
.adminnav { align-items: center; padding-top: 4px; border-top: 1px dashed var(--line); }
.adminnav .count { font-weight: 600; font-size: 12px; color: var(--accent-ink); background: var(--accent); padding: 0 6px; border-radius: 9px; }
@media (max-width: 640px) {
  header.site { position: static; }
  header.site .bar { flex-wrap: wrap; gap: 8px; }
  .search { max-width: none; flex-basis: 100%; }
  .brand .mark svg { height: 34px; }
}

/* admin visibility */
.admin-only { display: none !important; }
[data-ktf-view="admin"] .admin-only { display: revert !important; }
[data-ktf-view="admin"] a.admin-only, [data-ktf-view="admin"] .btn.admin-only { display: inline-flex !important; }
[data-ktf-view="admin"] .adminnav.admin-only, [data-ktf-view="admin"] .adminbar.admin-only { display: flex !important; }
.btn-admin { border-style: dashed !important; }
.adminbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between; padding: 10px 14px; margin-bottom: 16px;
  border: 1px dashed var(--accent); border-radius: var(--radius); }

/* footer */
footer.site { border-top: 1px solid var(--line); padding-block: 22px 96px; font-size: 14px; color: var(--muted); }
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.foot a { color: var(--muted); }
.credits { margin-top: 14px; }
.credits summary { cursor: pointer; }
.credits ul { columns: 2 280px; font-size: 13px; padding-left: 18px; }

/* buttons, chips, tags */
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 15px; line-height: 1.2; padding: 9px 14px; cursor: pointer;
  color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; }
.btn:hover { border-color: var(--text); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-s { padding: 5px 10px; font-size: 13px; }
.btn[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: 14px; padding: 5px 12px; border: 1px solid var(--line); background: transparent; color: var(--text); border-radius: 999px; cursor: pointer; }
[data-ktf-dir="v2"] .chip, [data-ktf-dir="v3"] .chip { border-radius: var(--radius); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-block: 10px; }
.tag { font-size: 13px; padding: 2px 9px; border: 1px solid var(--line); color: var(--muted); border-radius: var(--radius); }
.badge { position: absolute; left: 6px; top: 6px; font-size: 11px; padding: 2px 6px; background: var(--accent); color: var(--accent-ink); }
.filters { display: grid; gap: 10px; margin-bottom: 18px; }
.frow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.frow > .label { min-width: 74px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 12px; }
.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; }
.pname { color: var(--muted); font-size: .8em; }
.ribbon { width: .7em; height: 1em; vertical-align: -.1em; margin-left: .3em; display: inline-block; }
.crest { color: var(--muted); display: inline-block; vertical-align: middle; }
.crest-ktf svg { width: 100%; height: 100%; color: var(--text); }
.scrollx { overflow-x: auto; max-width: 100%; }
.year { font-size: 22px; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 4px; }

/* toast and mock switches */
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 50; max-width: min(520px, calc(100% - 32px));
  background: var(--text); color: var(--bg); padding: 12px 16px; font-size: 14px; border-radius: 6px; box-shadow: 0 6px 24px rgba(0,0,0,.3); }
#mockbar { position: fixed; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 40; width: 250px; max-width: calc(100% - 24px);
  font-family: "Segoe UI", Arial, sans-serif; font-size: 13px; background: #1f2126; color: #f1f2f4; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
#mockbar .bartoggle { width: 100%; text-align: left; font: 600 13px/1 "Segoe UI", Arial, sans-serif; letter-spacing: .08em; text-transform: uppercase;
  color: #f1f2f4; background: none; border: 0; padding: 12px 14px; cursor: pointer; }
#mockbar .bartoggle::after { content: " ▾"; }
#mockbar:not(.open) { width: auto; }
#mockbar:not(.open) .barbody { display: none; }
#mockbar .barbody { padding: 0 14px 12px; }
#mockbar .label { color: #a7abb3; margin: 10px 0 5px; font-family: inherit; letter-spacing: .08em; font-size: 11px; }
#mockbar .seg { display: flex; flex-wrap: wrap; gap: 4px; }
#mockbar .seg button { flex: 1 1 auto; font: inherit; font-size: 12px; padding: 6px 8px; border: 1px solid #454952; background: transparent; color: #f1f2f4; border-radius: 4px; cursor: pointer; }
#mockbar .seg button[aria-pressed="true"] { background: #f1f2f4; color: #1f2126; border-color: #f1f2f4; }
#mockbar a { color: #c9d4ff; }
.barlinks { margin: 10px 0 0; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 0; }
.calbar .seg button { font: inherit; font-size: 14px; padding: 8px 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.calbar .seg button + button { border-left: 0; }
.calbar .seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .gp img, .album img, .pcard img, .tile img { transition: transform .35s ease-out; }
  .gp:hover img, .album:hover img, .pcard:hover img, .tile:hover img { transform: scale(1.03); }
}
