/* ===== 预设下载页 ===== */
.presets-page {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
.presets-page main {
  flex: 1;
}

.preset-hero {
  padding: 72px 0 28px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(50% 60% at 85% 0%, rgba(47,107,255,0.06), transparent 70%);
}
.preset-hero h1 {
  font-size: clamp(30px, 4.4vw, 46px);
  letter-spacing: -0.03em;
  margin: 14px 0 14px;
  font-weight: 680;
}
.preset-hero p {
  color: var(--ink-2);
  font-size: 17px;
  margin: 0;
  white-space: nowrap;
}

.preset-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 40px;
  padding: 40px 0 96px;
  align-items: start;
}

/* 侧栏：应用列表 */
.app-rail {
  position: sticky;
  top: 80px;
}
.app-rail h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 12px;
  font-weight: 600;
}
.app-list { display: flex; flex-direction: column; gap: 2px; }
.app-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s ease;
  text-align: left;
  width: 100%;
  background: none;
  font: inherit;
  color: inherit;
}
.app-item:hover { background: var(--bg-soft); }
.app-item.active { background: var(--bg-sunken); border-color: var(--line); }
.app-item img,
.app-item .ph {
  width: 30px; height: 30px;
  border-radius: 7px;
  object-fit: cover;
  flex: none;
  background: var(--bg-sunken);
  display: grid; place-items: center;
  border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.app-item .meta { min-width: 0; }
.app-item .meta strong { display: block; font-size: 14px; font-weight: 550; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-item .meta span { font-size: 12px; color: var(--muted); }

.rail-divider {
  height: 1px;
  background: var(--line);
  margin: 18px 0 16px;
}
.rail-scripts-item { margin-top: 2px; }
.scripts-ph {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  color: var(--accent);
}
.scripts-ph-lg {
  width: 52px;
  height: 52px;
  border-radius: 11px;
  font-size: 22px;
}
.scripts-main .script-safe-hint { margin-bottom: 22px; }

/* 主区 */
.preset-main {
  min-width: 0;
  min-height: 320px;
  transition: opacity 0.18s ease;
}
.preset-main.is-loading {
  opacity: 0.72;
  pointer-events: none;
}
.preset-main-body {
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.preset-main-body.is-entering {
  opacity: 0;
  transform: translateY(6px);
}
.preset-main-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 22px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--line);
}
.preset-main-head img,
.preset-main-head .ph {
  width: 52px; height: 52px; border-radius: 11px; flex: none;
  border: 1px solid var(--line);
  background: var(--bg-sunken);
  display: grid; place-items: center;
  font-size: 20px; font-weight: 600; color: var(--muted);
  object-fit: cover;
}
.preset-main-head-text {
  min-width: 0;
  flex: 1;
}
.preset-main-head h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preset-main-head .app-desc {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.preset-main-head .app-desc.is-clamped {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.preset-main-head .app-desc.is-clamped.is-expanded {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}
.app-desc-toggle {
  margin-top: 6px;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
}
.app-desc-toggle:hover { text-decoration: underline; }

.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  align-items: start;
}
.preset-card {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  background: var(--bg);
  cursor: pointer;
}
.preset-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.preset-card:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.12);
}
.preset-card .pc-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.preset-card h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  min-width: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preset-card .dl-count {
  font-size: 12px; color: var(--muted);
  border: 1px solid var(--line);
  padding: 3px 8px; border-radius: var(--r-pill);
  white-space: nowrap;
}
.preset-card .desc {
  font-size: 14px;
  color: var(--ink-2);
  margin: 10px 0 0;
  line-height: 1.55;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
}
.preset-card .pc-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.preset-card .pc-preview-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.preset-card:hover .pc-preview-hint { color: var(--accent-ink); }

/* 轮盘预览 */
.wheel-loading,
.wheel-error {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 28px 12px;
  border: 1px dashed var(--line);
  border-radius: var(--r-sm);
}
.wheel-error { color: #b42318; border-color: rgba(180, 35, 24, 0.25); }

.wheel-preview { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.wheel-summary {
  margin: 0;
  width: 100%;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
}
.wheel-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.wheel-canvas {
  width: min(220px, 100%);
  margin-inline: auto;
}
.preset-modal-wheel .wheel-canvas {
  width: min(280px, 100%);
}
.preset-wheel-svg {
  width: 100%;
  height: auto;
  display: block;
  user-select: none;
}
.wheel-sector { cursor: pointer; }
.wheel-sector-path {
  fill: #fafbfc;
  stroke: rgba(10, 11, 13, 0.09);
  stroke-width: 1;
  transition: fill 0.12s ease, stroke 0.12s ease;
}
.wheel-sector:hover:not(.is-active) .wheel-sector-path { fill: #f3f5f8; }
.wheel-sector.is-active .wheel-sector-path {
  fill: #e8efff;
  stroke: var(--accent);
  stroke-width: 2;
}
.wheel-sector:focus { outline: none; }
.wheel-sector:focus:not(.is-active) .wheel-sector-path { stroke: rgba(47, 107, 255, 0.35); }
.wheel-sector-num {
  font-size: 10px;
  fill: var(--muted);
  font-weight: 600;
  pointer-events: none;
}
.wheel-sector-label {
  font-size: 11px;
  fill: var(--ink);
  font-weight: 550;
  pointer-events: none;
}

.wheel-detail-host { width: 100%; }
.sector-detail {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-soft);
  padding: 12px 14px;
  text-align: left;
}
.sector-detail.is-placeholder {
  background: transparent;
  border-style: dashed;
  text-align: center;
}
.sector-detail.is-placeholder p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.sd-head { margin-bottom: 10px; }
.sd-index {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-right: 8px;
}
.sd-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-ink);
  background: rgba(47, 107, 255, 0.1);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  margin-right: 6px;
}
.sd-head h5 {
  margin: 8px 0 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.sd-body { font-size: 13px; color: var(--ink-2); }
.sd-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px 12px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}
.sd-row:first-child { border-top: none; padding-top: 0; }
.sd-dt { color: var(--muted); font-size: 12px; }
.sd-dd { color: var(--ink); line-height: 1.5; word-break: break-word; }
.sd-dd.is-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.sd-row.is-multiline .sd-dd { white-space: pre-wrap; }

.sd-folder-hint,
.sd-empty-hint {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.5;
}
.sd-folder-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sd-folder-list li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 4px 8px;
  align-items: baseline;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}
.sd-folder-list li.is-empty { opacity: 0.65; }
.sd-folder-list li > span {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--bg-sunken);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.sd-folder-list strong { grid-column: 2; font-weight: 600; color: var(--ink); }
.sd-folder-list em {
  grid-column: 2;
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
}
.preset-card .author { font-size: 12px; color: var(--muted); }

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--r);
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
}
.empty svg { width: 34px; height: 34px; stroke: var(--line-strong); margin-bottom: 12px; }
.empty p { margin: 0; font-size: 14px; }

.hint-bar {
  display: flex; gap: 10px; align-items: center;
  font-size: 13px; color: var(--muted);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 11px 14px;
  margin-bottom: 24px;
}
.hint-bar svg { width: 16px; height: 16px; stroke: var(--accent); flex: none; }

/* Bash 脚本区 */
.scripts-section {
  margin-top: 36px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}
.scripts-section-head { margin-bottom: 14px; }
.scripts-section-head h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.scripts-section-head p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.script-safe-hint {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--ink-2);
  background: rgba(47, 107, 255, 0.06);
  border: 1px solid rgba(47, 107, 255, 0.16);
  border-radius: var(--r-sm);
  padding: 11px 14px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.script-safe-hint svg {
  width: 18px;
  height: 18px;
  stroke: var(--accent);
  flex: none;
  margin-top: 1px;
}
.script-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  align-items: start;
}
.script-card {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px 20px;
  background: var(--bg);
  overflow: hidden;
  min-width: 0;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.script-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.script-card:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.12);
}
.script-card .sc-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.script-card h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  min-width: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.script-card .sc-desc {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
}
.script-card .script-code {
  margin: 12px 0 0;
  padding: 14px 16px;
  border-radius: var(--r-sm);
  background: #0f1115;
  color: #e8eaed;
  overflow: hidden;
  max-height: calc(1.55em * 8 + 28px);
  font-size: 12px;
  line-height: 1.55;
  tab-size: 2;
  flex: none;
}
.script-card .script-code code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: block;
}
.script-card .sc-foot {
  display: flex;
  align-items: center;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.script-card .sc-preview-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.script-card:hover .sc-preview-hint { color: var(--accent-ink); }

.script-modal .preset-modal-dialog {
  width: min(720px, 100%);
}
.script-code-full {
  margin: 0;
  padding: 14px 16px;
  border-radius: var(--r-sm);
  background: #0f1115;
  color: #e8eaed;
  max-height: min(52vh, 480px);
  overflow-x: hidden;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.55;
  tab-size: 2;
}
.script-code-full code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: block;
}
.bash-highlight .bh-comment,
.bash-highlight .bh-shebang { color: #6a9955; }
.bash-highlight .bh-string { color: #ce9178; }
.bash-highlight .bh-var { color: #9cdcfe; }
.bash-highlight .bh-kw { color: #c586c0; }
.bash-highlight .bh-cmd { color: #dcdcaa; }
.bash-highlight .bh-num { color: #b5cea8; }
.bash-highlight .bh-flag { color: #9cdcfe; }
.bash-highlight .bh-op { color: #d4d4d4; }

/* 预设预览弹窗 */
.preset-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
}
.preset-modal[hidden] { display: none; }
.preset-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 11, 13, 0.42);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.preset-modal.is-open .preset-modal-backdrop { opacity: 1; }
.preset-modal-dialog {
  position: relative;
  width: min(560px, 100%);
  max-height: min(88vh, 900px);
  overflow-x: hidden;
  overflow-y: auto;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 24px;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.preset-modal.is-open .preset-modal-dialog {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.preset-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.preset-modal-close:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}
.preset-modal-head {
  padding-right: 40px;
  margin-bottom: 18px;
  min-width: 0;
  overflow: hidden;
}
.preset-modal-head h3 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.preset-modal-desc {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.preset-modal-meta {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.preset-modal-body {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  min-width: 0;
  overflow-x: hidden;
}
.preset-modal-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
body.preset-modal-open { overflow: hidden; }

@media (max-width: 820px) {
  .preset-hero p { white-space: normal; font-size: 15px; }
  .preset-layout { grid-template-columns: 1fr; gap: 24px; }
  .app-rail { position: static; }
  .app-list { flex-direction: row; overflow-x: auto; padding-bottom: 6px; }
  .app-item { flex: none; }
  .preset-grid,
  .script-grid { grid-template-columns: 1fr; }
  .preset-modal { padding: 12px; }
  .preset-modal-dialog { padding: 18px; max-height: 92vh; }
}
