/* Spen Tracker — dark grid like artistgrid.cx */
:root {
  --bg: #000000;
  --surface: #0a0a0a;
  --card: #171717;
  --border: #262626;
  --muted: #737373;
  --muted-2: #a3a3a3;
  --text: #ffffff;
  --text-dim: #d4d4d4;
  --accent: #ffffff;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: 'IBM Plex Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }

a { color: inherit; text-decoration: none; }

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(0,0,0,0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  height: 52px;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
}
.logo { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.logo-main { font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.logo-sub { font-weight: 500; font-size: 11px; letter-spacing: 0.08em; color: var(--muted); }

.search-wrap {
  flex: 0 1 520px;
  max-width: 520px;
  height: 34px;
  background: #111111;
  border: 1px solid #1e1e1e;
  border-radius: 10px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 8px;
  margin-left: 6px;
}
.search-wrap:focus-within { border-color: #404040; }
.search-icon { color: var(--muted); font-size: 16px; line-height: 1; }
.search-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}
.search-wrap input::placeholder { color: var(--muted); }

.header-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.route-label { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: #525252; }
.admin-link {
  font-size: 13px;
  font-weight: 600;
  background: #fff;
  color: #000;
  padding: 6px 14px;
  border-radius: 8px;
  line-height: 1;
}
.admin-link.secondary { background: transparent; color: var(--muted-2); border: 1px solid var(--border); }
.admin-link.secondary:hover { color: #fff; border-color: #404040; }

/* Main grid — 4 per row, bigger squares */
.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}
.grid.mini { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }

.tile {
  background: #0f0f0f;
  border: 1px solid #1e1e1e;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s ease;
}
.tile:hover { border-color: #2a2a2a; }
.tile-img-wrap {
  aspect-ratio: 1 / 1;
  background: #0a0a0a;
  overflow: hidden;
}
.tile-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}
.tile:hover .tile-img-wrap img { transform: scale(1.03); }
.tile-footer {
  height: 36px;
  min-height: 36px;
  background: #0a0a0a;
  border-top: 1px solid #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  gap: 8px;
}
.tile-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.tile-icon {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: #3a3a3a;
  display: grid;
  place-items: center;
}
.tile-icon svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.6; }

@media (max-width: 900px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 80px 20px 40px;
  max-width: 520px;
  margin: 0 auto;
}
.empty-state.hidden { display: none; }
.empty-icon { font-size: 42px; color: #404040; margin-bottom: 10px; }
.empty-state h2 { margin: 0 0 8px; font-size: 18px; font-weight: 700; color: var(--text-dim); }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

/* Person page — media spread like screenshot (masonry, dark bg like home) */
.person-header {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 20px 12px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.person-header .back-btn {
  width: 32px; height: 32px; display: grid; place-items: center;
  background: #111; border: 1px solid #1e1e1e; border-radius: 8px; color: #a3a3a3; cursor: pointer;
}
.person-header .back-btn:hover { color: #fff; border-color: #2a2a2a; }
.person-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.person-count { font-size: 12px; color: #737373; margin-left: 6px; font-weight: 400; }
.media-masonry {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 20px 40px;
  column-count: 4;
  column-gap: 12px;
}
@media (max-width: 900px) { .media-masonry { column-count: 3; } }
@media (max-width: 640px) { .media-masonry { column-count: 2; } }
@media (max-width: 420px) { .media-masonry { column-count: 1; } }
.media-item {
  break-inside: avoid;
  margin-bottom: 12px;
  background: #0f0f0f;
  border: 1px solid #1e1e1e;
  border-radius: 12px;
  overflow: hidden;
}
.media-item img, .media-item video { width: 100%; height: auto; display: block; background: #000; }
.media-item video { max-height: 70vh; object-fit: contain; }
.media-item .video-wrap { position: relative; background: #000; }
.media-item .video-wrap video { width: 100%; display: block; }
.media-item .mute-badge {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,0.7); border: 1px solid #333; color: #fff;
  font-size: 11px; font-weight: 600; padding: 4px 7px; border-radius: 6px;
  cursor: pointer; backdrop-filter: blur(4px);
}
.media-item .mute-badge:hover { background: rgba(20,20,20,0.9); }
.media-item .media-caption {
  padding: 8px 10px;
  font-size: 12px; color: #a3a3a3; line-height: 1.4;
  border-top: 1px solid #1a1a1a; background: #0a0a0a;
}
.media-empty {
  text-align: center; padding: 40px 20px; color: #525252; font-size: 13px;
}

/* Admin page */
.admin-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 16px 40px;
}
.admin-card {
  background: #171717;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.admin-card-head {
  padding: 20px 20px 0;
}
.admin-card-head h1 { margin: 0 0 6px; font-size: 20px; font-weight: 700; }
.admin-card-head p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.admin-form { padding: 20px; display: flex; flex-direction: column; gap: 0; }
.field-label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: var(--muted-2); margin-top: 14px; margin-bottom: 6px; display: block; }
.field {
  background: #0a0a0a;
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 10px;
}
.field:focus-within { border-color: #404040; }
.field input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
}
.field input::placeholder { color: #525252; }

.upload-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.upload-btn {
  font-size: 13px;
  font-weight: 600;
  background: #0a0a0a;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.upload-btn:hover { border-color: #404040; color: #fff; }
.file-name { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }
.hint { margin: 8px 0 0; color: #525252; font-size: 11px; line-height: 1.4; }

.preview-wrap { margin-top: 16px; }
.preview { display: flex; gap: 12px; align-items: center; margin-top: 6px; }
.preview-img-wrap {
  width: 64px;
  height: 64px;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: none; }
.preview-img-wrap.has-image img { display: block; }
.preview-placeholder { font-size: 11px; color: #525252; }
.preview-img-wrap.has-image .preview-placeholder { display: none; }
.preview-name { font-size: 14px; font-weight: 700; }
.preview-sub { font-size: 11px; color: var(--muted); }

.status-msg { min-height: 18px; margin-top: 12px; font-size: 12px; }
.status-msg.error { color: #f87171; }
.status-msg.success { color: #4ade80; }

.submit-btn {
  margin-top: 10px;
  width: 100%;
  height: 38px;
  background: #fff;
  color: #000;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.submit-btn:hover { background: #e5e5e5; }
.clear-btn {
  margin-top: 8px;
  width: 100%;
  height: 36px;
  background: transparent;
  color: #737373;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.clear-btn:hover { color: #f87171; border-color: #7f1d1d; }

.admin-list-head { padding: 16px 20px 8px; border-top: 1px solid var(--border); }
.admin-list-head h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted-2); }
#adminGrid { padding: 0 20px 20px; }

.site-footer {
  text-align: center;
  padding: 28px 16px 32px;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: #525252;
  border-top: 1px solid #111;
  margin-top: 24px;
}

@media (max-width: 640px) {
  .search-wrap { display: none; }
}
