* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0a0a0a;
  color: #e0e0e0;
  min-height: 100vh;
  padding-bottom: 80px;
}

/* Header */
.header {
  padding: 20px 32px;
  border-bottom: 1px solid #222;
}
.header h1 {
  font-size: 20px;
  font-weight: 600;
  color: #fff;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  padding: 12px 32px;
  border-bottom: 1px solid #222;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid #333;
  border-radius: 6px;
  color: #888;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.tab-btn:hover {
  border-color: #555;
  color: #ccc;
}
.tab-btn.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
}

/* Card Grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  padding: 24px 32px;
}

/* Card */
.card {
  background: #1e1e1e;
  border-radius: 8px;
  border: 1px solid #2a2a2a;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.card:hover {
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px #3b82f6;
}

.card-thumbnail {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  position: relative;
  background: #fff;
}
.card-thumbnail iframe {
  width: 1280px;
  height: 720px;
  transform: scale(0.234375);
  transform-origin: top left;
  border: none;
  pointer-events: none;
}

.card-info {
  padding: 12px 16px;
}
.card-info .name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}
.card-info .desc {
  font-size: 12px;
  color: #888;
  margin-top: 4px;
}

/* Modal Overlay */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}
.modal-overlay.open {
  display: flex;
}

.modal {
  width: 90vw;
  height: 80vh;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover {
  background: rgba(0,0,0,0.8);
}

.modal-body {
  flex: 1;
  overflow: hidden;
}
.modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.modal-footer {
  padding: 12px 20px;
  background: #f5f5f5;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  align-items: center;
}

/* View Toggle (PC/SP) */
.view-toggle {
  display: flex;
  gap: 4px;
  margin-right: 12px;
}
.view-btn {
  padding: 6px 14px;
  border: 1px solid #ccc;
  border-radius: 5px;
  background: #fff;
  color: #666;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.view-btn:hover {
  border-color: #999;
  color: #333;
}
.view-btn.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
}

.modal-body.sp-view {
  display: flex;
  justify-content: center;
  background: #e5e5e5;
}
.modal-body.sp-view iframe {
  width: 375px;
  max-width: 375px;
  height: 100%;
  border: none;
  box-shadow: 0 0 20px rgba(0,0,0,0.15);
}

.btn-select {
  padding: 10px 24px;
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-select:hover {
  background: #2563eb;
}

/* Bottom Bar */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #111;
  border-top: 1px solid #333;
  z-index: 900;
  transition: height 0.2s;
}
.bottom-bar.empty {
  height: 40px;
}
.bottom-bar.has-items {
  min-height: 60px;
}

.bottom-bar-inner {
  display: flex;
  align-items: center;
  padding: 8px 24px;
  gap: 12px;
  height: 100%;
}

.bottom-label {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
}

.selected-chips {
  display: flex;
  gap: 8px;
  flex: 1;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0;
}
.selected-chips::-webkit-scrollbar { display: none; }

.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 6px;
  font-size: 12px;
  color: #e0e0e0;
  white-space: nowrap;
  cursor: grab;
  user-select: none;
}
.chip.dragging {
  opacity: 0.5;
}
.chip .chip-remove {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
}
.chip .chip-remove:hover {
  color: #f87171;
}

.bottom-actions {
  display: flex;
  gap: 8px;
}
.bottom-actions button {
  padding: 6px 14px;
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid #333;
  background: #1e1e1e;
  color: #ccc;
  white-space: nowrap;
  transition: all 0.15s;
}
.bottom-actions button:hover {
  border-color: #555;
  color: #fff;
}
.bottom-actions .btn-copy {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
}
.bottom-actions .btn-copy:hover {
  background: #2563eb;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #22c55e;
  color: #fff;
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 13px;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
  .card-grid {
    grid-template-columns: 1fr;
    padding: 16px;
  }
  .tabs {
    padding: 12px 16px;
  }
  .header {
    padding: 16px;
  }
}
