/* Folia 壁纸库 —— 仿 Wallpaper Engine：左侧图标栏 / 中部工具条+缩略图网格 / 右侧详情面板 */
:root {
  color-scheme: dark;
  --bg: #0c0c0f;
  --bg-2: #111114;
  --panel: #16161a;
  --panel-2: #1b1b21;
  --line: #24242b;
  --line-2: #32323c;
  --text: #e8e8ee;
  --dim: #9a9aa6;
  --faint: #6a6a76;
  --accent: #c8b6ff;
  --accent-ink: #150f2b;
  --heart: #ff6b9a;
  --tile: 240px;
  --radius: 8px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 10px; top: 10px; z-index: 99; background: var(--accent); color: var(--accent-ink); padding: 6px 12px; border-radius: 6px; }

/* ---------- 三段式骨架 ---------- */
.app {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 316px;
  height: 100vh;
}

/* ---------- 左侧图标栏 ---------- */
.rail {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 0;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
}

.rail-logo {
  width: 32px; height: 32px; margin-bottom: 10px;
  display: grid; place-items: center;
  border-radius: 9px; font-weight: 700; font-size: 15px; color: var(--accent-ink);
  background: conic-gradient(from 130deg, #c8b6ff, #7ee0d3, #c8b6ff);
}

.rail-btn {
  position: relative;
  width: 38px; height: 38px; padding: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 9px; background: transparent;
  color: var(--faint); cursor: pointer;
  transition: background .14s, color .14s;
}
.rail-btn:hover { background: #1a1a20; color: var(--text); }
.rail-btn[aria-current="true"] { background: #23232c; color: var(--accent); }
.rail-btn[aria-current="true"]::before {
  content: ""; position: absolute; left: -10px; top: 9px; bottom: 9px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.rail-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rail-gap { flex: 1; }

/* ---------- 中部 ---------- */
.content { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.search {
  display: flex; align-items: center; gap: 7px;
  flex: 0 1 240px; height: 30px; padding: 0 9px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 7px;
}
.search:focus-within { border-color: var(--line-2); }
.search svg { width: 13px; height: 13px; fill: none; stroke: var(--faint); stroke-width: 2; stroke-linecap: round; flex: none; }
.search input { width: 100%; min-width: 0; background: none; border: 0; outline: none; color: var(--text); font: inherit; }
.search input::placeholder { color: var(--faint); }

.filters { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--dim);
  cursor: pointer; white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--line-2); }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }

select, .btn {
  height: 30px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--panel); color: var(--text);
  font: inherit; font-size: 12.5px; text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background .14s, border-color .14s;
}
select:hover, .btn:hover { background: var(--panel-2); border-color: var(--line-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.wide { flex: 1 1 100%; }
.btn[aria-pressed="true"] { background: #2a1d33; border-color: #4a2f57; color: #ffb3cd; }
:where(.btn, select, input, .rail-btn, .chip, a):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.zoom { display: flex; align-items: center; gap: 6px; color: var(--faint); margin-left: auto; }
.zoom svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.zoom input { width: 90px; accent-color: var(--accent); }

#copy20 { flex: none; }

/* 网格区 */
.scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; }

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

.tile {
  position: relative; margin: 0; cursor: pointer;
  border-radius: var(--radius); overflow: hidden;
  background: var(--panel);
  border: 1px solid transparent;
  aspect-ratio: 16 / 9;
  transition: border-color .12s, transform .12s;
}
.tile:hover { border-color: var(--line-2); transform: translateY(-1px); }
.tile[aria-selected="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

.tile img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transition: opacity .2s;
  background: linear-gradient(110deg, #15151a 30%, #1d1d24 50%, #15151a 70%);
  background-size: 200% 100%;
}
.tile img.loaded { opacity: 1; }

.tile .cap {
  position: absolute; inset: auto 0 0 0;
  padding: 22px 9px 7px;
  font-size: 11.5px; color: #fff;
  background: linear-gradient(to top, rgb(0 0 0 / .82), transparent);
  opacity: 0; transition: opacity .12s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile:hover .cap, .tile[aria-selected="true"] .cap { opacity: 1; }

.tile .badge {
  position: absolute; left: 7px; top: 7px;
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px;
  background: rgb(200 182 255 / .92); color: var(--accent-ink);
}
.tile .fav {
  position: absolute; right: 6px; top: 6px;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid rgb(255 255 255 / .18); background: rgb(10 10 14 / .55);
  color: #fff; font-size: 12px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity .12s;
}
.tile:hover .fav, .tile .fav[aria-pressed="true"] { opacity: 1; }
.tile .fav[aria-pressed="true"] { color: var(--heart); border-color: rgb(255 107 154 / .5); }

.empty { padding: 70px 0; text-align: center; color: var(--dim); }
.empty p { margin: 0 0 12px; }

/* 底部状态条 */
.statusbar {
  display: flex; align-items: center; gap: 10px;
  height: 30px; padding: 0 14px;
  border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--dim);
  background: var(--bg-2);
}
.spacer { flex: 1; }
.muted { color: var(--faint); }

/* ---------- 右侧详情 ---------- */
.detail {
  border-left: 1px solid var(--line);
  background: var(--bg-2);
  display: flex; flex-direction: column;
  min-height: 0; overflow-y: auto;
}

.detail-empty { margin: auto; text-align: center; color: var(--dim); }
.detail-empty p { margin: 4px 0; }

.detail-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }

.preview {
  border-radius: var(--radius); overflow: hidden;
  background: var(--panel); border: 1px solid var(--line);
  aspect-ratio: 16 / 9;
}
.preview img { width: 100%; height: 100%; object-fit: contain; display: block; background: #0a0a0d; }

.detail h2 { margin: 0; font-size: 15px; line-height: 1.35; }

.detail dl { margin: 0; display: grid; gap: 7px; }
.detail dl div { display: grid; grid-template-columns: 58px 1fr; gap: 8px; font-size: 12px; }
.detail dt { color: var(--faint); }
.detail dd { margin: 0; color: var(--dim); word-break: break-all; }

.d-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.d-tags span { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--dim); }

.d-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }

.d-tip { margin: 0; font-size: 11px; line-height: 1.7; color: var(--faint); }
.d-tip b { color: var(--dim); }

/* ---------- 弹窗/提示 ---------- */
.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgb(4 4 7 / .72); }
.modal-card {
  width: min(500px, 92vw); padding: 22px;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px;
}
.modal-card h2 { margin: 0 0 10px; font-size: 16px; }
.modal-card ol { margin: 0 0 10px; padding-left: 18px; color: var(--dim); }
.modal-card li { margin-bottom: 5px; }
.modal-card b { color: var(--text); }
.modal-card .btn { margin-top: 4px; }

.toast {
  position: fixed; left: 50%; bottom: 42px; z-index: 80;
  transform: translate(-50%, 12px);
  padding: 8px 16px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 12.5px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .app { grid-template-columns: 56px minmax(0, 1fr); }
  .detail { position: fixed; right: 0; top: 0; bottom: 0; width: 316px; z-index: 50; box-shadow: -18px 0 40px rgb(0 0 0 / .5); transform: translateX(100%); transition: transform .18s; }
  .app.detail-open .detail { transform: none; }
}

@media (max-width: 720px) {
  .toolbar { flex-wrap: wrap; }
  .search { flex: 1 1 100%; }
  .zoom { display: none; }
  .app { grid-template-columns: 48px minmax(0, 1fr); }
  .rail-btn { width: 34px; height: 34px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
