:root {
  color-scheme: dark;
  --bg: #101012;
  --panel: #19181c;
  --line: #343036;
  --text: #f1eae0;
  --muted: #b7abb0;
  --accent: #e1828c;
  --serif: Georgia, "Times New Roman", serif;
  --mono: "Cascadia Mono", Consolas, monospace;
  font-family: system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(ellipse at 70% 0, #451e292f, transparent 45%), var(--bg); }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid #ee9299;
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.sr-only, .symbols { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.frame { width: min(1160px, calc(100% - 64px)); margin-inline: auto; }
.skip { position: absolute; z-index: 2; left: 16px; top: 12px; transform: translateY(-150%); padding: 12px 16px; background: #2e2028; }
.skip:focus { transform: none; }

.masthead { background: #141316; border-bottom: 1px solid #32282c; }
.masthead-inner { min-height: 73px; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.identity { display: flex; align-items: center; gap: 12px; }
.identity img { border-radius: 50%; flex: none; }
.identity-title { display: block; font: 19px/1.1 var(--serif); }
.identity-label { font: 10px/1.4 var(--mono); text-transform: uppercase; letter-spacing: .13em; }
.identity-label { display: block; margin-top: 5px; color: var(--muted); }
.masthead-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.session-account { color: #e2cdd4; font: 11px/1.4 var(--mono); overflow-wrap: anywhere; }
.admin-link, .session-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 6px 12px; border: 1px solid #76414b; border-radius: 4px; text-decoration: none; font-size: 13px; }
.admin-link { color: #f5dce0; background: #352129; }
.admin-link:hover { background: #47252f; border-color: #a35967; }
.session-button { color: var(--text); background: #242027; border-color: #59454f; }
.session-button:hover { background: #32252f; border-color: #a97480; }
.session-button:disabled { opacity: .6; cursor: wait; }
.registry-access {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
  padding: 18px;
  background: #21191f;
  border: 1px solid #65424d;
  border-radius: 5px;
}
.registry-access > .icon { color: var(--accent); width: 26px; height: 26px; }
.registry-access h2 { margin: 0 0 6px; font: 24px/1.1 var(--serif); }
.registry-access p { margin: 0; color: var(--muted); font-size: 14px; }
.access-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.hero {
  isolation: isolate;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  min-height: 350px;
  margin-top: 25px;
  border: 1px solid #65443e;
  border-radius: 5px;
  background: #1b1518;
}
.hero::before, .hero::after { content: ""; position: absolute; z-index: -1; inset: 0; }
.hero::before {
  background: url("./konoha-encre.jpg") center right / cover no-repeat;
  filter: brightness(.59) saturate(.62);
}
.hero::after { background: linear-gradient(90deg, #141115 0%, #1b1318f5 24%, #24171bbd 42%, #2415180b 76%), linear-gradient(0deg, #100b10a3, transparent 50%); }
.hero-inner { padding: 43px clamp(27px, 5vw, 63px); }
.eyebrow { display: flex; align-items: center; gap: 9px; color: var(--accent); font: 11px/1.5 var(--mono); letter-spacing: .15em; text-transform: uppercase; }
.seal-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: #c45464; box-shadow: 0 0 0 3px #c4546424; }
.hero h1 { margin: 12px 0 16px; color: #fff1df; font: 400 clamp(45px, 6vw, 78px)/.98 var(--serif); letter-spacing: -.057em; }
.hero p { max-width: 34ch; margin: 0; color: #e5d7cb; font-size: 15px; line-height: 1.6; }
.hero-mark {
  position: absolute;
  right: 23px;
  top: 23px;
  border: 1px solid #dd8c90ac;
  background: #27151edb;
  box-shadow: 0 0 0 3px #26161bc2;
  padding: 7px 6px 6px;
  color: #f1c0b3;
  font: 15px/1.13 serif;
  text-align: center;
  transform: rotate(3deg);
}
.hero-corner { position: absolute; bottom: 12px; right: 12px; width: 21px; height: 21px; border: solid #e6bbae8c; border-width: 0 1px 1px 0; }

.categories { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 15px; }
.category {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  min-height: 84px;
  padding: 15px;
  text-align: left;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 5px;
  background: linear-gradient(135deg, #211e23, #18171b 65%);
  transition: background .15s, border-color .15s;
}
[data-category="konoha"] { --category-color: #bdd19f; --category-bg: #282f24; }
[data-category="suna"] { --category-color: #dfc08d; --category-bg: #352c23; }
[data-category="etranger"] { --category-color: #a7cce4; --category-bg: #23323b; }
[data-category="nukenin"] { --category-color: #f1a5ae; --category-bg: #3d242d; }
.category:hover, .category[aria-pressed="true"] { border-color: var(--category-color); background: linear-gradient(130deg, var(--category-bg), #1c191e); }
.category-icon { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid #ffffff12; border-radius: 4px; color: var(--category-color); background: var(--category-bg); }
.category-text { display: grid; gap: 4px; }
.category-text strong { font: 400 17px/1.15 var(--serif); }
.category-text > span { color: var(--muted); font-size: 12px; line-height: 1.35; }
.category-count { color: var(--category-color); font: 13px var(--mono); }
.category-arrow { color: #a9949d; width: 16px; height: 16px; }

.register { margin-top: 40px; scroll-margin-top: 18px; }
.section-rule { width: 25px; height: 1px; background: #ab4c59; }
.section-header h2 { margin: 6px 0; font: 400 clamp(33px, 4.8vw, 46px)/1.13 var(--serif); letter-spacing: -.035em; }
.section-header p { margin: 7px 0 20px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(164px, .38fr) minmax(160px, .35fr); gap: 10px; }
.search, .filter {
  min-height: 55px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
}
.search { display: flex; align-items: center; gap: 11px; padding: 0 13px; }
.search:focus-within, .filter:focus-within { border-color: #c66d79; }
.search .icon { color: #d496a0; }
.search input { width: 100%; min-width: 0; min-height: 44px; color: var(--text); background: transparent; border: 0; outline: none; padding: 0 3px; font-size: 15px; }
.search input::placeholder { color: #aa9ba2; opacity: 1; }
.search kbd { padding: 2px 6px; border: 1px solid #433a41; border-radius: 3px; color: #c3b2bb; font: 12px var(--mono); }
.filter { display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 6px 10px 6px 12px; }
.filter > span { color: #c8b9be; font: 10px/1.15 var(--mono); letter-spacing: .07em; text-transform: uppercase; }
.filter select { width: 100%; border: 0; padding: 2px 0; border-radius: 2px; color: var(--text); background: var(--panel); font-size: 14px; }
.record-filters, .life-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.record-filters { margin-top: 10px; justify-content: space-between; }
.filter-button, .threat-filter { padding: 7px 9px; min-height: 38px; color: #ddd0d5; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; font-size: 12px; }
.filter-button:hover, .filter-button[aria-pressed="true"] { color: #f7d6d8; background: #352129; border-color: #76414b; }
.threat-filter { display: flex; align-items: center; gap: 8px; }
.threat-filter select { color: var(--text); border: 0; background: transparent; }
.threat-filter option { background: var(--panel); }
.results-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 20px 0 12px; }
#category-title { margin: 0; color: var(--text); font: 400 clamp(21px, 3vw, 27px)/1.2 var(--serif); }
#result-count { color: var(--muted); font: 11px/1.3 var(--mono); text-align: right; }
.registry-message { margin: 0 0 10px; padding: 10px 12px; border: 1px solid #76414b; border-radius: 4px; color: #f7d6d8; background: #352129; font-size: 13px; }
.session-feedback { margin-top: 14px; }
.results { list-style: none; padding: 0; margin: 0; }
.gallery { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.record-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #1a191d;
  text-decoration: none;
  transition: border-color .15s, background .15s;
}
.record-card:hover, .record-card:focus-visible { border-color: var(--category-color, var(--accent)); background: #221d24; }
.record-media {
  position: relative;
  display: block;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: #201b21;
}
.record-portrait, .record-placeholder { position: absolute; inset: 0; width: 100%; height: 100%; }
.record-portrait { display: block; object-fit: cover; object-position: center 28%; }
.record-placeholder {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 12px;
  color: var(--muted);
  background: repeating-linear-gradient(135deg, #ffffff05 0 1px, transparent 1px 7px), radial-gradient(ellipse at center, var(--category-bg, #33252d), #1d181e 75%);
  text-align: center;
}
.record-initials { color: var(--category-color, var(--accent)); font: 400 clamp(33px, 6vw, 54px)/1 var(--serif); letter-spacing: -.06em; }
.record-portrait-label { font: 10px/1.4 var(--mono); }
.record-deceased {
  position: absolute;
  top: 9px;
  left: 9px;
  padding: 5px 7px;
  border: 1px solid #a38ba9;
  border-radius: 3px;
  background: #2f2635;
  color: #f2e2f4;
  font: 10px/1.2 var(--mono);
  letter-spacing: .045em;
  text-transform: uppercase;
}
.record-threat {
  position: absolute;
  right: 9px;
  bottom: 9px;
  display: grid;
  justify-items: center;
  gap: 3px;
  min-width: 58px;
  padding: 5px 7px;
  border: 1px solid #93636f;
  border-radius: 3px;
  background: #281d26;
  color: #f5d1d8;
}
.record-threat small { font: 9px/1.15 var(--mono); text-transform: uppercase; }
.record-threat-rank { font: 400 25px/1 var(--serif); }
.record-threat[data-rank="A"], .record-threat[data-rank="S"], .record-threat[data-rank="S+"] { border-color: #c97987; background: #512b37; }
.record-content { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; min-width: 0; padding: 13px; }
.record-affiliation { color: var(--category-color, var(--muted)); font: 10px/1.4 var(--mono); letter-spacing: .06em; text-transform: uppercase; overflow-wrap: anywhere; }
.record-name { color: #fff1e5; font: 400 clamp(17px, 2vw, 23px)/1.17 var(--serif); overflow-wrap: anywhere; }
.record-rank { margin-bottom: 6px; color: #c9bfc4; font-size: 12px; line-height: 1.35; overflow-wrap: anywhere; }
.record-open { display: flex; justify-content: space-between; align-items: center; gap: 5px; width: 100%; margin-top: auto; padding-top: 7px; border-top: 1px solid var(--line); color: #e3b7c0; font-size: 12px; }
.record-open .icon { width: 15px; height: 15px; }
.tag { display: inline-block; padding: 4px 7px; border: 1px solid #ffffff15; border-radius: 3px; color: var(--category-color); background: var(--category-bg); font-size: 11px; line-height: 1.2; white-space: nowrap; }
.empty { margin: 0; padding: 38px 16px; border: 1px solid var(--line); border-radius: 5px; background: #19171b; text-align: center; }
.empty > .icon { color: var(--accent); width: 28px; height: 28px; }
.empty h3 { margin: 8px 0 4px; font: 23px var(--serif); }
.empty p { margin: 0 0 15px; color: var(--muted); font-size: 14px; }
.empty button, .dossier-footer button { min-height: 42px; padding: 8px 12px; border-radius: 4px; border: 1px solid #92525c; color: #f5dce0; background: #47252f; font-size: 13px; }
.empty button:hover, .dossier-footer button:hover { background: #61303d; }
.footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 19px 0 24px; margin-top: 32px; border-top: 1px solid var(--line); color: #b1a4ab; font: 11px/1.5 var(--mono); }
.footer span:first-child { display: flex; gap: 7px; align-items: center; }
.footer .icon { width: 15px; height: 15px; color: var(--accent); }

dialog {
  width: min(670px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: auto;
  color: var(--text);
  border: 1px solid #81535b;
  border-radius: 6px;
  background: radial-gradient(ellipse at 5% 0, #4829328f, transparent 48%), #1b181d;
  box-shadow: 0 20px 80px #000b;
}
dialog::backdrop { background: #09080bd9; backdrop-filter: blur(4px); }
body:has(dialog[open]) { overflow: hidden; }
#dossier { width: min(1050px, calc(100% - 24px)); background: #18151a; scrollbar-gutter: stable; }
.dossier-body { --sheet-gutter: clamp(12px, 3vw, 28px); padding: 0 var(--sheet-gutter) var(--sheet-gutter); }
.dossier-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px var(--sheet-gutter); margin: 0 calc(-1 * var(--sheet-gutter)) 16px; border-bottom: 1px solid #4b333c; background: #211920; position: sticky; top: 0; z-index: 1; }
.dossier-top .eyebrow { flex-wrap: wrap; }
.close { flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; color: #f4dce0; background: #2e2028; border: 1px solid #7a4e58; border-radius: 4px; }
.close:hover { background: #4a2934; }
.bio-sheet { padding: clamp(12px, 2.2vw, 22px); border: 1px solid #6b4850; background: radial-gradient(ellipse at 5% 0, #38242a, transparent 55%), #241d21; overflow-wrap: anywhere; }
.bio-sheet-header { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: clamp(10px, 2vw, 20px); padding-bottom: 15px; margin-bottom: 13px; border-bottom: 3px double #9d606b; }
.bio-sheet-header img { width: clamp(42px, 8vw, 70px); height: auto; }
.bio-sheet-heading h2 { margin: 4px 0; color: #f9e8d9; font: 400 clamp(26px, 4vw, 43px)/1.06 var(--serif); }
.bio-sheet-heading p { margin: 0; color: #e6b3bb; font: 16px/1.4 var(--serif); }
.bio-secret { display: inline-block; margin-top: 7px; padding: 3px 6px; border: 1px solid #85515c; border-radius: 3px; background: #3b222b; color: #f4c9ce; font: 10px/1.2 var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.bio-hokage { padding-inline: 7px; color: #d995a1; text-align: center; font: 31px/1.1 var(--serif); }
.bio-hokage small { display: block; margin-top: 4px; color: #d2b5ba; font: 9px/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.bio-deceased-notice { display: grid; gap: 4px; padding: 10px 13px; margin-bottom: 12px; border: 1px solid #5e4c68; border-left: 3px solid #b899c7; background: #302637; color: #ebdbee; font-size: 13px; }
.bio-deceased-notice strong { font-size: 15px; }
.bio-columns { display: grid; grid-template-columns: minmax(0, 42fr) minmax(0, 58fr); gap: 11px; }
.bio-column { display: grid; align-content: start; gap: 11px; }
.bio-portrait { margin: 0; overflow: hidden; border: 1px solid #61424b; background: #1b161a; }
.bio-portrait img, .bio-portrait-placeholder { display: block; width: 100%; aspect-ratio: 4 / 5; max-height: 360px; }
.bio-portrait img { object-fit: contain; }
.bio-portrait-placeholder { display: grid; align-content: center; justify-items: center; gap: 9px; background: repeating-linear-gradient(135deg, #ffffff04 0 1px, transparent 1px 7px), radial-gradient(ellipse at center, #33252d, #1d181c 75%); color: #baa4ad; font-size: 13px; }
.bio-portrait-placeholder .icon { width: 46px; height: 46px; color: #d0929f; stroke-width: 1; }
.bio-portrait figcaption { padding: 7px 10px; border-top: 1px solid #563e47; color: #d2b9bf; font: 10px/1.4 var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.bio-panel { min-width: 0; padding: clamp(11px, 2vw, 16px); border: 1px solid #5b4149; background: #1a161a8f; }
.bio-panel h3 { margin: 0 0 9px; color: #efb8c0; font: 400 20px/1.2 var(--serif); }
.bio-panel h4 { margin: 13px 0 5px; color: #e7bdc4; font: 400 17px/1.2 var(--serif); }
.bio-details, .bio-scores { margin: 0; }
.bio-details > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); align-items: baseline; gap: 8px; padding: 5px 0; border-bottom: 1px solid #4f383f; font-size: 13px; }
.bio-details > div:last-child { border: 0; }
.bio-details dt { color: #dcc1c7; font-weight: 500; }
.bio-details dd { margin: 0; }
.bio-details .tag { white-space: normal; }
.bio-narrative { margin: 0; color: #e9dde0; font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.bio-narrative.unknown { color: #c0adb3; font-style: italic; }
.bio-scores > div { display: grid; grid-template-columns: minmax(74px, 1fr) minmax(0, 1.6fr) 35px; align-items: center; gap: 6px; margin: 8px 0; font-size: 12px; }
.bio-scores dd { grid-column: 2 / -1; display: grid; grid-template-columns: minmax(0, 1fr) 35px; align-items: center; gap: 6px; margin: 0; }
.bio-scores dd span:last-child { text-align: right; font: 10px/1.25 var(--mono); }
.bio-score-bars { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 2px; }
.bio-score-bars i { height: 7px; background: #432e38; border-radius: 1px; }
.bio-score-bars .filled { background: #c36a7b; }
.bio-threat-panel { display: flex; justify-content: space-between; gap: 12px; }
.bio-threat { display: grid; place-content: center; gap: 2px; flex: none; min-width: 59px; padding: 7px; border: 1px solid #85515c; background: #3b222b; color: #efb8c0; text-align: center; }
.bio-threat span { font: 9px var(--mono); text-transform: uppercase; }
.bio-threat strong { font: 31px/1 var(--serif); }
.bio-sheet-footer { display: grid; grid-template-columns: minmax(0, 58fr) minmax(0, 42fr); gap: 11px; margin-top: 11px; }
.bio-instructions { display: flex; align-items: flex-start; gap: 10px; }
.bio-instructions .icon { color: var(--accent); width: 24px; height: 24px; }
.dossier-footer { margin-top: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); font: 11px/1.4 var(--mono); text-transform: uppercase; letter-spacing: .07em; }
.dossier-footer button { margin-inline-start: auto; font-family: system-ui, sans-serif; }

@media (max-width: 1160px) {
  .category { gap: 8px; padding: 12px; grid-template-columns: auto minmax(0, 1fr) auto; }
  .category-arrow { display: none; }
}
@media (max-width: 1040px) {
  .categories { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 890px) {
  .frame { width: calc(100% - 40px); }
}
@media (max-width: 670px) {
  .frame { width: calc(100% - 28px); }
  .masthead-inner { min-height: 65px; }
  .masthead-actions { gap: 5px; }
  .identity-title { font-size: 17px; }
  .identity-label { font-size: 9px; letter-spacing: .08em; }
  .masthead-inner:has(.masthead-actions > :not([hidden])) { flex-wrap: wrap; padding-block: 11px; gap: 9px; }
  .masthead-actions { justify-content: flex-start; }
  .masthead-actions .admin-link, .masthead-actions .session-button { min-height: 38px; font-size: 12px; padding-inline: 8px; }
  .registry-access { grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 13px; }
  .registry-access .access-actions { grid-column: 2; }
  .hero { min-height: 282px; margin-top: 14px; }
  .hero::before { background-position: 69% center; }
  .hero::after { background: linear-gradient(90deg, #151116f5, #20151bd4 38%, #20141a61 100%); }
  .hero-inner { padding: 27px 19px; }
  .hero h1 { font-size: clamp(36px, 9.4vw, 54px); }
  .hero p { font-size: 14px; }
  .hero-mark { top: 13px; right: 13px; font-size: 12px; padding: 4px; }
  .categories { grid-template-columns: 1fr; gap: 7px; margin-top: 9px; }
  .category { min-height: 59px; padding: 8px 11px; gap: 10px; }
  .category-icon { width: 34px; height: 34px; }
  .category-text { gap: 2px; }
  .register { margin-top: 28px; }
  .controls { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .search { grid-column: 1 / -1; }
  .search kbd { display: none; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .record-content { padding: 10px; }
  .record-open { font-size: 11px; }
  .footer { flex-wrap: wrap; gap: 5px 12px; margin-top: 25px; }
  .bio-columns, .bio-sheet-footer { grid-template-columns: minmax(0, 1fr); }
  .bio-sheet-header { grid-template-columns: auto minmax(0, 1fr); }
  .bio-hokage { display: none; }
  .bio-portrait img, .bio-portrait-placeholder { max-height: 290px; }
  .bio-portrait-placeholder { aspect-ratio: 4 / 3; }
}
@media (max-width: 360px) {
  .hero-mark { display: none; }
  .hero .eyebrow { font-size: 10px; letter-spacing: .09em; }
  .tag { padding-inline: 4px; font-size: 10px; }
  .masthead-inner, .identity { gap: 7px; }
  .admin-link { padding-inline: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
