/*
 * My Mochi World Wiki — MediaWiki/Fandom-style layout.
 * Sidebar navigation, article with tabs, infobox, contents box, thumbnails,
 * wikitables, navbox, image gallery and a media viewer lightbox.
 * Loaded after styles.css on /wiki pages only; every class is prefixed `wk-` (or `mv-` for the viewer).
 */
:root {
  --wk-serif: "Linux Libertine", "Georgia", "Times New Roman", serif;
  --wk-line: rgba(242, 155, 184, 0.24);
  --wk-line-soft: rgba(242, 155, 184, 0.14);
  --wk-surface: rgba(19, 17, 42, 0.96);
  --wk-inset: rgba(11, 10, 26, 0.72);
  --wk-head: rgba(242, 155, 184, 0.14);
  --wk-body-text: #ece6f7;
}

/* Shell */
.wk-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

/* Sidebar */
.wk-sidebar {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  scrollbar-width: thin;
  font-size: 0.88rem;
}

.wk-wordmark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 8px 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--wk-line);
  color: var(--gold);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.wk-wordmark:hover {
  text-decoration: none;
  color: var(--pink);
}

.wk-wordmark img {
  display: block;
  width: 150px;
  height: auto;
}

.wk-nav > summary {
  display: none;
}

.wk-portlet {
  margin: 0 0 14px;
}

.wk-portlet h2 {
  margin: 0;
  padding: 0 8px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--wk-line-soft);
}

.wk-portlet ul {
  list-style: none;
  margin: 0;
  padding: 4px 0 0;
}

.wk-portlet a {
  display: block;
  padding: 3px 8px;
  border-radius: 5px;
}

.wk-portlet a:hover {
  background: rgba(242, 155, 184, 0.1);
  text-decoration: none;
}

.wk-portlet a[aria-current="page"] {
  background: rgba(242, 155, 184, 0.16);
  color: var(--gold);
  font-weight: 700;
}

/* Article frame */
.wk-article {
  min-width: 0;
  background: var(--wk-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.wk-tabs {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 0 18px;
  border-bottom: 1px solid var(--wk-line);
  overflow-x: auto;
  scrollbar-width: none;
}

.wk-tab {
  padding: 11px 14px 9px;
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.wk-tab:hover {
  color: var(--text);
  text-decoration: none;
}

.wk-tab[aria-current="page"] {
  color: var(--gold);
  border-bottom-color: var(--pink);
}

.wk-tab-end {
  margin-left: auto;
}

.wk-page {
  padding: 16px 28px 28px;
}

.wk-crumbs {
  margin: 0 0 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

.wk-title {
  margin: 0;
  padding-bottom: 6px;
  font-family: var(--wk-serif);
  font-weight: 400;
  font-size: clamp(1.7rem, 3.4vw, 2.2rem);
  line-height: 1.25;
  color: var(--text);
  border-bottom: 1px solid var(--wk-line);
}

.wk-tagline {
  margin: 6px 0 16px;
  font-size: 0.84rem;
  color: var(--muted);
}

.wk-title + .wk-content {
  margin-top: 16px;
}

/* Article body */
.wk-content {
  display: flow-root;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--wk-body-text);
}

.wk-content p {
  margin: 0 0 12px;
}

.wk-content h2 {
  overflow: hidden;
  margin: 26px 0 10px;
  padding-bottom: 4px;
  font-family: var(--wk-serif);
  font-weight: 400;
  font-size: 1.5rem;
  line-height: 1.3;
  color: var(--gold);
  border-bottom: 1px solid var(--wk-line);
  scroll-margin-top: 80px;
}

.wk-content h3 {
  overflow: hidden;
  margin: 18px 0 6px;
  font-size: 1.06rem;
  font-weight: 700;
  color: var(--text);
  scroll-margin-top: 80px;
}

.wk-content ul,
.wk-content ol {
  margin: 0 0 12px;
  padding-left: 22px;
}

.wk-content li {
  margin-bottom: 4px;
}

.wk-content strong {
  color: var(--text);
}

.wk-content code {
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.82em;
  color: var(--gold);
  background: var(--wk-inset);
  border: 1px solid var(--wk-line);
  border-bottom-width: 2px;
  border-radius: 4px;
  white-space: nowrap;
}

.wk-hatnote {
  margin: -2px 0 12px;
  padding-left: 1.6em;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--muted);
}

/* Infobox (portable-infobox style) */
.wk-infobox {
  float: right;
  clear: right;
  width: 290px;
  margin: 0 0 16px 24px;
  font-size: 0.86rem;
  line-height: 1.45;
  background: var(--wk-inset);
  border: 1px solid var(--wk-line);
  border-radius: 8px;
  overflow: hidden;
}

.wk-infobox-title {
  margin: 0;
  padding: 9px 12px;
  font-family: var(--wk-serif);
  font-size: 1.2rem;
  font-weight: 400;
  text-align: center;
  color: var(--text);
  background: linear-gradient(135deg, rgba(242, 155, 184, 0.34), rgba(255, 227, 163, 0.16));
}

.wk-infobox-image {
  margin: 0;
  padding: 10px;
  text-align: center;
  border-bottom: 1px solid var(--wk-line-soft);
}

.wk-infobox-image img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
}

.wk-infobox-image.is-sprite img {
  width: 128px;
  margin: 0 auto;
  image-rendering: pixelated;
}

.wk-infobox-image figcaption {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.wk-infobox-section {
  margin: 0;
  padding: 5px 12px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  color: var(--gold);
  background: var(--wk-head);
}

.wk-infobox dl {
  margin: 0;
}

.wk-infobox-row {
  display: grid;
  grid-template-columns: 40% 1fr;
  gap: 10px;
  padding: 7px 12px;
  border-top: 1px solid var(--wk-line-soft);
}

.wk-infobox dt {
  font-weight: 700;
  color: var(--text);
}

.wk-infobox dd {
  margin: 0;
  color: var(--wk-body-text);
}

/* Contents box */
.wk-toc {
  display: inline-block;
  min-width: 230px;
  max-width: 100%;
  margin: 4px 0 14px;
  padding: 9px 16px 11px;
  font-size: 0.88rem;
  line-height: 1.6;
  background: var(--wk-inset);
  border: 1px solid var(--wk-line);
  border-radius: 6px;
}

.wk-toc-title {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
  font-weight: 700;
  color: var(--text);
}

.wk-toc-toggle {
  padding: 0;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--pink);
  background: none;
  border: 0;
  cursor: pointer;
}

.wk-toc-toggle::before {
  content: "[";
  color: var(--muted);
}

.wk-toc-toggle::after {
  content: "]";
  color: var(--muted);
}

.wk-toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.wk-toc ol ol {
  padding-left: 1.6em;
}

.wk-toc li {
  margin: 0;
}

.wk-tocnumber {
  display: inline-block;
  min-width: 1.4em;
  margin-right: 4px;
  color: var(--muted);
}

.wk-toc.is-collapsed > ol {
  display: none;
}

/* Thumbnails */
.wk-thumb {
  width: var(--wk-thumb-w, 300px);
  max-width: 100%;
  margin: 4px 0 14px;
  padding: 4px;
  background: var(--wk-inset);
  border: 1px solid var(--wk-line);
  border-radius: 6px;
}

.wk-thumb.is-right {
  float: right;
  clear: right;
  margin-left: 22px;
}

.wk-thumb.is-center {
  margin-left: auto;
  margin-right: auto;
}

.wk-thumb > a {
  display: block;
}

.wk-thumb img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 3px;
}

.wk-thumb figcaption {
  padding: 6px 4px 2px;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted);
}

/* Wikitables */
.wk-table-wrap {
  overflow-x: auto;
  margin: 0 0 16px;
}

.wk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  line-height: 1.5;
  background: rgba(11, 10, 26, 0.5);
}

.wk-table th,
.wk-table td {
  padding: 7px 10px;
  text-align: left;
  vertical-align: middle;
  border: 1px solid var(--wk-line);
}

.wk-table th {
  color: var(--gold);
  font-weight: 700;
  background: var(--wk-head);
}

.wk-table tbody th {
  color: var(--text);
  background: rgba(242, 155, 184, 0.07);
}

.wk-table tr:target td,
.wk-table tr:target th {
  background: rgba(255, 227, 163, 0.1);
}

.wk-table tr {
  scroll-margin-top: 90px;
}

.wk-table .wk-nowrap {
  white-space: nowrap;
}

.wk-table .wk-cell-img {
  width: 1%;
  padding: 4px;
  text-align: center;
}

.wk-table .wk-sprite {
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 auto;
  image-rendering: pixelated;
}

.wk-table .wk-room-img {
  display: block;
  width: 168px;
  height: auto;
  border-radius: 3px;
}

/* Image gallery */
.wk-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(176px, 100%), 1fr));
  gap: 10px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.wk-gallery.is-wide {
  grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr));
}

.wk-gallerybox {
  display: flex;
  flex-direction: column;
  margin: 0;
  background: var(--wk-inset);
  border: 1px solid var(--wk-line);
  border-radius: 6px;
  overflow: hidden;
  scroll-margin-top: 90px;
  transition: border-color 0.15s ease;
}

.wk-gallerybox:hover,
.wk-gallerybox:target {
  border-color: var(--border-strong);
}

.wk-gallery-img {
  display: block;
  aspect-ratio: 16 / 10;
  padding: 6px;
  background: radial-gradient(circle at 50% 55%, rgba(242, 155, 184, 0.14), rgba(11, 10, 26, 0.9) 80%);
}

.wk-gallery-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.wk-gallerytext {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 1px;
  padding: 6px 9px 8px;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted);
  border-top: 1px solid var(--wk-line-soft);
}

.wk-gallerytext b {
  font-size: 0.82rem;
  color: var(--text);
}

.wk-file-meta {
  margin-top: auto;
  padding-top: 3px;
  font-size: 0.74rem;
  opacity: 0.85;
}

.wk-section-count {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 0.8rem;
  color: var(--muted);
}

/* License template */
.wk-license {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin: 0 0 16px;
  padding: 12px 16px;
  font-size: 0.9rem;
  background: rgba(140, 193, 82, 0.07);
  border: 1px solid rgba(140, 193, 82, 0.4);
  border-left: 6px solid var(--good);
  border-radius: 6px;
  scroll-margin-top: 90px;
}

.wk-license-badge {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--bg-deep);
  background: var(--good);
  border-radius: 50%;
}

.wk-license p {
  margin: 0 0 6px;
}

.wk-license p:last-child {
  margin-bottom: 0;
}

/* Navbox */
.wk-navbox {
  clear: both;
  margin: 30px 0 0;
  font-size: 0.84rem;
  line-height: 1.55;
  border: 1px solid var(--wk-line);
  border-radius: 6px;
  overflow: hidden;
}

.wk-navbox-title {
  margin: 0;
  padding: 6px 12px;
  font-size: 0.92rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  background: linear-gradient(135deg, rgba(242, 155, 184, 0.3), rgba(255, 227, 163, 0.14));
}

.wk-navbox-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  border-top: 1px solid var(--wk-line-soft);
}

.wk-navbox-group {
  padding: 5px 12px;
  font-weight: 700;
  text-align: right;
  color: var(--gold);
  background: var(--wk-head);
}

.wk-navbox-list {
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 5px 12px;
  list-style: none;
}

.wk-navbox-list li:not(:last-child)::after {
  content: "\00a0·\00a0";
  color: var(--muted);
}

.wk-navbox-list strong {
  color: var(--text);
}

/* Main Page */
.wk-mp-welcome {
  margin: 0 0 18px;
  padding: 16px 20px;
  text-align: center;
  background: radial-gradient(circle at 50% 0%, rgba(242, 155, 184, 0.18), rgba(11, 10, 26, 0.6) 75%);
  border: 1px solid var(--wk-line);
  border-radius: 8px;
}

.wk-mp-welcome p {
  margin: 0;
}

.wk-mp-welcome .wk-mp-lead {
  font-family: var(--wk-serif);
  font-size: 1.25rem;
  color: var(--text);
}

.wk-mp-stats {
  margin-top: 6px !important;
  font-size: 0.86rem;
  color: var(--muted);
}

.wk-mp-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.wk-mp-col {
  display: grid;
  gap: 16px;
}

.wk-mp-box {
  background: rgba(11, 10, 26, 0.5);
  border: 1px solid var(--wk-line);
  border-radius: 8px;
  overflow: hidden;
}

.wk-content .wk-mp-box > h2 {
  margin: 0;
  padding: 6px 12px;
  font-size: 1.1rem;
  background: var(--wk-head);
  border-bottom: 1px solid var(--wk-line);
}

.wk-mp-body {
  padding: 12px 14px;
}

.wk-mp-body > :last-child {
  margin-bottom: 0;
}

.wk-mp-list {
  list-style: none;
  margin: 0 !important;
  padding: 0 !important;
}

.wk-mp-list li {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin: 0;
  padding: 8px 0;
  border-top: 1px solid var(--wk-line-soft);
}

.wk-mp-list li:first-child {
  padding-top: 0;
  border-top: 0;
}

.wk-mp-list li:last-child {
  padding-bottom: 0;
}

.wk-mp-thumb {
  display: block;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--wk-line-soft);
  background: var(--wk-inset);
}

.wk-mp-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wk-mp-thumb.is-sprite img {
  object-fit: contain;
  image-rendering: pixelated;
}

.wk-mp-list b {
  display: block;
}

.wk-mp-list span {
  display: block;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--muted);
}

.wk-mp-pets {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin: 0 0 10px !important;
  padding: 0 !important;
  list-style: none;
}

.wk-mp-pets li {
  margin: 0;
}

.wk-mp-pets a {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 64px;
  font-size: 0.74rem;
  color: var(--muted);
}

.wk-mp-pets a:hover {
  color: var(--pink);
  text-decoration: none;
}

.wk-mp-pets img {
  width: 56px;
  height: 56px;
  image-rendering: pixelated;
}

.wk-mp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Media viewer (lightbox) */
html:has(.mv[open]) {
  overflow: hidden;
}

.mv {
  width: min(1180px, calc(100vw - 24px));
  max-width: none;
  max-height: calc(100vh - 24px);
  padding: 0;
  color: var(--text);
  background: #0b0a18;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.75);
  overflow: hidden;
}

.mv::backdrop {
  background: rgba(5, 4, 12, 0.88);
}

.mv-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: min(70vh, 720px);
  padding: 14px 64px;
  background: radial-gradient(circle at 50% 50%, rgba(242, 155, 184, 0.1), rgba(5, 4, 12, 0.95) 75%);
}

.mv-stage img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.mv-btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--text);
  background: rgba(24, 21, 50, 0.88);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
}

.mv-btn:hover,
.mv-btn:focus-visible {
  border-color: var(--pink);
  color: var(--gold);
}

.mv-prev,
.mv-next {
  top: 50%;
  transform: translateY(-50%);
}

.mv-prev {
  left: 12px;
}

.mv-next {
  right: 12px;
}

.mv-close {
  top: 10px;
  right: 10px;
}

.mv-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  padding: 12px 18px 14px;
  border-top: 1px solid var(--wk-line);
}

.mv-text {
  min-width: 0;
  flex: 1 1 340px;
}

.mv-title {
  margin: 0;
  font-weight: 700;
  color: var(--gold);
}

.mv-caption {
  margin: 2px 0 0;
  font-size: 0.88rem;
  color: var(--wk-body-text);
}

.mv-meta {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.mv-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.mv-counter {
  font-size: 0.82rem;
  color: var(--muted);
}

/* Responsive */
@media (max-width: 900px) {
  .wk-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding-top: 14px;
  }

  .wk-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .wk-wordmark {
    display: none;
  }

  .wk-nav {
    background: var(--wk-surface);
    border: 1px solid var(--border);
    border-radius: 10px;
  }

  .wk-nav > summary {
    display: block;
    padding: 10px 14px;
    font-weight: 700;
    color: var(--gold);
    cursor: pointer;
  }

  .wk-nav[open] > summary {
    border-bottom: 1px solid var(--wk-line);
  }

  .wk-nav-groups {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0 12px;
    padding: 10px 8px 4px;
  }

  .wk-mp-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .wk-page {
    padding: 14px 16px 22px;
  }

  .wk-tabs {
    padding: 0 8px;
  }

  .wk-infobox,
  .wk-thumb.is-right {
    float: none;
    width: 100%;
    margin: 0 0 16px;
  }

  .wk-toc {
    display: block;
  }

  .wk-navbox-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .wk-navbox-group {
    text-align: left;
  }

  .mv-stage {
    height: min(60vh, 520px);
    padding: 10px;
  }

  .mv-prev,
  .mv-next {
    top: auto;
    bottom: 10px;
    transform: none;
  }
}
