@layer reset, base, layout, components, motion, responsive;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scrollbar-gutter: stable; }
  body { min-height: 100svh; }
  img, svg { display: block; max-width: 100%; }
  button, input { font: inherit; color: inherit; }
  button { cursor: pointer; }
  a { color: inherit; }
  :target { scroll-margin-block: 82px; }
  [hidden] { display: none !important; }
}

@layer base {
  @font-face { font-family: "Lunar Sans"; src: url("/assets/fonts/space-grotesk-latin.woff2") format("woff2"); font-weight: 300 700; font-style: normal; font-display: swap; }
  :root {
    color-scheme: light dark;
    --bg: light-dark(#f6f9fc, #171a20);
    --surface: light-dark(#ffffff, #21252c);
    --soft: light-dark(#eaf3ff, #2a3443);
    --text: light-dark(#202936, #edf1f7);
    --muted: light-dark(#667386, #a3adbd);
    --faint: light-dark(#7b8796, #909cad);
    --line: light-dark(#e1e8f0, #353c47);
    --accent: light-dark(#2676db, #8abaff);
    --accent-hover: light-dark(#165fbd, #afd0ff);
    --on-accent: light-dark(#ffffff, #182233);
    --warning: light-dark(#a0671e, #ebbd7c);
    --warning-bg: light-dark(#fff7e9, #3a3023);
    --focus: light-dark(#2676db, #9cc8ff);
    --radius: 8px;
    --ease: cubic-bezier(.16, 1, .3, 1);
    --spring: linear(0, .26 8%, .66 18%, .95 30%, 1.025 43%, 1.006 64%, 1);
    --latin: "Lunar Sans", "Segoe UI", Arial, sans-serif;
    --body: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
    --gutter: 40px;
    accent-color: var(--accent);
    caret-color: var(--accent);
  }
  :root[data-theme="light"] { color-scheme: light; }
  :root[data-theme="dark"] { color-scheme: dark; }
  body { background: var(--bg); color: var(--text); font: 400 14px/1.65 var(--body); letter-spacing: 0; -webkit-font-smoothing: antialiased; }
  body:has(dialog[open]) { overflow: hidden; }
  ::selection { background: var(--accent); color: var(--on-accent); }
  :is(a, button, input, summary):focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
  :is(a, button) { -webkit-tap-highlight-color: transparent; }
  h1, h2, h3 { font-weight: 600; overflow-wrap: anywhere; }
  p { text-wrap: pretty; }
  .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
  .skip-link { position: fixed; z-index: 30; top: 10px; left: 10px; transform: translateY(-150%); padding: 10px 16px; border-radius: 6px; color: var(--on-accent); background: var(--accent); text-decoration: none; }
  .skip-link:focus { transform: translateY(0); }
  .icon { flex: none; width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .no-js :is(.loading-row, .market-toolbar, .filter-bar, #result-summary, .theme-button, .release-sync, .release-value, .release-date) { display: none !important; }
}

@layer layout {
  .header-inner, .hero-inner, .market-inner, .install-inner, .footer-inner { width: min(100% - var(--gutter) * 2, 1180px); margin-inline: auto; }
  .site-header { position: sticky; z-index: 10; top: 0; border-bottom: 1px solid var(--line); background: var(--surface); }
  .header-inner { min-height: 68px; display: flex; align-items: center; gap: 48px; }
  .header-actions { display: flex; gap: 4px; margin-left: auto; }
  .hero { background: var(--surface); border-bottom: 1px solid var(--line); }
  .hero-inner { display: flex; justify-content: space-between; gap: 40px; align-items: center; min-height: 190px; padding-block: 28px; }
  .product-heading { min-width: 0; }
  .release-band { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 5px 36px; min-width: 400px; }
  .release-content { min-width: 0; }
  .release-actions { display: grid; justify-items: center; grid-row: span 2; gap: 1px; }
  .release-sync { display: flex; align-items: center; gap: 6px; min-width: 0; }
  .market-section { padding-block: 30px 48px; }
  .market-intro, .market-heading { display: flex; align-items: center; }
  .market-intro { justify-content: space-between; gap: 20px; margin-bottom: 18px; }
  .market-heading { gap: 14px; min-width: 0; }
  .market-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
  .filter-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; }
  .module-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .install-section { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .install-inner { padding-block: 8px; }
  .site-footer { padding-block: 24px; color: var(--muted); }
  .footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 20px; font-size: 12px; }
}

@layer components {
  .brand { display: inline-flex; flex: none; gap: 10px; align-items: center; text-decoration: none; }
  .brand > span { font: 650 19px/1 var(--latin); white-space: nowrap; }
  .brand small { margin-left: 4px; font: 500 13px/1 var(--body); color: var(--muted); }
  .desktop-nav { display: flex; align-self: stretch; align-items: center; gap: 28px; }
  .desktop-nav a { display: grid; place-items: center; min-height: 44px; font-size: 13px; text-decoration: none; color: var(--muted); }
  .desktop-nav .nav-current { color: var(--accent); font-weight: 600; }
  .icon-button { flex: none; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--muted); transition: background-color 140ms, color 140ms, transform 160ms var(--spring); }
  .theme-sun, :root[data-theme="dark"] .theme-moon { display: none; }
  :root[data-theme="dark"] .theme-sun { display: block; }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .theme-moon { display: none; }
    :root:not([data-theme]) .theme-sun { display: block; }
  }
  #hero-title { font: 600 38px/1.2 var(--latin); }
  #hero-title > span { display: inline-block; margin-left: 10px; font: 500 23px/1.4 var(--body); color: var(--muted); vertical-align: baseline; }
  .hero-description { margin-top: 12px; color: var(--muted); font-size: 14px; }
  .release-value { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
  .release-value strong { font: 600 22px/1.3 var(--latin); overflow-wrap: anywhere; }
  #release-channel { color: var(--warning); font-size: 11px; white-space: nowrap; }
  .release-date { margin-top: 7px; color: var(--muted); font-size: 12px; }
  .source-state { min-width: 0; color: var(--muted); font-size: 11px; }
  .source-state::before { content: ""; display: inline-block; width: 5px; height: 5px; margin: 0 6px 2px 0; border-radius: 50%; background: var(--accent); }
  .source-state[data-state="offline"] { color: var(--warning); }
  .source-state[data-state="offline"]::before { background: var(--warning); }
  .refresh-button { margin-block: -8px; }
  .refresh-button .icon { width: 14px; height: 14px; }
  .refresh-button[disabled] { cursor: wait; opacity: .5; }
  .refresh-button[aria-busy="true"] .icon { animation: spin 900ms linear infinite; }
  .button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 46px; padding: 0 20px; border: 1px solid transparent; border-radius: var(--radius); font: 600 14px/1.3 var(--body); text-decoration: none; white-space: nowrap; transition: background-color 150ms, transform 160ms var(--spring); }
  .button-primary { background: var(--accent); color: var(--on-accent); }
  .button .icon { width: 18px; height: 18px; }
  .release-notes, .text-link { display: inline-flex; gap: 4px; min-height: 44px; align-items: center; color: var(--muted); font-size: 12px; text-decoration: none; }
  .release-notes .icon, .text-link .icon { width: 14px; height: 14px; }
  .market-heading h2 { font-size: 24px; line-height: 1.4; }
  #result-summary { color: var(--muted); font-size: 12px; }
  .source-tabs { --selected: 0; position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; width: 224px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: light-dark(#edf1f6, #292f39); }
  .source-tabs::before { content: ""; position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 12px) / 2); border-radius: 5px; background: var(--surface); box-shadow: 0 1px 3px #182b4612; transform: translateX(calc(var(--selected) * (100% + 4px))); transition: transform 360ms var(--spring); }
  .source-tab { position: relative; min-height: 44px; padding-inline: 14px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 13px; white-space: nowrap; }
  .source-tab[aria-pressed="true"] { color: var(--text); font-weight: 600; }
  .search-field { display: flex; align-items: center; gap: 9px; width: 300px; height: 46px; padding-inline: 14px; color: var(--faint); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
  .search-field .icon { width: 17px; height: 17px; }
  .search-field:focus-within { border-color: var(--accent); outline: 2px solid var(--focus); outline-offset: 2px; }
  .search-field input { min-width: 0; width: 100%; border: 0; outline: none; background: transparent; font-size: 13px; }
  .search-field input::placeholder { color: var(--faint); }
  .category-list { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
  .category-button { display: flex; align-items: center; justify-content: center; min-width: 58px; min-height: 44px; padding-inline: 13px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 13px; white-space: nowrap; }
  .category-button[aria-pressed="true"] { color: var(--accent); background: var(--soft); font-weight: 600; }
  .market-source { color: var(--faint); font-size: 11px; text-align: right; }
  .market-source[data-state="unavailable"], .market-source[data-state="offline"], .market-source[data-state="cached"] { color: var(--warning); }
  .module-item { display: flex; flex-direction: column; min-width: 0; min-height: 220px; padding: 22px 22px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
  .module-top { display: flex; align-items: center; gap: 12px; }
  .module-icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 8px; color: var(--accent); background: var(--soft); }
  .module-icon .icon { width: 21px; height: 21px; }
  [data-category="security"] .module-icon { color: light-dark(#a47124, #ecc68e); background: light-dark(#f9f0df, #3c3225); }
  [data-category="players"] .module-icon { color: light-dark(#9e6480, #e0acc7); background: light-dark(#f8eef3, #3d2c37); }
  [data-category="server"] .module-icon { color: light-dark(#5d7d76, #a4cdc4); background: light-dark(#ecf4f1, #2a3834); }
  .module-name { min-width: 0; }
  .module-name h3 { font-size: 17px; line-height: 1.45; }
  .module-category { display: block; margin-top: 1px; font-size: 11px; color: var(--faint); }
  .module-description { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 44px; margin-top: 15px; color: var(--muted); font-size: 13px; line-height: 1.7; }
  .module-requirement { min-height: 20px; margin-top: 5px; margin-bottom: 11px; font-size: 11px; color: var(--warning); overflow-wrap: anywhere; }
  .module-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: auto; border-top: 1px solid var(--line); }
  .module-detail-trigger, .module-download { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0; border: 0; border-radius: 4px; background: transparent; text-decoration: none; white-space: nowrap; }
  .module-detail-trigger { color: var(--muted); font-size: 12px; }
  .module-detail-trigger .icon { width: 15px; height: 15px; }
  .module-download { font-size: 13px; color: var(--accent); font-weight: 600; }
  .module-download .icon { width: 16px; height: 16px; }
  .loading-row { min-height: 220px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(100deg, var(--surface) 20%, var(--soft) 48%, var(--surface) 80%) 0 0 / 220% 100%; animation: loading 1600ms linear infinite; }
  .market-message { padding: 56px 24px; color: var(--muted); text-align: center; }
  .market-message > .icon { width: 30px; height: 30px; margin: 0 auto 16px; color: var(--faint); }
  .market-message strong { display: block; font-size: 18px; color: var(--text); }
  .market-message p { margin-top: 8px; font-size: 13px; }
  .market-message button, .market-message a { display: inline-flex; align-items: center; min-height: 44px; margin-top: 15px; padding-inline: 16px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--accent); font-size: 13px; text-decoration: none; }
  .install-guide summary { display: flex; align-items: center; gap: 10px; min-height: 60px; cursor: pointer; list-style: none; font-size: 13px; font-weight: 600; }
  .install-guide summary::-webkit-details-marker { display: none; }
  .install-guide summary > .icon:first-child { color: var(--muted); width: 18px; height: 18px; }
  .guide-chevron { margin-left: auto; color: var(--muted); transition: transform 230ms var(--spring); }
  .install-guide[open] .guide-chevron { transform: rotate(90deg); }
  .guide-content { padding-block: 10px 24px; }
  .install-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; padding: 0; list-style: none; }
  .install-steps li { display: flex; gap: 12px; align-items: baseline; }
  .step-number { font: 500 15px/1 var(--latin); color: var(--accent); }
  .install-steps h3 { font-size: 14px; }
  .install-steps p { margin-top: 8px; color: var(--muted); font-size: 12px; }
  .install-steps code { overflow-wrap: anywhere; font: 12px/1.6 Consolas, monospace; color: var(--text); }
  .guide-content > .text-link { margin-top: 12px; color: var(--accent); }
  .footer-inner nav { display: flex; gap: 24px; }
  .footer-inner a { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; }
  .module-dialog { width: min(560px, 100% - 40px); max-height: min(760px, 100svh - 48px); margin: auto; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); box-shadow: 0 24px 80px #0b17252b; }
  .module-dialog::backdrop { background: #131c2d70; }
  .dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
  .dialog-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
  .dialog-heading > div { min-width: 0; }
  .dialog-heading h2 { font-size: 19px; line-height: 1.4; }
  #dialog-subtitle { margin-top: 3px; color: var(--muted); font-size: 12px; }
  .dialog-body { padding: 24px; overflow-wrap: anywhere; }
  #dialog-description { color: var(--muted); font-size: 14px; }
  .dialog-requirements { margin-top: 18px; padding: 12px 14px; border-left: 2px solid var(--warning); background: var(--warning-bg); color: var(--warning); font-size: 12px; }
  .dialog-meta { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 14px; margin-top: 24px; font-size: 12px; }
  .dialog-meta dt { color: var(--muted); }
  .dialog-meta dd { min-width: 0; }
  .dialog-meta .hash-value { color: var(--muted); font: 11px/1.8 Consolas, monospace; }
  .dialog-meta a { color: var(--accent); text-underline-offset: 3px; }
  .dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 24px; border-top: 1px solid var(--line); background: var(--surface); }
  .dialog-origin { color: var(--muted); font-size: 11px; }
  .not-found { display: grid; place-items: center; padding: 24px; }
  .not-found main { max-width: 600px; width: 100%; }
  .not-found .section-index { margin-top: 30px; color: var(--accent); }
  .not-found h1 { margin-top: 14px; font-size: 42px; line-height: 1.3; }
  .not-found p:not(.section-index) { margin: 15px 0 30px; color: var(--muted); }
}

@layer motion {
  @media (hover: hover) and (pointer: fine) {
    .desktop-nav a:hover, .text-link:hover, .release-notes:hover, .footer-inner a:hover { color: var(--accent); }
    .icon-button:hover { background: var(--soft); color: var(--accent); }
    .button-primary:hover { background: var(--accent-hover); }
    .module-download:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 4px; }
    .module-detail-trigger:hover { color: var(--text); }
    .category-button:hover:not([aria-pressed="true"]) { background: var(--surface); color: var(--text); }
  }
  :is(.button, .icon-button, .module-download, .module-detail-trigger):active { transform: scale(.97); }
  .module-item { animation: module-enter 300ms var(--spring); }
  .module-dialog[open] { animation: dialog-enter 360ms var(--spring); }
  @keyframes module-enter { from { opacity: .75; transform: translateY(5px); } to { opacity: 1; transform: none; } }
  @keyframes dialog-enter { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
  @keyframes spin { to { transform: rotate(360deg); } }
  @keyframes loading { to { background-position: 220% 0; } }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition-duration: .01ms !important; }
  }
}

@layer responsive {
  @media (max-width: 1060px) {
    .header-inner { gap: 32px; }
    .module-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .release-band { min-width: 360px; column-gap: 24px; }
    #hero-title { font-size: 34px; }
    #hero-title > span { font-size: 20px; margin-left: 6px; }
  }
  @media (max-width: 760px) {
    :root { --gutter: 24px; }
    .header-inner { min-height: 62px; }
    .desktop-nav { display: none; }
    .hero-inner { display: block; padding-block: 24px 14px; }
    .hero-description { margin-top: 6px; }
    .release-band { min-width: 0; width: 100%; margin-top: 22px; gap: 0 18px; }
    .release-actions { gap: 0; }
    .release-value strong { font-size: 21px; }
    .release-sync { margin-top: 0; }
    .market-section { padding-top: 24px; }
    .market-intro { margin-bottom: 14px; }
    .market-heading h2 { font-size: 22px; }
    .market-toolbar { gap: 16px; }
    .source-tabs { width: 218px; flex: none; }
    .search-field { width: 100%; }
    .filter-bar { align-items: flex-start; flex-direction: column; gap: 0; min-height: 0; padding-block: 12px; }
    .market-source { text-align: left; padding: 4px 8px 0; }
    .install-steps { grid-template-columns: 1fr; gap: 24px; }
  }
  @media (max-width: 560px) {
    :root { --gutter: 20px; }
    .brand > span { font-size: 18px; }
    .brand small { font-size: 12px; }
    .brand img { width: 30px; height: 30px; }
    .hero-inner { padding-top: 22px; }
    #hero-title { font-size: 31px; }
    #hero-title > span { font-size: 19px; }
    .hero-description { font-size: 12px; }
    .release-band { margin-top: 20px; column-gap: 10px; }
    .release-value { gap: 3px 7px; }
    .release-value strong { font-size: 20px; }
    #release-channel { font-size: 10px; }
    .release-date { font-size: 11px; margin-top: 4px; }
    #core-download { min-height: 44px; padding-inline: 13px; font-size: 13px; gap: 6px; }
    .release-notes { font-size: 11px; }
    .source-state { font-size: 10px; }
    .market-section { padding-block: 20px 32px; }
    .market-heading { gap: 10px; }
    .market-heading h2 { font-size: 21px; }
    #result-summary { font-size: 11px; }
    .market-docs { display: none; }
    .market-toolbar { flex-wrap: wrap; gap: 10px; }
    .source-tabs { width: 100%; }
    .source-tab { min-height: 44px; }
    .search-field { height: 44px; }
    .filter-bar { padding-block: 10px 12px; }
    .category-list { justify-content: space-between; gap: 0; width: 100%; }
    .category-button { flex: 1; min-width: 0; min-height: 44px; padding-inline: 9px; font-size: 12px; }
    .market-source { display: none; }
    .market-source[data-state="unavailable"], .market-source[data-state="offline"], .market-source[data-state="cached"] { display: block; padding-top: 8px; font-size: 11px; }
    .module-list { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .module-item { min-height: 208px; padding: 18px 18px 6px; }
    .module-description { margin-top: 12px; }
    .module-requirement { margin-bottom: 8px; }
    .module-dialog { width: calc(100% - 32px); max-height: calc(100svh - 32px); }
    .dialog-header { padding: 16px 18px; }
    .dialog-body { padding: 20px 18px; }
    .dialog-footer { padding: 14px 18px; }
    .dialog-meta { grid-template-columns: 65px minmax(0, 1fr); gap: 12px; }
    .footer-inner { gap: 8px; flex-wrap: wrap; font-size: 11px; }
    .footer-inner nav { gap: 16px; }
  }
  @media (max-width: 350px) {
    :root { --gutter: 16px; }
    .brand { gap: 8px; }
    .brand > span { font-size: 16px; }
    .brand small { display: none; }
    #hero-title { font-size: 28px; }
    .release-value strong { font-size: 18px; }
    #release-channel { display: block; }
    .source-state { max-width: 130px; }
    .release-sync { gap: 0; }
  }
}

@media print {
  .site-header, .market-toolbar, .filter-bar, .module-actions, .release-sync { display: none !important; }
  body { background: white; color: black; }
  .module-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .module-item { break-inside: avoid; animation: none; }
}
