:root {
  --bg: #0f1115;
  --card: #1a1d24;
  --card-hover: #222630;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --muted: #9099a8;
  --accent: #4c8dff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 24px;
}

header { max-width: 1200px; margin: 0 auto 20px; }
header h1 { margin: 0 0 4px; font-size: 1.5rem; }
.hint { margin: 0; color: var(--muted); font-size: 0.9rem; }

main { max-width: 1200px; margin: 0 auto; }

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

.card {
  margin: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: background 0.15s, transform 0.15s;
}
.card:hover { background: var(--card-hover); transform: translateY(-2px); }

.preview {
  aspect-ratio: 4 / 3;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.preview img,
.preview video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

figcaption {
  padding: 8px 12px 0;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actions {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
}
.actions button {
  flex: 1;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #232733;
  color: var(--text);
  border-radius: 8px;
  padding: 7px 6px;
  font-size: 0.85rem;
  transition: background 0.15s, border-color 0.15s;
}
.actions button:hover { background: var(--accent); border-color: var(--accent); }
.actions button:active { transform: scale(0.97); }

.empty { color: var(--muted); text-align: center; padding: 60px 0; }
.empty code { background: var(--card); padding: 2px 6px; border-radius: 4px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: #232733;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: #ff5c5c; }
