* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  background: #0f0f10;
  color: #f2f2f2;
  padding-bottom: 100px;
}

/* Auth pages */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 320px; }
.auth-card h1 { text-align: center; margin-bottom: 8px; font-size: 22px; }
.auth-card input, .auth-card button { padding: 14px; font-size: 16px; border-radius: 10px; border: 1px solid #333; }
.auth-card input { background: #1b1b1d; color: #fff; }
.auth-card button { background: #1db954; color: #000; font-weight: 600; border: none; }
.auth-switch { text-align: center; color: #9c9c9c; font-size: 14px; margin-top: 6px; }
.error { color: #ff6161; font-size: 14px; text-align: center; }

/* Header */
header { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px; }
header h1 { font-size: 20px; margin: 0; }
.header-actions { display: flex; align-items: center; gap: 14px; }
.link-btn { background: none; border: none; color: #9c9c9c; font-size: 14px; }
#settings-btn { font-size: 18px; color: #ddd; }

/* Grid */
.grid {
  display: grid;
  gap: 4px;
  padding: 4px;
}
.grid.size-small { grid-template-columns: repeat(4, 1fr); }
.grid.size-medium { grid-template-columns: repeat(3, 1fr); }
.grid.size-large { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) {
  .grid.size-small { grid-template-columns: repeat(8, 1fr); }
  .grid.size-medium { grid-template-columns: repeat(6, 1fr); }
  .grid.size-large { grid-template-columns: repeat(4, 1fr); }
}
.grid-item {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  background: #222;
}
/* Card images (cover + code bar) are slightly taller than square --
   show the whole thing rather than cropping the code bar off. */
.grid-item img { width: 100%; height: auto; display: block; }
.grid-item.dragging { opacity: 0.4; }

/* Floating add button */
.fab {
  position: fixed;
  right: 20px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #1db954;
  color: #000;
  font-size: 30px;
  border: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal.hidden { display: none; }
.modal-card {
  background: #17171a;
  width: 100%;
  max-width: 480px;
  border-radius: 16px 16px 0 0;
  padding: 16px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-header { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.modal-title { flex: 1; margin: 0; font-size: 17px; }
#search-input { flex: 1; padding: 12px; border-radius: 10px; border: 1px solid #333; background: #1b1b1d; color: #fff; font-size: 16px; }
.close-btn { background: none; border: none; color: #ccc; font-size: 24px; line-height: 1; }

.pref-group { margin-bottom: 18px; }
.pref-label { font-size: 13px; color: #9c9c9c; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.03em; }
.segmented { display: flex; background: #1b1b1d; border-radius: 10px; padding: 3px; gap: 3px; }
.segmented button {
  flex: 1;
  padding: 10px 6px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #ccc;
  font-size: 14px;
}
.segmented button.active { background: #1db954; color: #000; font-weight: 600; }

.export-textarea {
  width: 100%;
  min-height: 220px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #333;
  background: #1b1b1d;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  margin-bottom: 12px;
}
.copy-status { min-height: 18px; text-align: center; font-size: 13px; }

.search-results { display: flex; flex-direction: column; gap: 8px; }
.result-row { display: flex; gap: 12px; align-items: center; padding: 8px; border-radius: 10px; }
.result-row:active { background: #232326; }
.result-row img { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; }
.result-meta .title { font-weight: 600; }
.result-meta .sub { color: #9c9c9c; font-size: 13px; }

.info-card { text-align: center; position: relative; }
.info-cover { width: 60%; max-width: 260px; border-radius: 10px; margin: 8px auto 12px; display: block; }
.muted { color: #9c9c9c; margin: 2px 0; }
.info-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.btn { display: inline-block; padding: 12px; border-radius: 10px; background: #2a2a2d; color: #fff; text-decoration: none; border: none; font-size: 15px; }
.btn.danger { background: #4a1f1f; color: #ff8b8b; }
