:root {
  color-scheme: dark;
  --bg: #101114;
  --surface: #17191e;
  --surface-strong: #20232a;
  --border: #30343d;
  --text: #f5f6f8;
  --muted: #aeb4c0;
  --violet: #a78bfa;
  --mint: #58d6a9;
  --coral: #ff806a;
  --gold: #e8bd61;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}
button, input, select { font: inherit; }
a { color: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 68px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 10px clamp(16px, 4vw, 52px);
  border-bottom: 1px solid var(--border);
  background: rgba(16, 17, 20, 0.96);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
}
.brand span { display: grid; }
.brand strong { font-size: 16px; }
.brand small { color: var(--muted); margin-top: 2px; }
.server-name { color: var(--muted); text-align: center; font-weight: 650; }
.editor-link {
  justify-self: end;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}
.editor-link:hover { border-color: var(--violet); background: var(--surface-strong); }

.library-shell {
  width: min(1500px, 100%);
  min-height: calc(100vh - 68px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}
.filters {
  padding: 26px 20px;
  border-right: 1px solid var(--border);
}
.filter-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-weight: 800; }
.filter-heading button { border: 0; background: transparent; color: var(--violet); cursor: pointer; }
.category-list { display: grid; gap: 4px; }
.category-list button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}
.category-list button:hover { background: var(--surface); color: var(--text); }
.category-list button.active { background: var(--surface-strong); color: var(--text); box-shadow: inset 3px 0 var(--violet); }
.category-list em { color: var(--muted); font-style: normal; }
.library-note { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border); }
.library-note strong { color: var(--mint); }
.library-note p { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.library-content { min-width: 0; padding: 26px clamp(18px, 4vw, 54px) 60px; }
.library-toolbar { display: grid; grid-template-columns: 1fr 190px; gap: 12px; }
.search-box input, .library-toolbar select {
  width: 100%;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.search-box input:focus, .library-toolbar select:focus { border-color: var(--violet); box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.18); }
.library-status { min-height: 44px; display: flex; align-items: center; color: var(--muted); font-size: 14px; }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 310px), 1fr)); gap: 14px; }
.guide-card {
  min-width: 0;
  display: grid;
  grid-template-rows: 160px auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 140ms ease, transform 140ms ease;
}
.guide-card:hover { border-color: var(--violet); transform: translateY(-2px); }
.guide-card:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
.guide-card-media { width: 100%; height: 160px; object-fit: cover; background: var(--surface-strong); }
.guide-card-placeholder {
  display: grid;
  place-items: center;
  padding: 14px;
  background: repeating-linear-gradient(135deg, #171d26, #171d26 14px, #1d2530 14px, #1d2530 28px);
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-align: center;
}
.guide-card-content { padding: 15px; }
.guide-card-category { margin: 0 0 7px; color: var(--mint); font-size: 12px; font-weight: 850; text-transform: uppercase; }
.guide-card h2 { margin: 0; font-size: 18px; line-height: 1.3; overflow-wrap: anywhere; }
.guide-card-summary { min-height: 42px; margin: 9px 0; color: var(--muted); line-height: 1.45; font-size: 14px; }
.guide-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.guide-tags span { padding: 4px 7px; border: 1px solid var(--border); border-radius: 4px; color: var(--gold); font-size: 12px; }
.guide-card-updated, .updated { margin: 11px 0 0; color: var(--muted); font-size: 12px; }
.guide-card-credit { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--muted); }
.guide-card-credit .contributor-avatar { width: 26px; height: 26px; font-size: 9px; }
.guide-card-credit .contributor-copy { min-width: 0; }
.guide-card-credit .contributor-copy > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 750; }
.guide-card-credit .contributor-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }

.empty-state { min-height: 330px; display: flex; align-items: center; justify-content: center; gap: 22px; border-top: 1px solid var(--border); }
.empty-mark { width: 72px; height: 72px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--gold); font-weight: 900; }
.empty-state h1 { margin: 0; font-size: 24px; }
.empty-state p { max-width: 520px; margin: 8px 0 0; color: var(--muted); line-height: 1.55; }

.guide-dialog { width: min(900px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); opacity: 1; transform: translateY(0) scale(1); transition: opacity 200ms ease, transform 220ms cubic-bezier(.2, .8, .2, 1), overlay 220ms allow-discrete, display 220ms allow-discrete; }
.guide-dialog::backdrop { background: rgba(0, 0, 0, 0.76); opacity: 1; transition: opacity 200ms ease, overlay 220ms allow-discrete, display 220ms allow-discrete; }
.guide-dialog.is-opening,
.guide-dialog.is-closing { opacity: 0; transform: translateY(14px) scale(.975); }
.guide-dialog.is-opening::backdrop,
.guide-dialog.is-closing::backdrop { opacity: 0; }
.guide-dialog article { position: relative; }
.close-button { position: sticky; top: 12px; float: right; margin: 12px; z-index: 2; width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); cursor: pointer; }
.guide-cover { width: 100%; max-height: 380px; object-fit: cover; }
.guide-cover-placeholder {
  min-height: 280px;
  display: grid;
  place-items: center;
  background: repeating-linear-gradient(135deg, #171d26, #171d26 16px, #1d2530 16px, #1d2530 32px);
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
}
.guide-detail-header, .guide-body { padding: 24px clamp(20px, 5vw, 52px); }
.guide-detail-header { border-bottom: 1px solid var(--border); }
.guide-detail-header > p:first-child { margin: 0 0 8px; color: var(--mint); font-weight: 850; text-transform: uppercase; font-size: 12px; }
.guide-detail-header h1 { margin: 0 0 14px; font-size: clamp(26px, 5vw, 42px); letter-spacing: 0; overflow-wrap: anywhere; }
.guide-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.guide-title-row h1 { min-width: 0; flex: 1; }
.guide-title-row .editor-link { flex: 0 0 auto; margin-top: 2px; }
.guide-credit { margin-top: 16px; }
.guide-credit-card { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.contributor-avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; }
.contributor-avatar-fallback { display: grid; place-items: center; background: var(--surface-strong); color: var(--gold); font-weight: 900; }
.contributor-copy { display: grid; gap: 2px; }
.contributor-copy strong { font-size: 14px; }
.contributor-copy small { color: var(--muted); font-size: 12px; }
.contributor-copy p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.guide-credit-card a { color: var(--mint); font-size: 13px; font-weight: 750; text-decoration: none; }
.guide-credit-card a:hover { text-decoration: underline; }
.guide-body { line-height: 1.7; overflow-wrap: anywhere; }
.guide-body h1, .guide-body h2, .guide-body h3, .guide-body h4, .guide-body h5, .guide-body h6 { margin: 22px 0 8px; letter-spacing: 0; line-height: 1.3; }
.guide-body h1 { font-size: 28px; }
.guide-body h2 { font-size: 24px; }
.guide-body h3 { font-size: 20px; }
.guide-body h4, .guide-body h5, .guide-body h6 { font-size: 17px; }
.guide-markdown-line { min-height: 1.45em; }
.guide-list-item { padding-left: calc(var(--guide-indent, 0) * 18px); }
.guide-body blockquote { margin: 4px 0; padding: 3px 12px; border-left: 3px solid var(--violet); color: var(--muted); }
.guide-body pre { overflow-x: auto; margin: 12px 0; padding: 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); white-space: pre; }
.guide-body code { padding: 2px 5px; border-radius: 4px; background: var(--bg); color: var(--gold); font-family: Consolas, monospace; }
.guide-body pre code { padding: 0; background: transparent; color: var(--text); }
.guide-body a { color: var(--mint); }
.guide-body hr { margin: 20px 0; border: 0; border-top: 1px solid var(--border); }
.guide-spoiler { padding: 0 3px; border-radius: 3px; background: #05070a; color: transparent; }
.guide-spoiler:hover, .guide-spoiler:focus { color: var(--text); }
.guide-markdown-image { display: block; width: 100%; height: auto; margin: 16px 0; border-radius: 6px; }
.guide-inline-image-placeholder { min-height: 160px; display: grid; place-items: center; margin: 16px 0; border: 1px solid var(--border); border-radius: 6px; background: repeating-linear-gradient(135deg, #171d26, #171d26 12px, #1d2530 12px, #1d2530 24px); color: var(--muted); font-size: 13px; font-weight: 850; }

@media (max-width: 760px) {
  .site-header { grid-template-columns: 1fr auto; gap: 10px; }
  .server-name { grid-column: 1 / -1; grid-row: 2; text-align: left; font-size: 13px; }
  .library-shell { display: block; }
  .filters { padding: 12px 14px; border-right: 0; border-bottom: 1px solid var(--border); }
  .filter-heading, .library-note { display: none; }
  .category-list { display: flex; overflow-x: auto; gap: 6px; padding-bottom: 2px; }
  .category-list button { width: auto; white-space: nowrap; border: 1px solid var(--border); }
  .category-list button.active { box-shadow: none; border-color: var(--violet); }
  .category-list em { margin-left: 8px; }
  .library-content { padding: 16px 14px 44px; }
  .library-toolbar { grid-template-columns: 1fr; }
  .guide-grid { grid-template-columns: 1fr; }
  .guide-card { grid-template-columns: 108px minmax(0, 1fr); grid-template-rows: auto; }
  .guide-card-media { width: 108px; height: 100%; min-height: 150px; }
  .guide-card-placeholder { font-size: 26px; }
  .guide-card h2 { font-size: 16px; }
  .guide-card-summary { min-height: 0; }
  .empty-state { align-items: flex-start; padding-top: 42px; }
  .empty-mark { width: 58px; height: 58px; }
  .empty-state h1 { font-size: 20px; }
  .guide-credit-card { grid-template-columns: 38px minmax(0, 1fr); }
  .guide-credit-card .contributor-avatar { width: 38px; height: 38px; }
  .guide-credit-card a { grid-column: 2; }
  .guide-title-row { display: block; }
  .guide-title-row .editor-link { margin: 0 0 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .guide-dialog,
  .guide-dialog::backdrop { transition-duration: 0s !important; }
}

@media (max-width: 390px) {
  .brand small { display: none; }
  .guide-card { grid-template-columns: 88px minmax(0, 1fr); }
  .guide-card-media { width: 88px; }
  .guide-card-content { padding: 12px; }
  .guide-card-summary { display: none; }
  .empty-state { display: grid; text-align: center; justify-items: center; }
}
