/* Kura Vault admin. Palette from a kura storehouse wall: lime plaster above,
   namako slate tiles in a white lattice below, indigo for actions. */
:root {
  --plaster: #f1f2ef;
  --plaster-2: #e6e8e3;
  --paper: #fbfbfa;
  --slate: #2f343b;
  --slate-2: #3a4049;
  --lattice: #e8eae6;
  --ink: #23272d;
  --ink-2: #5b626c;
  --ink-3: #8a919a;
  --line: #d6d9d3;
  --indigo: #2d4b7c;
  --indigo-2: #233c64;
  --rust: #8e4426;
  --moss: #4d7a4e;
  --ochre: #a87a1f;
  --sans: "Avenir Next", "Avenir", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mincho: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif CJK JP", "Noto Serif JP", serif;
  --s13: 0.8125rem;
  --s15: 0.9375rem;
  --s19: 1.1875rem;
  --s26: 1.625rem;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 400 var(--s15)/1.5 var(--sans);
  color: var(--ink);
  background: var(--plaster);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--indigo); }
:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  color: var(--lattice);
  background-color: var(--slate);
  /* namako-kabe: raised white joints on a diagonal grid */
  background-image:
    repeating-linear-gradient(45deg, transparent 0 25px, rgba(232,234,230,.10) 25px 27px),
    repeating-linear-gradient(-45deg, transparent 0 25px, rgba(232,234,230,.10) 25px 27px);
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px 18px; text-decoration: none; color: inherit; }
.mark {
  font: 600 30px/1 var(--mincho);
  width: 46px; height: 46px; display: grid; place-items: center;
  background: var(--lattice); color: var(--slate); border-radius: 3px;
}
.brand-name { font-size: var(--s19); font-weight: 600; letter-spacing: .01em; }
.brand-sub { font-size: var(--s13); color: #b9bfc7; }

.nav { padding: 6px 10px 20px; display: flex; flex-direction: column; gap: 2px; }
.nav h2 { font-size: var(--s13); font-weight: 500; color: #aab1ba; margin: 18px 10px 6px; }
.nav a {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding: 7px 10px; border-radius: 6px; color: var(--lattice); text-decoration: none;
  background: rgba(47,52,59,.82);
}
.nav a:hover { background: var(--slate-2); }
.nav a.on { background: var(--lattice); color: var(--slate); font-weight: 600; }
.nav .count { font-size: var(--s13); opacity: .7; }
.side-foot { margin-top: auto; padding: 14px 20px 20px; font-size: var(--s13); color: #aab1ba; background: rgba(47,52,59,.9); }
.side-foot button { background: none; border: 0; padding: 0; color: var(--lattice); text-decoration: underline; cursor: pointer; }

.main { min-width: 0; padding: 22px 32px 60px; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 22px; }
.bar h1 { font-size: var(--s26); font-weight: 600; margin: 0 auto 0 0; letter-spacing: -.01em; }
.bar h1 small { font-size: var(--s15); font-weight: 400; color: var(--ink-2); margin-left: 10px; }

.input {
  height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--paper); min-width: 0;
}
.input:focus { border-color: var(--indigo); outline: none; box-shadow: 0 0 0 3px rgba(45,75,124,.15); }
.search { width: 200px; }

.btn {
  height: 36px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--paper); cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; color: var(--ink);
}
.btn:hover { border-color: #b9bdb6; }
.btn.primary { background: var(--indigo); border-color: var(--indigo); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--indigo-2); }
.btn.danger { color: var(--rust); border-color: #d9b8aa; }
.btn.danger:hover { background: #f6ece8; }
.btn.small { height: 28px; padding: 0 10px; font-size: var(--s13); }
.btn:disabled { opacity: .5; cursor: default; }
.linkish { background: none; border: 0; padding: 0; color: var(--indigo); cursor: pointer; text-decoration: underline; font-size: inherit; }

/* ---------- cover shelf ---------- */
.shelf-group { margin-bottom: 34px; }
.shelf-group h2 { font-size: var(--s19); font-weight: 600; margin: 0 0 12px; display: flex; gap: 10px; align-items: baseline; }
.shelf-group h2 span { font-size: var(--s13); font-weight: 400; color: var(--ink-2); }
.shelf {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 18px;
}
.tile { display: flex; flex-direction: column; gap: 8px; cursor: pointer; text-align: left; background: none; border: 0; padding: 0; }
.tile .art {
  height: 200px; display: flex; align-items: flex-end; justify-content: center;
  border-bottom: 3px solid var(--plaster-2); /* the shelf edge */
  padding-bottom: 6px;
}
.tile img {
  max-width: 100%; max-height: 194px; object-fit: contain; display: block;
  box-shadow: 0 1px 2px rgba(35,39,45,.18), 0 6px 14px -6px rgba(35,39,45,.35);
  border-radius: 2px; background: var(--paper);
}
.tile:hover img, .tile:focus-visible img { transform: translateY(-3px); transition: transform .15s ease; }
.noart {
  width: 128px; height: 176px; border-radius: 2px; padding: 12px 10px;
  background: var(--slate); color: var(--lattice);
  display: flex; flex-direction: column; justify-content: space-between;
  font-size: var(--s13); line-height: 1.3; overflow: hidden;
}
.noart b { font: 600 22px/1 var(--mincho); opacity: .55; }
.tile .t { font-size: var(--s13); font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile .m { font-size: var(--s13); color: var(--ink-2); margin-top: -6px; display: flex; gap: 6px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--ink-3); }
.dot.verified { background: var(--moss); }
.dot.rename { background: var(--ochre); }
.dot.partial { background: var(--rust); }
.dot.unknown { background: var(--rust); }

.empty { padding: 48px 0; color: var(--ink-2); max-width: 46ch; }
.empty h2 { color: var(--ink); font-size: var(--s19); margin: 0 0 6px; }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(35,39,45,.35); z-index: 10; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); z-index: 11;
  background: var(--paper); box-shadow: -10px 0 30px rgba(35,39,45,.2);
  overflow-y: auto; padding: 24px 28px 40px;
  animation: slidein .18s ease-out;
}
@keyframes slidein { from { transform: translateX(24px); opacity: .6; } }
.drawer .close { position: absolute; top: 18px; right: 18px; }
.d-head { display: grid; grid-template-columns: 140px 1fr; gap: 20px; margin-bottom: 22px; padding-right: 40px; }
.d-head img, .d-head .noart { width: 140px; height: auto; border-radius: 3px; box-shadow: 0 6px 18px -8px rgba(35,39,45,.5); }
.d-head .noart { height: 190px; width: 140px; }
.d-head h2 { font-size: var(--s26); line-height: 1.15; margin: 0 0 6px; letter-spacing: -.01em; }
.d-head .file { font-size: var(--s13); color: var(--ink-2); word-break: break-word; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag { font-size: var(--s13); padding: 1px 8px; border-radius: 999px; background: var(--plaster-2); color: var(--ink-2); }

.section { border-top: 1px solid var(--line); padding: 18px 0; }
.section h3 { font-size: var(--s15); font-weight: 600; margin: 0 0 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row .input { flex: 1; }
.help { font-size: var(--s13); color: var(--ink-2); margin: 6px 0 0; }
.err { font-size: var(--s13); color: var(--rust); margin: 6px 0 0; }

.matchbox { border-radius: 8px; padding: 12px 14px; background: var(--plaster); font-size: var(--s15); }
.matchbox.verified { background: #e6efe5; }
.matchbox.rename { background: #f5eddb; }
.matchbox.partial, .matchbox.unknown { background: #f1e6e1; }
.matchbox p { margin: 0 0 4px; }
.matchbox .sugg { font-weight: 600; word-break: break-word; }

.files { width: 100%; border-collapse: collapse; font-size: var(--s13); }
.files td { padding: 6px 0; border-bottom: 1px solid var(--plaster-2); vertical-align: top; }
.files td:last-child { text-align: right; color: var(--ink-2); white-space: nowrap; padding-left: 12px; }
.hash { font-size: 12px; color: var(--ink-3); word-break: break-all; }

.art-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; margin-top: 12px; }
.art-pick { background: none; border: 2px solid transparent; border-radius: 6px; padding: 4px; cursor: pointer; text-align: left; }
.art-pick:hover { border-color: var(--line); }
.art-pick img { width: 100%; height: 120px; object-fit: contain; display: block; }
.art-pick span { display: block; font-size: 11px; color: var(--ink-2); line-height: 1.25; margin-top: 4px; max-height: 2.5em; overflow: hidden; }
.art-pick.missing { display: none; }

/* ---------- panels / tables ---------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin-bottom: 18px; }
.panel h2 { font-size: var(--s19); margin: 0 0 4px; }
.panel > p { margin: 0 0 12px; color: var(--ink-2); max-width: 70ch; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: var(--s13); font-weight: 500; color: var(--ink-2); padding: 0 10px 8px 0; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 10px 10px 0; border-bottom: 1px solid var(--plaster-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table .name { word-break: break-word; }
.table .old { color: var(--ink-2); text-decoration: line-through; text-decoration-color: var(--ink-3); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.chip { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; font-size: var(--s13); }
.chip.on { background: var(--slate); color: var(--lattice); border-color: var(--slate); }

/* ---------- upload ---------- */
.drop {
  border: 2px dashed #c3c7c0; border-radius: 12px; padding: 34px 20px; text-align: center;
  background: var(--paper); color: var(--ink-2); margin-bottom: 18px; cursor: pointer;
}
.drop strong { display: block; color: var(--ink); font-size: var(--s19); margin-bottom: 4px; }
.drop.over { border-color: var(--indigo); background: #eef1f7; }
.bar-prog { height: 4px; background: var(--plaster-2); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.bar-prog i { display: block; height: 100%; background: var(--indigo); width: 0; transition: width .2s; }
.up-name { font-weight: 600; word-break: break-all; }
.up-sub { font-size: var(--s13); color: var(--ink-2); }
.up-match { font-size: var(--s13); color: var(--moss); }
.table select.input, .table input.input { height: 32px; width: 100%; }
.import-bar {
  position: sticky; bottom: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  box-shadow: 0 -6px 20px -12px rgba(35,39,45,.4); margin-top: 14px;
}
.import-bar .input { flex: 1; min-width: 200px; }

/* ---------- bios / status ---------- */
.bios-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.bios-list { list-style: none; margin: 10px 0 0; padding: 0; font-size: var(--s13); max-height: 260px; overflow-y: auto; }
.bios-list li { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; }
.bios-list .st { width: 74px; flex: none; }
.st.ok { color: var(--moss); font-weight: 600; }
.st.different { color: var(--ochre); font-weight: 600; }
.st.missing { color: var(--ink-3); }
.meter { height: 6px; border-radius: 3px; background: var(--plaster-2); overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; background: var(--moss); }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stat b { display: block; font-size: var(--s26); font-weight: 600; line-height: 1.2; }
.stat span { font-size: var(--s13); color: var(--ink-2); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background-color: var(--slate);
  background-image:
    repeating-linear-gradient(45deg, transparent 0 25px, rgba(232,234,230,.10) 25px 27px),
    repeating-linear-gradient(-45deg, transparent 0 25px, rgba(232,234,230,.10) 25px 27px);
}
.login { width: min(380px, 100%); background: var(--paper); border-radius: 12px; padding: 30px 28px; box-shadow: 0 20px 50px -20px rgba(0,0,0,.6); }
.login .mark { width: 56px; height: 56px; font-size: 36px; background: var(--slate); color: var(--lattice); margin-bottom: 16px; }
.login h1 { font-size: var(--s26); margin: 0 0 4px; }
.login p { color: var(--ink-2); margin: 0 0 18px; }
.login .input { width: 100%; margin-bottom: 12px; }
.login .btn { width: 100%; justify-content: center; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  background: var(--slate); color: var(--lattice); padding: 10px 16px; border-radius: 8px;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.5); max-width: 90vw;
}
.toast.bad { background: var(--rust); color: #fff; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .brand { padding: 14px 16px 8px; }
  .nav { flex-direction: row; flex-wrap: wrap; padding: 0 8px 12px; gap: 4px; }
  .nav h2 { width: 100%; margin: 6px 6px 0; }
  .nav a { padding: 4px 9px; font-size: var(--s13); }
  .side-foot { display: none; }
  .main { padding: 18px 16px 60px; }
  .search { width: 100%; }
  .shelf { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 18px 14px; }
  .tile .art { height: 150px; }
  .tile img { max-height: 144px; }
  .noart { width: 100px; height: 140px; }
  .d-head { grid-template-columns: 96px 1fr; }
  .d-head img, .d-head .noart { width: 96px; }
  .d-head .noart { height: 130px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* official-name finder in the game drawer */
.finder { margin-top: 14px; }
.finder h4 { font-size: var(--s15); font-weight: 600; margin: 0 0 8px; }
.finder .input { width: 100%; }
.finder-list { margin-top: 6px; }
.finder-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--plaster-2); }
.finder-row:last-child { border-bottom: 0; }
.finder-name { min-width: 0; word-break: break-word; font-size: var(--s13); }
.score { font-size: var(--s13); color: var(--ink-2); min-width: 3.2em; text-align: right; }
.dot.named { background: var(--indigo); }
@media (max-width: 820px) {
  .finder-row { grid-template-columns: 1fr auto; }
  .finder-row .row { grid-column: 1 / -1; }
}

/* selection mode on the shelf */
.tile .art { position: relative; }
.tile.selecting img, .tile.selecting .noart { opacity: .55; transition: opacity .12s; }
.tile.picked img, .tile.picked .noart { opacity: 1; outline: 3px solid var(--indigo); outline-offset: 3px; }
.tile .check {
  position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(251,251,250,.9); border: 2px solid var(--ink-3);
}
.tile.picked .check { background: var(--indigo); border-color: var(--indigo); }
.tile.picked .check::after { content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.select-bar {
  position: sticky; bottom: 12px; z-index: 5; margin-top: 18px;
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  background: var(--slate); color: var(--lattice); border-radius: 10px; padding: 10px 14px;
  box-shadow: 0 10px 30px -12px rgba(0,0,0,.5);
}
.select-bar .linkish { color: var(--lattice); }

/* modal */
.modal-scrim { position: fixed; inset: 0; z-index: 30; background: rgba(35,39,45,.45); display: grid; place-items: center; padding: 20px; }
.modal {
  width: min(720px, 100%); max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--paper); border-radius: 12px; padding: 22px 24px; box-shadow: 0 30px 60px -20px rgba(0,0,0,.5);
  outline: none;
}
.modal h2 { font-size: var(--s19); margin: 0 0 6px; }
.modal.busy { opacity: .6; pointer-events: none; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; align-items: center; }
.modal-scroll { max-height: 46vh; overflow-y: auto; border-top: 1px solid var(--plaster-2); }
.undo-table .old { font-size: var(--s13); }

/* wizard */
.wiz-head { display: flex; align-items: center; font-size: var(--s13); color: var(--ink-2); margin-bottom: 16px; }
.wiz-game { display: grid; grid-template-columns: 96px 1fr; gap: 16px; margin-bottom: 14px; align-items: start; }
.wiz-game img, .wiz-game .noart { width: 96px; height: auto; border-radius: 3px; }
.wiz-game .noart { height: 130px; }
.wiz-game h2 { margin: 0 0 4px; font-size: var(--s26); line-height: 1.15; }
.wiz-game .file { font-size: var(--s13); color: var(--ink-2); word-break: break-word; }
.modal > .input { width: 100%; margin-bottom: 8px; }
.wiz-list { display: flex; flex-direction: column; gap: 6px; }
.wiz-opt {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; text-align: left;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); cursor: pointer;
}
.wiz-opt:hover, .wiz-opt:focus-visible { border-color: var(--indigo); background: #eef1f7; }
.wiz-key { width: 24px; height: 24px; border-radius: 5px; background: var(--plaster-2); display: grid; place-items: center; font-size: var(--s13); font-weight: 600; }
.wiz-name { display: flex; flex-direction: column; min-width: 0; word-break: break-word; }

/* multi-disc */
.disc-list { margin: 0 0 10px; padding-left: 1.4em; font-size: var(--s13); }
.disc-list li { padding: 2px 0; word-break: break-word; }
.group-list { margin: 0; padding: 0; list-style: none; counter-reset: disc; border-top: 1px solid var(--plaster-2); }
.group-list li { counter-increment: disc; display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--plaster-2); font-size: var(--s13); }
.group-list li::before { content: "Disc " counter(disc); color: var(--ink-2); min-width: 4em; }
.group-list .name { word-break: break-word; }

/* updates and DLC */
.tag.role-update { background: #e3e8f2; color: var(--indigo); }
.tag.role-dlc { background: #efe6d4; color: #7a5a17; }
.group-list.parts li { grid-template-columns: 1fr auto; }
.group-list.parts li::before { content: none; }
