* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  background: #f5f6f8;
  color: #222;
}
.topbar {
  background: #fff;
  padding: 12px 20px;
  border-bottom: 1px solid #e4e6eb;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.topbar h1 { margin: 0; font-size: 18px; }
.platforms-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.label { font-size: 13px; color: #666; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: #e9edf4;
  border-radius: 14px;
  padding: 3px 10px 3px 10px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.chip .x { cursor: pointer; color: #999; font-weight: bold; }
.chip .x:hover { color: #c33; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 20px 0;
  background: #f5f6f8;
  align-items: center;
  border-bottom: 1px solid #e4e6eb;
}
.tab {
  background: transparent;
  border: none;
  padding: 10px 18px;
  cursor: pointer;
  font-size: 14px;
  color: #666;
  border-bottom: 2px solid transparent;
}
.tab.active { color: #0066cc; border-bottom-color: #0066cc; font-weight: 600; }
.badge {
  background: #ddd;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 11px;
  margin-left: 4px;
}
.tab.active .badge { background: #0066cc; color: #fff; }
.btn-primary {
  background: #0066cc; color: #fff; border: none; padding: 8px 14px;
  border-radius: 6px; cursor: pointer; font-size: 14px; margin-left: auto;
}
.btn-primary:hover { background: #0055aa; }
.btn-primary:disabled { background: #999; cursor: not-allowed; }
.btn-ghost {
  background: transparent; border: 1px dashed #999; padding: 4px 10px;
  border-radius: 6px; cursor: pointer; font-size: 12px; color: #555;
}
.btn-ghost:hover { background: #eee; }
.btn-danger {
  background: #d33; color: #fff; border: none; padding: 6px 12px;
  border-radius: 6px; cursor: pointer; font-size: 13px;
}

.list { padding: 16px 20px; display: grid; gap: 12px; }
.card {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  cursor: pointer;
  border: 1px solid #eaecf0;
  position: relative;
}
.card:hover { border-color: #cdd3dc; }
.card-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
}
.card h3 { margin: 0 0 6px; font-size: 16px; flex: 1; }
.card .dl-btn {
  background: #0066cc; color: #fff; border: none;
  padding: 6px 12px; border-radius: 6px; cursor: pointer;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 4px;
}
.card .dl-btn:hover { background: #0055aa; }
.card .dl-btn:disabled { background: #aaa; cursor: not-allowed; }
.card .box-link-btn {
  background: #0061d5; color: #fff; border: none;
  padding: 6px 12px; border-radius: 6px; cursor: pointer;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  text-decoration: none; display: inline-flex; align-items: center; gap: 4px;
}
.card .box-link-btn:hover { background: #004eb0; }
.card .card-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.card .meta { font-size: 12px; color: #666; display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.card .meta .spec { color: #444; }
.card .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.card .tag { background: #e3f2fd; color: #0066cc; font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.card .photo-strip { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.card .photo-strip img { width: 60px; height: 60px; object-fit: cover; border-radius: 4px; border: 1px solid #eee; }
.card .comment { background: #fff8e1; padding: 6px 10px; border-radius: 6px; font-size: 13px; margin-top: 6px; }
.empty { text-align: center; padding: 40px; color: #999; }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 20px; z-index: 1000; overflow-y: auto;
}
.modal.hidden { display: none; }
.modal-card {
  background: #fff; border-radius: 10px; width: 100%; max-width: 640px;
  display: flex; flex-direction: column; max-height: calc(100vh - 40px);
}
.modal-head {
  padding: 14px 18px; border-bottom: 1px solid #eee;
  display: flex; justify-content: space-between; align-items: center;
}
.modal-head h2 { margin: 0; font-size: 18px; }
.close { background: none; border: none; font-size: 24px; cursor: pointer; color: #888; }
.modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.modal-body label { display: block; margin: 12px 0 4px; font-size: 13px; color: #444; font-weight: 500; }
.modal-body input, .modal-body textarea {
  width: 100%; padding: 8px 10px; font-size: 14px; border: 1px solid #ccc;
  border-radius: 6px; font-family: inherit;
}
.modal-body input:focus, .modal-body textarea:focus { outline: none; border-color: #0066cc; }

.dim-row {
  display: flex; align-items: center; gap: 6px;
}
.dim-row input {
  width: 80px; text-align: center;
}
.dim-x { color: #888; font-size: 14px; }

.modal-foot {
  padding: 12px 18px; border-top: 1px solid #eee;
  display: flex; gap: 8px; align-items: center;
}
.spacer { flex: 1; }

.chips-select { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 0; }
.chips-select .chip {
  cursor: pointer; user-select: none;
  background: #f0f2f5; padding: 5px 12px; font-size: 13px;
}
.chips-select .chip.selected { background: #0066cc; color: #fff; }

.photo-slots { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.photo-slot {
  width: 90px; height: 90px; border: 2px dashed #bbb; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  position: relative; color: #999; font-size: 11px; text-align: center;
  background: #fafbfc; transition: border-color 0.15s;
}
.photo-slot:hover, .photo-slot.focused { border-color: #0066cc; background: #f0f7ff; }
.photo-slot.has-image { border-style: solid; border-color: #0066cc; }
.photo-slot img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.photo-slot .remove-slot {
  position: absolute; top: -6px; right: -6px; background: #d33; color: #fff;
  width: 20px; height: 20px; border-radius: 50%; font-size: 14px; line-height: 18px;
  cursor: pointer; border: 2px solid #fff;
}
.photo-slot input[type=file] { display: none; }

.existing-photos { margin-top: 14px; }
.existing-photos.hidden { display: none; }
.existing-photos h4 { margin: 6px 0 6px; font-size: 13px; color: #444; }
.photo-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.photo-strip .thumb { position: relative; }
.photo-strip .thumb img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid #ddd; cursor: pointer; }
.photo-strip .thumb .del {
  position: absolute; top: -5px; right: -5px; background: #d33; color: #fff;
  width: 18px; height: 18px; border-radius: 50%; font-size: 12px; line-height: 16px;
  cursor: pointer; text-align: center; border: 1px solid #fff;
}
.photo-strip .thumb .dl {
  position: absolute; bottom: 2px; right: 2px; background: rgba(0,0,0,0.6); color: #fff;
  padding: 1px 5px; border-radius: 3px; font-size: 10px; text-decoration: none;
}

.hidden { display: none !important; }

.viewer {
  position: fixed; inset: 0; background: rgba(0,0,0,0.9);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000; cursor: pointer;
}
.viewer img { max-width: 95%; max-height: 95%; }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.status-open { background: #4caf50; }
.status-closed { background: #999; }

@media (max-width: 600px) {
  .modal { padding: 0; }
  .modal-card { max-height: 100vh; border-radius: 0; }
  .photo-slot { width: 72px; height: 72px; }
  .dim-row input { width: 60px; }
}
