:root {
  color-scheme: light dark;
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --accent: #4f46e5;
  --border: #e5e7eb;
  --radius-card: 14px;
  --radius-btn: 9px;
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, .08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --text: #e8eaed;
    --text-muted: #9aa1ac;
    --accent: #818cf8;
    --border: #262b36;
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

.site-header { padding: 48px 0 32px; border-bottom: 1px solid var(--border); }
.brand { font-size: 30px; font-weight: 700; letter-spacing: -.04em; color: var(--text); text-decoration: none; }
.tagline { margin: 6px 0 0; color: var(--text-muted); font-size: 15px; }

main.wrap { padding: 48px 24px 96px; }

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

.card {
  display: block;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius-card);
  transition: transform .15s ease, box-shadow .15s ease;
}

.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }

.cover {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--surface);
}

.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, hsl(var(--hue) 70% 88%), hsl(calc(var(--hue) + 40) 70% 78%));
}

@media (prefers-color-scheme: dark) {
  .placeholder {
    background: linear-gradient(135deg, hsl(var(--hue) 40% 26%), hsl(calc(var(--hue) + 40) 40% 18%));
  }
}

.placeholder span { font-size: 48px; font-weight: 600; color: rgba(255, 255, 255, .8); }

.badge {
  position: absolute; left: 12px; bottom: 12px;
  font-size: 10px; font-weight: 600; letter-spacing: .08em;
  padding: 2px 8px; border-radius: 99px;
  background: rgba(0, 0, 0, .55); color: #fff;
}

.pin { position: absolute; right: 12px; top: 12px; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.5); }

.card-body { padding: 16px 4px; }
.card-body h3 { margin: 0; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-body p {
  margin: 6px 0 0; font-size: 14px; color: var(--text-muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.empty { text-align: center; padding: 120px 0; }
.empty h2 { font-size: 22px; font-weight: 500; margin: 0; }
.empty p { color: var(--text-muted); margin: 12px 0 0; }

.site-footer { border-top: 1px solid var(--border); padding: 24px 0; color: var(--text-muted); font-size: 13px; }

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 40px;
  width: 360px;
  display: flex; flex-direction: column; gap: 16px;
}

.login-card h1 { margin: 0 0 8px; font-size: 24px; letter-spacing: -.03em; text-align: center; }

.login-card input[type="password"] {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-btn);
  background: var(--bg); color: var(--text); font-size: 15px;
}

.login-card button {
  padding: 12px; border: none; border-radius: var(--radius-btn);
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}

.login-error { margin: 0; color: #ef4444; font-size: 14px; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.admin-entry { color: var(--text-muted); opacity: .45; transition: opacity .15s; display: inline-flex; }
.admin-entry:hover { opacity: 1; }

[hidden] { display: none !important; }
.icon { display: block; flex: none; }

.brand { display: inline-flex; align-items: center; gap: 8px; }
.card { position: relative; }
.card-external {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .55); color: #fff;
}
.pin { top: auto; bottom: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-btn);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 500; line-height: 1.4; text-decoration: none; cursor: pointer;
  transition: border-color .15s, background .15s, color .15s, filter .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { border-color: transparent; background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); }
.btn.danger { border-color: transparent; background: transparent; color: #ef4444; }
.btn.danger:hover { background: color-mix(in srgb, #ef4444 12%, transparent); border-color: transparent; }
.icon-btn { padding: 8px; }
.icon-btn.is-active { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 2px dashed var(--border); border-radius: var(--radius-card);
  background: var(--surface); padding: 44px 24px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}
.dropzone-icon { color: var(--text-muted); }
.dropzone p { margin: 0; }
.dropzone .muted { font-size: 13px; }

.link-row { display: flex; gap: 12px; margin: 24px 0 40px; }
.link-row input {
  flex: 1; min-width: 0; padding: 11px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-btn);
  background: var(--surface); color: var(--text); font-size: 14px;
}
.link-row input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); outline-offset: 1px; }

.list { display: flex; flex-direction: column; gap: 12px; }
.row {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); padding: 12px 16px;
}
.thumb { width: 72px; height: 48px; object-fit: cover; border-radius: 8px; background: var(--bg); flex: none; }
.row-main { flex: 1; min-width: 160px; display: flex; flex-direction: column; }
.row-main .muted { font-size: 13px; color: var(--text-muted); }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; }

.editor {
  flex-basis: 100%; display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  padding-top: 16px; border-top: 1px solid var(--border);
}
.editor label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); }
.editor input {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-btn);
  background: var(--bg); color: var(--text); font-size: 14px; width: 100%;
}
.editor .btn { align-self: end; justify-self: start; }

.empty.small { padding: 48px 0; }

[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  font-size: 12px; font-weight: 500; line-height: 1;
  padding: 6px 8px; border-radius: 6px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .12s ease .04s;
  z-index: 20;
}
[data-tip]::before {
  content: "";
  position: absolute; bottom: calc(100% + 3px); left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--text); border-bottom: 0;
  opacity: 0; pointer-events: none; transition: opacity .12s ease .04s;
  z-index: 20;
}
[data-tip]:hover::after, [data-tip]:hover::before,
[data-tip]:focus-visible::after, [data-tip]:focus-visible::before { opacity: 1; }

.editor .field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); }
.file-picker { display: flex; align-items: center; gap: 10px; min-width: 0; }
.file-button {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 9px 12px; border: 1px dashed var(--border); border-radius: var(--radius-btn);
  background: var(--surface); color: var(--text); font-size: 13px; font-weight: 500;
  font-family: inherit; cursor: pointer; transition: border-color .15s, color .15s, background .15s;
}
.file-button:hover { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.file-name {
  font-size: 12px; color: var(--text-muted);
  max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
