:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --border: #e3e6ea;
  --text: #16191d;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #e8efff;
  --warn-bg: #fff5e5;
  --warn-fg: #9a5b00;
  --danger-bg: #fdecec;
  --danger-fg: #b42318;
  --radius: 12px;
  --radius-sm: 7px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1e222a;
    --border: #2a2f39;
    --text: #e7e9ee;
    --muted: #9aa3b2;
    --accent: #5b8cff;
    --accent-soft: #1b2740;
    --warn-bg: #33260f;
    --warn-fg: #f0b95b;
    --danger-bg: #3a1a1a;
    --danger-fg: #f28b82;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", Roboto, sans-serif;
}

.wrap { width: min(1120px, 100% - 2.5rem); margin-inline: auto; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; margin: 0 0 .35rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
h3, h4, h5, h6 { margin: 1rem 0 .4rem; }

p { margin: 0 0 .6rem; }

code, .mono { font-family: var(--mono); font-size: .85em; }

.muted { color: var(--muted); }
.grow { flex: 1; }
.nowrap { white-space: nowrap; }
.num { text-align: right; }
.sep { color: var(--border); }

/* ---------------------------------------------------------------- top bar */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner { display: flex; align-items: center; gap: .75rem; height: 56px; }

.brand {
  display: inline-flex; align-items: center; gap: .5rem;
  color: var(--text); font-weight: 650; font-size: 1rem;
}
.brand:hover { text-decoration: none; }
.brand-mark { width: 20px; height: 20px; color: var(--accent); }

.brand-sub {
  color: var(--muted); font-size: .85rem;
  border-left: 1px solid var(--border); padding-left: .75rem;
}

.topnav { margin-left: auto; font-size: .875rem; display: flex; gap: 1rem; }

main { padding: 1.75rem 0 3rem; }

/* ------------------------------------------------------------------ footer */

.footer {
  border-top: 1px solid var(--border);
  padding: 1.1rem 0 2rem;
  color: var(--muted);
  font-size: .8rem;
}
.footer-inner { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* -------------------------------------------------------------------- grid */

.page-head { margin-bottom: 1.25rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1rem;
}

.card {
  display: flex; flex-direction: column; gap: .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  color: inherit;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.card:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgb(0 0 0 / .07);
}

.card-head { display: flex; gap: .85rem; align-items: flex-start; }
.card-title { min-width: 0; }
.card-title h2 { margin: 0 0 .2rem; }
.card-title p { margin: 0; font-size: .875rem; }

.card-foot { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.card-meta { font-size: .8rem; }

.clamp-2 {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

.version {
  font-family: var(--mono);
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: .1rem .5rem;
  font-size: .85rem;
}

/* ------------------------------------------------------------------- icons */

.icon {
  width: 40px; height: 40px; border-radius: 9px;
  object-fit: contain; flex: none;
  background: var(--surface-2);
}
.icon-lg { width: 60px; height: 60px; border-radius: 13px; }
.icon-fallback {
  display: grid; place-items: center;
  font-weight: 600; font-size: 1.1rem; color: var(--accent);
  background: var(--accent-soft);
}

/* ------------------------------------------------------------------ chips */

.chip {
  display: inline-flex; align-items: center; gap: .25rem;
  font-family: var(--mono); font-size: .8rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: .15rem .6rem;
  color: var(--muted);
}
.chip:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.chip-sm { font-size: .75rem; padding: .05rem .45rem; }
.chip-active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.chip-active:hover { color: #fff; }
.pre {
  font-size: .62rem; text-transform: uppercase; letter-spacing: .04em;
  opacity: .75;
}

/* --------------------------------------------------------------- app page */

.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 1rem; }
.crumbs .sep { margin: 0 .4rem; }

.app-head { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1.25rem; }
.app-head-main { min-width: 0; }
.app-meta {
  display: flex; flex-wrap: wrap; gap: .45rem; align-items: center;
  font-size: .85rem; color: var(--muted);
}

.versions {
  display: flex; flex-wrap: wrap; gap: .4rem;
  margin-bottom: 1.25rem;
}

/* ----------------------------------------------------------------- panels */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
}

.panel-head {
  display: flex; flex-wrap: wrap; gap: .5rem 1rem;
  align-items: center; justify-content: space-between;
  margin-bottom: .85rem;
}
.panel-head h2 { margin: 0; }
.panel-sub { color: var(--muted); font-weight: 400; }

.badges { display: flex; flex-wrap: wrap; gap: .35rem; }
.badge {
  font-size: .72rem; border-radius: 999px; padding: .1rem .5rem;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border);
}
.badge-warn { background: var(--warn-bg); color: var(--warn-fg); border-color: transparent; }
.badge-danger { background: var(--danger-bg); color: var(--danger-fg); border-color: transparent; }

/* ------------------------------------------------------------------ table */

.table-scroll { overflow-x: auto; margin: 0 -.35rem; }

table.files { width: 100%; border-collapse: collapse; font-size: .875rem; }

table.files th {
  text-align: left; font-weight: 600; font-size: .75rem;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted);
  padding: .35rem .6rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.files td {
  padding: .6rem; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.files tr:last-child td { border-bottom: 0; }
table.files tr:hover td { background: var(--surface-2); }

.os { font-weight: 600; }
.file a { word-break: break-all; }

.sha code {
  cursor: pointer; background: var(--surface-2); border-radius: var(--radius-sm);
  padding: .1rem .35rem; border: 1px solid var(--border);
  white-space: nowrap;
}
.sha code:hover { border-color: var(--accent); color: var(--accent); }

.tag {
  font-size: .68rem; color: var(--muted);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 0 .3rem; margin-left: .3rem;
}

.actions { text-align: right; }

/* ------------------------------------------------------------------ button */

.btn {
  display: inline-block;
  background: var(--accent); color: #fff;
  border-radius: var(--radius-sm);
  padding: .3rem .8rem; font-size: .85rem;
  border: 0; cursor: pointer;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn-sm { padding: .2rem .65rem; font-size: .8rem; }

/* ------------------------------------------------------------------- lists */

.api-list { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.api-list li {
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: center;
  padding: .35rem 0; border-bottom: 1px dashed var(--border);
}
.api-list li:last-child { border-bottom: 0; }
.api-list code {
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: .15rem .45rem; border: 1px solid var(--border);
  word-break: break-all;
}

/* ---------------------------------------------------------------- markdown */

.markdown { font-size: .9rem; overflow-wrap: anywhere; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown h1 { font-size: 1.2rem; }
.markdown h2 { font-size: 1.05rem; }
.markdown h3 { font-size: .95rem; }
.markdown ul, .markdown ol { margin: 0 0 .7rem; padding-left: 1.4rem; }
.markdown li { margin: .15rem 0; }
.markdown code {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 4px; padding: .05rem .3rem;
}
.markdown pre {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .75rem;
  overflow-x: auto;
}
.markdown pre code { background: none; border: 0; padding: 0; }
.markdown blockquote {
  margin: .6rem 0; padding: .1rem .9rem;
  border-left: 3px solid var(--border); color: var(--muted);
}
.markdown hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.markdown h2 {
  margin-top: 1.9rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.markdown h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

/* Tables survive narrow screens by scrolling sideways. */
.markdown .table-wrap { overflow-x: auto; margin: 0 0 .9rem; }
.markdown table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.markdown th,
.markdown td {
  border: 1px solid var(--border);
  padding: .45rem .65rem;
  vertical-align: top;
}
.markdown th {
  background: var(--surface-2);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

/* -------------------------------------------------------------------- docs */

.docs {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.docs-nav {
  position: sticky;
  top: 72px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
}
.docs-nav-title {
  margin: 0 0 .5rem;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
.docs-nav ul { list-style: none; margin: 0; padding: 0; }
.docs-nav li { margin: .1rem 0; }
.docs-nav a {
  display: block;
  padding: .3rem .55rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--text);
}
.docs-nav a:hover { background: var(--surface-2); text-decoration: none; }
.docs-nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.docs-body { padding: 1.5rem 1.75rem; }

@media (max-width: 760px) {
  .docs { grid-template-columns: 1fr; }
  .docs-nav { position: static; }
}

/* ------------------------------------------------------------------- empty */

.empty {
  background: var(--surface); border: 1px dashed var(--border);
  border-radius: var(--radius); padding: 3rem 1.5rem; text-align: center;
}
.empty code {
  background: var(--surface-2); border-radius: 4px; padding: .1rem .3rem;
}

/* ------------------------------------------------------------------ upload */

.upload-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .9rem 1rem;
  margin: 1.1rem 0 .5rem;
}
.field { display: flex; flex-direction: column; gap: .3rem; }
.field-wide { grid-column: 1 / -1; }
.field > span { font-size: .8rem; color: var(--muted); }
.field input {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .42rem .6rem;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.field .btn { align-self: start; margin-top: auto; }

/* Drop zone: the real file input is hidden inside the label so the whole area
   is clickable, while drag and drop still works. */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  padding: 1.4rem 1rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s, color .15s;
}
.dropzone:hover,
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--accent); }
.dropzone input[type=file] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
  opacity: 0;
}
.dropzone-arrow { font-size: 1.3rem; line-height: 1; color: var(--accent); }
.dropzone-main { font-size: .9rem; }
.dropzone-file { font-family: var(--mono); font-size: .78rem; color: var(--muted); }
.dropzone.has-file .dropzone-file { color: var(--accent); }

/* Upload progress. */
.progress-wrap { width: 100%; margin-top: .9rem; }
.progress {
  height: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}
.progress-bar {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width .15s linear;
}
.progress-text {
  margin: .35rem 0 0;
  font-family: var(--mono);
  font-size: .78rem;
}

/* Metadata form. */
.field textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .42rem .6rem;
  resize: vertical;
  min-height: 4rem;
}
.field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

.check { display: flex; align-items: center; gap: .45rem; font-size: .85rem; cursor: pointer; }
.check input { width: auto; }

.meta-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.dropzone-sm {
  flex: 1;
  min-width: 200px;
  padding: .7rem 1rem;
  align-items: flex-start;
  text-align: left;
}
.meta-actions { flex-direction: row; gap: .6rem; }

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--accent); background: var(--accent-soft); }

.details { margin-top: 1rem; font-size: .85rem; }
.details summary { cursor: pointer; color: var(--muted); }
.details summary:hover { color: var(--accent); }
.details[open] summary { margin-bottom: .5rem; }

.upload-result {
  margin: 1rem 0 0;
  padding: .9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: .8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 22rem;
  overflow: auto;
}
.upload-result.ok { border-color: #1a7f37; }
.upload-result.fail { border-color: #b42318; }

.numbered { margin: 0 0 .7rem; padding-left: 1.4rem; font-size: .9rem; }
.numbered li { margin: .2rem 0; }

.code-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .8rem 1rem;
  overflow-x: auto;
  font-size: .8rem;
  margin: 0 0 .7rem;
}
.code-block code { background: none; border: 0; padding: 0; }

/* ------------------------------------------------------------------- error */

.error-page { text-align: center; padding: 4rem 1rem; }
.error-code { font-size: 3rem; font-weight: 700; margin: 0; color: var(--muted); }
.error-text { font-size: 1rem; margin: .5rem 0 1.5rem; }

/* ------------------------------------------------------------------- misc */

.muted.ext { margin-left: .35rem; }

@media (max-width: 560px) {
  .wrap { width: calc(100% - 1.5rem); }
  .app-head { flex-direction: column; }
  .brand-sub { display: none; }
}
