/* ============================================================
   MyLoon Box
   Mode: Operate. Task-first surface, so density and predictability
   win over expression; brand lives in the details.

   Tokens are the single source of truth. Two themes follow the OS,
   not a toggle: this page is opened outdoors to install a plugin.

   Shape scale (documented, applied everywhere):
     chips    -> pill (999px)      small metadata, version, category
     controls -> 12px              buttons, inputs
     surfaces -> 16px              rows, notices, brand mark
   ============================================================ */

:root {
  color-scheme: light dark;

  --bg: #fbfbfa;
  --surface: #ffffff;
  --surface-hover: #f5f5f4;
  --surface-sunken: #f1f1f0;

  --line: rgba(15, 16, 20, 0.11);
  --line-strong: rgba(15, 16, 20, 0.18);

  --text: #15161a;
  --text-2: #494a52;
  --text-3: #6a6b74;

  --accent: #0a6a5f;
  --accent-ink: #ffffff;
  --accent-soft: rgba(10, 106, 95, 0.09);

  --shadow-row: 0 1px 2px rgba(15, 16, 20, 0.04);
  --shadow-pop: 0 12px 32px -12px rgba(15, 16, 20, 0.28);

  --r-chip: 999px;
  --r-control: 12px;
  --r-surface: 16px;

  --ease: cubic-bezier(0.22, 0.78, 0.24, 1);
  --dur: 180ms;

  --measure: 68ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0d;
    --surface: #141417;
    --surface-hover: #1b1b1f;
    --surface-sunken: #101013;

    --line: rgba(255, 255, 255, 0.12);
    --line-strong: rgba(255, 255, 255, 0.2);

    --text: #f4f4f5;
    --text-2: #a9a9b2;
    --text-3: #8b8b95;

    --accent: #3ddbb0;
    --accent-ink: #04201a;
    --accent-soft: rgba(61, 219, 176, 0.12);

    --shadow-row: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-pop: 0 16px 40px -16px rgba(0, 0, 0, 0.7);
  }
}

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

/* ---------- Browser surfaces ---------- */
::selection {
  background: var(--accent-soft);
  color: var(--text);
}
:root { scrollbar-color: var(--line-strong) transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 3px solid transparent;
  border-radius: var(--r-chip);
  background-clip: content-box;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
input:focus-visible { outline-offset: 0; border-radius: var(--r-control); }

html { background: var(--bg); overflow-x: hidden; }
@supports (overflow-x: clip) {
  html, body { overflow-x: clip; }
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
a { color: var(--text); text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }
button, input { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.skip-link {
  position: absolute; left: 12px; top: -64px;
  padding: 10px 14px; background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--r-control);
  text-decoration: none; z-index: 20;
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: 12px; box-shadow: var(--shadow-pop); }

.shell {
  flex: 1;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 40px 20px 24px;
}

/* ---------- Masthead ---------- */
.masthead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark {
  flex: none;
  width: 46px; height: 46px;
  padding: 5px;
  object-fit: contain;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-surface);
  background: var(--surface);
  box-shadow: var(--shadow-row);
}
.brand-copy { min-width: 0; }
h1 {
  margin: 0 0 4px;
  font-size: 1.7rem;
  line-height: 1.15;
  letter-spacing: -0.03em;
  font-weight: 640;
}
.brand-copy p {
  margin: 0;
  max-width: 52ch;
  color: var(--text-2);
  font-size: 0.875rem;
}
.masthead-actions { display: flex; gap: 8px; flex: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 38px; padding: 0 13px;
  border-radius: var(--r-control);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem; font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
    transform var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-hover); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: default; transform: none; }
.btn-icon { padding: 0; width: 38px; justify-content: center; }

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }

.link-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 0; border: 0; background: none;
  color: var(--accent);
  font-size: 0.8125rem; font-weight: 500;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

.ico { flex: none; width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.6; fill: none;
  stroke-linecap: round; stroke-linejoin: round; }
.ico-sm { width: 15px; height: 15px; transition: transform var(--dur) var(--ease); }
.plugin-toggle[aria-expanded="true"] .ico-sm { transform: rotate(180deg); }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  margin-bottom: 14px;
}
.search {
  display: flex; align-items: center; gap: 9px;
  flex: 1 1 280px; min-width: 0;
  height: 44px; padding: 0 13px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  box-shadow: var(--shadow-row);
  transition: border-color var(--dur) var(--ease);
}
.search:focus-within { border-color: var(--accent); }
.search-ico { color: var(--text-3); }
.search input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: none;
  font-size: 1rem;
}
.search input::placeholder { color: var(--text-3); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
kbd {
  flex: none;
  font-family: inherit; font-size: 0.6875rem; font-weight: 500;
  color: var(--text-3);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 2px 6px;
  white-space: nowrap;
}
.filters {
  display: flex; gap: 7px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding: 2px;
}
.filters::-webkit-scrollbar { display: none; }
.chip-filter {
  flex: none;
  min-height: 34px; padding: 0 13px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-2);
  border-radius: var(--r-chip);
  font-size: 0.8125rem; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}
.chip-filter:hover { background: var(--surface-hover); color: var(--text); }
.chip-filter[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Cloudflare Turnstile Wrapper ---------- */
.turnstile-wrapper {
  display: flex;
  justify-content: center;
  margin: 12px 0 16px;
  min-height: 65px;
}

/* ---------- Meta row ---------- */
.meta {
  display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap;
  margin: 0 2px 8px;
  color: var(--text-3);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.meta > span { min-width: 0; overflow-wrap: anywhere; }

/* ---------- Results ---------- */
.results { border-top: 1px solid var(--line); }
.plugin {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  padding: 18px 12px;
  border-bottom: 1px solid var(--line);
  transition: background var(--dur) var(--ease);
}
.plugin:hover { background: var(--surface-hover); }
.plugin-icon {
  width: 44px; height: 44px;
  border-radius: var(--r-surface);
  border: 1px solid var(--line);
  background: var(--surface-sunken);
  object-fit: cover;
}
.plugin-body { min-width: 0; }
.plugin-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.plugin-name {
  margin: 0;
  min-width: 0;
  font-size: 1.0625rem;
  line-height: 1.3;
  letter-spacing: -0.015em;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.chip {
  display: inline-flex; align-items: center;
  border-radius: var(--r-chip);
  font-size: 0.6875rem;
  font-weight: 550;
  padding: 1px 8px;
  font-variant-numeric: tabular-nums;
}
.chip-version { border: 1px solid var(--line-strong); color: var(--text-2); }
.chip-cat { background: var(--accent-soft); color: var(--accent); max-width: 100%; overflow-wrap: anywhere; }
.plugin-name + .chip-version:empty,
.chip-version:empty,
.chip-cat:empty { display: none; }
.plugin-desc {
  margin: 5px 0 0;
  max-width: var(--measure);
  color: var(--text-2);
  font-size: 0.875rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.plugin-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 9px;
  min-width: 0;
}
.plugin-foot > * { min-width: 0; }
.plugin-author {
  color: var(--text-3);
  font-size: 0.75rem;
  min-width: 0;
  overflow-wrap: anywhere;
}
.plugin-install { align-self: center; }

.plugin-desc[data-clamped="true"] {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.plugin-toggle[hidden] { display: none; }

/* ---------- Notices, empty, skeleton ---------- */
.notice {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 16px;
  margin: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-surface);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.875rem;
}
.notice > div { min-width: 0; }
.notice h2 {
  margin: 0 0 3px;
  font-size: 0.9375rem;
  color: var(--text);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.notice p { margin: 0 0 10px; max-width: 52ch; overflow-wrap: anywhere; }
.notice-empty { justify-content: center; text-align: center; padding: 44px 20px; }
.notice-empty div { max-width: 40ch; }
.notice-alert { border-color: var(--line-strong); }
.notice-alert .ico { color: var(--text); margin-top: 2px; }
.results > .notice { border-inline: 0; border-radius: 0; border-top: 0; }
.results > .notice-empty { border-bottom: 1px solid var(--line); }

.sk {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 16px;
  padding: 18px 12px;
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.sk-box { background: var(--surface-sunken); border-radius: var(--r-surface); animation: sk-pulse 1.4s var(--ease) infinite; }
.sk-icon { width: 44px; height: 44px; }
.sk-line { height: 12px; border-radius: var(--r-chip); }
.sk-lines > .sk-box + .sk-box { margin-top: 9px; }
.sk-w-40 { width: 40%; }
.sk-w-70 { width: 70%; }
.sk-w-90 { width: 90%; }
.sk-btn { width: 88px; height: 38px; }
@keyframes sk-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ---------- Footer & toast ---------- */
.site-footer {
  display: flex; align-items: center; gap: 9px; justify-content: center;
  padding: 28px 0 4px;
  color: var(--text-3);
  font-size: 0.75rem;
}
.sep { color: var(--line-strong); }
.toast {
  position: fixed; left: 50%; bottom: 20px;
  transform: translate(-50%, 16px);
  max-width: min(90vw, 380px);
  padding: 10px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-pop);
  font-size: 0.8125rem;
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .masthead { margin-bottom: 22px; }
}
@media (max-width: 640px) {
  .shell { padding: 24px 16px 16px; }
  h1 { font-size: 1.45rem; }
  .brand-mark { width: 40px; height: 40px; padding: 4px; }
  .search { flex-basis: 100%; }
  kbd { display: none; }
  .plugin {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 12px;
  }
  .plugin-icon { width: 40px; height: 40px; }
  .plugin-install { grid-column: 1 / -1; justify-content: center; width: 100%; }
  .notice-empty { padding: 36px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
  .sk-box { animation: none; opacity: 0.7; }
}
