:root {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

body {
  margin: 0;
  background: #fafafa;
  color: #1a1a1a;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

h1 {
  font-size: 1.6rem;
}

.dropzone {
  border: 3px dashed #c3c3c3;
  border-radius: 12px;
  padding: 2.5rem 1rem;
  text-align: center;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone.drag {
  border-color: #4f7cff;
  background: #eef3ff;
}

.pick-btn {
  font-size: 1.1rem;
  padding: 0.9rem 1.4rem;
  border: 0;
  border-radius: 10px;
  background: #4f7cff;
  color: #fff;
  cursor: pointer;
}

.dropzone .hint {
  color: #666;
  margin: 0.8rem 0 0;
}

.file-list {
  list-style: none;
  padding: 0;
  margin: 1.2rem 0;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #eee;
}

.file-row .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row .status {
  font-size: 0.85rem;
  color: #666;
}

.file-row[data-status="done"] .status { color: #1a7f37; }
.file-row[data-status="duplicate"] .status { color: #9a6700; }
.file-row[data-status="failed"] .status { color: #cf222e; }

.summary {
  background: #f0f6ff;
  border: 1px solid #cfe0ff;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin: 1rem 0;
}

.actions {
  display: flex;
  gap: 0.6rem;
}

.actions button {
  padding: 0.6rem 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

/* --- admin --- */
.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card {
  background: #fff;
  border: 1px solid #e3e3e3;
  border-radius: 10px;
  padding: 1rem 1.2rem;
  margin: 1rem 0;
}

.create-form label,
.create-form input,
.inline-form input[type="text"] {
  display: block;
  margin: 0.4rem 0;
}

.create-form input[type="text"],
.create-form input[type="datetime-local"],
.inline-form input[type="text"] {
  padding: 0.5rem;
  width: 100%;
  max-width: 360px;
  box-sizing: border-box;
}

.inline-form {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0.35rem 0.6rem 0.35rem 0;
}

table.events {
  width: 100%;
  border-collapse: collapse;
}

table.events th,
table.events td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid #eee;
  font-size: 0.92rem;
}

.badge {
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  text-transform: capitalize;
}
.badge.active { background: #e6f4ea; color: #1a7f37; }
.badge.disabled { background: #fbe9e7; color: #b3261e; }
.badge.expired { background: #f3f0e8; color: #8a6d00; }

button.danger {
  border-color: #cf222e;
  color: #cf222e;
  background: #fff;
}

.error { color: #cf222e; }
.qr img { border: 1px solid #eee; }

/* --- file grid --- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.9rem;
}

.tile {
  margin: 0;
  position: relative;
  border: 1px solid #e3e3e3;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.tile img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  cursor: pointer;
  background: #eee;
}

.tile .play {
  position: absolute;
  top: 50px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 2rem;
  color: #fff;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
  pointer-events: auto;
  cursor: pointer;
}

.tile figcaption {
  padding: 0.4rem 0.5rem;
  font-size: 0.78rem;
}

.tile .fn {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.tile figcaption small { color: #666; }

.tile .audit {
  display: block;
  margin-top: 0.25rem;
  padding-top: 0.25rem;
  border-top: 1px dashed #e3e3e3;
  color: #8a6d00;
  font-size: 0.72rem;
  word-break: break-word;
}

button.danger.small {
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  margin-top: 0.3rem;
}

/* --- lightbox --- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

/* The `hidden` attribute must win over the display:flex above, otherwise the
   overlay is always visible and can never be closed. */
.lightbox[hidden] {
  display: none;
}

.lb-content img,
.lb-content video {
  max-width: 92vw;
  max-height: 82vh;
}

.lb-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 1.4rem;
  background: transparent;
  border: 0;
  color: #fff;
  cursor: pointer;
}

.lb-download {
  margin-top: 1rem;
  color: #fff;
  text-decoration: underline;
}

.btn-link {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  background: #4f7cff;
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
}

.stale {
  background: #fff6e5;
  border: 1px solid #ffd596;
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
}

.error-card { border-color: #f3b0b0; background: #fff5f5; }
