:root {
  --surface: rgba(255, 255, 255, .65);
  --surface-border: rgba(255, 255, 255, .7);
  --surface-solid: rgba(255, 255, 255, .94);
  --blur: 12px;
  --text: #1f2328;
  --muted: #59636e;
  --accent: #6366f1;
  --accent-fg: #ffffff;
  --row-hover: rgba(99, 102, 241, .08);
  --shadow: 0 8px 32px rgba(31, 35, 40, .12);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --capsule-border: #dfe1e5;
  --capsule-bg: #ffffff;
  --btn-border: #d0d5dd;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface: rgba(30, 33, 42, .55);
    --surface-border: rgba(255, 255, 255, .12);
    --surface-solid: rgba(17, 19, 26, .96);
    --blur: 16px;
    --text: #e6edf3;
    --muted: #a1a7b3;
    --accent: #818cf8;
    --accent-fg: #0b0e14;
    --row-hover: rgba(129, 140, 248, .12);
    --shadow: 0 8px 32px rgba(0, 0, 0, .45);
    --capsule-border: rgba(255, 255, 255, .14);
    --capsule-bg: #1e212a;
    --btn-border: rgba(255, 255, 255, .2);
  }
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(600px 400px at 12% 8%, rgba(124, 58, 237, .30), transparent 65%),
    radial-gradient(700px 450px at 88% 12%, rgba(8, 145, 178, .28), transparent 65%),
    radial-gradient(800px 500px at 50% 100%, rgba(236, 72, 153, .18), transparent 65%),
    #eef1f8;
  background-attachment: fixed;
}
@media (prefers-color-scheme: dark) {
  body {
    background:
      radial-gradient(600px 400px at 12% 8%, rgba(124, 58, 237, .45), transparent 65%),
      radial-gradient(700px 450px at 88% 12%, rgba(8, 145, 178, .42), transparent 65%),
      radial-gradient(800px 500px at 50% 100%, rgba(236, 72, 153, .30), transparent 65%),
      #0b0e14;
  }
}

.container { width: 100%; max-width: 1400px; margin: 0 auto; padding: 32px 16px 48px; flex: 1; }
#app { display: grid; gap: 18px; align-content: flex-start; }
#release-info { display: grid; gap: 18px; }

.glass {
  background: var(--surface);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: var(--surface-solid); }
}

/* ===== github corners（tholman 官方样式，纯装饰置顶）===== */
.github-corner { position: fixed; top: 0; right: 0; z-index: 30; line-height: 0; pointer-events: none; }
.github-corner .octo-body, .github-corner .octo-arm { pointer-events: auto; }
.github-corner svg { fill: #151513; color: #fff; }
@media (prefers-color-scheme: dark) {
  .github-corner svg { fill: #f0f6fc; color: #0b0e14; }
}
.github-corner:hover .octo-arm { animation: octocat-wave 560ms ease-in-out; }
@keyframes octocat-wave {
  0%, 100% { transform: rotate(0); }
  20%, 60% { transform: rotate(-25deg); }
  40%, 80% { transform: rotate(10deg); }
}
@media (max-width: 500px) {
  .github-corner:hover .octo-arm { animation: none; }
  .github-corner .octo-arm { animation: octocat-wave 560ms ease-in-out; }
}

/* ===== 首页态 / 结果态 ===== */
body.mode-home #hero-card {
  border: none; background: transparent; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none;
  padding: 0; text-align: center;
  min-height: calc(100vh - 220px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
body.mode-home .hero-title { font-size: 34px; font-weight: 800; letter-spacing: -.5px; margin: 0; }

body.mode-results #hero-card {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0 14px;
  width: 100%;
  padding: 14px 0 4px;
  background: transparent; border: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none;
}
body.mode-results .hero-title { font-size: 16px; font-weight: 700; white-space: nowrap; margin: 0; flex: none; }
body.mode-results #repo-form { flex: 1; min-width: 0; margin: 0; max-width: none; }
body.mode-results .search-shell { max-width: none; }
body.mode-results #status { flex-basis: 100%; text-align: left; margin: 6px 0 0; padding: 0; }

/* ===== 搜索胶囊 ===== */
#repo-form { display: flex; justify-content: center; margin-top: 0; width: 100%; max-width: 584px; }
.search-shell {
  position: relative;
  width: 100%; max-width: 584px;
  background: var(--capsule-bg);
  border: 1px solid var(--capsule-border);
  border-radius: 24px;
  box-shadow: 0 1px 6px rgba(32, 33, 36, .10);
  transition: box-shadow .15s ease;
}
.search-shell:focus-within { box-shadow: 0 1px 10px rgba(32, 33, 36, .22); border-color: var(--accent); }
.search-shell:focus-within #history-box { border-color: var(--accent); }
.search-shell.expanded { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.search-row { display: flex; align-items: center; padding: 10px 10px 10px 22px; gap: 2px; }
#repo-input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font-size: 16px; color: var(--text); padding: 4px 0;
}
#repo-input::placeholder { color: var(--muted); }
.search-sep { width: 1px; height: 26px; background: var(--capsule-border); margin: 0 4px; flex: none; }
.icon-btn {
  border: none; background: none; cursor: pointer; color: var(--muted);
  padding: 8px; line-height: 0; border-radius: 50%; font-size: 18px; flex: none;
}
.icon-btn:hover { background: var(--row-hover); color: var(--text); }
.icon-btn.accent { color: var(--accent); }
.icon-btn.accent:hover { background: var(--row-hover); }

/* ===== 历史记录（浮层，与搜索框拼成完整胶囊）===== */
#history-box {
  position: absolute; top: calc(100% - 1px); left: -1px; right: -1px;
  background: var(--capsule-bg);
  border: 1px solid var(--capsule-border);
  border-top: none;
  border-radius: 0 0 24px 24px;
  box-shadow: 0 6px 18px rgba(32, 33, 36, .16);
  padding: 6px;
  z-index: 40;
}
#history-list { list-style: none; margin: 0; padding: 0; }
.history-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 999px;
  font-size: 13px; color: var(--text); cursor: pointer;
}
.history-item:hover { background: var(--row-hover); }
.history-item .icon-history { opacity: .55; font-size: 14px; }
.history-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-del {
  opacity: 0; border: none; background: none; cursor: pointer;
  color: var(--muted); padding: 2px 6px; border-radius: 50%; font-size: 12px; line-height: 1.4;
}
.history-item:hover .history-del,
.history-item:focus-within .history-del { opacity: 1; }
.history-del:hover { color: #d93025; background: rgba(217, 48, 37, .08); }
.history-foot { display: flex; justify-content: center; border-top: 1px solid var(--capsule-border); margin-top: 4px; padding: 8px 0 4px; }
#history-clear {
  border: none; background: none; cursor: pointer; color: var(--accent);
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 5px;
}
#history-clear:hover { background: var(--row-hover); }

#status { color: var(--muted); font-size: 13px; min-height: 20px; margin: 12px 0 0; text-align: center; }

/* ===== 输入控件（设置模态/附件搜索沿用）===== */
input[type="password"], input[type="number"], input[type="search"], select {
  padding: 9px 11px;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  width: 100%;
  background: rgba(255, 255, 255, .35);
  color: var(--text);
}
@media (prefers-color-scheme: dark) {
  input[type="password"], input[type="number"], input[type="search"], select {
    background: rgba(255, 255, 255, .06);
  }
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

select option { background: #ffffff; color: #1f2328; }
@media (prefers-color-scheme: dark) {
  select option { background: #1e212a; color: #e6edf3; }
}

button { font-size: 14px; cursor: pointer; }
.btn, button:where(:not(.link-btn, .icon-btn, .fab, .history-del, .btn-primary)) {
  border: 1px solid var(--btn-border);
  background: var(--surface);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text);
}
.btn:hover, button:where(:not(.link-btn, .icon-btn, .fab, .history-del, .btn-primary)):hover { background: var(--row-hover); }
button:disabled { opacity: .6; cursor: not-allowed; }
.link-btn { background: none; border: none; color: var(--accent); text-decoration: underline; padding: 4px; }

/* ===== 结果区（沿用原样式）===== */
.card-block { padding: 18px 16px; }
.release-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.release-head h2 { margin: 0; font-size: 18px; }
.badge { background: var(--surface); border: 1px solid var(--surface-border); border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--muted); }
.badge.prerelease { background: #fff8c5; border-color: #eac54f; color: #7a5d00; }
.meta { color: var(--muted); font-size: 13px; }
#body-wrap { margin: 12px 0; }
#body-content.body { line-height: 1.7; }
#body-content { overflow-x: auto; word-break: break-word; }
#body-content pre { white-space: pre-wrap; word-break: break-all; }
#body-content img { max-width: 100%; height: auto; }
#body-content h1 { font-size: 22px; }
#body-content a { color: var(--accent); text-decoration: none; }
#body-content a:hover { text-decoration: underline; }
#body-more { margin-top: 4px; }
.assets-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0 4px; }
.assets-head input { max-width: 300px; }
#asset-search {
  border-color: var(--btn-border);
  background: var(--capsule-bg);
  box-shadow: 0 1px 3px rgba(32, 33, 36, .08);
}
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.filter-row button.active { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.asset { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-bottom: 1px solid var(--surface-border); flex-wrap: wrap; }
.asset:hover { background: var(--row-hover); }
.asset-name { flex: 1; min-width: 180px; color: var(--accent); text-decoration: none; word-break: break-all; }
.asset-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.asset-actions { display: flex; gap: 8px; width: 240px; }
.asset-actions .btn { flex: 1; text-align: center; text-decoration: none; }
#release-select { max-width: min(360px, 100%); width: auto; }

/* ===== 手机适配：阻断 min-content 撑破布局 ===== */
#app > *, #app > * > * { min-width: 0; }
.card-block { min-width: 0; }
.release-head, .assets-head, .meta, .filter-row { max-width: 100%; }
.assets-head input { max-width: min(300px, 100%); }

/* ===== 悬浮按钮组 ===== */
#fab-group {
  position: fixed; right: 18px; bottom: 64px; z-index: 25;
  display: flex; flex-direction: column; gap: 10px;
}
.fab {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--capsule-bg); border: 1px solid var(--btn-border);
  box-shadow: 0 2px 10px rgba(32, 33, 36, .18);
  display: flex; align-items: center; justify-content: center;
  color: var(--text); font-size: 20px;
  transition: color .15s ease, background-color .15s ease, border-color .15s ease;
}
.fab:hover { color: var(--accent); border-color: var(--accent); background: var(--row-hover); }
body.mode-home #top-btn, body.mode-home #bottom-btn { display: none; }

/* ===== 设置模态 ===== */
.modal-mask {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(15, 18, 25, .35);
  display: flex; align-items: center; justify-content: center;
}
@media (prefers-color-scheme: dark) {
  .modal-mask { background: rgba(0, 0, 0, .5); }
}
.modal { width: 320px; max-width: 86%; padding: 18px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 15px; }
.modal label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.modal-foot { display: flex; justify-content: flex-end; margin-top: 4px; }
.btn-primary {
  padding: 8px 22px; border-radius: 999px; border: none;
  background: var(--accent); color: var(--accent-fg); font-size: 13px;
}
.btn-primary:hover { filter: brightness(1.05); }

/* ===== 底部 footer ===== */
#site-footer {
  padding: 14px 24px; border-top: 1px solid var(--surface-border);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px;
  color: var(--muted); font-size: 12px;
}
#site-footer a { color: var(--muted); }

[hidden] { display: none !important; }

@media (max-width: 480px) {
  .hero-title { font-size: 24px !important; }
  body.mode-results .hero-title { font-size: 14px !important; white-space: normal; }
  body.mode-results #repo-form { display: block; }
  body.mode-results #hero-card { display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding-right: 0; }
  body.mode-results #status { flex-basis: auto; width: 100%; }
  .asset-actions { width: 100%; }
  .card-block { padding: 14px 12px; }
  .assets-head { flex-direction: column; align-items: stretch; }
  .assets-head input { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
