/* ClassicStory+ Library — MapleLegends-style dark theme */

:root {
  --ml-bg: #111111;
  --ml-bar: #1c1c1c;
  --ml-bar-border: #2e2e2e;
  --ml-panel: #242424;
  --ml-panel-inner: #2c2c2c;
  --ml-border: #3a3a3a;
  --ml-text: #f0f0f0;
  --ml-muted: #a8a8a8;
  --ml-link: #ffffff;
  --ml-accent: #ffb347;
  --ml-accent-dark: #e86a20;
  --ml-yellow: #ffd54f;
  --ml-green: #6ecf6e;
  --ml-font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --ml-radius: 6px;
  --ml-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body.ml-lib {
  min-height: 100vh;
  background: var(--ml-bg);
  color: var(--ml-text);
  font: 15px/1.5 var(--ml-font);
}

a {
  color: var(--ml-link);
  text-decoration: none;
  cursor: inherit !important;
}

a:hover {
  color: var(--ml-accent);
}

/* ── Top bar ── */
.ml-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 0 20px;
  min-height: 52px;
  background: var(--ml-bar);
  border-bottom: 1px solid var(--ml-bar-border);
}

.ml-brand {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  font-weight: 800;
  font-size: 1.05rem;
  white-space: nowrap;
  text-decoration: none;
  margin-right: 8px;
}

.ml-brand-classic {
  color: #fff;
}

.ml-brand-plus {
  color: var(--ml-accent);
}

.ml-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 4px;
  flex: 1 1 320px;
}

.ml-nav-link {
  padding: 8px 12px;
  color: #ddd;
  font-weight: 600;
  font-size: 0.92rem;
  border-radius: 4px;
  white-space: nowrap;
}

.ml-nav-link:hover,
.ml-nav-link.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.ml-nav-dropdown {
  position: relative;
}

.ml-nav-dropdown:hover .ml-nav-menu,
.ml-nav-dropdown:focus-within .ml-nav-menu {
  display: block;
}

.ml-nav-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 160px;
  margin: 0;
  padding: 6px 0;
  background: #2a2a2a;
  border: 1px solid var(--ml-border);
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  z-index: 100;
}

.ml-nav-menu a {
  display: block;
  padding: 8px 14px;
  color: #ddd;
  font-size: 0.9rem;
  font-weight: 600;
}

.ml-nav-menu a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.ml-top-search {
  display: flex;
  align-items: stretch;
  margin-left: auto;
  flex: 0 1 280px;
  min-width: 200px;
}

.ml-top-search input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--ml-border);
  border-right: 0;
  border-radius: var(--ml-radius) 0 0 var(--ml-radius);
  background: #333;
  color: #fff;
  padding: 8px 12px;
  font: inherit;
}

.ml-top-search input::placeholder {
  color: #888;
}

.ml-top-search button {
  border: 1px solid var(--ml-border);
  border-radius: 0 var(--ml-radius) var(--ml-radius) 0;
  background: #444;
  color: #fff;
  padding: 8px 14px;
  font: inherit;
  font-weight: 700;
  cursor: inherit !important;
}

.ml-top-search button:hover {
  background: #555;
}

/* ── Main layout ── */
.ml-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.ml-lib--home .ml-main {
  max-width: 1100px;
  padding-top: 24px;
}

/* ── Home hero (custom ClassicStory+ artwork) ── */
.ml-hero {
  width: 100%;
  max-width: 820px;
}

.ml-hero-panel {
  background: #2c2c2c;
  border: 1px solid var(--ml-border);
  border-radius: 10px;
  box-shadow: var(--ml-shadow);
  padding: 0;
  overflow: hidden;
}

.ml-hero-visual {
  position: relative;
  width: 100%;
  line-height: 0;
}

.ml-hero-image {
  display: block;
  width: 100%;
  height: auto;
  max-width: 820px;
  margin: 0 auto;
}

.ml-hero-visual .ml-hero-search {
  position: absolute;
  left: 11.5%;
  right: 11.5%;
  bottom: 7.5%;
  max-width: none;
  margin: 0;
  height: 11.5%;
  min-height: 38px;
}

.ml-hero-visual .ml-hero-search input {
  flex: 1;
  border: 0;
  border-radius: 4px 0 0 4px;
  background: #fff;
  color: #222;
  padding: 0 14px;
  font: inherit;
  font-size: clamp(0.9rem, 2.2vw, 1rem);
  height: 100%;
}

.ml-hero-visual .ml-hero-search input::placeholder {
  color: #888;
}

.ml-hero-visual .ml-hero-search button {
  flex: 0 0 clamp(88px, 18%, 120px);
  border: 0;
  border-radius: 0 4px 4px 0;
  background: transparent;
  color: transparent;
  cursor: inherit !important;
  height: 100%;
  padding: 0;
  overflow: hidden;
}

.ml-hero-search {
  display: flex;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
}

.ml-hero-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: var(--ml-radius) 0 0 var(--ml-radius);
  background: #fff;
  color: #222;
  padding: 12px 16px;
  font: inherit;
  font-size: 1rem;
}

.ml-hero-search input::placeholder {
  color: #888;
}

.ml-hero-search button {
  border: 0;
  border-radius: 0 var(--ml-radius) var(--ml-radius) 0;
  background: #444;
  color: #fff;
  padding: 12px 22px;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  cursor: inherit !important;
  white-space: nowrap;
}

.ml-hero-search button:hover {
  background: #555;
}

/* Legacy CSS art (unused on home; kept harmless if referenced elsewhere) */
.ml-hero-art,
.ml-hero-sparkles,
.ml-hero-tree,
.ml-hero-leaves,
.ml-hero-book,
.ml-hero-logo {
  display: none;
}

/* ── Browse toolbar (MapleLegends-style) ── */
.lib-browse-toolbar {
  margin-bottom: 16px;
}

.lib-browse-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  padding: 14px 16px;
  background: var(--ml-panel);
  border: 1px solid var(--ml-border);
  border-radius: 8px;
}

.lib-filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--ml-muted);
}

.lib-filter-field select,
.lib-filter-field input {
  border: 1px solid var(--ml-border);
  border-radius: 4px;
  background: #333;
  color: #fff;
  padding: 8px 10px;
  font: inherit;
  min-width: 120px;
}

.lib-filter-field--search input {
  min-width: 180px;
}

.lib-filter-submit {
  border: 1px solid var(--ml-border);
  border-radius: 4px;
  background: #444;
  color: #fff;
  padding: 9px 18px;
  font: inherit;
  font-weight: 700;
  cursor: inherit !important;
}

.lib-filter-submit:hover {
  background: #555;
}

.lib-table--browse .lib-col-icon {
  width: 48px;
  text-align: center;
}

.lib-icon {
  display: block;
  width: 32px;
  height: 32px;
  margin: 0 auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  object-fit: contain;
}

.lib-col-name a {
  color: var(--ml-green);
  font-weight: 700;
}

.lib-col-name a:hover {
  color: var(--ml-accent);
}

/* ── Inner pages ── */
.lib-page-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 20px;
}

.lib-page-head--detail {
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
}

.lib-detail-icon {
  width: 64px;
  height: 64px;
  object-fit: contain;
  image-rendering: pixelated;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--ml-border);
  border-radius: 10px;
  padding: 6px;
}

.lib-row-desc {
  display: block;
  margin-top: 4px;
  color: var(--ml-muted);
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.35;
}

.lib-minimap {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--ml-border);
  background: #111;
}

.lib-panel--media {
  display: flex;
  flex-direction: column;
}

.lib-page-head h1 {
  margin: 0 0 6px;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 800;
}

.lib-breadcrumb {
  color: var(--ml-muted);
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.lib-breadcrumb a {
  color: var(--ml-muted);
}

.lib-breadcrumb a:hover {
  color: var(--ml-accent);
}

.lib-id-line {
  color: var(--ml-muted);
  margin: 0;
}

.lib-inline-search {
  display: flex;
  gap: 0;
}

.lib-inline-search input {
  min-width: 220px;
  border: 1px solid var(--ml-border);
  border-right: 0;
  border-radius: var(--ml-radius) 0 0 var(--ml-radius);
  background: #333;
  color: #fff;
  padding: 10px 12px;
  font: inherit;
}

.lib-inline-search button {
  border: 1px solid var(--ml-border);
  border-radius: 0 var(--ml-radius) var(--ml-radius) 0;
  background: #444;
  color: #fff;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  cursor: inherit !important;
}

.lib-table-wrap {
  overflow: auto;
  background: var(--ml-panel);
  border: 1px solid var(--ml-border);
  border-radius: 8px;
  box-shadow: var(--ml-shadow);
}

.lib-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.lib-table th,
.lib-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--ml-border);
  text-align: left;
  vertical-align: top;
}

.lib-table th {
  background: var(--ml-panel-inner);
  color: var(--ml-muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.lib-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.lib-table a {
  color: var(--ml-green);
  font-weight: 600;
}

.lib-table a:hover {
  color: var(--ml-accent);
}

.lib-detail-grid,
.lib-feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.lib-panel {
  background: var(--ml-panel);
  border: 1px solid var(--ml-border);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--ml-shadow);
}

.lib-panel h2 {
  margin: 0 0 12px;
  font-size: 1.15rem;
}

.lib-panel p,
.lib-panel li,
.lib-muted,
.lib-desc {
  color: var(--ml-muted);
}

.lib-panel ul {
  margin: 0;
  padding-left: 18px;
}

.lib-panel li + li {
  margin-top: 6px;
}

.lib-panel a {
  color: var(--ml-green);
}

.lib-meta-list {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 14px;
  margin: 16px 0 0;
}

.lib-meta-list dt {
  color: var(--ml-muted);
  font-weight: 700;
}

.lib-meta-list dd {
  margin: 0;
}

.lib-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--ml-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ml-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}

.lib-badge--boss {
  border-color: rgba(232, 145, 58, 0.55);
  color: #f0b36a;
  background: rgba(232, 145, 58, 0.12);
}

.lib-flag-list {
  margin: 0;
  padding-left: 18px;
  color: var(--ml-muted);
}

.lib-flag-list li + li {
  margin-top: 6px;
}

.lib-drop-note {
  margin: 16px 0 0;
  font-size: 0.9rem;
}

.lib-drops-wrap {
  margin-top: 22px;
}

.lib-section-title span {
  color: var(--ml-muted);
  font-size: 0.85rem;
  font-weight: 600;
  margin-left: 8px;
}

.lib-drops-empty {
  padding: 16px 18px;
  margin: 0;
}

.lib-table--drops .lib-col-name a {
  font-weight: 650;
}

.lib-result-group {
  margin-bottom: 28px;
}

.lib-result-group__title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 1.05rem;
  color: #fff;
}

.lib-result-group__title span {
  color: var(--ml-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.lib-result-list {
  display: grid;
  gap: 8px;
}

.lib-result-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: var(--ml-panel);
  border: 1px solid var(--ml-border);
  border-radius: 8px;
  color: inherit;
}

.lib-result-item:hover {
  background: var(--ml-panel-inner);
  border-color: #555;
}

.lib-result-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  image-rendering: pixelated;
  background: rgba(0,0,0,0.25);
  border-radius: 6px;
}

.lib-result-type {
  color: var(--ml-accent);
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.lib-result-name {
  font-weight: 700;
  color: #fff;
}

.lib-result-meta {
  color: var(--ml-muted);
  font-size: 0.9rem;
}

.lib-empty {
  background: var(--ml-panel);
  border: 1px dashed var(--ml-border);
  border-radius: 8px;
  padding: 28px;
  color: var(--ml-muted);
}

.lib-empty pre {
  overflow: auto;
  background: rgba(0, 0, 0, 0.25);
  padding: 12px;
  border-radius: 6px;
  margin-top: 12px;
  color: #ccc;
}

.lib-pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
}

.lib-pagination a,
.lib-pagination span {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 4px;
  background: var(--ml-panel);
  border: 1px solid var(--ml-border);
  color: #ddd;
}

.lib-pagination a:hover {
  background: #333;
  color: #fff;
}

.lib-pagination .is-active {
  background: var(--ml-accent-dark);
  border-color: var(--ml-accent-dark);
  color: #fff;
  font-weight: 800;
}

.ml-footer {
  text-align: center;
  padding: 16px 20px 24px;
  color: var(--ml-muted);
  font-size: 0.88rem;
}

.ml-footer a {
  color: var(--ml-muted);
}

.ml-footer a:hover {
  color: var(--ml-accent);
}

.ml-footer-sep {
  margin: 0 8px;
  opacity: 0.5;
}

@media (max-width: 860px) {
  .ml-topbar {
    padding: 10px 14px;
  }

  .ml-top-search {
    width: 100%;
    flex: 1 1 100%;
    margin-left: 0;
  }

  .ml-nav {
    order: 3;
    width: 100%;
  }

  .ml-hero-visual .ml-hero-search {
    left: 9%;
    right: 9%;
    bottom: 6.5%;
    min-height: 34px;
  }

  .lib-result-item {
    grid-template-columns: 44px 1fr;
  }

  .lib-home-grid {
    grid-template-columns: 1fr 1fr;
  }

  .lib-home-hero h1 {
    font-size: 2.2rem;
  }
}

/* ── New library home ── */
.lib-home-hero {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--ml-border);
  margin-bottom: 22px;
  min-height: 280px;
  background: #1a1a1a;
}

.lib-home-hero__art {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(105deg, rgba(10, 12, 16, 0.88) 0%, rgba(10, 12, 16, 0.55) 55%, rgba(10, 12, 16, 0.75) 100%),
    url("/img/ms-field.png") center 40% / cover no-repeat;
  filter: saturate(0.95) brightness(0.9);
}

.lib-home-hero__inner {
  position: relative;
  z-index: 1;
  padding: 36px 28px 28px;
  max-width: 720px;
}

.lib-home-hero__kicker {
  margin: 0 0 8px;
  color: var(--ml-accent);
  font: 800 11px/1 var(--ml-font);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lib-home-hero h1 {
  margin: 0 0 8px;
  font-size: clamp(2.4rem, 5vw, 3.2rem);
  line-height: 1.05;
  color: #fff;
}

.lib-home-hero__sub {
  margin: 0 0 20px;
  color: #d0d0d0;
  font-size: 1.02rem;
  max-width: 520px;
}

.lib-home-search {
  position: relative;
  display: flex;
  align-items: stretch;
  max-width: 560px;
  margin-bottom: 14px;
}

.lib-home-search input,
.lib-inline-search input {
  flex: 1;
  min-width: 0;
  border: 1px solid #555;
  border-right: 0;
  border-radius: 10px 0 0 10px;
  background: rgba(255,255,255,0.96);
  color: #111;
  padding: 12px 14px;
  font: inherit;
}

.lib-home-search button,
.lib-inline-search button {
  border: 1px solid var(--ml-accent-dark);
  border-radius: 0 10px 10px 0;
  background: linear-gradient(180deg, #ffb347, #e86a20);
  color: #1a1a1a;
  padding: 12px 18px;
  font: 800 0.95rem var(--ml-font);
  cursor: pointer;
}

.lib-home-hero__stats {
  margin: 0;
  color: #bdbdbd;
  font-size: 0.88rem;
}

.lib-home-hero__stats strong {
  color: #fff;
}

.lib-home-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.lib-home-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px;
  background: var(--ml-panel);
  border: 1px solid var(--ml-border);
  border-radius: 12px;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}

.lib-home-card:hover {
  border-color: rgba(255, 179, 71, 0.55);
  background: var(--ml-panel-inner);
  transform: translateY(-2px);
  color: inherit;
}

.lib-home-card img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.lib-home-card strong {
  display: block;
  color: #fff;
  font-size: 1rem;
  margin-bottom: 2px;
}

.lib-home-card span {
  display: block;
  color: var(--ml-muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.lib-home-card em {
  display: block;
  margin-top: 6px;
  color: var(--ml-accent);
  font-style: normal;
  font-size: 0.78rem;
  font-weight: 700;
}

.lib-inline-search {
  position: relative;
  display: flex;
  align-items: stretch;
  min-width: min(100%, 420px);
}

.lib-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  max-height: 340px;
  overflow: auto;
  background: #222;
  border: 1px solid #444;
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
}

.lib-suggest a {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  color: #eee;
  border-bottom: 1px solid #333;
}

.lib-suggest a:last-child { border-bottom: none; }
.lib-suggest a:hover { background: #2e2e2e; color: #fff; }
.lib-suggest img {
  width: 28px; height: 28px;
  object-fit: contain;
  image-rendering: pixelated;
}
.lib-suggest strong { font-size: 0.92rem; }
.lib-suggest span { color: #999; font-size: 0.78rem; }

@media (max-width: 900px) {
  .lib-home-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .lib-home-grid { grid-template-columns: 1fr; }
}
